@timber-js/app 0.2.0-alpha.9 → 0.2.0-alpha.91
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/dist/_chunks/actions-DLnUaR65.js +421 -0
- package/dist/_chunks/actions-DLnUaR65.js.map +1 -0
- package/dist/_chunks/{als-registry-B7DbZ2hS.js → als-registry-HS0LGUl2.js} +1 -1
- package/dist/_chunks/als-registry-HS0LGUl2.js.map +1 -0
- package/dist/_chunks/chunk-BYIpzuS7.js +39 -0
- package/dist/_chunks/{debug-gwlJkDuf.js → debug-ECi_61pb.js} +2 -2
- package/dist/_chunks/debug-ECi_61pb.js.map +1 -0
- package/dist/_chunks/define-C77ScO0m.js +106 -0
- package/dist/_chunks/define-C77ScO0m.js.map +1 -0
- package/dist/_chunks/define-Itxvcd7F.js +199 -0
- package/dist/_chunks/define-Itxvcd7F.js.map +1 -0
- package/dist/_chunks/define-cookie-BowvzoP0.js +94 -0
- package/dist/_chunks/define-cookie-BowvzoP0.js.map +1 -0
- package/dist/_chunks/{format-DviM89f0.js → dev-warnings-DpGRGoDi.js} +5 -44
- package/dist/_chunks/dev-warnings-DpGRGoDi.js.map +1 -0
- package/dist/_chunks/format-CYBGxKtc.js +14 -0
- package/dist/_chunks/format-CYBGxKtc.js.map +1 -0
- package/dist/_chunks/{interception-BOoWmLUA.js → interception-ErnB33JX.js} +301 -133
- package/dist/_chunks/interception-ErnB33JX.js.map +1 -0
- package/dist/_chunks/merge-search-params-Cm_KIWDX.js +41 -0
- package/dist/_chunks/merge-search-params-Cm_KIWDX.js.map +1 -0
- package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-DS3eKNmf.js} +1 -1
- package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js.map → metadata-routes-DS3eKNmf.js.map} +1 -1
- package/dist/_chunks/request-context-CK5tZqIP.js +478 -0
- package/dist/_chunks/request-context-CK5tZqIP.js.map +1 -0
- package/dist/_chunks/schema-bridge-C3xl_vfb.js +86 -0
- package/dist/_chunks/schema-bridge-C3xl_vfb.js.map +1 -0
- package/dist/_chunks/segment-classify-BDNn6EzD.js +65 -0
- package/dist/_chunks/segment-classify-BDNn6EzD.js.map +1 -0
- package/dist/_chunks/segment-context-fHFLF1PE.js +34 -0
- package/dist/_chunks/segment-context-fHFLF1PE.js.map +1 -0
- package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-DzuI0bIV.js} +1 -1
- package/dist/_chunks/{ssr-data-MjmprTmO.js.map → ssr-data-DzuI0bIV.js.map} +1 -1
- package/dist/_chunks/stale-reload-BX5gL1r-.js +64 -0
- package/dist/_chunks/stale-reload-BX5gL1r-.js.map +1 -0
- package/dist/_chunks/{tracing-CemImE6h.js → tracing-CCYbKn5n.js} +60 -9
- package/dist/_chunks/tracing-CCYbKn5n.js.map +1 -0
- package/dist/_chunks/use-params-Br9YSUFV.js +295 -0
- package/dist/_chunks/use-params-Br9YSUFV.js.map +1 -0
- package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-BiV5GJgm.js} +7 -4
- package/dist/_chunks/use-query-states-BiV5GJgm.js.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 +73 -0
- package/dist/adapters/cloudflare-dev.js.map +1 -0
- package/dist/adapters/cloudflare-kv-cache.d.ts +64 -0
- package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
- package/dist/adapters/cloudflare-kv-cache.js +95 -0
- package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
- package/dist/adapters/cloudflare.d.ts +148 -12
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +135 -11
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/adapters/compress-module.d.ts.map +1 -1
- package/dist/adapters/nitro.d.ts +17 -1
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +56 -13
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/cache/cache-api.d.ts +24 -0
- package/dist/cache/cache-api.d.ts.map +1 -0
- package/dist/cache/handler-store.d.ts +31 -0
- package/dist/cache/handler-store.d.ts.map +1 -0
- package/dist/cache/index.d.ts +23 -7
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +142 -80
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/singleflight.d.ts +18 -1
- 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/timber-cache.d.ts +1 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cli.d.ts +6 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +8 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/browser-dev.d.ts +27 -1
- package/dist/client/browser-dev.d.ts.map +1 -1
- package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
- package/dist/client/browser-entry/action-dispatch.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 +46 -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 +23 -0
- package/dist/client/browser-entry/router-init.d.ts.map +1 -0
- package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
- package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
- package/dist/client/browser-entry/scroll.d.ts +19 -0
- package/dist/client/browser-entry/scroll.d.ts.map +1 -0
- package/dist/client/error-boundary.d.ts +12 -5
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +10 -4
- package/dist/client/error-boundary.js.map +1 -1
- package/dist/client/error-reconstituter.d.ts +54 -0
- package/dist/client/error-reconstituter.d.ts.map +1 -0
- package/dist/client/form.d.ts +6 -3
- package/dist/client/form.d.ts.map +1 -1
- package/dist/client/history.d.ts +19 -4
- package/dist/client/history.d.ts.map +1 -1
- package/dist/client/index.d.ts +9 -21
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +229 -1018
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.d.ts +18 -0
- package/dist/client/internal.d.ts.map +1 -0
- package/dist/client/internal.js +890 -0
- package/dist/client/internal.js.map +1 -0
- package/dist/client/link-pending-store.d.ts +63 -0
- package/dist/client/link-pending-store.d.ts.map +1 -0
- package/dist/client/link.d.ts +62 -55
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/nav-link-store.d.ts +36 -0
- package/dist/client/nav-link-store.d.ts.map +1 -0
- package/dist/client/navigation-api-types.d.ts +90 -0
- package/dist/client/navigation-api-types.d.ts.map +1 -0
- package/dist/client/navigation-api.d.ts +115 -0
- package/dist/client/navigation-api.d.ts.map +1 -0
- package/dist/client/navigation-context.d.ts +13 -2
- package/dist/client/navigation-context.d.ts.map +1 -1
- package/dist/client/{transition-root.d.ts → navigation-root.d.ts} +42 -8
- package/dist/client/navigation-root.d.ts.map +1 -0
- package/dist/client/nuqs-adapter.d.ts.map +1 -1
- package/dist/client/router-ref.d.ts +1 -1
- package/dist/client/router.d.ts +70 -4
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +38 -3
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts +1 -1
- package/dist/client/segment-cache.d.ts.map +1 -1
- package/dist/client/segment-outlet.d.ts +63 -0
- package/dist/client/segment-outlet.d.ts.map +1 -0
- package/dist/client/ssr-data.d.ts +13 -4
- package/dist/client/ssr-data.d.ts.map +1 -1
- package/dist/client/stale-reload.d.ts +15 -0
- package/dist/client/stale-reload.d.ts.map +1 -1
- package/dist/client/top-loader.d.ts +5 -5
- package/dist/client/top-loader.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-params.d.ts +6 -4
- package/dist/client/use-params.d.ts.map +1 -1
- package/dist/client/{use-navigation-pending.d.ts → use-pending-navigation.d.ts} +4 -4
- package/dist/client/use-pending-navigation.d.ts.map +1 -0
- package/dist/client/use-query-states.d.ts +1 -1
- package/dist/client/use-query-states.d.ts.map +1 -1
- package/dist/client/use-router.d.ts +1 -1
- package/dist/codec.d.ts +33 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +2 -0
- package/dist/config-types.d.ts +266 -0
- package/dist/config-types.d.ts.map +1 -0
- package/dist/config-validation.d.ts +51 -0
- package/dist/config-validation.d.ts.map +1 -0
- package/dist/content/index.d.ts +1 -10
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +0 -2
- package/dist/cookies/define-cookie.d.ts +35 -14
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +1 -83
- package/dist/fonts/bundle.d.ts +48 -0
- package/dist/fonts/bundle.d.ts.map +1 -0
- package/dist/fonts/css.d.ts +1 -0
- package/dist/fonts/css.d.ts.map +1 -1
- package/dist/fonts/dev-middleware.d.ts +22 -0
- package/dist/fonts/dev-middleware.d.ts.map +1 -0
- package/dist/fonts/pipeline.d.ts +138 -0
- package/dist/fonts/pipeline.d.ts.map +1 -0
- package/dist/fonts/transform.d.ts +72 -0
- package/dist/fonts/transform.d.ts.map +1 -0
- package/dist/fonts/types.d.ts +45 -1
- package/dist/fonts/types.d.ts.map +1 -1
- package/dist/fonts/virtual-modules.d.ts +59 -0
- package/dist/fonts/virtual-modules.d.ts.map +1 -0
- package/dist/index.d.ts +45 -190
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4294 -2453
- package/dist/index.js.map +1 -1
- package/dist/plugin-context.d.ts +107 -0
- package/dist/plugin-context.d.ts.map +1 -0
- package/dist/plugins/adapter-build.d.ts +1 -1
- package/dist/plugins/adapter-build.d.ts.map +1 -1
- package/dist/plugins/build-manifest.d.ts +2 -2
- package/dist/plugins/build-manifest.d.ts.map +1 -1
- package/dist/plugins/build-report.d.ts +3 -3
- package/dist/plugins/build-report.d.ts.map +1 -1
- package/dist/plugins/client-chunks.d.ts +32 -0
- package/dist/plugins/client-chunks.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-404-page.d.ts +56 -0
- package/dist/plugins/dev-404-page.d.ts.map +1 -0
- package/dist/plugins/dev-browser-logs.d.ts +84 -0
- package/dist/plugins/dev-browser-logs.d.ts.map +1 -0
- package/dist/plugins/dev-error-overlay.d.ts +49 -9
- package/dist/plugins/dev-error-overlay.d.ts.map +1 -1
- package/dist/plugins/dev-error-page.d.ts +58 -0
- package/dist/plugins/dev-error-page.d.ts.map +1 -0
- package/dist/plugins/dev-logs.d.ts +1 -1
- package/dist/plugins/dev-logs.d.ts.map +1 -1
- package/dist/plugins/dev-server.d.ts +1 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/dev-terminal-error.d.ts +28 -0
- package/dist/plugins/dev-terminal-error.d.ts.map +1 -0
- package/dist/plugins/entries.d.ts +1 -1
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/fonts.d.ts +17 -73
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/mdx.d.ts +1 -1
- package/dist/plugins/mdx.d.ts.map +1 -1
- package/dist/plugins/routing.d.ts +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/plugins/server-bundle.d.ts.map +1 -1
- package/dist/plugins/shims.d.ts +6 -5
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts +4 -4
- package/dist/plugins/static-build.d.ts.map +1 -1
- package/dist/routing/codegen-shared.d.ts +38 -0
- package/dist/routing/codegen-shared.d.ts.map +1 -0
- package/dist/routing/codegen-types.d.ts +36 -0
- package/dist/routing/codegen-types.d.ts.map +1 -0
- package/dist/routing/codegen.d.ts +2 -2
- package/dist/routing/codegen.d.ts.map +1 -1
- package/dist/routing/convention-lint.d.ts +41 -0
- package/dist/routing/convention-lint.d.ts.map +1 -0
- package/dist/routing/index.d.ts +2 -0
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +3 -2
- package/dist/routing/link-codegen.d.ts +90 -0
- package/dist/routing/link-codegen.d.ts.map +1 -0
- package/dist/routing/scanner.d.ts.map +1 -1
- package/dist/routing/segment-classify.d.ts +46 -0
- package/dist/routing/segment-classify.d.ts.map +1 -0
- package/dist/routing/status-file-lint.d.ts +2 -1
- package/dist/routing/status-file-lint.d.ts.map +1 -1
- package/dist/routing/types.d.ts +16 -4
- package/dist/routing/types.d.ts.map +1 -1
- 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 +12 -0
- package/dist/rsc-runtime/ssr.d.ts.map +1 -1
- package/dist/schema-bridge.d.ts +76 -0
- package/dist/schema-bridge.d.ts.map +1 -0
- package/dist/search-params/define.d.ts +139 -0
- package/dist/search-params/define.d.ts.map +1 -0
- package/dist/search-params/index.d.ts +4 -7
- package/dist/search-params/index.d.ts.map +1 -1
- package/dist/search-params/index.js +32 -441
- package/dist/search-params/index.js.map +1 -1
- package/dist/search-params/registry.d.ts +2 -2
- package/dist/search-params/registry.d.ts.map +1 -1
- package/dist/search-params/wrappers.d.ts +53 -0
- package/dist/search-params/wrappers.d.ts.map +1 -0
- package/dist/segment-params/define.d.ts +78 -0
- package/dist/segment-params/define.d.ts.map +1 -0
- package/dist/segment-params/index.d.ts +3 -0
- package/dist/segment-params/index.d.ts.map +1 -0
- package/dist/segment-params/index.js +2 -0
- package/dist/server/access-gate.d.ts +4 -0
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/action-client.d.ts +41 -6
- 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 +7 -0
- package/dist/server/action-handler.d.ts.map +1 -1
- package/dist/server/actions.d.ts +3 -6
- package/dist/server/actions.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +32 -4
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/build-manifest.d.ts +2 -2
- package/dist/server/build-manifest.d.ts.map +1 -1
- package/dist/server/debug.d.ts +1 -1
- package/dist/server/default-logger.d.ts +22 -0
- package/dist/server/default-logger.d.ts.map +1 -0
- package/dist/server/deny-page-resolver.d.ts +52 -0
- package/dist/server/deny-page-resolver.d.ts.map +1 -0
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/dev-holding-server.d.ts +52 -0
- package/dist/server/dev-holding-server.d.ts.map +1 -0
- package/dist/server/dev-source-map.d.ts +22 -0
- package/dist/server/dev-source-map.d.ts.map +1 -0
- package/dist/server/dev-warnings.d.ts +1 -21
- package/dist/server/dev-warnings.d.ts.map +1 -1
- package/dist/server/early-hints.d.ts +13 -5
- package/dist/server/early-hints.d.ts.map +1 -1
- package/dist/server/error-boundary-wrapper.d.ts +7 -1
- package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
- package/dist/server/fallback-error.d.ts +12 -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 +42 -0
- package/dist/server/flight-scripts.d.ts.map +1 -0
- package/dist/server/flush.d.ts.map +1 -1
- package/dist/server/form-data.d.ts +29 -0
- package/dist/server/form-data.d.ts.map +1 -1
- package/dist/server/html-injectors.d.ts +51 -11
- package/dist/server/html-injectors.d.ts.map +1 -1
- package/dist/server/index.d.ts +5 -43
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +195 -2800
- package/dist/server/index.js.map +1 -1
- package/dist/server/internal.d.ts +46 -0
- package/dist/server/internal.d.ts.map +1 -0
- package/dist/server/internal.js +2900 -0
- package/dist/server/internal.js.map +1 -0
- package/dist/server/logger.d.ts +25 -7
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/middleware-runner.d.ts +19 -4
- package/dist/server/middleware-runner.d.ts.map +1 -1
- package/dist/server/node-stream-transforms.d.ts +113 -0
- package/dist/server/node-stream-transforms.d.ts.map +1 -0
- package/dist/server/page-deny-boundary.d.ts +31 -0
- package/dist/server/page-deny-boundary.d.ts.map +1 -0
- package/dist/server/pipeline-interception.d.ts +1 -1
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline-metadata.d.ts +6 -0
- package/dist/server/pipeline-metadata.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +52 -10
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +69 -18
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/render-timeout.d.ts +51 -0
- package/dist/server/render-timeout.d.ts.map +1 -0
- package/dist/server/request-context.d.ts +112 -43
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts +27 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +16 -2
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts +2 -2
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +48 -5
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts +20 -3
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +14 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
- package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +19 -4
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/safe-load.d.ts +46 -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/sitemap-generator.d.ts +129 -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/slot-resolver.d.ts +1 -1
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts +23 -0
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/server/ssr-render.d.ts +39 -21
- package/dist/server/ssr-render.d.ts.map +1 -1
- package/dist/server/ssr-wrappers.d.ts +50 -0
- package/dist/server/ssr-wrappers.d.ts.map +1 -0
- package/dist/server/status-code-resolver.d.ts +1 -1
- package/dist/server/status-code-resolver.d.ts.map +1 -1
- package/dist/server/stream-utils.d.ts +36 -0
- package/dist/server/stream-utils.d.ts.map +1 -0
- package/dist/server/tracing.d.ts +4 -4
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/tree-builder.d.ts +22 -19
- package/dist/server/tree-builder.d.ts.map +1 -1
- package/dist/server/types.d.ts +1 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/version-skew.d.ts +61 -0
- package/dist/server/version-skew.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/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 +2 -1
- package/dist/shims/headers.d.ts.map +1 -1
- package/dist/shims/navigation-client.d.ts +1 -1
- package/dist/shims/navigation-client.d.ts.map +1 -1
- package/dist/shims/navigation.d.ts +3 -2
- package/dist/shims/navigation.d.ts.map +1 -1
- package/dist/utils/directive-parser.d.ts +5 -2
- package/dist/utils/directive-parser.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/package.json +51 -16
- package/src/adapters/cloudflare-dev.ts +177 -0
- package/src/adapters/cloudflare-kv-cache.ts +142 -0
- package/src/adapters/cloudflare.ts +342 -28
- package/src/adapters/compress-module.ts +24 -4
- package/src/adapters/nitro.ts +52 -8
- package/src/adapters/wrangler.d.ts +7 -0
- package/src/cache/cache-api.ts +38 -0
- package/src/cache/handler-store.ts +68 -0
- package/src/cache/index.ts +81 -18
- package/src/cache/singleflight.ts +62 -4
- package/src/cache/sizeof.ts +31 -0
- package/src/cache/timber-cache.ts +24 -20
- package/src/cli.ts +16 -6
- package/src/client/browser-dev.ts +128 -1
- package/src/client/browser-entry/action-dispatch.ts +116 -0
- package/src/client/browser-entry/hmr.ts +81 -0
- package/src/client/browser-entry/hydrate.ts +145 -0
- package/src/client/browser-entry/index.ts +143 -0
- package/src/client/browser-entry/post-hydration.ts +119 -0
- package/src/client/browser-entry/router-init.ts +193 -0
- package/src/client/browser-entry/rsc-stream.ts +157 -0
- package/src/client/browser-entry/scroll.ts +27 -0
- package/src/client/error-boundary.tsx +48 -16
- package/src/client/error-reconstituter.tsx +65 -0
- package/src/client/form.tsx +14 -7
- package/src/client/history.ts +26 -4
- package/src/client/index.ts +65 -38
- package/src/client/internal.ts +57 -0
- package/src/client/link-pending-store.ts +111 -0
- package/src/client/link.tsx +342 -113
- package/src/client/nav-link-store.ts +47 -0
- package/src/client/navigation-api-types.ts +112 -0
- package/src/client/navigation-api.ts +332 -0
- package/src/client/navigation-context.ts +31 -6
- package/src/client/navigation-root.tsx +342 -0
- package/src/client/nuqs-adapter.tsx +16 -3
- package/src/client/router-ref.ts +1 -1
- package/src/client/router.ts +299 -72
- package/src/client/rsc-fetch.ts +97 -8
- package/src/client/segment-cache.ts +1 -1
- package/src/client/segment-outlet.tsx +86 -0
- package/src/client/ssr-data.ts +13 -5
- package/src/client/stale-reload.ts +72 -3
- package/src/client/top-loader.tsx +18 -6
- package/src/client/use-link-status.ts +7 -7
- package/src/client/use-params.ts +7 -5
- package/src/client/{use-navigation-pending.ts → use-pending-navigation.ts} +6 -6
- package/src/client/use-query-states.ts +9 -3
- package/src/client/use-router.ts +1 -1
- package/src/codec.ts +49 -0
- package/src/config-types.ts +264 -0
- package/src/config-validation.ts +303 -0
- package/src/content/index.ts +5 -13
- package/src/cookies/define-cookie.ts +78 -25
- package/src/cookies/index.ts +8 -0
- package/src/fonts/bundle.ts +142 -0
- package/src/fonts/css.ts +2 -1
- package/src/fonts/dev-middleware.ts +74 -0
- package/src/fonts/pipeline.ts +275 -0
- package/src/fonts/transform.ts +353 -0
- package/src/fonts/types.ts +50 -1
- package/src/fonts/virtual-modules.ts +159 -0
- package/src/index.ts +314 -355
- package/src/plugin-context.ts +240 -0
- package/src/plugins/adapter-build.ts +9 -3
- package/src/plugins/build-manifest.ts +13 -2
- package/src/plugins/build-report.ts +3 -3
- package/src/plugins/client-chunks.ts +65 -0
- package/src/plugins/content.ts +1 -1
- package/src/plugins/dev-404-page.ts +418 -0
- package/src/plugins/dev-browser-logs.ts +288 -0
- package/src/plugins/dev-error-overlay.ts +286 -42
- package/src/plugins/dev-error-page.ts +536 -0
- package/src/plugins/dev-logs.ts +1 -1
- package/src/plugins/dev-server.ts +146 -19
- package/src/plugins/dev-terminal-error.ts +217 -0
- package/src/plugins/entries.ts +111 -10
- package/src/plugins/fonts.ts +133 -638
- package/src/plugins/mdx.ts +1 -1
- package/src/plugins/routing.ts +213 -31
- package/src/plugins/server-action-exports.ts +1 -1
- package/src/plugins/server-bundle.ts +32 -1
- package/src/plugins/shims.ts +136 -35
- package/src/plugins/static-build.ts +17 -11
- package/src/routing/codegen-shared.ts +74 -0
- package/src/routing/codegen-types.ts +37 -0
- package/src/routing/codegen.ts +112 -173
- package/src/routing/convention-lint.ts +356 -0
- package/src/routing/index.ts +2 -0
- package/src/routing/link-codegen.ts +262 -0
- package/src/routing/scanner.ts +93 -23
- package/src/routing/segment-classify.ts +89 -0
- package/src/routing/status-file-lint.ts +3 -2
- package/src/routing/types.ts +17 -4
- package/src/rsc-runtime/rsc.ts +2 -0
- package/src/rsc-runtime/ssr.ts +50 -0
- package/src/rsc-runtime/vendor-types.d.ts +7 -0
- package/src/{search-params/codecs.ts → schema-bridge.ts} +57 -20
- package/src/search-params/define.ts +482 -0
- package/src/search-params/index.ts +14 -20
- package/src/search-params/registry.ts +2 -2
- package/src/search-params/wrappers.ts +85 -0
- package/src/segment-params/define.ts +279 -0
- package/src/segment-params/index.ts +9 -0
- package/src/server/access-gate.tsx +70 -29
- package/src/server/action-client.ts +88 -15
- package/src/server/action-encryption.ts +144 -0
- package/src/server/action-handler.ts +53 -6
- package/src/server/actions.ts +10 -9
- package/src/server/als-registry.ts +34 -6
- package/src/server/build-manifest.ts +10 -4
- package/src/server/compress.ts +25 -7
- package/src/server/debug.ts +1 -1
- package/src/server/default-logger.ts +99 -0
- package/src/server/deny-page-resolver.ts +154 -0
- package/src/server/deny-renderer.ts +24 -38
- package/src/server/dev-holding-server.ts +185 -0
- package/src/server/dev-source-map.ts +31 -0
- package/src/server/dev-warnings.ts +4 -49
- package/src/server/early-hints.ts +36 -15
- package/src/server/error-boundary-wrapper.ts +74 -22
- package/src/server/fallback-error.ts +74 -102
- package/src/server/flight-injection-state.ts +113 -0
- package/src/server/flight-scripts.ts +62 -0
- package/src/server/flush.ts +2 -1
- package/src/server/form-data.ts +76 -0
- package/src/server/html-injectors.ts +280 -120
- package/src/server/index.ts +25 -177
- package/src/server/internal.ts +169 -0
- package/src/server/logger.ts +44 -36
- package/src/server/middleware-runner.ts +31 -4
- package/src/server/node-stream-transforms.ts +509 -0
- package/src/server/page-deny-boundary.tsx +56 -0
- package/src/server/pipeline-interception.ts +17 -16
- package/src/server/pipeline-metadata.ts +13 -0
- package/src/server/pipeline.ts +261 -66
- package/src/server/primitives.ts +111 -28
- package/src/server/render-timeout.ts +108 -0
- package/src/server/request-context.ts +293 -132
- package/src/server/route-element-builder.ts +283 -191
- package/src/server/route-handler.ts +24 -4
- package/src/server/route-matcher.ts +31 -20
- package/src/server/rsc-entry/api-handler.ts +15 -16
- package/src/server/rsc-entry/error-renderer.ts +305 -89
- package/src/server/rsc-entry/helpers.ts +134 -5
- package/src/server/rsc-entry/index.ts +304 -111
- package/src/server/rsc-entry/rsc-payload.ts +65 -18
- package/src/server/rsc-entry/rsc-stream.ts +81 -13
- package/src/server/rsc-entry/ssr-bridge.ts +14 -5
- package/src/server/rsc-entry/ssr-renderer.ts +171 -38
- package/src/server/safe-load.ts +60 -0
- package/src/server/sensitive-fields.ts +230 -0
- package/src/server/sitemap-generator.ts +338 -0
- package/src/server/sitemap-handler.ts +126 -0
- package/src/server/slot-resolver.ts +244 -229
- package/src/server/ssr-entry.ts +215 -32
- package/src/server/ssr-render.ts +289 -67
- package/src/server/ssr-wrappers.tsx +139 -0
- package/src/server/status-code-resolver.ts +1 -1
- package/src/server/stream-utils.ts +213 -0
- package/src/server/tracing.ts +20 -9
- package/src/server/tree-builder.ts +92 -58
- package/src/server/types.ts +3 -6
- package/src/server/version-skew.ts +104 -0
- package/src/shared/merge-search-params.ts +55 -0
- package/src/shims/font-google.ts +1 -1
- package/src/shims/font-local.ts +34 -0
- package/src/shims/headers.ts +5 -1
- package/src/shims/navigation-client.ts +1 -1
- package/src/shims/navigation.ts +7 -2
- package/src/utils/directive-parser.ts +5 -2
- package/src/utils/state-machine.ts +111 -0
- package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
- package/dist/_chunks/debug-gwlJkDuf.js.map +0 -1
- package/dist/_chunks/format-DviM89f0.js.map +0 -1
- package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
- package/dist/_chunks/request-context-DIkVh_jG.js +0 -330
- package/dist/_chunks/request-context-DIkVh_jG.js.map +0 -1
- 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.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/link-status-provider.d.ts +0 -11
- package/dist/client/link-status-provider.d.ts.map +0 -1
- package/dist/client/transition-root.d.ts.map +0 -1
- package/dist/client/use-navigation-pending.d.ts.map +0 -1
- package/dist/cookies/index.js.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/dynamic-transform.d.ts +0 -72
- package/dist/plugins/dynamic-transform.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/server/prerender.d.ts +0 -77
- package/dist/server/prerender.d.ts.map +0 -1
- package/dist/server/response-cache.d.ts +0 -54
- package/dist/server/response-cache.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/link-status-provider.tsx +0 -30
- package/src/client/transition-root.tsx +0 -166
- package/src/plugins/cache-transform.ts +0 -199
- package/src/plugins/dynamic-transform.ts +0 -161
- package/src/search-params/analyze.ts +0 -192
- package/src/search-params/builtin-codecs.ts +0 -228
- package/src/search-params/create.ts +0 -321
- package/src/server/prerender.ts +0 -139
- package/src/server/response-cache.ts +0 -410
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* timber-static-build — Vite sub-plugin for static output mode.
|
|
3
3
|
*
|
|
4
4
|
* When `output: 'static'` is set in timber.config.ts, this plugin:
|
|
5
|
-
* 1. Validates that no dynamic APIs (
|
|
5
|
+
* 1. Validates that no dynamic APIs (getCookies(), getHeaders()) are used
|
|
6
6
|
* 2. When client JavaScript is disabled, rejects 'use client' and 'use server' directives
|
|
7
7
|
* 3. Coordinates build-time rendering of all pages
|
|
8
8
|
*
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type { Plugin } from 'vite';
|
|
13
|
-
import type { PluginContext } from '
|
|
14
|
-
import { detectFileDirective } from '
|
|
13
|
+
import type { PluginContext } from '../plugin-context.js';
|
|
14
|
+
import { detectFileDirective } from '../utils/directive-parser.js';
|
|
15
15
|
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
17
|
// Types
|
|
@@ -29,7 +29,7 @@ export interface StaticOptions {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// ---------------------------------------------------------------------------
|
|
32
|
-
// Detection: dynamic APIs (
|
|
32
|
+
// Detection: dynamic APIs (getCookies, getHeaders, and legacy cookies/headers)
|
|
33
33
|
// ---------------------------------------------------------------------------
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -39,12 +39,14 @@ export interface StaticOptions {
|
|
|
39
39
|
* We detect both import-level and call-level usage.
|
|
40
40
|
*/
|
|
41
41
|
const DYNAMIC_API_PATTERNS: Array<{ pattern: RegExp; name: string }> = [
|
|
42
|
+
{ pattern: /\bgetCookies\s*\(/, name: 'getCookies()' },
|
|
43
|
+
{ pattern: /\bgetHeaders\s*\(/, name: 'getHeaders()' },
|
|
42
44
|
{ pattern: /\bcookies\s*\(/, name: 'cookies()' },
|
|
43
45
|
{ pattern: /\bheaders\s*\(/, name: 'headers()' },
|
|
44
46
|
];
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
|
-
* Detect usage of dynamic per-request APIs (
|
|
49
|
+
* Detect usage of dynamic per-request APIs (getCookies(), getHeaders())
|
|
48
50
|
* that cannot work at build time in static mode.
|
|
49
51
|
*
|
|
50
52
|
* Returns an array of validation errors.
|
|
@@ -134,7 +136,7 @@ export function detectDirectives(
|
|
|
134
136
|
* Run all static mode validations on a source file.
|
|
135
137
|
*
|
|
136
138
|
* Combines:
|
|
137
|
-
* - Dynamic API detection (
|
|
139
|
+
* - Dynamic API detection (getCookies, getHeaders) — always in static mode
|
|
138
140
|
* - Directive detection ('use client', 'use server') — only when client JS is disabled
|
|
139
141
|
*/
|
|
140
142
|
export function validateStaticMode(
|
|
@@ -163,9 +165,6 @@ export function validateStaticMode(
|
|
|
163
165
|
* - transform: Validates source files for static mode violations
|
|
164
166
|
*/
|
|
165
167
|
export function timberStaticBuild(ctx: PluginContext): Plugin {
|
|
166
|
-
const isStatic = ctx.config.output === 'static';
|
|
167
|
-
const clientJavascriptDisabled = ctx.clientJavascript.disabled;
|
|
168
|
-
|
|
169
168
|
return {
|
|
170
169
|
name: 'timber-static-build',
|
|
171
170
|
|
|
@@ -173,10 +172,15 @@ export function timberStaticBuild(ctx: PluginContext): Plugin {
|
|
|
173
172
|
* Validate source files during transform.
|
|
174
173
|
*
|
|
175
174
|
* In static mode, we check every app/ file for:
|
|
176
|
-
* - Dynamic API usage (
|
|
175
|
+
* - Dynamic API usage (getCookies(), getHeaders()) → build error
|
|
177
176
|
* - When client JS disabled: 'use client' / 'use server' directives → build error
|
|
178
177
|
*/
|
|
179
178
|
transform(code: string, id: string) {
|
|
179
|
+
// Read ctx.config lazily inside the hook — not at plugin construction
|
|
180
|
+
// time — so file-based config from timber.config.ts is respected.
|
|
181
|
+
// See TIM-451.
|
|
182
|
+
const isStatic = ctx.config.output === 'static';
|
|
183
|
+
|
|
180
184
|
// Only active in static mode
|
|
181
185
|
if (!isStatic) return null;
|
|
182
186
|
|
|
@@ -189,7 +193,9 @@ export function timberStaticBuild(ctx: PluginContext): Plugin {
|
|
|
189
193
|
// Only check JS/TS files
|
|
190
194
|
if (!/\.[jt]sx?$/.test(id)) return null;
|
|
191
195
|
|
|
192
|
-
const errors = validateStaticMode(code, id, {
|
|
196
|
+
const errors = validateStaticMode(code, id, {
|
|
197
|
+
clientJavascriptDisabled: ctx.clientJavascript.disabled,
|
|
198
|
+
});
|
|
193
199
|
|
|
194
200
|
if (errors.length > 0) {
|
|
195
201
|
// Format all errors into a single build error message
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared codegen helpers — import-path computation, codec chain type
|
|
3
|
+
* builder, and searchParams type formatter.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `codegen.ts` so `link-codegen.ts` can use the same
|
|
6
|
+
* helpers without a cyclic import.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { relative, posix } from 'node:path';
|
|
10
|
+
import type { ParamEntry, RouteEntry } from './codegen-types.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Compute a relative import specifier for a codec/page file, stripping
|
|
14
|
+
* the .ts/.tsx extension and resolving against the codegen output dir.
|
|
15
|
+
*/
|
|
16
|
+
export function codecImportPath(codecFilePath: string, importBase: string | undefined): string {
|
|
17
|
+
const absPath = codecFilePath.replace(/\.(ts|tsx)$/, '');
|
|
18
|
+
if (importBase) {
|
|
19
|
+
return './' + relative(importBase, absPath).replace(/\\/g, '/');
|
|
20
|
+
}
|
|
21
|
+
return './' + posix.basename(absPath);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Build a TypeScript type expression that resolves a single param's
|
|
26
|
+
* codec by walking a chain of params.ts files in priority order.
|
|
27
|
+
*
|
|
28
|
+
* Each entry in the chain emits a conditional:
|
|
29
|
+
* `(typeof import(file))['segmentParams'] extends ParamsDefinition<infer T>
|
|
30
|
+
* ? K extends keyof T ? T[K] : <next>
|
|
31
|
+
* : <next>`
|
|
32
|
+
*
|
|
33
|
+
* The closest match (position 0 in the chain) is checked first; if its
|
|
34
|
+
* `segmentParams` definition declares the key, its inferred type wins.
|
|
35
|
+
* Otherwise we fall through to the next ancestor, and finally to the
|
|
36
|
+
* provided fallback. See TIM-834.
|
|
37
|
+
*/
|
|
38
|
+
export function buildCodecChainType(
|
|
39
|
+
p: ParamEntry,
|
|
40
|
+
importBase: string | undefined,
|
|
41
|
+
fallback: string
|
|
42
|
+
): string {
|
|
43
|
+
const files = p.codecFilePaths;
|
|
44
|
+
if (!files || files.length === 0) return fallback;
|
|
45
|
+
const key = JSON.stringify(p.name);
|
|
46
|
+
// Build the nested conditional from the inside out so the closest
|
|
47
|
+
// entry (files[0]) ends up as the OUTERMOST check.
|
|
48
|
+
let inner = fallback;
|
|
49
|
+
for (let i = files.length - 1; i >= 0; i--) {
|
|
50
|
+
const importPath = codecImportPath(files[i], importBase);
|
|
51
|
+
inner =
|
|
52
|
+
`((typeof import('${importPath}'))['segmentParams'] extends ` +
|
|
53
|
+
`import('@timber-js/app/segment-params').ParamsDefinition<infer T> ` +
|
|
54
|
+
`? (${key} extends keyof T ? T[${key}] : ${inner}) : ${inner})`;
|
|
55
|
+
}
|
|
56
|
+
return inner;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Format the searchParams type for a route entry.
|
|
61
|
+
*
|
|
62
|
+
* When a page.tsx (or params.ts) exports searchParams, we reference its
|
|
63
|
+
* inferred type via an import type. The import path is relative to
|
|
64
|
+
* `importBase` (the directory where the .d.ts will be written). When
|
|
65
|
+
* importBase is undefined, falls back to a bare relative path.
|
|
66
|
+
*/
|
|
67
|
+
export function formatSearchParamsType(route: RouteEntry, importBase?: string): string {
|
|
68
|
+
if (route.hasSearchParams && route.searchParamsPagePath) {
|
|
69
|
+
const importPath = codecImportPath(route.searchParamsPagePath, importBase);
|
|
70
|
+
// Extract the type from the named 'searchParams' export of the page module.
|
|
71
|
+
return `(typeof import('${importPath}'))['searchParams'] extends import('@timber-js/app/search-params').SearchParamsDefinition<infer T> ? T : never`;
|
|
72
|
+
}
|
|
73
|
+
return '{}';
|
|
74
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for route codegen modules.
|
|
3
|
+
*
|
|
4
|
+
* Lives in its own file so `link-codegen.ts` and `codegen.ts` can import
|
|
5
|
+
* the same `RouteEntry` / `ParamEntry` shapes without a cyclic
|
|
6
|
+
* dependency between the two.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** A single route entry extracted from the segment tree. */
|
|
10
|
+
export interface RouteEntry {
|
|
11
|
+
/** URL path pattern (e.g. "/products/[id]") */
|
|
12
|
+
urlPath: string;
|
|
13
|
+
/** Accumulated params from all ancestor dynamic segments */
|
|
14
|
+
params: ParamEntry[];
|
|
15
|
+
/** Whether the page.tsx exports searchParams */
|
|
16
|
+
hasSearchParams: boolean;
|
|
17
|
+
/** Absolute path to the page file that exports searchParams (for import paths) */
|
|
18
|
+
searchParamsPagePath?: string;
|
|
19
|
+
/** Whether this is an API route (route.ts) vs page route */
|
|
20
|
+
isApiRoute: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ParamEntry {
|
|
24
|
+
name: string;
|
|
25
|
+
type: 'string' | 'string[]' | 'string[] | undefined';
|
|
26
|
+
/**
|
|
27
|
+
* Ordered list of params.ts (or layout/page) files that may declare a
|
|
28
|
+
* codec for this param, in priority order — closest match first.
|
|
29
|
+
*
|
|
30
|
+
* Position 0 is the segment's own params.ts (if present and exporting
|
|
31
|
+
* `segmentParams`); subsequent entries are ancestor params.ts files
|
|
32
|
+
* walking from closest ancestor up to the route root. The first entry
|
|
33
|
+
* in the chain whose `segmentParams` definition declares this param key
|
|
34
|
+
* wins. See TIM-834.
|
|
35
|
+
*/
|
|
36
|
+
codecFilePaths?: string[];
|
|
37
|
+
}
|
package/src/routing/codegen.ts
CHANGED
|
@@ -8,36 +8,19 @@
|
|
|
8
8
|
* No runtime overhead — purely static type generation.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { existsSync } from 'node:fs';
|
|
12
|
-
import { join, relative, posix } from 'node:path';
|
|
11
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
13
12
|
import type { RouteTree, SegmentNode } from './types.js';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** URL path pattern (e.g. "/products/[id]") */
|
|
18
|
-
urlPath: string;
|
|
19
|
-
/** Accumulated params from all ancestor dynamic segments */
|
|
20
|
-
params: ParamEntry[];
|
|
21
|
-
/** Whether this route has a co-located search-params.ts */
|
|
22
|
-
hasSearchParams: boolean;
|
|
23
|
-
/** Absolute path to search-params.ts (for computing relative import paths) */
|
|
24
|
-
searchParamsAbsPath?: string;
|
|
25
|
-
/** Whether this is an API route (route.ts) vs page route */
|
|
26
|
-
isApiRoute: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface ParamEntry {
|
|
30
|
-
name: string;
|
|
31
|
-
type: 'string' | 'string[]' | 'string[] | undefined';
|
|
32
|
-
}
|
|
13
|
+
import type { ParamEntry, RouteEntry } from './codegen-types.js';
|
|
14
|
+
import { buildCodecChainType, formatSearchParamsType } from './codegen-shared.js';
|
|
15
|
+
import { formatLinkCatchAllOverloads, formatTypedLinkOverloads } from './link-codegen.js';
|
|
33
16
|
|
|
34
17
|
/** Options for route map generation. */
|
|
35
18
|
export interface CodegenOptions {
|
|
36
|
-
/** Absolute path to the app/ directory. Required for
|
|
19
|
+
/** Absolute path to the app/ directory. Required for page searchParams detection. */
|
|
37
20
|
appDir?: string;
|
|
38
21
|
/**
|
|
39
22
|
* Absolute path to the directory where the .d.ts file will be written.
|
|
40
|
-
* Used to compute correct relative import paths for
|
|
23
|
+
* Used to compute correct relative import paths for page files.
|
|
41
24
|
* Defaults to appDir when not provided (preserves backward compat for tests).
|
|
42
25
|
*/
|
|
43
26
|
outputDir?: string;
|
|
@@ -51,7 +34,7 @@ export interface CodegenOptions {
|
|
|
51
34
|
*/
|
|
52
35
|
export function generateRouteMap(tree: RouteTree, options: CodegenOptions = {}): string {
|
|
53
36
|
const routes: RouteEntry[] = [];
|
|
54
|
-
collectRoutes(tree.root, [],
|
|
37
|
+
collectRoutes(tree.root, [], [], routes);
|
|
55
38
|
|
|
56
39
|
// Sort routes alphabetically for deterministic output
|
|
57
40
|
routes.sort((a, b) => a.urlPath.localeCompare(b.urlPath));
|
|
@@ -71,18 +54,47 @@ export function generateRouteMap(tree: RouteTree, options: CodegenOptions = {}):
|
|
|
71
54
|
function collectRoutes(
|
|
72
55
|
node: SegmentNode,
|
|
73
56
|
ancestorParams: ParamEntry[],
|
|
74
|
-
|
|
57
|
+
ancestorParamsFiles: string[],
|
|
75
58
|
routes: RouteEntry[]
|
|
76
59
|
): void {
|
|
60
|
+
// TIM-834: Identify this segment's own params.ts (if it has a
|
|
61
|
+
// segmentParams export). Ancestor params.ts files are inherited by
|
|
62
|
+
// descendant dynamic segments — closest-wins.
|
|
63
|
+
const ownParamsFile =
|
|
64
|
+
node.params && fileHasExport(node.params.filePath, 'segmentParams')
|
|
65
|
+
? node.params.filePath
|
|
66
|
+
: undefined;
|
|
67
|
+
|
|
77
68
|
// Accumulate params from this segment
|
|
78
69
|
const params = [...ancestorParams];
|
|
79
70
|
if (node.paramName) {
|
|
71
|
+
// Build the codec lookup chain in priority order: own segment first,
|
|
72
|
+
// then ancestor params.ts files closest-to-this-segment first. The
|
|
73
|
+
// generated type emits a nested conditional that picks the first
|
|
74
|
+
// entry in the chain whose `segmentParams` declares this key.
|
|
75
|
+
const codecFilePaths: string[] = [];
|
|
76
|
+
if (ownParamsFile) codecFilePaths.push(ownParamsFile);
|
|
77
|
+
for (let i = ancestorParamsFiles.length - 1; i >= 0; i--) {
|
|
78
|
+
codecFilePaths.push(ancestorParamsFiles[i]);
|
|
79
|
+
}
|
|
80
|
+
// Legacy fallback: layout/page export — only for the OWN segment.
|
|
81
|
+
// Inheritance does not extend to legacy layout/page exports.
|
|
82
|
+
if (codecFilePaths.length === 0) {
|
|
83
|
+
const legacy = findLegacyParamsExport(node);
|
|
84
|
+
if (legacy) codecFilePaths.push(legacy);
|
|
85
|
+
}
|
|
80
86
|
params.push({
|
|
81
87
|
name: node.paramName,
|
|
82
88
|
type: paramTypeForSegment(node.segmentType),
|
|
89
|
+
codecFilePaths: codecFilePaths.length > 0 ? codecFilePaths : undefined,
|
|
83
90
|
});
|
|
84
91
|
}
|
|
85
92
|
|
|
93
|
+
// Extend the ancestor chain for descendants of this segment.
|
|
94
|
+
const nextAncestorFiles = ownParamsFile
|
|
95
|
+
? [...ancestorParamsFiles, ownParamsFile]
|
|
96
|
+
: ancestorParamsFiles;
|
|
97
|
+
|
|
86
98
|
// Check if this segment is a leaf route (has page or route file)
|
|
87
99
|
const isPage = !!node.page;
|
|
88
100
|
const isApiRoute = !!node.route;
|
|
@@ -95,13 +107,14 @@ function collectRoutes(
|
|
|
95
107
|
isApiRoute,
|
|
96
108
|
};
|
|
97
109
|
|
|
98
|
-
// Detect
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
const searchParamsFile = findSearchParamsFile(segmentDir);
|
|
102
|
-
if (searchParamsFile) {
|
|
110
|
+
// Detect searchParams export from params.ts (primary) or page.tsx (fallback)
|
|
111
|
+
if (isPage) {
|
|
112
|
+
if (node.params && fileHasExport(node.params.filePath, 'searchParams')) {
|
|
103
113
|
entry.hasSearchParams = true;
|
|
104
|
-
entry.
|
|
114
|
+
entry.searchParamsPagePath = node.params.filePath;
|
|
115
|
+
} else if (node.page && fileHasExport(node.page.filePath, 'searchParams')) {
|
|
116
|
+
entry.hasSearchParams = true;
|
|
117
|
+
entry.searchParamsPagePath = node.page.filePath;
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
120
|
|
|
@@ -110,12 +123,12 @@ function collectRoutes(
|
|
|
110
123
|
|
|
111
124
|
// Recurse into children
|
|
112
125
|
for (const child of node.children) {
|
|
113
|
-
collectRoutes(child, params,
|
|
126
|
+
collectRoutes(child, params, nextAncestorFiles, routes);
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
// Recurse into slots (they share the parent's URL path, but may have their own pages)
|
|
117
130
|
for (const [, slot] of node.slots) {
|
|
118
|
-
collectRoutes(slot, params,
|
|
131
|
+
collectRoutes(slot, params, nextAncestorFiles, routes);
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
134
|
|
|
@@ -134,33 +147,38 @@ function paramTypeForSegment(segmentType: string): ParamEntry['type'] {
|
|
|
134
147
|
}
|
|
135
148
|
|
|
136
149
|
/**
|
|
137
|
-
*
|
|
150
|
+
* Check if a file exports a specific named export.
|
|
138
151
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
152
|
+
* Uses a lightweight regex check — not full AST parsing. The actual type
|
|
153
|
+
* extraction happens via the TypeScript compiler in the generated .d.ts.
|
|
141
154
|
*/
|
|
142
|
-
function
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
function fileHasExport(filePath: string, exportName: string): boolean {
|
|
156
|
+
if (!existsSync(filePath)) return false;
|
|
157
|
+
try {
|
|
158
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
159
|
+
const e = exportName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
160
|
+
return (
|
|
161
|
+
new RegExp(`export\\s+(const|let|var)\\s+${e}\\b`).test(content) ||
|
|
162
|
+
new RegExp(`export\\s*\\{[^}]*\\b${e}\\b[^}]*\\}`).test(content)
|
|
163
|
+
);
|
|
164
|
+
} catch {
|
|
165
|
+
return false;
|
|
150
166
|
}
|
|
151
|
-
// Fallback: construct from urlPath (imprecise for groups, but acceptable)
|
|
152
|
-
return appDir;
|
|
153
167
|
}
|
|
154
168
|
|
|
155
169
|
/**
|
|
156
|
-
* Find a
|
|
170
|
+
* Find a legacy `segmentParams` export on layout.tsx or page.tsx.
|
|
171
|
+
*
|
|
172
|
+
* Backward-compat shim: TIM-508 made params.ts the canonical location
|
|
173
|
+
* for `segmentParams`. Layout/page exports are still accepted for the
|
|
174
|
+
* OWN segment only (not inherited by descendants — see TIM-834).
|
|
157
175
|
*/
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
176
|
+
function findLegacyParamsExport(node: SegmentNode): string | undefined {
|
|
177
|
+
if (node.layout && fileHasExport(node.layout.filePath, 'segmentParams')) {
|
|
178
|
+
return node.layout.filePath;
|
|
179
|
+
}
|
|
180
|
+
if (node.page && fileHasExport(node.page.filePath, 'segmentParams')) {
|
|
181
|
+
return node.page.filePath;
|
|
164
182
|
}
|
|
165
183
|
return undefined;
|
|
166
184
|
}
|
|
@@ -184,11 +202,11 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
|
|
|
184
202
|
lines.push(' interface Routes {');
|
|
185
203
|
|
|
186
204
|
for (const route of routes) {
|
|
187
|
-
const paramsType = formatParamsType(route.params);
|
|
205
|
+
const paramsType = formatParamsType(route.params, importBase);
|
|
188
206
|
const searchParamsType = formatSearchParamsType(route, importBase);
|
|
189
207
|
|
|
190
208
|
lines.push(` '${route.urlPath}': {`);
|
|
191
|
-
lines.push(`
|
|
209
|
+
lines.push(` segmentParams: ${paramsType}`);
|
|
192
210
|
lines.push(` searchParams: ${searchParamsType}`);
|
|
193
211
|
lines.push(` }`);
|
|
194
212
|
}
|
|
@@ -200,15 +218,9 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
|
|
|
200
218
|
// Generate @timber-js/app/server augmentation — typed searchParams() generic
|
|
201
219
|
const pageRoutes = routes.filter((r) => !r.isApiRoute);
|
|
202
220
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
lines.push(
|
|
207
|
-
" export function searchParams<R extends keyof Routes>(): Promise<Routes[R]['searchParams']>"
|
|
208
|
-
);
|
|
209
|
-
lines.push('}');
|
|
210
|
-
lines.push('');
|
|
211
|
-
}
|
|
221
|
+
// Note: searchParams() always returns Promise<URLSearchParams>.
|
|
222
|
+
// Typed parsing is done via definition.parse(searchParams()).
|
|
223
|
+
// No module augmentation needed for @timber-js/app/server.
|
|
212
224
|
|
|
213
225
|
// Generate overloads for @timber-js/app/client
|
|
214
226
|
const dynamicRoutes = routes.filter((r) => r.params.length > 0);
|
|
@@ -223,10 +235,10 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
|
|
|
223
235
|
// useParams overloads
|
|
224
236
|
if (dynamicRoutes.length > 0) {
|
|
225
237
|
for (const route of dynamicRoutes) {
|
|
226
|
-
const paramsType = formatParamsType(route.params);
|
|
227
|
-
lines.push(` export function
|
|
238
|
+
const paramsType = formatParamsType(route.params, importBase);
|
|
239
|
+
lines.push(` export function useSegmentParams(route: '${route.urlPath}'): ${paramsType}`);
|
|
228
240
|
}
|
|
229
|
-
lines.push(' export function
|
|
241
|
+
lines.push(' export function useSegmentParams(): Record<string, string | string[]>');
|
|
230
242
|
lines.push('');
|
|
231
243
|
}
|
|
232
244
|
|
|
@@ -236,78 +248,57 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
|
|
|
236
248
|
lines.push('');
|
|
237
249
|
}
|
|
238
250
|
|
|
239
|
-
// Typed Link overloads
|
|
251
|
+
// Typed Link overloads — per-route with DIRECT types (no conditionals).
|
|
252
|
+
// Direct types preserve TypeScript's excess property checking.
|
|
253
|
+
//
|
|
254
|
+
// TIM-832: per-route and catch-all are emitted as TWO separate
|
|
255
|
+
// augmentation blocks. Per TS's merging rule "later overload sets
|
|
256
|
+
// ordered first", the catch-all block (declared SECOND in this file)
|
|
257
|
+
// ends up FIRST in the merged call-signature list at resolution time,
|
|
258
|
+
// which puts the per-route block LAST — so its error message is the
|
|
259
|
+
// one TypeScript reports when no overload matches. This gives users a
|
|
260
|
+
// clear prop-mismatch error (e.g. "'string | undefined' is not
|
|
261
|
+
// assignable to 'string | number' on id") instead of the old
|
|
262
|
+
// confusing "Type 'string' is not assignable to type 'never'" cascade.
|
|
240
263
|
if (pageRoutes.length > 0) {
|
|
241
|
-
lines.push(' // Typed Link
|
|
264
|
+
lines.push(' // Typed Link overloads — per-route (block 1 / emitted first)');
|
|
242
265
|
lines.push(...formatTypedLinkOverloads(pageRoutes, importBase));
|
|
266
|
+
lines.push('');
|
|
243
267
|
}
|
|
244
268
|
|
|
245
269
|
lines.push('}');
|
|
246
270
|
lines.push('');
|
|
247
271
|
}
|
|
248
272
|
|
|
273
|
+
// TIM-832: catch-all block — emitted as a SEPARATE `declare module`
|
|
274
|
+
// augmentation so TS's "later overload set first" rule orders it ahead
|
|
275
|
+
// of the per-route block above at resolution time, leaving per-route as
|
|
276
|
+
// the "last overload" whose error TypeScript reports.
|
|
277
|
+
lines.push("declare module '@timber-js/app/client' {");
|
|
278
|
+
lines.push(" import type { SearchParamsDefinition } from '@timber-js/app/search-params'");
|
|
279
|
+
lines.push('');
|
|
280
|
+
lines.push(...formatLinkCatchAllOverloads());
|
|
281
|
+
lines.push('}');
|
|
282
|
+
lines.push('');
|
|
283
|
+
|
|
249
284
|
return lines.join('\n');
|
|
250
285
|
}
|
|
251
286
|
|
|
252
287
|
/**
|
|
253
288
|
* Format the params type for a route entry.
|
|
254
289
|
*/
|
|
255
|
-
function formatParamsType(params: ParamEntry[]): string {
|
|
256
|
-
if (params.length === 0) {
|
|
257
|
-
return '{}';
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const fields = params.map((p) => `${p.name}: ${p.type}`);
|
|
261
|
-
return `{ ${fields.join('; ')} }`;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Format the params type for Link props.
|
|
266
|
-
*
|
|
267
|
-
* Link params accept `string | number` for single dynamic segments
|
|
268
|
-
* (convenience — values are stringified at runtime). Catch-all and
|
|
269
|
-
* optional catch-all remain `string[]` / `string[] | undefined`.
|
|
270
|
-
*
|
|
271
|
-
* See design/07-routing.md §"Typed params and searchParams on <Link>"
|
|
272
|
-
*/
|
|
273
|
-
function formatLinkParamsType(params: ParamEntry[]): string {
|
|
290
|
+
function formatParamsType(params: ParamEntry[], importBase?: string): string {
|
|
274
291
|
if (params.length === 0) {
|
|
275
292
|
return '{}';
|
|
276
293
|
}
|
|
277
294
|
|
|
278
295
|
const fields = params.map((p) => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
return `${p.name}: ${type}`;
|
|
296
|
+
const codecType = buildCodecChainType(p, importBase, p.type);
|
|
297
|
+
return `${p.name}: ${codecType}`;
|
|
282
298
|
});
|
|
283
299
|
return `{ ${fields.join('; ')} }`;
|
|
284
300
|
}
|
|
285
301
|
|
|
286
|
-
/**
|
|
287
|
-
* Format the searchParams type for a route entry.
|
|
288
|
-
*
|
|
289
|
-
* When a search-params.ts exists, we reference its inferred type via an import type.
|
|
290
|
-
* The import path is relative to `importBase` (the directory where the .d.ts will be
|
|
291
|
-
* written). When importBase is undefined, falls back to a bare relative path.
|
|
292
|
-
*/
|
|
293
|
-
function formatSearchParamsType(route: RouteEntry, importBase?: string): string {
|
|
294
|
-
if (route.hasSearchParams && route.searchParamsAbsPath) {
|
|
295
|
-
const absPath = route.searchParamsAbsPath.replace(/\.(ts|tsx)$/, '');
|
|
296
|
-
let importPath: string;
|
|
297
|
-
if (importBase) {
|
|
298
|
-
// Make the path relative to the output directory, converted to posix separators
|
|
299
|
-
importPath = './' + relative(importBase, absPath).replace(/\\/g, '/');
|
|
300
|
-
} else {
|
|
301
|
-
importPath = './' + posix.basename(absPath);
|
|
302
|
-
}
|
|
303
|
-
// Use (typeof import('...'))[' default'] instead of import('...').default
|
|
304
|
-
// because with moduleResolution:"bundler", import('...').default is treated as
|
|
305
|
-
// a namespace member access which doesn't work for default exports.
|
|
306
|
-
return `(typeof import('${importPath}'))['default'] extends import('@timber-js/app/search-params').SearchParamsDefinition<infer T> ? T : never`;
|
|
307
|
-
}
|
|
308
|
-
return '{}';
|
|
309
|
-
}
|
|
310
|
-
|
|
311
302
|
/**
|
|
312
303
|
* Generate useQueryStates overloads.
|
|
313
304
|
*
|
|
@@ -337,60 +328,8 @@ function formatUseQueryStatesOverloads(routes: RouteEntry[], importBase?: string
|
|
|
337
328
|
return lines;
|
|
338
329
|
}
|
|
339
330
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
* - Types the params prop based on dynamic segments
|
|
346
|
-
* - Types the searchParams prop based on search-params.ts (if present)
|
|
347
|
-
*
|
|
348
|
-
* Routes without dynamic segments accept href as a literal string with no params.
|
|
349
|
-
* Routes with dynamic segments require a params prop.
|
|
350
|
-
*/
|
|
351
|
-
function formatTypedLinkOverloads(routes: RouteEntry[], importBase?: string): string[] {
|
|
352
|
-
const lines: string[] = [];
|
|
353
|
-
|
|
354
|
-
for (const route of routes) {
|
|
355
|
-
const hasDynamicParams = route.params.length > 0;
|
|
356
|
-
const paramsType = formatLinkParamsType(route.params);
|
|
357
|
-
const searchParamsType = route.hasSearchParams
|
|
358
|
-
? formatSearchParamsType(route, importBase)
|
|
359
|
-
: null;
|
|
360
|
-
|
|
361
|
-
if (hasDynamicParams) {
|
|
362
|
-
// Route with dynamic segments — params prop required
|
|
363
|
-
const spProp = searchParamsType
|
|
364
|
-
? `searchParams?: { definition: SearchParamsDefinition<${searchParamsType}>; values: Partial<${searchParamsType}> }`
|
|
365
|
-
: `searchParams?: never`;
|
|
366
|
-
lines.push(
|
|
367
|
-
` export function Link(props: Omit<import('react').AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {`
|
|
368
|
-
);
|
|
369
|
-
lines.push(` href: '${route.urlPath}'`);
|
|
370
|
-
lines.push(` params: ${paramsType}`);
|
|
371
|
-
lines.push(` ${spProp}`);
|
|
372
|
-
lines.push(` prefetch?: boolean; scroll?: boolean; children?: import('react').ReactNode`);
|
|
373
|
-
lines.push(` }): import('react').JSX.Element`);
|
|
374
|
-
} else {
|
|
375
|
-
// Static route — no params needed
|
|
376
|
-
const spProp = searchParamsType
|
|
377
|
-
? `searchParams?: { definition: SearchParamsDefinition<${searchParamsType}>; values: Partial<${searchParamsType}> }`
|
|
378
|
-
: `searchParams?: never`;
|
|
379
|
-
lines.push(
|
|
380
|
-
` export function Link(props: Omit<import('react').AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {`
|
|
381
|
-
);
|
|
382
|
-
lines.push(` href: '${route.urlPath}'`);
|
|
383
|
-
lines.push(` params?: never`);
|
|
384
|
-
lines.push(` ${spProp}`);
|
|
385
|
-
lines.push(` prefetch?: boolean; scroll?: boolean; children?: import('react').ReactNode`);
|
|
386
|
-
lines.push(` }): import('react').JSX.Element`);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// Fallback overload for arbitrary string hrefs (escape hatch)
|
|
391
|
-
lines.push(
|
|
392
|
-
` export function Link(props: import('./client/link.js').LinkProps): import('react').JSX.Element`
|
|
393
|
-
);
|
|
394
|
-
|
|
395
|
-
return lines;
|
|
396
|
-
}
|
|
331
|
+
// Link overload formatters and helpers (`formatTypedLinkOverloads`,
|
|
332
|
+
// `formatLinkCatchAllOverloads`, `formatLinkParamsType`,
|
|
333
|
+
// `buildResolvedPattern`, `LINK_BASE_PROPS_TYPE`) were extracted to
|
|
334
|
+
// `./link-codegen.ts` (TIM-835) to keep this file under the 500-line
|
|
335
|
+
// cap. They are imported at the top of this file.
|