@timber-js/app 0.2.0-alpha.21 → 0.2.0-alpha.211
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/LICENSE +8 -0
- package/agent-skill.md +346 -0
- package/bin/timber.mjs +15 -1
- package/dist/_chunks/actions-Rjk4htmA.js +1199 -0
- package/dist/_chunks/actions-Rjk4htmA.js.map +1 -0
- package/dist/_chunks/als-registry-DaxkVjt5.js +45 -0
- package/dist/_chunks/als-registry-DaxkVjt5.js.map +1 -0
- package/dist/_chunks/als-slots-BEEIPKYm.js +26 -0
- package/dist/_chunks/als-slots-BEEIPKYm.js.map +1 -0
- package/dist/_chunks/base-path-DaQrzbez.js +80 -0
- package/dist/_chunks/base-path-DaQrzbez.js.map +1 -0
- package/dist/_chunks/build-manifest-DWppEdLB.js +86 -0
- package/dist/_chunks/build-manifest-DWppEdLB.js.map +1 -0
- package/dist/_chunks/build-output-helper-RV_BRcF1.js +367 -0
- package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +1 -0
- package/dist/_chunks/cache-api-DGdYfNJn.js +1182 -0
- package/dist/_chunks/cache-api-DGdYfNJn.js.map +1 -0
- package/dist/_chunks/canonicalize-CgHoscYO.js +66 -0
- package/dist/_chunks/canonicalize-CgHoscYO.js.map +1 -0
- package/dist/_chunks/chains-DGX9zmg9.js +272 -0
- package/dist/_chunks/chains-DGX9zmg9.js.map +1 -0
- package/dist/_chunks/classify-QwG5rxKI.js +147 -0
- package/dist/_chunks/classify-QwG5rxKI.js.map +1 -0
- package/dist/_chunks/cli-check-ajNY3B2e.js +252 -0
- package/dist/_chunks/cli-check-ajNY3B2e.js.map +1 -0
- package/dist/_chunks/cli-context-By7k2xVo.js +70 -0
- package/dist/_chunks/cli-context-By7k2xVo.js.map +1 -0
- package/dist/_chunks/cli-schema-sync-D2eI8jEg.js +299 -0
- package/dist/_chunks/cli-schema-sync-D2eI8jEg.js.map +1 -0
- package/dist/_chunks/client-dep-entries-2HCF09no.js +66 -0
- package/dist/_chunks/client-dep-entries-2HCF09no.js.map +1 -0
- package/dist/_chunks/cloudflare-Byxl8FWP.js +1333 -0
- package/dist/_chunks/cloudflare-Byxl8FWP.js.map +1 -0
- package/dist/_chunks/codec-registry-oOUxugz3.js +21 -0
- package/dist/_chunks/codec-registry-oOUxugz3.js.map +1 -0
- package/dist/_chunks/codegen-Bps1sLKJ.js +432 -0
- package/dist/_chunks/codegen-Bps1sLKJ.js.map +1 -0
- package/dist/_chunks/convention-lint-DLmhGsRS.js +590 -0
- package/dist/_chunks/convention-lint-DLmhGsRS.js.map +1 -0
- package/dist/_chunks/dev-server-TFpEwm3H.js +2039 -0
- package/dist/_chunks/dev-server-TFpEwm3H.js.map +1 -0
- package/dist/_chunks/dist-DtrJyBbw.js +386 -0
- package/dist/_chunks/dist-DtrJyBbw.js.map +1 -0
- package/dist/_chunks/error-boundary-DsNScGRM.js +1024 -0
- package/dist/_chunks/error-boundary-DsNScGRM.js.map +1 -0
- package/dist/_chunks/fast-hash-C-tVYrLb.js +41 -0
- package/dist/_chunks/fast-hash-C-tVYrLb.js.map +1 -0
- package/dist/_chunks/format-BKclgVbk.js +14 -0
- package/dist/_chunks/format-BKclgVbk.js.map +1 -0
- package/dist/_chunks/fs-identity-BRKuL215.js +207 -0
- package/dist/_chunks/fs-identity-BRKuL215.js.map +1 -0
- package/dist/_chunks/graph-cache-CYiUS2aS.js +303 -0
- package/dist/_chunks/graph-cache-CYiUS2aS.js.map +1 -0
- package/dist/_chunks/href-validation-BIrxavIy.js +213 -0
- package/dist/_chunks/href-validation-BIrxavIy.js.map +1 -0
- package/dist/_chunks/json-lossy-check-CVuRs2hG.js +66 -0
- package/dist/_chunks/json-lossy-check-CVuRs2hG.js.map +1 -0
- package/dist/_chunks/live-graph-cNuWMYQI.js +151 -0
- package/dist/_chunks/live-graph-cNuWMYQI.js.map +1 -0
- package/dist/_chunks/logger-BP0LN6vP.js +662 -0
- package/dist/_chunks/logger-BP0LN6vP.js.map +1 -0
- package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-DSDjM_hJ.js} +71 -27
- package/dist/_chunks/metadata-routes-DSDjM_hJ.js.map +1 -0
- package/dist/_chunks/navigation-root-BQfo1-kG.js +126 -0
- package/dist/_chunks/navigation-root-BQfo1-kG.js.map +1 -0
- package/dist/_chunks/param-value-C8TNYchQ.js +66 -0
- package/dist/_chunks/param-value-C8TNYchQ.js.map +1 -0
- package/dist/_chunks/plugin-context-BPBPc3lL.js +345 -0
- package/dist/_chunks/plugin-context-BPBPc3lL.js.map +1 -0
- package/dist/_chunks/poison-rules-DoEhbqaY.js +110 -0
- package/dist/_chunks/poison-rules-DoEhbqaY.js.map +1 -0
- package/dist/_chunks/poison-scan-CfQ3unZR.js +99 -0
- package/dist/_chunks/poison-scan-CfQ3unZR.js.map +1 -0
- package/dist/_chunks/purge-store-Byr8XOjU.js +14 -0
- package/dist/_chunks/purge-store-Byr8XOjU.js.map +1 -0
- package/dist/_chunks/render-timeout-DOf_BBcO.js +46 -0
- package/dist/_chunks/render-timeout-DOf_BBcO.js.map +1 -0
- package/dist/_chunks/resolve-schema-CBR6Lm4i.js +50 -0
- package/dist/_chunks/resolve-schema-CBR6Lm4i.js.map +1 -0
- package/dist/_chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/_chunks/rsc-cache-key-ClUiXQnK.js +243 -0
- package/dist/_chunks/rsc-cache-key-ClUiXQnK.js.map +1 -0
- package/dist/_chunks/rsc-media-type-DDc7duTD.js +61 -0
- package/dist/_chunks/rsc-media-type-DDc7duTD.js.map +1 -0
- package/dist/_chunks/rsc-payload-path-dffcs4jp.js +54 -0
- package/dist/_chunks/rsc-payload-path-dffcs4jp.js.map +1 -0
- package/dist/_chunks/scan-BoP17W3w.js +140 -0
- package/dist/_chunks/scan-BoP17W3w.js.map +1 -0
- package/dist/_chunks/scanner-DmqdxzbW.js +2056 -0
- package/dist/_chunks/scanner-DmqdxzbW.js.map +1 -0
- package/dist/_chunks/schema-bridge-C83xa9lT.js +199 -0
- package/dist/_chunks/schema-bridge-C83xa9lT.js.map +1 -0
- package/dist/_chunks/segment-classify-C539Pa2O.js +197 -0
- package/dist/_chunks/segment-classify-C539Pa2O.js.map +1 -0
- package/dist/_chunks/segment-context-xtPUGfdq.js +137 -0
- package/dist/_chunks/segment-context-xtPUGfdq.js.map +1 -0
- package/dist/_chunks/segment-keys-D5hu1hz4.js +62 -0
- package/dist/_chunks/segment-keys-D5hu1hz4.js.map +1 -0
- package/dist/_chunks/singleflight-BeVMMKi0.js +55 -0
- package/dist/_chunks/singleflight-BeVMMKi0.js.map +1 -0
- package/dist/_chunks/sizeof-BM1409x2.js +36 -0
- package/dist/_chunks/sizeof-BM1409x2.js.map +1 -0
- package/dist/_chunks/ssr-data-nA3I70_n.js +49 -0
- package/dist/_chunks/ssr-data-nA3I70_n.js.map +1 -0
- package/dist/_chunks/state-BhNGPsdi.js +50 -0
- package/dist/_chunks/state-BhNGPsdi.js.map +1 -0
- package/dist/_chunks/status-page-marker-BRX9Ib-d.js +564 -0
- package/dist/_chunks/status-page-marker-BRX9Ib-d.js.map +1 -0
- package/dist/_chunks/tree-match-6yihorhk.js +169 -0
- package/dist/_chunks/tree-match-6yihorhk.js.map +1 -0
- package/dist/_chunks/use-query-states-I3JMng6J.js +226 -0
- package/dist/_chunks/use-query-states-I3JMng6J.js.map +1 -0
- package/dist/_chunks/walkers-Czu2jXFq.js +144 -0
- package/dist/_chunks/walkers-Czu2jXFq.js.map +1 -0
- package/dist/_chunks/write-file-atomic-D1qWqHb4.js +32 -0
- package/dist/_chunks/write-file-atomic-D1qWqHb4.js.map +1 -0
- package/dist/adapters/build-output-helper.d.ts +72 -0
- package/dist/adapters/build-output-helper.d.ts.map +1 -0
- package/dist/adapters/canonicalize-module.d.ts +8 -0
- package/dist/adapters/canonicalize-module.d.ts.map +1 -0
- package/dist/adapters/cloudflare-dev.d.ts +109 -0
- package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
- package/dist/adapters/cloudflare-dev.js +74 -0
- package/dist/adapters/cloudflare-dev.js.map +1 -0
- package/dist/adapters/cloudflare-kv-cache.d.ts +65 -0
- package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
- package/dist/adapters/cloudflare-kv-cache.js +123 -0
- package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
- package/dist/adapters/cloudflare.d.ts +224 -24
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +2 -188
- package/dist/adapters/compress-module.d.ts +25 -4
- package/dist/adapters/compress-module.d.ts.map +1 -1
- package/dist/adapters/fs-identity.d.ts +63 -0
- package/dist/adapters/fs-identity.d.ts.map +1 -0
- package/dist/adapters/nitro-presets.d.ts +31 -0
- package/dist/adapters/nitro-presets.d.ts.map +1 -0
- package/dist/adapters/nitro-preview.d.ts +64 -0
- package/dist/adapters/nitro-preview.d.ts.map +1 -0
- package/dist/adapters/nitro.d.ts +54 -37
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +631 -359
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/adapters/shared.d.ts +67 -0
- package/dist/adapters/shared.d.ts.map +1 -0
- package/dist/adapters/types.d.ts +122 -16
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js +0 -0
- package/dist/analyze/chains.d.ts +124 -0
- package/dist/analyze/chains.d.ts.map +1 -0
- package/dist/analyze/classify.d.ts +153 -0
- package/dist/analyze/classify.d.ts.map +1 -0
- package/dist/analyze/crawl-entry.d.ts +17 -0
- package/dist/analyze/crawl-entry.d.ts.map +1 -0
- package/dist/analyze/crawl-entry.js +314 -0
- package/dist/analyze/crawl-entry.js.map +1 -0
- package/dist/analyze/crawl.d.ts +134 -0
- package/dist/analyze/crawl.d.ts.map +1 -0
- package/dist/analyze/graph-cache.d.ts +104 -0
- package/dist/analyze/graph-cache.d.ts.map +1 -0
- package/dist/analyze/graph-command.d.ts +43 -0
- package/dist/analyze/graph-command.d.ts.map +1 -0
- package/dist/analyze/graph-command.js +472 -0
- package/dist/analyze/graph-command.js.map +1 -0
- package/dist/analyze/live-graph.d.ts +81 -0
- package/dist/analyze/live-graph.d.ts.map +1 -0
- package/dist/analyze/poison-rules.d.ts +72 -0
- package/dist/analyze/poison-rules.d.ts.map +1 -0
- package/dist/analyze/poison-scan.d.ts +48 -0
- package/dist/analyze/poison-scan.d.ts.map +1 -0
- package/dist/analyze/scan.d.ts +73 -0
- package/dist/analyze/scan.d.ts.map +1 -0
- package/dist/cache/cache-api.d.ts +48 -0
- package/dist/cache/cache-api.d.ts.map +1 -0
- package/dist/cache/fast-hash.d.ts +5 -0
- package/dist/cache/fast-hash.d.ts.map +1 -1
- package/dist/cache/handler-store.d.ts +33 -0
- package/dist/cache/handler-store.d.ts.map +1 -0
- package/dist/cache/index.d.ts +32 -9
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +3 -326
- package/dist/cache/invalidation-epoch.d.ts +43 -0
- package/dist/cache/invalidation-epoch.d.ts.map +1 -0
- package/dist/cache/json-lossy-check.d.ts +11 -0
- package/dist/cache/json-lossy-check.d.ts.map +1 -0
- package/dist/cache/redis-handler.d.ts +141 -9
- package/dist/cache/redis-handler.d.ts.map +1 -1
- package/dist/cache/singleflight.d.ts +21 -2
- package/dist/cache/singleflight.d.ts.map +1 -1
- package/dist/cache/sizeof.d.ts +22 -0
- package/dist/cache/sizeof.d.ts.map +1 -0
- package/dist/cache/stable-stringify.d.ts +9 -0
- package/dist/cache/stable-stringify.d.ts.map +1 -1
- package/dist/cache/store.d.ts +53 -0
- package/dist/cache/store.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.d.ts +38 -0
- package/dist/cache/stores/cloudflare-kv.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.js +29 -0
- package/dist/cache/stores/cloudflare-kv.js.map +1 -0
- package/dist/cache/stores/memory.d.ts +42 -0
- package/dist/cache/stores/memory.d.ts.map +1 -0
- package/dist/cache/stores/memory.js +90 -0
- package/dist/cache/stores/memory.js.map +1 -0
- package/dist/cache/stores/redis.d.ts +69 -0
- package/dist/cache/stores/redis.d.ts.map +1 -0
- package/dist/cache/stores/redis.js +35 -0
- package/dist/cache/stores/redis.js.map +1 -0
- package/dist/cache/stores/vercel.d.ts +36 -0
- package/dist/cache/stores/vercel.d.ts.map +1 -0
- package/dist/cache/stores/vercel.js +33 -0
- package/dist/cache/stores/vercel.js.map +1 -0
- package/dist/cache/tag-aware-handler.d.ts +52 -0
- package/dist/cache/tag-aware-handler.d.ts.map +1 -0
- package/dist/cache/timber-cache.d.ts +21 -11
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.d.ts +23 -0
- package/dist/cdn/cloudflare-purge.d.ts.map +1 -0
- package/dist/cdn/cloudflare-purge.js +30 -0
- package/dist/cdn/cloudflare-purge.js.map +1 -0
- package/dist/cdn/fastly-purge.d.ts +25 -0
- package/dist/cdn/fastly-purge.d.ts.map +1 -0
- package/dist/cdn/fastly-purge.js +33 -0
- package/dist/cdn/fastly-purge.js.map +1 -0
- package/dist/cdn/headers.d.ts +97 -0
- package/dist/cdn/headers.d.ts.map +1 -0
- package/dist/cdn/index.d.ts +5 -0
- package/dist/cdn/index.d.ts.map +1 -0
- package/dist/cdn/index.js +94 -0
- package/dist/cdn/index.js.map +1 -0
- package/dist/cdn/purge-store.d.ts +23 -0
- package/dist/cdn/purge-store.d.ts.map +1 -0
- package/dist/cdn/workers-cache-purge.d.ts +20 -0
- package/dist/cdn/workers-cache-purge.d.ts.map +1 -0
- package/dist/cdn/workers-cache-purge.js +35 -0
- package/dist/cdn/workers-cache-purge.js.map +1 -0
- package/dist/cli-check.d.ts +133 -0
- package/dist/cli-check.d.ts.map +1 -0
- package/dist/cli-context.d.ts +54 -0
- package/dist/cli-context.d.ts.map +1 -0
- package/dist/cli-schema-sync.d.ts +59 -0
- package/dist/cli-schema-sync.d.ts.map +1 -0
- package/dist/cli.d.ts +85 -13
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +224 -63
- package/dist/cli.js.map +1 -1
- package/dist/client/browser-dev.d.ts +42 -2
- package/dist/client/browser-dev.d.ts.map +1 -1
- package/dist/client/browser-entry/action-dispatch.d.ts +19 -0
- package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
- package/dist/client/browser-entry/action-queue.d.ts +63 -0
- package/dist/client/browser-entry/action-queue.d.ts.map +1 -0
- package/dist/client/browser-entry/hmr.d.ts +21 -0
- package/dist/client/browser-entry/hmr.d.ts.map +1 -0
- package/dist/client/browser-entry/hydrate.d.ts +53 -0
- package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
- package/dist/client/browser-entry/index.d.ts +30 -0
- package/dist/client/browser-entry/index.d.ts.map +1 -0
- package/dist/client/browser-entry/post-hydration.d.ts +26 -0
- package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
- package/dist/client/browser-entry/router-init.d.ts +41 -0
- package/dist/client/browser-entry/router-init.d.ts.map +1 -0
- package/dist/client/browser-entry/rsc-stream.d.ts +32 -0
- package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
- package/dist/client/browser-entry/scroll.d.ts +28 -0
- package/dist/client/browser-entry/scroll.d.ts.map +1 -0
- package/dist/client/deny-last-resort.d.ts +29 -0
- package/dist/client/deny-last-resort.d.ts.map +1 -0
- package/dist/client/error-boundary.d.ts +58 -9
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +2 -126
- package/dist/client/error-reconstituter.d.ts +55 -0
- package/dist/client/error-reconstituter.d.ts.map +1 -0
- package/dist/client/form.d.ts +16 -27
- package/dist/client/form.d.ts.map +1 -1
- package/dist/client/global-context.d.ts +15 -0
- package/dist/client/global-context.d.ts.map +1 -0
- package/dist/client/history.d.ts +50 -9
- package/dist/client/history.d.ts.map +1 -1
- package/dist/client/index.d.ts +20 -33
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +330 -1150
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.d.ts +20 -0
- package/dist/client/internal.d.ts.map +1 -0
- package/dist/client/internal.js +792 -0
- package/dist/client/internal.js.map +1 -0
- package/dist/client/link.d.ts +85 -60
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/location-search.d.ts +12 -0
- package/dist/client/location-search.d.ts.map +1 -0
- package/dist/client/navigation-api.d.ts +133 -0
- package/dist/client/navigation-api.d.ts.map +1 -0
- package/dist/client/navigation-commit.d.ts +111 -0
- package/dist/client/navigation-commit.d.ts.map +1 -0
- package/dist/client/navigation-context.d.ts +54 -36
- package/dist/client/navigation-context.d.ts.map +1 -1
- package/dist/client/navigation-root.d.ts +106 -0
- package/dist/client/navigation-root.d.ts.map +1 -0
- package/dist/client/navigation-transition.d.ts +192 -0
- package/dist/client/navigation-transition.d.ts.map +1 -0
- package/dist/client/nuqs-adapter.d.ts +1 -1
- package/dist/client/nuqs-adapter.d.ts.map +1 -1
- package/dist/client/params-context.d.ts +81 -0
- package/dist/client/params-context.d.ts.map +1 -0
- package/dist/client/react-root.d.ts +45 -0
- package/dist/client/react-root.d.ts.map +1 -0
- package/dist/client/router-effects.d.ts +137 -0
- package/dist/client/router-effects.d.ts.map +1 -0
- package/dist/client/router-lifecycle.d.ts +98 -0
- package/dist/client/router-lifecycle.d.ts.map +1 -0
- package/dist/client/router-pipeline.d.ts +84 -0
- package/dist/client/router-pipeline.d.ts.map +1 -0
- package/dist/client/router-ref.d.ts +2 -2
- package/dist/client/router-ref.d.ts.map +1 -1
- package/dist/client/router-skew.d.ts +21 -0
- package/dist/client/router-skew.d.ts.map +1 -0
- package/dist/client/router-types.d.ts +334 -0
- package/dist/client/router-types.d.ts.map +1 -0
- package/dist/client/router-url.d.ts +24 -0
- package/dist/client/router-url.d.ts.map +1 -0
- package/dist/client/router.d.ts +1 -97
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +110 -28
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +186 -25
- package/dist/client/segment-cache.d.ts.map +1 -1
- package/dist/client/segment-context.d.ts.map +1 -1
- package/dist/client/segment-outlet.d.ts +68 -0
- package/dist/client/segment-outlet.d.ts.map +1 -0
- package/dist/client/segment-update-context.d.ts +15 -0
- package/dist/client/segment-update-context.d.ts.map +1 -0
- package/dist/client/shallow-url.d.ts +10 -0
- package/dist/client/shallow-url.d.ts.map +1 -0
- package/dist/client/slot-content-cache-context.d.ts +35 -0
- package/dist/client/slot-content-cache-context.d.ts.map +1 -0
- package/dist/client/slot-context.d.ts +31 -0
- package/dist/client/slot-context.d.ts.map +1 -0
- package/dist/client/slot-outlet.d.ts +16 -0
- package/dist/client/slot-outlet.d.ts.map +1 -0
- package/dist/client/slot-provider.d.ts +25 -0
- package/dist/client/slot-provider.d.ts.map +1 -0
- package/dist/client/ssr-data.d.ts +26 -50
- package/dist/client/ssr-data.d.ts.map +1 -1
- package/dist/client/stale-client.d.ts +69 -0
- package/dist/client/stale-client.d.ts.map +1 -0
- package/dist/client/state.d.ts +21 -13
- package/dist/client/state.d.ts.map +1 -1
- package/dist/client/status-page-marker.d.ts +25 -0
- package/dist/client/status-page-marker.d.ts.map +1 -0
- package/dist/client/top-loader.d.ts +7 -6
- package/dist/client/top-loader.d.ts.map +1 -1
- package/dist/client/unload-guard.d.ts +5 -0
- package/dist/client/unload-guard.d.ts.map +1 -1
- package/dist/client/use-cookie.d.ts +12 -0
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/client/use-link-status.d.ts +5 -5
- package/dist/client/use-link-status.d.ts.map +1 -1
- package/dist/client/use-pathname.d.ts +13 -11
- package/dist/client/use-pathname.d.ts.map +1 -1
- package/dist/client/use-pending-navigation.d.ts +23 -0
- package/dist/client/use-pending-navigation.d.ts.map +1 -0
- package/dist/client/use-query-states.d.ts +10 -4
- package/dist/client/use-query-states.d.ts.map +1 -1
- package/dist/client/use-router.d.ts +15 -8
- package/dist/client/use-router.d.ts.map +1 -1
- package/dist/client/use-search-params.d.ts +15 -8
- package/dist/client/use-search-params.d.ts.map +1 -1
- package/dist/client/use-segment-params.d.ts +55 -0
- package/dist/client/use-segment-params.d.ts.map +1 -0
- package/dist/codec.d.ts +69 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +76 -0
- package/dist/codec.js.map +1 -0
- package/dist/config-types.d.ts +323 -0
- package/dist/config-types.d.ts.map +1 -0
- package/dist/config-validation.d.ts +68 -0
- package/dist/config-validation.d.ts.map +1 -0
- package/dist/cookies/define-cookie.d.ts +58 -25
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.d.ts +3 -2
- package/dist/cookies/index.d.ts.map +1 -1
- package/dist/cookies/index.js +256 -36
- package/dist/cookies/index.js.map +1 -1
- package/dist/cookies/json-cookie.d.ts +64 -0
- package/dist/cookies/json-cookie.d.ts.map +1 -0
- package/dist/cookies/validation.d.ts +34 -0
- package/dist/cookies/validation.d.ts.map +1 -0
- package/dist/dev-tools/404-page.d.ts +50 -0
- package/dist/dev-tools/404-page.d.ts.map +1 -0
- package/dist/dev-tools/browser-logs.d.ts +40 -0
- package/dist/dev-tools/browser-logs.d.ts.map +1 -0
- package/dist/dev-tools/dev-page-shell.d.ts +95 -0
- package/dist/dev-tools/dev-page-shell.d.ts.map +1 -0
- package/dist/dev-tools/error-page.d.ts +32 -0
- package/dist/dev-tools/error-page.d.ts.map +1 -0
- package/dist/dev-tools/holding-server.d.ts +46 -0
- package/dist/dev-tools/holding-server.d.ts.map +1 -0
- package/dist/dev-tools/hydration-overlay.d.ts +11 -0
- package/dist/dev-tools/hydration-overlay.d.ts.map +1 -0
- package/dist/dev-tools/index.d.ts +31 -0
- package/dist/dev-tools/index.d.ts.map +1 -0
- package/dist/dev-tools/instrumentation.d.ts +74 -0
- package/dist/dev-tools/instrumentation.d.ts.map +1 -0
- package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
- package/dist/dev-tools/logger.d.ts.map +1 -0
- package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +17 -3
- package/dist/dev-tools/logs.d.ts.map +1 -0
- package/dist/{plugins/dev-error-overlay.d.ts → dev-tools/overlay.d.ts} +15 -25
- package/dist/dev-tools/overlay.d.ts.map +1 -0
- package/dist/dev-tools/stack-classifier.d.ts +34 -0
- package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
- package/dist/dev-tools/terminal.d.ts +28 -0
- package/dist/dev-tools/terminal.d.ts.map +1 -0
- package/dist/fonts/ast-walk.d.ts +68 -0
- package/dist/fonts/ast-walk.d.ts.map +1 -0
- package/dist/fonts/ast.d.ts +112 -8
- package/dist/fonts/ast.d.ts.map +1 -1
- package/dist/fonts/bundle.d.ts +50 -0
- package/dist/fonts/bundle.d.ts.map +1 -0
- package/dist/fonts/css.d.ts +1 -1
- package/dist/fonts/dev-middleware.d.ts +22 -0
- package/dist/fonts/dev-middleware.d.ts.map +1 -0
- package/dist/fonts/fallbacks.d.ts +0 -7
- package/dist/fonts/fallbacks.d.ts.map +1 -1
- package/dist/fonts/google.d.ts +5 -3
- package/dist/fonts/google.d.ts.map +1 -1
- package/dist/fonts/local.d.ts +5 -5
- package/dist/fonts/local.d.ts.map +1 -1
- package/dist/fonts/paths.d.ts +43 -0
- package/dist/fonts/paths.d.ts.map +1 -0
- package/dist/fonts/pipeline.d.ts +177 -0
- package/dist/fonts/pipeline.d.ts.map +1 -0
- package/dist/fonts/transform.d.ts +82 -0
- package/dist/fonts/transform.d.ts.map +1 -0
- package/dist/fonts/types.d.ts +47 -1
- package/dist/fonts/types.d.ts.map +1 -1
- package/dist/fonts/virtual-modules.d.ts +77 -0
- package/dist/fonts/virtual-modules.d.ts.map +1 -0
- package/dist/index.d.ts +35 -181
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8871 -14233
- package/dist/index.js.map +1 -1
- package/dist/params/codec-registry.d.ts +26 -0
- package/dist/params/codec-registry.d.ts.map +1 -0
- package/dist/params/define-schema.d.ts +81 -0
- package/dist/params/define-schema.d.ts.map +1 -0
- package/dist/params/index.d.ts +5 -0
- package/dist/params/index.d.ts.map +1 -0
- package/dist/params/index.js +34 -0
- package/dist/params/index.js.map +1 -0
- package/dist/params/resolve-schema.d.ts +34 -0
- package/dist/params/resolve-schema.d.ts.map +1 -0
- package/dist/plugin-context.d.ts +262 -0
- package/dist/plugin-context.d.ts.map +1 -0
- package/dist/plugins/build-manifest.d.ts +7 -3
- package/dist/plugins/build-manifest.d.ts.map +1 -1
- package/dist/plugins/build-report.d.ts +61 -11
- package/dist/plugins/build-report.d.ts.map +1 -1
- package/dist/plugins/cache.d.ts +64 -0
- package/dist/plugins/cache.d.ts.map +1 -0
- package/dist/plugins/callsite-ast.d.ts +117 -0
- package/dist/plugins/callsite-ast.d.ts.map +1 -0
- package/dist/plugins/callsite-jsx.d.ts +35 -0
- package/dist/plugins/callsite-jsx.d.ts.map +1 -0
- package/dist/plugins/chunks.d.ts +11 -4
- package/dist/plugins/chunks.d.ts.map +1 -1
- package/dist/plugins/client-chunks.d.ts +40 -0
- package/dist/plugins/client-chunks.d.ts.map +1 -0
- package/dist/plugins/client-dep-entries.d.ts +44 -0
- package/dist/plugins/client-dep-entries.d.ts.map +1 -0
- package/dist/plugins/cloudflare-wasm.d.ts +21 -0
- package/dist/plugins/cloudflare-wasm.d.ts.map +1 -0
- package/dist/plugins/content.d.ts +1 -1
- package/dist/plugins/content.d.ts.map +1 -1
- package/dist/plugins/dev-discovery.d.ts +123 -0
- package/dist/plugins/dev-discovery.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +24 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts +34 -4
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/fonts.d.ts +35 -74
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/graph-endpoint.d.ts +112 -0
- package/dist/plugins/graph-endpoint.d.ts.map +1 -0
- package/dist/plugins/mdx.d.ts +18 -5
- package/dist/plugins/mdx.d.ts.map +1 -1
- package/dist/plugins/post-build.d.ts +110 -0
- package/dist/plugins/post-build.d.ts.map +1 -0
- package/dist/plugins/prebuilt-capture.d.ts +67 -0
- package/dist/plugins/prebuilt-capture.d.ts.map +1 -0
- package/dist/plugins/prebuilt-options-analysis.d.ts +40 -0
- package/dist/plugins/prebuilt-options-analysis.d.ts.map +1 -0
- package/dist/plugins/prebuilt.d.ts +98 -0
- package/dist/plugins/prebuilt.d.ts.map +1 -0
- package/dist/plugins/prerender-sugar.d.ts +39 -0
- package/dist/plugins/prerender-sugar.d.ts.map +1 -0
- package/dist/plugins/react-resolve.d.ts +49 -0
- package/dist/plugins/react-resolve.d.ts.map +1 -0
- package/dist/plugins/request-dep/analysis.d.ts +106 -0
- package/dist/plugins/request-dep/analysis.d.ts.map +1 -0
- package/dist/plugins/request-dep/index.d.ts +75 -0
- package/dist/plugins/request-dep/index.d.ts.map +1 -0
- package/dist/plugins/request-dep/origin.d.ts +61 -0
- package/dist/plugins/request-dep/origin.d.ts.map +1 -0
- package/dist/plugins/routing.d.ts +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/plugins/rsc-assets-manifest.d.ts +33 -0
- package/dist/plugins/rsc-assets-manifest.d.ts.map +1 -0
- package/dist/plugins/server-bundle.d.ts.map +1 -1
- package/dist/plugins/shims.d.ts +29 -5
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts +246 -26
- package/dist/plugins/static-build.d.ts.map +1 -1
- package/dist/routing/codegen-shared.d.ts +26 -0
- package/dist/routing/codegen-shared.d.ts.map +1 -0
- package/dist/routing/codegen-types.d.ts +61 -0
- package/dist/routing/codegen-types.d.ts.map +1 -0
- package/dist/routing/codegen-write.d.ts +42 -0
- package/dist/routing/codegen-write.d.ts.map +1 -0
- package/dist/routing/codegen.d.ts +8 -3
- package/dist/routing/codegen.d.ts.map +1 -1
- package/dist/routing/collision-probe.d.ts +104 -0
- package/dist/routing/collision-probe.d.ts.map +1 -0
- package/dist/routing/collision-spaces.d.ts +26 -0
- package/dist/routing/collision-spaces.d.ts.map +1 -0
- package/dist/routing/convention-lint.d.ts +55 -0
- package/dist/routing/convention-lint.d.ts.map +1 -0
- package/dist/routing/export-detect.d.ts +91 -0
- package/dist/routing/export-detect.d.ts.map +1 -0
- package/dist/routing/file-cache.d.ts +8 -0
- package/dist/routing/file-cache.d.ts.map +1 -0
- package/dist/routing/index.d.ts +13 -7
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +5 -2
- package/dist/routing/interception-overlap.d.ts +35 -0
- package/dist/routing/interception-overlap.d.ts.map +1 -0
- package/dist/routing/interception.d.ts +234 -10
- package/dist/routing/interception.d.ts.map +1 -1
- package/dist/routing/link-codegen.d.ts +105 -0
- package/dist/routing/link-codegen.d.ts.map +1 -0
- package/dist/routing/manifest-codegen.d.ts +26 -0
- package/dist/routing/manifest-codegen.d.ts.map +1 -0
- package/dist/routing/scanner.d.ts +14 -10
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/routing/schema-validation.d.ts +35 -0
- package/dist/routing/schema-validation.d.ts.map +1 -0
- package/dist/routing/segment-classify.d.ts +114 -0
- package/dist/routing/segment-classify.d.ts.map +1 -0
- package/dist/routing/segment-codegen.d.ts +38 -0
- package/dist/routing/segment-codegen.d.ts.map +1 -0
- package/dist/routing/segment-keys.d.ts +118 -0
- package/dist/routing/segment-keys.d.ts.map +1 -0
- package/dist/routing/slot-placement.d.ts +48 -0
- package/dist/routing/slot-placement.d.ts.map +1 -0
- package/dist/routing/types.d.ts +81 -26
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/routing/walkers.d.ts +57 -0
- package/dist/routing/walkers.d.ts.map +1 -0
- package/dist/rsc-runtime/rsc.d.ts +1 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/ssr.d.ts +14 -0
- package/dist/rsc-runtime/ssr.d.ts.map +1 -1
- package/dist/rsc-runtime/transforms.d.ts +13 -0
- package/dist/rsc-runtime/transforms.d.ts.map +1 -0
- package/dist/schema-bridge.d.ts +145 -0
- package/dist/schema-bridge.d.ts.map +1 -0
- package/dist/search-params/define.d.ts +262 -0
- package/dist/search-params/define.d.ts.map +1 -0
- package/dist/search-params/index.d.ts +3 -7
- package/dist/search-params/index.d.ts.map +1 -1
- package/dist/search-params/index.js +179 -360
- package/dist/search-params/index.js.map +1 -1
- package/dist/search-params/parse-total.d.ts +81 -0
- package/dist/search-params/parse-total.d.ts.map +1 -0
- package/dist/search-params/serialize-equal.d.ts +9 -0
- package/dist/search-params/serialize-equal.d.ts.map +1 -0
- package/dist/search-params/wrappers.d.ts +76 -0
- package/dist/search-params/wrappers.d.ts.map +1 -0
- package/dist/server/access-gate.d.ts +98 -10
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/action-client.d.ts +44 -9
- package/dist/server/action-client.d.ts.map +1 -1
- package/dist/server/action-encryption.d.ts +76 -0
- package/dist/server/action-encryption.d.ts.map +1 -0
- package/dist/server/action-handler.d.ts +40 -5
- package/dist/server/action-handler.d.ts.map +1 -1
- package/dist/server/actions.d.ts +78 -40
- package/dist/server/actions.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +166 -16
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/body-limits.d.ts.map +1 -1
- package/dist/server/build-manifest.d.ts +25 -30
- package/dist/server/build-manifest.d.ts.map +1 -1
- package/dist/server/canonicalize.d.ts +10 -0
- package/dist/server/canonicalize.d.ts.map +1 -1
- package/dist/server/chain-url-parts.d.ts +82 -0
- package/dist/server/chain-url-parts.d.ts.map +1 -0
- package/dist/server/children-interception.d.ts +49 -0
- package/dist/server/children-interception.d.ts.map +1 -0
- package/dist/server/coalesce-tick.d.ts +40 -0
- package/dist/server/coalesce-tick.d.ts.map +1 -0
- package/dist/server/compress.d.ts.map +1 -1
- package/dist/server/cookie-context.d.ts +149 -0
- package/dist/server/cookie-context.d.ts.map +1 -0
- package/dist/server/cookie-parsing.d.ts +65 -0
- package/dist/server/cookie-parsing.d.ts.map +1 -0
- package/dist/server/csp-nonce.d.ts +36 -0
- package/dist/server/csp-nonce.d.ts.map +1 -0
- package/dist/server/csrf.d.ts +58 -15
- package/dist/server/csrf.d.ts.map +1 -1
- package/dist/server/debug.d.ts +0 -1
- package/dist/server/debug.d.ts.map +1 -1
- package/dist/server/default-logger.d.ts +23 -0
- package/dist/server/default-logger.d.ts.map +1 -0
- package/dist/server/default-status-page.d.ts +45 -0
- package/dist/server/default-status-page.d.ts.map +1 -0
- package/dist/server/deny-boundary.d.ts +257 -0
- package/dist/server/deny-boundary.d.ts.map +1 -0
- package/dist/server/deny-renderer.d.ts +21 -15
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/early-hints-sender.d.ts.map +1 -1
- package/dist/server/early-hints.d.ts +14 -12
- package/dist/server/early-hints.d.ts.map +1 -1
- package/dist/server/error-boundary-wrapper.d.ts +102 -10
- package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
- package/dist/server/error-response-headers.d.ts +3 -0
- package/dist/server/error-response-headers.d.ts.map +1 -0
- package/dist/server/fallback-error.d.ts +19 -7
- package/dist/server/fallback-error.d.ts.map +1 -1
- package/dist/server/flight-injection-state.d.ts +66 -0
- package/dist/server/flight-injection-state.d.ts.map +1 -0
- package/dist/server/flight-scripts.d.ts +45 -0
- package/dist/server/flight-scripts.d.ts.map +1 -0
- package/dist/server/form-data.d.ts +41 -0
- package/dist/server/form-data.d.ts.map +1 -1
- package/dist/server/form-flash.d.ts +2 -2
- package/dist/server/head-response.d.ts +35 -0
- package/dist/server/head-response.d.ts.map +1 -0
- package/dist/server/html-injector-core.d.ts +257 -0
- package/dist/server/html-injector-core.d.ts.map +1 -0
- package/dist/server/html-injectors.d.ts +84 -42
- package/dist/server/html-injectors.d.ts.map +1 -1
- package/dist/server/index.d.ts +17 -54
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +195 -2922
- package/dist/server/index.js.map +1 -1
- package/dist/server/instrumentation.d.ts +11 -4
- package/dist/server/instrumentation.d.ts.map +1 -1
- package/dist/server/internal.d.ts +47 -0
- package/dist/server/internal.d.ts.map +1 -0
- package/dist/server/internal.js +4645 -0
- package/dist/server/internal.js.map +1 -0
- package/dist/server/json-status-response.d.ts +34 -0
- package/dist/server/json-status-response.d.ts.map +1 -0
- package/dist/server/logger.d.ts +78 -7
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/metadata-collector.d.ts +73 -0
- package/dist/server/metadata-collector.d.ts.map +1 -0
- package/dist/server/metadata-platform.d.ts +2 -2
- package/dist/server/metadata-render.d.ts +2 -2
- package/dist/server/metadata-render.d.ts.map +1 -1
- package/dist/server/metadata-routes.d.ts +71 -11
- package/dist/server/metadata-routes.d.ts.map +1 -1
- package/dist/server/metadata-social.d.ts +2 -2
- package/dist/server/metadata.d.ts +10 -2
- package/dist/server/metadata.d.ts.map +1 -1
- package/dist/server/middleware-runner.d.ts +20 -5
- package/dist/server/middleware-runner.d.ts.map +1 -1
- package/dist/server/node-stream-transforms.d.ts +105 -0
- package/dist/server/node-stream-transforms.d.ts.map +1 -0
- package/dist/server/nuqs-ssr-provider.d.ts +7 -3
- package/dist/server/nuqs-ssr-provider.d.ts.map +1 -1
- package/dist/server/param-coercion.d.ts +83 -0
- package/dist/server/param-coercion.d.ts.map +1 -0
- package/dist/server/pipeline-helpers.d.ts +193 -0
- package/dist/server/pipeline-helpers.d.ts.map +1 -0
- package/dist/server/pipeline-interception.d.ts +70 -9
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline-metadata.d.ts +7 -1
- package/dist/server/pipeline-metadata.d.ts.map +1 -1
- package/dist/server/pipeline-outcome.d.ts +59 -0
- package/dist/server/pipeline-outcome.d.ts.map +1 -0
- package/dist/server/pipeline-phases.d.ts +70 -0
- package/dist/server/pipeline-phases.d.ts.map +1 -0
- package/dist/server/pipeline.d.ts +147 -23
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/port-resolution.d.ts +31 -0
- package/dist/server/port-resolution.d.ts.map +1 -0
- package/dist/server/prebuilt/cache-key.d.ts +63 -0
- package/dist/server/prebuilt/cache-key.d.ts.map +1 -0
- package/dist/server/prebuilt/capture-render.d.ts +25 -0
- package/dist/server/prebuilt/capture-render.d.ts.map +1 -0
- package/dist/server/prebuilt/capture-routes.d.ts +37 -0
- package/dist/server/prebuilt/capture-routes.d.ts.map +1 -0
- package/dist/server/prebuilt/capture-state.d.ts +101 -0
- package/dist/server/prebuilt/capture-state.d.ts.map +1 -0
- package/dist/server/prebuilt/key-discipline.d.ts +52 -0
- package/dist/server/prebuilt/key-discipline.d.ts.map +1 -0
- package/dist/server/prebuilt/lifetime.d.ts +38 -0
- package/dist/server/prebuilt/lifetime.d.ts.map +1 -0
- package/dist/server/prebuilt/manifest-tag-index.d.ts +27 -0
- package/dist/server/prebuilt/manifest-tag-index.d.ts.map +1 -0
- package/dist/server/prebuilt/overlay.d.ts +100 -0
- package/dist/server/prebuilt/overlay.d.ts.map +1 -0
- package/dist/server/prebuilt/payload-source.d.ts +79 -0
- package/dist/server/prebuilt/payload-source.d.ts.map +1 -0
- package/dist/server/prebuilt/slots.d.ts +106 -0
- package/dist/server/prebuilt/slots.d.ts.map +1 -0
- package/dist/server/prebuilt/synthetic-store.d.ts +67 -0
- package/dist/server/prebuilt/synthetic-store.d.ts.map +1 -0
- package/dist/server/prebuilt-builder.d.ts +121 -0
- package/dist/server/prebuilt-builder.d.ts.map +1 -0
- package/dist/server/prebuilt-runtime.d.ts +111 -0
- package/dist/server/prebuilt-runtime.d.ts.map +1 -0
- package/dist/server/primitives.d.ts +101 -90
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/publish-params.d.ts +33 -0
- package/dist/server/publish-params.d.ts.map +1 -0
- package/dist/server/react-cache-bridge.d.ts +59 -0
- package/dist/server/react-cache-bridge.d.ts.map +1 -0
- package/dist/server/react-cache-scope.d.ts +49 -0
- package/dist/server/react-cache-scope.d.ts.map +1 -0
- package/dist/server/render-timeout.d.ts +66 -0
- package/dist/server/render-timeout.d.ts.map +1 -0
- package/dist/server/render-utils.d.ts +35 -0
- package/dist/server/render-utils.d.ts.map +1 -0
- package/dist/server/request-context.d.ts +128 -103
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-dep.d.ts +15 -0
- package/dist/server/request-dep.d.ts.map +1 -0
- package/dist/server/response-cache-policy.d.ts +3 -0
- package/dist/server/response-cache-policy.d.ts.map +1 -0
- package/dist/server/route-element-builder.d.ts +57 -30
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-element-helpers.d.ts +12 -0
- package/dist/server/route-element-helpers.d.ts.map +1 -0
- package/dist/server/route-handler.d.ts +1 -1
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +55 -38
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/route-module-loader.d.ts +37 -0
- package/dist/server/route-module-loader.d.ts.map +1 -0
- package/dist/server/rsc-cache-key-guard.d.ts +78 -0
- package/dist/server/rsc-cache-key-guard.d.ts.map +1 -0
- package/dist/server/rsc-entry/action-dispatcher.d.ts +67 -0
- package/dist/server/rsc-entry/action-dispatcher.d.ts.map +1 -0
- package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
- package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
- package/dist/server/rsc-entry/api-handler.d.ts +19 -3
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/deny-fallback.d.ts +55 -0
- package/dist/server/rsc-entry/deny-fallback.d.ts.map +1 -0
- package/dist/server/rsc-entry/error-renderer.d.ts +35 -21
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +14 -59
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts +30 -6
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts +50 -0
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
- package/dist/server/rsc-entry/render-signals.d.ts +65 -0
- package/dist/server/rsc-entry/render-signals.d.ts.map +1 -0
- package/dist/server/rsc-entry/revalidate-renderer.d.ts +98 -0
- package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -0
- package/dist/server/rsc-entry/rsc-payload.d.ts +30 -6
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +12 -30
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-bridge.d.ts +6 -2
- package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +44 -7
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/rsc-error-envelope.d.ts +11 -0
- package/dist/server/rsc-error-envelope.d.ts.map +1 -0
- package/dist/server/safe-load.d.ts +39 -0
- package/dist/server/safe-load.d.ts.map +1 -0
- package/dist/server/sensitive-fields.d.ts +74 -0
- package/dist/server/sensitive-fields.d.ts.map +1 -0
- package/dist/server/signal-identity.d.ts +43 -0
- package/dist/server/signal-identity.d.ts.map +1 -0
- package/dist/server/sitemap-generator.d.ts +130 -0
- package/dist/server/sitemap-generator.d.ts.map +1 -0
- package/dist/server/sitemap-handler.d.ts +22 -0
- package/dist/server/sitemap-handler.d.ts.map +1 -0
- package/dist/server/skippable-prefix.d.ts +29 -0
- package/dist/server/skippable-prefix.d.ts.map +1 -0
- package/dist/server/slot-interception.d.ts +80 -0
- package/dist/server/slot-interception.d.ts.map +1 -0
- package/dist/server/slot-resolver.d.ts +138 -7
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/slot-subtree-contain.d.ts +54 -0
- package/dist/server/slot-subtree-contain.d.ts.map +1 -0
- package/dist/server/ssr-bridge-types.d.ts +198 -0
- package/dist/server/ssr-bridge-types.d.ts.map +1 -0
- package/dist/server/ssr-entry.d.ts +8 -47
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/server/ssr-render.d.ts +60 -27
- package/dist/server/ssr-render.d.ts.map +1 -1
- package/dist/server/ssr-wrappers.d.ts +93 -0
- package/dist/server/ssr-wrappers.d.ts.map +1 -0
- package/dist/server/state-tree-diff.d.ts +44 -9
- package/dist/server/state-tree-diff.d.ts.map +1 -1
- package/dist/server/static-generator.d.ts +112 -0
- package/dist/server/static-generator.d.ts.map +1 -0
- package/dist/server/static-not-found.d.ts +52 -0
- package/dist/server/static-not-found.d.ts.map +1 -0
- package/dist/server/status-code-resolver.d.ts +26 -15
- package/dist/server/status-code-resolver.d.ts.map +1 -1
- package/dist/server/stream-utils.d.ts +59 -0
- package/dist/server/stream-utils.d.ts.map +1 -0
- package/dist/server/tracing.d.ts +57 -26
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/tree-match.d.ts +59 -0
- package/dist/server/tree-match.d.ts.map +1 -0
- package/dist/server/types.d.ts +89 -8
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/utils/element-type.d.ts +50 -0
- package/dist/server/utils/element-type.d.ts.map +1 -0
- package/dist/server/utils/escape-html.d.ts +14 -0
- package/dist/server/utils/escape-html.d.ts.map +1 -0
- package/dist/server/version-skew.d.ts +61 -0
- package/dist/server/version-skew.d.ts.map +1 -0
- package/dist/server/workers-cache-bridge.d.ts +26 -0
- package/dist/server/workers-cache-bridge.d.ts.map +1 -0
- package/dist/shared/als-slots.d.ts +42 -0
- package/dist/shared/als-slots.d.ts.map +1 -0
- package/dist/shared/base-path.d.ts +56 -0
- package/dist/shared/base-path.d.ts.map +1 -0
- package/dist/shared/csrf-reject.d.ts +16 -0
- package/dist/shared/csrf-reject.d.ts.map +1 -0
- package/dist/shared/error-digest.d.ts +28 -0
- package/dist/shared/error-digest.d.ts.map +1 -0
- package/dist/shared/href-validation.d.ts +49 -0
- package/dist/shared/href-validation.d.ts.map +1 -0
- package/dist/shared/merge-search-params.d.ts +22 -0
- package/dist/shared/merge-search-params.d.ts.map +1 -0
- package/dist/shared/param-value.d.ts +104 -0
- package/dist/shared/param-value.d.ts.map +1 -0
- package/dist/shared/payload-root.d.ts +110 -0
- package/dist/shared/payload-root.d.ts.map +1 -0
- package/dist/shared/redirect-type.d.ts +17 -0
- package/dist/shared/redirect-type.d.ts.map +1 -0
- package/dist/shared/rsc-cache-key.d.ts +163 -0
- package/dist/shared/rsc-cache-key.d.ts.map +1 -0
- package/dist/shared/rsc-error-envelope.d.ts +16 -0
- package/dist/shared/rsc-error-envelope.d.ts.map +1 -0
- package/dist/shared/rsc-manifest.d.ts +28 -0
- package/dist/shared/rsc-manifest.d.ts.map +1 -0
- package/dist/shared/rsc-media-type.d.ts +52 -0
- package/dist/shared/rsc-media-type.d.ts.map +1 -0
- package/dist/shared/rsc-payload-path.d.ts +48 -0
- package/dist/shared/rsc-payload-path.d.ts.map +1 -0
- package/dist/shared/segment-info.d.ts +66 -0
- package/dist/shared/segment-info.d.ts.map +1 -0
- package/dist/shared/slot-params.d.ts +52 -0
- package/dist/shared/slot-params.d.ts.map +1 -0
- package/dist/shared/static-platform-files.d.ts +71 -0
- package/dist/shared/static-platform-files.d.ts.map +1 -0
- package/dist/shared/status-reason-phrase.d.ts +26 -0
- package/dist/shared/status-reason-phrase.d.ts.map +1 -0
- package/dist/shims/font-google.d.ts +1 -1
- package/dist/shims/font-google.d.ts.map +1 -1
- package/dist/shims/font-google.js +42 -0
- package/dist/shims/font-google.js.map +1 -0
- package/dist/shims/font-local.d.ts +26 -0
- package/dist/shims/font-local.d.ts.map +1 -0
- package/dist/shims/font-local.js +20 -0
- package/dist/shims/font-local.js.map +1 -0
- package/dist/shims/headers.d.ts +53 -1
- package/dist/shims/headers.d.ts.map +1 -1
- package/dist/shims/image.d.ts +120 -120
- package/dist/shims/image.d.ts.map +1 -1
- package/dist/shims/navigation-client.d.ts +25 -12
- package/dist/shims/navigation-client.d.ts.map +1 -1
- package/dist/shims/navigation-rsc.d.ts +21 -0
- package/dist/shims/navigation-rsc.d.ts.map +1 -0
- package/dist/shims/navigation.d.ts +10 -5
- package/dist/shims/navigation.d.ts.map +1 -1
- package/dist/utils/state-machine.d.ts +80 -0
- package/dist/utils/state-machine.d.ts.map +1 -0
- package/dist/utils/write-file-atomic.d.ts +17 -0
- package/dist/utils/write-file-atomic.d.ts.map +1 -0
- package/docs/api/30-api-server.mdx +239 -0
- package/docs/api/31-api-client.mdx +170 -0
- package/docs/api/32-api-cache.mdx +339 -0
- package/docs/api/33-api-search-params.mdx +176 -0
- package/docs/api/34-api-config.mdx +359 -0
- package/docs/api/35-api-typescript.mdx +91 -0
- package/docs/api/36-cli.mdx +202 -0
- package/docs/learn/00-introduction.mdx +109 -0
- package/docs/learn/01-quick-start.mdx +94 -0
- package/docs/learn/02-pages-and-layouts.mdx +147 -0
- package/docs/learn/03-fetching-data.mdx +227 -0
- package/docs/learn/04-access-control.mdx +115 -0
- package/docs/learn/05-the-flush-point.mdx +175 -0
- package/docs/learn/06-typed-params.mdx +275 -0
- package/docs/learn/07-typed-routes.mdx +108 -0
- package/docs/learn/08-forms-and-actions.mdx +146 -0
- package/docs/learn/09-streaming.mdx +140 -0
- package/docs/learn/10-caching.mdx +270 -0
- package/docs/learn/11-middleware.mdx +164 -0
- package/docs/learn/12-error-handling.mdx +192 -0
- package/docs/learn/13-deploying.mdx +287 -0
- package/llms.txt +55 -0
- package/package.json +120 -29
- package/src/adapters/build-output-helper.ts +353 -0
- package/src/adapters/canonicalize-module.ts +29 -0
- package/src/adapters/cloudflare-dev.ts +183 -0
- package/src/adapters/cloudflare-kv-cache.ts +207 -0
- package/src/adapters/cloudflare.ts +809 -150
- package/src/adapters/compress-module.ts +110 -86
- package/src/adapters/fs-identity.ts +155 -0
- package/src/adapters/nitro-presets.ts +124 -0
- package/src/adapters/nitro-preview.ts +476 -0
- package/src/adapters/nitro.ts +317 -457
- package/src/adapters/raw-imports.d.ts +5 -0
- package/src/adapters/shared.ts +283 -0
- package/src/adapters/types.ts +127 -17
- package/src/adapters/wrangler.d.ts +7 -0
- package/src/analyze/chains.ts +411 -0
- package/src/analyze/classify.ts +259 -0
- package/src/analyze/crawl-entry.ts +68 -0
- package/src/analyze/crawl.ts +500 -0
- package/src/analyze/graph-cache.ts +331 -0
- package/src/analyze/graph-command.ts +762 -0
- package/src/analyze/live-graph.ts +232 -0
- package/src/analyze/poison-rules.ts +165 -0
- package/src/analyze/poison-scan.ts +159 -0
- package/src/analyze/scan.ts +149 -0
- package/src/cache/cache-api.ts +107 -0
- package/src/cache/fast-hash.ts +5 -0
- package/src/cache/handler-store.ts +76 -0
- package/src/cache/index.ts +115 -22
- package/src/cache/invalidation-epoch.ts +93 -0
- package/src/cache/json-lossy-check.ts +69 -0
- package/src/cache/redis-handler.ts +198 -20
- package/src/cache/singleflight.ts +72 -6
- package/src/cache/sizeof.ts +35 -0
- package/src/cache/stable-stringify.ts +65 -2
- package/src/cache/store.ts +71 -0
- package/src/cache/stores/cloudflare-kv.ts +52 -0
- package/src/cache/stores/memory.ts +125 -0
- package/src/cache/stores/redis.ts +97 -0
- package/src/cache/stores/vercel.ts +59 -0
- package/src/cache/tag-aware-handler.ts +254 -0
- package/src/cache/timber-cache.ts +165 -40
- package/src/cdn/cloudflare-purge.ts +50 -0
- package/src/cdn/fastly-purge.ts +63 -0
- package/src/cdn/headers.ts +153 -0
- package/src/cdn/index.ts +23 -0
- package/src/cdn/purge-store.ts +34 -0
- package/src/cdn/workers-cache-purge.ts +34 -0
- package/src/cli-check.ts +417 -0
- package/src/cli-context.ts +119 -0
- package/src/cli-schema-sync.ts +401 -0
- package/src/cli.ts +330 -78
- package/src/client/browser-dev.ts +192 -5
- package/src/client/browser-entry/action-dispatch.ts +237 -0
- package/src/client/browser-entry/action-queue.ts +152 -0
- package/src/client/browser-entry/hmr.ts +70 -0
- package/src/client/browser-entry/hydrate.ts +143 -0
- package/src/client/browser-entry/index.ts +120 -0
- package/src/client/browser-entry/post-hydration.ts +99 -0
- package/src/client/browser-entry/router-init.ts +406 -0
- package/src/client/browser-entry/rsc-stream.ts +145 -0
- package/src/client/browser-entry/scroll.ts +50 -0
- package/src/client/deny-last-resort.tsx +54 -0
- package/src/client/error-boundary.tsx +279 -61
- package/src/client/error-reconstituter.tsx +84 -0
- package/src/client/form.tsx +36 -32
- package/src/client/global-context.ts +31 -0
- package/src/client/history.ts +74 -11
- package/src/client/index.ts +89 -53
- package/src/client/internal.ts +54 -0
- package/src/client/link.tsx +468 -151
- package/src/client/location-search.ts +15 -0
- package/src/client/navigation-api.ts +380 -0
- package/src/client/navigation-commit.ts +318 -0
- package/src/client/navigation-context.ts +67 -134
- package/src/client/navigation-root.tsx +236 -0
- package/src/client/navigation-transition.ts +337 -0
- package/src/client/nuqs-adapter.tsx +21 -9
- package/src/client/params-context.ts +187 -0
- package/src/client/react-root.ts +82 -0
- package/src/client/router-effects.ts +235 -0
- package/src/client/router-lifecycle.ts +354 -0
- package/src/client/router-pipeline.ts +458 -0
- package/src/client/router-ref.ts +3 -3
- package/src/client/router-skew.ts +30 -0
- package/src/client/router-types.ts +370 -0
- package/src/client/router-url.ts +32 -0
- package/src/client/router.ts +491 -424
- package/src/client/rsc-fetch.ts +510 -109
- package/src/client/segment-cache.ts +362 -41
- package/src/client/segment-context.ts +7 -4
- package/src/client/segment-outlet.tsx +96 -0
- package/src/client/segment-update-context.ts +23 -0
- package/src/client/shallow-url.ts +22 -0
- package/src/client/slot-content-cache-context.ts +43 -0
- package/src/client/slot-context.ts +50 -0
- package/src/client/slot-outlet.tsx +22 -0
- package/src/client/slot-provider.tsx +32 -0
- package/src/client/ssr-data.ts +27 -67
- package/src/client/stale-client.ts +191 -0
- package/src/client/state.ts +31 -24
- package/src/client/status-page-marker.tsx +32 -0
- package/src/client/top-loader.tsx +13 -10
- package/src/client/unload-guard.ts +35 -3
- package/src/client/use-cookie.ts +70 -18
- package/src/client/use-link-status.ts +7 -7
- package/src/client/use-pathname.ts +22 -31
- package/src/client/use-pending-navigation.ts +40 -0
- package/src/client/use-query-states.ts +206 -36
- package/src/client/use-router.ts +31 -9
- package/src/client/use-search-params.ts +38 -49
- package/src/client/use-segment-params.ts +69 -0
- package/src/client/use-selected-layout-segment.ts +2 -2
- package/src/codec.ts +149 -0
- package/src/config-types.ts +323 -0
- package/src/config-validation.ts +464 -0
- package/src/cookies/define-cookie.ts +222 -53
- package/src/cookies/index.ts +13 -2
- package/src/cookies/json-cookie.ts +105 -0
- package/src/cookies/validation.ts +192 -0
- package/src/dev-tools/404-page.ts +286 -0
- package/src/dev-tools/browser-logs.ts +55 -0
- package/src/dev-tools/dev-page-shell.ts +278 -0
- package/src/dev-tools/error-page.ts +331 -0
- package/src/dev-tools/holding-server.ts +185 -0
- package/src/dev-tools/hydration-overlay.ts +158 -0
- package/src/dev-tools/index.ts +79 -0
- package/src/dev-tools/instrumentation.ts +261 -0
- package/src/{server/dev-logger.ts → dev-tools/logger.ts} +33 -51
- package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +122 -26
- package/src/{plugins/dev-error-overlay.ts → dev-tools/overlay.ts} +25 -80
- package/src/dev-tools/stack-classifier.ts +75 -0
- package/src/dev-tools/terminal.ts +182 -0
- package/src/fonts/ast-walk.ts +235 -0
- package/src/fonts/ast.ts +479 -128
- package/src/fonts/bundle.ts +138 -0
- package/src/fonts/css.ts +1 -1
- package/src/fonts/dev-middleware.ts +85 -0
- package/src/fonts/fallbacks.ts +0 -23
- package/src/fonts/google.ts +101 -19
- package/src/fonts/local.ts +12 -11
- package/src/fonts/paths.ts +58 -0
- package/src/fonts/pipeline.ts +348 -0
- package/src/fonts/transform.ts +311 -0
- package/src/fonts/types.ts +52 -1
- package/src/fonts/virtual-modules.ts +179 -0
- package/src/index.ts +513 -380
- package/src/params/codec-registry.ts +34 -0
- package/src/params/define-schema.ts +115 -0
- package/src/params/index.ts +17 -0
- package/src/params/resolve-schema.ts +84 -0
- package/src/plugin-context.ts +502 -0
- package/src/plugins/build-manifest.ts +204 -36
- package/src/plugins/build-report.ts +299 -87
- package/src/plugins/cache.ts +243 -0
- package/src/plugins/callsite-ast.ts +472 -0
- package/src/plugins/callsite-jsx.ts +243 -0
- package/src/plugins/chunks.ts +74 -5
- package/src/plugins/client-chunks.ts +185 -0
- package/src/plugins/client-dep-entries.ts +78 -0
- package/src/plugins/cloudflare-wasm.ts +141 -0
- package/src/plugins/content.ts +31 -2
- package/src/plugins/dev-discovery.ts +218 -0
- package/src/plugins/dev-server.ts +360 -97
- package/src/plugins/entries.ts +149 -16
- package/src/plugins/fonts.ts +260 -657
- package/src/plugins/graph-endpoint.ts +532 -0
- package/src/plugins/mdx.ts +108 -35
- package/src/plugins/post-build.ts +327 -0
- package/src/plugins/prebuilt-capture.ts +213 -0
- package/src/plugins/prebuilt-options-analysis.ts +175 -0
- package/src/plugins/prebuilt.ts +670 -0
- package/src/plugins/prerender-sugar.ts +316 -0
- package/src/plugins/react-resolve.ts +149 -0
- package/src/plugins/request-dep/analysis.ts +447 -0
- package/src/plugins/request-dep/index.ts +376 -0
- package/src/plugins/request-dep/origin.ts +310 -0
- package/src/plugins/routing.ts +273 -277
- package/src/plugins/rsc-assets-manifest.ts +251 -0
- package/src/plugins/server-bundle.ts +99 -14
- package/src/plugins/shims.ts +260 -97
- package/src/plugins/static-build.ts +681 -71
- package/src/react-canary.d.ts +2 -0
- package/src/routing/codegen-shared.ts +39 -0
- package/src/routing/codegen-types.ts +62 -0
- package/src/routing/codegen-write.ts +163 -0
- package/src/routing/codegen.ts +349 -232
- package/src/routing/collision-probe.ts +438 -0
- package/src/routing/collision-spaces.ts +281 -0
- package/src/routing/convention-lint.ts +651 -0
- package/src/routing/export-detect.ts +536 -0
- package/src/routing/file-cache.ts +23 -0
- package/src/routing/index.ts +16 -7
- package/src/routing/interception-overlap.ts +141 -0
- package/src/routing/interception.ts +1044 -67
- package/src/routing/link-codegen.ts +280 -0
- package/src/routing/manifest-codegen.ts +232 -0
- package/src/routing/scanner.ts +417 -223
- package/src/routing/schema-validation.ts +155 -0
- package/src/routing/segment-classify.ts +280 -0
- package/src/routing/segment-codegen.ts +99 -0
- package/src/routing/segment-keys.ts +186 -0
- package/src/routing/slot-placement.ts +97 -0
- package/src/routing/types.ts +82 -26
- package/src/routing/walkers.ts +98 -0
- package/src/rsc-runtime/rsc.ts +9 -0
- package/src/rsc-runtime/ssr.ts +51 -0
- package/src/rsc-runtime/transforms.ts +13 -0
- package/src/rsc-runtime/vendor-types.d.ts +27 -0
- package/src/schema-bridge.ts +382 -0
- package/src/search-params/define.ts +677 -0
- package/src/search-params/index.ts +14 -20
- package/src/search-params/parse-total.ts +91 -0
- package/src/search-params/serialize-equal.ts +14 -0
- package/src/search-params/wrappers.ts +150 -0
- package/src/server/access-gate.tsx +195 -56
- package/src/server/action-client.ts +126 -33
- package/src/server/action-encryption.ts +144 -0
- package/src/server/action-handler.ts +457 -111
- package/src/server/actions.ts +172 -85
- package/src/server/als-registry.ts +224 -25
- package/src/server/body-limits.ts +10 -2
- package/src/server/build-manifest.ts +33 -57
- package/src/server/canonicalize.ts +6 -3
- package/src/server/chain-url-parts.ts +163 -0
- package/src/server/children-interception.ts +116 -0
- package/src/server/coalesce-tick.ts +75 -0
- package/src/server/compress.ts +43 -8
- package/src/server/cookie-context.ts +454 -0
- package/src/server/cookie-parsing.ts +163 -0
- package/src/server/csp-nonce.ts +58 -0
- package/src/server/csrf.ts +228 -35
- package/src/server/debug.ts +0 -1
- package/src/server/default-logger.ts +100 -0
- package/src/server/default-status-page.ts +88 -0
- package/src/server/deny-boundary.ts +527 -0
- package/src/server/deny-renderer.ts +201 -179
- package/src/server/early-hints-sender.ts +4 -3
- package/src/server/early-hints.ts +39 -29
- package/src/server/error-boundary-wrapper.ts +160 -44
- package/src/server/error-response-headers.ts +18 -0
- package/src/server/fallback-error.ts +88 -104
- package/src/server/flight-injection-state.ts +113 -0
- package/src/server/flight-scripts.ts +67 -0
- package/src/server/form-data.ts +124 -12
- package/src/server/form-flash.ts +3 -3
- package/src/server/head-response.ts +54 -0
- package/src/server/html-injector-core.ts +512 -0
- package/src/server/html-injectors.ts +270 -255
- package/src/server/index.ts +36 -192
- package/src/server/instrumentation.ts +11 -4
- package/src/server/internal.ts +168 -0
- package/src/server/json-status-response.ts +105 -0
- package/src/server/logger.ts +126 -38
- package/src/server/metadata-collector.ts +177 -0
- package/src/server/metadata-platform.ts +2 -2
- package/src/server/metadata-render.ts +30 -8
- package/src/server/metadata-routes.ts +220 -24
- package/src/server/metadata-social.ts +2 -2
- package/src/server/metadata.ts +23 -2
- package/src/server/middleware-runner.ts +32 -5
- package/src/server/node-stream-transforms.ts +323 -0
- package/src/server/nuqs-ssr-provider.tsx +8 -7
- package/src/server/param-coercion.ts +201 -0
- package/src/server/pipeline-helpers.ts +485 -0
- package/src/server/pipeline-interception.ts +241 -32
- package/src/server/pipeline-metadata.ts +15 -1
- package/src/server/pipeline-outcome.ts +290 -0
- package/src/server/pipeline-phases.ts +496 -0
- package/src/server/pipeline.ts +385 -427
- package/src/server/port-resolution.ts +53 -0
- package/src/server/prebuilt/cache-key.ts +299 -0
- package/src/server/prebuilt/capture-render.ts +118 -0
- package/src/server/prebuilt/capture-routes.ts +104 -0
- package/src/server/prebuilt/capture-state.ts +196 -0
- package/src/server/prebuilt/key-discipline.ts +122 -0
- package/src/server/prebuilt/lifetime.ts +151 -0
- package/src/server/prebuilt/manifest-tag-index.ts +46 -0
- package/src/server/prebuilt/overlay.ts +256 -0
- package/src/server/prebuilt/payload-source.ts +202 -0
- package/src/server/prebuilt/slots.ts +202 -0
- package/src/server/prebuilt/synthetic-store.ts +125 -0
- package/src/server/prebuilt-builder.ts +514 -0
- package/src/server/prebuilt-runtime.ts +813 -0
- package/src/server/primitives.ts +153 -171
- package/src/server/publish-params.ts +42 -0
- package/src/server/react-cache-bridge.ts +124 -0
- package/src/server/react-cache-scope.ts +104 -0
- package/src/server/render-timeout.ts +128 -0
- package/src/server/render-utils.ts +45 -0
- package/src/server/request-context.ts +269 -332
- package/src/server/request-dep.ts +37 -0
- package/src/server/response-cache-policy.ts +45 -0
- package/src/server/route-element-builder.ts +514 -355
- package/src/server/route-element-helpers.ts +37 -0
- package/src/server/route-handler.ts +67 -27
- package/src/server/route-matcher.ts +238 -267
- package/src/server/route-module-loader.ts +161 -0
- package/src/server/rsc-cache-key-guard.ts +122 -0
- package/src/server/rsc-entry/action-dispatcher.ts +142 -0
- package/src/server/rsc-entry/action-middleware-runner.ts +130 -0
- package/src/server/rsc-entry/api-handler.ts +49 -81
- package/src/server/rsc-entry/deny-fallback.ts +151 -0
- package/src/server/rsc-entry/error-renderer.ts +301 -113
- package/src/server/rsc-entry/helpers.ts +90 -115
- package/src/server/rsc-entry/index.ts +370 -350
- package/src/server/rsc-entry/render-route.ts +229 -0
- package/src/server/rsc-entry/render-signals.ts +108 -0
- package/src/server/rsc-entry/revalidate-renderer.ts +349 -0
- package/src/server/rsc-entry/rsc-payload.ts +192 -72
- package/src/server/rsc-entry/rsc-stream.ts +128 -131
- package/src/server/rsc-entry/ssr-bridge.ts +19 -6
- package/src/server/rsc-entry/ssr-renderer.ts +300 -137
- package/src/server/rsc-error-envelope.ts +18 -0
- package/src/server/rsc-prop-warnings.ts +1 -1
- package/src/server/safe-load.ts +53 -0
- package/src/server/sensitive-fields.ts +230 -0
- package/src/server/server-only-guard-noop.js +3 -0
- package/src/server/server-timing.ts +1 -1
- package/src/server/signal-identity.ts +112 -0
- package/src/server/sitemap-generator.ts +337 -0
- package/src/server/sitemap-handler.ts +157 -0
- package/src/server/skippable-prefix.ts +172 -0
- package/src/server/slot-interception.ts +168 -0
- package/src/server/slot-resolver.ts +707 -300
- package/src/server/slot-subtree-contain.ts +273 -0
- package/src/server/ssr-bridge-types.ts +201 -0
- package/src/server/ssr-entry.ts +225 -104
- package/src/server/ssr-render.ts +354 -91
- package/src/server/ssr-wrappers.tsx +162 -0
- package/src/server/state-tree-diff.ts +85 -30
- package/src/server/static-generator.ts +680 -0
- package/src/server/static-not-found.ts +134 -0
- package/src/server/status-code-resolver.ts +107 -148
- package/src/server/stream-utils.ts +343 -0
- package/src/server/tracing.ts +163 -68
- package/src/server/tree-match.ts +494 -0
- package/src/server/types.ts +96 -11
- package/src/server/utils/element-type.ts +88 -0
- package/src/server/utils/escape-html.ts +20 -0
- package/src/server/version-skew.ts +104 -0
- package/src/server/waituntil-bridge.ts +1 -1
- package/src/server/workers-cache-bridge.ts +33 -0
- package/src/shared/als-slots.ts +74 -0
- package/src/shared/base-path.ts +80 -0
- package/src/shared/csrf-reject.ts +15 -0
- package/src/shared/error-digest.ts +46 -0
- package/src/shared/href-validation.ts +159 -0
- package/src/shared/merge-search-params.ts +55 -0
- package/src/shared/param-value.ts +281 -0
- package/src/shared/payload-root.ts +153 -0
- package/src/shared/redirect-type.ts +17 -0
- package/src/shared/rsc-cache-key.ts +269 -0
- package/src/shared/rsc-error-envelope.ts +16 -0
- package/src/shared/rsc-manifest.ts +29 -0
- package/src/shared/rsc-media-type.ts +59 -0
- package/src/shared/rsc-payload-path.ts +52 -0
- package/src/shared/segment-info.ts +67 -0
- package/src/shared/slot-params.ts +109 -0
- package/src/shared/static-platform-files.ts +75 -0
- package/src/shared/status-reason-phrase.ts +61 -0
- package/src/shims/font-google.ts +1 -1
- package/src/shims/font-local.ts +34 -0
- package/src/shims/headers.ts +122 -1
- package/src/shims/navigation-client.ts +36 -32
- package/src/shims/navigation-rsc.ts +47 -0
- package/src/shims/navigation.ts +10 -7
- package/src/utils/state-machine.ts +111 -0
- package/src/utils/write-file-atomic.ts +32 -0
- package/dist/_chunks/als-registry-B7DbZ2hS.js +0 -41
- package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
- package/dist/_chunks/debug-B3Gypr3D.js +0 -108
- package/dist/_chunks/debug-B3Gypr3D.js.map +0 -1
- package/dist/_chunks/format-RyoGQL74.js +0 -164
- package/dist/_chunks/format-RyoGQL74.js.map +0 -1
- package/dist/_chunks/interception-BOoWmLUA.js +0 -676
- package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
- package/dist/_chunks/metadata-routes-Cjmvi3rQ.js.map +0 -1
- package/dist/_chunks/request-context-BQUC8PHn.js +0 -330
- package/dist/_chunks/request-context-BQUC8PHn.js.map +0 -1
- package/dist/_chunks/ssr-data-MjmprTmO.js +0 -88
- package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
- package/dist/_chunks/tracing-CemImE6h.js +0 -187
- package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
- package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
- package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
- package/dist/_chunks/use-query-states-D5KaffOK.js +0 -109
- package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
- package/dist/adapters/cloudflare.js.map +0 -1
- package/dist/cache/index.js.map +0 -1
- package/dist/cache/register-cached-function.d.ts +0 -17
- package/dist/cache/register-cached-function.d.ts.map +0 -1
- package/dist/client/browser-entry.d.ts +0 -21
- package/dist/client/browser-entry.d.ts.map +0 -1
- package/dist/client/error-boundary.js.map +0 -1
- package/dist/client/head.d.ts +0 -16
- package/dist/client/head.d.ts.map +0 -1
- package/dist/client/link-status-provider.d.ts +0 -11
- package/dist/client/link-status-provider.d.ts.map +0 -1
- package/dist/client/segment-merger.d.ts +0 -119
- package/dist/client/segment-merger.d.ts.map +0 -1
- package/dist/client/stale-reload.d.ts +0 -44
- package/dist/client/stale-reload.d.ts.map +0 -1
- package/dist/client/transition-root.d.ts +0 -74
- package/dist/client/transition-root.d.ts.map +0 -1
- package/dist/client/types.d.ts +0 -14
- package/dist/client/types.d.ts.map +0 -1
- package/dist/client/use-navigation-pending.d.ts +0 -26
- package/dist/client/use-navigation-pending.d.ts.map +0 -1
- package/dist/client/use-params.d.ts +0 -92
- package/dist/client/use-params.d.ts.map +0 -1
- package/dist/content/index.d.ts +0 -11
- package/dist/content/index.d.ts.map +0 -1
- package/dist/content/index.js +0 -2
- package/dist/plugins/adapter-build.d.ts +0 -18
- package/dist/plugins/adapter-build.d.ts.map +0 -1
- package/dist/plugins/cache-transform.d.ts +0 -36
- package/dist/plugins/cache-transform.d.ts.map +0 -1
- package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
- package/dist/plugins/dev-logs.d.ts.map +0 -1
- package/dist/plugins/dynamic-transform.d.ts +0 -72
- package/dist/plugins/dynamic-transform.d.ts.map +0 -1
- package/dist/plugins/server-action-exports.d.ts +0 -26
- package/dist/plugins/server-action-exports.d.ts.map +0 -1
- package/dist/routing/status-file-lint.d.ts +0 -33
- package/dist/routing/status-file-lint.d.ts.map +0 -1
- package/dist/search-params/analyze.d.ts +0 -54
- package/dist/search-params/analyze.d.ts.map +0 -1
- package/dist/search-params/builtin-codecs.d.ts +0 -105
- package/dist/search-params/builtin-codecs.d.ts.map +0 -1
- package/dist/search-params/codecs.d.ts +0 -53
- package/dist/search-params/codecs.d.ts.map +0 -1
- package/dist/search-params/create.d.ts +0 -106
- package/dist/search-params/create.d.ts.map +0 -1
- package/dist/search-params/registry.d.ts +0 -20
- package/dist/search-params/registry.d.ts.map +0 -1
- package/dist/server/asset-headers.d.ts +0 -42
- package/dist/server/asset-headers.d.ts.map +0 -1
- package/dist/server/client-module-map.d.ts +0 -47
- package/dist/server/client-module-map.d.ts.map +0 -1
- package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
- package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
- package/dist/server/dev-logger.d.ts.map +0 -1
- package/dist/server/dev-span-processor.d.ts +0 -29
- package/dist/server/dev-span-processor.d.ts.map +0 -1
- package/dist/server/dev-warnings.d.ts +0 -129
- package/dist/server/dev-warnings.d.ts.map +0 -1
- package/dist/server/flush.d.ts +0 -74
- package/dist/server/flush.d.ts.map +0 -1
- package/dist/server/manifest-status-resolver.d.ts +0 -58
- package/dist/server/manifest-status-resolver.d.ts.map +0 -1
- package/dist/server/prerender.d.ts +0 -77
- package/dist/server/prerender.d.ts.map +0 -1
- package/dist/server/tree-builder.d.ts +0 -126
- package/dist/server/tree-builder.d.ts.map +0 -1
- package/dist/utils/directive-parser.d.ts +0 -70
- package/dist/utils/directive-parser.d.ts.map +0 -1
- package/src/cache/register-cached-function.ts +0 -103
- package/src/client/browser-entry.ts +0 -678
- package/src/client/head.ts +0 -61
- package/src/client/link-status-provider.tsx +0 -30
- package/src/client/segment-merger.ts +0 -339
- package/src/client/stale-reload.ts +0 -87
- package/src/client/transition-root.tsx +0 -166
- package/src/client/types.ts +0 -21
- package/src/client/use-navigation-pending.ts +0 -38
- package/src/client/use-params.ts +0 -141
- package/src/content/index.ts +0 -13
- package/src/plugins/adapter-build.ts +0 -118
- package/src/plugins/cache-transform.ts +0 -199
- package/src/plugins/dynamic-transform.ts +0 -161
- package/src/plugins/server-action-exports.ts +0 -220
- package/src/routing/status-file-lint.ts +0 -112
- package/src/search-params/analyze.ts +0 -192
- package/src/search-params/builtin-codecs.ts +0 -228
- package/src/search-params/codecs.ts +0 -153
- package/src/search-params/create.ts +0 -321
- package/src/search-params/registry.ts +0 -31
- package/src/server/asset-headers.ts +0 -81
- package/src/server/client-module-map.ts +0 -58
- package/src/server/dev-fetch-instrumentation.ts +0 -96
- package/src/server/dev-span-processor.ts +0 -78
- package/src/server/dev-warnings.ts +0 -283
- package/src/server/flush.ts +0 -182
- package/src/server/manifest-status-resolver.ts +0 -215
- package/src/server/prerender.ts +0 -139
- package/src/server/tree-builder.ts +0 -382
- package/src/shims/server-only-noop.js +0 -6
- package/src/utils/directive-parser.ts +0 -529
package/dist/adapters/nitro.js
CHANGED
|
@@ -1,110 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as RSC_CONTENT_TYPE } from "../_chunks/rsc-media-type-DDc7duTD.js";
|
|
2
|
+
import { a as STATIC_CACHE, i as IMMUTABLE_CACHE, n as runSharedBuildSteps, o as adapterBase, r as writeHeadersFile, t as buildStaticDirectoryOutput } from "../_chunks/build-output-helper-RV_BRcF1.js";
|
|
3
|
+
import { transformWithOxc } from "vite";
|
|
4
|
+
import { basename, dirname, join, relative, sep } from "node:path";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { cp, glob, readFile, writeFile } from "node:fs/promises";
|
|
3
7
|
import { execFile } from "node:child_process";
|
|
8
|
+
//#region src/server/compress.ts?raw
|
|
9
|
+
var compress_default = "// Response compression for self-hosted deployments (dev server, Nitro preview).\n//\n// Uses CompressionStream (Web Platform API) for gzip. Brotli is intentionally\n// left to CDNs and reverse proxies — at streaming-friendly quality levels its\n// ratio advantage is marginal, and node:zlib's brotli transform buffers output\n// internally, breaking streaming. Cloudflare Workers auto-compress at the edge —\n// this module is only used on Node.js/Bun.\n//\n// See design/25-production-deployments.md.\n//\n// This module is also emitted standalone as `_compress.mjs` by\n// `adapters/compress-module.ts`, which strips types but does not bundle. Its\n// imports must therefore be interpolated there — a new import that is not\n// fails the build with an explanatory error rather than resolving to nothing\n// on the deployed server.\n\nimport { RSC_CONTENT_TYPE } from '../shared/rsc-media-type.ts';\n\n// ─── Constants ────────────────────────────────────────────────────────────\n\n/**\n * MIME types that benefit from compression.\n * text/* is handled via prefix matching; these are the specific\n * application/* and image/* types that are compressible.\n */\nexport const COMPRESSIBLE_TYPES = new Set([\n 'text/html',\n 'text/css',\n 'text/plain',\n 'text/xml',\n 'text/javascript',\n RSC_CONTENT_TYPE,\n 'application/json',\n 'application/javascript',\n 'application/xml',\n 'application/xhtml+xml',\n 'application/rss+xml',\n 'application/atom+xml',\n 'image/svg+xml',\n]);\n\n/**\n * Status codes that should never be compressed (no body or special semantics).\n */\nconst NO_COMPRESS_STATUSES = new Set([204, 304]);\n\n// ─── Encoding Negotiation ─────────────────────────────────────────────────\n\n/**\n * Parse Accept-Encoding and return the best supported encoding.\n * Returns 'gzip' if the client accepts it, null otherwise.\n *\n * Brotli (br) is intentionally not handled at the application level.\n * At the streaming-friendly quality levels (0–4), brotli's compression\n * ratio advantage over gzip is marginal, and node:zlib's brotli transform\n * buffers output internally — turning smooth streaming responses into\n * large infrequent bursts. Brotli's real wins come from offline/static\n * compression at higher quality levels (5–11), which CDNs and reverse\n * proxies (Cloudflare, nginx, Caddy) apply on cached responses.\n *\n * See design/25-production-deployments.md.\n */\nexport function negotiateEncoding(acceptEncoding: string): 'gzip' | null {\n if (!acceptEncoding) return null;\n\n // Parse tokens with quality values from the Accept-Encoding header.\n // Per RFC 9110 §12.5.3, q=0 means \"not acceptable\" — the client explicitly\n // rejects that encoding. Tokens without a q-value default to q=1.\n // e.g. \"gzip;q=1.0, br;q=0\" → gzip is acceptable, br is rejected.\n const parts = acceptEncoding.split(',');\n for (const part of parts) {\n const [token, ...params] = part.split(';');\n const name = token.trim().toLowerCase();\n if (name !== 'gzip') continue;\n\n // Check for q=0 (explicitly disabled)\n let qValue = 1; // default quality is 1\n for (const param of params) {\n const trimmed = param.trim().toLowerCase();\n if (trimmed.startsWith('q=')) {\n qValue = parseFloat(trimmed.slice(2));\n if (Number.isNaN(qValue)) qValue = 1;\n break;\n }\n }\n\n if (qValue > 0) return 'gzip';\n }\n\n return null;\n}\n\n// ─── Compressibility Check ────────────────────────────────────────────────\n\n/**\n * Determine if a response should be compressed.\n *\n * Returns false for:\n * - Responses without a body (204, 304, null body)\n * - Already-encoded responses (Content-Encoding set)\n * - Non-compressible content types (images, binary)\n * - SSE streams (text/event-stream — must not be buffered)\n */\nexport function shouldCompress(response: Response): boolean {\n // No body to compress\n if (!response.body) return false;\n if (NO_COMPRESS_STATUSES.has(response.status)) return false;\n\n // Already compressed\n if (response.headers.has('Content-Encoding')) return false;\n\n // Check content type\n const contentType = response.headers.get('Content-Type');\n if (!contentType) return false;\n\n // Extract the MIME type (strip charset and other parameters)\n const mimeType = contentType.split(';')[0].trim().toLowerCase();\n\n // SSE must not be compressed — it relies on chunk-by-chunk delivery\n if (mimeType === 'text/event-stream') return false;\n\n return COMPRESSIBLE_TYPES.has(mimeType);\n}\n\n// ─── Compression ──────────────────────────────────────────────────────────\n\n/**\n * Compress a Web Response if the client supports it and the content is compressible.\n *\n * Returns the original response unchanged if compression is not applicable.\n * Returns a new Response with the compressed body, Content-Encoding, and Vary headers.\n *\n * The body is piped through a compression stream — no buffering of the full response.\n * This preserves streaming behavior for HTML shell + deferred Suspense chunks.\n */\nexport function compressResponse(request: Request, response: Response): Response {\n // Check if response is compressible\n if (!shouldCompress(response)) return response;\n\n // Negotiate encoding with the client\n const acceptEncoding = request.headers.get('Accept-Encoding') ?? '';\n const encoding = negotiateEncoding(acceptEncoding);\n if (!encoding) return response;\n\n // Compress the body stream with gzip via the Web Platform CompressionStream API.\n const compressedBody = compressWithGzip(response.body!);\n\n // Build new headers: copy originals, add compression headers, remove Content-Length\n // (compressed size is unknown until streaming completes).\n const headers = new Headers(response.headers);\n headers.set('Content-Encoding', encoding);\n headers.delete('Content-Length');\n\n // Append to Vary header (preserve existing Vary values)\n const existingVary = headers.get('Vary');\n if (existingVary) {\n if (!existingVary.toLowerCase().includes('accept-encoding')) {\n headers.set('Vary', `${existingVary}, Accept-Encoding`);\n }\n } else {\n headers.set('Vary', 'Accept-Encoding');\n }\n\n return new Response(compressedBody, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n}\n\n// ─── Gzip (node:zlib with Z_SYNC_FLUSH) ──────────────────────────────────\n//\n// Uses node:zlib's createGzip with Z_SYNC_FLUSH so each chunk is flushed\n// to the output immediately. The Web Platform CompressionStream API buffers\n// internally and does NOT flush per-chunk — this kills streaming because\n// the browser doesn't receive the HTML shell until the gzip stream closes\n// (i.e. after all Suspense boundaries resolve).\n//\n// Z_SYNC_FLUSH adds ~2–5% size overhead vs Z_NO_FLUSH but preserves\n// correct streaming behavior: the shell renders instantly, Suspense\n// fallbacks are visible immediately, and streamed content appears\n// progressively.\n\nimport { createGzip, constants } from 'node:zlib';\nimport { Readable, pipeline } from 'node:stream';\n\n/**\n * Compress a ReadableStream with gzip, flushing each chunk immediately.\n *\n * Uses node:zlib's createGzip with Z_SYNC_FLUSH to ensure each HTML chunk\n * (shell, Suspense resolution, RSC payload) is delivered to the browser\n * as soon as it's available — preserving streaming semantics.\n */\nfunction compressWithGzip(body: ReadableStream<Uint8Array>): ReadableStream<Uint8Array> {\n const gzip = createGzip({ flush: constants.Z_SYNC_FLUSH });\n const nodeInput = Readable.fromWeb(body as import('stream/web').ReadableStream);\n\n // pipeline() instead of bare pipe(): pipe() does not forward source errors,\n // so an erroring body (streaming route handler, dropped upstream fetch)\n // would emit an unhandled 'error' event and crash the process. pipeline()\n // destroys gzip on source error — the returned web stream rejects — and\n // tears down nodeInput when the consumer cancels the web stream, which\n // cancels the source body via fromWeb. The error reaches the consumer\n // through the web stream; the callback only marks it handled at the Node\n // layer.\n pipeline(nodeInput, gzip, () => {});\n\n return Readable.toWeb(gzip) as ReadableStream<Uint8Array>;\n}\n";
|
|
10
|
+
//#endregion
|
|
4
11
|
//#region src/adapters/compress-module.ts
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
13
|
+
* The one import `server/compress.ts` is allowed to carry, and its inlined
|
|
14
|
+
* form.
|
|
15
|
+
*
|
|
16
|
+
* The binding list is matched exactly rather than as `{…}`. A second binding
|
|
17
|
+
* added to that import would otherwise be erased along with the statement and
|
|
18
|
+
* become a `ReferenceError` in the deployed `_compress.mjs` — the failure this
|
|
19
|
+
* whole module exists to make impossible. Matching exactly means such an
|
|
20
|
+
* import falls through to the rejection below instead.
|
|
21
|
+
*/
|
|
22
|
+
var INLINED_IMPORTS = [{
|
|
23
|
+
pattern: /^import\s*\{\s*RSC_CONTENT_TYPE\s*,?\s*\}\s*from\s*["'][^"']*shared\/rsc-media-type\.(?:js|ts)["'];?[ \t]*$/m,
|
|
24
|
+
replacement: `const RSC_CONTENT_TYPE = ${JSON.stringify(RSC_CONTENT_TYPE)};`
|
|
25
|
+
}];
|
|
26
|
+
/**
|
|
27
|
+
* Every way a module specifier can reach the emitted file, minus Node
|
|
28
|
+
* builtins.
|
|
7
29
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
30
|
+
* `node:*` is exempt because it resolves on the deployed server exactly as it
|
|
31
|
+
* does here — `_compress.mjs` already imports `node:zlib` and `node:stream`,
|
|
32
|
+
* and self-hosted (Node/Bun) is the only place this file runs. Everything
|
|
33
|
+
* else — relative paths, bare packages — has no resolution target next to a
|
|
34
|
+
* lone `.mjs` in the build output.
|
|
35
|
+
*
|
|
36
|
+
* All three forms are listed rather than the one `server/compress.ts` happens
|
|
37
|
+
* to use, because a re-export or a lazy `await import()` fails in exactly the
|
|
38
|
+
* same place and is exactly as invisible until deploy.
|
|
39
|
+
*/
|
|
40
|
+
var MODULE_SPECIFIERS = [
|
|
41
|
+
/^[ \t]*(?:import|export)\b[^\n]*\bfrom\s*["'](?!node:)[^"']+["']/m,
|
|
42
|
+
/^[ \t]*import\s*["'](?!node:)[^"']+["']/m,
|
|
43
|
+
/\bimport\s*\(\s*["'](?!node:)[^"']+["']/
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* Replace the shared-module imports with their values and reject anything
|
|
47
|
+
* else that would leave a dangling specifier in `_compress.mjs`.
|
|
48
|
+
*
|
|
49
|
+
* Exported separately from `generateCompressModule` so both branches can be
|
|
50
|
+
* driven with fixtures: the source it normally compiles is fixed, so a test
|
|
51
|
+
* of the generator alone can only ever exercise whichever branch that source
|
|
52
|
+
* happens to take today.
|
|
10
53
|
*
|
|
11
54
|
* @internal Exported for testing.
|
|
12
55
|
*/
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// node:zlib buffers output internally, breaking streaming.
|
|
19
|
-
|
|
20
|
-
const COMPRESSIBLE_TYPES = new Set([
|
|
21
|
-
'text/html', 'text/css', 'text/plain', 'text/xml', 'text/javascript',
|
|
22
|
-
'text/x-component', 'application/json', 'application/javascript',
|
|
23
|
-
'application/xml', 'application/xhtml+xml', 'application/rss+xml',
|
|
24
|
-
'application/atom+xml', 'image/svg+xml',
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
const NO_COMPRESS_STATUSES = new Set([204, 304]);
|
|
28
|
-
|
|
29
|
-
function negotiateEncoding(acceptEncoding) {
|
|
30
|
-
if (!acceptEncoding) return null;
|
|
31
|
-
// Parse tokens with quality values. Per RFC 9110 §12.5.3, q=0 means
|
|
32
|
-
// "not acceptable" — the client explicitly rejects that encoding.
|
|
33
|
-
// Brotli (br) is intentionally not handled at the application level.
|
|
34
|
-
const parts = acceptEncoding.split(',');
|
|
35
|
-
for (const part of parts) {
|
|
36
|
-
const [token, ...params] = part.split(';');
|
|
37
|
-
const name = token.trim().toLowerCase();
|
|
38
|
-
if (name !== 'gzip') continue;
|
|
39
|
-
let qValue = 1;
|
|
40
|
-
for (const param of params) {
|
|
41
|
-
const trimmed = param.trim().toLowerCase();
|
|
42
|
-
if (trimmed.startsWith('q=')) {
|
|
43
|
-
qValue = parseFloat(trimmed.slice(2));
|
|
44
|
-
if (Number.isNaN(qValue)) qValue = 1;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (qValue > 0) return 'gzip';
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
56
|
+
function inlineCompressImports(code) {
|
|
57
|
+
let out = code;
|
|
58
|
+
for (const { pattern, replacement } of INLINED_IMPORTS) out = out.replace(pattern, replacement);
|
|
59
|
+
assertStandalone(out, "server/compress.ts", "_compress.mjs");
|
|
60
|
+
return out;
|
|
51
61
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function compressWithGzip(body) {
|
|
65
|
-
return body.pipeThrough(new CompressionStream('gzip'));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function compressResponse(request, response) {
|
|
69
|
-
if (!shouldCompress(response)) return response;
|
|
70
|
-
const acceptEncoding = request.headers.get('Accept-Encoding') || '';
|
|
71
|
-
const encoding = negotiateEncoding(acceptEncoding);
|
|
72
|
-
if (!encoding) return response;
|
|
73
|
-
const compressedBody = compressWithGzip(response.body);
|
|
74
|
-
const headers = new Headers(response.headers);
|
|
75
|
-
headers.set('Content-Encoding', encoding);
|
|
76
|
-
headers.delete('Content-Length');
|
|
77
|
-
const existingVary = headers.get('Vary');
|
|
78
|
-
if (existingVary) {
|
|
79
|
-
if (!existingVary.toLowerCase().includes('accept-encoding')) {
|
|
80
|
-
headers.set('Vary', existingVary + ', Accept-Encoding');
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
headers.set('Vary', 'Accept-Encoding');
|
|
84
|
-
}
|
|
85
|
-
return new Response(compressedBody, {
|
|
86
|
-
status: response.status,
|
|
87
|
-
statusText: response.statusText,
|
|
88
|
-
headers,
|
|
89
|
-
});
|
|
62
|
+
/**
|
|
63
|
+
* Throw if type-stripped server source still imports anything but a Node
|
|
64
|
+
* builtin. Such a module is emitted alone into the build output, where no
|
|
65
|
+
* specifier has anything to resolve to.
|
|
66
|
+
*
|
|
67
|
+
* @internal Shared by the standalone-module generators.
|
|
68
|
+
*/
|
|
69
|
+
function assertStandalone(code, source, emitted) {
|
|
70
|
+
const surviving = MODULE_SPECIFIERS.map((pattern) => pattern.exec(code)).find(Boolean);
|
|
71
|
+
if (surviving) throw new Error(`[timber] ${source} is emitted as a standalone ${emitted} (type-stripped, not bundled), so it cannot import anything at runtime. Found: ${surviving[0].trim()}\n Either inline the value in the generator in adapters/ or keep the dependency out of ${source}.`);
|
|
90
72
|
}
|
|
91
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Compile server/compress.ts into a standalone ESM module.
|
|
75
|
+
*
|
|
76
|
+
* Uses Vite's OXC transform to strip TypeScript types from the
|
|
77
|
+
* embedded source. The result is written to `_compress.mjs` during
|
|
78
|
+
* buildOutput.
|
|
79
|
+
*
|
|
80
|
+
* @internal Exported for testing.
|
|
81
|
+
*/
|
|
82
|
+
async function generateCompressModule() {
|
|
83
|
+
return "// Generated by @timber-js/app — compiled from server/compress.ts.\n// Do not edit — this file is regenerated on each build.\n" + inlineCompressImports((await transformWithOxc(compress_default, "compress.ts", { lang: "ts" })).code);
|
|
92
84
|
}
|
|
93
85
|
//#endregion
|
|
94
|
-
//#region src/
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
86
|
+
//#region src/server/canonicalize.ts?raw
|
|
87
|
+
var canonicalize_default = "/**\n * URL canonicalization — runs once at the request boundary.\n *\n * Every layer (proxy.ts, middleware.ts, access.ts, components) sees the same\n * canonical path. No re-decoding occurs at any later stage.\n *\n * See design/07-routing.md §\"URL Canonicalization & Security\"\n */\n\n/** Result of canonicalization — either a clean path or a rejection. */\nexport type CanonicalizeResult = { ok: true; pathname: string } | { ok: false; status: 400 };\n\n/**\n * Encoded separators that produce a 400 rejection.\n * %2f (/) and %5c (\\) cause path-confusion attacks.\n *\n * Shared between the runtime canonicalizer and the build-time route scanner\n * to ensure both enforce identical security rules. See design/13-security.md.\n */\nexport const ENCODED_SEPARATOR_RE = /%2f|%5c/i;\n\n/** Null byte — rejected. Shared with the route scanner. */\nexport const NULL_BYTE_RE = /%00/i;\n\n/**\n * Canonicalize a URL pathname.\n *\n * 1. Reject encoded separators (%2f, %5c) and null bytes (%00)\n * 2. Single percent-decode\n * 3. Collapse // → /\n * 4. Resolve .. segments (reject if escaping root)\n * 5. Strip trailing slash (except root \"/\")\n *\n * @param rawPathname - The raw pathname from the request URL (percent-encoded)\n * @param stripTrailingSlash - Whether to strip trailing slashes. Default: true.\n */\nexport function canonicalize(rawPathname: string, stripTrailingSlash = true): CanonicalizeResult {\n // Step 1: Reject dangerous encoded sequences BEFORE decoding.\n // This must happen on the raw input so %252f doesn't bypass after a single decode.\n if (ENCODED_SEPARATOR_RE.test(rawPathname)) {\n return { ok: false, status: 400 };\n }\n if (NULL_BYTE_RE.test(rawPathname)) {\n return { ok: false, status: 400 };\n }\n\n // Step 2: Single percent-decode.\n // Double-encoded input (%2561 → %61) stays as %61 — not decoded again.\n let decoded: string;\n try {\n decoded = decodeURIComponent(rawPathname);\n } catch {\n // Malformed percent-encoding → 400\n return { ok: false, status: 400 };\n }\n\n // Reject null bytes that appeared after decoding (from valid %00-like sequences\n // that weren't caught above — belt and suspenders).\n if (decoded.includes('\\0')) {\n return { ok: false, status: 400 };\n }\n\n // Backslash is NOT a path separator — keep as literal character.\n // But reject if it would create // after normalization (e.g., /\\evil.com).\n // We do NOT convert \\ to / — it stays as a literal.\n\n // Step 3: Collapse consecutive slashes.\n let pathname = decoded.replace(/\\/\\/+/g, '/');\n\n // Step 4: Resolve .. and . segments.\n const segments = pathname.split('/');\n const resolved: string[] = [];\n for (const seg of segments) {\n if (seg === '..') {\n if (resolved.length <= 1) {\n // Trying to escape root — 400\n return { ok: false, status: 400 };\n }\n resolved.pop();\n } else if (seg !== '.') {\n resolved.push(seg);\n }\n }\n\n pathname = resolved.join('/') || '/';\n\n // Step 5: Strip trailing slash (except root \"/\").\n if (stripTrailingSlash && pathname.length > 1 && pathname.endsWith('/')) {\n pathname = pathname.slice(0, -1);\n }\n\n return { ok: true, pathname };\n}\n";
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/adapters/canonicalize-module.ts
|
|
90
|
+
/**
|
|
91
|
+
* Compile server/canonicalize.ts into a standalone ESM module exporting
|
|
92
|
+
* `canonicalize`.
|
|
93
|
+
*
|
|
94
|
+
* @internal Exported for testing.
|
|
95
|
+
*/
|
|
96
|
+
async function generateCanonicalizeModule() {
|
|
97
|
+
const result = await transformWithOxc(canonicalize_default, "canonicalize.ts", { lang: "ts" });
|
|
98
|
+
assertStandalone(result.code, "server/canonicalize.ts", "_canonicalize.mjs");
|
|
99
|
+
return "// Generated by @timber-js/app — compiled from server/canonicalize.ts.\n// Do not edit — this file is regenerated on each build.\n" + result.code;
|
|
107
100
|
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/adapters/nitro-presets.ts
|
|
108
103
|
var PRESET_CONFIGS = {
|
|
109
104
|
"vercel": {
|
|
110
105
|
nitroPreset: "vercel",
|
|
@@ -171,6 +166,409 @@ var PRESET_CONFIGS = {
|
|
|
171
166
|
runtimeName: "bun"
|
|
172
167
|
}
|
|
173
168
|
};
|
|
169
|
+
/** Presets that produce a locally-runnable server entry. */
|
|
170
|
+
var LOCALLY_PREVIEWABLE = /* @__PURE__ */ new Set(["node-server", "bun"]);
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/adapters/nitro-preview.ts
|
|
173
|
+
/**
|
|
174
|
+
* Content-Type by file extension for the preview server. Static hosts decide
|
|
175
|
+
* this themselves; the table covers the file types a web build ships so the
|
|
176
|
+
* preview does not turn ordinary files into downloads. An extension missing
|
|
177
|
+
* here is served as `application/octet-stream`.
|
|
178
|
+
*/
|
|
179
|
+
var PREVIEW_MIME_TYPES = {
|
|
180
|
+
".html": "text/html; charset=utf-8",
|
|
181
|
+
".htm": "text/html; charset=utf-8",
|
|
182
|
+
".css": "text/css; charset=utf-8",
|
|
183
|
+
".js": "text/javascript; charset=utf-8",
|
|
184
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
185
|
+
".cjs": "text/javascript; charset=utf-8",
|
|
186
|
+
".map": "application/json; charset=utf-8",
|
|
187
|
+
".json": "application/json; charset=utf-8",
|
|
188
|
+
".jsonld": "application/ld+json",
|
|
189
|
+
".webmanifest": "application/manifest+json",
|
|
190
|
+
".xml": "application/xml",
|
|
191
|
+
".rss": "application/rss+xml",
|
|
192
|
+
".atom": "application/atom+xml",
|
|
193
|
+
".txt": "text/plain; charset=utf-8",
|
|
194
|
+
".md": "text/markdown; charset=utf-8",
|
|
195
|
+
".csv": "text/csv; charset=utf-8",
|
|
196
|
+
".ics": "text/calendar; charset=utf-8",
|
|
197
|
+
".vtt": "text/vtt; charset=utf-8",
|
|
198
|
+
".pdf": "application/pdf",
|
|
199
|
+
".wasm": "application/wasm",
|
|
200
|
+
".zip": "application/zip",
|
|
201
|
+
".gz": "application/gzip",
|
|
202
|
+
".png": "image/png",
|
|
203
|
+
".apng": "image/apng",
|
|
204
|
+
".jpg": "image/jpeg",
|
|
205
|
+
".jpeg": "image/jpeg",
|
|
206
|
+
".gif": "image/gif",
|
|
207
|
+
".svg": "image/svg+xml",
|
|
208
|
+
".ico": "image/x-icon",
|
|
209
|
+
".webp": "image/webp",
|
|
210
|
+
".avif": "image/avif",
|
|
211
|
+
".bmp": "image/bmp",
|
|
212
|
+
".tif": "image/tiff",
|
|
213
|
+
".tiff": "image/tiff",
|
|
214
|
+
".woff": "font/woff",
|
|
215
|
+
".woff2": "font/woff2",
|
|
216
|
+
".ttf": "font/ttf",
|
|
217
|
+
".otf": "font/otf",
|
|
218
|
+
".mp3": "audio/mpeg",
|
|
219
|
+
".wav": "audio/wav",
|
|
220
|
+
".ogg": "audio/ogg",
|
|
221
|
+
".oga": "audio/ogg",
|
|
222
|
+
".m4a": "audio/mp4",
|
|
223
|
+
".flac": "audio/flac",
|
|
224
|
+
".mp4": "video/mp4",
|
|
225
|
+
".webm": "video/webm",
|
|
226
|
+
".ogv": "video/ogg",
|
|
227
|
+
".mov": "video/quicktime"
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Generate a standalone preview server script that uses Node's built-in
|
|
231
|
+
* HTTP server. This bypasses Nitro entirely — the Nitro entry.ts imports
|
|
232
|
+
* h3 which isn't available outside a Nitro build. For local preview we
|
|
233
|
+
* just need to serve static files and, in a server build, route requests
|
|
234
|
+
* to the RSC handler.
|
|
235
|
+
*
|
|
236
|
+
* Generated at build time rather than at preview time, so everything it
|
|
237
|
+
* serves comes from the build's artifacts instead of guesses about the
|
|
238
|
+
* directory it runs in.
|
|
239
|
+
*
|
|
240
|
+
* @internal Exported for testing.
|
|
241
|
+
*/
|
|
242
|
+
function generatePreviewScript(options) {
|
|
243
|
+
const immutablePrefixes = options.immutableDirs.map((dir) => `/${dir}/`);
|
|
244
|
+
const contentTypes = options.output === "static" ? options.contentTypes : {};
|
|
245
|
+
const handlerSetup = options.output === "server" ? `// Set runtime before importing the handler.
|
|
246
|
+
process.env.TIMBER_RUNTIME = ${JSON.stringify(options.runtimeName)};
|
|
247
|
+
${options.hasManifestInit ? `
|
|
248
|
+
// Load the build manifest before the handler reads it.
|
|
249
|
+
await import('./_timber-manifest-init.js');
|
|
250
|
+
` : ""}
|
|
251
|
+
// Import the RSC handler (default export is the fetch-like handler).
|
|
252
|
+
const { default: handler, runWithEarlyHintsSender } = await import(${JSON.stringify(options.rscEntry)});
|
|
253
|
+
|
|
254
|
+
// Import compression helper for self-hosted response compression.
|
|
255
|
+
const { compressResponse } = await import('./_compress.mjs');
|
|
256
|
+
|
|
257
|
+
// Web→Node response bridge with backpressure (TIM-1154).
|
|
258
|
+
const { sendNodeResponse } = await import('./_send-response.mjs');
|
|
259
|
+
` : "";
|
|
260
|
+
const fallback = options.output === "static" ? ` if (badPath) {
|
|
261
|
+
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
|
262
|
+
res.end('Bad Request');
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const notFound = await findFile('/404.html');
|
|
266
|
+
if (notFound) {
|
|
267
|
+
await sendFile(req, res, notFound, 404, 'text/html', 'public, max-age=0, must-revalidate');
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
271
|
+
res.end('Not Found');
|
|
272
|
+
` : ` await handleDynamic(req, res, url);
|
|
273
|
+
`;
|
|
274
|
+
const dynamicHandler = options.output === "server" ? `
|
|
275
|
+
async function handleDynamic(req, res, url) {
|
|
276
|
+
// Convert Node request to Web Request.
|
|
277
|
+
const headers = new Headers();
|
|
278
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
279
|
+
if (value) {
|
|
280
|
+
if (Array.isArray(value)) {
|
|
281
|
+
for (const v of value) headers.append(key, v);
|
|
282
|
+
} else {
|
|
283
|
+
headers.set(key, value);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
let body = undefined;
|
|
289
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
290
|
+
body = await new Promise((resolve) => {
|
|
291
|
+
const chunks = [];
|
|
292
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
293
|
+
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const webRequest = new Request(url.href, {
|
|
298
|
+
method: req.method,
|
|
299
|
+
headers,
|
|
300
|
+
body,
|
|
301
|
+
duplex: body ? 'half' : undefined,
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
try {
|
|
305
|
+
// Support 103 Early Hints when available.
|
|
306
|
+
const earlyHintsSender = (typeof res.writeEarlyHints === 'function')
|
|
307
|
+
? (links) => { try { res.writeEarlyHints({ link: links }); } catch {} }
|
|
308
|
+
: undefined;
|
|
309
|
+
|
|
310
|
+
const rawResponse = earlyHintsSender && runWithEarlyHintsSender
|
|
311
|
+
? await runWithEarlyHintsSender(earlyHintsSender, () => handler(webRequest))
|
|
312
|
+
: await handler(webRequest);
|
|
313
|
+
|
|
314
|
+
// Compress the response for self-hosted deployments.
|
|
315
|
+
const webResponse = compressResponse(webRequest, rawResponse);
|
|
316
|
+
|
|
317
|
+
// Write the response to Node's ServerResponse. sendNodeResponse handles
|
|
318
|
+
// status, headers (including Set-Cookie splitting via [...headers]),
|
|
319
|
+
// body streaming with backpressure, and client disconnect cleanup.
|
|
320
|
+
// See TIM-1154.
|
|
321
|
+
await sendNodeResponse(res, webResponse);
|
|
322
|
+
} catch (err) {
|
|
323
|
+
console.error('[timber preview] Request error:', err);
|
|
324
|
+
if (!res.headersSent) {
|
|
325
|
+
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
326
|
+
}
|
|
327
|
+
res.end('Internal Server Error');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
` : "";
|
|
331
|
+
return `// Generated by @timber-js/app — standalone preview server.
|
|
332
|
+
// Do not edit — this file is regenerated on each build.
|
|
333
|
+
// Uses Node's built-in HTTP server to serve the build's files${options.output === "server" ? " and route\n// dynamic requests through the RSC handler" : ""}. No Nitro/h3 dependency.
|
|
334
|
+
|
|
335
|
+
import { createServer } from 'node:http';
|
|
336
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
337
|
+
import { join, extname, sep } from 'node:path';
|
|
338
|
+
import { fileURLToPath } from 'node:url';
|
|
339
|
+
import { canonicalize } from './_canonicalize.mjs';
|
|
340
|
+
|
|
341
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
342
|
+
|
|
343
|
+
${handlerSetup}
|
|
344
|
+
const MIME_TYPES = ${JSON.stringify(PREVIEW_MIME_TYPES, null, 2)};
|
|
345
|
+
|
|
346
|
+
// Recorded by the build: content-hashed directories, and the Content-Type of
|
|
347
|
+
// each extensionless API route output (a file name cannot say it). Both are
|
|
348
|
+
// decoded route-space paths, matched against the decoded request path.
|
|
349
|
+
const IMMUTABLE_PREFIXES = ${JSON.stringify(immutablePrefixes)};
|
|
350
|
+
const BASE = ${JSON.stringify(options.base)};
|
|
351
|
+
const CONTENT_TYPES = ${JSON.stringify(contentTypes)};
|
|
352
|
+
const SERVE_DIRECTORY_INDEX = ${options.output === "static"};
|
|
353
|
+
|
|
354
|
+
const publicDir = join(__dirname, 'public');
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* The file under publicDir that a decoded URL path names, or null. A static
|
|
358
|
+
* build lays its pages out as <path>/index.html, so a directory serves its
|
|
359
|
+
* index there.
|
|
360
|
+
*/
|
|
361
|
+
async function findFile(pathname) {
|
|
362
|
+
const filePath = join(publicDir, pathname);
|
|
363
|
+
// Prevent path traversal (and a sibling like public-other/ passing a bare
|
|
364
|
+
// prefix check).
|
|
365
|
+
if (!filePath.startsWith(publicDir + sep)) return null;
|
|
366
|
+
try {
|
|
367
|
+
const fileStat = await stat(filePath);
|
|
368
|
+
if (fileStat.isFile()) return filePath;
|
|
369
|
+
if (SERVE_DIRECTORY_INDEX && fileStat.isDirectory()) {
|
|
370
|
+
const index = join(filePath, 'index.html');
|
|
371
|
+
if ((await stat(index)).isFile()) return index;
|
|
372
|
+
}
|
|
373
|
+
} catch {
|
|
374
|
+
// Not found.
|
|
375
|
+
}
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The route-space path for a request path, or null when the request is
|
|
381
|
+
* outside the deployment base (it names no file of this build).
|
|
382
|
+
*/
|
|
383
|
+
function stripBase(pathname) {
|
|
384
|
+
if (BASE === '/') return pathname;
|
|
385
|
+
if (pathname === BASE.slice(0, -1)) return '/';
|
|
386
|
+
if (!pathname.startsWith(BASE)) return null;
|
|
387
|
+
return pathname.slice(BASE.length - 1);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
async function sendFile(req, res, filePath, status, contentType, cacheControl) {
|
|
391
|
+
const body = await readFile(filePath);
|
|
392
|
+
res.writeHead(status, {
|
|
393
|
+
'Content-Type': contentType,
|
|
394
|
+
'Content-Length': body.length,
|
|
395
|
+
'Cache-Control': cacheControl,
|
|
396
|
+
});
|
|
397
|
+
res.end(req.method === 'HEAD' ? undefined : body);
|
|
398
|
+
}
|
|
399
|
+
${dynamicHandler}
|
|
400
|
+
// Port resolution (TIM-842):
|
|
401
|
+
// - Default to 3000
|
|
402
|
+
// - If PORT env var is set, honor it strictly (fail loudly on conflict)
|
|
403
|
+
// - Otherwise auto-bump from 3000 until a free port is found
|
|
404
|
+
// Mirrors the dev server behavior so timber dev/preview/production all
|
|
405
|
+
// behave the same way around port selection.
|
|
406
|
+
const envPort = process.env.PORT ? parseInt(process.env.PORT, 10) : null;
|
|
407
|
+
const portIsExplicit = envPort != null && Number.isFinite(envPort) && envPort > 0;
|
|
408
|
+
const startPort = portIsExplicit ? envPort : 3000;
|
|
409
|
+
const host = process.env.HOST || 'localhost';
|
|
410
|
+
|
|
411
|
+
// Set after listenWithBump() resolves so request handlers can build
|
|
412
|
+
// absolute URLs from the actual bound port (which may differ from
|
|
413
|
+
// startPort after an auto-bump).
|
|
414
|
+
let boundPort = startPort;
|
|
415
|
+
|
|
416
|
+
const server = createServer(async (req, res) => {
|
|
417
|
+
// Scheme from the socket's TLS state — a hardcoded http:// breaks CSRF
|
|
418
|
+
// origin comparison and absolute-URL construction when TLS is terminated
|
|
419
|
+
// at this server (TIM-1073; mirrors the dev-server fix in TIM-1067).
|
|
420
|
+
// X-Forwarded-Proto is intentionally not consulted here: on a direct
|
|
421
|
+
// connection it would be attacker-controlled. The CSRF layer honors it
|
|
422
|
+
// separately for reverse-proxy deployments.
|
|
423
|
+
const scheme = req.socket?.encrypted ? 'https' : 'http';
|
|
424
|
+
const url = new URL(req.url || '/', \`\${scheme}://\${host}:\${boundPort}\`);
|
|
425
|
+
|
|
426
|
+
// The runtime's own request-boundary canonicalizer (_canonicalize.mjs,
|
|
427
|
+
// compiled from server/canonicalize.ts): one decode, and the same 400s for
|
|
428
|
+
// encoded separators, null bytes, malformed encoding, and escaping the root
|
|
429
|
+
// (design/13-security.md). The base is stripped from its canonical result,
|
|
430
|
+
// so an encoded spelling of the base is the same path. What remains, in
|
|
431
|
+
// route space, is looked up in public/; null names no file.
|
|
432
|
+
const canonical = canonicalize(url.pathname, false);
|
|
433
|
+
const badPath = !canonical.ok;
|
|
434
|
+
const pathname = canonical.ok ? stripBase(canonical.pathname) : null;
|
|
435
|
+
const filePath = pathname === null ? null : await findFile(pathname);
|
|
436
|
+
if (filePath) {
|
|
437
|
+
const contentType =
|
|
438
|
+
CONTENT_TYPES[pathname] || MIME_TYPES[extname(filePath).toLowerCase()] || 'application/octet-stream';
|
|
439
|
+
// Hashed assets get immutable cache, others get short cache.
|
|
440
|
+
const isImmutable = IMMUTABLE_PREFIXES.some((prefix) => pathname.startsWith(prefix));
|
|
441
|
+
const cacheControl = isImmutable ? ${JSON.stringify(IMMUTABLE_CACHE)} : ${JSON.stringify(STATIC_CACHE)};
|
|
442
|
+
await sendFile(req, res, filePath, 200, contentType, cacheControl);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
${fallback}});
|
|
447
|
+
|
|
448
|
+
function listenWithBump(port, attempt = 0) {
|
|
449
|
+
return new Promise((resolveListen, rejectListen) => {
|
|
450
|
+
const onError = (err) => {
|
|
451
|
+
server.removeListener('listening', onListening);
|
|
452
|
+
if (err && err.code === 'EADDRINUSE' && !portIsExplicit && attempt < 100) {
|
|
453
|
+
if (attempt === 0) {
|
|
454
|
+
console.log(\` [timber] Port \${port} in use, trying \${port + 1}...\`);
|
|
455
|
+
}
|
|
456
|
+
listenWithBump(port + 1, attempt + 1).then(resolveListen, rejectListen);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
rejectListen(err);
|
|
460
|
+
};
|
|
461
|
+
const onListening = () => {
|
|
462
|
+
server.removeListener('error', onError);
|
|
463
|
+
resolveListen(port);
|
|
464
|
+
};
|
|
465
|
+
server.once('error', onError);
|
|
466
|
+
server.once('listening', onListening);
|
|
467
|
+
server.listen(port, host);
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
try {
|
|
472
|
+
boundPort = await listenWithBump(startPort);
|
|
473
|
+
if (boundPort !== startPort) {
|
|
474
|
+
console.log();
|
|
475
|
+
console.log(\` [timber] Port \${startPort} in use, using \${boundPort}\`);
|
|
476
|
+
}
|
|
477
|
+
console.log();
|
|
478
|
+
console.log(' ⚡ timber preview server running at:');
|
|
479
|
+
console.log();
|
|
480
|
+
console.log(\` ➜ http://\${host}:\${boundPort}\`);
|
|
481
|
+
console.log();
|
|
482
|
+
} catch (err) {
|
|
483
|
+
if (err && err.code === 'EADDRINUSE') {
|
|
484
|
+
console.error(\`[timber] Port \${startPort} is already in use. \` +
|
|
485
|
+
'Set PORT to a free port, or unset PORT to auto-pick.');
|
|
486
|
+
} else {
|
|
487
|
+
console.error('[timber] Failed to start preview server:', err);
|
|
488
|
+
}
|
|
489
|
+
process.exit(1);
|
|
490
|
+
}
|
|
491
|
+
`;
|
|
492
|
+
}
|
|
493
|
+
/** Spawn a Nitro preview process and pipe stdio. */
|
|
494
|
+
function spawnNitroPreview(command, args, cwd) {
|
|
495
|
+
return new Promise((resolve, reject) => {
|
|
496
|
+
const child = execFile(command, args, { cwd }, (err) => {
|
|
497
|
+
if (err) reject(err);
|
|
498
|
+
else resolve();
|
|
499
|
+
});
|
|
500
|
+
child.stdout?.pipe(process.stdout);
|
|
501
|
+
child.stderr?.pipe(process.stderr);
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Generate a standalone ESM module that exports sendNodeResponse.
|
|
506
|
+
*
|
|
507
|
+
* Mirrors srvx/node's sendNodeResponse: status + headers via writeHead,
|
|
508
|
+
* body streaming with backpressure (waits for drain on write() === false),
|
|
509
|
+
* and client disconnect cleanup. Written to `_send-response.mjs` during
|
|
510
|
+
* buildOutput for use by the preview server script. See TIM-1154.
|
|
511
|
+
*
|
|
512
|
+
* @internal Exported for testing.
|
|
513
|
+
*/
|
|
514
|
+
function generateSendResponseModule() {
|
|
515
|
+
return `// Generated by @timber-js/app — Web→Node response bridge.
|
|
516
|
+
// Do not edit — this file is regenerated on each build.
|
|
517
|
+
// Mirrors srvx/node's sendNodeResponse with backpressure support.
|
|
518
|
+
|
|
519
|
+
export function sendNodeResponse(nodeRes, webRes) {
|
|
520
|
+
if (!webRes) {
|
|
521
|
+
nodeRes.statusCode = 500;
|
|
522
|
+
return new Promise((resolve) => nodeRes.end(resolve));
|
|
523
|
+
}
|
|
524
|
+
const rawHeaders = [...webRes.headers];
|
|
525
|
+
const writeHeaders = rawHeaders.flat();
|
|
526
|
+
if (!nodeRes.headersSent) {
|
|
527
|
+
if (nodeRes.req?.httpVersion === '2.0') {
|
|
528
|
+
nodeRes.writeHead(webRes.status, writeHeaders);
|
|
529
|
+
} else {
|
|
530
|
+
nodeRes.writeHead(webRes.status, webRes.statusText, writeHeaders);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (!webRes.body) {
|
|
534
|
+
return new Promise((resolve) => nodeRes.end(resolve));
|
|
535
|
+
}
|
|
536
|
+
// Stream with backpressure: pause reading when the kernel buffer is
|
|
537
|
+
// full (write() returns false) and resume on 'drain'.
|
|
538
|
+
if (nodeRes.destroyed) {
|
|
539
|
+
webRes.body.cancel();
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
const reader = webRes.body.getReader();
|
|
543
|
+
function streamCancel(error) {
|
|
544
|
+
reader.cancel(error).catch(() => {});
|
|
545
|
+
if (error) nodeRes.destroy(error);
|
|
546
|
+
}
|
|
547
|
+
function streamHandle({ done, value }) {
|
|
548
|
+
try {
|
|
549
|
+
if (done) {
|
|
550
|
+
nodeRes.end();
|
|
551
|
+
} else if (nodeRes.write(value)) {
|
|
552
|
+
reader.read().then(streamHandle, streamCancel);
|
|
553
|
+
} else {
|
|
554
|
+
nodeRes.once('drain', () => reader.read().then(streamHandle, streamCancel));
|
|
555
|
+
}
|
|
556
|
+
} catch (error) {
|
|
557
|
+
streamCancel(error instanceof Error ? error : undefined);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
nodeRes.on('close', streamCancel);
|
|
561
|
+
nodeRes.on('error', streamCancel);
|
|
562
|
+
reader.read().then(streamHandle, streamCancel);
|
|
563
|
+
return reader.closed.catch(streamCancel).finally(() => {
|
|
564
|
+
nodeRes.off('close', streamCancel);
|
|
565
|
+
nodeRes.off('error', streamCancel);
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
`;
|
|
569
|
+
}
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region src/adapters/nitro.ts
|
|
174
572
|
/**
|
|
175
573
|
* Create a Nitro-based adapter for multi-platform deployment.
|
|
176
574
|
*
|
|
@@ -190,50 +588,82 @@ var PRESET_CONFIGS = {
|
|
|
190
588
|
function nitro(options = {}) {
|
|
191
589
|
const preset = options.preset ?? "node-server";
|
|
192
590
|
const compress = options.compress ?? true;
|
|
193
|
-
const presetConfig = PRESET_CONFIGS[preset];
|
|
194
|
-
const pendingPromises = [];
|
|
195
591
|
return {
|
|
196
592
|
name: `nitro-${preset}`,
|
|
197
|
-
async buildOutput(config,
|
|
198
|
-
const outDir = join(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
593
|
+
async buildOutput(config, artifacts) {
|
|
594
|
+
const outDir = join(artifacts.outputDir, "nitro");
|
|
595
|
+
if (artifacts.output === "static") {
|
|
596
|
+
await buildStaticDirectoryOutput(config, artifacts, outDir, "public");
|
|
597
|
+
const publicDir = join(outDir, "public");
|
|
598
|
+
await writeHeadersFile(publicDir, config, artifacts);
|
|
599
|
+
await writeFile(join(outDir, CANONICALIZE_MODULE), await generateCanonicalizeModule());
|
|
600
|
+
await writeFile(join(outDir, PREVIEW_SCRIPT), generatePreviewScript({
|
|
601
|
+
output: "static",
|
|
602
|
+
immutableDirs: artifacts.immutableDirs,
|
|
603
|
+
base: adapterBase(config),
|
|
604
|
+
contentTypes: artifacts.contentTypes
|
|
605
|
+
}));
|
|
606
|
+
if ((options.staticTarget ?? "generic") === "github-pages") {
|
|
607
|
+
await writeFile(join(publicDir, ".nojekyll"), "");
|
|
608
|
+
try {
|
|
609
|
+
if ((await readFile(join(publicDir, "_redirects"), "utf-8")).trim().length > 0) console.warn("[timber] Warning: GitHub Pages does not support _redirects files. Redirect rules from middleware/proxy will not work on this platform.");
|
|
610
|
+
} catch {}
|
|
611
|
+
}
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
await runSharedBuildSteps({
|
|
615
|
+
config,
|
|
616
|
+
artifacts,
|
|
617
|
+
outDir,
|
|
618
|
+
publicDirName: "public"
|
|
619
|
+
});
|
|
620
|
+
await writeFile(join(outDir, "_compress.mjs"), await generateCompressModule());
|
|
621
|
+
await writeFile(join(outDir, "_send-response.mjs"), generateSendResponseModule());
|
|
622
|
+
if (LOCALLY_PREVIEWABLE.has(preset)) {
|
|
623
|
+
await writeFile(join(outDir, CANONICALIZE_MODULE), await generateCanonicalizeModule());
|
|
624
|
+
await writeFile(join(outDir, PREVIEW_SCRIPT), generatePreviewScript({
|
|
625
|
+
output: "server",
|
|
626
|
+
runtimeName: PRESET_CONFIGS[preset].runtimeName,
|
|
627
|
+
rscEntry: importSpecifier(outDir, join(artifacts.rsc.path, "index.js")),
|
|
628
|
+
hasManifestInit: !!artifacts.manifestInit,
|
|
629
|
+
immutableDirs: artifacts.immutableDirs,
|
|
630
|
+
base: adapterBase(config)
|
|
631
|
+
}));
|
|
632
|
+
}
|
|
633
|
+
if (artifacts.manifestInit) {
|
|
213
634
|
const rscEntry = join(outDir, "rsc", "index.js");
|
|
214
635
|
const rscContent = await readFile(rscEntry, "utf-8");
|
|
215
|
-
await writeFile(rscEntry, `${
|
|
636
|
+
await writeFile(rscEntry, `${artifacts.manifestInit}\n${rscContent}`);
|
|
216
637
|
}
|
|
217
|
-
const entry = generateNitroEntry(
|
|
638
|
+
const entry = generateNitroEntry(preset, compress);
|
|
218
639
|
await writeFile(join(outDir, "entry.ts"), entry);
|
|
219
|
-
await runNitroBuild(outDir, preset, options.nitroConfig);
|
|
640
|
+
const { serverDir } = await runNitroBuild(outDir, preset, artifacts.immutableDirs, options.nitroConfig);
|
|
641
|
+
if (artifacts.prebuilt) {
|
|
642
|
+
const prebuiltSrc = artifacts.prebuilt.path;
|
|
643
|
+
await cp(prebuiltSrc, join(serverDir, "prebuilt"), { recursive: true });
|
|
644
|
+
if (preset === "vercel" || preset === "vercel-edge") await copyPrebuiltToVercelFuncClones(dirname(serverDir), prebuiltSrc, basename(serverDir));
|
|
645
|
+
}
|
|
220
646
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const tracked = promise.catch((err) => {
|
|
229
|
-
console.error("[timber] waitUntil promise rejected:", err);
|
|
230
|
-
});
|
|
231
|
-
pendingPromises.push(tracked);
|
|
232
|
-
} : void 0
|
|
647
|
+
async preview(_config, { output, outputDir }) {
|
|
648
|
+
if (output === "server" && !LOCALLY_PREVIEWABLE.has(preset)) throw new Error(`[timber] The nitro '${preset}' preset has no local runtime, so \`timber preview\` cannot run its server build. Preview with a node-server build, or with the platform's own tooling.`);
|
|
649
|
+
const nitroDir = join(outputDir, "nitro");
|
|
650
|
+
const script = join(nitroDir, PREVIEW_SCRIPT);
|
|
651
|
+
if (!existsSync(script)) throw new Error(`[timber] No preview server at ${script}. Run \`timber build\` before \`timber preview\`.`);
|
|
652
|
+
await spawnNitroPreview(output === "server" && preset === "bun" ? "bun" : process.execPath, [script], nitroDir);
|
|
653
|
+
}
|
|
233
654
|
};
|
|
234
655
|
}
|
|
656
|
+
/** The preview server buildOutput writes into the Nitro output directory. */
|
|
657
|
+
var PREVIEW_SCRIPT = "_preview-server.mjs";
|
|
658
|
+
/** The request-path canonicalizer the preview server imports beside it. */
|
|
659
|
+
var CANONICALIZE_MODULE = "_canonicalize.mjs";
|
|
660
|
+
/** A relative ESM import specifier for `file`, as imported from a module in `fromDir`. */
|
|
661
|
+
function importSpecifier(fromDir, file) {
|
|
662
|
+
const path = relative(fromDir, file).split(sep).join("/");
|
|
663
|
+
return path.startsWith("../") ? path : "./" + path;
|
|
664
|
+
}
|
|
235
665
|
/** @internal Exported for testing. */
|
|
236
|
-
function generateNitroEntry(
|
|
666
|
+
function generateNitroEntry(preset, compress = true) {
|
|
237
667
|
const serverEntryRelative = "./rsc/index.js";
|
|
238
668
|
const runtimeName = PRESET_CONFIGS[preset].runtimeName;
|
|
239
669
|
const earlyHints = PRESET_CONFIGS[preset].supportsEarlyHints;
|
|
@@ -274,15 +704,7 @@ function generateNitroEntry(buildDir, outDir, preset, compress = true, hasManife
|
|
|
274
704
|
return `// Generated by @timber-js/app/adapters/nitro
|
|
275
705
|
// Do not edit — this file is regenerated on each build.
|
|
276
706
|
|
|
277
|
-
|
|
278
|
-
// Must run before ANY code creates ReadableStream/WritableStream/TransformStream.
|
|
279
|
-
// React's RSC Flight streams, SSR output, .tee(), and all pipeThrough transforms
|
|
280
|
-
// benefit: 3.8x faster reads, 11x faster transforms, 13x faster sequential tee.
|
|
281
|
-
// See: https://github.com/vercel-labs/fast-webstreams
|
|
282
|
-
import { patchGlobalWebStreams } from 'experimental-fast-webstreams'
|
|
283
|
-
patchGlobalWebStreams()
|
|
284
|
-
|
|
285
|
-
${hasManifestInit ? "import './_timber-manifest-init.js'\n" : ""}import handler, { runWithEarlyHintsSender${supportsWaitUntil ? ", runWithWaitUntil" : ""} } from '${serverEntryRelative}'
|
|
707
|
+
import handler, { runWithEarlyHintsSender${supportsWaitUntil ? ", runWithWaitUntil" : ""} } from '${serverEntryRelative}'
|
|
286
708
|
${compress ? "import { compressResponse } from './_compress.mjs'\n" : ""}
|
|
287
709
|
// Set TIMBER_RUNTIME for instrumentation.ts conditional SDK initialization.
|
|
288
710
|
// See design/25-production-deployments.md §"TIMBER_RUNTIME".
|
|
@@ -301,222 +723,64 @@ ${handlerCall}
|
|
|
301
723
|
}
|
|
302
724
|
`;
|
|
303
725
|
}
|
|
726
|
+
/**
|
|
727
|
+
* Prefixes of nitro build-output lines that give wrong advice for timber
|
|
728
|
+
* builds. Every nitro bundler path emits these hints via `logger.success` —
|
|
729
|
+
* the rollup path hardcodes `npx nitro preview`; rolldown and vite default
|
|
730
|
+
* to it. That command resolves `.output/nitro.json` relative to cwd, but
|
|
731
|
+
* timber's nitro build lives at `.timber/dist/nitro/.output`, so the
|
|
732
|
+
* suggested command can never work from the project root.
|
|
733
|
+
* Prefix matching degrades gracefully: if upstream rewords the line
|
|
734
|
+
* entirely, it passes through rather than being silently eaten.
|
|
735
|
+
*/
|
|
736
|
+
var NITRO_PREVIEW_HINT_PREFIX = "You can preview this build using";
|
|
737
|
+
var NITRO_DEPLOY_HINT_PREFIX = "You can deploy this build using";
|
|
738
|
+
var SUPPRESSED_NITRO_HINT_PREFIXES = [NITRO_PREVIEW_HINT_PREFIX, NITRO_DEPLOY_HINT_PREFIX];
|
|
304
739
|
/** @internal Exported for testing. */
|
|
305
|
-
function
|
|
306
|
-
|
|
307
|
-
const config = {
|
|
308
|
-
preset: presetConfig.nitroPreset,
|
|
309
|
-
entry: "./entry.ts",
|
|
310
|
-
output: { dir: presetConfig.outputDir },
|
|
311
|
-
routeRules: { "/assets/**": { headers: { "Cache-Control": IMMUTABLE_CACHE } } },
|
|
312
|
-
...presetConfig.extraConfig,
|
|
313
|
-
...userConfig
|
|
314
|
-
};
|
|
315
|
-
return `// Generated by @timber-js/app/adapters/nitro
|
|
316
|
-
// Do not edit — this file is regenerated on each build.
|
|
317
|
-
|
|
318
|
-
import { defineNitroConfig } from 'nitro/config'
|
|
319
|
-
|
|
320
|
-
export default defineNitroConfig(${JSON.stringify(config, null, 2)})
|
|
321
|
-
`;
|
|
740
|
+
function isSuppressedNitroHint(message, prefixes = SUPPRESSED_NITRO_HINT_PREFIXES) {
|
|
741
|
+
return typeof message === "string" && prefixes.some((prefix) => message.startsWith(prefix));
|
|
322
742
|
}
|
|
323
|
-
/** Presets that produce a locally-runnable server entry. */
|
|
324
|
-
var LOCALLY_PREVIEWABLE = new Set(["node-server", "bun"]);
|
|
325
743
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
744
|
+
* Nitro's rolldown and vite builders render `framework.previewCommand` /
|
|
745
|
+
* `framework.deployCommand` into these hints. A user who explicitly set one
|
|
746
|
+
* via `nitroConfig` has provided valid guidance — only suppress the hints
|
|
747
|
+
* whose command is still nitro's broken default.
|
|
330
748
|
*
|
|
331
749
|
* @internal Exported for testing.
|
|
332
750
|
*/
|
|
333
|
-
function
|
|
334
|
-
|
|
335
|
-
const rscEntry = rscEntryRelative.startsWith(".") ? rscEntryRelative : "./" + rscEntryRelative;
|
|
336
|
-
const publicDir = "./public";
|
|
337
|
-
const manifestInitPath = "./_timber-manifest-init.js";
|
|
338
|
-
return `// Generated by @timber-js/app — standalone preview server.
|
|
339
|
-
// Uses Node's built-in HTTP server to serve static assets and route
|
|
340
|
-
// dynamic requests through the RSC handler. No Nitro/h3 dependency.
|
|
341
|
-
|
|
342
|
-
// Patch global Web Streams with fast-webstreams before any imports.
|
|
343
|
-
import { patchGlobalWebStreams } from 'experimental-fast-webstreams';
|
|
344
|
-
patchGlobalWebStreams();
|
|
345
|
-
|
|
346
|
-
import { createServer } from 'node:http';
|
|
347
|
-
import { readFile, stat } from 'node:fs/promises';
|
|
348
|
-
import { join, extname } from 'node:path';
|
|
349
|
-
import { fileURLToPath } from 'node:url';
|
|
350
|
-
import { existsSync } from 'node:fs';
|
|
351
|
-
|
|
352
|
-
// Set runtime before importing the handler.
|
|
353
|
-
process.env.TIMBER_RUNTIME = '${PRESET_CONFIGS[preset].runtimeName}';
|
|
354
|
-
|
|
355
|
-
// Load the build manifest if it exists.
|
|
356
|
-
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
357
|
-
const manifestPath = join(__dirname, '${manifestInitPath}');
|
|
358
|
-
if (existsSync(manifestPath)) {
|
|
359
|
-
await import('${manifestInitPath}');
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// Import the RSC handler (default export is the fetch-like handler).
|
|
363
|
-
const { default: handler, runWithEarlyHintsSender } = await import('${rscEntry}');
|
|
364
|
-
|
|
365
|
-
// Import compression helper for self-hosted response compression.
|
|
366
|
-
const { compressResponse } = await import('./_compress.mjs');
|
|
367
|
-
|
|
368
|
-
const MIME_TYPES = {
|
|
369
|
-
'.html': 'text/html',
|
|
370
|
-
'.js': 'application/javascript',
|
|
371
|
-
'.mjs': 'application/javascript',
|
|
372
|
-
'.css': 'text/css',
|
|
373
|
-
'.json': 'application/json',
|
|
374
|
-
'.png': 'image/png',
|
|
375
|
-
'.jpg': 'image/jpeg',
|
|
376
|
-
'.jpeg': 'image/jpeg',
|
|
377
|
-
'.gif': 'image/gif',
|
|
378
|
-
'.svg': 'image/svg+xml',
|
|
379
|
-
'.ico': 'image/x-icon',
|
|
380
|
-
'.woff': 'font/woff',
|
|
381
|
-
'.woff2': 'font/woff2',
|
|
382
|
-
'.ttf': 'font/ttf',
|
|
383
|
-
'.otf': 'font/otf',
|
|
384
|
-
'.webp': 'image/webp',
|
|
385
|
-
'.avif': 'image/avif',
|
|
386
|
-
'.webm': 'video/webm',
|
|
387
|
-
'.mp4': 'video/mp4',
|
|
388
|
-
'.txt': 'text/plain',
|
|
389
|
-
'.xml': 'application/xml',
|
|
390
|
-
'.wasm': 'application/wasm',
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
const publicDir = join(__dirname, '${publicDir}');
|
|
394
|
-
const port = parseInt(process.env.PORT || '3000', 10);
|
|
395
|
-
const host = process.env.HOST || process.env.HOSTNAME || 'localhost';
|
|
396
|
-
|
|
397
|
-
const server = createServer(async (req, res) => {
|
|
398
|
-
const url = new URL(req.url || '/', \`http://\${host}:\${port}\`);
|
|
399
|
-
|
|
400
|
-
// Try serving static files from the public directory first.
|
|
401
|
-
const filePath = join(publicDir, url.pathname);
|
|
402
|
-
// Prevent path traversal.
|
|
403
|
-
if (filePath.startsWith(publicDir)) {
|
|
404
|
-
try {
|
|
405
|
-
const fileStat = await stat(filePath);
|
|
406
|
-
if (fileStat.isFile()) {
|
|
407
|
-
const ext = extname(filePath);
|
|
408
|
-
const contentType = MIME_TYPES[ext] || 'application/octet-stream';
|
|
409
|
-
const body = await readFile(filePath);
|
|
410
|
-
// Hashed assets get immutable cache, others get short cache.
|
|
411
|
-
const cacheControl = url.pathname.startsWith('/assets/')
|
|
412
|
-
? 'public, max-age=31536000, immutable'
|
|
413
|
-
: 'public, max-age=3600, must-revalidate';
|
|
414
|
-
res.writeHead(200, {
|
|
415
|
-
'Content-Type': contentType,
|
|
416
|
-
'Content-Length': body.length,
|
|
417
|
-
'Cache-Control': cacheControl,
|
|
418
|
-
});
|
|
419
|
-
res.end(body);
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
} catch {
|
|
423
|
-
// File not found — fall through to the RSC handler.
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// Convert Node request to Web Request.
|
|
428
|
-
const headers = new Headers();
|
|
429
|
-
for (const [key, value] of Object.entries(req.headers)) {
|
|
430
|
-
if (value) {
|
|
431
|
-
if (Array.isArray(value)) {
|
|
432
|
-
for (const v of value) headers.append(key, v);
|
|
433
|
-
} else {
|
|
434
|
-
headers.set(key, value);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
let body = undefined;
|
|
440
|
-
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
441
|
-
body = await new Promise((resolve) => {
|
|
442
|
-
const chunks = [];
|
|
443
|
-
req.on('data', (chunk) => chunks.push(chunk));
|
|
444
|
-
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
const webRequest = new Request(url.href, {
|
|
449
|
-
method: req.method,
|
|
450
|
-
headers,
|
|
451
|
-
body,
|
|
452
|
-
duplex: body ? 'half' : undefined,
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
try {
|
|
456
|
-
// Support 103 Early Hints when available.
|
|
457
|
-
const earlyHintsSender = (typeof res.writeEarlyHints === 'function')
|
|
458
|
-
? (links) => { try { res.writeEarlyHints({ link: links }); } catch {} }
|
|
459
|
-
: undefined;
|
|
460
|
-
|
|
461
|
-
const rawResponse = earlyHintsSender && runWithEarlyHintsSender
|
|
462
|
-
? await runWithEarlyHintsSender(earlyHintsSender, () => handler(webRequest))
|
|
463
|
-
: await handler(webRequest);
|
|
464
|
-
|
|
465
|
-
// Compress the response for self-hosted deployments.
|
|
466
|
-
const webResponse = compressResponse(webRequest, rawResponse);
|
|
467
|
-
|
|
468
|
-
// Write the response back to the Node response.
|
|
469
|
-
res.writeHead(webResponse.status, Object.fromEntries(webResponse.headers.entries()));
|
|
470
|
-
|
|
471
|
-
if (webResponse.body) {
|
|
472
|
-
const reader = webResponse.body.getReader();
|
|
473
|
-
const pump = async () => {
|
|
474
|
-
while (true) {
|
|
475
|
-
const { done, value } = await reader.read();
|
|
476
|
-
if (done) { res.end(); return; }
|
|
477
|
-
res.write(value);
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
await pump();
|
|
481
|
-
} else {
|
|
482
|
-
res.end();
|
|
483
|
-
}
|
|
484
|
-
} catch (err) {
|
|
485
|
-
console.error('[timber preview] Request error:', err);
|
|
486
|
-
if (!res.headersSent) {
|
|
487
|
-
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
488
|
-
}
|
|
489
|
-
res.end('Internal Server Error');
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
server.listen(port, host, () => {
|
|
494
|
-
console.log();
|
|
495
|
-
console.log(' ⚡ timber preview server running at:');
|
|
496
|
-
console.log();
|
|
497
|
-
console.log(\` ➜ http://\${host}:\${port}\`);
|
|
498
|
-
console.log();
|
|
499
|
-
});
|
|
500
|
-
`;
|
|
751
|
+
function selectSuppressedHintPrefixes(framework) {
|
|
752
|
+
return [...framework?.previewCommand ? [] : [NITRO_PREVIEW_HINT_PREFIX], ...framework?.deployCommand ? [] : [NITRO_DEPLOY_HINT_PREFIX]];
|
|
501
753
|
}
|
|
502
|
-
/**
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
754
|
+
/**
|
|
755
|
+
* Wrap a nitro logger's `success` so hardcoded preview/deploy hints are
|
|
756
|
+
* dropped for this programmatic build only. Returns the original
|
|
757
|
+
* (unfiltered) success fn so timber can print its own hint — which shares
|
|
758
|
+
* the suppressed prefix on purpose, replacing nitro's wording.
|
|
759
|
+
*
|
|
760
|
+
* @internal Exported for testing.
|
|
761
|
+
*/
|
|
762
|
+
function wrapNitroLoggerForBuild(logger, prefixes = SUPPRESSED_NITRO_HINT_PREFIXES) {
|
|
763
|
+
const originalSuccess = logger.success.bind(logger);
|
|
764
|
+
const wrapped = (message, ...args) => {
|
|
765
|
+
if (isSuppressedNitroHint(message, prefixes)) return;
|
|
766
|
+
originalSuccess(message, ...args);
|
|
511
767
|
};
|
|
768
|
+
logger.success = Object.assign(wrapped, logger.success);
|
|
769
|
+
return originalSuccess;
|
|
512
770
|
}
|
|
513
771
|
/**
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
772
|
+
* Timber's own post-build hint. Locally-runnable presets are previewed via
|
|
773
|
+
* `timber preview`, which invokes this adapter's `preview()` to run the
|
|
774
|
+
* generated `_preview-server.mjs`. Serverless presets get no hint — their
|
|
775
|
+
* output lives under `.timber/dist/nitro/`, so any cwd-relative deploy
|
|
776
|
+
* command would be as wrong as the nitro hint this replaces.
|
|
777
|
+
*
|
|
778
|
+
* @internal Exported for testing.
|
|
518
779
|
*/
|
|
519
|
-
|
|
780
|
+
function getPostBuildHint(preset) {
|
|
781
|
+
return LOCALLY_PREVIEWABLE.has(preset) ? "You can preview this build using `timber preview`" : null;
|
|
782
|
+
}
|
|
783
|
+
async function runNitroBuild(nitroDir, preset, immutableDirs, userConfig) {
|
|
520
784
|
const presetConfig = PRESET_CONFIGS[preset];
|
|
521
785
|
const { createNitro, build: nitroBuild, prepare, copyPublicAssets } = await import("nitro/builder");
|
|
522
786
|
const nitro = await createNitro({
|
|
@@ -524,35 +788,43 @@ async function runNitroBuild(nitroDir, preset, userConfig) {
|
|
|
524
788
|
preset: presetConfig.nitroPreset,
|
|
525
789
|
renderer: { handler: join(nitroDir, "entry.ts") },
|
|
526
790
|
output: { dir: join(nitroDir, presetConfig.outputDir) },
|
|
527
|
-
routeRules:
|
|
791
|
+
routeRules: Object.fromEntries(immutableDirs.map((dir) => [`/${dir}/**`, { headers: { "Cache-Control": IMMUTABLE_CACHE } }])),
|
|
528
792
|
rollupConfig: { external: [/\.\.\/rsc\//] },
|
|
529
793
|
...presetConfig.extraConfig,
|
|
530
794
|
...userConfig
|
|
531
795
|
});
|
|
796
|
+
const framework = nitro.options.builder === "rollup" ? void 0 : nitro.options.framework;
|
|
797
|
+
const logSuccess = wrapNitroLoggerForBuild(nitro.logger, selectSuppressedHintPrefixes(framework));
|
|
798
|
+
const raw = nitro.options.output.serverDir;
|
|
799
|
+
const serverDir = raw.endsWith("/") ? raw.slice(0, -1) : raw;
|
|
532
800
|
await prepare(nitro);
|
|
533
801
|
await copyPublicAssets(nitro);
|
|
534
802
|
await nitroBuild(nitro);
|
|
535
803
|
await nitro.close();
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return new Promise((resolve, reject) => {
|
|
540
|
-
const child = execFile(command, args, { cwd }, (err) => {
|
|
541
|
-
if (err) reject(err);
|
|
542
|
-
else resolve();
|
|
543
|
-
});
|
|
544
|
-
child.stdout?.pipe(process.stdout);
|
|
545
|
-
child.stderr?.pipe(process.stderr);
|
|
546
|
-
});
|
|
804
|
+
const hint = framework?.previewCommand ? null : getPostBuildHint(preset);
|
|
805
|
+
if (hint) logSuccess(hint);
|
|
806
|
+
return { serverDir };
|
|
547
807
|
}
|
|
548
808
|
/**
|
|
549
|
-
*
|
|
809
|
+
* Copy prebuilt payloads into cloned Vercel function directories.
|
|
810
|
+
*
|
|
811
|
+
* When users configure `vercel.functionRules`, Nitro's compiled hook clones
|
|
812
|
+
* the base __server.func to per-route .func directories. These clones are
|
|
813
|
+
* created during `runNitroBuild()` — before our post-build prebuilt copy.
|
|
814
|
+
* Each clone resolves `../prebuilt` independently, so they each need a copy.
|
|
815
|
+
*
|
|
550
816
|
* @internal Exported for testing.
|
|
551
817
|
*/
|
|
552
|
-
function
|
|
553
|
-
|
|
818
|
+
async function copyPrebuiltToVercelFuncClones(functionsDir, prebuiltSrc, baseFuncName) {
|
|
819
|
+
const funcDirs = [];
|
|
820
|
+
try {
|
|
821
|
+
for await (const match of glob("**/*.func", { cwd: functionsDir })) if (!match.endsWith(baseFuncName)) funcDirs.push(join(functionsDir, match));
|
|
822
|
+
} catch {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
await Promise.all(funcDirs.map((dir) => cp(prebuiltSrc, join(dir, "prebuilt"), { recursive: true })));
|
|
554
826
|
}
|
|
555
827
|
//#endregion
|
|
556
|
-
export {
|
|
828
|
+
export { copyPrebuiltToVercelFuncClones, generateNitroEntry, getPostBuildHint, isSuppressedNitroHint, nitro, selectSuppressedHintPrefixes, wrapNitroLoggerForBuild };
|
|
557
829
|
|
|
558
830
|
//# sourceMappingURL=nitro.js.map
|