@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Steps 1–5 of every adapter's buildOutput are platform-agnostic:
|
|
4
4
|
// 1. Copy client assets to the public/static directory
|
|
5
|
-
// 2. Write _headers file for static asset cache control
|
|
5
|
+
// 2. Write _headers file for static asset cache control, where the platform reads it
|
|
6
6
|
// 3. Copy RSC + SSR server bundles
|
|
7
7
|
// 4. Write manifest-init module (if present)
|
|
8
8
|
//
|
|
@@ -19,6 +19,7 @@ import { adapterBase, generateHeadersFile } from './shared.ts';
|
|
|
19
19
|
// `adapters/shared.ts` importing `../shared/base-path.js`.
|
|
20
20
|
import {
|
|
21
21
|
HEADERS_FILE,
|
|
22
|
+
REDIRECTS_FILE,
|
|
22
23
|
USER_MERGED_PLATFORM_FILES,
|
|
23
24
|
USER_PLATFORM_DIR,
|
|
24
25
|
} from '../shared/static-platform-files.ts';
|
|
@@ -43,6 +44,15 @@ export interface BuildOutputBaseOptions {
|
|
|
43
44
|
* Nitro uses 'public', Cloudflare uses 'static'.
|
|
44
45
|
*/
|
|
45
46
|
publicDirName: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the platform reads `_headers` and `_redirects` from the public
|
|
49
|
+
* directory (Cloudflare, Netlify). When false, the output has neither — no
|
|
50
|
+
* generated `_headers`, and not the user's `public/_headers` or
|
|
51
|
+
* `public/_redirects`, which Vite copies into the client output: on a host
|
|
52
|
+
* that does not read them they are plain files, served to anyone who asks
|
|
53
|
+
* for `/_headers` (TIM-1605).
|
|
54
|
+
*/
|
|
55
|
+
platformFiles: boolean;
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
/**
|
|
@@ -50,14 +60,14 @@ export interface BuildOutputBaseOptions {
|
|
|
50
60
|
*
|
|
51
61
|
* 1. Create the output directory
|
|
52
62
|
* 2. Copy client assets to the public/static directory
|
|
53
|
-
* 3. Write the `_headers` file for static asset cache control
|
|
63
|
+
* 3. Write the `_headers` file for static asset cache control, if `platformFiles`
|
|
54
64
|
* 4. Copy RSC and SSR server bundles into the output directory
|
|
55
65
|
* 5. Write the manifest-init module if present
|
|
56
66
|
*
|
|
57
67
|
* Returns the resolved public directory path for further adapter-specific use.
|
|
58
68
|
*/
|
|
59
69
|
export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise<string> {
|
|
60
|
-
const { config, artifacts, outDir, publicDirName } = opts;
|
|
70
|
+
const { config, artifacts, outDir, publicDirName, platformFiles } = opts;
|
|
61
71
|
|
|
62
72
|
// 1. Create the output directory.
|
|
63
73
|
await mkdir(outDir, { recursive: true });
|
|
@@ -65,9 +75,17 @@ export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise
|
|
|
65
75
|
// 2. Copy client assets to public/static directory.
|
|
66
76
|
// When client JavaScript is disabled, skip .js files — only CSS,
|
|
67
77
|
// fonts, images, and other static assets are needed.
|
|
78
|
+
// Cleaned first: the adapter output directory outlives a build, and a file
|
|
79
|
+
// an earlier build left here (a static build's pre-rendered `index.html`,
|
|
80
|
+
// a `_headers` the preset no longer reads) would otherwise ship and be
|
|
81
|
+
// served ahead of the app.
|
|
68
82
|
const publicDir = join(outDir, publicDirName);
|
|
83
|
+
await rm(publicDir, { recursive: true, force: true });
|
|
69
84
|
await mkdir(publicDir, { recursive: true });
|
|
70
85
|
const clientDir = artifacts.client.path;
|
|
86
|
+
const userPlatformFiles = new Set(
|
|
87
|
+
platformFiles ? [] : [HEADERS_FILE, REDIRECTS_FILE].map((name) => join(clientDir, name))
|
|
88
|
+
);
|
|
71
89
|
// Find WASM files that are referenced by client JS (legitimate client WASM)
|
|
72
90
|
// vs orphaned server-only WASM (e.g. @takumi-rs for OG image generation).
|
|
73
91
|
// Only strip orphaned WASM to avoid breaking client-side WASM usage.
|
|
@@ -80,6 +98,7 @@ export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise
|
|
|
80
98
|
return false;
|
|
81
99
|
}
|
|
82
100
|
if (config.clientJavascriptDisabled && src.endsWith('.js')) return false;
|
|
101
|
+
if (userPlatformFiles.has(src)) return false;
|
|
83
102
|
return true;
|
|
84
103
|
},
|
|
85
104
|
});
|
|
@@ -88,7 +107,10 @@ export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise
|
|
|
88
107
|
// Scan for unhashed files so they get per-file Cache-Control rules in the
|
|
89
108
|
// _headers file. On platforms like Cloudflare Workers Static Assets, the
|
|
90
109
|
// worker never sees static file requests — _headers is the only mechanism.
|
|
91
|
-
|
|
110
|
+
// Elsewhere nothing reads it, so its rules never applied and the file was
|
|
111
|
+
// only a public asset; the immutable header there comes from the server
|
|
112
|
+
// instead (nitro-immutable-assets.ts).
|
|
113
|
+
if (platformFiles) await writeHeadersFile(publicDir, config, artifacts);
|
|
92
114
|
|
|
93
115
|
// 4. Copy RSC + SSR server bundles into the output directory. The RSC
|
|
94
116
|
// bundle imports the SSR one by a path the RSC plugin computed between the
|
|
@@ -277,6 +277,7 @@ export function cloudflare(options: CloudflareAdapterOptions = {}): TimberPlatfo
|
|
|
277
277
|
artifacts: { ...artifacts, prebuilt: undefined },
|
|
278
278
|
outDir,
|
|
279
279
|
publicDirName: 'static',
|
|
280
|
+
platformFiles: true,
|
|
280
281
|
});
|
|
281
282
|
|
|
282
283
|
// Compile optional worker handlers (queue, scheduled, etc.)
|
|
@@ -30,6 +30,12 @@ export interface PresetConfig {
|
|
|
30
30
|
supportsWaitUntil: boolean;
|
|
31
31
|
/** Whether the runtime supports application-level 103 Early Hints. */
|
|
32
32
|
supportsEarlyHints: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the platform reads `_headers` and `_redirects` from the public
|
|
35
|
+
* directory. Everywhere else they are just public files anyone can fetch,
|
|
36
|
+
* so the build leaves them out (TIM-1605).
|
|
37
|
+
*/
|
|
38
|
+
readsPlatformFiles: boolean;
|
|
33
39
|
/** Value for TIMBER_RUNTIME env var. See design/25-production-deployments.md. */
|
|
34
40
|
runtimeName: string;
|
|
35
41
|
/** Additional nitro.config fields for this preset. */
|
|
@@ -42,6 +48,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
42
48
|
outputDir: '.vercel/output',
|
|
43
49
|
supportsWaitUntil: true,
|
|
44
50
|
supportsEarlyHints: false,
|
|
51
|
+
readsPlatformFiles: false,
|
|
45
52
|
runtimeName: 'vercel',
|
|
46
53
|
extraConfig: { vercel: { functions: { maxDuration: 30 } } },
|
|
47
54
|
},
|
|
@@ -50,6 +57,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
50
57
|
outputDir: '.vercel/output',
|
|
51
58
|
supportsWaitUntil: true,
|
|
52
59
|
supportsEarlyHints: false,
|
|
60
|
+
readsPlatformFiles: false,
|
|
53
61
|
runtimeName: 'vercel-edge',
|
|
54
62
|
},
|
|
55
63
|
'netlify': {
|
|
@@ -57,6 +65,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
57
65
|
outputDir: '.netlify/functions-internal',
|
|
58
66
|
supportsWaitUntil: false,
|
|
59
67
|
supportsEarlyHints: false,
|
|
68
|
+
readsPlatformFiles: true,
|
|
60
69
|
runtimeName: 'netlify',
|
|
61
70
|
},
|
|
62
71
|
'netlify-edge': {
|
|
@@ -64,6 +73,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
64
73
|
outputDir: '.netlify/edge-functions',
|
|
65
74
|
supportsWaitUntil: true,
|
|
66
75
|
supportsEarlyHints: false,
|
|
76
|
+
readsPlatformFiles: true,
|
|
67
77
|
runtimeName: 'netlify-edge',
|
|
68
78
|
},
|
|
69
79
|
'aws-lambda': {
|
|
@@ -71,6 +81,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
71
81
|
outputDir: '.output',
|
|
72
82
|
supportsWaitUntil: false,
|
|
73
83
|
supportsEarlyHints: false,
|
|
84
|
+
readsPlatformFiles: false,
|
|
74
85
|
runtimeName: 'aws-lambda',
|
|
75
86
|
},
|
|
76
87
|
'deno-deploy': {
|
|
@@ -78,6 +89,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
78
89
|
outputDir: '.output',
|
|
79
90
|
supportsWaitUntil: true,
|
|
80
91
|
supportsEarlyHints: false,
|
|
92
|
+
readsPlatformFiles: false,
|
|
81
93
|
runtimeName: 'deno-deploy',
|
|
82
94
|
},
|
|
83
95
|
'azure-functions': {
|
|
@@ -85,6 +97,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
85
97
|
outputDir: '.output',
|
|
86
98
|
supportsWaitUntil: false,
|
|
87
99
|
supportsEarlyHints: false,
|
|
100
|
+
readsPlatformFiles: false,
|
|
88
101
|
runtimeName: 'azure-functions',
|
|
89
102
|
},
|
|
90
103
|
'node-server': {
|
|
@@ -99,6 +112,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
99
112
|
// are the safe fallback — Cloudflare and other CDNs convert them to
|
|
100
113
|
// 103 automatically at the edge (over HTTP/2+ to the browser).
|
|
101
114
|
supportsEarlyHints: false,
|
|
115
|
+
readsPlatformFiles: false,
|
|
102
116
|
runtimeName: 'node-server',
|
|
103
117
|
},
|
|
104
118
|
'bun': {
|
|
@@ -108,6 +122,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
|
|
|
108
122
|
// Disabled for same reason as node-server — reverse proxies choke on 103.
|
|
109
123
|
// Link headers on the 200 response are converted to 103 by CDNs.
|
|
110
124
|
supportsEarlyHints: false,
|
|
125
|
+
readsPlatformFiles: false,
|
|
111
126
|
runtimeName: 'bun',
|
|
112
127
|
},
|
|
113
128
|
};
|
|
@@ -250,7 +250,7 @@ import { createServer } from 'node:http';
|
|
|
250
250
|
import { readFile, stat } from 'node:fs/promises';
|
|
251
251
|
import { join, extname, sep } from 'node:path';
|
|
252
252
|
import { fileURLToPath } from 'node:url';
|
|
253
|
-
import { canonicalize } from './_canonicalize.mjs';
|
|
253
|
+
import { canonicalize, requestTargetUrl } from './_canonicalize.mjs';
|
|
254
254
|
|
|
255
255
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
256
256
|
|
|
@@ -321,6 +321,9 @@ const envPort = process.env.PORT ? parseInt(process.env.PORT, 10) : null;
|
|
|
321
321
|
const portIsExplicit = envPort != null && Number.isFinite(envPort) && envPort > 0;
|
|
322
322
|
const startPort = portIsExplicit ? envPort : 3000;
|
|
323
323
|
const host = process.env.HOST || 'localhost';
|
|
324
|
+
// An IPv6 HOST ('::', '::1') binds as is but needs brackets in a URL;
|
|
325
|
+
// unbracketed, every request URL is unparseable and answered 400.
|
|
326
|
+
const urlHost = host.includes(':') && !host.startsWith('[') ? \`[\${host}]\` : host;
|
|
324
327
|
|
|
325
328
|
// Set after listenWithBump() resolves so request handlers can build
|
|
326
329
|
// absolute URLs from the actual bound port (which may differ from
|
|
@@ -335,16 +338,17 @@ const server = createServer(async (req, res) => {
|
|
|
335
338
|
// connection it would be attacker-controlled. The CSRF layer honors it
|
|
336
339
|
// separately for reverse-proxy deployments.
|
|
337
340
|
const scheme = req.socket?.encrypted ? 'https' : 'http';
|
|
338
|
-
//
|
|
339
|
-
//
|
|
340
|
-
//
|
|
341
|
-
//
|
|
342
|
-
//
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
341
|
+
// requestTargetUrl() (server/canonicalize.ts) concatenates an origin-form
|
|
342
|
+
// target and resolves any other form, so '//evil.com/' stays a path the
|
|
343
|
+
// pipeline redirects (TIM-1571) and 'OPTIONS *' is '/*'. A target that
|
|
344
|
+
// names no URL is answered here: thrown in this callback, which has no
|
|
345
|
+
// catch around it, the rejection would take the preview process down.
|
|
346
|
+
const url = requestTargetUrl(\`\${scheme}://\${urlHost}:\${boundPort}\`, req.url || '/');
|
|
347
|
+
if (!url) {
|
|
348
|
+
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
|
349
|
+
res.end('Bad Request');
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
348
352
|
|
|
349
353
|
// The runtime's own request-boundary canonicalizer (_canonicalize.mjs,
|
|
350
354
|
// compiled from server/canonicalize.ts): one decode, and the same 400s for
|
|
@@ -450,44 +454,63 @@ export function sendNodeResponse(nodeRes, webRes) {
|
|
|
450
454
|
// pipe it straight to the socket, no Web Streams round trip. pipe() rather
|
|
451
455
|
// than pipeline(), which allocates an AbortController and an error on every
|
|
452
456
|
// finish; a client that disconnects early destroys the body (aborting the
|
|
453
|
-
// render), and a body that errors destroys the socket.
|
|
457
|
+
// render), and a body that errors mid-stream destroys the socket.
|
|
458
|
+
//
|
|
459
|
+
// As srvx's pipeBody does, the status line waits until the body is
|
|
460
|
+
// readable: a body that errors before its first chunk answers a bare 500
|
|
461
|
+
// instead of closing the socket with nothing written (TIM-1602).
|
|
454
462
|
if (typeof webRes._toNodeResponse === 'function') {
|
|
455
463
|
const res = webRes._toNodeResponse();
|
|
456
464
|
if (res.body && typeof res.body.pipe === 'function') {
|
|
457
|
-
if (!nodeRes.headersSent) {
|
|
458
|
-
if (nodeRes.req?.httpVersion === '2.0') {
|
|
459
|
-
nodeRes.writeHead(res.status, res.headers);
|
|
460
|
-
} else {
|
|
461
|
-
nodeRes.writeHead(res.status, res.statusText, res.headers);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
465
|
const body = res.body;
|
|
465
466
|
// The client already left: 'close' has fired and will not again.
|
|
466
467
|
if (nodeRes.destroyed) {
|
|
467
468
|
body.destroy();
|
|
468
469
|
return;
|
|
469
470
|
}
|
|
471
|
+
// Already failed: its 'error' has fired and 'readable' never will.
|
|
472
|
+
if (body.destroyed) {
|
|
473
|
+
writeHead(nodeRes, 500, 'Internal Server Error', []);
|
|
474
|
+
return new Promise((resolve) => nodeRes.end(resolve));
|
|
475
|
+
}
|
|
470
476
|
return new Promise((resolve) => {
|
|
471
|
-
|
|
472
|
-
|
|
477
|
+
function cleanup() {
|
|
478
|
+
body.off('error', onEarlyError);
|
|
479
|
+
body.off('readable', onReadable);
|
|
480
|
+
nodeRes.off('close', onEarlyClose);
|
|
481
|
+
}
|
|
482
|
+
function onEarlyError() {
|
|
483
|
+
cleanup();
|
|
484
|
+
body.destroy();
|
|
485
|
+
writeHead(nodeRes, 500, 'Internal Server Error', []);
|
|
486
|
+
nodeRes.end(resolve);
|
|
487
|
+
}
|
|
488
|
+
function onEarlyClose() {
|
|
489
|
+
cleanup();
|
|
490
|
+
body.destroy();
|
|
473
491
|
resolve();
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
492
|
+
}
|
|
493
|
+
function onReadable() {
|
|
494
|
+
cleanup();
|
|
495
|
+
writeHead(nodeRes, res.status, res.statusText, res.headers);
|
|
496
|
+
nodeRes.once('close', () => {
|
|
497
|
+
if (!body.readableEnded) body.destroy();
|
|
498
|
+
resolve();
|
|
499
|
+
});
|
|
500
|
+
nodeRes.on('error', () => body.destroy());
|
|
501
|
+
body.once('error', (error) => nodeRes.destroy(error));
|
|
502
|
+
body.pipe(nodeRes);
|
|
503
|
+
}
|
|
504
|
+
body.once('error', onEarlyError);
|
|
505
|
+
body.once('readable', onReadable);
|
|
506
|
+
nodeRes.once('close', onEarlyClose);
|
|
478
507
|
});
|
|
479
508
|
}
|
|
480
509
|
webRes = new Response(res.body, { status: res.status, statusText: res.statusText, headers: pairs(res.headers) });
|
|
481
510
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
if (nodeRes.req?.httpVersion === '2.0') {
|
|
486
|
-
nodeRes.writeHead(webRes.status, writeHeaders);
|
|
487
|
-
} else {
|
|
488
|
-
nodeRes.writeHead(webRes.status, webRes.statusText, writeHeaders);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
511
|
+
// A Web body's status line goes out before its first read, as in srvx:
|
|
512
|
+
// one that errors before its first chunk closes the socket unanswered.
|
|
513
|
+
writeHead(nodeRes, webRes.status, webRes.statusText, [...webRes.headers].flat());
|
|
491
514
|
if (!webRes.body) {
|
|
492
515
|
return new Promise((resolve) => nodeRes.end(resolve));
|
|
493
516
|
}
|
|
@@ -524,6 +547,15 @@ export function sendNodeResponse(nodeRes, webRes) {
|
|
|
524
547
|
});
|
|
525
548
|
}
|
|
526
549
|
|
|
550
|
+
function writeHead(nodeRes, status, statusText, headers) {
|
|
551
|
+
if (nodeRes.headersSent) return;
|
|
552
|
+
if (nodeRes.req?.httpVersion === '2.0') {
|
|
553
|
+
nodeRes.writeHead(status, headers);
|
|
554
|
+
} else {
|
|
555
|
+
nodeRes.writeHead(status, statusText, headers);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
527
559
|
function pairs(flat) {
|
|
528
560
|
const out = [];
|
|
529
561
|
for (let i = 0; i < flat.length; i += 2) out.push([flat[i], flat[i + 1]]);
|
package/src/adapters/nitro.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// See design/11-platform.md and design/25-production-deployments.md.
|
|
7
7
|
|
|
8
8
|
import { existsSync } from 'node:fs';
|
|
9
|
-
import { cp, glob, readFile, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { cp, glob, readFile, rm, writeFile } from 'node:fs/promises';
|
|
10
10
|
import { basename, dirname, join, relative, sep } from 'node:path';
|
|
11
11
|
import type { NitroConfig } from 'nitro/types';
|
|
12
12
|
import {
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
spawnNitroPreview,
|
|
25
25
|
} from './nitro-preview.ts';
|
|
26
26
|
import { adapterBase } from './shared.ts';
|
|
27
|
+
import { HEADERS_FILE, REDIRECTS_FILE } from '../shared/static-platform-files.ts';
|
|
27
28
|
import type {
|
|
28
29
|
BuildArtifacts,
|
|
29
30
|
PreviewTarget,
|
|
@@ -117,10 +118,12 @@ export function nitro(options: NitroAdapterOptions = {}): TimberPlatformAdapter
|
|
|
117
118
|
if (artifacts.output === 'static') {
|
|
118
119
|
await buildStaticDirectoryOutput(config, artifacts, outDir, 'public');
|
|
119
120
|
const publicDir = join(outDir, 'public');
|
|
121
|
+
const target = options.staticTarget ?? 'generic';
|
|
120
122
|
|
|
121
|
-
// Write _headers for cache control + extensionless Content-Type
|
|
122
|
-
//
|
|
123
|
-
|
|
123
|
+
// Write _headers for cache control + extensionless Content-Type, for
|
|
124
|
+
// the hosts a generic static build lands on that read it (Netlify,
|
|
125
|
+
// Cloudflare Pages). GitHub Pages reads neither platform file.
|
|
126
|
+
if (target !== 'github-pages') await writeHeadersFile(publicDir, config, artifacts);
|
|
124
127
|
|
|
125
128
|
// Local preview serves the site as the build recorded it.
|
|
126
129
|
await writeFile(join(outDir, CANONICALIZE_MODULE), await generateCanonicalizeModule());
|
|
@@ -135,7 +138,6 @@ export function nitro(options: NitroAdapterOptions = {}): TimberPlatformAdapter
|
|
|
135
138
|
);
|
|
136
139
|
|
|
137
140
|
// Platform-specific files for static deploy targets.
|
|
138
|
-
const target = options.staticTarget ?? 'generic';
|
|
139
141
|
if (target === 'github-pages') {
|
|
140
142
|
// Deploy-from-a-branch runs Jekyll, which drops `_`-prefixed paths —
|
|
141
143
|
// every `_rsc/` payload. Written unconditionally: GitHub reads only
|
|
@@ -154,18 +156,24 @@ export function nitro(options: NitroAdapterOptions = {}): TimberPlatformAdapter
|
|
|
154
156
|
} catch {
|
|
155
157
|
// No _redirects file — nothing to warn about
|
|
156
158
|
}
|
|
159
|
+
// With `.nojekyll` nothing hides `_`-prefixed files, so these would be
|
|
160
|
+
// published as-is — the user's `public/` copies included (TIM-1605).
|
|
161
|
+
for (const name of [HEADERS_FILE, REDIRECTS_FILE]) {
|
|
162
|
+
await rm(join(publicDir, name), { force: true });
|
|
163
|
+
}
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
return;
|
|
160
167
|
}
|
|
161
168
|
|
|
162
169
|
// Steps 1–5: shared across all adapters (mkdir, copy client/rsc/ssr,
|
|
163
|
-
// write _headers, write manifest-init).
|
|
170
|
+
// write _headers where the platform reads it, write manifest-init).
|
|
164
171
|
await runSharedBuildSteps({
|
|
165
172
|
config,
|
|
166
173
|
artifacts,
|
|
167
174
|
outDir,
|
|
168
175
|
publicDirName: 'public',
|
|
176
|
+
platformFiles: PRESET_CONFIGS[preset].readsPlatformFiles,
|
|
169
177
|
});
|
|
170
178
|
|
|
171
179
|
// Write runtime helper modules used by the preview server.
|
|
@@ -22,15 +22,13 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { execFile } from 'node:child_process';
|
|
25
|
-
import { existsSync
|
|
25
|
+
import { existsSync } from 'node:fs';
|
|
26
26
|
import { mkdir, readFile, realpath, rm } from 'node:fs/promises';
|
|
27
|
-
import { request as httpRequest } from 'node:http';
|
|
28
|
-
import { request as httpsRequest } from 'node:https';
|
|
29
27
|
import { createRequire } from 'node:module';
|
|
30
28
|
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
31
29
|
import { fileURLToPath } from 'node:url';
|
|
32
30
|
import { promisify } from 'node:util';
|
|
33
|
-
import {
|
|
31
|
+
import { DEV_PROBE_TIMEOUT_MS, probeDevServer, readDevRecords } from '../plugins/dev-discovery.ts';
|
|
34
32
|
import {
|
|
35
33
|
collectBaseFingerprintEntries,
|
|
36
34
|
computeProjectFingerprint,
|
|
@@ -53,12 +51,6 @@ export type GraphSource = 'dev-server' | 'static-scan';
|
|
|
53
51
|
const CRAWL_TIMEOUT_MS = 120_000;
|
|
54
52
|
const SPAWN_SLACK_MS = 30_000;
|
|
55
53
|
|
|
56
|
-
/**
|
|
57
|
-
* Short timeout for the dev-server probe: the fast path must not hold
|
|
58
|
-
* the fallback hostage if the server is wedged or the connection hangs.
|
|
59
|
-
*/
|
|
60
|
-
const DEV_PROBE_TIMEOUT_MS = 2_000;
|
|
61
|
-
|
|
62
54
|
/**
|
|
63
55
|
* Vite's own default config file names, in Vite's precedence order.
|
|
64
56
|
* Matching the list (rather than globbing) keeps the walk-up aligned
|
|
@@ -100,146 +92,46 @@ export function findViteConfigUpward(startDir: string): string | null {
|
|
|
100
92
|
}
|
|
101
93
|
}
|
|
102
94
|
|
|
103
|
-
/** Max response body size (16 MB — matches the crawl child). */
|
|
104
|
-
const PROBE_MAX_BODY_BYTES = 16 * 1024 * 1024;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* HTTP(S) GET with a wall-clock deadline and response-size limit,
|
|
108
|
-
* returning the parsed JSON body or null on any failure. Uses
|
|
109
|
-
* node:http/https directly — `fetch` silently strips the Host header,
|
|
110
|
-
* which the endpoint's DNS-rebinding defense needs to see as `localhost`.
|
|
111
|
-
*
|
|
112
|
-
* The wall-clock timer covers both connection and body streaming —
|
|
113
|
-
* node's `timeout` option is an INACTIVITY timeout that resets on every
|
|
114
|
-
* chunk, so a slow-drip response would never fire it.
|
|
115
|
-
*/
|
|
116
|
-
function probeEndpoint(record: DevRecord, path: string, timeoutMs: number): Promise<unknown> {
|
|
117
|
-
return new Promise((resolve) => {
|
|
118
|
-
let settled = false;
|
|
119
|
-
const done = (value: unknown) => {
|
|
120
|
-
if (settled) return;
|
|
121
|
-
settled = true;
|
|
122
|
-
clearTimeout(wallClock);
|
|
123
|
-
resolve(value);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const probeHost =
|
|
127
|
-
record.host === '0.0.0.0' || record.host === '::' || record.host === ''
|
|
128
|
-
? '127.0.0.1'
|
|
129
|
-
: record.host;
|
|
130
|
-
const doRequest = record.protocol === 'https' ? httpsRequest : httpRequest;
|
|
131
|
-
const req = doRequest(
|
|
132
|
-
{
|
|
133
|
-
hostname: probeHost,
|
|
134
|
-
port: record.port,
|
|
135
|
-
path,
|
|
136
|
-
method: 'GET',
|
|
137
|
-
// Self-signed certs are normal for dev servers.
|
|
138
|
-
rejectUnauthorized: false,
|
|
139
|
-
},
|
|
140
|
-
(res) => {
|
|
141
|
-
if (res.statusCode !== 200) {
|
|
142
|
-
req.destroy();
|
|
143
|
-
done(null);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const chunks: Buffer[] = [];
|
|
147
|
-
let totalBytes = 0;
|
|
148
|
-
res.on('data', (chunk: Buffer) => {
|
|
149
|
-
totalBytes += chunk.length;
|
|
150
|
-
if (totalBytes > PROBE_MAX_BODY_BYTES) {
|
|
151
|
-
req.destroy();
|
|
152
|
-
done(null);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
chunks.push(chunk);
|
|
156
|
-
});
|
|
157
|
-
res.on('end', () => {
|
|
158
|
-
try {
|
|
159
|
-
const parsed = JSON.parse(Buffer.concat(chunks).toString('utf8')) as Record<
|
|
160
|
-
string,
|
|
161
|
-
unknown
|
|
162
|
-
>;
|
|
163
|
-
done(
|
|
164
|
-
parsed?.version === GRAPH_JSON_VERSION && parsed?.source === 'dev-server'
|
|
165
|
-
? parsed
|
|
166
|
-
: null
|
|
167
|
-
);
|
|
168
|
-
} catch {
|
|
169
|
-
done(null);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
res.on('error', () => done(null));
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
req.on('error', () => done(null));
|
|
176
|
-
|
|
177
|
-
const wallClock = setTimeout(() => {
|
|
178
|
-
req.destroy();
|
|
179
|
-
done(null);
|
|
180
|
-
}, timeoutMs);
|
|
181
|
-
req.end();
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
95
|
/**
|
|
186
96
|
* Try to delegate a graph query to a running dev server discovered via
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
97
|
+
* its discovery record. Returns the parsed JSON response on success, null
|
|
98
|
+
* on any failure (no live records, wrong config, probe failure). Every
|
|
99
|
+
* failure mode is silent — the caller falls back to the cold crawl. The
|
|
100
|
+
* graph request itself is the liveness probe, so no separate status probe
|
|
101
|
+
* is made.
|
|
190
102
|
*/
|
|
191
103
|
async function tryDevServer(
|
|
192
104
|
configDir: string,
|
|
193
105
|
configFile: string,
|
|
194
106
|
queryString: string
|
|
195
107
|
): Promise<unknown> {
|
|
196
|
-
const
|
|
197
|
-
let entries: string[];
|
|
198
|
-
try {
|
|
199
|
-
entries = readdirSync(dir);
|
|
200
|
-
} catch {
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
for (const entry of entries) {
|
|
204
|
-
if (!entry.endsWith('.json')) continue;
|
|
205
|
-
let record: DevRecord;
|
|
206
|
-
try {
|
|
207
|
-
record = JSON.parse(readFileSync(join(dir, entry), 'utf8')) as DevRecord;
|
|
208
|
-
} catch {
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
if (
|
|
212
|
-
typeof record.port !== 'number' ||
|
|
213
|
-
!Number.isInteger(record.port) ||
|
|
214
|
-
record.port < 1 ||
|
|
215
|
-
record.port > 65535 ||
|
|
216
|
-
typeof record.pid !== 'number' ||
|
|
217
|
-
!Number.isInteger(record.pid) ||
|
|
218
|
-
record.pid < 1 ||
|
|
219
|
-
typeof record.host !== 'string' ||
|
|
220
|
-
(record.protocol !== 'http' && record.protocol !== 'https')
|
|
221
|
-
) {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
108
|
+
for (const record of readDevRecords(configDir)) {
|
|
224
109
|
// Skip records from a different Vite config (TIM-1393). Records
|
|
225
110
|
// without configFile (old servers) are accepted — rejecting them
|
|
226
111
|
// would break the fast path until every server restarts.
|
|
227
112
|
if (record.configFile && normalizeSlashes(record.configFile) !== normalizeSlashes(configFile))
|
|
228
113
|
continue;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
// (ERR_INVALID_CHAR) or other invalid options — treat as absent.
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
if (result) return result;
|
|
114
|
+
const result = await probeDevServer(
|
|
115
|
+
record,
|
|
116
|
+
`/__timber/graph${queryString}`,
|
|
117
|
+
DEV_PROBE_TIMEOUT_MS
|
|
118
|
+
);
|
|
119
|
+
if (isDevServerGraphResponse(result)) return result;
|
|
239
120
|
}
|
|
240
121
|
return null;
|
|
241
122
|
}
|
|
242
123
|
|
|
124
|
+
function isDevServerGraphResponse(value: unknown): boolean {
|
|
125
|
+
return (
|
|
126
|
+
typeof value === 'object' &&
|
|
127
|
+
value !== null &&
|
|
128
|
+
'version' in value &&
|
|
129
|
+
value.version === GRAPH_JSON_VERSION &&
|
|
130
|
+
'source' in value &&
|
|
131
|
+
value.source === 'dev-server'
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
243
135
|
/**
|
|
244
136
|
* Resolve the app root from the config file's own directory, reading
|
|
245
137
|
* it off the timber root-sync plugin api (the single supported way —
|