vinext 0.0.50 → 0.0.52
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/build/google-fonts/fallback-metrics-data.js +14031 -0
- package/dist/build/google-fonts/fallback-metrics-data.js.map +1 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +13 -0
- package/dist/build/google-fonts/fallback-metrics.js +46 -0
- package/dist/build/google-fonts/fallback-metrics.js.map +1 -0
- package/dist/build/precompress.d.ts +13 -2
- package/dist/build/precompress.js +23 -13
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +4 -15
- package/dist/build/prerender.js +83 -53
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/report.d.ts +5 -4
- package/dist/build/report.js +196 -348
- package/dist/build/report.js.map +1 -1
- package/dist/check.js +5 -0
- package/dist/check.js.map +1 -1
- package/dist/cli-args.d.ts +1 -0
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +99 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +47 -0
- package/dist/client/navigation-runtime.js +156 -0
- package/dist/client/navigation-runtime.js.map +1 -0
- package/dist/client/pages-router-link-navigation.d.ts +26 -0
- package/dist/client/pages-router-link-navigation.js +14 -0
- package/dist/client/pages-router-link-navigation.js.map +1 -0
- package/dist/client/vinext-next-data.d.ts +12 -2
- package/dist/client/vinext-next-data.js +50 -1
- package/dist/client/vinext-next-data.js.map +1 -0
- package/dist/client/window-next.d.ts +3 -1
- package/dist/client/window-next.js.map +1 -1
- package/dist/cloudflare/kv-cache-handler.js +2 -1
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/config/config-matchers.d.ts +63 -16
- package/dist/config/config-matchers.js +143 -8
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.d.ts +11 -1
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +107 -5
- package/dist/config/next-config.js +233 -7
- package/dist/config/next-config.js.map +1 -1
- package/dist/config/tsconfig-paths.d.ts +13 -0
- package/dist/config/tsconfig-paths.js +117 -0
- package/dist/config/tsconfig-paths.js.map +1 -0
- package/dist/deploy.js +104 -41
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +2 -2
- package/dist/entries/app-browser-entry.js +34 -3
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +19 -1
- package/dist/entries/app-rsc-entry.js +89 -23
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +10 -0
- package/dist/entries/app-rsc-manifest.js +57 -7
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +3 -3
- package/dist/entries/app-ssr-entry.js +4 -4
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js +21 -7
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +77 -9
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +2 -1
- package/dist/entries/runtime-entry-module.js +9 -3
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +260 -75
- package/dist/index.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +15 -2
- package/dist/plugins/client-reference-dedup.js +138 -16
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/plugins/css-data-url.d.ts +7 -0
- package/dist/plugins/css-data-url.js +81 -0
- package/dist/plugins/css-data-url.js.map +1 -0
- package/dist/plugins/fonts.d.ts +2 -2
- package/dist/plugins/fonts.js +20 -9
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/middleware-server-only.d.ts +54 -0
- package/dist/plugins/middleware-server-only.js +91 -0
- package/dist/plugins/middleware-server-only.js.map +1 -0
- package/dist/plugins/optimize-imports.js +4 -4
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/sass.d.ts +34 -0
- package/dist/plugins/sass.js +22 -0
- package/dist/plugins/sass.js.map +1 -0
- package/dist/plugins/strip-server-exports.js +5 -8
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +50 -2
- package/dist/routing/app-route-graph.js +140 -16
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/route-pattern.d.ts +56 -1
- package/dist/routing/route-pattern.js +60 -1
- package/dist/routing/route-pattern.js.map +1 -1
- package/dist/routing/utils.d.ts +2 -1
- package/dist/routing/utils.js +4 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +139 -37
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +27 -2
- package/dist/server/app-browser-action-result.js +63 -2
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +493 -195
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-hydration.d.ts +13 -1
- package/dist/server/app-browser-hydration.js +9 -1
- package/dist/server/app-browser-hydration.js.map +1 -1
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +32 -0
- package/dist/server/app-browser-interception-context.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +17 -2
- package/dist/server/app-browser-navigation-controller.js +33 -10
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-popstate.d.ts +16 -0
- package/dist/server/app-browser-popstate.js +17 -0
- package/dist/server/app-browser-popstate.js.map +1 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +29 -0
- package/dist/server/app-browser-rsc-redirect.js +37 -0
- package/dist/server/app-browser-rsc-redirect.js.map +1 -0
- package/dist/server/app-browser-state.d.ts +28 -7
- package/dist/server/app-browser-state.js +63 -27
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +9 -17
- package/dist/server/app-browser-stream.js +18 -13
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +7 -1
- package/dist/server/app-browser-visible-commit.js +39 -5
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +43 -6
- package/dist/server/app-elements-wire.js +189 -7
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +3 -2
- package/dist/server/app-elements.js +3 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +10 -1
- package/dist/server/app-fallback-renderer.js +41 -3
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.d.ts +26 -0
- package/dist/server/app-history-state.js +53 -0
- package/dist/server/app-history-state.js.map +1 -0
- package/dist/server/app-middleware.d.ts +13 -0
- package/dist/server/app-middleware.js +3 -1
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-optimistic-routing.d.ts +54 -0
- package/dist/server/app-optimistic-routing.js +200 -0
- package/dist/server/app-optimistic-routing.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +10 -1
- package/dist/server/app-page-boundary-render.js +13 -6
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.js +3 -2
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +26 -1
- package/dist/server/app-page-cache.js +86 -14
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +7 -0
- package/dist/server/app-page-dispatch.js +96 -12
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +7 -0
- package/dist/server/app-page-element-builder.js +34 -5
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +91 -7
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +7 -0
- package/dist/server/app-page-head.js +23 -3
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +23 -1
- package/dist/server/app-page-probe.js +29 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render-observation.d.ts +35 -0
- package/dist/server/app-page-render-observation.js +68 -0
- package/dist/server/app-page-render-observation.js.map +1 -0
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +81 -4
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +1 -0
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +7 -5
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +3 -1
- package/dist/server/app-page-route-wiring.js +59 -24
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +5 -0
- package/dist/server/app-page-stream.js +2 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +44 -8
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +3 -2
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +6 -1
- package/dist/server/app-route-handler-dispatch.js +1 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +17 -2
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +5 -4
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.js +7 -15
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +19 -1
- package/dist/server/app-rsc-cache-busting.js +36 -1
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-embedded-chunks.d.ts +9 -0
- package/dist/server/app-rsc-embedded-chunks.js +34 -0
- package/dist/server/app-rsc-embedded-chunks.js.map +1 -0
- package/dist/server/app-rsc-errors.d.ts +4 -1
- package/dist/server/app-rsc-errors.js +1 -1
- package/dist/server/app-rsc-errors.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +21 -5
- package/dist/server/app-rsc-handler.js +38 -15
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +4 -3
- package/dist/server/app-rsc-render-mode.js +7 -1
- package/dist/server/app-rsc-render-mode.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +4 -1
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -1
- package/dist/server/app-rsc-response-finalizer.js +10 -3
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.d.ts +23 -0
- package/dist/server/app-rsc-route-matching.js +47 -25
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +35 -3
- package/dist/server/app-server-action-execution.js +87 -33
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +83 -58
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.d.ts +14 -0
- package/dist/server/app-ssr-error-meta.js +50 -0
- package/dist/server/app-ssr-error-meta.js.map +1 -0
- package/dist/server/app-ssr-stream.d.ts +7 -2
- package/dist/server/app-ssr-stream.js +26 -15
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +13 -3
- package/dist/server/artifact-compatibility.js +12 -8
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-headers.d.ts +7 -0
- package/dist/server/cache-headers.js +19 -0
- package/dist/server/cache-headers.js.map +1 -0
- package/dist/server/cache-proof.d.ts +170 -5
- package/dist/server/cache-proof.js +472 -18
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +99 -0
- package/dist/server/client-reuse-manifest.js +212 -0
- package/dist/server/client-reuse-manifest.js.map +1 -0
- package/dist/server/default-global-error-module.d.ts +20 -0
- package/dist/server/default-global-error-module.js +20 -0
- package/dist/server/default-global-error-module.js.map +1 -0
- package/dist/server/dev-lockfile.d.ts +110 -0
- package/dist/server/dev-lockfile.js +180 -0
- package/dist/server/dev-lockfile.js.map +1 -0
- package/dist/server/dev-server.d.ts +9 -1
- package/dist/server/dev-server.js +76 -19
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/edge-api-runtime.d.ts +5 -0
- package/dist/server/edge-api-runtime.js +8 -0
- package/dist/server/edge-api-runtime.js.map +1 -0
- package/dist/server/file-based-metadata.d.ts +13 -0
- package/dist/server/file-based-metadata.js +49 -2
- package/dist/server/file-based-metadata.js.map +1 -1
- package/dist/server/headers.d.ts +20 -1
- package/dist/server/headers.js +22 -2
- package/dist/server/headers.js.map +1 -1
- package/dist/server/html.js +1 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +26 -1
- package/dist/server/http-error-responses.js +32 -2
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/isr-cache.d.ts +8 -3
- package/dist/server/isr-cache.js +24 -6
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-route-response.js +22 -5
- package/dist/server/metadata-route-response.js.map +1 -1
- package/dist/server/metadata-routes.js +27 -8
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +15 -0
- package/dist/server/middleware-runtime.js +60 -7
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +13 -1
- package/dist/server/middleware.js +16 -2
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +26 -6
- package/dist/server/navigation-planner.js +358 -24
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +9 -1
- package/dist/server/navigation-trace.js +8 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/normalize-path.d.ts +2 -1
- package/dist/server/normalize-path.js +4 -1
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +27 -1
- package/dist/server/pages-api-route.js +25 -3
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-data-route.d.ts +77 -0
- package/dist/server/pages-data-route.js +97 -0
- package/dist/server/pages-data-route.js.map +1 -0
- package/dist/server/pages-i18n.d.ts +51 -1
- package/dist/server/pages-i18n.js +61 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +32 -4
- package/dist/server/pages-page-data.js +52 -19
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +11 -1
- package/dist/server/pages-page-response.js +6 -4
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prod-server.d.ts +26 -1
- package/dist/server/prod-server.js +150 -44
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +11 -2
- package/dist/server/request-pipeline.js +28 -11
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.d.ts +12 -31
- package/dist/server/seed-cache.js +22 -35
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.d.ts +16 -3
- package/dist/server/server-action-not-found.js +27 -4
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/server-globals.d.ts +5 -0
- package/dist/server/server-globals.js +37 -0
- package/dist/server/server-globals.js.map +1 -0
- package/dist/server/skip-cache-proof.d.ts +41 -0
- package/dist/server/skip-cache-proof.js +101 -0
- package/dist/server/skip-cache-proof.js.map +1 -0
- package/dist/server/static-file-cache.d.ts +1 -1
- package/dist/server/static-file-cache.js +7 -6
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/cache-runtime.d.ts +19 -2
- package/dist/shims/cache-runtime.js +67 -11
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +5 -18
- package/dist/shims/cache.js +2 -0
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-locale.d.ts +15 -0
- package/dist/shims/client-locale.js +13 -0
- package/dist/shims/client-locale.js.map +1 -0
- package/dist/shims/default-global-error.d.ts +32 -0
- package/dist/shims/default-global-error.js +181 -0
- package/dist/shims/default-global-error.js.map +1 -0
- package/dist/shims/document.d.ts +59 -3
- package/dist/shims/document.js +36 -5
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +2 -2
- package/dist/shims/error-boundary.js +6 -8
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts +18 -1
- package/dist/shims/error.js +56 -1
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +4 -1
- package/dist/shims/fetch-cache.js +40 -5
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +22 -8
- package/dist/shims/font-google-base.js +41 -71
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-local.d.ts +3 -20
- package/dist/shims/font-local.js +23 -75
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/font-utils.d.ts +51 -0
- package/dist/shims/font-utils.js +97 -0
- package/dist/shims/font-utils.js.map +1 -0
- package/dist/shims/form.js +13 -6
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/hash-scroll.d.ts +7 -0
- package/dist/shims/hash-scroll.js +30 -0
- package/dist/shims/hash-scroll.js.map +1 -0
- package/dist/shims/headers.d.ts +8 -11
- package/dist/shims/headers.js +22 -2
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -0
- package/dist/shims/image.js +144 -78
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/app-router-context.d.ts +6 -6
- package/dist/shims/internal/app-router-context.js +17 -6
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/link-prefetch.d.ts +9 -1
- package/dist/shims/link-prefetch.js +11 -6
- package/dist/shims/link-prefetch.js.map +1 -1
- package/dist/shims/link.d.ts +33 -5
- package/dist/shims/link.js +205 -50
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +16 -30
- package/dist/shims/metadata.js +91 -32
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +164 -17
- package/dist/shims/navigation.js +355 -84
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.d.ts +3 -2
- package/dist/shims/navigation.react-server.js +5 -2
- package/dist/shims/navigation.react-server.js.map +1 -1
- package/dist/shims/og.d.ts +18 -2
- package/dist/shims/og.js +49 -1
- package/dist/shims/og.js.map +1 -0
- package/dist/shims/pages-router-runtime.d.ts +7 -0
- package/dist/shims/pages-router-runtime.js +16 -0
- package/dist/shims/pages-router-runtime.js.map +1 -0
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +11 -3
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +40 -7
- package/dist/shims/router.js +355 -250
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.js +110 -32
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts +21 -4
- package/dist/shims/server.js +31 -10
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.d.ts +1 -0
- package/dist/shims/slot.js +45 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/unrecognized-action-error.d.ts +35 -0
- package/dist/shims/unrecognized-action-error.js +41 -0
- package/dist/shims/unrecognized-action-error.js.map +1 -0
- package/dist/shims/url-safety.d.ts +23 -1
- package/dist/shims/url-safety.js +29 -2
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +21 -1
- package/dist/shims/url-utils.js +67 -3
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/typegen.d.ts +10 -0
- package/dist/typegen.js +242 -0
- package/dist/typegen.js.map +1 -0
- package/dist/utils/asset-prefix.d.ts +97 -0
- package/dist/utils/asset-prefix.js +124 -0
- package/dist/utils/asset-prefix.js.map +1 -0
- package/dist/utils/base-path.d.ts +7 -1
- package/dist/utils/base-path.js +10 -1
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/cache-control-metadata.d.ts +2 -1
- package/dist/utils/cache-control-metadata.js +1 -3
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +2 -1
- package/dist/utils/domain-locale.js +9 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/navigation-signal.d.ts +1 -2
- package/dist/utils/navigation-signal.js +1 -1
- package/dist/utils/navigation-signal.js.map +1 -1
- package/dist/utils/prerender-output-paths.d.ts +15 -0
- package/dist/utils/prerender-output-paths.js +24 -0
- package/dist/utils/prerender-output-paths.js.map +1 -0
- package/dist/utils/query.d.ts +17 -1
- package/dist/utils/query.js +36 -1
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/record.d.ts +5 -0
- package/dist/utils/record.js +8 -0
- package/dist/utils/record.js.map +1 -0
- package/dist/utils/sorted-array.d.ts +9 -0
- package/dist/utils/sorted-array.js +22 -0
- package/dist/utils/sorted-array.js.map +1 -0
- package/package.json +13 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import DefaultGlobalError from "../shims/default-global-error.js";
|
|
2
|
+
//#region src/server/default-global-error-module.ts
|
|
3
|
+
/**
|
|
4
|
+
* Module-shaped wrapper around vinext's built-in default global error
|
|
5
|
+
* component. Used as the fallback when an app does not define its own
|
|
6
|
+
* `app/global-error.tsx`. The runtime treats any `{ default: Component }`
|
|
7
|
+
* record as a "global error module", so wrapping the component this way lets
|
|
8
|
+
* us thread the default through the existing `globalErrorModule` plumbing
|
|
9
|
+
* without introducing a parallel code path.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors Next.js's `defaultGlobalErrorPath`
|
|
12
|
+
* (`next/dist/client/components/builtin/global-error.js`), which is selected
|
|
13
|
+
* automatically when the user has not supplied a custom global error file:
|
|
14
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/loaders/next-app-loader/index.ts
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_GLOBAL_ERROR_MODULE = { default: DefaultGlobalError };
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DEFAULT_GLOBAL_ERROR_MODULE };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=default-global-error-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-global-error-module.js","names":[],"sources":["../../src/server/default-global-error-module.ts"],"sourcesContent":["import DefaultGlobalError from \"vinext/shims/default-global-error\";\n\n/**\n * Module-shaped wrapper around vinext's built-in default global error\n * component. Used as the fallback when an app does not define its own\n * `app/global-error.tsx`. The runtime treats any `{ default: Component }`\n * record as a \"global error module\", so wrapping the component this way lets\n * us thread the default through the existing `globalErrorModule` plumbing\n * without introducing a parallel code path.\n *\n * Mirrors Next.js's `defaultGlobalErrorPath`\n * (`next/dist/client/components/builtin/global-error.js`), which is selected\n * automatically when the user has not supplied a custom global error file:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/build/webpack/loaders/next-app-loader/index.ts\n */\nexport const DEFAULT_GLOBAL_ERROR_MODULE = {\n default: DefaultGlobalError,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,8BAA8B,EACzC,SAAS,oBACV"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
//#region src/server/dev-lockfile.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Dev server lock file.
|
|
4
|
+
*
|
|
5
|
+
* Writes the running dev server's PID, port, and URL into a lock file at
|
|
6
|
+
* `<root>/.vinext/dev/lock.json`. When a second `vinext dev` process starts in
|
|
7
|
+
* the same project directory, it reads the lock file and either fails with an
|
|
8
|
+
* actionable error or, if the previous process is dead, takes over the lock.
|
|
9
|
+
*
|
|
10
|
+
* This is especially useful for AI coding agents, which frequently attempt to
|
|
11
|
+
* start `vinext dev` without knowing a server is already running.
|
|
12
|
+
*
|
|
13
|
+
* Ported behaviorally from Next.js:
|
|
14
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/lockfile.ts
|
|
15
|
+
*
|
|
16
|
+
* Differences vs Next.js:
|
|
17
|
+
* - No native `flock()`. Next.js uses Rust SWC bindings for cross-platform
|
|
18
|
+
* advisory locking; vinext uses a JSON file plus a PID liveness check
|
|
19
|
+
* (`process.kill(pid, 0)`), which is good enough for the dev-server
|
|
20
|
+
* "another server is running" use case. Race conditions on lock acquisition
|
|
21
|
+
* are tolerated: at worst, two dev servers race and one fails to bind a port.
|
|
22
|
+
* - Lock file lives in `<root>/.vinext/dev/lock.json` (mirroring Next.js'
|
|
23
|
+
* `.next/dev/lock` layout). `.vinext/` is already used by the fonts plugin
|
|
24
|
+
* to cache self-hosted Google Fonts, so this re-uses the same project-local
|
|
25
|
+
* state directory rather than polluting `node_modules`.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Information about a running dev server, stored inside the lock file itself.
|
|
29
|
+
*/
|
|
30
|
+
type DevServerInfo = {
|
|
31
|
+
pid: number;
|
|
32
|
+
port: number;
|
|
33
|
+
hostname: string;
|
|
34
|
+
appUrl: string;
|
|
35
|
+
startedAt: number; /** Project directory the server is running in. Used to detect stale entries. */
|
|
36
|
+
cwd: string;
|
|
37
|
+
};
|
|
38
|
+
type DevLockfile = {
|
|
39
|
+
/** Update the lock file contents (e.g. once the port is known after listen). */update(info: DevServerInfo): void; /** Release the lock — deletes the file. Safe to call multiple times. */
|
|
40
|
+
release(): void; /** Absolute path to the lock file. */
|
|
41
|
+
path: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Returns the absolute path to the lock file for a given project root.
|
|
45
|
+
*/
|
|
46
|
+
declare function getLockfilePath(root: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Reads and parses the lock file at the given path. Returns `undefined` if the
|
|
49
|
+
* file doesn't exist or can't be parsed.
|
|
50
|
+
*/
|
|
51
|
+
declare function readLockfile(lockfilePath: string): DevServerInfo | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Returns true if a process with the given PID is running.
|
|
54
|
+
*
|
|
55
|
+
* Uses `process.kill(pid, 0)`, which sends a null signal — it doesn't actually
|
|
56
|
+
* kill the process, it just checks if it exists. Throws `ESRCH` if the process
|
|
57
|
+
* doesn't exist, or `EPERM` if it exists but we don't have permission to
|
|
58
|
+
* signal it (in which case it's still running, just owned by someone else).
|
|
59
|
+
*/
|
|
60
|
+
declare function isPidAlive(pid: number): boolean;
|
|
61
|
+
type FormatErrorOptions = {
|
|
62
|
+
/** Existing server info from the lock file, if readable. */existing: DevServerInfo | undefined; /** Project directory the new (failing) process is trying to run in. */
|
|
63
|
+
cwd: string; /** Path to the lock file. */
|
|
64
|
+
lockfilePath: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Format the error message printed when another dev server is already running.
|
|
68
|
+
*
|
|
69
|
+
* Matches Next.js' error layout so AI agents and CLIs can parse the same
|
|
70
|
+
* `- PID: ` / `- Local: ` lines.
|
|
71
|
+
*
|
|
72
|
+
* The `existing: undefined` branch below is defensive — `tryAcquireLockfile`
|
|
73
|
+
* currently only returns `ok: false` with a defined `existing`, but the
|
|
74
|
+
* formatter is exported and unit-tested separately, so it handles both shapes.
|
|
75
|
+
*/
|
|
76
|
+
declare function formatAlreadyRunningError(opts: FormatErrorOptions): string;
|
|
77
|
+
type AcquireOptions = {
|
|
78
|
+
/** Project root. Lock file goes in `<root>/.vinext/dev/lock.json`. */root: string; /** Initial server info to write. Port/URL may be updated later via `update()`. */
|
|
79
|
+
info: DevServerInfo;
|
|
80
|
+
/**
|
|
81
|
+
* If a lock file exists but its PID is dead, take over instead of failing.
|
|
82
|
+
* Defaults to `true`. Set to `false` for testing.
|
|
83
|
+
*/
|
|
84
|
+
takeOverStale?: boolean; /** Register `process.on('exit', release)`. Defaults to `true`. */
|
|
85
|
+
unlockOnExit?: boolean;
|
|
86
|
+
};
|
|
87
|
+
type AcquireSuccess = {
|
|
88
|
+
ok: true;
|
|
89
|
+
lockfile: DevLockfile;
|
|
90
|
+
};
|
|
91
|
+
type AcquireFailure = {
|
|
92
|
+
ok: false; /** The server info from the existing lock file, if readable. */
|
|
93
|
+
existing: DevServerInfo | undefined; /** Absolute path to the lock file. */
|
|
94
|
+
lockfilePath: string;
|
|
95
|
+
};
|
|
96
|
+
type AcquireResult = AcquireSuccess | AcquireFailure;
|
|
97
|
+
/**
|
|
98
|
+
* Try to acquire the dev lock file for the given project root.
|
|
99
|
+
*
|
|
100
|
+
* Returns `{ ok: true, lockfile }` on success — the caller should call
|
|
101
|
+
* `lockfile.release()` on shutdown (or rely on the exit listener registered
|
|
102
|
+
* via `unlockOnExit`).
|
|
103
|
+
*
|
|
104
|
+
* Returns `{ ok: false, existing, lockfilePath }` if another live dev server
|
|
105
|
+
* already holds the lock.
|
|
106
|
+
*/
|
|
107
|
+
declare function tryAcquireLockfile(opts: AcquireOptions): AcquireResult;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { DevLockfile, DevServerInfo, formatAlreadyRunningError, getLockfilePath, isPidAlive, readLockfile, tryAcquireLockfile };
|
|
110
|
+
//# sourceMappingURL=dev-lockfile.d.ts.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region src/server/dev-lockfile.ts
|
|
4
|
+
/**
|
|
5
|
+
* Dev server lock file.
|
|
6
|
+
*
|
|
7
|
+
* Writes the running dev server's PID, port, and URL into a lock file at
|
|
8
|
+
* `<root>/.vinext/dev/lock.json`. When a second `vinext dev` process starts in
|
|
9
|
+
* the same project directory, it reads the lock file and either fails with an
|
|
10
|
+
* actionable error or, if the previous process is dead, takes over the lock.
|
|
11
|
+
*
|
|
12
|
+
* This is especially useful for AI coding agents, which frequently attempt to
|
|
13
|
+
* start `vinext dev` without knowing a server is already running.
|
|
14
|
+
*
|
|
15
|
+
* Ported behaviorally from Next.js:
|
|
16
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/build/lockfile.ts
|
|
17
|
+
*
|
|
18
|
+
* Differences vs Next.js:
|
|
19
|
+
* - No native `flock()`. Next.js uses Rust SWC bindings for cross-platform
|
|
20
|
+
* advisory locking; vinext uses a JSON file plus a PID liveness check
|
|
21
|
+
* (`process.kill(pid, 0)`), which is good enough for the dev-server
|
|
22
|
+
* "another server is running" use case. Race conditions on lock acquisition
|
|
23
|
+
* are tolerated: at worst, two dev servers race and one fails to bind a port.
|
|
24
|
+
* - Lock file lives in `<root>/.vinext/dev/lock.json` (mirroring Next.js'
|
|
25
|
+
* `.next/dev/lock` layout). `.vinext/` is already used by the fonts plugin
|
|
26
|
+
* to cache self-hosted Google Fonts, so this re-uses the same project-local
|
|
27
|
+
* state directory rather than polluting `node_modules`.
|
|
28
|
+
*/
|
|
29
|
+
const LOCK_DIR_RELATIVE = path.join(".vinext", "dev");
|
|
30
|
+
const LOCK_FILE_NAME = "lock.json";
|
|
31
|
+
/**
|
|
32
|
+
* Returns the absolute path to the lock file for a given project root.
|
|
33
|
+
*/
|
|
34
|
+
function getLockfilePath(root) {
|
|
35
|
+
return path.join(root, LOCK_DIR_RELATIVE, LOCK_FILE_NAME);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads and parses the lock file at the given path. Returns `undefined` if the
|
|
39
|
+
* file doesn't exist or can't be parsed.
|
|
40
|
+
*/
|
|
41
|
+
function readLockfile(lockfilePath) {
|
|
42
|
+
let content;
|
|
43
|
+
try {
|
|
44
|
+
content = fs.readFileSync(lockfilePath, "utf-8");
|
|
45
|
+
} catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(content);
|
|
50
|
+
if (typeof parsed.pid === "number" && typeof parsed.port === "number" && typeof parsed.hostname === "string" && typeof parsed.appUrl === "string" && typeof parsed.startedAt === "number" && typeof parsed.cwd === "string") return parsed;
|
|
51
|
+
return;
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns true if a process with the given PID is running.
|
|
58
|
+
*
|
|
59
|
+
* Uses `process.kill(pid, 0)`, which sends a null signal — it doesn't actually
|
|
60
|
+
* kill the process, it just checks if it exists. Throws `ESRCH` if the process
|
|
61
|
+
* doesn't exist, or `EPERM` if it exists but we don't have permission to
|
|
62
|
+
* signal it (in which case it's still running, just owned by someone else).
|
|
63
|
+
*/
|
|
64
|
+
function isPidAlive(pid) {
|
|
65
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
66
|
+
try {
|
|
67
|
+
process.kill(pid, 0);
|
|
68
|
+
return true;
|
|
69
|
+
} catch (err) {
|
|
70
|
+
return err.code === "EPERM";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Writes the lock file with the given content. Creates the parent directory
|
|
75
|
+
* if it doesn't exist.
|
|
76
|
+
*
|
|
77
|
+
* Mode `0o600` because the lock file contains a PID that, in principle, lets
|
|
78
|
+
* other users on the machine send signals to this user's dev server.
|
|
79
|
+
* Restricting reads is defense-in-depth: the PID is also discoverable via
|
|
80
|
+
* `ps` and the port via `netstat`/`ss`, so this isn't load-bearing.
|
|
81
|
+
*/
|
|
82
|
+
function writeLockfile(lockfilePath, info) {
|
|
83
|
+
fs.mkdirSync(path.dirname(lockfilePath), { recursive: true });
|
|
84
|
+
fs.writeFileSync(lockfilePath, JSON.stringify(info, null, 2), { mode: 384 });
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Format the error message printed when another dev server is already running.
|
|
88
|
+
*
|
|
89
|
+
* Matches Next.js' error layout so AI agents and CLIs can parse the same
|
|
90
|
+
* `- PID: ` / `- Local: ` lines.
|
|
91
|
+
*
|
|
92
|
+
* The `existing: undefined` branch below is defensive — `tryAcquireLockfile`
|
|
93
|
+
* currently only returns `ok: false` with a defined `existing`, but the
|
|
94
|
+
* formatter is exported and unit-tested separately, so it handles both shapes.
|
|
95
|
+
*/
|
|
96
|
+
function formatAlreadyRunningError(opts) {
|
|
97
|
+
const { existing, cwd, lockfilePath } = opts;
|
|
98
|
+
if (!existing) return [
|
|
99
|
+
"Another vinext dev server appears to be running in this directory.",
|
|
100
|
+
"",
|
|
101
|
+
`Stale lock file: ${path.relative(cwd, lockfilePath)}`,
|
|
102
|
+
"Remove it manually if no server is running, then re-run `vinext dev`."
|
|
103
|
+
].join("\n");
|
|
104
|
+
const killCommand = process.platform === "win32" ? `taskkill /PID ${existing.pid} /F` : `kill ${existing.pid}`;
|
|
105
|
+
return [
|
|
106
|
+
"Another vinext dev server is already running.",
|
|
107
|
+
"",
|
|
108
|
+
`- Local: ${existing.appUrl}`,
|
|
109
|
+
`- PID: ${existing.pid}`,
|
|
110
|
+
`- Dir: ${existing.cwd}`,
|
|
111
|
+
"",
|
|
112
|
+
`You can access the existing server at ${existing.appUrl},`,
|
|
113
|
+
`or run \`${killCommand}\` to stop it and start a new one.`
|
|
114
|
+
].join("\n");
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Try to acquire the dev lock file for the given project root.
|
|
118
|
+
*
|
|
119
|
+
* Returns `{ ok: true, lockfile }` on success — the caller should call
|
|
120
|
+
* `lockfile.release()` on shutdown (or rely on the exit listener registered
|
|
121
|
+
* via `unlockOnExit`).
|
|
122
|
+
*
|
|
123
|
+
* Returns `{ ok: false, existing, lockfilePath }` if another live dev server
|
|
124
|
+
* already holds the lock.
|
|
125
|
+
*/
|
|
126
|
+
function tryAcquireLockfile(opts) {
|
|
127
|
+
const { root, info, takeOverStale = true, unlockOnExit = true } = opts;
|
|
128
|
+
const lockfilePath = getLockfilePath(root);
|
|
129
|
+
const existing = readLockfile(lockfilePath);
|
|
130
|
+
if (existing) {
|
|
131
|
+
if (isPidAlive(existing.pid)) return {
|
|
132
|
+
ok: false,
|
|
133
|
+
existing,
|
|
134
|
+
lockfilePath
|
|
135
|
+
};
|
|
136
|
+
if (!takeOverStale) return {
|
|
137
|
+
ok: false,
|
|
138
|
+
existing,
|
|
139
|
+
lockfilePath
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
writeLockfile(lockfilePath, info);
|
|
143
|
+
const ownerPid = info.pid;
|
|
144
|
+
let released = false;
|
|
145
|
+
const release = () => {
|
|
146
|
+
if (released) return;
|
|
147
|
+
released = true;
|
|
148
|
+
try {
|
|
149
|
+
const current = readLockfile(lockfilePath);
|
|
150
|
+
if (current && current.pid === ownerPid) fs.unlinkSync(lockfilePath);
|
|
151
|
+
} catch {}
|
|
152
|
+
};
|
|
153
|
+
let exitListener;
|
|
154
|
+
if (unlockOnExit) {
|
|
155
|
+
exitListener = () => release();
|
|
156
|
+
process.on("exit", exitListener);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
ok: true,
|
|
160
|
+
lockfile: {
|
|
161
|
+
path: lockfilePath,
|
|
162
|
+
update(next) {
|
|
163
|
+
try {
|
|
164
|
+
writeLockfile(lockfilePath, next);
|
|
165
|
+
} catch {}
|
|
166
|
+
},
|
|
167
|
+
release() {
|
|
168
|
+
release();
|
|
169
|
+
if (exitListener) {
|
|
170
|
+
process.off("exit", exitListener);
|
|
171
|
+
exitListener = void 0;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { formatAlreadyRunningError, getLockfilePath, isPidAlive, readLockfile, tryAcquireLockfile };
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=dev-lockfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-lockfile.js","names":[],"sources":["../../src/server/dev-lockfile.ts"],"sourcesContent":["/**\n * Dev server lock file.\n *\n * Writes the running dev server's PID, port, and URL into a lock file at\n * `<root>/.vinext/dev/lock.json`. When a second `vinext dev` process starts in\n * the same project directory, it reads the lock file and either fails with an\n * actionable error or, if the previous process is dead, takes over the lock.\n *\n * This is especially useful for AI coding agents, which frequently attempt to\n * start `vinext dev` without knowing a server is already running.\n *\n * Ported behaviorally from Next.js:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/build/lockfile.ts\n *\n * Differences vs Next.js:\n * - No native `flock()`. Next.js uses Rust SWC bindings for cross-platform\n * advisory locking; vinext uses a JSON file plus a PID liveness check\n * (`process.kill(pid, 0)`), which is good enough for the dev-server\n * \"another server is running\" use case. Race conditions on lock acquisition\n * are tolerated: at worst, two dev servers race and one fails to bind a port.\n * - Lock file lives in `<root>/.vinext/dev/lock.json` (mirroring Next.js'\n * `.next/dev/lock` layout). `.vinext/` is already used by the fonts plugin\n * to cache self-hosted Google Fonts, so this re-uses the same project-local\n * state directory rather than polluting `node_modules`.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nconst LOCK_DIR_RELATIVE = path.join(\".vinext\", \"dev\");\nconst LOCK_FILE_NAME = \"lock.json\";\n\n/**\n * Information about a running dev server, stored inside the lock file itself.\n */\nexport type DevServerInfo = {\n pid: number;\n port: number;\n hostname: string;\n appUrl: string;\n startedAt: number;\n /** Project directory the server is running in. Used to detect stale entries. */\n cwd: string;\n};\n\nexport type DevLockfile = {\n /** Update the lock file contents (e.g. once the port is known after listen). */\n update(info: DevServerInfo): void;\n /** Release the lock — deletes the file. Safe to call multiple times. */\n release(): void;\n /** Absolute path to the lock file. */\n path: string;\n};\n\n/**\n * Returns the absolute path to the lock file for a given project root.\n */\nexport function getLockfilePath(root: string): string {\n return path.join(root, LOCK_DIR_RELATIVE, LOCK_FILE_NAME);\n}\n\n/**\n * Reads and parses the lock file at the given path. Returns `undefined` if the\n * file doesn't exist or can't be parsed.\n */\nexport function readLockfile(lockfilePath: string): DevServerInfo | undefined {\n let content: string;\n try {\n content = fs.readFileSync(lockfilePath, \"utf-8\");\n } catch {\n return undefined;\n }\n try {\n const parsed = JSON.parse(content) as DevServerInfo;\n if (\n typeof parsed.pid === \"number\" &&\n typeof parsed.port === \"number\" &&\n typeof parsed.hostname === \"string\" &&\n typeof parsed.appUrl === \"string\" &&\n typeof parsed.startedAt === \"number\" &&\n typeof parsed.cwd === \"string\"\n ) {\n return parsed;\n }\n return undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Returns true if a process with the given PID is running.\n *\n * Uses `process.kill(pid, 0)`, which sends a null signal — it doesn't actually\n * kill the process, it just checks if it exists. Throws `ESRCH` if the process\n * doesn't exist, or `EPERM` if it exists but we don't have permission to\n * signal it (in which case it's still running, just owned by someone else).\n */\nexport function isPidAlive(pid: number): boolean {\n if (!Number.isInteger(pid) || pid <= 0) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n // EPERM means the process exists but we lack permission — still alive.\n return code === \"EPERM\";\n }\n}\n\n/**\n * Writes the lock file with the given content. Creates the parent directory\n * if it doesn't exist.\n *\n * Mode `0o600` because the lock file contains a PID that, in principle, lets\n * other users on the machine send signals to this user's dev server.\n * Restricting reads is defense-in-depth: the PID is also discoverable via\n * `ps` and the port via `netstat`/`ss`, so this isn't load-bearing.\n */\nfunction writeLockfile(lockfilePath: string, info: DevServerInfo): void {\n fs.mkdirSync(path.dirname(lockfilePath), { recursive: true });\n fs.writeFileSync(lockfilePath, JSON.stringify(info, null, 2), { mode: 0o600 });\n}\n\ntype FormatErrorOptions = {\n /** Existing server info from the lock file, if readable. */\n existing: DevServerInfo | undefined;\n /** Project directory the new (failing) process is trying to run in. */\n cwd: string;\n /** Path to the lock file. */\n lockfilePath: string;\n};\n\n/**\n * Format the error message printed when another dev server is already running.\n *\n * Matches Next.js' error layout so AI agents and CLIs can parse the same\n * `- PID: ` / `- Local: ` lines.\n *\n * The `existing: undefined` branch below is defensive — `tryAcquireLockfile`\n * currently only returns `ok: false` with a defined `existing`, but the\n * formatter is exported and unit-tested separately, so it handles both shapes.\n */\nexport function formatAlreadyRunningError(opts: FormatErrorOptions): string {\n const { existing, cwd, lockfilePath } = opts;\n\n if (!existing) {\n // Defensive fallback. Not reachable from tryAcquireLockfile today.\n return [\n \"Another vinext dev server appears to be running in this directory.\",\n \"\",\n `Stale lock file: ${path.relative(cwd, lockfilePath)}`,\n \"Remove it manually if no server is running, then re-run `vinext dev`.\",\n ].join(\"\\n\");\n }\n\n const killCommand =\n process.platform === \"win32\" ? `taskkill /PID ${existing.pid} /F` : `kill ${existing.pid}`;\n\n return [\n \"Another vinext dev server is already running.\",\n \"\",\n `- Local: ${existing.appUrl}`,\n `- PID: ${existing.pid}`,\n `- Dir: ${existing.cwd}`,\n \"\",\n `You can access the existing server at ${existing.appUrl},`,\n `or run \\`${killCommand}\\` to stop it and start a new one.`,\n ].join(\"\\n\");\n}\n\ntype AcquireOptions = {\n /** Project root. Lock file goes in `<root>/.vinext/dev/lock.json`. */\n root: string;\n /** Initial server info to write. Port/URL may be updated later via `update()`. */\n info: DevServerInfo;\n /**\n * If a lock file exists but its PID is dead, take over instead of failing.\n * Defaults to `true`. Set to `false` for testing.\n */\n takeOverStale?: boolean;\n /** Register `process.on('exit', release)`. Defaults to `true`. */\n unlockOnExit?: boolean;\n};\n\ntype AcquireSuccess = {\n ok: true;\n lockfile: DevLockfile;\n};\n\ntype AcquireFailure = {\n ok: false;\n /** The server info from the existing lock file, if readable. */\n existing: DevServerInfo | undefined;\n /** Absolute path to the lock file. */\n lockfilePath: string;\n};\n\ntype AcquireResult = AcquireSuccess | AcquireFailure;\n\n/**\n * Try to acquire the dev lock file for the given project root.\n *\n * Returns `{ ok: true, lockfile }` on success — the caller should call\n * `lockfile.release()` on shutdown (or rely on the exit listener registered\n * via `unlockOnExit`).\n *\n * Returns `{ ok: false, existing, lockfilePath }` if another live dev server\n * already holds the lock.\n */\nexport function tryAcquireLockfile(opts: AcquireOptions): AcquireResult {\n const { root, info, takeOverStale = true, unlockOnExit = true } = opts;\n const lockfilePath = getLockfilePath(root);\n\n const existing = readLockfile(lockfilePath);\n if (existing) {\n const alive = isPidAlive(existing.pid);\n if (alive) {\n return { ok: false, existing, lockfilePath };\n }\n if (!takeOverStale) {\n return { ok: false, existing, lockfilePath };\n }\n // Existing entry is stale (dead PID). Fall through and overwrite.\n }\n\n // NB: there is a small TOCTOU window between readLockfile() above and\n // writeLockfile() here. Two processes starting simultaneously can both\n // pass the check and both write the lock file. This is intentionally\n // tolerated — the loser will fail to bind its port, producing a clear\n // error. A native flock() (the approach Next.js takes via Rust bindings)\n // would close the window, but it's not worth the complexity for a\n // dev-ergonomics feature.\n writeLockfile(lockfilePath, info);\n\n // Capture the owner PID once so release() always asks \"is the file still\n // mine?\" against the same identity, regardless of what update() writes\n // later. In practice the PID never changes between acquire and release,\n // but this makes the intent explicit and decouples release from update.\n const ownerPid = info.pid;\n\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n try {\n // Only delete if the file still points at us. If another process took\n // over the lock (e.g. after a crash), don't delete their entry.\n const current = readLockfile(lockfilePath);\n if (current && current.pid === ownerPid) {\n fs.unlinkSync(lockfilePath);\n }\n } catch {\n // Best-effort cleanup.\n }\n };\n\n // The \"exit\" event fires once Node.js is about to exit — either gracefully\n // (event loop drained, explicit process.exit(), or after the default\n // SIGINT/SIGTERM handlers terminate the process). It does NOT fire on\n // uncaught exceptions or hard crashes (SIGKILL), which is fine: the next\n // `vinext dev` will detect the dead PID and take over the stale lock.\n //\n // If a future caller installs a custom signal handler that swallows\n // SIGINT/SIGTERM without exiting, the lock would leak — also fine, same\n // recovery path applies.\n let exitListener: NodeJS.ExitListener | undefined;\n if (unlockOnExit) {\n exitListener = () => release();\n process.on(\"exit\", exitListener);\n }\n\n const lockfile: DevLockfile = {\n path: lockfilePath,\n update(next: DevServerInfo): void {\n try {\n writeLockfile(lockfilePath, next);\n } catch {\n // Best-effort; not fatal.\n }\n },\n release(): void {\n release();\n if (exitListener) {\n process.off(\"exit\", exitListener);\n exitListener = undefined;\n }\n },\n };\n\n return { ok: true, lockfile };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,oBAAoB,KAAK,KAAK,WAAW,MAAM;AACrD,MAAM,iBAAiB;;;;AA2BvB,SAAgB,gBAAgB,MAAsB;CACpD,OAAO,KAAK,KAAK,MAAM,mBAAmB,eAAe;;;;;;AAO3D,SAAgB,aAAa,cAAiD;CAC5E,IAAI;CACJ,IAAI;EACF,UAAU,GAAG,aAAa,cAAc,QAAQ;SAC1C;EACN;;CAEF,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,QAAQ;EAClC,IACE,OAAO,OAAO,QAAQ,YACtB,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,aAAa,YAC3B,OAAO,OAAO,WAAW,YACzB,OAAO,OAAO,cAAc,YAC5B,OAAO,OAAO,QAAQ,UAEtB,OAAO;EAET;SACM;EACN;;;;;;;;;;;AAYJ,SAAgB,WAAW,KAAsB;CAC/C,IAAI,CAAC,OAAO,UAAU,IAAI,IAAI,OAAO,GAAG,OAAO;CAC/C,IAAI;EACF,QAAQ,KAAK,KAAK,EAAE;EACpB,OAAO;UACA,KAAK;EAGZ,OAFc,IAA8B,SAE5B;;;;;;;;;;;;AAapB,SAAS,cAAc,cAAsB,MAA2B;CACtE,GAAG,UAAU,KAAK,QAAQ,aAAa,EAAE,EAAE,WAAW,MAAM,CAAC;CAC7D,GAAG,cAAc,cAAc,KAAK,UAAU,MAAM,MAAM,EAAE,EAAE,EAAE,MAAM,KAAO,CAAC;;;;;;;;;;;;AAsBhF,SAAgB,0BAA0B,MAAkC;CAC1E,MAAM,EAAE,UAAU,KAAK,iBAAiB;CAExC,IAAI,CAAC,UAEH,OAAO;EACL;EACA;EACA,oBAAoB,KAAK,SAAS,KAAK,aAAa;EACpD;EACD,CAAC,KAAK,KAAK;CAGd,MAAM,cACJ,QAAQ,aAAa,UAAU,iBAAiB,SAAS,IAAI,OAAO,QAAQ,SAAS;CAEvF,OAAO;EACL;EACA;EACA,mBAAmB,SAAS;EAC5B,mBAAmB,SAAS;EAC5B,mBAAmB,SAAS;EAC5B;EACA,yCAAyC,SAAS,OAAO;EACzD,YAAY,YAAY;EACzB,CAAC,KAAK,KAAK;;;;;;;;;;;;AA0Cd,SAAgB,mBAAmB,MAAqC;CACtE,MAAM,EAAE,MAAM,MAAM,gBAAgB,MAAM,eAAe,SAAS;CAClE,MAAM,eAAe,gBAAgB,KAAK;CAE1C,MAAM,WAAW,aAAa,aAAa;CAC3C,IAAI,UAAU;EAEZ,IADc,WAAW,SAAS,IACzB,EACP,OAAO;GAAE,IAAI;GAAO;GAAU;GAAc;EAE9C,IAAI,CAAC,eACH,OAAO;GAAE,IAAI;GAAO;GAAU;GAAc;;CAYhD,cAAc,cAAc,KAAK;CAMjC,MAAM,WAAW,KAAK;CAEtB,IAAI,WAAW;CACf,MAAM,gBAAgB;EACpB,IAAI,UAAU;EACd,WAAW;EACX,IAAI;GAGF,MAAM,UAAU,aAAa,aAAa;GAC1C,IAAI,WAAW,QAAQ,QAAQ,UAC7B,GAAG,WAAW,aAAa;UAEvB;;CAcV,IAAI;CACJ,IAAI,cAAc;EAChB,qBAAqB,SAAS;EAC9B,QAAQ,GAAG,QAAQ,aAAa;;CAqBlC,OAAO;EAAE,IAAI;EAAM,UAAA;GAjBjB,MAAM;GACN,OAAO,MAA2B;IAChC,IAAI;KACF,cAAc,cAAc,KAAK;YAC3B;;GAIV,UAAgB;IACd,SAAS;IACT,IAAI,cAAc;KAChB,QAAQ,IAAI,QAAQ,aAAa;KACjC,eAAe,KAAA;;;GAKM;EAAE"}
|
|
@@ -38,7 +38,15 @@ declare function parseCookieLocale(req: IncomingMessage, i18nConfig: NextI18nCon
|
|
|
38
38
|
*/
|
|
39
39
|
declare function createSSRHandler(server: ViteDevServer, runner: ModuleImporter, routes: Route[], pagesDir: string, i18nConfig?: NextI18nConfig | null, fileMatcher?: ValidFileMatcher, basePath?: string, trailingSlash?: boolean): (req: IncomingMessage, res: ServerResponse, url: string, /** Status code override — propagated from middleware rewrite status. */
|
|
40
40
|
|
|
41
|
-
statusCode?: number
|
|
41
|
+
statusCode?: number,
|
|
42
|
+
/**
|
|
43
|
+
* True when the request originated as `/_next/data/<buildId>/<page>.json`.
|
|
44
|
+
* When true the handler emits a `{ pageProps }` JSON envelope instead of
|
|
45
|
+
* rendering the React tree to HTML — matching Next.js' behavior for
|
|
46
|
+
* client-side navigations in the Pages Router.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
isDataReq?: boolean) => Promise<void>;
|
|
42
50
|
//#endregion
|
|
43
51
|
export { createSSRHandler, detectLocaleFromHeaders, extractLocaleFromUrl, parseCookieLocale };
|
|
44
52
|
//# sourceMappingURL=dev-server.d.ts.map
|
|
@@ -2,13 +2,14 @@ import { createRequestContext, runWithRequestContext } from "../shims/unified-re
|
|
|
2
2
|
import { createValidFileMatcher, findFileWithExtensions } from "../routing/file-matcher.js";
|
|
3
3
|
import { patternToNextFormat } from "../routing/route-validation.js";
|
|
4
4
|
import { matchRoute } from "../routing/pages-router.js";
|
|
5
|
-
import {
|
|
5
|
+
import { mergeRouteParamsIntoQuery, parseQueryString } from "../utils/query.js";
|
|
6
|
+
import { normalizeStaticPathname } from "../routing/route-pattern.js";
|
|
6
7
|
import { importModule, reportRequestError } from "./instrumentation.js";
|
|
8
|
+
import { buildCacheStateHeaders } from "./cache-headers.js";
|
|
7
9
|
import { _runWithCacheState } from "../shims/cache.js";
|
|
8
10
|
import { buildPagesCacheValue, getRevalidateDuration, isrCacheKey, isrGet, isrSet, setRevalidateDuration, triggerBackgroundRegeneration } from "./isr-cache.js";
|
|
9
11
|
import { runWithPrivateCache } from "../shims/cache-runtime.js";
|
|
10
12
|
import { ensureFetchPatch, runWithFetchCache } from "../shims/fetch-cache.js";
|
|
11
|
-
import { mergeRouteParamsIntoQuery, parseQueryString } from "../utils/query.js";
|
|
12
13
|
import "../shims/router-state.js";
|
|
13
14
|
import { runWithHeadState } from "../shims/head-state.js";
|
|
14
15
|
import { runWithServerInsertedHTMLState } from "../shims/navigation-state.js";
|
|
@@ -135,7 +136,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
135
136
|
const matcher = fileMatcher ?? createValidFileMatcher();
|
|
136
137
|
const _alsRegistration = Promise.all([runner.import("vinext/head-state"), runner.import("vinext/router-state")]);
|
|
137
138
|
_alsRegistration.catch(() => {});
|
|
138
|
-
return async (req, res, url, statusCode) => {
|
|
139
|
+
return async (req, res, url, statusCode, isDataReq = false) => {
|
|
139
140
|
const _reqStart = now();
|
|
140
141
|
let _compileEnd;
|
|
141
142
|
let _renderEnd;
|
|
@@ -169,10 +170,16 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
169
170
|
}
|
|
170
171
|
const match = matchRoute(localeStrippedUrl, routes);
|
|
171
172
|
if (!match) {
|
|
173
|
+
if (isDataReq) {
|
|
174
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
175
|
+
res.end("{}");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
172
178
|
await renderErrorPage(server, runner, req, res, url, pagesDir, 404, void 0, matcher);
|
|
173
179
|
return;
|
|
174
180
|
}
|
|
175
181
|
const { route, params } = match;
|
|
182
|
+
const userFacingParams = route.isDynamic ? params : null;
|
|
176
183
|
const query = mergeRouteParamsIntoQuery(parseQueryString(url), params);
|
|
177
184
|
return runWithRequestContext(createRequestContext(), async () => {
|
|
178
185
|
ensureFetchPatch();
|
|
@@ -210,27 +217,53 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
210
217
|
}
|
|
211
218
|
let pageProps = {};
|
|
212
219
|
let isrRevalidateSeconds = null;
|
|
220
|
+
let isFallbackRender = false;
|
|
213
221
|
if (typeof pageModule.getStaticPaths === "function" && route.isDynamic) {
|
|
214
222
|
const pathsResult = await pageModule.getStaticPaths({
|
|
215
223
|
locales: i18nConfig?.locales ?? [],
|
|
216
224
|
defaultLocale: currentDefaultLocale ?? ""
|
|
217
225
|
});
|
|
218
|
-
|
|
219
|
-
|
|
226
|
+
const fallback = pathsResult?.fallback ?? false;
|
|
227
|
+
const paths = pathsResult?.paths ?? [];
|
|
228
|
+
const currentPathname = normalizeStaticPathname(url);
|
|
229
|
+
const isValidPath = paths.some((p) => {
|
|
230
|
+
if (typeof p === "string") return normalizeStaticPathname(p) === currentPathname;
|
|
231
|
+
const entryParams = p.params;
|
|
232
|
+
if (entryParams === void 0 || entryParams === null) return false;
|
|
233
|
+
return Object.entries(entryParams).every(([key, val]) => {
|
|
220
234
|
const actual = params[key];
|
|
221
235
|
if (Array.isArray(val)) return Array.isArray(actual) && val.join("/") === actual.join("/");
|
|
222
236
|
return String(val) === String(actual);
|
|
223
|
-
})
|
|
224
|
-
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
if (fallback === false && !isValidPath) {
|
|
240
|
+
if (isDataReq) {
|
|
241
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
242
|
+
res.end("{}");
|
|
225
243
|
return;
|
|
226
244
|
}
|
|
245
|
+
await renderErrorPage(server, runner, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext, matcher);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (fallback === true && !isValidPath && !isDataReq) {
|
|
249
|
+
isFallbackRender = true;
|
|
250
|
+
if (typeof routerShim.setSSRContext === "function") routerShim.setSSRContext({
|
|
251
|
+
pathname: patternToNextFormat(route.pattern),
|
|
252
|
+
query,
|
|
253
|
+
asPath: url,
|
|
254
|
+
locale: locale ?? currentDefaultLocale,
|
|
255
|
+
locales: i18nConfig?.locales,
|
|
256
|
+
defaultLocale: currentDefaultLocale,
|
|
257
|
+
domainLocales,
|
|
258
|
+
isFallback: true
|
|
259
|
+
});
|
|
227
260
|
}
|
|
228
261
|
}
|
|
229
262
|
const gsspExtraHeaders = {};
|
|
230
|
-
if (typeof pageModule.getServerSideProps === "function") {
|
|
263
|
+
if (typeof pageModule.getServerSideProps === "function" && !isFallbackRender) {
|
|
231
264
|
const headersBeforeGSSP = new Set(Object.keys(res.getHeaders()));
|
|
232
265
|
const context = {
|
|
233
|
-
params,
|
|
266
|
+
params: userFacingParams,
|
|
234
267
|
req,
|
|
235
268
|
res,
|
|
236
269
|
query,
|
|
@@ -252,6 +285,11 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
252
285
|
return;
|
|
253
286
|
}
|
|
254
287
|
if (result && "notFound" in result && result.notFound) {
|
|
288
|
+
if (isDataReq) {
|
|
289
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
290
|
+
res.end("{}");
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
255
293
|
await renderErrorPage(server, runner, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);
|
|
256
294
|
return;
|
|
257
295
|
}
|
|
@@ -275,16 +313,16 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
275
313
|
if (typeof fontLocalEarly.getSSRFontPreloads === "function") earlyPreloads.push(...fontLocalEarly.getSSRFontPreloads());
|
|
276
314
|
if (earlyPreloads.length > 0) earlyFontLinkHeader = earlyPreloads.map((p) => `<${p.href}>; rel=preload; as=font; type=${p.type}; crossorigin`).join(", ");
|
|
277
315
|
} catch {}
|
|
278
|
-
if (typeof pageModule.getStaticProps === "function") {
|
|
316
|
+
if (typeof pageModule.getStaticProps === "function" && !isFallbackRender) {
|
|
279
317
|
const cacheKey = isrCacheKey("pages", url.split("?")[0], process.env.__VINEXT_BUILD_ID);
|
|
280
318
|
const cached = await isrGet(cacheKey);
|
|
281
|
-
if (cached && !cached.isStale && cached.value.value?.kind === "PAGES" && !scriptNonce) {
|
|
319
|
+
if (cached && !cached.isStale && cached.value.value?.kind === "PAGES" && !scriptNonce && !isDataReq) {
|
|
282
320
|
const cachedHtml = cached.value.value.html;
|
|
283
321
|
const transformedHtml = await server.transformIndexHtml(url, cachedHtml);
|
|
284
322
|
const revalidateSecs = getRevalidateDuration(cacheKey) ?? 60;
|
|
285
323
|
const hitHeaders = {
|
|
286
324
|
"Content-Type": "text/html",
|
|
287
|
-
|
|
325
|
+
...buildCacheStateHeaders("HIT"),
|
|
288
326
|
"Cache-Control": `s-maxage=${revalidateSecs}, stale-while-revalidate`
|
|
289
327
|
};
|
|
290
328
|
if (earlyFontLinkHeader) hitHeaders["Link"] = earlyFontLinkHeader;
|
|
@@ -292,14 +330,14 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
292
330
|
res.end(transformedHtml);
|
|
293
331
|
return;
|
|
294
332
|
}
|
|
295
|
-
if (cached && cached.isStale && cached.value.value?.kind === "PAGES" && !scriptNonce) {
|
|
333
|
+
if (cached && cached.isStale && cached.value.value?.kind === "PAGES" && !scriptNonce && !isDataReq) {
|
|
296
334
|
const cachedHtml = cached.value.value.html;
|
|
297
335
|
const transformedHtml = await server.transformIndexHtml(url, cachedHtml);
|
|
298
336
|
triggerBackgroundRegeneration(cacheKey, async () => {
|
|
299
337
|
return runWithRequestContext(createRequestContext({ executionContext: null }), async () => {
|
|
300
338
|
ensureFetchPatch();
|
|
301
339
|
const freshResult = await pageModule.getStaticProps({
|
|
302
|
-
params,
|
|
340
|
+
params: userFacingParams,
|
|
303
341
|
locale: locale ?? currentDefaultLocale,
|
|
304
342
|
locales: i18nConfig?.locales,
|
|
305
343
|
defaultLocale: currentDefaultLocale
|
|
@@ -369,7 +407,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
369
407
|
const revalidateSecs = getRevalidateDuration(cacheKey) ?? 60;
|
|
370
408
|
const staleHeaders = {
|
|
371
409
|
"Content-Type": "text/html",
|
|
372
|
-
|
|
410
|
+
...buildCacheStateHeaders("STALE"),
|
|
373
411
|
"Cache-Control": `s-maxage=${revalidateSecs}, stale-while-revalidate`
|
|
374
412
|
};
|
|
375
413
|
if (earlyFontLinkHeader) staleHeaders["Link"] = earlyFontLinkHeader;
|
|
@@ -378,7 +416,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
378
416
|
return;
|
|
379
417
|
}
|
|
380
418
|
const context = {
|
|
381
|
-
params,
|
|
419
|
+
params: userFacingParams,
|
|
382
420
|
locale: locale ?? currentDefaultLocale,
|
|
383
421
|
locales: i18nConfig?.locales,
|
|
384
422
|
defaultLocale: currentDefaultLocale
|
|
@@ -395,11 +433,24 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
395
433
|
return;
|
|
396
434
|
}
|
|
397
435
|
if (result && "notFound" in result && result.notFound) {
|
|
436
|
+
if (isDataReq) {
|
|
437
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
438
|
+
res.end("{}");
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
398
441
|
await renderErrorPage(server, runner, req, res, url, pagesDir, 404, routerShim.wrapWithRouterContext);
|
|
399
442
|
return;
|
|
400
443
|
}
|
|
401
444
|
if (typeof result?.revalidate === "number" && result.revalidate > 0) isrRevalidateSeconds = result.revalidate;
|
|
402
445
|
}
|
|
446
|
+
if (isDataReq) {
|
|
447
|
+
const dataHeaders = { "Content-Type": "application/json" };
|
|
448
|
+
if (gsspExtraHeaders) for (const [k, v] of Object.entries(gsspExtraHeaders)) dataHeaders[k] = v;
|
|
449
|
+
res.writeHead(statusCode ?? 200, dataHeaders);
|
|
450
|
+
res.end(JSON.stringify({ pageProps }));
|
|
451
|
+
_renderEnd = now();
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
403
454
|
let AppComponent = null;
|
|
404
455
|
const appPath = path.join(pagesDir, "_app");
|
|
405
456
|
if (findFileWithExtensions(appPath, matcher)) try {
|
|
@@ -453,6 +504,7 @@ function createSSRHandler(server, runner, routes, pagesDir, i18nConfig, fileMatc
|
|
|
453
504
|
import "vinext/instrumentation-client";
|
|
454
505
|
import React from "react";
|
|
455
506
|
import { hydrateRoot } from "react-dom/client";
|
|
507
|
+
import { installPagesRouterRuntime } from "vinext/pages-router-runtime";
|
|
456
508
|
import { wrapWithRouterContext } from "next/router";
|
|
457
509
|
|
|
458
510
|
const nextData = window.__NEXT_DATA__;
|
|
@@ -473,7 +525,12 @@ async function hydrate() {
|
|
|
473
525
|
element = wrapWithRouterContext(element);
|
|
474
526
|
const root = hydrateRoot(document.getElementById("__next"), element);
|
|
475
527
|
window.__VINEXT_ROOT__ = root;
|
|
476
|
-
|
|
528
|
+
installPagesRouterRuntime();
|
|
529
|
+
const hydratedAt = performance.now();
|
|
530
|
+
window.__VINEXT_HYDRATED_AT = hydratedAt;
|
|
531
|
+
window.__NEXT_HYDRATED = true;
|
|
532
|
+
window.__NEXT_HYDRATED_AT = hydratedAt;
|
|
533
|
+
window.__NEXT_HYDRATED_CB?.();
|
|
477
534
|
}
|
|
478
535
|
hydrate();
|
|
479
536
|
<\/script>`;
|
|
@@ -482,7 +539,7 @@ hydrate();
|
|
|
482
539
|
page: patternToNextFormat(route.pattern),
|
|
483
540
|
query: params,
|
|
484
541
|
buildId: process.env.__VINEXT_BUILD_ID,
|
|
485
|
-
isFallback:
|
|
542
|
+
isFallback: isFallbackRender,
|
|
486
543
|
locale: locale ?? currentDefaultLocale,
|
|
487
544
|
locales: i18nConfig?.locales,
|
|
488
545
|
defaultLocale: currentDefaultLocale,
|
|
@@ -502,7 +559,7 @@ hydrate();
|
|
|
502
559
|
if (isrRevalidateSeconds) if (scriptNonce) extraHeaders["Cache-Control"] = "no-store, must-revalidate";
|
|
503
560
|
else {
|
|
504
561
|
extraHeaders["Cache-Control"] = `s-maxage=${isrRevalidateSeconds}, stale-while-revalidate`;
|
|
505
|
-
extraHeaders
|
|
562
|
+
Object.assign(extraHeaders, buildCacheStateHeaders("MISS"));
|
|
506
563
|
}
|
|
507
564
|
if (allFontPreloads.length > 0) extraHeaders["Link"] = allFontPreloads.map((p) => `<${p.href}>; rel=preload; as=font; type=${p.type}; crossorigin`).join(", ");
|
|
508
565
|
await streamPageToResponse(res, withScriptNonce(element, scriptNonce), {
|