@timber-js/app 0.2.0-alpha.221 → 0.2.0-alpha.223
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-skill.md +21 -5
- package/dist/_chunks/{actions-BDqn4Oxj.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-GE4AOe2H.js → cache-api-TDZ4hlDc.js} +237 -37
- 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-e_Buf9vg.js → chains-Dgm3PrMe.js} +3 -4
- package/dist/_chunks/{chains-e_Buf9vg.js.map → chains-Dgm3PrMe.js.map} +1 -1
- package/dist/_chunks/{classify-2Yp3xJY1.js → classify--_kINHQV.js} +4 -5
- package/dist/_chunks/{classify-2Yp3xJY1.js.map → classify--_kINHQV.js.map} +1 -1
- package/dist/_chunks/{cli-check-DDwCkeDY.js → cli-check-Dv3f8d2j.js} +5 -6
- package/dist/_chunks/{cli-check-DDwCkeDY.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-BdIebmk3.js → cli-schema-sync-DIPurq7X.js} +4 -5
- package/dist/_chunks/{cli-schema-sync-BdIebmk3.js.map → cli-schema-sync-DIPurq7X.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-CLNfXQDK.js → cli-schema-sync-uq72EZmD.js} +1 -1
- package/dist/_chunks/{client-dep-entries-BOkpKjj1.js → client-dep-entries-CP7AkMCM.js} +4 -5
- package/dist/_chunks/{client-dep-entries-BOkpKjj1.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-ByKJ6aqD.js → convention-lint-hZwz5wd4.js} +8 -11
- package/dist/_chunks/{convention-lint-ByKJ6aqD.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-DIy-SY-J.js → dev-server-C61GWpGg.js} +409 -51
- package/dist/_chunks/dev-server-C61GWpGg.js.map +1 -0
- package/dist/_chunks/dev-server-CBvvM7Lr.js +1 -0
- package/dist/_chunks/{dev-store-BOa304m_.js → dev-store-BvdqtHvK.js} +82 -38
- package/dist/_chunks/dev-store-BvdqtHvK.js.map +1 -0
- package/dist/_chunks/{dist-DtrJyBbw.js → dist-C1Rjlo6s.js} +3 -5
- package/dist/_chunks/{dist-DtrJyBbw.js.map → dist-C1Rjlo6s.js.map} +1 -1
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js → error-boundary-DRQXGWCp.js} +20 -27
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js.map → error-boundary-DRQXGWCp.js.map} +1 -1
- package/dist/_chunks/{fast-hash-C-tVYrLb.js → fast-hash-DddxkU5Y.js} +2 -3
- package/dist/_chunks/{fast-hash-C-tVYrLb.js.map → fast-hash-DddxkU5Y.js.map} +1 -1
- package/dist/_chunks/{flight-source-node-HptmGMT8.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-DbxNWeBP.js +47 -0
- package/dist/_chunks/global-context-DbxNWeBP.js.map +1 -0
- 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-C8zBY2uZ.js → json-lossy-check-DVkLUlfC.js} +3 -4
- package/dist/_chunks/{json-lossy-check-C8zBY2uZ.js.map → json-lossy-check-DVkLUlfC.js.map} +1 -1
- package/dist/_chunks/{live-graph-tSWrv8eH.js → live-graph-BcVjQ1Te.js} +6 -7
- package/dist/_chunks/{live-graph-tSWrv8eH.js.map → live-graph-BcVjQ1Te.js.map} +1 -1
- package/dist/_chunks/{logger-CbLdcy-W.js → logger-CWk44DLp.js} +97 -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-rkQqcFGq.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-C4FgMxFl.js → poison-scan-DJYxZc_7.js} +4 -5
- package/dist/_chunks/{poison-scan-C4FgMxFl.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-joFhz4KH.js → render-timeout-MrrqD1wd.js} +20 -4
- package/dist/_chunks/{render-timeout-joFhz4KH.js.map → render-timeout-MrrqD1wd.js.map} +1 -1
- package/dist/_chunks/{resolve-schema-CBR6Lm4i.js → resolve-schema-B-aCuTu3.js} +3 -4
- package/dist/_chunks/{resolve-schema-CBR6Lm4i.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-Cb3fSjAC.js → scanner-CJC-ScJU.js} +15 -23
- package/dist/_chunks/{scanner-Cb3fSjAC.js.map → scanner-CJC-ScJU.js.map} +1 -1
- package/dist/_chunks/{schema-bridge-C83xa9lT.js → schema-bridge-DyRs3cqy.js} +61 -25
- package/dist/_chunks/schema-bridge-DyRs3cqy.js.map +1 -0
- 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-xtPUGfdq.js → segment-context-CYiGTi3K.js} +6 -12
- package/dist/_chunks/segment-context-CYiGTi3K.js.map +1 -0
- 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-QPE5nd3u.js → sizeof-DG4W40lv.js} +3 -4
- package/dist/_chunks/{sizeof-QPE5nd3u.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-qu8TpiLh.js → walkers-DIE203ir.js} +6 -8
- package/dist/_chunks/{walkers-qu8TpiLh.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/guarded-read.d.ts +29 -0
- package/dist/cache/guarded-read.d.ts.map +1 -0
- 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/global-context.d.ts +21 -1
- package/dist/client/global-context.d.ts.map +1 -1
- package/dist/client/index.js +23 -44
- 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/navigation-context.d.ts.map +1 -1
- package/dist/client/params-context.d.ts.map +1 -1
- package/dist/client/slot-context.d.ts +2 -2
- package/dist/client/slot-context.d.ts.map +1 -1
- package/dist/client/use-cookie.d.ts +18 -5
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/codec.js +2 -3
- package/dist/config-types.d.ts +22 -5
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +40 -67
- package/dist/cookies/index.js.map +1 -1
- package/dist/cookies/json-cookie.d.ts +4 -4
- package/dist/index.js +266 -229
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +3 -4
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/dev-discovery.d.ts +69 -5
- package/dist/plugins/dev-discovery.d.ts.map +1 -1
- package/dist/plugins/dev-hostname.d.ts +152 -0
- package/dist/plugins/dev-hostname.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +6 -2
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/dev-store-clear.d.ts +83 -0
- package/dist/plugins/dev-store-clear.d.ts.map +1 -0
- package/dist/plugins/graph-endpoint.d.ts +4 -2
- package/dist/plugins/graph-endpoint.d.ts.map +1 -1
- package/dist/plugins/prebuilt.d.ts.map +1 -1
- package/dist/routing/index.js +4 -4
- package/dist/rsc-runtime/rsc.d.ts +2 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/server-references.d.ts +8 -0
- package/dist/rsc-runtime/server-references.d.ts.map +1 -0
- package/dist/schema-bridge.d.ts +28 -19
- package/dist/schema-bridge.d.ts.map +1 -1
- package/dist/search-params/define.d.ts +1 -1
- package/dist/search-params/define.d.ts.map +1 -1
- package/dist/search-params/index.js +11 -14
- package/dist/search-params/index.js.map +1 -1
- package/dist/search-params/wrappers.d.ts +3 -3
- 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 +1080 -959
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +26 -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 +17 -3
- 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/33-api-search-params.mdx +3 -1
- package/docs/api/34-api-config.mdx +22 -0
- package/docs/api/36-cli.mdx +72 -6
- package/docs/learn/01-quick-start.mdx +1 -1
- package/docs/learn/06-typed-params.mdx +4 -4
- 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/guarded-read.ts +44 -0
- package/src/cache/key-discipline.ts +218 -0
- package/src/cache/timber-cache.ts +46 -7
- 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/global-context.ts +42 -14
- package/src/client/navigation-context.ts +4 -11
- package/src/client/params-context.ts +5 -17
- package/src/client/segment-update-context.ts +1 -1
- package/src/client/slot-content-cache-context.ts +1 -1
- package/src/client/slot-context.ts +6 -17
- package/src/client/use-cookie.ts +33 -21
- package/src/config-types.ts +22 -5
- package/src/config-validation.ts +17 -0
- package/src/cookies/define-cookie.ts +10 -46
- package/src/cookies/json-cookie.ts +4 -4
- package/src/plugin-context.ts +7 -0
- package/src/plugins/dev-discovery.ts +216 -6
- package/src/plugins/dev-hostname.ts +322 -0
- package/src/plugins/dev-server.ts +130 -37
- package/src/plugins/dev-store-clear.ts +145 -0
- package/src/plugins/graph-endpoint.ts +15 -3
- package/src/plugins/prebuilt.ts +9 -0
- package/src/rsc-runtime/rsc.ts +7 -3
- package/src/rsc-runtime/server-references.ts +73 -0
- package/src/rsc-runtime/vendor-types.d.ts +17 -0
- package/src/schema-bridge.ts +93 -38
- package/src/search-params/define.ts +5 -6
- package/src/search-params/wrappers.ts +3 -3
- package/src/server/access-gate.tsx +32 -20
- package/src/server/action-handler.ts +58 -36
- 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 +32 -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 +32 -4
- package/src/server/prebuilt-runtime.ts +63 -45
- 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-BDqn4Oxj.js.map +0 -1
- package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +0 -1
- package/dist/_chunks/cache-api-GE4AOe2H.js.map +0 -1
- package/dist/_chunks/chains-CDK1AWZQ.js +0 -1
- package/dist/_chunks/cli-context-BJQB6rtF.js +0 -1
- package/dist/_chunks/dev-server-BiWNMBVU.js +0 -1
- package/dist/_chunks/dev-server-DIy-SY-J.js.map +0 -1
- package/dist/_chunks/dev-store-BOa304m_.js.map +0 -1
- package/dist/_chunks/flight-source-node-HptmGMT8.js.map +0 -1
- package/dist/_chunks/graph-cache-CYiUS2aS.js.map +0 -1
- package/dist/_chunks/logger-CbLdcy-W.js.map +0 -1
- package/dist/_chunks/node-response-rkQqcFGq.js.map +0 -1
- package/dist/_chunks/plugin-context-DxMMvjUt.js.map +0 -1
- package/dist/_chunks/schema-bridge-C83xa9lT.js.map +0 -1
- package/dist/_chunks/segment-context-xtPUGfdq.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,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-app dev hostnames — print and open `<name>.localhost:<port>`.
|
|
3
|
+
*
|
|
4
|
+
* Cookies are not scoped by port, so every app served on `localhost` shares
|
|
5
|
+
* one cookie jar: two apps on :3000 and :3001 overwrite each other's
|
|
6
|
+
* sessions, and service workers stuck to `localhost:3000` carry over to
|
|
7
|
+
* whichever project next gets that port. Browsers resolve
|
|
8
|
+
* `*.localhost` (at any depth) to loopback with no DNS or `/etc/hosts` setup,
|
|
9
|
+
* so giving each app its own name gives it its own cookie jar.
|
|
10
|
+
*
|
|
11
|
+
* This only changes the URL Vite prints, opens, and records for discovery.
|
|
12
|
+
* Nothing is proxied, no `Host` is rewritten, and plain `localhost:<port>`
|
|
13
|
+
* keeps working. Vite's host check already accepts `*.localhost`.
|
|
14
|
+
*
|
|
15
|
+
* See design/21-dev-server.md §"Dev Hostnames" (TIM-1613).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { X509Certificate } from 'node:crypto';
|
|
19
|
+
import { readFileSync } from 'node:fs';
|
|
20
|
+
import { basename, join, resolve } from 'node:path';
|
|
21
|
+
|
|
22
|
+
const LOCALHOST = 'localhost';
|
|
23
|
+
const LOCALHOST_SUFFIX = `.${LOCALHOST}`;
|
|
24
|
+
|
|
25
|
+
/** RFC 1035 label limit. */
|
|
26
|
+
const MAX_LABEL_LENGTH = 63;
|
|
27
|
+
|
|
28
|
+
/** RFC 1035 name limit, `.localhost` included. */
|
|
29
|
+
const MAX_HOSTNAME_LENGTH = 253;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Package names that say nothing about the app: the create-timber-app
|
|
33
|
+
* default (`packages/create-timber-app/src/index.ts`) and the generic names
|
|
34
|
+
* people leave in templates. They would put every unrenamed app on the same
|
|
35
|
+
* hostname, and so the same cookie jar, which is exactly what this
|
|
36
|
+
* feature is for avoiding. The directory name is used instead.
|
|
37
|
+
*/
|
|
38
|
+
const PLACEHOLDER_PACKAGE_NAMES = new Set(['app', 'my-app', 'my-timber-app']);
|
|
39
|
+
|
|
40
|
+
const LABEL_RE = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Reduce arbitrary text to one DNS label: lowercase, anything outside
|
|
44
|
+
* `[a-z0-9-]` becomes `-`, runs of `-` collapse, no leading or trailing
|
|
45
|
+
* `-`, at most 63 characters. May return '' when nothing usable is left.
|
|
46
|
+
*/
|
|
47
|
+
export function sanitizeLabel(raw: string): string {
|
|
48
|
+
return raw
|
|
49
|
+
.toLowerCase()
|
|
50
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
51
|
+
.replace(/-{2,}/g, '-')
|
|
52
|
+
.replace(/^-+/, '')
|
|
53
|
+
.slice(0, MAX_LABEL_LENGTH)
|
|
54
|
+
.replace(/-+$/, '');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Labels for a package name, most specific first: `@acme/web` →
|
|
59
|
+
* `['web', 'acme']` (so `web.acme.localhost`), `example-blog` →
|
|
60
|
+
* `['example-blog']`. Placeholders and non-strings give `[]`.
|
|
61
|
+
*/
|
|
62
|
+
function packageNameLabels(name: unknown): string[] {
|
|
63
|
+
if (typeof name !== 'string') return [];
|
|
64
|
+
if (PLACEHOLDER_PACKAGE_NAMES.has(name.trim().toLowerCase())) return [];
|
|
65
|
+
const scoped = /^@([^/]+)\/(.+)$/.exec(name);
|
|
66
|
+
const parts = scoped ? [scoped[2], scoped[1]] : [name];
|
|
67
|
+
return parts.map(sanitizeLabel).filter(Boolean);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Why a `dev.hostname` value is unusable, or null when it is fine. Accepts
|
|
72
|
+
* `false` (opt out: keep plain `localhost`) or a dot-separated sequence of
|
|
73
|
+
* DNS labels, case-insensitively, with or without a trailing `.localhost`.
|
|
74
|
+
*/
|
|
75
|
+
export function devHostnameError(value: unknown): string | null {
|
|
76
|
+
if (value === false) return null;
|
|
77
|
+
if (typeof value !== 'string') {
|
|
78
|
+
return `must be a string like "blog" or false, got ${JSON.stringify(value)}.`;
|
|
79
|
+
}
|
|
80
|
+
const labels = stripLocalhost(value.toLowerCase());
|
|
81
|
+
if (labels === '') {
|
|
82
|
+
return `${JSON.stringify(value)} names no app. Use a name like "blog", or false to keep plain localhost.`;
|
|
83
|
+
}
|
|
84
|
+
const bad = labels.split('.').find((label) => !LABEL_RE.test(label));
|
|
85
|
+
if (bad !== undefined) {
|
|
86
|
+
return (
|
|
87
|
+
`${JSON.stringify(value)} is not a valid hostname: label ${JSON.stringify(bad)} must be ` +
|
|
88
|
+
'1-63 characters of a-z, 0-9 and "-", not starting or ending with "-".'
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (labels.length + LOCALHOST_SUFFIX.length > MAX_HOSTNAME_LENGTH) {
|
|
92
|
+
return `${JSON.stringify(value)} is longer than a hostname can be (253 characters with .localhost).`;
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function stripLocalhost(name: string): string {
|
|
98
|
+
if (name === LOCALHOST) return '';
|
|
99
|
+
return name.endsWith(LOCALHOST_SUFFIX) ? name.slice(0, -LOCALHOST_SUFFIX.length) : name;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface DevHostnameSource {
|
|
103
|
+
/** `dev.hostname` from timber.config.ts. */
|
|
104
|
+
override?: string | false;
|
|
105
|
+
/** `name` from the app's package.json, if it has one. */
|
|
106
|
+
packageName?: unknown;
|
|
107
|
+
/** The app directory's own name. */
|
|
108
|
+
dirName: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The dev hostname for an app. In order:
|
|
113
|
+
*
|
|
114
|
+
* 1. `dev.hostname`, when set (`false` → plain `localhost`). An invalid value
|
|
115
|
+
* throws; config validation reports it as fatal before this runs.
|
|
116
|
+
* 2. package.json `name`, unless it is a placeholder. Preferred over the
|
|
117
|
+
* directory because it is stable across clones and worktrees, so OAuth
|
|
118
|
+
* callback URLs registered against it keep working, and because monorepo
|
|
119
|
+
* directories are generic (`apps/web` everywhere).
|
|
120
|
+
* 3. The directory name.
|
|
121
|
+
* 4. Plain `localhost`, when nothing usable is left after sanitizing.
|
|
122
|
+
*/
|
|
123
|
+
export function deriveDevHostname(source: DevHostnameSource): string {
|
|
124
|
+
const { override } = source;
|
|
125
|
+
if (override === false) return LOCALHOST;
|
|
126
|
+
if (override !== undefined) {
|
|
127
|
+
const error = devHostnameError(override);
|
|
128
|
+
if (error) throw new Error(`[timber] dev.hostname ${error}`);
|
|
129
|
+
return `${stripLocalhost(override.toLowerCase())}${LOCALHOST_SUFFIX}`;
|
|
130
|
+
}
|
|
131
|
+
let labels = packageNameLabels(source.packageName);
|
|
132
|
+
if (labels.length === 0) labels = [sanitizeLabel(source.dirName)].filter(Boolean);
|
|
133
|
+
return labels.length === 0 ? LOCALHOST : `${labels.join('.')}${LOCALHOST_SUFFIX}`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* `deriveDevHostname` for the app in `appDir` — the directory its
|
|
138
|
+
* `.timber/` lives in (`devRecordRoot`), where its package.json is. A
|
|
139
|
+
* missing or unreadable package.json falls through to the directory name.
|
|
140
|
+
*/
|
|
141
|
+
export function resolveDevHostname(appDir: string, override: string | false | undefined): string {
|
|
142
|
+
let packageName: unknown;
|
|
143
|
+
try {
|
|
144
|
+
packageName = (
|
|
145
|
+
JSON.parse(readFileSync(join(appDir, 'package.json'), 'utf8')) as {
|
|
146
|
+
name?: unknown;
|
|
147
|
+
}
|
|
148
|
+
).name;
|
|
149
|
+
} catch {
|
|
150
|
+
packageName = undefined;
|
|
151
|
+
}
|
|
152
|
+
return deriveDevHostname({ override, packageName, dirName: basename(appDir) });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A `cert` entry as Vite reads it (`readFileIfExists` in its
|
|
157
|
+
* `resolveHttpsConfig`): a string is first tried as a file path, resolved
|
|
158
|
+
* against the cwd, and is PEM text only when no such file can be read.
|
|
159
|
+
* `config.server.https` keeps the raw option, so the path is read here too.
|
|
160
|
+
*/
|
|
161
|
+
function certBytes(entry: unknown): string | Uint8Array | null {
|
|
162
|
+
if (entry instanceof Uint8Array) return entry;
|
|
163
|
+
if (typeof entry !== 'string') return null;
|
|
164
|
+
try {
|
|
165
|
+
return readFileSync(resolve(entry));
|
|
166
|
+
} catch {
|
|
167
|
+
return entry;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether a TLS `cert` option (PEM string or Buffer, a path to one, or an
|
|
173
|
+
* array of them — Node's `tls` shape plus Vite's paths) names `hostname`.
|
|
174
|
+
* A `pfx`-only config has no `cert` and so keeps `localhost`. An https dev server prints the
|
|
175
|
+
* named URL only when it does: a trusted certificate issued for `localhost`
|
|
176
|
+
* alone (mkcert's default) would turn a working URL into a certificate error.
|
|
177
|
+
*/
|
|
178
|
+
export function certCoversHostname(cert: unknown, hostname: string): boolean {
|
|
179
|
+
const pems = Array.isArray(cert) ? cert : [cert];
|
|
180
|
+
return pems.some((entry) => {
|
|
181
|
+
const pem = certBytes(entry);
|
|
182
|
+
if (pem === null) return false;
|
|
183
|
+
try {
|
|
184
|
+
return new X509Certificate(pem).checkHost(hostname) !== undefined;
|
|
185
|
+
} catch {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The hostname to print for this server, after the https check. `https` is
|
|
193
|
+
* Vite's resolved `server.https` (undefined for plain http).
|
|
194
|
+
*/
|
|
195
|
+
export function effectiveDevHostname(
|
|
196
|
+
hostname: string,
|
|
197
|
+
https: { cert?: unknown } | undefined
|
|
198
|
+
): string {
|
|
199
|
+
if (hostname === LOCALHOST || !https) return hostname;
|
|
200
|
+
return certCoversHostname(https.cert, hostname) ? hostname : LOCALHOST;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Vite's `server.resolvedUrls` shape — the URLs it prints under Local and
|
|
205
|
+
* Network and picks from for `server.open`.
|
|
206
|
+
*/
|
|
207
|
+
export interface ResolvedServerUrls {
|
|
208
|
+
local: string[];
|
|
209
|
+
network: string[];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Rename the `localhost` entries of `urls.local` to `hostname`. Only those:
|
|
214
|
+
* an explicit loopback IP (`host: '127.0.0.1'`) is what the developer asked
|
|
215
|
+
* to see, certificate-derived names already name a host, and network URLs
|
|
216
|
+
* are other machines' way in. Idempotent: a renamed URL is no longer a
|
|
217
|
+
* `localhost` URL.
|
|
218
|
+
*/
|
|
219
|
+
export function withDevHostname<T extends ResolvedServerUrls>(urls: T, hostname: string): T {
|
|
220
|
+
if (hostname === LOCALHOST) return urls;
|
|
221
|
+
const local = urls.local.map((href) => {
|
|
222
|
+
const url = new URL(href);
|
|
223
|
+
if (url.hostname !== LOCALHOST) return href;
|
|
224
|
+
url.hostname = hostname;
|
|
225
|
+
return url.href;
|
|
226
|
+
});
|
|
227
|
+
return { ...urls, local: [...new Set(local)] };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The same URL through plain `localhost`: what a non-browser HTTP client can
|
|
232
|
+
* reach. Browsers and curl resolve `*.localhost` themselves, but Node, Python
|
|
233
|
+
* and other clients ask the OS, and not every resolver (glibc without
|
|
234
|
+
* systemd-resolved) maps `*.localhost` to loopback. The server answers both
|
|
235
|
+
* names, so only the hostname changes. Other URLs are returned unchanged.
|
|
236
|
+
*
|
|
237
|
+
* Under https the swap also has to survive TLS hostname verification: a
|
|
238
|
+
* certificate issued for `blog.localhost` alone fails for `localhost`
|
|
239
|
+
* (`ERR_TLS_CERT_ALTNAME_INVALID`), so the named URL is kept unless the
|
|
240
|
+
* certificate covers `localhost` too. `https` is Vite's `server.https`.
|
|
241
|
+
*/
|
|
242
|
+
export function loopbackUrl(href: string, https: { cert?: unknown } | undefined): string {
|
|
243
|
+
const url = new URL(href);
|
|
244
|
+
if (!url.hostname.endsWith(LOCALHOST_SUFFIX)) return href;
|
|
245
|
+
if (url.protocol === 'https:' && !certCoversHostname(https?.cert, LOCALHOST)) return href;
|
|
246
|
+
url.hostname = LOCALHOST;
|
|
247
|
+
return url.href;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The URL a server is opened at, after the rename: Vite's own choice, as its
|
|
252
|
+
* `getServerUrlByHost` makes it for `server.open` — the first URL containing
|
|
253
|
+
* a string `server.host`, else `local[0]`, else `network[0]`. The discovery
|
|
254
|
+
* record stores this, so `timber dev status` reports the URL Vite opens.
|
|
255
|
+
*/
|
|
256
|
+
export function primaryServerUrl(
|
|
257
|
+
urls: ResolvedServerUrls | null | undefined,
|
|
258
|
+
hostname: string,
|
|
259
|
+
serverHost: string | boolean | undefined
|
|
260
|
+
): string | undefined {
|
|
261
|
+
if (!urls) return undefined;
|
|
262
|
+
const named = withDevHostname(urls, hostname);
|
|
263
|
+
const all = [...named.local, ...named.network];
|
|
264
|
+
const byHost =
|
|
265
|
+
typeof serverHost === 'string' ? all.find((url) => url.includes(serverHost)) : undefined;
|
|
266
|
+
return byHost ?? named.local[0] ?? named.network[0];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** The URLs a discovery record advertises. */
|
|
270
|
+
export interface AdvertisedUrls {
|
|
271
|
+
/** What the server printed and opens (`primaryServerUrl`). */
|
|
272
|
+
url: string;
|
|
273
|
+
/** The same server for non-browser HTTP clients (`loopbackUrl`). */
|
|
274
|
+
loopbackUrl: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The record's URLs, computed by the server, which alone knows its
|
|
279
|
+
* certificate. `server` is Vite's resolved `server` config.
|
|
280
|
+
*/
|
|
281
|
+
export function advertisedUrls(
|
|
282
|
+
urls: ResolvedServerUrls | null | undefined,
|
|
283
|
+
hostname: string,
|
|
284
|
+
server: { host?: string | boolean; https?: { cert?: unknown } } | undefined
|
|
285
|
+
): AdvertisedUrls | undefined {
|
|
286
|
+
const url = primaryServerUrl(urls, hostname, server?.host);
|
|
287
|
+
return url === undefined ? undefined : { url, loopbackUrl: loopbackUrl(url, server?.https) };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** The slice of `ViteDevServer` the rename needs. */
|
|
291
|
+
interface DevHostnameServer {
|
|
292
|
+
httpServer: { on(event: 'listening', listener: () => void): unknown } | null;
|
|
293
|
+
resolvedUrls: ResolvedServerUrls | null;
|
|
294
|
+
config: { server?: { https?: { cert?: unknown } } };
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Resolve the app's dev hostname and rename the printed/opened URL once the
|
|
299
|
+
* server is listening. Returns the hostname so the discovery record can
|
|
300
|
+
* describe the same URL (`primaryServerUrl`).
|
|
301
|
+
*
|
|
302
|
+
* Vite assigns `resolvedUrls` in a `listening` listener it *prepends* in
|
|
303
|
+
* `listen()`, after every `configureServer` hook has run, so this listener
|
|
304
|
+
* always sees them; `printUrls()` and `openBrowser()` run after `listen()`
|
|
305
|
+
* resolves. Middleware mode has no `httpServer` and prints nothing.
|
|
306
|
+
*/
|
|
307
|
+
export function applyDevHostname(
|
|
308
|
+
server: DevHostnameServer,
|
|
309
|
+
appDir: string,
|
|
310
|
+
override: string | false | undefined
|
|
311
|
+
): string {
|
|
312
|
+
const hostname = effectiveDevHostname(
|
|
313
|
+
resolveDevHostname(appDir, override),
|
|
314
|
+
server.config.server?.https
|
|
315
|
+
);
|
|
316
|
+
if (server.httpServer && hostname !== LOCALHOST) {
|
|
317
|
+
server.httpServer.on('listening', () => {
|
|
318
|
+
if (server.resolvedUrls) server.resolvedUrls = withDevHostname(server.resolvedUrls, hostname);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
return hostname;
|
|
322
|
+
}
|
|
@@ -12,7 +12,13 @@
|
|
|
12
12
|
* Design docs: 18-build-system.md §"Dev Server", 02-rendering-pipeline.md
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import {
|
|
16
|
+
loadConfigFromFile,
|
|
17
|
+
normalizePath,
|
|
18
|
+
type Plugin,
|
|
19
|
+
type ViteDevServer,
|
|
20
|
+
type DevEnvironment,
|
|
21
|
+
} from 'vite';
|
|
16
22
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
17
23
|
import type { TLSSocket } from 'node:tls';
|
|
18
24
|
import { existsSync, realpathSync, statSync } from 'node:fs';
|
|
@@ -32,7 +38,8 @@ import {
|
|
|
32
38
|
type DevHooks,
|
|
33
39
|
} from '../dev-tools/dev-page-shell.ts';
|
|
34
40
|
import { addVirtualModuleContext } from '../config-validation.ts';
|
|
35
|
-
import { registerDevDiscovery } from './dev-discovery.ts';
|
|
41
|
+
import { devRecordRoot, registerDevDiscovery } from './dev-discovery.ts';
|
|
42
|
+
import { advertisedUrls, applyDevHostname } from './dev-hostname.ts';
|
|
36
43
|
import {
|
|
37
44
|
createGraphEndpointMiddleware,
|
|
38
45
|
makeGraphUpdateChannel,
|
|
@@ -40,8 +47,9 @@ import {
|
|
|
40
47
|
} from './graph-endpoint.ts';
|
|
41
48
|
import { compressResponse } from '../server/compress.ts';
|
|
42
49
|
import { isMetadataRouteServePath } from '../server/metadata-routes.ts';
|
|
43
|
-
import { canonicalize } from '../server/canonicalize.ts';
|
|
44
|
-
import { PREBUILT_DEV_CLEAR_EVENT } from '../server/prebuilt/dev-store.ts';
|
|
50
|
+
import { canonicalize, requestTargetUrl } from '../server/canonicalize.ts';
|
|
51
|
+
import { PREBUILT_DEV_CLEAR_EVENT, type DevStoreClear } from '../server/prebuilt/dev-store.ts';
|
|
52
|
+
import { clearDevStoreOnWatcherEvents, componentsChangedBy } from './dev-store-clear.ts';
|
|
45
53
|
import { matchUrlParts } from '../server/tree-match.ts';
|
|
46
54
|
import type { RouteTree } from '../routing/types.ts';
|
|
47
55
|
|
|
@@ -159,12 +167,58 @@ export function timberDevServer(ctx: PluginContext): Plugin {
|
|
|
159
167
|
server.watcher.on('add', onConfigChange);
|
|
160
168
|
server.watcher.on('unlink', onConfigChange);
|
|
161
169
|
|
|
170
|
+
// Vite's own restarts (vite.config.ts or one of its dependencies, a
|
|
171
|
+
// .env file) go through server.restart(), which
|
|
172
|
+
// builds a new server in this process and leaks the old one through
|
|
173
|
+
// rolldown's native resolver (rolldown#10887). Under the supervisor,
|
|
174
|
+
// restart the process instead, as timber.config.ts changes do
|
|
175
|
+
// (TIM-1590). The new config is loaded here first: a vite.config.ts
|
|
176
|
+
// that fails to evaluate would fail the new worker's startup, and the
|
|
177
|
+
// supervisor respawns only on RESTART_EXIT_CODE, so exiting would take
|
|
178
|
+
// the dev server down. Vite's own restart keeps the old server then.
|
|
179
|
+
if (hasSupervisor) {
|
|
180
|
+
server.restart = async () => {
|
|
181
|
+
const { configFile, mode, root, logger } = server.config;
|
|
182
|
+
try {
|
|
183
|
+
await loadConfigFromFile(
|
|
184
|
+
{ command: 'serve', mode },
|
|
185
|
+
configFile || undefined,
|
|
186
|
+
root,
|
|
187
|
+
'silent'
|
|
188
|
+
);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
logger.error(
|
|
191
|
+
`[timber] ${configFile ? basename(configFile) : 'Vite config'} failed to load — ` +
|
|
192
|
+
`keeping the running server.\n${error instanceof Error ? error.message : String(error)}`,
|
|
193
|
+
{ timestamp: true }
|
|
194
|
+
);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
console.log('\n[timber] Restarting the dev server process...\n');
|
|
198
|
+
process.exit(RESTART_EXIT_CODE);
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
162
202
|
// Listen for client-side errors forwarded from the browser.
|
|
163
203
|
// The browser entry sends 'timber:client-error' events via HMR
|
|
164
204
|
// for uncaught errors and unhandled rejections. We echo them back
|
|
165
205
|
// as Vite's '{ type: "error" }' payload to trigger the overlay.
|
|
166
206
|
listenForClientErrors(server, ctx.root);
|
|
167
207
|
|
|
208
|
+
// Before any of Vite's middlewares: an absolute-form or asterisk-form
|
|
209
|
+
// target becomes the origin-form path the pipeline will see, so Vite's
|
|
210
|
+
// transform/static middlewares and the checks in the timber
|
|
211
|
+
// middleware agree with it — `GET http://host/@vite/client` is Vite's,
|
|
212
|
+
// not a 404 from the app (TIM-1600). A target that names no URL is
|
|
213
|
+
// left for toWebRequest to answer with 400.
|
|
214
|
+
server.middlewares.use((req, _res, next) => {
|
|
215
|
+
if (req.url && !req.url.startsWith('/')) {
|
|
216
|
+
const url = requestTargetUrl('http://localhost', req.url);
|
|
217
|
+
if (url) req.url = url.pathname + url.search;
|
|
218
|
+
}
|
|
219
|
+
next();
|
|
220
|
+
});
|
|
221
|
+
|
|
168
222
|
// GET /__timber/graph — module-environment classification from the
|
|
169
223
|
// live env graphs, plus the timber:graph-update HMR push channel.
|
|
170
224
|
// Registered before the timber middleware so /__timber/* requests
|
|
@@ -172,17 +226,48 @@ export function timberDevServer(ctx: PluginContext): Plugin {
|
|
|
172
226
|
// plugin is apply: 'serve'). See design/47 §"Dev-server endpoint".
|
|
173
227
|
server.middlewares.use(createGraphEndpointMiddleware(server, ctx));
|
|
174
228
|
|
|
229
|
+
// Canonicalize watcher/hook paths into the module graphs' path
|
|
230
|
+
// space: under the default preserveSymlinks:false the graphs
|
|
231
|
+
// carry realpaths while watcher events can carry symlink paths
|
|
232
|
+
// — unkeyed by one canonical form, a pending entry would never
|
|
233
|
+
// match its own transform. Deleted files realpath their parent
|
|
234
|
+
// directory instead; virtual ids pass through untouched.
|
|
235
|
+
const toGraphPath = (file: string): string => {
|
|
236
|
+
// Optional-chained: mock servers in unit tests carry a bare
|
|
237
|
+
// config object without resolve options.
|
|
238
|
+
if (server.config?.resolve?.preserveSymlinks || file.includes('virtual:')) return file;
|
|
239
|
+
try {
|
|
240
|
+
return realpathSync(file);
|
|
241
|
+
} catch {
|
|
242
|
+
try {
|
|
243
|
+
return join(realpathSync(dirname(file)), basename(file));
|
|
244
|
+
} catch {
|
|
245
|
+
return file;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
175
250
|
// Every watcher event clears the RSC environment's cache.component dev
|
|
176
251
|
// store (TIM-1588) — source files, and files outside the module graph
|
|
177
|
-
// that a component reads with fs. A
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
//
|
|
252
|
+
// that a component reads with fs. A save of a module clears only the
|
|
253
|
+
// components it could have changed (TIM-1599). A raw listener, not
|
|
254
|
+
// hotUpdate: it runs in the same synchronous dispatch as every other
|
|
255
|
+
// watcher listener (timber-routing's reloads included), before Vite's
|
|
256
|
+
// own handling sends any HMR update. A browser that a reload or update
|
|
181
257
|
// makes refetch can only reach the server after the clear has gone
|
|
182
|
-
// out.
|
|
183
|
-
|
|
184
|
-
server.
|
|
185
|
-
|
|
258
|
+
// out. A trailing clear covers the saves the watcher drops
|
|
259
|
+
// (dev-store-clear.ts).
|
|
260
|
+
const rsc = server.environments.rsc;
|
|
261
|
+
clearDevStoreOnWatcherEvents(server.watcher, (changed) => {
|
|
262
|
+
if (!rsc) return;
|
|
263
|
+
const componentIds = componentsChangedBy(
|
|
264
|
+
changed,
|
|
265
|
+
rsc.moduleGraph,
|
|
266
|
+
ctx.devPrebuiltComponentIds ?? new Map(),
|
|
267
|
+
(path) => normalizePath(toGraphPath(path))
|
|
268
|
+
);
|
|
269
|
+
const data: DevStoreClear = componentIds === null ? {} : { componentIds };
|
|
270
|
+
rsc.hot.send({ type: 'custom', event: PREBUILT_DEV_CLEAR_EVENT, data });
|
|
186
271
|
});
|
|
187
272
|
graphChannel = makeGraphUpdateChannel(
|
|
188
273
|
ctx,
|
|
@@ -204,35 +289,26 @@ export function timberDevServer(ctx: PluginContext): Plugin {
|
|
|
204
289
|
}
|
|
205
290
|
return graph.getModuleById(file)?.transformResult != null;
|
|
206
291
|
},
|
|
207
|
-
|
|
208
|
-
// space: under the default preserveSymlinks:false the graphs
|
|
209
|
-
// carry realpaths while watcher events can carry symlink paths
|
|
210
|
-
// — unkeyed by one canonical form, a pending entry would never
|
|
211
|
-
// match its own transform. Deleted files realpath their parent
|
|
212
|
-
// directory instead; virtual ids pass through untouched.
|
|
213
|
-
(file) => {
|
|
214
|
-
// Optional-chained: mock servers in unit tests carry a bare
|
|
215
|
-
// config object without resolve options.
|
|
216
|
-
if (server.config?.resolve?.preserveSymlinks || file.includes('virtual:')) return file;
|
|
217
|
-
try {
|
|
218
|
-
return realpathSync(file);
|
|
219
|
-
} catch {
|
|
220
|
-
try {
|
|
221
|
-
return join(realpathSync(dirname(file)), basename(file));
|
|
222
|
-
} catch {
|
|
223
|
-
return file;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
292
|
+
toGraphPath
|
|
227
293
|
);
|
|
228
294
|
|
|
229
295
|
// Pre-hook — registers middleware before Vite's internals
|
|
230
296
|
server.middlewares.use(createTimberMiddleware(server, ctx));
|
|
231
297
|
|
|
298
|
+
// Print and open <name>.localhost:<port> instead of localhost:<port>, so
|
|
299
|
+
// each app gets its own cookie jar. See design/21 §Dev Hostnames.
|
|
300
|
+
const appDir = devRecordRoot(ctx.root, server.config.configFile);
|
|
301
|
+
const hostname = applyDevHostname(server, appDir, ctx.config.dev?.hostname);
|
|
302
|
+
|
|
232
303
|
// Write this server's .timber/dev/<pid>-<port>-<token>.json record once
|
|
233
|
-
// the server is listening so the graph CLI
|
|
234
|
-
// discover it. See design/
|
|
235
|
-
registerDevDiscovery(
|
|
304
|
+
// the server is listening so `timber dev status`, the graph CLI and the
|
|
305
|
+
// VS Code extension can discover it. See design/21 §Discovery Records.
|
|
306
|
+
registerDevDiscovery(
|
|
307
|
+
server.httpServer,
|
|
308
|
+
ctx.root,
|
|
309
|
+
() => advertisedUrls(server.resolvedUrls, hostname, server.config.server),
|
|
310
|
+
server.config
|
|
311
|
+
);
|
|
236
312
|
|
|
237
313
|
// Close the holding server and await the port release so Vite's
|
|
238
314
|
// port probe and bind see a free port. configureServer is awaited
|
|
@@ -369,6 +445,13 @@ function createTimberMiddleware(server: ViteDevServer, ctx: PluginContext) {
|
|
|
369
445
|
try {
|
|
370
446
|
// Convert Node IncomingMessage → Web Request
|
|
371
447
|
const webRequest = toWebRequest(req);
|
|
448
|
+
// A malformed Host or request target is the client's error: a 400,
|
|
449
|
+
// not a 500 and an overlay for a bug the app doesn't have (TIM-1600).
|
|
450
|
+
if (!webRequest) {
|
|
451
|
+
res.writeHead(400, { 'content-type': 'text/plain; charset=utf-8' });
|
|
452
|
+
res.end('Bad Request');
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
372
455
|
|
|
373
456
|
// Check for a platform-specific request wrapper (e.g., Cloudflare
|
|
374
457
|
// dev bindings). The cloudflareDevBindings() plugin stores a wrapper
|
|
@@ -484,15 +567,25 @@ function addTimberContext(error: Error): void {
|
|
|
484
567
|
* consulted: dev connections are direct, so the header would be
|
|
485
568
|
* attacker-controlled. (TIM-1067, B32)
|
|
486
569
|
*
|
|
570
|
+
* Returns null for a request that names no URL — a Host that is not a bare
|
|
571
|
+
* host[:port], or a request target that does not parse — which the caller
|
|
572
|
+
* answers with 400. (TIM-1600)
|
|
573
|
+
*
|
|
487
574
|
* Exported for tests.
|
|
488
575
|
*/
|
|
489
|
-
export function toWebRequest(nodeReq: IncomingMessage): Request {
|
|
576
|
+
export function toWebRequest(nodeReq: IncomingMessage): Request | null {
|
|
490
577
|
const protocol = (nodeReq.socket as TLSSocket | undefined)?.encrypted ? 'https' : 'http';
|
|
491
578
|
// Under HTTP/2 there is no Host header — the authority lives in the
|
|
492
579
|
// `:authority` pseudo-header.
|
|
493
580
|
const host =
|
|
494
581
|
nodeReq.headers.host ?? (nodeReq.headers[':authority'] as string | undefined) ?? 'localhost';
|
|
495
|
-
|
|
582
|
+
// The Host is an authority, nothing more. Pasted into the URL, one with a
|
|
583
|
+
// path or query moves the request target: `Host: localhost:5173/x?` and
|
|
584
|
+
// target `/admin` would route `/x` with search `?/admin`. A backslash is a
|
|
585
|
+
// path separator to the URL parser, and `@` would make the host userinfo.
|
|
586
|
+
const origin = /[/?#@\\]/.test(host) ? null : URL.parse(`${protocol}://${host}`)?.origin;
|
|
587
|
+
const url = origin ? requestTargetUrl(origin, nodeReq.url || '/') : null;
|
|
588
|
+
if (!url) return null;
|
|
496
589
|
|
|
497
590
|
const headers = new Headers();
|
|
498
591
|
for (const [key, value] of Object.entries(nodeReq.headers)) {
|