@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,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `timber dev status [--json]` — which dev servers are running for this app.
|
|
3
|
+
*
|
|
4
|
+
* The agent-facing answer to "is a dev server already up?" Agents that
|
|
5
|
+
* skip the question start a second server, Vite bumps it to the next
|
|
6
|
+
* port, and the agent then tests a different server than the one the user
|
|
7
|
+
* is watching.
|
|
8
|
+
*
|
|
9
|
+
* Servers are found through their discovery records (plugins/dev-discovery.ts)
|
|
10
|
+
* and listed only after the full validation: pid alive AND the server
|
|
11
|
+
* answers the status probe with that pid. The record format stays private;
|
|
12
|
+
* this command is the public contract.
|
|
13
|
+
*
|
|
14
|
+
* Worktree-aware: `.timber/` is gitignored, so each git worktree has its own
|
|
15
|
+
* records. A server in another worktree serves that worktree's code — never
|
|
16
|
+
* reuse it — but it may be holding the port this checkout would have taken,
|
|
17
|
+
* so it is reported separately.
|
|
18
|
+
*
|
|
19
|
+
* See design/21-dev-server.md §"`timber dev status`".
|
|
20
|
+
*/
|
|
21
|
+
/** Bumped only on a breaking change to the `--json` shape. */
|
|
22
|
+
export declare const DEV_STATUS_JSON_VERSION = 1;
|
|
23
|
+
export interface DevStatusServer {
|
|
24
|
+
/** The URL the server printed — open this in a browser (`http://blog.localhost:3000/`). */
|
|
25
|
+
url: string;
|
|
26
|
+
/**
|
|
27
|
+
* The same server through plain `localhost` (`http://localhost:3000/`), for
|
|
28
|
+
* HTTP clients that resolve through the OS, which may not map `*.localhost`.
|
|
29
|
+
* Equal to `url` when the server has no dev hostname, or when its https
|
|
30
|
+
* certificate does not cover `localhost` (the named URL is then the only
|
|
31
|
+
* one that verifies).
|
|
32
|
+
*/
|
|
33
|
+
loopbackUrl: string;
|
|
34
|
+
port: number;
|
|
35
|
+
pid: number;
|
|
36
|
+
}
|
|
37
|
+
export interface DevStatusWorktree {
|
|
38
|
+
/** The other worktree's root directory. */
|
|
39
|
+
path: string;
|
|
40
|
+
/** Short branch name, or null for a detached HEAD. */
|
|
41
|
+
branch: string | null;
|
|
42
|
+
/** The same app, inside that worktree. */
|
|
43
|
+
appRoot: string;
|
|
44
|
+
servers: DevStatusServer[];
|
|
45
|
+
}
|
|
46
|
+
/** The `timber dev status --json` contract. */
|
|
47
|
+
export interface DevStatusReport {
|
|
48
|
+
version: typeof DEV_STATUS_JSON_VERSION;
|
|
49
|
+
/** The app this checkout's servers were looked up for. */
|
|
50
|
+
appRoot: string;
|
|
51
|
+
/** Live servers serving this checkout. Reuse one of these. */
|
|
52
|
+
servers: DevStatusServer[];
|
|
53
|
+
/** Live servers in other git worktrees of the same app — different code. */
|
|
54
|
+
otherWorktrees: DevStatusWorktree[];
|
|
55
|
+
}
|
|
56
|
+
interface Worktree {
|
|
57
|
+
path: string;
|
|
58
|
+
branch: string | null;
|
|
59
|
+
}
|
|
60
|
+
/** Parse `git worktree list --porcelain`, skipping bare entries. */
|
|
61
|
+
export declare function parseWorktreeList(porcelain: string): Worktree[];
|
|
62
|
+
export declare function collectDevStatus(appRoot: string): Promise<DevStatusReport>;
|
|
63
|
+
export declare function formatDevStatus(report: DevStatusReport): string;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the app root the way `timber graph` does — the directory of the
|
|
66
|
+
* Vite config, found by walking up from the cwd unless `--config` names it —
|
|
67
|
+
* then print the report. Exits 0 whether or not servers are found ("no server"
|
|
68
|
+
* is an answer); throws only when there is no config to anchor on.
|
|
69
|
+
*/
|
|
70
|
+
export declare function runDevStatus(options: {
|
|
71
|
+
config?: string;
|
|
72
|
+
json: boolean;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=cli-dev-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-dev-status.d.ts","sourceRoot":"","sources":["../src/cli-dev-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAaH,8DAA8D;AAC9D,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,2FAA2F;IAC3F,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,uBAAuB,CAAC;IACxC,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,4EAA4E;IAC5E,cAAc,EAAE,iBAAiB,EAAE,CAAC;CACrC;AAeD,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE,CAgB/D;AAqCD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAMhF;AASD,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAkB/D;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAW7F"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `timber init` — point a project's agent instruction files at the guide
|
|
3
|
+
* that ships inside the installed `@timber-js/app` package.
|
|
4
|
+
*
|
|
5
|
+
* The guide (`node_modules/@timber-js/app/agent-skill.md`) is never copied.
|
|
6
|
+
* A copy freezes at the version `init` ran with; a pointer always reads the
|
|
7
|
+
* installed version. Each of `AGENTS.md` and `CLAUDE.md` gets one
|
|
8
|
+
* marker-delimited block that timber owns; everything outside the markers
|
|
9
|
+
* belongs to the user and is never touched.
|
|
10
|
+
*
|
|
11
|
+
* This module is also the single source of the block text: the
|
|
12
|
+
* create-timber-app templates are generated from `agentsFileContent()` /
|
|
13
|
+
* `claudeFileContent()` and a test fails if they drift.
|
|
14
|
+
*
|
|
15
|
+
* See design/11-platform.md §"`timber init` — agent guide pointer blocks".
|
|
16
|
+
*/
|
|
17
|
+
export declare const BLOCK_START = "<!-- timber:start -->";
|
|
18
|
+
export declare const BLOCK_END = "<!-- timber:end -->";
|
|
19
|
+
/** Where the guide lives, relative to the project root, in a non-hoisted install. */
|
|
20
|
+
export declare const AGENT_GUIDE_PATH = "node_modules/@timber-js/app/agent-skill.md";
|
|
21
|
+
/** The AGENTS.md block: a plain pointer, for every AGENTS.md-reading tool. */
|
|
22
|
+
export declare function agentsBlock(guide?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* The CLAUDE.md block: Claude Code's `@path` imports, so the guide is
|
|
25
|
+
* loaded into every session instead of relying on the agent following a
|
|
26
|
+
* pointer. `@AGENTS.md` carries the user's own AGENTS.md content to Claude.
|
|
27
|
+
* A missing import target is skipped silently, so the block is harmless
|
|
28
|
+
* before `node_modules` exists.
|
|
29
|
+
*/
|
|
30
|
+
export declare function claudeBlock(guide?: string): string;
|
|
31
|
+
/** A freshly created AGENTS.md: just the block. */
|
|
32
|
+
export declare function agentsFileContent(): string;
|
|
33
|
+
/** A freshly created CLAUDE.md: just the block. */
|
|
34
|
+
export declare function claudeFileContent(): string;
|
|
35
|
+
export type InitOutcome = {
|
|
36
|
+
kind: 'created';
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'updated';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'appended';
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'unchanged';
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'replaced-legacy';
|
|
45
|
+
backup: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'replaced-symlink';
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'skipped-symlink';
|
|
50
|
+
target: string;
|
|
51
|
+
};
|
|
52
|
+
/** What `init` will do to one file, decided before anything is written. */
|
|
53
|
+
interface Plan {
|
|
54
|
+
outcome: InitOutcome;
|
|
55
|
+
apply(): void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Decide what to do with one file. Pure: reads, never writes. `runInit`
|
|
59
|
+
* plans both files before applying either, so an error in one (malformed
|
|
60
|
+
* markers) leaves both untouched.
|
|
61
|
+
*/
|
|
62
|
+
export declare function planBlock(root: string, name: string, block: string): Plan;
|
|
63
|
+
/**
|
|
64
|
+
* Where the installed guide is, relative to `root`: `node_modules` in the
|
|
65
|
+
* project, or one a package manager hoisted to an ancestor (npm/yarn/bun
|
|
66
|
+
* workspaces). Null when no install is found (not installed yet, or Yarn PnP).
|
|
67
|
+
*/
|
|
68
|
+
export declare function findAgentGuide(root: string): string | null;
|
|
69
|
+
/** Run `timber init` in `root`: plan both files, then write them. */
|
|
70
|
+
export declare function runInit(root: string): void;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=cli-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-init.d.ts","sourceRoot":"","sources":["../src/cli-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAcH,eAAO,MAAM,WAAW,0BAA0B,CAAC;AACnD,eAAO,MAAM,SAAS,wBAAwB,CAAC;AAE/C,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,+CAA+C,CAAC;AAE7E,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,KAAK,GAAE,MAAyB,GAAG,MAAM,CAOpE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,GAAE,MAAyB,GAAG,MAAM,CAEpE;AAED,mDAAmD;AACnD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,mDAAmD;AACnD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAuBD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,2EAA2E;AAC3E,UAAU,IAAI;IACZ,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,IAAI,IAAI,CAAC;CACf;AAoDD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAuDzE;AAyBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO1D;AAED,qEAAqE;AACrE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAyB1C"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -9,11 +9,11 @@ export interface ParsedArgs {
|
|
|
9
9
|
config: string | undefined;
|
|
10
10
|
/** `--project`: the tsconfig `timber check` passes to tsgo. */
|
|
11
11
|
project: string | undefined;
|
|
12
|
-
/** `timber graph`
|
|
12
|
+
/** `timber graph` and `timber dev status`: emit the machine-readable JSON contract. */
|
|
13
13
|
json: boolean;
|
|
14
14
|
/** `timber graph` only: classify the whole project. */
|
|
15
15
|
all: boolean;
|
|
16
|
-
/** Positional arguments after the command (`schema sync`, `graph <file>`). */
|
|
16
|
+
/** Positional arguments after the command (`schema sync`, `dev status`, `graph <file>`). */
|
|
17
17
|
rest: string[];
|
|
18
18
|
}
|
|
19
19
|
export interface CommandOptions {
|
|
@@ -43,7 +43,8 @@ export interface CommandOptions {
|
|
|
43
43
|
*
|
|
44
44
|
* Each subcommand declares its exact flags (the `check --project` precedent,
|
|
45
45
|
* TIM-1332): `graph` additionally accepts a file positional plus `--json` and
|
|
46
|
-
* `--all`, and those two are rejected everywhere else
|
|
46
|
+
* `--all`, and those two are rejected everywhere else — except `--json`,
|
|
47
|
+
* which `dev status` accepts too.
|
|
47
48
|
*/
|
|
48
49
|
export declare function parseArgs(args: string[]): ParsedArgs;
|
|
49
50
|
/** @internal Dependency injection for testing. */
|
|
@@ -110,13 +111,4 @@ export declare function runCheck(options: CommandOptions, _deps?: CheckDeps): Pr
|
|
|
110
111
|
* See design/41-global-params.md §Auto-Scaffolding
|
|
111
112
|
*/
|
|
112
113
|
export declare function runSchema(args: string[]): Promise<void>;
|
|
113
|
-
/**
|
|
114
|
-
* `timber init` — write AGENTS.md (and a CLAUDE.md symlink to it) to the
|
|
115
|
-
* project root so AI coding agents can discover timber.js documentation and
|
|
116
|
-
* conventions.
|
|
117
|
-
*
|
|
118
|
-
* The content is read from the installed @timber-js/app package itself, so it
|
|
119
|
-
* stays in sync with the installed version.
|
|
120
|
-
*/
|
|
121
|
-
export declare function runInit(): Promise<void>;
|
|
122
114
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,QAAA,MAAM,QAAQ,YAAI,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAC1F,KAAK,OAAO,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzC,M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GAAG,OAAO,CAAC,IAAI,CAAC,CAMxF;AAID;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA6C7D"}
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
// src/cli.ts
|
|
3
3
|
var COMMANDS = [
|
|
4
4
|
"dev",
|
|
5
5
|
"build",
|
|
@@ -30,7 +30,8 @@ var COMMANDS = [
|
|
|
30
30
|
*
|
|
31
31
|
* Each subcommand declares its exact flags (the `check --project` precedent,
|
|
32
32
|
* TIM-1332): `graph` additionally accepts a file positional plus `--json` and
|
|
33
|
-
* `--all`, and those two are rejected everywhere else
|
|
33
|
+
* `--all`, and those two are rejected everywhere else — except `--json`,
|
|
34
|
+
* which `dev status` accepts too.
|
|
34
35
|
*/
|
|
35
36
|
function parseArgs(args) {
|
|
36
37
|
if (args.length === 0) throw new Error("No command provided. Usage: timber <dev|build|preview|check|schema|init|graph> [--config <path>]");
|
|
@@ -46,18 +47,20 @@ function parseArgs(args) {
|
|
|
46
47
|
if (arg === "--config" || arg === "-c") {
|
|
47
48
|
config = args[++i];
|
|
48
49
|
if (!config) throw new Error("--config requires a path argument");
|
|
49
|
-
} else if (arg === "--json"
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
|
|
50
|
+
} else if (arg === "--json") json = true;
|
|
51
|
+
else if (arg === "--all") {
|
|
52
|
+
if (command !== "graph") throw new Error(`--all is only valid for \`timber graph\` (the module-environment query).`);
|
|
53
|
+
all = true;
|
|
53
54
|
} else if (arg === "--project") {
|
|
54
55
|
if (command !== "check") throw new Error(`--project is only valid for \`timber check\` (it names the tsconfig to type-check). To point \`timber ${command}\` at a different Vite config, use --config <path>.`);
|
|
55
56
|
project = args[++i];
|
|
56
57
|
if (!project) throw new Error("--project requires a path argument");
|
|
57
58
|
} else if (arg.startsWith("-")) throw new Error(`Unknown option: ${arg}. The timber CLI accepts --config <path> (and --project <path> for \`check\`).${arg === "--port" || arg === "-p" ? " To change the port, set the PORT environment variable (PORT=4000 timber dev) or server.port in vite.config.ts." : ""}`);
|
|
58
|
-
else if (command === "schema" || command === "init" || command === "graph") rest.push(arg);
|
|
59
|
+
else if (command === "schema" || command === "init" || command === "graph" || command === "dev" && rest.length === 0 && arg === "status") rest.push(arg);
|
|
59
60
|
else throw new Error(`Unexpected argument: ${arg}. Usage: timber ${command} [--config <path>]`);
|
|
60
61
|
}
|
|
62
|
+
const devStatus = command === "dev" && rest[0] === "status";
|
|
63
|
+
if (json && command !== "graph" && !devStatus) throw new Error(`--json is only valid for \`timber graph\` and \`timber dev status\`.`);
|
|
61
64
|
if (command === "graph" && rest.length > 1) throw new Error(`timber graph takes one file. Usage: timber graph <file> [--json], or timber graph --all --json`);
|
|
62
65
|
return {
|
|
63
66
|
command,
|
|
@@ -90,7 +93,7 @@ async function runDev(options, _deps) {
|
|
|
90
93
|
return;
|
|
91
94
|
}
|
|
92
95
|
const { fork } = await import("node:child_process");
|
|
93
|
-
const { RESTART_EXIT_CODE } = await import("./_chunks/dev-server-
|
|
96
|
+
const { RESTART_EXIT_CODE } = await import("./_chunks/dev-server-CBvvM7Lr.js");
|
|
94
97
|
while (true) {
|
|
95
98
|
const result = await new Promise((resolve) => {
|
|
96
99
|
const child = fork(process.argv[1], process.argv.slice(2), {
|
|
@@ -142,8 +145,8 @@ async function runBuild(options, _deps) {
|
|
|
142
145
|
* exists but fails to load throws, naming the file (TIM-1066).
|
|
143
146
|
*/
|
|
144
147
|
async function runPreview(options, _deps) {
|
|
145
|
-
const { resolveTimberContext } = await import("./_chunks/cli-context-
|
|
146
|
-
const { adapterConfig, contextAdapter } = await import("./_chunks/plugin-context-
|
|
148
|
+
const { resolveTimberContext } = await import("./_chunks/cli-context-n5hmkdla.js");
|
|
149
|
+
const { adapterConfig, contextAdapter } = await import("./_chunks/plugin-context-BfSRKJfz.js");
|
|
147
150
|
const ctx = await resolveTimberContext("preview", options.config, _deps?.resolveViteConfig);
|
|
148
151
|
const adapter = contextAdapter(ctx);
|
|
149
152
|
if (typeof adapter?.preview !== "function") {
|
|
@@ -170,7 +173,7 @@ async function runPreview(options, _deps) {
|
|
|
170
173
|
* `--project` names the tsconfig handed to tsgo.
|
|
171
174
|
*/
|
|
172
175
|
async function runCheck(options, _deps) {
|
|
173
|
-
const { checkRoutes, runTypeCheck } = await import("./_chunks/cli-check-
|
|
176
|
+
const { checkRoutes, runTypeCheck } = await import("./_chunks/cli-check-Dv3f8d2j.js");
|
|
174
177
|
const { root } = await checkRoutes({ viteConfigFile: options.config }, _deps);
|
|
175
178
|
await runTypeCheck({
|
|
176
179
|
root,
|
|
@@ -186,7 +189,7 @@ async function runCheck(options, _deps) {
|
|
|
186
189
|
async function runSchema(args) {
|
|
187
190
|
const subcommand = args[0];
|
|
188
191
|
if (subcommand !== "sync") throw new Error(`Unknown schema subcommand: ${subcommand ?? "(none)"}. Usage: timber schema sync`);
|
|
189
|
-
const { runSchemaSync, defaultCodecForSegment } = await import("./_chunks/cli-schema-sync-
|
|
192
|
+
const { runSchemaSync, defaultCodecForSegment } = await import("./_chunks/cli-schema-sync-uq72EZmD.js");
|
|
190
193
|
const result = runSchemaSync(process.cwd());
|
|
191
194
|
if (result.filesystemSegments.length === 0) {
|
|
192
195
|
console.log("[timber] No dynamic segments found in app/.");
|
|
@@ -210,43 +213,6 @@ async function runSchema(args) {
|
|
|
210
213
|
for (const seg of result.removedSegments) console.log(` - ${seg}`);
|
|
211
214
|
}
|
|
212
215
|
}
|
|
213
|
-
/**
|
|
214
|
-
* `timber init` — write AGENTS.md (and a CLAUDE.md symlink to it) to the
|
|
215
|
-
* project root so AI coding agents can discover timber.js documentation and
|
|
216
|
-
* conventions.
|
|
217
|
-
*
|
|
218
|
-
* The content is read from the installed @timber-js/app package itself, so it
|
|
219
|
-
* stays in sync with the installed version.
|
|
220
|
-
*/
|
|
221
|
-
async function runInit() {
|
|
222
|
-
const { readFileSync, writeFileSync, existsSync, symlinkSync } = await import("node:fs");
|
|
223
|
-
const { resolve, dirname } = await import("node:path");
|
|
224
|
-
const { fileURLToPath } = await import("node:url");
|
|
225
|
-
const root = process.cwd();
|
|
226
|
-
const agentSkillPath = resolve(resolve(dirname(fileURLToPath(import.meta.url)), ".."), "agent-skill.md");
|
|
227
|
-
if (!existsSync(agentSkillPath)) throw new Error("agent-skill.md not found in @timber-js/app package. This may be a development install — try reinstalling.");
|
|
228
|
-
const agentSkill = readFileSync(agentSkillPath, "utf-8");
|
|
229
|
-
const agentsPath = resolve(root, "AGENTS.md");
|
|
230
|
-
const claudePath = resolve(root, "CLAUDE.md");
|
|
231
|
-
const wrote = [];
|
|
232
|
-
if (existsSync(agentsPath)) console.log("[timber] AGENTS.md already exists — skipping (delete it first to regenerate)");
|
|
233
|
-
else {
|
|
234
|
-
writeFileSync(agentsPath, agentSkill);
|
|
235
|
-
wrote.push("AGENTS.md");
|
|
236
|
-
}
|
|
237
|
-
if (existsSync(claudePath)) console.log("[timber] CLAUDE.md already exists — skipping (delete it first to regenerate)");
|
|
238
|
-
else try {
|
|
239
|
-
symlinkSync("AGENTS.md", claudePath, "file");
|
|
240
|
-
wrote.push("CLAUDE.md (symlink)");
|
|
241
|
-
} catch {
|
|
242
|
-
writeFileSync(claudePath, "Read AGENTS.md for project context and conventions.\n");
|
|
243
|
-
wrote.push("CLAUDE.md");
|
|
244
|
-
}
|
|
245
|
-
if (wrote.length > 0) {
|
|
246
|
-
console.log(`[timber] Created ${wrote.join(" and ")} — AI agents can now discover timber.js docs.`);
|
|
247
|
-
console.log("[timber] Full documentation: node_modules/@timber-js/app/docs/");
|
|
248
|
-
} else console.log("[timber] Nothing to do — both files already exist.");
|
|
249
|
-
}
|
|
250
216
|
async function main() {
|
|
251
217
|
const parsed = parseArgs(process.argv.slice(2));
|
|
252
218
|
const options = {
|
|
@@ -255,7 +221,13 @@ async function main() {
|
|
|
255
221
|
};
|
|
256
222
|
switch (parsed.command) {
|
|
257
223
|
case "dev":
|
|
258
|
-
|
|
224
|
+
if (parsed.rest[0] === "status") {
|
|
225
|
+
const { runDevStatus } = await import("./_chunks/cli-dev-status-prPMLU8G.js");
|
|
226
|
+
await runDevStatus({
|
|
227
|
+
config: parsed.config,
|
|
228
|
+
json: parsed.json
|
|
229
|
+
});
|
|
230
|
+
} else await runDev(options);
|
|
259
231
|
break;
|
|
260
232
|
case "build":
|
|
261
233
|
await runBuild(options);
|
|
@@ -269,9 +241,11 @@ async function main() {
|
|
|
269
241
|
case "schema":
|
|
270
242
|
await runSchema(parsed.rest);
|
|
271
243
|
break;
|
|
272
|
-
case "init":
|
|
273
|
-
await
|
|
244
|
+
case "init": {
|
|
245
|
+
const { runInit } = await import("./_chunks/cli-init-BoXOYYil.js");
|
|
246
|
+
runInit(process.cwd());
|
|
274
247
|
break;
|
|
248
|
+
}
|
|
275
249
|
case "graph": {
|
|
276
250
|
const { runGraph } = await import("./analyze/graph-command.js");
|
|
277
251
|
await runGraph({
|
|
@@ -288,7 +262,6 @@ if (typeof process !== "undefined" && process.argv[1] && (import.meta.url.endsWi
|
|
|
288
262
|
console.error(err.message);
|
|
289
263
|
process.exit(1);
|
|
290
264
|
});
|
|
291
|
-
|
|
292
|
-
export { parseArgs, runBuild, runCheck, runDev, runInit, runPreview, runSchema };
|
|
265
|
+
export { parseArgs, runBuild, runCheck, runDev, runPreview, runSchema };
|
|
293
266
|
|
|
294
267
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// timber.js CLI\n//\n// Wraps Vite commands with timber-specific behavior.\n// See design/18-build-system.md §\"CLI\".\n//\n// Commands:\n// timber dev — Start Vite dev server with HMR\n// timber build — Run multi-environment build via createBuilder/buildApp\n// timber preview — Serve the production build\n// timber check — Validate types + routes without building\n// timber graph — Classify a file's module environment(s) (design/47)\n\n// Type-only — the implementation is imported dynamically inside runCheck so the\n// CLI's other commands never load the route scanner.\nimport type { CheckDeps } from './cli-check.ts';\nimport type { ResolveViteConfig } from './cli-context.ts';\n\nexport type { CheckDeps };\n\nconst COMMANDS = ['dev', 'build', 'preview', 'check', 'schema', 'init', 'graph'] as const;\ntype Command = (typeof COMMANDS)[number];\n\nexport interface ParsedArgs {\n command: Command;\n config: string | undefined;\n /** `--project`: the tsconfig `timber check` passes to tsgo. */\n project: string | undefined;\n /** `timber graph` only: emit the machine-readable JSON contract. */\n json: boolean;\n /** `timber graph` only: classify the whole project. */\n all: boolean;\n /** Positional arguments after the command (`schema sync`, `graph <file>`). */\n rest: string[];\n}\n\nexport interface CommandOptions {\n /** Path to a Vite config file. Means the same thing for every command. */\n config?: string;\n /** `timber check` only: the tsconfig to type-check. */\n project?: string;\n}\n\n/**\n * Parse CLI arguments into a structured command + options.\n * Accepts: timber <command> [--config|-c <path>] [--project <path>]\n *\n * `--config` names a **Vite** config file for every command, `check` included\n * (TIM-1332): `check` resolves the project through Vite, so a project that\n * builds with `--config ./custom.vite.config.ts` has to be checkable the same\n * way. `--project` names the tsconfig, spelled as tsgo and tsc spell it, and\n * is meaningful only for `check`.\n *\n * Before TIM-1332 `--config` meant the tsconfig for `check` alone — one flag\n * with two meanings, which the docs had to carry a note to explain and which\n * left custom Vite configs unreachable from `check` entirely.\n *\n * Unknown flags are an error, not silently ignored — `timber dev --port 4000`\n * starting on the default port would contradict fail-loudly. The surface stays\n * deliberately small (design/11-platform.md §CLI); port selection goes through\n * the PORT env var or server.port in vite.config.ts.\n *\n * Each subcommand declares its exact flags (the `check --project` precedent,\n * TIM-1332): `graph` additionally accepts a file positional plus `--json` and\n * `--all`, and those two are rejected everywhere else.\n */\nexport function parseArgs(args: string[]): ParsedArgs {\n if (args.length === 0) {\n throw new Error(\n 'No command provided. Usage: timber <dev|build|preview|check|schema|init|graph> [--config <path>]'\n );\n }\n\n const command = args[0];\n if (!COMMANDS.includes(command as Command)) {\n throw new Error(`Unknown command: ${command}. Available commands: ${COMMANDS.join(', ')}`);\n }\n\n let config: string | undefined;\n let project: string | undefined;\n let json = false;\n let all = false;\n const rest: string[] = [];\n for (let i = 1; i < args.length; i++) {\n const arg = args[i];\n if (arg === '--config' || arg === '-c') {\n config = args[++i];\n if (!config) {\n throw new Error('--config requires a path argument');\n }\n } else if (arg === '--json' || arg === '--all') {\n if (command !== 'graph') {\n throw new Error(\n `${arg} is only valid for \\`timber graph\\` (the module-environment query).`\n );\n }\n if (arg === '--json') json = true;\n else all = true;\n } else if (arg === '--project') {\n if (command !== 'check') {\n throw new Error(\n `--project is only valid for \\`timber check\\` (it names the tsconfig to type-check). ` +\n `To point \\`timber ${command}\\` at a different Vite config, use --config <path>.`\n );\n }\n project = args[++i];\n if (!project) {\n throw new Error('--project requires a path argument');\n }\n } else if (arg.startsWith('-')) {\n const portHint =\n arg === '--port' || arg === '-p'\n ? ' To change the port, set the PORT environment variable (PORT=4000 timber dev) ' +\n 'or server.port in vite.config.ts.'\n : '';\n throw new Error(\n `Unknown option: ${arg}. The timber CLI accepts --config <path>` +\n ` (and --project <path> for \\`check\\`).${portHint}`\n );\n } else if (command === 'schema' || command === 'init' || command === 'graph') {\n rest.push(arg);\n } else {\n throw new Error(`Unexpected argument: ${arg}. Usage: timber ${command} [--config <path>]`);\n }\n }\n\n if (command === 'graph' && rest.length > 1) {\n throw new Error(\n `timber graph takes one file. Usage: timber graph <file> [--json], or timber graph --all --json`\n );\n }\n\n return { command: command as Command, config, project, json, all, rest };\n}\n\n// ─── Command Implementations ─────────────────────────────────────────────────\n\n/** @internal Dependency injection for testing. */\nexport interface ViteDeps {\n createServer?: typeof import('vite').createServer;\n createBuilder?: typeof import('vite').createBuilder;\n resolveViteConfig?: ResolveViteConfig;\n}\n\n/**\n * Start the Vite dev server with a supervisor that respawns the process\n * when timber.config.ts changes. Node's require cache for ESM modules\n * loaded via require() cannot be evicted, so an in-process restart\n * serves stale config. The supervisor forks a worker; when the worker\n * exits with RESTART_EXIT_CODE (set by timber-dev-server on config file\n * change), the supervisor spawns a fresh worker with a clean cache.\n *\n * The timber plugin binds the port immediately with a holding page\n * (in rootSync's config hook) so browsers see a \"starting...\" page\n * instead of ERR_CONNECTION_REFUSED during initialization.\n *\n * See design/21-dev-server.md, TIM-665, TIM-1444.\n */\nexport async function runDev(options: CommandOptions, _deps?: ViteDeps): Promise<void> {\n // Worker mode: run the dev server directly (forked by supervisor below)\n if (process.env.__TIMBER_DEV_WORKER) {\n const createServer = _deps?.createServer ?? (await import('vite')).createServer;\n const server = await createServer({\n configFile: options.config,\n });\n await server.listen();\n server.printUrls();\n return;\n }\n\n // Supervisor mode: fork a worker and respawn on config changes.\n const { fork } = await import('node:child_process');\n const { RESTART_EXIT_CODE } = await import('./plugins/dev-server.ts');\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await new Promise<{ code: number | null; signal: NodeJS.Signals | null }>(\n (resolve) => {\n const child = fork(process.argv[1], process.argv.slice(2), {\n stdio: 'inherit',\n env: { ...process.env, __TIMBER_DEV_WORKER: '1' },\n });\n\n // Forward signals to the child. SIGINT from Ctrl+C is sent to\n // the entire process group, but a targeted SIGTERM (from a\n // process manager or test teardown) only reaches the parent.\n const onSigint = () => child.kill('SIGINT');\n const onSigterm = () => child.kill('SIGTERM');\n process.on('SIGINT', onSigint);\n process.on('SIGTERM', onSigterm);\n\n child.on('exit', (code, signal) => {\n process.off('SIGINT', onSigint);\n process.off('SIGTERM', onSigterm);\n resolve({ code, signal });\n });\n }\n );\n\n if (result.code === RESTART_EXIT_CODE) {\n continue;\n }\n\n // Child was killed by a signal (e.g. SIGTERM) — re-raise on ourselves\n if (result.signal) {\n process.kill(process.pid, result.signal);\n }\n\n if (result.code != null && result.code !== 0) {\n process.exit(result.code);\n }\n\n break;\n }\n}\n\n/**\n * Run the production build using createBuilder + buildApp.\n * Direct build() calls do NOT trigger the RSC plugin's multi-environment\n * pipeline — createBuilder/buildApp is required.\n */\nexport async function runBuild(options: CommandOptions, _deps?: ViteDeps): Promise<void> {\n const createBuilder = _deps?.createBuilder ?? (await import('vite')).createBuilder;\n const builder = await createBuilder({\n configFile: options.config,\n });\n await builder.buildApp();\n}\n\n/**\n * Serve the production build for local testing.\n * The adapter's preview() serves it; without one, preview fails (TIM-1565).\n * There is no fallback to Vite preview: it would serve the build directory\n * itself — the server bundles as static files, with no root `index.html` —\n * which is useless in either output mode.\n *\n * The project is resolved through Vite, as `timber check` resolves it\n * (`cli-context.ts`), so the adapter, the output mode, and the build\n * directory are the ones `timber build` used — including `--config`, inline\n * `timber({ ... })` options, Vite's `root`, and `build.outDir`, none of which\n * a re-read of `timber.config.ts` can see (TIM-1531). A config file that\n * exists but fails to load throws, naming the file (TIM-1066).\n */\nexport async function runPreview(options: CommandOptions, _deps?: ViteDeps): Promise<void> {\n const { resolveTimberContext } = await import('./cli-context.ts');\n const { adapterConfig, contextAdapter } = await import('./plugin-context.ts');\n\n const ctx = await resolveTimberContext('preview', options.config, _deps?.resolveViteConfig);\n const adapter = contextAdapter(ctx);\n\n if (typeof adapter?.preview !== 'function') {\n const missing = adapter\n ? `The adapter '${adapter.name}' has no preview(), so \\`timber preview\\` cannot serve this build.`\n : `No adapter is configured, so \\`timber preview\\` has nothing to serve this build with.`;\n throw new Error(\n `[timber] ${missing} Use an adapter that implements preview() — ` +\n `cloudflare() from '@timber-js/app/adapters/cloudflare', or nitro() from ` +\n `'@timber-js/app/adapters/nitro' (any preset for a static build; node-server or bun ` +\n `for a server build) — or serve the build with your platform's own tooling.`\n );\n }\n\n await adapter.preview(adapterConfig(ctx), {\n output: ctx.config.output ?? 'server',\n outputDir: ctx.buildDir,\n });\n}\n\n/**\n * Validate routes and types without producing build output.\n *\n * Runs the route pass first — resolve the project through Vite, scan it, fail\n * on proven-fatal convention errors, print warnings, and regenerate the route\n * types — then `tsgo --noEmit`. Codegen has to precede the type pass: the\n * generated `.timber/*.d.ts` files are what type `<Link href>` and\n * `useSegmentParams()`, and a fresh clone has never produced them. See\n * `cli-check.ts` for the full reasoning.\n *\n * `--config` names the **Vite** config, as it does for every other command, so\n * an app that builds with a custom one is checkable the same way.\n * `--project` names the tsconfig handed to tsgo.\n */\nexport async function runCheck(options: CommandOptions, _deps?: CheckDeps): Promise<void> {\n const { checkRoutes, runTypeCheck } = await import('./cli-check.ts');\n const { root } = await checkRoutes({ viteConfigFile: options.config }, _deps);\n // tsgo runs from the root the route pass resolved, not from cwd — that is\n // where it just wrote the declarations tsgo has to read.\n await runTypeCheck({ root, config: options.project }, _deps);\n}\n\n// ─── Schema Subcommand ───────────────────────────────────────────────────────\n\n/**\n * `timber schema sync` — scan filesystem for dynamic segments, diff against\n * app/schema.ts, and append missing entries with type-appropriate codec defaults.\n *\n * See design/41-global-params.md §Auto-Scaffolding\n */\nexport async function runSchema(args: string[]): Promise<void> {\n const subcommand = args[0];\n\n if (subcommand !== 'sync') {\n throw new Error(\n `Unknown schema subcommand: ${subcommand ?? '(none)'}. Usage: timber schema sync`\n );\n }\n\n const { runSchemaSync, defaultCodecForSegment } = await import('./cli-schema-sync.ts');\n const result = runSchemaSync(process.cwd());\n\n if (result.filesystemSegments.length === 0) {\n console.log('[timber] No dynamic segments found in app/.');\n return;\n }\n\n if (result.created) {\n console.log(`[timber] Created app/schema.ts with ${result.addedSegments.length} segment(s):`);\n for (const seg of result.addedSegments) {\n console.log(` + ${seg}: ${defaultCodecForSegment(seg)}`);\n }\n return;\n }\n\n if (result.addedSegments.length === 0 && result.removedSegments.length === 0) {\n console.log('[timber] Schema is up to date — all segments are registered.');\n return;\n }\n\n if (result.addedSegments.length > 0) {\n console.log(`[timber] Added ${result.addedSegments.length} segment(s) to app/schema.ts:`);\n for (const seg of result.addedSegments) {\n console.log(` + ${seg}: ${defaultCodecForSegment(seg)}`);\n }\n }\n\n if (result.removedSegments.length > 0) {\n console.log(\n `[timber] Removed ${result.removedSegments.length} stale segment(s) from app/schema.ts:`\n );\n for (const seg of result.removedSegments) {\n console.log(` - ${seg}`);\n }\n }\n}\n\n// ─── Init Subcommand ─────────────────────────────────────────────────────────\n\n/**\n * `timber init` — write AGENTS.md (and a CLAUDE.md symlink to it) to the\n * project root so AI coding agents can discover timber.js documentation and\n * conventions.\n *\n * The content is read from the installed @timber-js/app package itself, so it\n * stays in sync with the installed version.\n */\nexport async function runInit(): Promise<void> {\n const { readFileSync, writeFileSync, existsSync, symlinkSync } = await import('node:fs');\n const { resolve, dirname } = await import('node:path');\n const { fileURLToPath } = await import('node:url');\n\n const root = process.cwd();\n const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\n\n const agentSkillPath = resolve(packageRoot, 'agent-skill.md');\n if (!existsSync(agentSkillPath)) {\n throw new Error(\n 'agent-skill.md not found in @timber-js/app package. ' +\n 'This may be a development install — try reinstalling.'\n );\n }\n\n const agentSkill = readFileSync(agentSkillPath, 'utf-8');\n\n const agentsPath = resolve(root, 'AGENTS.md');\n const claudePath = resolve(root, 'CLAUDE.md');\n\n const wrote: string[] = [];\n\n if (existsSync(agentsPath)) {\n console.log('[timber] AGENTS.md already exists — skipping (delete it first to regenerate)');\n } else {\n writeFileSync(agentsPath, agentSkill);\n wrote.push('AGENTS.md');\n }\n\n if (existsSync(claudePath)) {\n console.log('[timber] CLAUDE.md already exists — skipping (delete it first to regenerate)');\n } else {\n try {\n // Relative target so the link survives the project directory moving.\n // The 'file' type argument is required for Windows (ignored elsewhere).\n symlinkSync('AGENTS.md', claudePath, 'file');\n wrote.push('CLAUDE.md (symlink)');\n } catch {\n // Windows without Developer Mode or admin rights can't create symlinks\n // (EPERM) — fall back to a plain pointer file.\n writeFileSync(claudePath, 'Read AGENTS.md for project context and conventions.\\n');\n wrote.push('CLAUDE.md');\n }\n }\n\n if (wrote.length > 0) {\n console.log(\n `[timber] Created ${wrote.join(' and ')} — AI agents can now discover timber.js docs.`\n );\n console.log('[timber] Full documentation: node_modules/@timber-js/app/docs/');\n } else {\n console.log('[timber] Nothing to do — both files already exist.');\n }\n}\n\n// ─── Main Entry Point ────────────────────────────────────────────────────────\n\nasync function main(): Promise<void> {\n const parsed = parseArgs(process.argv.slice(2));\n const options: CommandOptions = { config: parsed.config, project: parsed.project };\n\n switch (parsed.command) {\n case 'dev':\n await runDev(options);\n break;\n case 'build':\n await runBuild(options);\n break;\n case 'preview':\n await runPreview(options);\n break;\n case 'check':\n await runCheck(options);\n break;\n case 'schema':\n await runSchema(parsed.rest);\n break;\n case 'init':\n await runInit();\n break;\n case 'graph': {\n // Lazy import — the graph implementation (and, on a cache miss,\n // Vite + the crawl child) never loads for the other commands.\n const { runGraph } = await import('./analyze/graph-command.ts');\n await runGraph({\n file: parsed.rest[0],\n config: parsed.config,\n json: parsed.json,\n all: parsed.all,\n });\n break;\n }\n }\n}\n\n// Run main when executed as a CLI (not imported in tests).\n// The bin shim (bin/timber.mjs) does `import '../dist/cli.js'`, so\n// process.argv[1] points to the shim, not this file. We check both:\n// direct execution AND being imported by the timber bin shim.\nconst isDirectExecution =\n typeof process !== 'undefined' &&\n process.argv[1] &&\n (import.meta.url.endsWith(process.argv[1]) ||\n process.argv[1].endsWith('bin/timber.mjs') ||\n process.argv[1].endsWith('bin/timber'));\n\nif (isDirectExecution) {\n main().catch((err) => {\n console.error(err.message);\n process.exit(1);\n });\n}\n"],"mappings":";;AAqBA,IAAM,WAAW;CAAC;CAAO;CAAS;CAAW;CAAS;CAAU;CAAQ;AAAO;;;;;;;;;;;;;;;;;;;;;;;;AA8C/E,SAAgB,UAAU,MAA4B;CACpD,IAAI,KAAK,WAAW,GAClB,MAAM,IAAI,MACR,kGACF;CAGF,MAAM,UAAU,KAAK;CACrB,IAAI,CAAC,SAAS,SAAS,OAAkB,GACvC,MAAM,IAAI,MAAM,oBAAoB,QAAQ,wBAAwB,SAAS,KAAK,IAAI,GAAG;CAG3F,IAAI;CACJ,IAAI;CACJ,IAAI,OAAO;CACX,IAAI,MAAM;CACV,MAAM,OAAiB,C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AM,SAAS,OAAO;GACtB;EACF,KAAK;GACH,MAAM,WAAW,OAAO;GACxB;EACF,KAAK;GACH,MAAM,SAAS,OAAO;GACtB;EACF,KAAK;GACH,MAAM,UAAU,OAAO,IAAI;GAC3B;EACF,KAAK;GACH,MAAM,QAAQ;GACd;EACF,KAAK,SAAS;GAGZ,MAAM,EAAE,aAAa,MAAM,OAAO;GAClC,MAAM,SAAS;IACb,MAAM,OAAO,KAAK;IAClB,QAAQ,OAAO;IACf,MAAM,OAAO;IACb,KAAK,OAAO;GACd,CAAC;GACD;EACF;CACF;AACF;AAaA,IANE,OAAO,YAAY,eACnB,QAAQ,KAAK,OACZ,YAAY,IAAI,SAAS,QAAQ,KAAK,EAAE,KACvC,QAAQ,KAAK,EAAE,CAAC,SAAS,gBAAgB,KACzC,QAAQ,KAAK,EAAE,CAAC,SAAS,YAAY,IAGvC,KAAK,CAAC,CAAC,OAAO,QAAQ;CACpB,QAAQ,MAAM,IAAI,OAAO;CACzB,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// timber.js CLI\n//\n// Wraps Vite commands with timber-specific behavior.\n// See design/18-build-system.md §\"CLI\".\n//\n// Commands:\n// timber dev — Start Vite dev server with HMR\n// timber build — Run multi-environment build via createBuilder/buildApp\n// timber preview — Serve the production build\n// timber check — Validate types + routes without building\n// timber graph — Classify a file's module environment(s) (design/47)\n// timber dev status — List running dev servers for this checkout (design/21)\n// timber init — Point AGENTS.md / CLAUDE.md at the installed agent guide\n\n// Type-only — the implementation is imported dynamically inside runCheck so the\n// CLI's other commands never load the route scanner.\nimport type { CheckDeps } from './cli-check.ts';\nimport type { ResolveViteConfig } from './cli-context.ts';\n\nexport type { CheckDeps };\n\nconst COMMANDS = ['dev', 'build', 'preview', 'check', 'schema', 'init', 'graph'] as const;\ntype Command = (typeof COMMANDS)[number];\n\nexport interface ParsedArgs {\n command: Command;\n config: string | undefined;\n /** `--project`: the tsconfig `timber check` passes to tsgo. */\n project: string | undefined;\n /** `timber graph` and `timber dev status`: emit the machine-readable JSON contract. */\n json: boolean;\n /** `timber graph` only: classify the whole project. */\n all: boolean;\n /** Positional arguments after the command (`schema sync`, `dev status`, `graph <file>`). */\n rest: string[];\n}\n\nexport interface CommandOptions {\n /** Path to a Vite config file. Means the same thing for every command. */\n config?: string;\n /** `timber check` only: the tsconfig to type-check. */\n project?: string;\n}\n\n/**\n * Parse CLI arguments into a structured command + options.\n * Accepts: timber <command> [--config|-c <path>] [--project <path>]\n *\n * `--config` names a **Vite** config file for every command, `check` included\n * (TIM-1332): `check` resolves the project through Vite, so a project that\n * builds with `--config ./custom.vite.config.ts` has to be checkable the same\n * way. `--project` names the tsconfig, spelled as tsgo and tsc spell it, and\n * is meaningful only for `check`.\n *\n * Before TIM-1332 `--config` meant the tsconfig for `check` alone — one flag\n * with two meanings, which the docs had to carry a note to explain and which\n * left custom Vite configs unreachable from `check` entirely.\n *\n * Unknown flags are an error, not silently ignored — `timber dev --port 4000`\n * starting on the default port would contradict fail-loudly. The surface stays\n * deliberately small (design/11-platform.md §CLI); port selection goes through\n * the PORT env var or server.port in vite.config.ts.\n *\n * Each subcommand declares its exact flags (the `check --project` precedent,\n * TIM-1332): `graph` additionally accepts a file positional plus `--json` and\n * `--all`, and those two are rejected everywhere else — except `--json`,\n * which `dev status` accepts too.\n */\nexport function parseArgs(args: string[]): ParsedArgs {\n if (args.length === 0) {\n throw new Error(\n 'No command provided. Usage: timber <dev|build|preview|check|schema|init|graph> [--config <path>]'\n );\n }\n\n const command = args[0];\n if (!COMMANDS.includes(command as Command)) {\n throw new Error(`Unknown command: ${command}. Available commands: ${COMMANDS.join(', ')}`);\n }\n\n let config: string | undefined;\n let project: string | undefined;\n let json = false;\n let all = false;\n const rest: string[] = [];\n for (let i = 1; i < args.length; i++) {\n const arg = args[i];\n if (arg === '--config' || arg === '-c') {\n config = args[++i];\n if (!config) {\n throw new Error('--config requires a path argument');\n }\n } else if (arg === '--json') {\n json = true;\n } else if (arg === '--all') {\n if (command !== 'graph') {\n throw new Error(`--all is only valid for \\`timber graph\\` (the module-environment query).`);\n }\n all = true;\n } else if (arg === '--project') {\n if (command !== 'check') {\n throw new Error(\n `--project is only valid for \\`timber check\\` (it names the tsconfig to type-check). ` +\n `To point \\`timber ${command}\\` at a different Vite config, use --config <path>.`\n );\n }\n project = args[++i];\n if (!project) {\n throw new Error('--project requires a path argument');\n }\n } else if (arg.startsWith('-')) {\n const portHint =\n arg === '--port' || arg === '-p'\n ? ' To change the port, set the PORT environment variable (PORT=4000 timber dev) ' +\n 'or server.port in vite.config.ts.'\n : '';\n throw new Error(\n `Unknown option: ${arg}. The timber CLI accepts --config <path>` +\n ` (and --project <path> for \\`check\\`).${portHint}`\n );\n } else if (\n command === 'schema' ||\n command === 'init' ||\n command === 'graph' ||\n (command === 'dev' && rest.length === 0 && arg === 'status')\n ) {\n rest.push(arg);\n } else {\n throw new Error(`Unexpected argument: ${arg}. Usage: timber ${command} [--config <path>]`);\n }\n }\n\n // Checked after the loop so flag order does not matter (`dev --json status`).\n const devStatus = command === 'dev' && rest[0] === 'status';\n if (json && command !== 'graph' && !devStatus) {\n throw new Error(`--json is only valid for \\`timber graph\\` and \\`timber dev status\\`.`);\n }\n\n if (command === 'graph' && rest.length > 1) {\n throw new Error(\n `timber graph takes one file. Usage: timber graph <file> [--json], or timber graph --all --json`\n );\n }\n\n return { command: command as Command, config, project, json, all, rest };\n}\n\n// ─── Command Implementations ─────────────────────────────────────────────────\n\n/** @internal Dependency injection for testing. */\nexport interface ViteDeps {\n createServer?: typeof import('vite').createServer;\n createBuilder?: typeof import('vite').createBuilder;\n resolveViteConfig?: ResolveViteConfig;\n}\n\n/**\n * Start the Vite dev server with a supervisor that respawns the process\n * when timber.config.ts changes. Node's require cache for ESM modules\n * loaded via require() cannot be evicted, so an in-process restart\n * serves stale config. The supervisor forks a worker; when the worker\n * exits with RESTART_EXIT_CODE (set by timber-dev-server on config file\n * change), the supervisor spawns a fresh worker with a clean cache.\n *\n * The timber plugin binds the port immediately with a holding page\n * (in rootSync's config hook) so browsers see a \"starting...\" page\n * instead of ERR_CONNECTION_REFUSED during initialization.\n *\n * See design/21-dev-server.md, TIM-665, TIM-1444.\n */\nexport async function runDev(options: CommandOptions, _deps?: ViteDeps): Promise<void> {\n // Worker mode: run the dev server directly (forked by supervisor below)\n if (process.env.__TIMBER_DEV_WORKER) {\n const createServer = _deps?.createServer ?? (await import('vite')).createServer;\n const server = await createServer({\n configFile: options.config,\n });\n await server.listen();\n server.printUrls();\n return;\n }\n\n // Supervisor mode: fork a worker and respawn on config changes.\n const { fork } = await import('node:child_process');\n const { RESTART_EXIT_CODE } = await import('./plugins/dev-server.ts');\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await new Promise<{ code: number | null; signal: NodeJS.Signals | null }>(\n (resolve) => {\n const child = fork(process.argv[1], process.argv.slice(2), {\n stdio: 'inherit',\n env: { ...process.env, __TIMBER_DEV_WORKER: '1' },\n });\n\n // Forward signals to the child. SIGINT from Ctrl+C is sent to\n // the entire process group, but a targeted SIGTERM (from a\n // process manager or test teardown) only reaches the parent.\n const onSigint = () => child.kill('SIGINT');\n const onSigterm = () => child.kill('SIGTERM');\n process.on('SIGINT', onSigint);\n process.on('SIGTERM', onSigterm);\n\n child.on('exit', (code, signal) => {\n process.off('SIGINT', onSigint);\n process.off('SIGTERM', onSigterm);\n resolve({ code, signal });\n });\n }\n );\n\n if (result.code === RESTART_EXIT_CODE) {\n continue;\n }\n\n // Child was killed by a signal (e.g. SIGTERM) — re-raise on ourselves\n if (result.signal) {\n process.kill(process.pid, result.signal);\n }\n\n if (result.code != null && result.code !== 0) {\n process.exit(result.code);\n }\n\n break;\n }\n}\n\n/**\n * Run the production build using createBuilder + buildApp.\n * Direct build() calls do NOT trigger the RSC plugin's multi-environment\n * pipeline — createBuilder/buildApp is required.\n */\nexport async function runBuild(options: CommandOptions, _deps?: ViteDeps): Promise<void> {\n const createBuilder = _deps?.createBuilder ?? (await import('vite')).createBuilder;\n const builder = await createBuilder({\n configFile: options.config,\n });\n await builder.buildApp();\n}\n\n/**\n * Serve the production build for local testing.\n * The adapter's preview() serves it; without one, preview fails (TIM-1565).\n * There is no fallback to Vite preview: it would serve the build directory\n * itself — the server bundles as static files, with no root `index.html` —\n * which is useless in either output mode.\n *\n * The project is resolved through Vite, as `timber check` resolves it\n * (`cli-context.ts`), so the adapter, the output mode, and the build\n * directory are the ones `timber build` used — including `--config`, inline\n * `timber({ ... })` options, Vite's `root`, and `build.outDir`, none of which\n * a re-read of `timber.config.ts` can see (TIM-1531). A config file that\n * exists but fails to load throws, naming the file (TIM-1066).\n */\nexport async function runPreview(options: CommandOptions, _deps?: ViteDeps): Promise<void> {\n const { resolveTimberContext } = await import('./cli-context.ts');\n const { adapterConfig, contextAdapter } = await import('./plugin-context.ts');\n\n const ctx = await resolveTimberContext('preview', options.config, _deps?.resolveViteConfig);\n const adapter = contextAdapter(ctx);\n\n if (typeof adapter?.preview !== 'function') {\n const missing = adapter\n ? `The adapter '${adapter.name}' has no preview(), so \\`timber preview\\` cannot serve this build.`\n : `No adapter is configured, so \\`timber preview\\` has nothing to serve this build with.`;\n throw new Error(\n `[timber] ${missing} Use an adapter that implements preview() — ` +\n `cloudflare() from '@timber-js/app/adapters/cloudflare', or nitro() from ` +\n `'@timber-js/app/adapters/nitro' (any preset for a static build; node-server or bun ` +\n `for a server build) — or serve the build with your platform's own tooling.`\n );\n }\n\n await adapter.preview(adapterConfig(ctx), {\n output: ctx.config.output ?? 'server',\n outputDir: ctx.buildDir,\n });\n}\n\n/**\n * Validate routes and types without producing build output.\n *\n * Runs the route pass first — resolve the project through Vite, scan it, fail\n * on proven-fatal convention errors, print warnings, and regenerate the route\n * types — then `tsgo --noEmit`. Codegen has to precede the type pass: the\n * generated `.timber/*.d.ts` files are what type `<Link href>` and\n * `useSegmentParams()`, and a fresh clone has never produced them. See\n * `cli-check.ts` for the full reasoning.\n *\n * `--config` names the **Vite** config, as it does for every other command, so\n * an app that builds with a custom one is checkable the same way.\n * `--project` names the tsconfig handed to tsgo.\n */\nexport async function runCheck(options: CommandOptions, _deps?: CheckDeps): Promise<void> {\n const { checkRoutes, runTypeCheck } = await import('./cli-check.ts');\n const { root } = await checkRoutes({ viteConfigFile: options.config }, _deps);\n // tsgo runs from the root the route pass resolved, not from cwd — that is\n // where it just wrote the declarations tsgo has to read.\n await runTypeCheck({ root, config: options.project }, _deps);\n}\n\n// ─── Schema Subcommand ───────────────────────────────────────────────────────\n\n/**\n * `timber schema sync` — scan filesystem for dynamic segments, diff against\n * app/schema.ts, and append missing entries with type-appropriate codec defaults.\n *\n * See design/41-global-params.md §Auto-Scaffolding\n */\nexport async function runSchema(args: string[]): Promise<void> {\n const subcommand = args[0];\n\n if (subcommand !== 'sync') {\n throw new Error(\n `Unknown schema subcommand: ${subcommand ?? '(none)'}. Usage: timber schema sync`\n );\n }\n\n const { runSchemaSync, defaultCodecForSegment } = await import('./cli-schema-sync.ts');\n const result = runSchemaSync(process.cwd());\n\n if (result.filesystemSegments.length === 0) {\n console.log('[timber] No dynamic segments found in app/.');\n return;\n }\n\n if (result.created) {\n console.log(`[timber] Created app/schema.ts with ${result.addedSegments.length} segment(s):`);\n for (const seg of result.addedSegments) {\n console.log(` + ${seg}: ${defaultCodecForSegment(seg)}`);\n }\n return;\n }\n\n if (result.addedSegments.length === 0 && result.removedSegments.length === 0) {\n console.log('[timber] Schema is up to date — all segments are registered.');\n return;\n }\n\n if (result.addedSegments.length > 0) {\n console.log(`[timber] Added ${result.addedSegments.length} segment(s) to app/schema.ts:`);\n for (const seg of result.addedSegments) {\n console.log(` + ${seg}: ${defaultCodecForSegment(seg)}`);\n }\n }\n\n if (result.removedSegments.length > 0) {\n console.log(\n `[timber] Removed ${result.removedSegments.length} stale segment(s) from app/schema.ts:`\n );\n for (const seg of result.removedSegments) {\n console.log(` - ${seg}`);\n }\n }\n}\n\n// ─── Main Entry Point ────────────────────────────────────────────────────────\n\nasync function main(): Promise<void> {\n const parsed = parseArgs(process.argv.slice(2));\n const options: CommandOptions = { config: parsed.config, project: parsed.project };\n\n switch (parsed.command) {\n case 'dev':\n if (parsed.rest[0] === 'status') {\n const { runDevStatus } = await import('./cli-dev-status.ts');\n await runDevStatus({ config: parsed.config, json: parsed.json });\n } else {\n await runDev(options);\n }\n break;\n case 'build':\n await runBuild(options);\n break;\n case 'preview':\n await runPreview(options);\n break;\n case 'check':\n await runCheck(options);\n break;\n case 'schema':\n await runSchema(parsed.rest);\n break;\n case 'init': {\n const { runInit } = await import('./cli-init.ts');\n runInit(process.cwd());\n break;\n }\n case 'graph': {\n // Lazy import — the graph implementation (and, on a cache miss,\n // Vite + the crawl child) never loads for the other commands.\n const { runGraph } = await import('./analyze/graph-command.ts');\n await runGraph({\n file: parsed.rest[0],\n config: parsed.config,\n json: parsed.json,\n all: parsed.all,\n });\n break;\n }\n }\n}\n\n// Run main when executed as a CLI (not imported in tests).\n// The bin shim (bin/timber.mjs) does `import '../dist/cli.js'`, so\n// process.argv[1] points to the shim, not this file. We check both:\n// direct execution AND being imported by the timber bin shim.\nconst isDirectExecution =\n typeof process !== 'undefined' &&\n process.argv[1] &&\n (import.meta.url.endsWith(process.argv[1]) ||\n process.argv[1].endsWith('bin/timber.mjs') ||\n process.argv[1].endsWith('bin/timber'));\n\nif (isDirectExecution) {\n main().catch((err) => {\n console.error(err.message);\n process.exit(1);\n });\n}\n"],"mappings":";;AAuBA,IAAM,WAAW;CAAC;CAAO;CAAS;CAAW;CAAS;CAAU;CAAQ;AAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA+C/E,SAAgB,UAAU,MAA4B;CACpD,IAAI,KAAK,WAAW,GAClB,MAAM,IAAI,MACR,kGACF;CAGF,MAAM,UAAU,KAAK;CACrB,IAAI,CAAC,SAAS,SAAS,OAAkB,GACvC,MAAM,IAAI,MAAM,oBAAoB,QAAQ,wBAA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,EAAE,CAAC,SAAS,YAAY,IAGvC,KAAK,CAAC,CAAC,OAAO,QAAQ;CACpB,QAAQ,MAAM,IAAI,OAAO;CACzB,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../src/client/error-boundary.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAc5F;;;;;;GAMG;AACH,QAAA,MAAM,mBAAmB,4CAAuC,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../src/client/error-boundary.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAc5F;;;;;;GAMG;AACH,QAAA,MAAM,mBAAmB,4CAAuC,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAoC/B,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,SAAS,CAAC;IACtD;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,UAAU,wBAAwB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAsBD,qBAAa,mBAAoB,SAAQ,SAAS,CAChD,wBAAwB,EACxB,wBAAwB,CACzB;IACC,YAAY,KAAK,EAAE,wBAAwB,EAG1C;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,wBAAwB,CAUtE;IAED,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAWpC;IAED,kBAAkB,CAAC,SAAS,EAAE,wBAAwB,GAAG,IAAI,CAO5D;IAED,mDAAmD;IACnD,OAAO,CAAC,KAAK,CAEX;IAEF,OAAgB,WAAW,6CAAuB;IAC1C,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAEnC,OAAO,KAAK,aAAa,GAMxB;IAED,MAAM,IAAI,SAAS,CAmJlB;IAED;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAyBtB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;CAIvB"}
|
package/dist/client/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { n as classifyUrlSegment } from "../_chunks/segment-classify-
|
|
3
|
-
import { c as stripRscCacheKey } from "../_chunks/rsc-cache-key-
|
|
4
|
-
import { a as mergePreservedSearchParams, i as validateNavigationHref, n as isInternalHref, o as resolveSegmentParams } from "../_chunks/href-validation-
|
|
5
|
-
import "../_chunks/param-value-
|
|
6
|
-
import { t as createGlobalContext } from "../_chunks/global-context-
|
|
7
|
-
import { i as getRouterOrNull, n as usePendingNavigation } from "../_chunks/navigation-root-
|
|
8
|
-
import { t as getSsrData } from "../_chunks/ssr-data-
|
|
9
|
-
import { t as getLinkCodec } from "../_chunks/codec-registry-
|
|
10
|
-
import { i as useNavigationContext, n as useSegmentContext } from "../_chunks/segment-context-
|
|
11
|
-
import { n as useQueryStates } from "../_chunks/use-query-states-
|
|
2
|
+
import { n as classifyUrlSegment } from "../_chunks/segment-classify-Ho8jXWeC.js";
|
|
3
|
+
import { c as stripRscCacheKey } from "../_chunks/rsc-cache-key-D0cb0Gmc.js";
|
|
4
|
+
import { a as mergePreservedSearchParams, i as validateNavigationHref, n as isInternalHref, o as resolveSegmentParams } from "../_chunks/href-validation-CEZy1V-k.js";
|
|
5
|
+
import "../_chunks/param-value-DqlGfF57.js";
|
|
6
|
+
import { t as createGlobalContext } from "../_chunks/global-context-DbxNWeBP.js";
|
|
7
|
+
import { i as getRouterOrNull, n as usePendingNavigation } from "../_chunks/navigation-root-M3B2ZrdO.js";
|
|
8
|
+
import { t as getSsrData } from "../_chunks/ssr-data-9hPtcNOr.js";
|
|
9
|
+
import { t as getLinkCodec } from "../_chunks/codec-registry-CPc6bjVl.js";
|
|
10
|
+
import { i as useNavigationContext, n as useSegmentContext } from "../_chunks/segment-context-CYiGTi3K.js";
|
|
11
|
+
import { n as useQueryStates } from "../_chunks/use-query-states-pkDV-jSg.js";
|
|
12
12
|
import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
13
13
|
import { flushSync } from "react-dom";
|
|
14
14
|
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
|
|
15
|
+
// src/client/use-link-status.ts
|
|
16
16
|
/**
|
|
17
17
|
* React context provided by <Link>. Holds the pending status
|
|
18
18
|
* for that specific link's navigation.
|
|
@@ -46,8 +46,7 @@ var LinkStatusContext = createContext({ isPending: false });
|
|
|
46
46
|
function useLinkStatus() {
|
|
47
47
|
return useContext(LinkStatusContext);
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
//#region src/client/location-search.ts
|
|
49
|
+
// src/client/location-search.ts
|
|
51
50
|
/**
|
|
52
51
|
* The app-visible search string from the address bar.
|
|
53
52
|
*
|
|
@@ -61,8 +60,7 @@ function useLinkStatus() {
|
|
|
61
60
|
function locationSearch() {
|
|
62
61
|
return stripRscCacheKey(window.location.search);
|
|
63
62
|
}
|
|
64
|
-
|
|
65
|
-
//#region src/client/link.tsx
|
|
63
|
+
// src/client/link.tsx
|
|
66
64
|
var LINK_PENDING = { isPending: true };
|
|
67
65
|
var LINK_IDLE = { isPending: false };
|
|
68
66
|
/**
|
|
@@ -317,8 +315,7 @@ var Link = function LinkImpl(props) {
|
|
|
317
315
|
})
|
|
318
316
|
});
|
|
319
317
|
};
|
|
320
|
-
|
|
321
|
-
//#region src/client/use-router.ts
|
|
318
|
+
// src/client/use-router.ts
|
|
322
319
|
/**
|
|
323
320
|
* useRouter() — client-side hook for programmatic navigation.
|
|
324
321
|
*
|
|
@@ -408,8 +405,7 @@ function useRouter() {
|
|
|
408
405
|
}
|
|
409
406
|
};
|
|
410
407
|
}
|
|
411
|
-
|
|
412
|
-
//#region src/client/use-pathname.ts
|
|
408
|
+
// src/client/use-pathname.ts
|
|
413
409
|
/**
|
|
414
410
|
* usePathname() — client-side hook for reading the current pathname.
|
|
415
411
|
*
|
|
@@ -442,8 +438,7 @@ function usePathname() {
|
|
|
442
438
|
if (nav === null) throw new Error("[timber] usePathname() was called outside the timber app tree (no NavigationProvider found). In tests, render the component inside the timber providers.");
|
|
443
439
|
return nav.pathname;
|
|
444
440
|
}
|
|
445
|
-
|
|
446
|
-
//#region src/client/navigation-api.ts
|
|
441
|
+
// src/client/navigation-api.ts
|
|
447
442
|
/**
|
|
448
443
|
* Returns true if the Navigation API is available in the current environment.
|
|
449
444
|
* Feature-detected at runtime — no polyfill.
|
|
@@ -458,8 +453,7 @@ function getNavigationApi() {
|
|
|
458
453
|
if (!hasNavigationApi()) return null;
|
|
459
454
|
return window.navigation;
|
|
460
455
|
}
|
|
461
|
-
|
|
462
|
-
//#region src/client/shallow-url.ts
|
|
456
|
+
// src/client/shallow-url.ts
|
|
463
457
|
/**
|
|
464
458
|
* Shallow URL replacement — update the browser URL bar without triggering
|
|
465
459
|
* RSC navigation, TopLoader, or any server round-trip.
|
|
@@ -476,8 +470,7 @@ function replaceUrl(url) {
|
|
|
476
470
|
});
|
|
477
471
|
else history.replaceState(history.state, "", url);
|
|
478
472
|
}
|
|
479
|
-
|
|
480
|
-
//#region src/client/use-selected-layout-segment.ts
|
|
473
|
+
// src/client/use-selected-layout-segment.ts
|
|
481
474
|
/**
|
|
482
475
|
* useSelectedLayoutSegment / useSelectedLayoutSegments — client-side hooks
|
|
483
476
|
* for reading the active segment(s) below the current layout.
|
|
@@ -564,8 +557,7 @@ function useSelectedLayoutSegments(parallelRouteKey) {
|
|
|
564
557
|
const pathname = usePathname();
|
|
565
558
|
return getSelectedSegments(context?.segments ?? null, pathname);
|
|
566
559
|
}
|
|
567
|
-
|
|
568
|
-
//#region src/client/form.tsx
|
|
560
|
+
// src/client/form.tsx
|
|
569
561
|
var EMPTY = Object.freeze({
|
|
570
562
|
field: () => null,
|
|
571
563
|
form: Object.freeze([]),
|
|
@@ -601,8 +593,7 @@ function readFormErrors(result) {
|
|
|
601
593
|
hasErrors
|
|
602
594
|
};
|
|
603
595
|
}
|
|
604
|
-
|
|
605
|
-
//#region src/client/use-field-state.ts
|
|
596
|
+
// src/client/use-field-state.ts
|
|
606
597
|
/**
|
|
607
598
|
* useFieldState — state for a form field that needs JavaScript (a combobox, a
|
|
608
599
|
* chip list, a row list), made to behave like a native uncontrolled input.
|
|
@@ -696,8 +687,7 @@ function useFieldState(defaultValue) {
|
|
|
696
687
|
ref
|
|
697
688
|
];
|
|
698
689
|
}
|
|
699
|
-
|
|
700
|
-
//#region src/client/params-context.ts
|
|
690
|
+
// src/client/params-context.ts
|
|
701
691
|
/**
|
|
702
692
|
* Segment params context — the one channel params use to reach the browser.
|
|
703
693
|
*
|
|
@@ -768,14 +758,12 @@ var ParamsContext = createGlobalContext(Symbol.for("__timber_params_ctx"), null)
|
|
|
768
758
|
function useParamsContext() {
|
|
769
759
|
return React.useContext(ParamsContext);
|
|
770
760
|
}
|
|
771
|
-
|
|
772
|
-
//#region src/client/use-segment-params.ts
|
|
761
|
+
// src/client/use-segment-params.ts
|
|
773
762
|
function useSegmentParams(segmentPath) {
|
|
774
763
|
const paramsContext = useParamsContext();
|
|
775
764
|
if (paramsContext === null) throw new Error("[timber] useSegmentParams() was called outside the timber app tree (no params provider found). In tests, render the component inside the timber providers.");
|
|
776
765
|
return resolveSegmentParams(paramsContext.params, paramsContext.slotParams, segmentPath);
|
|
777
766
|
}
|
|
778
|
-
//#endregion
|
|
779
767
|
export { Link, LinkStatusContext, buildLinkProps, interpolateParams, mergePreservedSearchParams, readFormErrors, replaceUrl, resolveHref, useFieldState, useLinkStatus, usePathname, usePendingNavigation, useQueryStates, useRouter, useSegmentParams, useSelectedLayoutSegment, useSelectedLayoutSegments, validateNavigationHref as validateLinkHref };
|
|
780
768
|
|
|
781
769
|
//# sourceMappingURL=index.js.map
|