@timber-js/app 0.2.0-alpha.222 → 0.2.0-alpha.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-skill.md +21 -5
- package/dist/_chunks/{actions-vBHr2vqd.js → actions-7dTXYJfu.js} +53 -24
- package/dist/_chunks/actions-7dTXYJfu.js.map +1 -0
- package/dist/_chunks/{als-registry-BZqHCtq-.js → als-registry-DpygwCp0.js} +2 -3
- package/dist/_chunks/{als-registry-BZqHCtq-.js.map → als-registry-DpygwCp0.js.map} +1 -1
- package/dist/_chunks/{als-slots-BEEIPKYm.js → als-slots-kbQrHTzm.js} +2 -3
- package/dist/_chunks/{als-slots-BEEIPKYm.js.map → als-slots-kbQrHTzm.js.map} +1 -1
- package/dist/_chunks/{base-path-DaQrzbez.js → base-path-DDIx0FXe.js} +2 -3
- package/dist/_chunks/{base-path-DaQrzbez.js.map → base-path-DDIx0FXe.js.map} +1 -1
- package/dist/_chunks/{build-manifest-DWppEdLB.js → build-manifest-Y4jl7nwU.js} +2 -3
- package/dist/_chunks/{build-manifest-DWppEdLB.js.map → build-manifest-Y4jl7nwU.js.map} +1 -1
- package/dist/_chunks/{build-output-helper-RV_BRcF1.js → build-output-helper-B7wWGTfR.js} +14 -10
- package/dist/_chunks/build-output-helper-B7wWGTfR.js.map +1 -0
- package/dist/_chunks/{cache-api-DdcDLpBj.js → cache-api-TDZ4hlDc.js} +190 -38
- package/dist/_chunks/cache-api-TDZ4hlDc.js.map +1 -0
- package/dist/_chunks/{canonicalize-BAWkWiKK.js → canonicalize-CqK135BN.js} +29 -4
- package/dist/_chunks/{canonicalize-BAWkWiKK.js.map → canonicalize-CqK135BN.js.map} +1 -1
- package/dist/_chunks/chains-CwOr3Myj.js +1 -0
- package/dist/_chunks/{chains-BchW_AtW.js → chains-Dgm3PrMe.js} +3 -4
- package/dist/_chunks/{chains-BchW_AtW.js.map → chains-Dgm3PrMe.js.map} +1 -1
- package/dist/_chunks/{classify-IqzMpxMs.js → classify--_kINHQV.js} +4 -5
- package/dist/_chunks/{classify-IqzMpxMs.js.map → classify--_kINHQV.js.map} +1 -1
- package/dist/_chunks/{cli-check-DQne_YhU.js → cli-check-Dv3f8d2j.js} +5 -6
- package/dist/_chunks/{cli-check-DQne_YhU.js.map → cli-check-Dv3f8d2j.js.map} +1 -1
- package/dist/_chunks/{cli-context-_mPttGGY.js → cli-context-CbZp32SK.js} +3 -4
- package/dist/_chunks/{cli-context-_mPttGGY.js.map → cli-context-CbZp32SK.js.map} +1 -1
- package/dist/_chunks/cli-context-n5hmkdla.js +1 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js +138 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js.map +1 -0
- package/dist/_chunks/cli-init-BoXOYYil.js +196 -0
- package/dist/_chunks/cli-init-BoXOYYil.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js → cli-schema-sync-DIPurq7X.js} +4 -5
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js.map → cli-schema-sync-DIPurq7X.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-v872sHms.js → cli-schema-sync-uq72EZmD.js} +1 -1
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js → client-dep-entries-CP7AkMCM.js} +4 -5
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js.map → client-dep-entries-CP7AkMCM.js.map} +1 -1
- package/dist/_chunks/{cloudflare-Byxl8FWP.js → cloudflare-B75X6u4O.js} +10 -13
- package/dist/_chunks/{cloudflare-Byxl8FWP.js.map → cloudflare-B75X6u4O.js.map} +1 -1
- package/dist/_chunks/{codec-registry-oOUxugz3.js → codec-registry-CPc6bjVl.js} +2 -3
- package/dist/_chunks/{codec-registry-oOUxugz3.js.map → codec-registry-CPc6bjVl.js.map} +1 -1
- package/dist/_chunks/{codegen-Bps1sLKJ.js → codegen-B9oWkWGf.js} +5 -8
- package/dist/_chunks/{codegen-Bps1sLKJ.js.map → codegen-B9oWkWGf.js.map} +1 -1
- package/dist/_chunks/{convention-lint-VwzrtjIt.js → convention-lint-hZwz5wd4.js} +8 -11
- package/dist/_chunks/{convention-lint-VwzrtjIt.js.map → convention-lint-hZwz5wd4.js.map} +1 -1
- package/dist/_chunks/dev-discovery-YnabkCKD.js +238 -0
- package/dist/_chunks/dev-discovery-YnabkCKD.js.map +1 -0
- package/dist/_chunks/{dev-server-BNr5drEO.js → dev-server-B7o4As0l.js} +383 -55
- package/dist/_chunks/dev-server-B7o4As0l.js.map +1 -0
- package/dist/_chunks/dev-server-hZzmbMvK.js +1 -0
- package/dist/_chunks/{dev-store-BOa304m_.js → dev-store-BvdqtHvK.js} +82 -38
- package/dist/_chunks/dev-store-BvdqtHvK.js.map +1 -0
- package/dist/_chunks/{dist-DtrJyBbw.js → dist-C1Rjlo6s.js} +3 -5
- package/dist/_chunks/{dist-DtrJyBbw.js.map → dist-C1Rjlo6s.js.map} +1 -1
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js → error-boundary-DRQXGWCp.js} +20 -27
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js.map → error-boundary-DRQXGWCp.js.map} +1 -1
- package/dist/_chunks/{fast-hash-C-tVYrLb.js → fast-hash-DddxkU5Y.js} +2 -3
- package/dist/_chunks/{fast-hash-C-tVYrLb.js.map → fast-hash-DddxkU5Y.js.map} +1 -1
- package/dist/_chunks/{flight-source-node-BdHUOUqg.js → flight-source-node-0Tp6evlz.js} +6 -8
- package/dist/_chunks/flight-source-node-0Tp6evlz.js.map +1 -0
- package/dist/_chunks/{format-BKclgVbk.js → format-DuPOoXUP.js} +2 -3
- package/dist/_chunks/{format-BKclgVbk.js.map → format-DuPOoXUP.js.map} +1 -1
- package/dist/_chunks/{fs-identity-BRKuL215.js → fs-identity-BmQ_Agg-.js} +3 -5
- package/dist/_chunks/{fs-identity-BRKuL215.js.map → fs-identity-BmQ_Agg-.js.map} +1 -1
- package/dist/_chunks/{global-context-B9PFncvb.js → global-context-DbxNWeBP.js} +2 -3
- package/dist/_chunks/{global-context-B9PFncvb.js.map → global-context-DbxNWeBP.js.map} +1 -1
- package/dist/_chunks/{graph-cache-CYiUS2aS.js → graph-cache-B1LAg4t7.js} +5 -89
- package/dist/_chunks/graph-cache-B1LAg4t7.js.map +1 -0
- package/dist/_chunks/{href-validation-BIrxavIy.js → href-validation-CEZy1V-k.js} +4 -7
- package/dist/_chunks/{href-validation-BIrxavIy.js.map → href-validation-CEZy1V-k.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js → json-lossy-check-DVkLUlfC.js} +3 -4
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js.map → json-lossy-check-DVkLUlfC.js.map} +1 -1
- package/dist/_chunks/{live-graph-DEu_GWbc.js → live-graph-BcVjQ1Te.js} +6 -7
- package/dist/_chunks/{live-graph-DEu_GWbc.js.map → live-graph-BcVjQ1Te.js.map} +1 -1
- package/dist/_chunks/{logger-CI_hThfy.js → logger-CWk44DLp.js} +89 -47
- package/dist/_chunks/logger-CWk44DLp.js.map +1 -0
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js → metadata-routes-BL26HCDd.js} +2 -3
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js.map → metadata-routes-BL26HCDd.js.map} +1 -1
- package/dist/_chunks/{navigation-root-BQfo1-kG.js → navigation-root-M3B2ZrdO.js} +6 -10
- package/dist/_chunks/{navigation-root-BQfo1-kG.js.map → navigation-root-M3B2ZrdO.js.map} +1 -1
- package/dist/_chunks/{node-response-bF0bKoig.js → node-response-B9aviPDa.js} +43 -9
- package/dist/_chunks/node-response-B9aviPDa.js.map +1 -0
- package/dist/_chunks/{param-value-C8TNYchQ.js → param-value-DqlGfF57.js} +2 -3
- package/dist/_chunks/{param-value-C8TNYchQ.js.map → param-value-DqlGfF57.js.map} +1 -1
- package/dist/_chunks/{plugin-context-uDHFqHHJ.js → plugin-context-BfSRKJfz.js} +1 -1
- package/dist/_chunks/{plugin-context-DxMMvjUt.js → plugin-context-FCkaNLUB.js} +4 -6
- package/dist/_chunks/plugin-context-FCkaNLUB.js.map +1 -0
- package/dist/_chunks/{poison-rules-DoEhbqaY.js → poison-rules-Bmz-lCPi.js} +2 -3
- package/dist/_chunks/{poison-rules-DoEhbqaY.js.map → poison-rules-Bmz-lCPi.js.map} +1 -1
- package/dist/_chunks/{poison-scan-DTWIfNgD.js → poison-scan-DJYxZc_7.js} +4 -5
- package/dist/_chunks/{poison-scan-DTWIfNgD.js.map → poison-scan-DJYxZc_7.js.map} +1 -1
- package/dist/_chunks/{purge-store-WZaxu-3m.js → purge-store-8BqLAYZ1.js} +2 -3
- package/dist/_chunks/{purge-store-WZaxu-3m.js.map → purge-store-8BqLAYZ1.js.map} +1 -1
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js → render-timeout-MrrqD1wd.js} +2 -3
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js.map → render-timeout-MrrqD1wd.js.map} +1 -1
- package/dist/_chunks/{resolve-schema-CkAInout.js → resolve-schema-B-aCuTu3.js} +3 -4
- package/dist/_chunks/{resolve-schema-CkAInout.js.map → resolve-schema-B-aCuTu3.js.map} +1 -1
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js → rsc-cache-key-D0cb0Gmc.js} +2 -3
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js.map → rsc-cache-key-D0cb0Gmc.js.map} +1 -1
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js → rsc-media-type-m8jz9u6_.js} +2 -3
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js.map → rsc-media-type-m8jz9u6_.js.map} +1 -1
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js → rsc-payload-path-EphpDB-J.js} +2 -3
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js.map → rsc-payload-path-EphpDB-J.js.map} +1 -1
- package/dist/_chunks/{scan-BoP17W3w.js → scan-CyizcBiX.js} +2 -3
- package/dist/_chunks/{scan-BoP17W3w.js.map → scan-CyizcBiX.js.map} +1 -1
- package/dist/_chunks/{scanner-C8fdKvKG.js → scanner-CJC-ScJU.js} +15 -23
- package/dist/_chunks/{scanner-C8fdKvKG.js.map → scanner-CJC-ScJU.js.map} +1 -1
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js → schema-bridge-DyRs3cqy.js} +2 -3
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js.map → schema-bridge-DyRs3cqy.js.map} +1 -1
- package/dist/_chunks/{segment-classify-C539Pa2O.js → segment-classify-Ho8jXWeC.js} +3 -5
- package/dist/_chunks/{segment-classify-C539Pa2O.js.map → segment-classify-Ho8jXWeC.js.map} +1 -1
- package/dist/_chunks/{segment-context-D3DNxKFq.js → segment-context-CYiGTi3K.js} +4 -6
- package/dist/_chunks/{segment-context-D3DNxKFq.js.map → segment-context-CYiGTi3K.js.map} +1 -1
- package/dist/_chunks/{segment-keys-D5hu1hz4.js → segment-keys-Y60KNc8C.js} +2 -3
- package/dist/_chunks/{segment-keys-D5hu1hz4.js.map → segment-keys-Y60KNc8C.js.map} +1 -1
- package/dist/_chunks/{singleflight-BeVMMKi0.js → singleflight-BChPMjwH.js} +2 -3
- package/dist/_chunks/{singleflight-BeVMMKi0.js.map → singleflight-BChPMjwH.js.map} +1 -1
- package/dist/_chunks/{sizeof-CO3dk0V1.js → sizeof-DG4W40lv.js} +3 -4
- package/dist/_chunks/{sizeof-CO3dk0V1.js.map → sizeof-DG4W40lv.js.map} +1 -1
- package/dist/_chunks/{ssr-data-nA3I70_n.js → ssr-data-9hPtcNOr.js} +3 -4
- package/dist/_chunks/{ssr-data-nA3I70_n.js.map → ssr-data-9hPtcNOr.js.map} +1 -1
- package/dist/_chunks/{state-BhNGPsdi.js → state-B-EBjeER.js} +2 -3
- package/dist/_chunks/{state-BhNGPsdi.js.map → state-B-EBjeER.js.map} +1 -1
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js → status-page-marker-XIQXlTOb.js} +8 -13
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js.map → status-page-marker-XIQXlTOb.js.map} +1 -1
- package/dist/_chunks/{tree-match-6yihorhk.js → tree-match-Bqdr9szG.js} +2 -3
- package/dist/_chunks/{tree-match-6yihorhk.js.map → tree-match-Bqdr9szG.js.map} +1 -1
- package/dist/_chunks/{use-query-states-I3JMng6J.js → use-query-states-pkDV-jSg.js} +4 -7
- package/dist/_chunks/{use-query-states-I3JMng6J.js.map → use-query-states-pkDV-jSg.js.map} +1 -1
- package/dist/_chunks/{walkers-BqzxnwGC.js → walkers-DIE203ir.js} +6 -8
- package/dist/_chunks/{walkers-BqzxnwGC.js.map → walkers-DIE203ir.js.map} +1 -1
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js → write-file-atomic-DW8m_Atv.js} +2 -3
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js.map → write-file-atomic-DW8m_Atv.js.map} +1 -1
- package/dist/adapters/build-output-helper.d.ts +10 -1
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare-dev.js +2 -3
- package/dist/adapters/cloudflare-kv-cache.js +3 -4
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/nitro-presets.d.ts +6 -0
- package/dist/adapters/nitro-presets.d.ts.map +1 -1
- package/dist/adapters/nitro-preview.d.ts.map +1 -1
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +94 -57
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/analyze/crawl-entry.js +7 -9
- package/dist/analyze/crawl-entry.js.map +1 -1
- package/dist/analyze/graph-command.d.ts.map +1 -1
- package/dist/analyze/graph-command.js +19 -105
- package/dist/analyze/graph-command.js.map +1 -1
- package/dist/cache/index.js +3 -3
- package/dist/cache/key-discipline.d.ts +61 -0
- package/dist/cache/key-discipline.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.js +1 -2
- package/dist/cache/stores/memory.js +2 -3
- package/dist/cache/stores/redis.js +1 -2
- package/dist/cache/stores/vercel.js +1 -2
- package/dist/cache/timber-cache.d.ts +5 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.js +1 -2
- package/dist/cdn/fastly-purge.js +1 -2
- package/dist/cdn/index.js +2 -3
- package/dist/cdn/workers-cache-purge.js +3 -5
- package/dist/cdn/workers-cache-purge.js.map +1 -1
- package/dist/cli-dev-status.d.ts +75 -0
- package/dist/cli-dev-status.d.ts.map +1 -0
- package/dist/cli-init.d.ts +72 -0
- package/dist/cli-init.d.ts.map +1 -0
- package/dist/cli.d.ts +4 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -54
- package/dist/cli.js.map +1 -1
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +22 -34
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +13 -18
- package/dist/client/internal.js.map +1 -1
- package/dist/client/use-cookie.d.ts +18 -5
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/codec.js +2 -3
- package/dist/config-types.d.ts +40 -5
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +40 -67
- package/dist/cookies/index.js.map +1 -1
- package/dist/cookies/json-cookie.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +698 -237
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +3 -4
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/dev-discovery.d.ts +69 -5
- package/dist/plugins/dev-discovery.d.ts.map +1 -1
- package/dist/plugins/dev-hostname.d.ts +152 -0
- package/dist/plugins/dev-hostname.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +5 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/dev-store-clear.d.ts +59 -4
- package/dist/plugins/dev-store-clear.d.ts.map +1 -1
- package/dist/plugins/graph-endpoint.d.ts +4 -2
- package/dist/plugins/graph-endpoint.d.ts.map +1 -1
- package/dist/plugins/optimize-package-imports-defaults.d.ts +13 -0
- package/dist/plugins/optimize-package-imports-defaults.d.ts.map +1 -0
- package/dist/plugins/optimize-package-imports.d.ts +113 -0
- package/dist/plugins/optimize-package-imports.d.ts.map +1 -0
- package/dist/plugins/prebuilt.d.ts.map +1 -1
- package/dist/routing/index.js +4 -4
- package/dist/rsc-runtime/rsc.d.ts +2 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/server-references.d.ts +8 -0
- package/dist/rsc-runtime/server-references.d.ts.map +1 -0
- package/dist/search-params/index.js +5 -7
- package/dist/search-params/index.js.map +1 -1
- package/dist/server/access-gate.d.ts +12 -0
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/canonicalize.d.ts +21 -0
- package/dist/server/canonicalize.d.ts.map +1 -1
- package/dist/server/cookie-context.d.ts +8 -1
- package/dist/server/cookie-context.d.ts.map +1 -1
- package/dist/server/flight-source-node.d.ts.map +1 -1
- package/dist/server/flight-source.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +8 -13
- package/dist/server/index.js.map +1 -1
- package/dist/server/interception-gates.d.ts +49 -0
- package/dist/server/interception-gates.d.ts.map +1 -0
- package/dist/server/internal.js +1061 -943
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +17 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/param-coercion.d.ts +8 -0
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/pipeline-interception.d.ts +34 -4
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline-metadata-route.d.ts +24 -0
- package/dist/server/pipeline-metadata-route.d.ts.map +1 -0
- package/dist/server/pipeline-metadata.d.ts +3 -2
- package/dist/server/pipeline-metadata.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts +9 -3
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +18 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/prebuilt/dev-store.d.ts +68 -22
- package/dist/server/prebuilt/dev-store.d.ts.map +1 -1
- package/dist/server/prebuilt/overlay.d.ts +8 -0
- package/dist/server/prebuilt/overlay.d.ts.map +1 -1
- package/dist/server/prebuilt-runtime.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +13 -0
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/render-utils.d.ts +21 -0
- package/dist/server/render-utils.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +14 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts +7 -0
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +14 -3
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/signal-identity.d.ts +6 -0
- package/dist/server/signal-identity.d.ts.map +1 -1
- package/dist/server/traced-access.d.ts +18 -0
- package/dist/server/traced-access.d.ts.map +1 -0
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/types.d.ts +5 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-local.js +1 -2
- package/dist/shims/headers.d.ts +11 -4
- package/dist/shims/headers.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +3 -1
- package/docs/api/32-api-cache.mdx +1 -1
- package/docs/api/34-api-config.mdx +42 -0
- package/docs/api/36-cli.mdx +72 -6
- package/docs/learn/01-quick-start.mdx +1 -1
- package/docs/learn/06-typed-params.mdx +2 -2
- package/docs/learn/10-caching.mdx +26 -5
- package/llms.txt +1 -1
- package/package.json +12 -12
- package/src/adapters/build-output-helper.ts +26 -4
- package/src/adapters/cloudflare.ts +1 -0
- package/src/adapters/nitro-presets.ts +15 -0
- package/src/adapters/nitro-preview.ts +66 -34
- package/src/adapters/nitro.ts +14 -6
- package/src/analyze/graph-command.ts +25 -133
- package/src/cache/key-discipline.ts +218 -0
- package/src/cache/timber-cache.ts +42 -5
- package/src/cli-dev-status.ts +196 -0
- package/src/cli-init.ts +278 -0
- package/src/cli.ts +33 -79
- package/src/client/error-boundary.tsx +19 -2
- package/src/client/use-cookie.ts +33 -21
- package/src/config-types.ts +40 -5
- package/src/config-validation.ts +37 -0
- package/src/cookies/define-cookie.ts +10 -46
- package/src/cookies/json-cookie.ts +4 -4
- package/src/index.ts +2 -0
- package/src/plugin-context.ts +7 -0
- package/src/plugins/dev-discovery.ts +216 -6
- package/src/plugins/dev-hostname.ts +322 -0
- package/src/plugins/dev-server.ts +96 -37
- package/src/plugins/dev-store-clear.ts +105 -7
- package/src/plugins/graph-endpoint.ts +15 -3
- package/src/plugins/optimize-package-imports-defaults.ts +88 -0
- package/src/plugins/optimize-package-imports.ts +439 -0
- package/src/plugins/prebuilt.ts +9 -0
- package/src/rsc-runtime/rsc.ts +7 -3
- package/src/rsc-runtime/server-references.ts +73 -0
- package/src/rsc-runtime/vendor-types.d.ts +9 -0
- package/src/server/access-gate.tsx +32 -20
- package/src/server/action-handler.ts +40 -34
- package/src/server/canonicalize.ts +27 -0
- package/src/server/cookie-context.ts +11 -3
- package/src/server/flight-source-node.ts +5 -2
- package/src/server/flight-source.ts +4 -3
- package/src/server/index.ts +6 -1
- package/src/server/interception-gates.ts +94 -0
- package/src/server/logger.ts +23 -0
- package/src/server/param-coercion.ts +22 -0
- package/src/server/pipeline-interception.ts +64 -4
- package/src/server/pipeline-metadata-route.ts +242 -0
- package/src/server/pipeline-metadata.ts +7 -5
- package/src/server/pipeline-phases.ts +71 -131
- package/src/server/pipeline.ts +20 -2
- package/src/server/prebuilt/dev-store.ts +113 -34
- package/src/server/prebuilt/overlay.ts +18 -0
- package/src/server/prebuilt-runtime.ts +43 -44
- package/src/server/primitives.ts +14 -0
- package/src/server/render-utils.ts +25 -0
- package/src/server/request-context.ts +27 -3
- package/src/server/route-element-builder.ts +15 -2
- package/src/server/route-handler.ts +3 -2
- package/src/server/route-matcher.ts +48 -33
- package/src/server/rsc-entry/api-handler.ts +2 -33
- package/src/server/rsc-entry/index.ts +8 -3
- package/src/server/rsc-entry/rsc-stream.ts +7 -1
- package/src/server/signal-identity.ts +30 -12
- package/src/server/traced-access.ts +50 -0
- package/src/server/tracing.ts +18 -1
- package/src/server/types.ts +5 -4
- package/src/shims/headers.ts +12 -4
- package/dist/_chunks/actions-vBHr2vqd.js.map +0 -1
- package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +0 -1
- package/dist/_chunks/cache-api-DdcDLpBj.js.map +0 -1
- package/dist/_chunks/chains-B8TCLved.js +0 -1
- package/dist/_chunks/cli-context-BJQB6rtF.js +0 -1
- package/dist/_chunks/dev-server-BNr5drEO.js.map +0 -1
- package/dist/_chunks/dev-server-CUg7Mqh_.js +0 -1
- package/dist/_chunks/dev-store-BOa304m_.js.map +0 -1
- package/dist/_chunks/flight-source-node-BdHUOUqg.js.map +0 -1
- package/dist/_chunks/graph-cache-CYiUS2aS.js.map +0 -1
- package/dist/_chunks/logger-CI_hThfy.js.map +0 -1
- package/dist/_chunks/node-response-bF0bKoig.js.map +0 -1
- package/dist/_chunks/plugin-context-DxMMvjUt.js.map +0 -1
- package/dist/server/prebuilt/key-discipline.d.ts +0 -52
- package/dist/server/prebuilt/key-discipline.d.ts.map +0 -1
- package/src/server/prebuilt/key-discipline.ts +0 -122
package/src/config-validation.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { createRequire } from 'node:module';
|
|
12
12
|
import type { TimberUserConfig } from './config-types.ts';
|
|
13
|
+
import { devHostnameError } from './plugins/dev-hostname.ts';
|
|
13
14
|
import { DEFAULT_RENDER_TIMEOUT_MS, RENDER_TIMEOUT_CEILING_MS } from './server/render-timeout.ts';
|
|
14
15
|
|
|
15
16
|
// ─── Types ──────────────────────────────────────────────────────────────────
|
|
@@ -42,6 +43,7 @@ const KNOWN_CONFIG_KEYS = {
|
|
|
42
43
|
limits: true,
|
|
43
44
|
forms: true,
|
|
44
45
|
pageExtensions: true,
|
|
46
|
+
optimizePackageImports: true,
|
|
45
47
|
slowRequestMs: true,
|
|
46
48
|
renderTimeoutMs: true,
|
|
47
49
|
devBrowserLogs: true,
|
|
@@ -114,6 +116,25 @@ export function validateConfig(config: TimberUserConfig): ConfigError[] {
|
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
// optimizePackageImports
|
|
120
|
+
if (config.optimizePackageImports !== undefined) {
|
|
121
|
+
const list: unknown = config.optimizePackageImports;
|
|
122
|
+
const badIndex = Array.isArray(list)
|
|
123
|
+
? list.findIndex((entry) => typeof entry !== 'string' || entry.trim() === '')
|
|
124
|
+
: -1;
|
|
125
|
+
if (!Array.isArray(list) || badIndex !== -1) {
|
|
126
|
+
const value = Array.isArray(list) ? list[badIndex] : list;
|
|
127
|
+
errors.push({
|
|
128
|
+
field: 'optimizePackageImports',
|
|
129
|
+
message: Array.isArray(list)
|
|
130
|
+
? `optimizePackageImports contains an invalid entry: ${String(JSON.stringify(value))}`
|
|
131
|
+
: 'optimizePackageImports must be an array of import specifiers.',
|
|
132
|
+
value,
|
|
133
|
+
suggestion: 'Example: optimizePackageImports: ["@acme/icons", "react-icons/fa"]',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
117
138
|
// allowedOrigins
|
|
118
139
|
if (config.allowedOrigins !== undefined) {
|
|
119
140
|
if (!Array.isArray(config.allowedOrigins)) {
|
|
@@ -185,6 +206,22 @@ export function validateConfig(config: TimberUserConfig): ConfigError[] {
|
|
|
185
206
|
}
|
|
186
207
|
}
|
|
187
208
|
|
|
209
|
+
// dev.hostname — not fatal: it is dev-only, so a typo must not fail
|
|
210
|
+
// `timber build`. Dev startup still refuses it (deriveDevHostname throws).
|
|
211
|
+
if (config.dev?.hostname !== undefined) {
|
|
212
|
+
const problem = devHostnameError(config.dev.hostname);
|
|
213
|
+
if (problem) {
|
|
214
|
+
errors.push({
|
|
215
|
+
field: 'dev.hostname',
|
|
216
|
+
message: `dev.hostname ${problem}`,
|
|
217
|
+
value: config.dev.hostname,
|
|
218
|
+
suggestion:
|
|
219
|
+
'Use DNS labels separated by dots, e.g. dev: { hostname: "blog" } for blog.localhost, ' +
|
|
220
|
+
'or false to keep plain localhost.',
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
188
225
|
// sitemap
|
|
189
226
|
if (config.sitemap != null && typeof config.sitemap === 'object') {
|
|
190
227
|
if (config.sitemap.enabled && !config.sitemap.baseUrl) {
|
|
@@ -81,7 +81,7 @@ export interface CookieDefinition<T> extends ServerOnlyCookieDefinition<T> {
|
|
|
81
81
|
// by trying getCookieJar() — if it throws the stub error, we fall through
|
|
82
82
|
// to the client path.
|
|
83
83
|
//
|
|
84
|
-
// Client: useCookie, getCookieValue,
|
|
84
|
+
// Client: useCookie, getCookieValue, writeClientCookie, deleteClientCookie
|
|
85
85
|
// are imported from use-cookie.ts. These are safe in all environments (no
|
|
86
86
|
// node:async_hooks dependency).
|
|
87
87
|
//
|
|
@@ -90,8 +90,9 @@ export interface CookieDefinition<T> extends ServerOnlyCookieDefinition<T> {
|
|
|
90
90
|
import { getCookieJar } from '@timber-js/app/server';
|
|
91
91
|
import {
|
|
92
92
|
useCookie as useRawCookie,
|
|
93
|
-
notifyCookieChange,
|
|
94
93
|
getCookieValue,
|
|
94
|
+
writeClientCookie,
|
|
95
|
+
deleteClientCookie,
|
|
95
96
|
} from '../client/use-cookie.ts';
|
|
96
97
|
|
|
97
98
|
// ─── Environment Detection ────────────────────────────────────────────────
|
|
@@ -117,33 +118,6 @@ function tryGetServerCookieJar(): ReturnType<typeof getCookieJar> | null {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
// ─── Client Cookie Helpers ────────────────────────────────────────────────
|
|
121
|
-
|
|
122
|
-
/** Write a cookie via document.cookie and notify useCookie subscribers. */
|
|
123
|
-
function setClientCookie(name: string, value: string, options?: ClientCookieOptions): void {
|
|
124
|
-
const parts: string[] = [`${name}=${encodeURIComponent(value)}`];
|
|
125
|
-
const path = options?.path ?? '/';
|
|
126
|
-
parts.push(`Path=${path}`);
|
|
127
|
-
if (options?.domain) parts.push(`Domain=${options.domain}`);
|
|
128
|
-
if (options?.maxAge !== undefined) parts.push(`Max-Age=${options.maxAge}`);
|
|
129
|
-
if (options?.expires) parts.push(`Expires=${options.expires.toUTCString()}`);
|
|
130
|
-
const sameSite = options?.sameSite ?? 'lax';
|
|
131
|
-
parts.push(`SameSite=${sameSite.charAt(0).toUpperCase()}${sameSite.slice(1)}`);
|
|
132
|
-
if (options?.secure) parts.push('Secure');
|
|
133
|
-
document.cookie = parts.join('; ');
|
|
134
|
-
notifyCookieChange(name);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** Delete a cookie via document.cookie and notify useCookie subscribers. */
|
|
138
|
-
function deleteClientCookie(name: string, options?: ClientCookieOptions): void {
|
|
139
|
-
const path = options?.path ?? '/';
|
|
140
|
-
const domain = options?.domain;
|
|
141
|
-
let cookieStr = `${name}=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=${path}`;
|
|
142
|
-
if (domain) cookieStr += `; Domain=${domain}`;
|
|
143
|
-
document.cookie = cookieStr;
|
|
144
|
-
notifyCookieChange(name);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
121
|
// ─── Standard Schema Auto-Detection ───────────────────────────────────────
|
|
148
122
|
|
|
149
123
|
function resolveCodec<T>(codecOrSchema: CookieCodec<T> | StandardSchemaV1<T>): CookieCodec<T> {
|
|
@@ -196,14 +170,10 @@ export function defineCookie<T, HttpOnly extends boolean = true>(
|
|
|
196
170
|
const isHttpOnly = options.httpOnly !== false; // default true
|
|
197
171
|
|
|
198
172
|
function getClientOpts(): ClientCookieOptions {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
expires: resolvedOptions.expires,
|
|
204
|
-
sameSite: resolvedOptions.sameSite,
|
|
205
|
-
secure: resolvedOptions.secure,
|
|
206
|
-
};
|
|
173
|
+
// httpOnly is the one attribute document.cookie cannot write.
|
|
174
|
+
const { httpOnly: _httpOnly, ...clientOpts } = resolvedOptions;
|
|
175
|
+
void _httpOnly;
|
|
176
|
+
return clientOpts;
|
|
207
177
|
}
|
|
208
178
|
|
|
209
179
|
const base: ServerOnlyCookieDefinition<T> = {
|
|
@@ -232,10 +202,7 @@ export function defineCookie<T, HttpOnly extends boolean = true>(
|
|
|
232
202
|
if (serverJar) {
|
|
233
203
|
const serialized = codec.serialize(value);
|
|
234
204
|
if (serialized === null) {
|
|
235
|
-
serverJar.delete(name,
|
|
236
|
-
path: resolvedOptions.path,
|
|
237
|
-
domain: resolvedOptions.domain,
|
|
238
|
-
});
|
|
205
|
+
serverJar.delete(name, resolvedOptions);
|
|
239
206
|
} else {
|
|
240
207
|
serverJar.set(name, serialized, resolvedOptions);
|
|
241
208
|
}
|
|
@@ -252,17 +219,14 @@ export function defineCookie<T, HttpOnly extends boolean = true>(
|
|
|
252
219
|
if (serialized === null) {
|
|
253
220
|
deleteClientCookie(name, getClientOpts());
|
|
254
221
|
} else {
|
|
255
|
-
|
|
222
|
+
writeClientCookie(name, serialized, getClientOpts());
|
|
256
223
|
}
|
|
257
224
|
},
|
|
258
225
|
|
|
259
226
|
delete(): void {
|
|
260
227
|
const serverJar = tryGetServerCookieJar();
|
|
261
228
|
if (serverJar) {
|
|
262
|
-
serverJar.delete(name,
|
|
263
|
-
path: resolvedOptions.path,
|
|
264
|
-
domain: resolvedOptions.domain,
|
|
265
|
-
});
|
|
229
|
+
serverJar.delete(name, resolvedOptions);
|
|
266
230
|
return;
|
|
267
231
|
}
|
|
268
232
|
// Client path
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* `JSON.parse` on parse. The framework handles the URL encoding /
|
|
7
7
|
* decoding around it (see design/29-cookies.md §"Encoding Contract"):
|
|
8
8
|
*
|
|
9
|
-
* defineCookie.
|
|
9
|
+
* defineCookie().set(value)
|
|
10
10
|
* → codec.serialize: JSON.stringify → '{"a":1}'
|
|
11
|
-
* →
|
|
11
|
+
* → getCookieJar().set: encodeURIComponent → '%7B%22a%22%3A1%7D'
|
|
12
12
|
* → wire: Set-Cookie: prefs=%7B%22a%22%3A1%7D
|
|
13
13
|
*
|
|
14
|
-
* defineCookie.
|
|
14
|
+
* defineCookie().get()
|
|
15
15
|
* → wire: Cookie: prefs=%7B%22a%22%3A1%7D
|
|
16
16
|
* → parseCookieHeader: decodeURIComponent → '{"a":1}'
|
|
17
17
|
* → codec.parse: JSON.parse → { a: 1 }
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* maxAge: 60 * 60 * 24 * 365,
|
|
37
37
|
* });
|
|
38
38
|
*
|
|
39
|
-
*
|
|
39
|
+
* prefsCookie.set({ lang: 'fr', fontSize: 18 });
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
42
|
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ import { timberServerBundle } from './plugins/server-bundle.ts';
|
|
|
35
35
|
import { timberEncryptionRuntime } from './plugins/encryption-runtime.ts';
|
|
36
36
|
import { timberCacheTransform } from './plugins/cache.ts';
|
|
37
37
|
import { timberRequestDep } from './plugins/request-dep/index.ts';
|
|
38
|
+
import { timberOptimizePackageImports } from './plugins/optimize-package-imports.ts';
|
|
38
39
|
import { timberPrebuilt } from './plugins/prebuilt.ts';
|
|
39
40
|
import { timberPrerenderSugar } from './plugins/prerender-sugar.ts';
|
|
40
41
|
import { timberCloudflareWasm } from './plugins/cloudflare-wasm.ts';
|
|
@@ -577,6 +578,7 @@ export function timber(config?: TimberUserConfig): PluginOption[] {
|
|
|
577
578
|
timberBuildManifest(ctx),
|
|
578
579
|
fonts,
|
|
579
580
|
timberMdx(ctx),
|
|
581
|
+
timberOptimizePackageImports(ctx), // Listed barrels → the modules that define the imported names
|
|
580
582
|
timberRequestDep(ctx),
|
|
581
583
|
timberCacheTransform(ctx),
|
|
582
584
|
timberPrerenderSugar(ctx), // export const prerender → cache.component() desugaring
|
package/src/plugin-context.ts
CHANGED
|
@@ -167,6 +167,13 @@ export interface PluginContext {
|
|
|
167
167
|
* RSC generateBundle alongside routePrebuiltComponents.
|
|
168
168
|
*/
|
|
169
169
|
prebuiltLazyChunks?: Map<string, string>;
|
|
170
|
+
/**
|
|
171
|
+
* Dev only: RSC module ID → the cache.component IDs its last transform
|
|
172
|
+
* declared. Written by timber-prebuilt's transform, read by
|
|
173
|
+
* timber-dev-server to scope a dev store clear to the components a saved
|
|
174
|
+
* module could have changed (plugins/dev-store-clear.ts, TIM-1599).
|
|
175
|
+
*/
|
|
176
|
+
devPrebuiltComponentIds?: Map<string, string[]>;
|
|
170
177
|
/**
|
|
171
178
|
* Content-keyed AST parse memo shared across cache/prebuilt/prerender-sugar
|
|
172
179
|
* transforms. Collapses both cross-plugin and cross-environment duplicate
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dev-server discovery records — `.timber/dev/<pid>-<port>-<token>.json`.
|
|
3
3
|
*
|
|
4
|
-
* On startup each dev server writes `{ port, pid, host, protocol }` to its own record
|
|
5
|
-
* file under the app's `.timber/dev/` so
|
|
6
|
-
* VS Code extension can discover a running
|
|
7
|
-
*
|
|
4
|
+
* On startup each dev server writes `{ url, port, pid, host, protocol }` to its own record
|
|
5
|
+
* file under the app's `.timber/dev/` so `timber dev status`, the
|
|
6
|
+
* `timber graph` CLI, and the VS Code extension can discover a running
|
|
7
|
+
* dev server. `timber dev status` is the public, agent-facing consumer;
|
|
8
|
+
* the records themselves are not.
|
|
8
9
|
*
|
|
9
10
|
* One record file per server, one writer per file. This is what makes
|
|
10
11
|
* multi-server roots (Vite auto-increments the port across processes;
|
|
@@ -29,12 +30,29 @@ import type { Server } from 'node:net';
|
|
|
29
30
|
import { Server as TlsServer } from 'node:tls';
|
|
30
31
|
import { randomUUID } from 'node:crypto';
|
|
31
32
|
import { mkdirSync, writeFileSync, rmSync, readFileSync, readdirSync } from 'node:fs';
|
|
32
|
-
import { join } from 'node:path';
|
|
33
|
+
import { dirname, join } from 'node:path';
|
|
34
|
+
import { request as httpRequest, type ClientRequest } from 'node:http';
|
|
35
|
+
import { request as httpsRequest } from 'node:https';
|
|
36
|
+
import type { AdvertisedUrls } from './dev-hostname.ts';
|
|
33
37
|
|
|
34
38
|
/** Relative path of the discovery directory within the project root. */
|
|
35
39
|
export const DEV_DISCOVERY_DIR = join('.timber', 'dev');
|
|
36
40
|
|
|
37
41
|
export interface DevRecord {
|
|
42
|
+
/**
|
|
43
|
+
* The URL the server printed and opened — Vite's `resolvedUrls` pick,
|
|
44
|
+
* with the app's dev hostname applied (`http://blog.localhost:3000/`,
|
|
45
|
+
* see plugins/dev-hostname.ts). What `timber dev status` reports. Taken
|
|
46
|
+
* from Vite rather than rebuilt from `host`, so the two cannot disagree.
|
|
47
|
+
*/
|
|
48
|
+
url: string;
|
|
49
|
+
/**
|
|
50
|
+
* The same server for non-browser HTTP clients: `url` at plain
|
|
51
|
+
* `localhost` when that resolves and verifies (see `loopbackUrl` in
|
|
52
|
+
* plugins/dev-hostname.ts). Computed by the server, which alone knows its
|
|
53
|
+
* TLS certificate.
|
|
54
|
+
*/
|
|
55
|
+
loopbackUrl: string;
|
|
38
56
|
port: number;
|
|
39
57
|
pid: number;
|
|
40
58
|
/**
|
|
@@ -133,12 +151,28 @@ function sweepDeadRecords(dir: string): void {
|
|
|
133
151
|
}
|
|
134
152
|
}
|
|
135
153
|
|
|
154
|
+
/**
|
|
155
|
+
* The directory whose `.timber/dev/` holds a server's record: the Vite
|
|
156
|
+
* config file's directory, falling back to the resolved root for an inline
|
|
157
|
+
* (`configFile: false`) server. Every consumer — `timber dev status`,
|
|
158
|
+
* `timber graph`, the VS Code extension — locates an app by its config or
|
|
159
|
+
* package directory without evaluating Vite, so the record goes where they
|
|
160
|
+
* look rather than under a `root` the config may move elsewhere.
|
|
161
|
+
*/
|
|
162
|
+
export function devRecordRoot(root: string, configFile: string | false | undefined): string {
|
|
163
|
+
return typeof configFile === 'string' ? dirname(configFile) : root;
|
|
164
|
+
}
|
|
165
|
+
|
|
136
166
|
/**
|
|
137
167
|
* Register discovery-record lifecycle handlers on the dev server's HTTP
|
|
138
168
|
* server. Writes `.timber/dev/<pid>-<port>-<token>.json` once the server is
|
|
139
169
|
* listening (the bound port is only known then) and removes exactly
|
|
140
170
|
* that record on clean shutdown.
|
|
141
171
|
*
|
|
172
|
+
* `urls` is read when the server starts listening: the URLs to advertise
|
|
173
|
+
* (`advertisedUrls`). With none, nothing is written — a record no one can
|
|
174
|
+
* open is not worth advertising.
|
|
175
|
+
*
|
|
142
176
|
* All filesystem work is best-effort: a failure to write or remove a
|
|
143
177
|
* record must never break the dev server. `httpServer` is null in
|
|
144
178
|
* middleware mode — no port exists, so there is nothing to advertise.
|
|
@@ -148,6 +182,7 @@ function sweepDeadRecords(dir: string): void {
|
|
|
148
182
|
export function registerDevDiscovery(
|
|
149
183
|
httpServer: Server | null,
|
|
150
184
|
root: string,
|
|
185
|
+
urls: () => AdvertisedUrls | undefined,
|
|
151
186
|
config?: {
|
|
152
187
|
configFile?: string | false;
|
|
153
188
|
base?: string;
|
|
@@ -164,16 +199,20 @@ export function registerDevDiscovery(
|
|
|
164
199
|
): void {
|
|
165
200
|
if (!httpServer) return;
|
|
166
201
|
|
|
167
|
-
const dir = join(root, DEV_DISCOVERY_DIR);
|
|
202
|
+
const dir = join(devRecordRoot(root, config?.configFile), DEV_DISCOVERY_DIR);
|
|
168
203
|
let recordPath: string | null = null;
|
|
169
204
|
|
|
170
205
|
httpServer.on('listening', () => {
|
|
171
206
|
const address = httpServer.address();
|
|
172
207
|
// Unix-socket listeners have a string address — no port to advertise.
|
|
173
208
|
if (address === null || typeof address === 'string') return;
|
|
209
|
+
const advertised = urls();
|
|
210
|
+
if (advertised === undefined) return;
|
|
174
211
|
const hmrOpts = typeof config?.server?.hmr === 'object' ? config.server.hmr : undefined;
|
|
175
212
|
const wsOpts = typeof config?.server?.ws === 'object' ? config.server.ws : undefined;
|
|
176
213
|
const record: DevRecord = {
|
|
214
|
+
url: advertised.url,
|
|
215
|
+
loopbackUrl: advertised.loopbackUrl,
|
|
177
216
|
port: address.port,
|
|
178
217
|
pid: process.pid,
|
|
179
218
|
host: address.address,
|
|
@@ -216,3 +255,174 @@ export function registerDevDiscovery(
|
|
|
216
255
|
}
|
|
217
256
|
});
|
|
218
257
|
}
|
|
258
|
+
|
|
259
|
+
// ─── Reading records ─────────────────────────────────────────────────────────
|
|
260
|
+
//
|
|
261
|
+
// The consumer side of the same contract, for the CLI: `timber graph` and
|
|
262
|
+
// `timber dev status` only see validated `DevRecord`s. The VS Code extension
|
|
263
|
+
// (packages/timber-vscode/src/graph-client.ts) is a separate package with its
|
|
264
|
+
// own reader of the same format; a format change must update both.
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* `GET /__timber/status` — the dev server's identity probe. Answers
|
|
268
|
+
* `{ pid }` with the serving process's pid, so a consumer can confirm the
|
|
269
|
+
* server on a record's port is the one that wrote the record (a crashed
|
|
270
|
+
* server's port may since have been taken by another process).
|
|
271
|
+
*/
|
|
272
|
+
export const STATUS_ENDPOINT_PATH = '/__timber/status';
|
|
273
|
+
|
|
274
|
+
/** Probe deadline: discovery must never hold a CLI hostage. */
|
|
275
|
+
export const DEV_PROBE_TIMEOUT_MS = 2_000;
|
|
276
|
+
|
|
277
|
+
/** Max probe response body (16 MB — matches the crawl child). */
|
|
278
|
+
const PROBE_MAX_BODY_BYTES = 16 * 1024 * 1024;
|
|
279
|
+
|
|
280
|
+
function isValidRecord(record: Partial<DevRecord>): record is DevRecord {
|
|
281
|
+
return (
|
|
282
|
+
typeof record.url === 'string' &&
|
|
283
|
+
typeof record.loopbackUrl === 'string' &&
|
|
284
|
+
typeof record.port === 'number' &&
|
|
285
|
+
Number.isInteger(record.port) &&
|
|
286
|
+
record.port >= 1 &&
|
|
287
|
+
record.port <= 65535 &&
|
|
288
|
+
typeof record.pid === 'number' &&
|
|
289
|
+
Number.isInteger(record.pid) &&
|
|
290
|
+
record.pid >= 1 &&
|
|
291
|
+
typeof record.host === 'string' &&
|
|
292
|
+
(record.protocol === 'http' || record.protocol === 'https')
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Records under `<root>/.timber/dev/` that are well-formed and name a live
|
|
298
|
+
* pid. These are candidates, not proof: the caller still has to probe the
|
|
299
|
+
* endpoint (`readLiveDevRecords`, or `timber graph`'s own graph request,
|
|
300
|
+
* which doubles as its probe). A missing directory or unreadable record is
|
|
301
|
+
* absence, never an error.
|
|
302
|
+
*/
|
|
303
|
+
export function readDevRecords(root: string): DevRecord[] {
|
|
304
|
+
const dir = join(root, DEV_DISCOVERY_DIR);
|
|
305
|
+
let entries: string[];
|
|
306
|
+
try {
|
|
307
|
+
entries = readdirSync(dir);
|
|
308
|
+
} catch {
|
|
309
|
+
return [];
|
|
310
|
+
}
|
|
311
|
+
const records: DevRecord[] = [];
|
|
312
|
+
for (const entry of entries) {
|
|
313
|
+
if (!entry.endsWith('.json')) continue;
|
|
314
|
+
let record: Partial<DevRecord>;
|
|
315
|
+
try {
|
|
316
|
+
record = JSON.parse(readFileSync(join(dir, entry), 'utf8')) as Partial<DevRecord>;
|
|
317
|
+
} catch {
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (isValidRecord(record) && isPidAlive(record.pid)) records.push(record);
|
|
321
|
+
}
|
|
322
|
+
return records;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Records whose server answers the status probe with the record's own pid —
|
|
327
|
+
* the full "pid alive AND probe succeeds" validation. Probes run in
|
|
328
|
+
* parallel, each under `DEV_PROBE_TIMEOUT_MS`.
|
|
329
|
+
*/
|
|
330
|
+
export async function readLiveDevRecords(root: string): Promise<DevRecord[]> {
|
|
331
|
+
const candidates = readDevRecords(root);
|
|
332
|
+
const answers = await Promise.all(
|
|
333
|
+
candidates.map((record) => probeDevServer(record, STATUS_ENDPOINT_PATH, DEV_PROBE_TIMEOUT_MS))
|
|
334
|
+
);
|
|
335
|
+
return candidates.filter((record, i) => {
|
|
336
|
+
const answer = answers[i];
|
|
337
|
+
return typeof answer === 'object' && answer !== null && 'pid' in answer
|
|
338
|
+
? answer.pid === record.pid
|
|
339
|
+
: false;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Wildcard binds (`0.0.0.0`, `::`) are reached through loopback; a server
|
|
345
|
+
* bound to one specific interface is reached only through that address.
|
|
346
|
+
*/
|
|
347
|
+
function connectHost(host: string): string {
|
|
348
|
+
return host === '0.0.0.0' || host === '::' || host === '' ? '127.0.0.1' : host;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* HTTP(S) GET against a record's server with a wall-clock deadline and a
|
|
353
|
+
* response-size limit, returning the parsed JSON body or null on any failure
|
|
354
|
+
* (non-200, bad JSON, timeout, connection error). Uses node:http/https
|
|
355
|
+
* directly — `fetch` silently strips the Host header, which the endpoint's
|
|
356
|
+
* DNS-rebinding defense needs to see as a localhost form.
|
|
357
|
+
*
|
|
358
|
+
* The wall-clock timer covers both connection and body streaming — node's
|
|
359
|
+
* `timeout` option is an INACTIVITY timeout that resets on every chunk, so a
|
|
360
|
+
* slow-drip response would never fire it.
|
|
361
|
+
*/
|
|
362
|
+
export function probeDevServer(
|
|
363
|
+
record: DevRecord,
|
|
364
|
+
path: string,
|
|
365
|
+
timeoutMs: number
|
|
366
|
+
): Promise<unknown> {
|
|
367
|
+
return new Promise((resolve) => {
|
|
368
|
+
let settled = false;
|
|
369
|
+
let req: ClientRequest | undefined;
|
|
370
|
+
const done = (value: unknown) => {
|
|
371
|
+
if (settled) return;
|
|
372
|
+
settled = true;
|
|
373
|
+
clearTimeout(wallClock);
|
|
374
|
+
resolve(value);
|
|
375
|
+
};
|
|
376
|
+
const wallClock = setTimeout(() => {
|
|
377
|
+
req?.destroy();
|
|
378
|
+
done(null);
|
|
379
|
+
}, timeoutMs);
|
|
380
|
+
|
|
381
|
+
const doRequest = record.protocol === 'https' ? httpsRequest : httpRequest;
|
|
382
|
+
try {
|
|
383
|
+
req = doRequest(
|
|
384
|
+
{
|
|
385
|
+
hostname: connectHost(record.host),
|
|
386
|
+
port: record.port,
|
|
387
|
+
path,
|
|
388
|
+
method: 'GET',
|
|
389
|
+
// Self-signed certs are normal for dev servers.
|
|
390
|
+
rejectUnauthorized: false,
|
|
391
|
+
},
|
|
392
|
+
(res) => {
|
|
393
|
+
if (res.statusCode !== 200) {
|
|
394
|
+
req?.destroy();
|
|
395
|
+
done(null);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const chunks: Buffer[] = [];
|
|
399
|
+
let totalBytes = 0;
|
|
400
|
+
res.on('data', (chunk: Buffer) => {
|
|
401
|
+
totalBytes += chunk.length;
|
|
402
|
+
if (totalBytes > PROBE_MAX_BODY_BYTES) {
|
|
403
|
+
req?.destroy();
|
|
404
|
+
done(null);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
chunks.push(chunk);
|
|
408
|
+
});
|
|
409
|
+
res.on('end', () => {
|
|
410
|
+
try {
|
|
411
|
+
done(JSON.parse(Buffer.concat(chunks).toString('utf8')));
|
|
412
|
+
} catch {
|
|
413
|
+
done(null);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
res.on('error', () => done(null));
|
|
417
|
+
}
|
|
418
|
+
);
|
|
419
|
+
} catch {
|
|
420
|
+
// http.request throws synchronously on malformed hostnames
|
|
421
|
+
// (ERR_INVALID_CHAR) or other invalid options — treat as absent.
|
|
422
|
+
done(null);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
req.on('error', () => done(null));
|
|
426
|
+
req.end();
|
|
427
|
+
});
|
|
428
|
+
}
|