@timber-js/app 0.2.0-alpha.222 → 0.2.0-alpha.223
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-skill.md +21 -5
- package/dist/_chunks/{actions-vBHr2vqd.js → actions-7dTXYJfu.js} +53 -24
- package/dist/_chunks/actions-7dTXYJfu.js.map +1 -0
- package/dist/_chunks/{als-registry-BZqHCtq-.js → als-registry-DpygwCp0.js} +2 -3
- package/dist/_chunks/{als-registry-BZqHCtq-.js.map → als-registry-DpygwCp0.js.map} +1 -1
- package/dist/_chunks/{als-slots-BEEIPKYm.js → als-slots-kbQrHTzm.js} +2 -3
- package/dist/_chunks/{als-slots-BEEIPKYm.js.map → als-slots-kbQrHTzm.js.map} +1 -1
- package/dist/_chunks/{base-path-DaQrzbez.js → base-path-DDIx0FXe.js} +2 -3
- package/dist/_chunks/{base-path-DaQrzbez.js.map → base-path-DDIx0FXe.js.map} +1 -1
- package/dist/_chunks/{build-manifest-DWppEdLB.js → build-manifest-Y4jl7nwU.js} +2 -3
- package/dist/_chunks/{build-manifest-DWppEdLB.js.map → build-manifest-Y4jl7nwU.js.map} +1 -1
- package/dist/_chunks/{build-output-helper-RV_BRcF1.js → build-output-helper-B7wWGTfR.js} +14 -10
- package/dist/_chunks/build-output-helper-B7wWGTfR.js.map +1 -0
- package/dist/_chunks/{cache-api-DdcDLpBj.js → cache-api-TDZ4hlDc.js} +190 -38
- package/dist/_chunks/cache-api-TDZ4hlDc.js.map +1 -0
- package/dist/_chunks/{canonicalize-BAWkWiKK.js → canonicalize-CqK135BN.js} +29 -4
- package/dist/_chunks/{canonicalize-BAWkWiKK.js.map → canonicalize-CqK135BN.js.map} +1 -1
- package/dist/_chunks/chains-CwOr3Myj.js +1 -0
- package/dist/_chunks/{chains-BchW_AtW.js → chains-Dgm3PrMe.js} +3 -4
- package/dist/_chunks/{chains-BchW_AtW.js.map → chains-Dgm3PrMe.js.map} +1 -1
- package/dist/_chunks/{classify-IqzMpxMs.js → classify--_kINHQV.js} +4 -5
- package/dist/_chunks/{classify-IqzMpxMs.js.map → classify--_kINHQV.js.map} +1 -1
- package/dist/_chunks/{cli-check-DQne_YhU.js → cli-check-Dv3f8d2j.js} +5 -6
- package/dist/_chunks/{cli-check-DQne_YhU.js.map → cli-check-Dv3f8d2j.js.map} +1 -1
- package/dist/_chunks/{cli-context-_mPttGGY.js → cli-context-CbZp32SK.js} +3 -4
- package/dist/_chunks/{cli-context-_mPttGGY.js.map → cli-context-CbZp32SK.js.map} +1 -1
- package/dist/_chunks/cli-context-n5hmkdla.js +1 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js +138 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js.map +1 -0
- package/dist/_chunks/cli-init-BoXOYYil.js +196 -0
- package/dist/_chunks/cli-init-BoXOYYil.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js → cli-schema-sync-DIPurq7X.js} +4 -5
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js.map → cli-schema-sync-DIPurq7X.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-v872sHms.js → cli-schema-sync-uq72EZmD.js} +1 -1
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js → client-dep-entries-CP7AkMCM.js} +4 -5
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js.map → client-dep-entries-CP7AkMCM.js.map} +1 -1
- package/dist/_chunks/{cloudflare-Byxl8FWP.js → cloudflare-B75X6u4O.js} +10 -13
- package/dist/_chunks/{cloudflare-Byxl8FWP.js.map → cloudflare-B75X6u4O.js.map} +1 -1
- package/dist/_chunks/{codec-registry-oOUxugz3.js → codec-registry-CPc6bjVl.js} +2 -3
- package/dist/_chunks/{codec-registry-oOUxugz3.js.map → codec-registry-CPc6bjVl.js.map} +1 -1
- package/dist/_chunks/{codegen-Bps1sLKJ.js → codegen-B9oWkWGf.js} +5 -8
- package/dist/_chunks/{codegen-Bps1sLKJ.js.map → codegen-B9oWkWGf.js.map} +1 -1
- package/dist/_chunks/{convention-lint-VwzrtjIt.js → convention-lint-hZwz5wd4.js} +8 -11
- package/dist/_chunks/{convention-lint-VwzrtjIt.js.map → convention-lint-hZwz5wd4.js.map} +1 -1
- package/dist/_chunks/dev-discovery-YnabkCKD.js +238 -0
- package/dist/_chunks/dev-discovery-YnabkCKD.js.map +1 -0
- package/dist/_chunks/{dev-server-BNr5drEO.js → dev-server-C61GWpGg.js} +369 -55
- package/dist/_chunks/dev-server-C61GWpGg.js.map +1 -0
- package/dist/_chunks/dev-server-CBvvM7Lr.js +1 -0
- package/dist/_chunks/{dev-store-BOa304m_.js → dev-store-BvdqtHvK.js} +82 -38
- package/dist/_chunks/dev-store-BvdqtHvK.js.map +1 -0
- package/dist/_chunks/{dist-DtrJyBbw.js → dist-C1Rjlo6s.js} +3 -5
- package/dist/_chunks/{dist-DtrJyBbw.js.map → dist-C1Rjlo6s.js.map} +1 -1
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js → error-boundary-DRQXGWCp.js} +20 -27
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js.map → error-boundary-DRQXGWCp.js.map} +1 -1
- package/dist/_chunks/{fast-hash-C-tVYrLb.js → fast-hash-DddxkU5Y.js} +2 -3
- package/dist/_chunks/{fast-hash-C-tVYrLb.js.map → fast-hash-DddxkU5Y.js.map} +1 -1
- package/dist/_chunks/{flight-source-node-BdHUOUqg.js → flight-source-node-0Tp6evlz.js} +6 -8
- package/dist/_chunks/flight-source-node-0Tp6evlz.js.map +1 -0
- package/dist/_chunks/{format-BKclgVbk.js → format-DuPOoXUP.js} +2 -3
- package/dist/_chunks/{format-BKclgVbk.js.map → format-DuPOoXUP.js.map} +1 -1
- package/dist/_chunks/{fs-identity-BRKuL215.js → fs-identity-BmQ_Agg-.js} +3 -5
- package/dist/_chunks/{fs-identity-BRKuL215.js.map → fs-identity-BmQ_Agg-.js.map} +1 -1
- package/dist/_chunks/{global-context-B9PFncvb.js → global-context-DbxNWeBP.js} +2 -3
- package/dist/_chunks/{global-context-B9PFncvb.js.map → global-context-DbxNWeBP.js.map} +1 -1
- package/dist/_chunks/{graph-cache-CYiUS2aS.js → graph-cache-B1LAg4t7.js} +5 -89
- package/dist/_chunks/graph-cache-B1LAg4t7.js.map +1 -0
- package/dist/_chunks/{href-validation-BIrxavIy.js → href-validation-CEZy1V-k.js} +4 -7
- package/dist/_chunks/{href-validation-BIrxavIy.js.map → href-validation-CEZy1V-k.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js → json-lossy-check-DVkLUlfC.js} +3 -4
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js.map → json-lossy-check-DVkLUlfC.js.map} +1 -1
- package/dist/_chunks/{live-graph-DEu_GWbc.js → live-graph-BcVjQ1Te.js} +6 -7
- package/dist/_chunks/{live-graph-DEu_GWbc.js.map → live-graph-BcVjQ1Te.js.map} +1 -1
- package/dist/_chunks/{logger-CI_hThfy.js → logger-CWk44DLp.js} +89 -47
- package/dist/_chunks/logger-CWk44DLp.js.map +1 -0
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js → metadata-routes-BL26HCDd.js} +2 -3
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js.map → metadata-routes-BL26HCDd.js.map} +1 -1
- package/dist/_chunks/{navigation-root-BQfo1-kG.js → navigation-root-M3B2ZrdO.js} +6 -10
- package/dist/_chunks/{navigation-root-BQfo1-kG.js.map → navigation-root-M3B2ZrdO.js.map} +1 -1
- package/dist/_chunks/{node-response-bF0bKoig.js → node-response-B9aviPDa.js} +43 -9
- package/dist/_chunks/node-response-B9aviPDa.js.map +1 -0
- package/dist/_chunks/{param-value-C8TNYchQ.js → param-value-DqlGfF57.js} +2 -3
- package/dist/_chunks/{param-value-C8TNYchQ.js.map → param-value-DqlGfF57.js.map} +1 -1
- package/dist/_chunks/{plugin-context-uDHFqHHJ.js → plugin-context-BfSRKJfz.js} +1 -1
- package/dist/_chunks/{plugin-context-DxMMvjUt.js → plugin-context-FCkaNLUB.js} +4 -6
- package/dist/_chunks/plugin-context-FCkaNLUB.js.map +1 -0
- package/dist/_chunks/{poison-rules-DoEhbqaY.js → poison-rules-Bmz-lCPi.js} +2 -3
- package/dist/_chunks/{poison-rules-DoEhbqaY.js.map → poison-rules-Bmz-lCPi.js.map} +1 -1
- package/dist/_chunks/{poison-scan-DTWIfNgD.js → poison-scan-DJYxZc_7.js} +4 -5
- package/dist/_chunks/{poison-scan-DTWIfNgD.js.map → poison-scan-DJYxZc_7.js.map} +1 -1
- package/dist/_chunks/{purge-store-WZaxu-3m.js → purge-store-8BqLAYZ1.js} +2 -3
- package/dist/_chunks/{purge-store-WZaxu-3m.js.map → purge-store-8BqLAYZ1.js.map} +1 -1
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js → render-timeout-MrrqD1wd.js} +2 -3
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js.map → render-timeout-MrrqD1wd.js.map} +1 -1
- package/dist/_chunks/{resolve-schema-CkAInout.js → resolve-schema-B-aCuTu3.js} +3 -4
- package/dist/_chunks/{resolve-schema-CkAInout.js.map → resolve-schema-B-aCuTu3.js.map} +1 -1
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js → rsc-cache-key-D0cb0Gmc.js} +2 -3
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js.map → rsc-cache-key-D0cb0Gmc.js.map} +1 -1
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js → rsc-media-type-m8jz9u6_.js} +2 -3
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js.map → rsc-media-type-m8jz9u6_.js.map} +1 -1
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js → rsc-payload-path-EphpDB-J.js} +2 -3
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js.map → rsc-payload-path-EphpDB-J.js.map} +1 -1
- package/dist/_chunks/{scan-BoP17W3w.js → scan-CyizcBiX.js} +2 -3
- package/dist/_chunks/{scan-BoP17W3w.js.map → scan-CyizcBiX.js.map} +1 -1
- package/dist/_chunks/{scanner-C8fdKvKG.js → scanner-CJC-ScJU.js} +15 -23
- package/dist/_chunks/{scanner-C8fdKvKG.js.map → scanner-CJC-ScJU.js.map} +1 -1
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js → schema-bridge-DyRs3cqy.js} +2 -3
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js.map → schema-bridge-DyRs3cqy.js.map} +1 -1
- package/dist/_chunks/{segment-classify-C539Pa2O.js → segment-classify-Ho8jXWeC.js} +3 -5
- package/dist/_chunks/{segment-classify-C539Pa2O.js.map → segment-classify-Ho8jXWeC.js.map} +1 -1
- package/dist/_chunks/{segment-context-D3DNxKFq.js → segment-context-CYiGTi3K.js} +4 -6
- package/dist/_chunks/{segment-context-D3DNxKFq.js.map → segment-context-CYiGTi3K.js.map} +1 -1
- package/dist/_chunks/{segment-keys-D5hu1hz4.js → segment-keys-Y60KNc8C.js} +2 -3
- package/dist/_chunks/{segment-keys-D5hu1hz4.js.map → segment-keys-Y60KNc8C.js.map} +1 -1
- package/dist/_chunks/{singleflight-BeVMMKi0.js → singleflight-BChPMjwH.js} +2 -3
- package/dist/_chunks/{singleflight-BeVMMKi0.js.map → singleflight-BChPMjwH.js.map} +1 -1
- package/dist/_chunks/{sizeof-CO3dk0V1.js → sizeof-DG4W40lv.js} +3 -4
- package/dist/_chunks/{sizeof-CO3dk0V1.js.map → sizeof-DG4W40lv.js.map} +1 -1
- package/dist/_chunks/{ssr-data-nA3I70_n.js → ssr-data-9hPtcNOr.js} +3 -4
- package/dist/_chunks/{ssr-data-nA3I70_n.js.map → ssr-data-9hPtcNOr.js.map} +1 -1
- package/dist/_chunks/{state-BhNGPsdi.js → state-B-EBjeER.js} +2 -3
- package/dist/_chunks/{state-BhNGPsdi.js.map → state-B-EBjeER.js.map} +1 -1
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js → status-page-marker-XIQXlTOb.js} +8 -13
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js.map → status-page-marker-XIQXlTOb.js.map} +1 -1
- package/dist/_chunks/{tree-match-6yihorhk.js → tree-match-Bqdr9szG.js} +2 -3
- package/dist/_chunks/{tree-match-6yihorhk.js.map → tree-match-Bqdr9szG.js.map} +1 -1
- package/dist/_chunks/{use-query-states-I3JMng6J.js → use-query-states-pkDV-jSg.js} +4 -7
- package/dist/_chunks/{use-query-states-I3JMng6J.js.map → use-query-states-pkDV-jSg.js.map} +1 -1
- package/dist/_chunks/{walkers-BqzxnwGC.js → walkers-DIE203ir.js} +6 -8
- package/dist/_chunks/{walkers-BqzxnwGC.js.map → walkers-DIE203ir.js.map} +1 -1
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js → write-file-atomic-DW8m_Atv.js} +2 -3
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js.map → write-file-atomic-DW8m_Atv.js.map} +1 -1
- package/dist/adapters/build-output-helper.d.ts +10 -1
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare-dev.js +2 -3
- package/dist/adapters/cloudflare-kv-cache.js +3 -4
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/nitro-presets.d.ts +6 -0
- package/dist/adapters/nitro-presets.d.ts.map +1 -1
- package/dist/adapters/nitro-preview.d.ts.map +1 -1
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +94 -57
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/analyze/crawl-entry.js +7 -9
- package/dist/analyze/crawl-entry.js.map +1 -1
- package/dist/analyze/graph-command.d.ts.map +1 -1
- package/dist/analyze/graph-command.js +19 -105
- package/dist/analyze/graph-command.js.map +1 -1
- package/dist/cache/index.js +3 -3
- package/dist/cache/key-discipline.d.ts +61 -0
- package/dist/cache/key-discipline.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.js +1 -2
- package/dist/cache/stores/memory.js +2 -3
- package/dist/cache/stores/redis.js +1 -2
- package/dist/cache/stores/vercel.js +1 -2
- package/dist/cache/timber-cache.d.ts +5 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.js +1 -2
- package/dist/cdn/fastly-purge.js +1 -2
- package/dist/cdn/index.js +2 -3
- package/dist/cdn/workers-cache-purge.js +3 -5
- package/dist/cdn/workers-cache-purge.js.map +1 -1
- package/dist/cli-dev-status.d.ts +75 -0
- package/dist/cli-dev-status.d.ts.map +1 -0
- package/dist/cli-init.d.ts +72 -0
- package/dist/cli-init.d.ts.map +1 -0
- package/dist/cli.d.ts +4 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -54
- package/dist/cli.js.map +1 -1
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +22 -34
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +13 -18
- package/dist/client/internal.js.map +1 -1
- package/dist/client/use-cookie.d.ts +18 -5
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/codec.js +2 -3
- package/dist/config-types.d.ts +22 -5
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +40 -67
- package/dist/cookies/index.js.map +1 -1
- package/dist/cookies/json-cookie.d.ts +4 -4
- package/dist/index.js +266 -229
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +3 -4
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/dev-discovery.d.ts +69 -5
- package/dist/plugins/dev-discovery.d.ts.map +1 -1
- package/dist/plugins/dev-hostname.d.ts +152 -0
- package/dist/plugins/dev-hostname.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +5 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/dev-store-clear.d.ts +59 -4
- package/dist/plugins/dev-store-clear.d.ts.map +1 -1
- package/dist/plugins/graph-endpoint.d.ts +4 -2
- package/dist/plugins/graph-endpoint.d.ts.map +1 -1
- package/dist/plugins/prebuilt.d.ts.map +1 -1
- package/dist/routing/index.js +4 -4
- package/dist/rsc-runtime/rsc.d.ts +2 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/server-references.d.ts +8 -0
- package/dist/rsc-runtime/server-references.d.ts.map +1 -0
- package/dist/search-params/index.js +5 -7
- package/dist/search-params/index.js.map +1 -1
- package/dist/server/access-gate.d.ts +12 -0
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/canonicalize.d.ts +21 -0
- package/dist/server/canonicalize.d.ts.map +1 -1
- package/dist/server/cookie-context.d.ts +8 -1
- package/dist/server/cookie-context.d.ts.map +1 -1
- package/dist/server/flight-source-node.d.ts.map +1 -1
- package/dist/server/flight-source.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +8 -13
- package/dist/server/index.js.map +1 -1
- package/dist/server/interception-gates.d.ts +49 -0
- package/dist/server/interception-gates.d.ts.map +1 -0
- package/dist/server/internal.js +1061 -943
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +17 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/param-coercion.d.ts +8 -0
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/pipeline-interception.d.ts +34 -4
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline-metadata-route.d.ts +24 -0
- package/dist/server/pipeline-metadata-route.d.ts.map +1 -0
- package/dist/server/pipeline-metadata.d.ts +3 -2
- package/dist/server/pipeline-metadata.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts +9 -3
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +18 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/prebuilt/dev-store.d.ts +68 -22
- package/dist/server/prebuilt/dev-store.d.ts.map +1 -1
- package/dist/server/prebuilt/overlay.d.ts +8 -0
- package/dist/server/prebuilt/overlay.d.ts.map +1 -1
- package/dist/server/prebuilt-runtime.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +13 -0
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/render-utils.d.ts +21 -0
- package/dist/server/render-utils.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +14 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts +7 -0
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +14 -3
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/signal-identity.d.ts +6 -0
- package/dist/server/signal-identity.d.ts.map +1 -1
- package/dist/server/traced-access.d.ts +18 -0
- package/dist/server/traced-access.d.ts.map +1 -0
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/types.d.ts +5 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-local.js +1 -2
- package/dist/shims/headers.d.ts +11 -4
- package/dist/shims/headers.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +3 -1
- package/docs/api/32-api-cache.mdx +1 -1
- package/docs/api/34-api-config.mdx +22 -0
- package/docs/api/36-cli.mdx +72 -6
- package/docs/learn/01-quick-start.mdx +1 -1
- package/docs/learn/06-typed-params.mdx +2 -2
- package/docs/learn/10-caching.mdx +26 -5
- package/llms.txt +1 -1
- package/package.json +12 -12
- package/src/adapters/build-output-helper.ts +26 -4
- package/src/adapters/cloudflare.ts +1 -0
- package/src/adapters/nitro-presets.ts +15 -0
- package/src/adapters/nitro-preview.ts +66 -34
- package/src/adapters/nitro.ts +14 -6
- package/src/analyze/graph-command.ts +25 -133
- package/src/cache/key-discipline.ts +218 -0
- package/src/cache/timber-cache.ts +42 -5
- package/src/cli-dev-status.ts +196 -0
- package/src/cli-init.ts +278 -0
- package/src/cli.ts +33 -79
- package/src/client/error-boundary.tsx +19 -2
- package/src/client/use-cookie.ts +33 -21
- package/src/config-types.ts +22 -5
- package/src/config-validation.ts +17 -0
- package/src/cookies/define-cookie.ts +10 -46
- package/src/cookies/json-cookie.ts +4 -4
- package/src/plugin-context.ts +7 -0
- package/src/plugins/dev-discovery.ts +216 -6
- package/src/plugins/dev-hostname.ts +322 -0
- package/src/plugins/dev-server.ts +96 -37
- package/src/plugins/dev-store-clear.ts +105 -7
- package/src/plugins/graph-endpoint.ts +15 -3
- package/src/plugins/prebuilt.ts +9 -0
- package/src/rsc-runtime/rsc.ts +7 -3
- package/src/rsc-runtime/server-references.ts +73 -0
- package/src/rsc-runtime/vendor-types.d.ts +9 -0
- package/src/server/access-gate.tsx +32 -20
- package/src/server/action-handler.ts +40 -34
- package/src/server/canonicalize.ts +27 -0
- package/src/server/cookie-context.ts +11 -3
- package/src/server/flight-source-node.ts +5 -2
- package/src/server/flight-source.ts +4 -3
- package/src/server/index.ts +6 -1
- package/src/server/interception-gates.ts +94 -0
- package/src/server/logger.ts +23 -0
- package/src/server/param-coercion.ts +22 -0
- package/src/server/pipeline-interception.ts +64 -4
- package/src/server/pipeline-metadata-route.ts +242 -0
- package/src/server/pipeline-metadata.ts +7 -5
- package/src/server/pipeline-phases.ts +71 -131
- package/src/server/pipeline.ts +20 -2
- package/src/server/prebuilt/dev-store.ts +113 -34
- package/src/server/prebuilt/overlay.ts +18 -0
- package/src/server/prebuilt-runtime.ts +43 -44
- package/src/server/primitives.ts +14 -0
- package/src/server/render-utils.ts +25 -0
- package/src/server/request-context.ts +27 -3
- package/src/server/route-element-builder.ts +15 -2
- package/src/server/route-handler.ts +3 -2
- package/src/server/route-matcher.ts +48 -33
- package/src/server/rsc-entry/api-handler.ts +2 -33
- package/src/server/rsc-entry/index.ts +8 -3
- package/src/server/rsc-entry/rsc-stream.ts +7 -1
- package/src/server/signal-identity.ts +30 -12
- package/src/server/traced-access.ts +50 -0
- package/src/server/tracing.ts +18 -1
- package/src/server/types.ts +5 -4
- package/src/shims/headers.ts +12 -4
- package/dist/_chunks/actions-vBHr2vqd.js.map +0 -1
- package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +0 -1
- package/dist/_chunks/cache-api-DdcDLpBj.js.map +0 -1
- package/dist/_chunks/chains-B8TCLved.js +0 -1
- package/dist/_chunks/cli-context-BJQB6rtF.js +0 -1
- package/dist/_chunks/dev-server-BNr5drEO.js.map +0 -1
- package/dist/_chunks/dev-server-CUg7Mqh_.js +0 -1
- package/dist/_chunks/dev-store-BOa304m_.js.map +0 -1
- package/dist/_chunks/flight-source-node-BdHUOUqg.js.map +0 -1
- package/dist/_chunks/graph-cache-CYiUS2aS.js.map +0 -1
- package/dist/_chunks/logger-CI_hThfy.js.map +0 -1
- package/dist/_chunks/node-response-bF0bKoig.js.map +0 -1
- package/dist/_chunks/plugin-context-DxMMvjUt.js.map +0 -1
- package/dist/server/prebuilt/key-discipline.d.ts +0 -52
- package/dist/server/prebuilt/key-discipline.d.ts.map +0 -1
- package/src/server/prebuilt/key-discipline.ts +0 -122
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { request } from "node:http";
|
|
4
|
+
import { request as request$1 } from "node:https";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { Server } from "node:tls";
|
|
7
|
+
// src/plugins/dev-discovery.ts
|
|
8
|
+
/** Relative path of the discovery directory within the project root. */
|
|
9
|
+
var DEV_DISCOVERY_DIR = join(".timber", "dev");
|
|
10
|
+
/** Best-effort "is this pid alive" — signal 0 probes without killing. */
|
|
11
|
+
function isPidAlive(pid) {
|
|
12
|
+
try {
|
|
13
|
+
process.kill(pid, 0);
|
|
14
|
+
return true;
|
|
15
|
+
} catch (error) {
|
|
16
|
+
return error.code === "EPERM";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Remove sibling records whose pid is no longer alive. Purely a
|
|
21
|
+
* tidiness sweep — consumers already ignore records that fail the
|
|
22
|
+
* pid + probe validation, so missing a stale record here is harmless.
|
|
23
|
+
*/
|
|
24
|
+
function sweepDeadRecords(dir) {
|
|
25
|
+
let entries;
|
|
26
|
+
try {
|
|
27
|
+
entries = readdirSync(dir);
|
|
28
|
+
} catch {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
if (!entry.endsWith(".json")) continue;
|
|
33
|
+
const filePath = join(dir, entry);
|
|
34
|
+
try {
|
|
35
|
+
const record = JSON.parse(readFileSync(filePath, "utf8"));
|
|
36
|
+
if (typeof record.pid === "number" && !isPidAlive(record.pid)) rmSync(filePath, { force: true });
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The directory whose `.timber/dev/` holds a server's record: the Vite
|
|
42
|
+
* config file's directory, falling back to the resolved root for an inline
|
|
43
|
+
* (`configFile: false`) server. Every consumer — `timber dev status`,
|
|
44
|
+
* `timber graph`, the VS Code extension — locates an app by its config or
|
|
45
|
+
* package directory without evaluating Vite, so the record goes where they
|
|
46
|
+
* look rather than under a `root` the config may move elsewhere.
|
|
47
|
+
*/
|
|
48
|
+
function devRecordRoot(root, configFile) {
|
|
49
|
+
return typeof configFile === "string" ? dirname(configFile) : root;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Register discovery-record lifecycle handlers on the dev server's HTTP
|
|
53
|
+
* server. Writes `.timber/dev/<pid>-<port>-<token>.json` once the server is
|
|
54
|
+
* listening (the bound port is only known then) and removes exactly
|
|
55
|
+
* that record on clean shutdown.
|
|
56
|
+
*
|
|
57
|
+
* `urls` is read when the server starts listening: the URLs to advertise
|
|
58
|
+
* (`advertisedUrls`). With none, nothing is written — a record no one can
|
|
59
|
+
* open is not worth advertising.
|
|
60
|
+
*
|
|
61
|
+
* All filesystem work is best-effort: a failure to write or remove a
|
|
62
|
+
* record must never break the dev server. `httpServer` is null in
|
|
63
|
+
* middleware mode — no port exists, so there is nothing to advertise.
|
|
64
|
+
* Typed as `net.Server` — the common base of Vite's `http.Server` and
|
|
65
|
+
* `Http2SecureServer` variants, which carries the events and `address()`.
|
|
66
|
+
*/
|
|
67
|
+
function registerDevDiscovery(httpServer, root, urls, config) {
|
|
68
|
+
if (!httpServer) return;
|
|
69
|
+
const dir = join(devRecordRoot(root, config?.configFile), DEV_DISCOVERY_DIR);
|
|
70
|
+
let recordPath = null;
|
|
71
|
+
httpServer.on("listening", () => {
|
|
72
|
+
const address = httpServer.address();
|
|
73
|
+
if (address === null || typeof address === "string") return;
|
|
74
|
+
const advertised = urls();
|
|
75
|
+
if (advertised === void 0) return;
|
|
76
|
+
const hmrOpts = typeof config?.server?.hmr === "object" ? config.server.hmr : void 0;
|
|
77
|
+
const wsOpts = typeof config?.server?.ws === "object" ? config.server.ws : void 0;
|
|
78
|
+
const record = {
|
|
79
|
+
url: advertised.url,
|
|
80
|
+
loopbackUrl: advertised.loopbackUrl,
|
|
81
|
+
port: address.port,
|
|
82
|
+
pid: process.pid,
|
|
83
|
+
host: address.address,
|
|
84
|
+
protocol: httpServer instanceof Server ? "https" : "http",
|
|
85
|
+
base: config?.base && config.base !== "/" ? config.base : void 0,
|
|
86
|
+
hmrPath: wsOpts?.path ?? hmrOpts?.path,
|
|
87
|
+
hmrHost: wsOpts?.host ?? hmrOpts?.host,
|
|
88
|
+
hmrPort: wsOpts?.clientPort || wsOpts?.port || hmrOpts?.clientPort || hmrOpts?.port || void 0,
|
|
89
|
+
hmrProtocol: wsOpts?.protocol ?? hmrOpts?.protocol,
|
|
90
|
+
webSocketToken: config?.webSocketToken,
|
|
91
|
+
configFile: typeof config?.configFile === "string" ? config.configFile : void 0
|
|
92
|
+
};
|
|
93
|
+
recordPath = join(dir, `${record.pid}-${record.port}-${randomUUID()}.json`);
|
|
94
|
+
try {
|
|
95
|
+
mkdirSync(dir, { recursive: true });
|
|
96
|
+
writeFileSync(recordPath, JSON.stringify(record));
|
|
97
|
+
sweepDeadRecords(dir);
|
|
98
|
+
} catch {}
|
|
99
|
+
});
|
|
100
|
+
httpServer.on("close", () => {
|
|
101
|
+
if (!recordPath) return;
|
|
102
|
+
try {
|
|
103
|
+
rmSync(recordPath, { force: true });
|
|
104
|
+
} catch {}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* `GET /__timber/status` — the dev server's identity probe. Answers
|
|
109
|
+
* `{ pid }` with the serving process's pid, so a consumer can confirm the
|
|
110
|
+
* server on a record's port is the one that wrote the record (a crashed
|
|
111
|
+
* server's port may since have been taken by another process).
|
|
112
|
+
*/
|
|
113
|
+
var STATUS_ENDPOINT_PATH = "/__timber/status";
|
|
114
|
+
/** Probe deadline: discovery must never hold a CLI hostage. */
|
|
115
|
+
var DEV_PROBE_TIMEOUT_MS = 2e3;
|
|
116
|
+
/** Max probe response body (16 MB — matches the crawl child). */
|
|
117
|
+
var PROBE_MAX_BODY_BYTES = 16777216;
|
|
118
|
+
function isValidRecord(record) {
|
|
119
|
+
return typeof record.url === "string" && typeof record.loopbackUrl === "string" && typeof record.port === "number" && Number.isInteger(record.port) && record.port >= 1 && record.port <= 65535 && typeof record.pid === "number" && Number.isInteger(record.pid) && record.pid >= 1 && typeof record.host === "string" && (record.protocol === "http" || record.protocol === "https");
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Records under `<root>/.timber/dev/` that are well-formed and name a live
|
|
123
|
+
* pid. These are candidates, not proof: the caller still has to probe the
|
|
124
|
+
* endpoint (`readLiveDevRecords`, or `timber graph`'s own graph request,
|
|
125
|
+
* which doubles as its probe). A missing directory or unreadable record is
|
|
126
|
+
* absence, never an error.
|
|
127
|
+
*/
|
|
128
|
+
function readDevRecords(root) {
|
|
129
|
+
const dir = join(root, DEV_DISCOVERY_DIR);
|
|
130
|
+
let entries;
|
|
131
|
+
try {
|
|
132
|
+
entries = readdirSync(dir);
|
|
133
|
+
} catch {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
const records = [];
|
|
137
|
+
for (const entry of entries) {
|
|
138
|
+
if (!entry.endsWith(".json")) continue;
|
|
139
|
+
let record;
|
|
140
|
+
try {
|
|
141
|
+
record = JSON.parse(readFileSync(join(dir, entry), "utf8"));
|
|
142
|
+
} catch {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (isValidRecord(record) && isPidAlive(record.pid)) records.push(record);
|
|
146
|
+
}
|
|
147
|
+
return records;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Records whose server answers the status probe with the record's own pid —
|
|
151
|
+
* the full "pid alive AND probe succeeds" validation. Probes run in
|
|
152
|
+
* parallel, each under `DEV_PROBE_TIMEOUT_MS`.
|
|
153
|
+
*/
|
|
154
|
+
async function readLiveDevRecords(root) {
|
|
155
|
+
const candidates = readDevRecords(root);
|
|
156
|
+
const answers = await Promise.all(candidates.map((record) => probeDevServer(record, STATUS_ENDPOINT_PATH, DEV_PROBE_TIMEOUT_MS)));
|
|
157
|
+
return candidates.filter((record, i) => {
|
|
158
|
+
const answer = answers[i];
|
|
159
|
+
return typeof answer === "object" && answer !== null && "pid" in answer ? answer.pid === record.pid : false;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Wildcard binds (`0.0.0.0`, `::`) are reached through loopback; a server
|
|
164
|
+
* bound to one specific interface is reached only through that address.
|
|
165
|
+
*/
|
|
166
|
+
function connectHost(host) {
|
|
167
|
+
return host === "0.0.0.0" || host === "::" || host === "" ? "127.0.0.1" : host;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* HTTP(S) GET against a record's server with a wall-clock deadline and a
|
|
171
|
+
* response-size limit, returning the parsed JSON body or null on any failure
|
|
172
|
+
* (non-200, bad JSON, timeout, connection error). Uses node:http/https
|
|
173
|
+
* directly — `fetch` silently strips the Host header, which the endpoint's
|
|
174
|
+
* DNS-rebinding defense needs to see as a localhost form.
|
|
175
|
+
*
|
|
176
|
+
* The wall-clock timer covers both connection and body streaming — node's
|
|
177
|
+
* `timeout` option is an INACTIVITY timeout that resets on every chunk, so a
|
|
178
|
+
* slow-drip response would never fire it.
|
|
179
|
+
*/
|
|
180
|
+
function probeDevServer(record, path, timeoutMs) {
|
|
181
|
+
return new Promise((resolve) => {
|
|
182
|
+
let settled = false;
|
|
183
|
+
let req;
|
|
184
|
+
const done = (value) => {
|
|
185
|
+
if (settled) return;
|
|
186
|
+
settled = true;
|
|
187
|
+
clearTimeout(wallClock);
|
|
188
|
+
resolve(value);
|
|
189
|
+
};
|
|
190
|
+
const wallClock = setTimeout(() => {
|
|
191
|
+
req?.destroy();
|
|
192
|
+
done(null);
|
|
193
|
+
}, timeoutMs);
|
|
194
|
+
const doRequest = record.protocol === "https" ? request$1 : request;
|
|
195
|
+
try {
|
|
196
|
+
req = doRequest({
|
|
197
|
+
hostname: connectHost(record.host),
|
|
198
|
+
port: record.port,
|
|
199
|
+
path,
|
|
200
|
+
method: "GET",
|
|
201
|
+
rejectUnauthorized: false
|
|
202
|
+
}, (res) => {
|
|
203
|
+
if (res.statusCode !== 200) {
|
|
204
|
+
req?.destroy();
|
|
205
|
+
done(null);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const chunks = [];
|
|
209
|
+
let totalBytes = 0;
|
|
210
|
+
res.on("data", (chunk) => {
|
|
211
|
+
totalBytes += chunk.length;
|
|
212
|
+
if (totalBytes > PROBE_MAX_BODY_BYTES) {
|
|
213
|
+
req?.destroy();
|
|
214
|
+
done(null);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
chunks.push(chunk);
|
|
218
|
+
});
|
|
219
|
+
res.on("end", () => {
|
|
220
|
+
try {
|
|
221
|
+
done(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
222
|
+
} catch {
|
|
223
|
+
done(null);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
res.on("error", () => done(null));
|
|
227
|
+
});
|
|
228
|
+
} catch {
|
|
229
|
+
done(null);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
req.on("error", () => done(null));
|
|
233
|
+
req.end();
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
export { readDevRecords as a, probeDevServer as i, STATUS_ENDPOINT_PATH as n, readLiveDevRecords as o, devRecordRoot as r, registerDevDiscovery as s, DEV_PROBE_TIMEOUT_MS as t };
|
|
237
|
+
|
|
238
|
+
//# sourceMappingURL=dev-discovery-YnabkCKD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-discovery-YnabkCKD.js","names":["TlsServer","httpsRequest","httpRequest"],"sources":["../../src/plugins/dev-discovery.ts"],"sourcesContent":["/**\n * Dev-server discovery records — `.timber/dev/<pid>-<port>-<token>.json`.\n *\n * On startup each dev server writes `{ url, port, pid, host, protocol }` to its own record\n * file under the app's `.timber/dev/` so `timber dev status`, the\n * `timber graph` CLI, and the VS Code extension can discover a running\n * dev server. `timber dev status` is the public, agent-facing consumer;\n * the records themselves are not.\n *\n * One record file per server, one writer per file. This is what makes\n * multi-server roots (Vite auto-increments the port across processes;\n * programmatic embeddings run several servers in one process) safe\n * without any coordination: there is no shared file to displace, no\n * ownership to arbitrate, and no shutdown-order dependency — each\n * server removes exactly its own record.\n *\n * Consumers must list the directory and trust a record only if its pid\n * is alive AND a probe request to the endpoint succeeds; anything else\n * is treated as absent (silent fallback), never an error. Stale records\n * (crashed servers) are therefore the normal case — startup sweeps\n * dead-pid records best-effort, and consumers validate the rest away.\n *\n * The directory layout and file format are implementation details, not\n * a public contract.\n *\n * Design doc: 47-module-environment-tooling.md §5, 21-dev-server.md.\n */\n\nimport type { Server } from 'node:net';\nimport { Server as TlsServer } from 'node:tls';\nimport { randomUUID } from 'node:crypto';\nimport { mkdirSync, writeFileSync, rmSync, readFileSync, readdirSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { request as httpRequest, type ClientRequest } from 'node:http';\nimport { request as httpsRequest } from 'node:https';\nimport type { AdvertisedUrls } from './dev-hostname.ts';\n\n/** Relative path of the discovery directory within the project root. */\nexport const DEV_DISCOVERY_DIR = join('.timber', 'dev');\n\nexport interface DevRecord {\n /**\n * The URL the server printed and opened — Vite's `resolvedUrls` pick,\n * with the app's dev hostname applied (`http://blog.localhost:3000/`,\n * see plugins/dev-hostname.ts). What `timber dev status` reports. Taken\n * from Vite rather than rebuilt from `host`, so the two cannot disagree.\n */\n url: string;\n /**\n * The same server for non-browser HTTP clients: `url` at plain\n * `localhost` when that resolves and verifies (see `loopbackUrl` in\n * plugins/dev-hostname.ts). Computed by the server, which alone knows its\n * TLS certificate.\n */\n loopbackUrl: string;\n port: number;\n pid: number;\n /**\n * The bound address, as reported by the socket. Consumers probing the\n * endpoint need it for servers bound to non-default interfaces;\n * wildcard addresses (`0.0.0.0`, `::`) should be probed via loopback.\n */\n host: string;\n /**\n * Probe scheme. `server.https` dev servers (including HTTP/2) answer\n * only TLS — an http:// probe of one would fail and wrongly trigger\n * the cold-crawl fallback.\n */\n protocol: 'http' | 'https';\n /**\n * Vite `base` path. When non-root (e.g. `/my-app/`), the WebSocket\n * upgrade path is `base + hmrPath`.\n */\n base?: string;\n /**\n * HMR WebSocket path (from `server.ws.path` or deprecated\n * `server.hmr.path`). Absent when no path is configured (default `/`).\n */\n hmrPath?: string;\n /**\n * Custom WebSocket host override (from `server.ws.host` or deprecated\n * `server.hmr.host`). When set, the WS connection targets this host\n * instead of the HTTP server's bound address.\n */\n hmrHost?: string;\n /**\n * Custom WebSocket port override (from `server.ws.clientPort` ??\n * `server.ws.port`, or deprecated `server.hmr.clientPort` ??\n * `server.hmr.port`). When set, the WS connection targets this port\n * instead of the HTTP server's bound port.\n */\n hmrPort?: number;\n /**\n * Custom WebSocket protocol override (from `server.ws.protocol` or\n * deprecated `server.hmr.protocol`). When set (e.g. `'wss'`), the\n * upgrade request uses the corresponding HTTP scheme.\n */\n hmrProtocol?: string;\n /**\n * Vite 8 WebSocket token (from `config.webSocketToken`). Required for\n * browser WS upgrades; the extension passes it as `?token=` on the\n * WebSocket URL.\n */\n webSocketToken?: string;\n /**\n * Absolute path to the Vite config file this server was started with.\n * When multiple dev servers share a project root but use different\n * configs, the fast path must only accept the record matching the\n * config the CLI resolved (TIM-1393).\n */\n configFile?: string;\n}\n\n/** Best-effort \"is this pid alive\" — signal 0 probes without killing. */\nexport function isPidAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means the process exists but is owned by someone else.\n return (error as NodeJS.ErrnoException).code === 'EPERM';\n }\n}\n\n/**\n * Remove sibling records whose pid is no longer alive. Purely a\n * tidiness sweep — consumers already ignore records that fail the\n * pid + probe validation, so missing a stale record here is harmless.\n */\nfunction sweepDeadRecords(dir: string): void {\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return;\n }\n for (const entry of entries) {\n if (!entry.endsWith('.json')) continue;\n const filePath = join(dir, entry);\n try {\n const record = JSON.parse(readFileSync(filePath, 'utf8')) as Partial<DevRecord>;\n // Remove only records that parse AND name a dead pid. An\n // unreadable file may be a sibling's record mid-write — leave it;\n // consumers ignore records that fail validation anyway.\n if (typeof record.pid === 'number' && !isPidAlive(record.pid)) {\n rmSync(filePath, { force: true });\n }\n } catch {\n // Unreadable — skip, never delete another writer's in-flight file.\n }\n }\n}\n\n/**\n * The directory whose `.timber/dev/` holds a server's record: the Vite\n * config file's directory, falling back to the resolved root for an inline\n * (`configFile: false`) server. Every consumer — `timber dev status`,\n * `timber graph`, the VS Code extension — locates an app by its config or\n * package directory without evaluating Vite, so the record goes where they\n * look rather than under a `root` the config may move elsewhere.\n */\nexport function devRecordRoot(root: string, configFile: string | false | undefined): string {\n return typeof configFile === 'string' ? dirname(configFile) : root;\n}\n\n/**\n * Register discovery-record lifecycle handlers on the dev server's HTTP\n * server. Writes `.timber/dev/<pid>-<port>-<token>.json` once the server is\n * listening (the bound port is only known then) and removes exactly\n * that record on clean shutdown.\n *\n * `urls` is read when the server starts listening: the URLs to advertise\n * (`advertisedUrls`). With none, nothing is written — a record no one can\n * open is not worth advertising.\n *\n * All filesystem work is best-effort: a failure to write or remove a\n * record must never break the dev server. `httpServer` is null in\n * middleware mode — no port exists, so there is nothing to advertise.\n * Typed as `net.Server` — the common base of Vite's `http.Server` and\n * `Http2SecureServer` variants, which carries the events and `address()`.\n */\nexport function registerDevDiscovery(\n httpServer: Server | null,\n root: string,\n urls: () => AdvertisedUrls | undefined,\n config?: {\n configFile?: string | false;\n base?: string;\n server?: {\n hmr?:\n | { path?: string; host?: string; port?: number; clientPort?: number; protocol?: string }\n | boolean;\n ws?:\n | { path?: string; host?: string; port?: number; clientPort?: number; protocol?: string }\n | false;\n };\n webSocketToken?: string;\n }\n): void {\n if (!httpServer) return;\n\n const dir = join(devRecordRoot(root, config?.configFile), DEV_DISCOVERY_DIR);\n let recordPath: string | null = null;\n\n httpServer.on('listening', () => {\n const address = httpServer.address();\n // Unix-socket listeners have a string address — no port to advertise.\n if (address === null || typeof address === 'string') return;\n const advertised = urls();\n if (advertised === undefined) return;\n const hmrOpts = typeof config?.server?.hmr === 'object' ? config.server.hmr : undefined;\n const wsOpts = typeof config?.server?.ws === 'object' ? config.server.ws : undefined;\n const record: DevRecord = {\n url: advertised.url,\n loopbackUrl: advertised.loopbackUrl,\n port: address.port,\n pid: process.pid,\n host: address.address,\n // Vite's https/h2 servers are tls.Server subclasses; plain HTTP\n // and h2c are not.\n protocol: httpServer instanceof TlsServer ? 'https' : 'http',\n base: config?.base && config.base !== '/' ? config.base : undefined,\n hmrPath: wsOpts?.path ?? hmrOpts?.path,\n hmrHost: wsOpts?.host ?? hmrOpts?.host,\n hmrPort:\n wsOpts?.clientPort || wsOpts?.port || hmrOpts?.clientPort || hmrOpts?.port || undefined,\n hmrProtocol: wsOpts?.protocol ?? hmrOpts?.protocol,\n webSocketToken: config?.webSocketToken,\n configFile: typeof config?.configFile === 'string' ? config.configFile : undefined,\n };\n // pid+port alone is not a unique server identity (same port on two\n // interfaces; worker threads and duplicate module copies share a\n // pid but not module state, so a counter cannot disambiguate\n // either). A random token makes the filename unique regardless of\n // process/isolate topology; pid and port stay in the name only for\n // human debuggability.\n recordPath = join(dir, `${record.pid}-${record.port}-${randomUUID()}.json`);\n try {\n mkdirSync(dir, { recursive: true });\n writeFileSync(recordPath, JSON.stringify(record));\n sweepDeadRecords(dir);\n } catch {\n // Best-effort — consumers fall back to the cold crawl.\n }\n });\n\n httpServer.on('close', () => {\n if (!recordPath) return;\n try {\n // Only ever this server's own record — sibling servers' records\n // are separate files and survive any shutdown order untouched.\n rmSync(recordPath, { force: true });\n } catch {\n // Best-effort — a stale record is validated away by consumers.\n }\n });\n}\n\n// ─── Reading records ─────────────────────────────────────────────────────────\n//\n// The consumer side of the same contract, for the CLI: `timber graph` and\n// `timber dev status` only see validated `DevRecord`s. The VS Code extension\n// (packages/timber-vscode/src/graph-client.ts) is a separate package with its\n// own reader of the same format; a format change must update both.\n\n/**\n * `GET /__timber/status` — the dev server's identity probe. Answers\n * `{ pid }` with the serving process's pid, so a consumer can confirm the\n * server on a record's port is the one that wrote the record (a crashed\n * server's port may since have been taken by another process).\n */\nexport const STATUS_ENDPOINT_PATH = '/__timber/status';\n\n/** Probe deadline: discovery must never hold a CLI hostage. */\nexport const DEV_PROBE_TIMEOUT_MS = 2_000;\n\n/** Max probe response body (16 MB — matches the crawl child). */\nconst PROBE_MAX_BODY_BYTES = 16 * 1024 * 1024;\n\nfunction isValidRecord(record: Partial<DevRecord>): record is DevRecord {\n return (\n typeof record.url === 'string' &&\n typeof record.loopbackUrl === 'string' &&\n typeof record.port === 'number' &&\n Number.isInteger(record.port) &&\n record.port >= 1 &&\n record.port <= 65535 &&\n typeof record.pid === 'number' &&\n Number.isInteger(record.pid) &&\n record.pid >= 1 &&\n typeof record.host === 'string' &&\n (record.protocol === 'http' || record.protocol === 'https')\n );\n}\n\n/**\n * Records under `<root>/.timber/dev/` that are well-formed and name a live\n * pid. These are candidates, not proof: the caller still has to probe the\n * endpoint (`readLiveDevRecords`, or `timber graph`'s own graph request,\n * which doubles as its probe). A missing directory or unreadable record is\n * absence, never an error.\n */\nexport function readDevRecords(root: string): DevRecord[] {\n const dir = join(root, DEV_DISCOVERY_DIR);\n let entries: string[];\n try {\n entries = readdirSync(dir);\n } catch {\n return [];\n }\n const records: DevRecord[] = [];\n for (const entry of entries) {\n if (!entry.endsWith('.json')) continue;\n let record: Partial<DevRecord>;\n try {\n record = JSON.parse(readFileSync(join(dir, entry), 'utf8')) as Partial<DevRecord>;\n } catch {\n continue;\n }\n if (isValidRecord(record) && isPidAlive(record.pid)) records.push(record);\n }\n return records;\n}\n\n/**\n * Records whose server answers the status probe with the record's own pid —\n * the full \"pid alive AND probe succeeds\" validation. Probes run in\n * parallel, each under `DEV_PROBE_TIMEOUT_MS`.\n */\nexport async function readLiveDevRecords(root: string): Promise<DevRecord[]> {\n const candidates = readDevRecords(root);\n const answers = await Promise.all(\n candidates.map((record) => probeDevServer(record, STATUS_ENDPOINT_PATH, DEV_PROBE_TIMEOUT_MS))\n );\n return candidates.filter((record, i) => {\n const answer = answers[i];\n return typeof answer === 'object' && answer !== null && 'pid' in answer\n ? answer.pid === record.pid\n : false;\n });\n}\n\n/**\n * Wildcard binds (`0.0.0.0`, `::`) are reached through loopback; a server\n * bound to one specific interface is reached only through that address.\n */\nfunction connectHost(host: string): string {\n return host === '0.0.0.0' || host === '::' || host === '' ? '127.0.0.1' : host;\n}\n\n/**\n * HTTP(S) GET against a record's server with a wall-clock deadline and a\n * response-size limit, returning the parsed JSON body or null on any failure\n * (non-200, bad JSON, timeout, connection error). Uses node:http/https\n * directly — `fetch` silently strips the Host header, which the endpoint's\n * DNS-rebinding defense needs to see as a localhost form.\n *\n * The wall-clock timer covers both connection and body streaming — node's\n * `timeout` option is an INACTIVITY timeout that resets on every chunk, so a\n * slow-drip response would never fire it.\n */\nexport function probeDevServer(\n record: DevRecord,\n path: string,\n timeoutMs: number\n): Promise<unknown> {\n return new Promise((resolve) => {\n let settled = false;\n let req: ClientRequest | undefined;\n const done = (value: unknown) => {\n if (settled) return;\n settled = true;\n clearTimeout(wallClock);\n resolve(value);\n };\n const wallClock = setTimeout(() => {\n req?.destroy();\n done(null);\n }, timeoutMs);\n\n const doRequest = record.protocol === 'https' ? httpsRequest : httpRequest;\n try {\n req = doRequest(\n {\n hostname: connectHost(record.host),\n port: record.port,\n path,\n method: 'GET',\n // Self-signed certs are normal for dev servers.\n rejectUnauthorized: false,\n },\n (res) => {\n if (res.statusCode !== 200) {\n req?.destroy();\n done(null);\n return;\n }\n const chunks: Buffer[] = [];\n let totalBytes = 0;\n res.on('data', (chunk: Buffer) => {\n totalBytes += chunk.length;\n if (totalBytes > PROBE_MAX_BODY_BYTES) {\n req?.destroy();\n done(null);\n return;\n }\n chunks.push(chunk);\n });\n res.on('end', () => {\n try {\n done(JSON.parse(Buffer.concat(chunks).toString('utf8')));\n } catch {\n done(null);\n }\n });\n res.on('error', () => done(null));\n }\n );\n } catch {\n // http.request throws synchronously on malformed hostnames\n // (ERR_INVALID_CHAR) or other invalid options — treat as absent.\n done(null);\n return;\n }\n req.on('error', () => done(null));\n req.end();\n });\n}\n"],"mappings":";;;;;;;;AAsCA,IAAa,oBAAoB,KAAK,WAAW,KAAK;;AA4EtD,SAAgB,WAAW,KAAsB;CAC/C,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EAEd,OAAQ,MAAgC,SAAS;CACnD;AACF;;;;;;AAOA,S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