vinext 0.0.51 → 0.0.53
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/README.md +1 -1
- package/dist/build/clean-output.d.ts +14 -0
- package/dist/build/clean-output.js +36 -0
- package/dist/build/clean-output.js.map +1 -0
- package/dist/build/precompress.d.ts +7 -7
- package/dist/build/precompress.js +18 -17
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +9 -16
- package/dist/build/prerender.js +88 -50
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/run-prerender.js +10 -1
- package/dist/build/run-prerender.js.map +1 -1
- package/dist/build/static-export.d.ts +5 -0
- package/dist/build/static-export.js +8 -3
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.js +4 -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 +58 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/instrumentation-client-inject.d.ts +34 -0
- package/dist/client/instrumentation-client-inject.js +57 -0
- package/dist/client/instrumentation-client-inject.js.map +1 -0
- package/dist/client/navigation-runtime.d.ts +60 -0
- package/dist/client/navigation-runtime.js +171 -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 +14 -3
- 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 +10 -2
- 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/cloudflare/tpr.js +1 -1
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.d.ts +63 -16
- package/dist/config/config-matchers.js +145 -9
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +32 -5
- package/dist/config/next-config.js +55 -15
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +130 -46
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.js +9 -3
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +4 -2
- package/dist/entries/app-rsc-entry.js +76 -16
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +1 -0
- package/dist/entries/app-rsc-manifest.js +53 -6
- 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 +40 -3
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +261 -31
- 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 +161 -46
- package/dist/index.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.js +30 -5
- 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/strip-server-exports.js +5 -8
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +20 -1
- package/dist/routing/app-route-graph.js +58 -6
- 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-trie.js +13 -18
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/utils.d.ts +12 -1
- package/dist/routing/utils.js +18 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +153 -42
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +16 -1
- package/dist/server/app-browser-action-result.js +15 -1
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +309 -155
- package/dist/server/app-browser-entry.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 +3 -1
- package/dist/server/app-browser-navigation-controller.js +5 -1
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-rsc-redirect.d.ts +2 -1
- package/dist/server/app-browser-rsc-redirect.js +2 -2
- package/dist/server/app-browser-rsc-redirect.js.map +1 -1
- package/dist/server/app-browser-state.d.ts +18 -1
- package/dist/server/app-browser-state.js +19 -1
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +5 -14
- package/dist/server/app-browser-stream.js +13 -7
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +2 -1
- package/dist/server/app-browser-visible-commit.js +1 -0
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +10 -5
- package/dist/server/app-elements-wire.js +84 -2
- 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 +12 -3
- package/dist/server/app-fallback-renderer.js +15 -8
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.js +6 -2
- package/dist/server/app-history-state.js.map +1 -1
- package/dist/server/app-interception-context-header.d.ts +33 -0
- package/dist/server/app-interception-context-header.js +44 -0
- package/dist/server/app-interception-context-header.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-mounted-slots-header.d.ts +19 -0
- package/dist/server/app-mounted-slots-header.js +40 -1
- package/dist/server/app-mounted-slots-header.js.map +1 -1
- package/dist/server/app-optimistic-routing.d.ts +54 -0
- package/dist/server/app-optimistic-routing.js +208 -0
- package/dist/server/app-optimistic-routing.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +2 -0
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +1 -0
- package/dist/server/app-page-boundary.js +2 -0
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +15 -1
- package/dist/server/app-page-cache.js +68 -7
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +5 -0
- package/dist/server/app-page-dispatch.js +39 -5
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +7 -3
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +29 -1
- package/dist/server/app-page-execution.js +91 -4
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +1 -0
- package/dist/server/app-page-head.js +29 -2
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.js +1 -1
- package/dist/server/app-page-render-observation.js +1 -1
- package/dist/server/app-page-render.d.ts +3 -0
- package/dist/server/app-page-render.js +7 -3
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-response.d.ts +11 -1
- package/dist/server/app-page-response.js +18 -5
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +35 -15
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +4 -0
- package/dist/server/app-page-stream.js +3 -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 +7 -1
- package/dist/server/app-route-handler-dispatch.js +4 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +18 -2
- package/dist/server/app-route-handler-execution.js +1 -0
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +6 -5
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.js +6 -2
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +11 -1
- package/dist/server/app-rsc-handler.js +48 -21
- 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 +6 -2
- 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.js +2 -2
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-segment-config.d.ts +4 -1
- package/dist/server/app-segment-config.js +6 -1
- package/dist/server/app-segment-config.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +1 -0
- package/dist/server/app-server-action-execution.js +5 -1
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +92 -55
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +30 -2
- package/dist/server/app-ssr-stream.js +95 -8
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +2 -1
- package/dist/server/app-static-generation.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +1 -1
- 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 +49 -3
- package/dist/server/cache-proof.js +78 -22
- 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/default-not-found-module.d.ts +20 -0
- package/dist/server/default-not-found-module.js +20 -0
- package/dist/server/default-not-found-module.js.map +1 -0
- package/dist/server/dev-server.d.ts +10 -2
- package/dist/server/dev-server.js +99 -36
- 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/headers.d.ts +22 -1
- package/dist/server/headers.js +22 -1
- package/dist/server/headers.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +16 -1
- package/dist/server/http-error-responses.js +21 -1
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/image-optimization.d.ts +13 -4
- package/dist/server/image-optimization.js +15 -4
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/isr-cache.d.ts +6 -2
- package/dist/server/isr-cache.js +20 -4
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +15 -0
- package/dist/server/middleware-runtime.js +59 -7
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +5 -3
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +9 -3
- package/dist/server/navigation-planner.js +98 -25
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +2 -1
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +45 -1
- package/dist/server/pages-api-route.js +27 -4
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-body-parser-config.d.ts +60 -0
- package/dist/server/pages-body-parser-config.js +79 -0
- package/dist/server/pages-body-parser-config.js.map +1 -0
- package/dist/server/pages-data-route.d.ts +77 -0
- package/dist/server/pages-data-route.js +98 -0
- package/dist/server/pages-data-route.js.map +1 -0
- package/dist/server/pages-default-404.d.ts +31 -0
- package/dist/server/pages-default-404.js +40 -0
- package/dist/server/pages-default-404.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-node-compat.d.ts +10 -0
- package/dist/server/pages-node-compat.js +12 -1
- package/dist/server/pages-node-compat.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +69 -2
- package/dist/server/pages-page-data.js +47 -31
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +13 -1
- package/dist/server/pages-page-response.js +16 -11
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prerender-route-params.d.ts +14 -0
- package/dist/server/prerender-route-params.js +94 -0
- package/dist/server/prerender-route-params.js.map +1 -0
- package/dist/server/prod-server.d.ts +15 -37
- package/dist/server/prod-server.js +143 -107
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/proxy-trust.d.ts +41 -0
- package/dist/server/proxy-trust.js +70 -0
- package/dist/server/proxy-trust.js.map +1 -0
- package/dist/server/request-pipeline.d.ts +13 -4
- package/dist/server/request-pipeline.js +32 -14
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.d.ts +12 -31
- package/dist/server/seed-cache.js +30 -37
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.js +8 -3
- package/dist/server/server-action-not-found.js.map +1 -1
- 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 +8 -7
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/server/streaming-metadata.d.ts +5 -0
- package/dist/server/streaming-metadata.js +10 -0
- package/dist/server/streaming-metadata.js.map +1 -0
- package/dist/shims/app-router-scroll-state.d.ts +12 -0
- package/dist/shims/app-router-scroll-state.js +38 -0
- package/dist/shims/app-router-scroll-state.js.map +1 -0
- package/dist/shims/app-router-scroll.d.ts +14 -0
- package/dist/shims/app-router-scroll.js +100 -0
- package/dist/shims/app-router-scroll.js.map +1 -0
- package/dist/shims/before-interactive-context.d.ts +30 -0
- package/dist/shims/before-interactive-context.js +10 -0
- package/dist/shims/before-interactive-context.js.map +1 -0
- package/dist/shims/cache-runtime.d.ts +1 -1
- package/dist/shims/cache-runtime.js +14 -1
- package/dist/shims/cache-runtime.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/default-not-found.d.ts +12 -0
- package/dist/shims/default-not-found.js +61 -0
- package/dist/shims/default-not-found.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/font-local.d.ts +5 -0
- package/dist/shims/font-local.js +6 -2
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/form.js +13 -6
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/head.js +4 -4
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +6 -2
- package/dist/shims/headers.js +64 -21
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -1
- package/dist/shims/image.js +4 -4
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/pages-data-target.d.ts +58 -0
- package/dist/shims/internal/pages-data-target.js +91 -0
- package/dist/shims/internal/pages-data-target.js.map +1 -0
- package/dist/shims/internal/pages-data-url.d.ts +42 -0
- package/dist/shims/internal/pages-data-url.js +73 -0
- package/dist/shims/internal/pages-data-url.js.map +1 -0
- package/dist/shims/link.d.ts +21 -3
- package/dist/shims/link.js +189 -30
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +2 -1
- package/dist/shims/metadata.js +65 -6
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +8 -2
- package/dist/shims/navigation.js +67 -23
- package/dist/shims/navigation.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/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 +12 -5
- package/dist/shims/router.js +535 -86
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.js +86 -12
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts +21 -4
- package/dist/shims/server.js +30 -9
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.js +5 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- 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 +2 -1
- package/dist/shims/url-utils.js +15 -4
- 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 +33 -5
- package/dist/utils/asset-prefix.js +39 -6
- package/dist/utils/asset-prefix.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/html-limited-bots.d.ts +5 -0
- package/dist/utils/html-limited-bots.js +15 -0
- package/dist/utils/html-limited-bots.js.map +1 -0
- 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/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 +23 -1
- package/dist/utils/query.js +46 -2
- 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/package.json +11 -3
package/dist/shims/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","names":["UnpicImage"],"sources":["../../src/shims/image.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * next/image shim\n *\n * Translates Next.js Image props to @unpic/react Image component.\n * @unpic/react auto-detects CDN from URL and uses native transforms.\n * For local images (relative paths), routes through `/_vinext/image`\n * for server-side optimization (resize, format negotiation, quality).\n *\n * Remote images are validated against `images.remotePatterns` and\n * `images.domains` from next.config.js. Unmatched URLs are blocked\n * in production and warn in development, matching Next.js behavior.\n */\nimport React, { forwardRef, useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { Image as UnpicImage } from \"@unpic/react\";\nimport { hasRemoteMatch, isPrivateIp, type RemotePattern } from \"./image-config.js\";\nimport { useMergedRef } from \"./use-merged-ref.js\";\n\nexport type StaticImageData = {\n src: string;\n height: number;\n width: number;\n blurDataURL?: string;\n};\n\n/**\n * Image config injected at build time via Vite define.\n * Serialized as JSON — parsed once at module level.\n */\nconst __imageRemotePatterns: RemotePattern[] = (() => {\n try {\n return JSON.parse(process.env.__VINEXT_IMAGE_REMOTE_PATTERNS ?? \"[]\");\n } catch {\n return [];\n }\n})();\nconst __imageDomains: string[] = (() => {\n try {\n return JSON.parse(process.env.__VINEXT_IMAGE_DOMAINS ?? \"[]\");\n } catch {\n return [];\n }\n})();\nconst __hasImageConfig = __imageRemotePatterns.length > 0 || __imageDomains.length > 0;\nconst __isDev = process.env.NODE_ENV !== \"production\";\nconst __imageDeviceSizes: number[] = (() => {\n try {\n return JSON.parse(\n process.env.__VINEXT_IMAGE_DEVICE_SIZES ?? \"[640,750,828,1080,1200,1920,2048,3840]\",\n );\n } catch {\n return [640, 750, 828, 1080, 1200, 1920, 2048, 3840];\n }\n})();\n/**\n * Whether dangerouslyAllowSVG is enabled in next.config.js.\n * When false (default), .svg sources auto-skip the optimization endpoint\n * and are served directly, matching Next.js behavior.\n * When true, .svg sources are routed through the optimizer (served as-is\n * with security headers).\n */\nconst __dangerouslyAllowSVG = process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG === \"true\";\n/**\n * Whether dangerouslyAllowLocalIP is enabled in next.config.js.\n * When false (default), remote image URLs with literal private-IP hostnames\n * are blocked to mitigate SSRF risk.\n */\nconst __dangerouslyAllowLocalIP = process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP === \"true\";\n\n/**\n * Validate that a remote URL is allowed by the configured remote patterns.\n * Returns true if the URL is allowed, false otherwise.\n *\n * When no remotePatterns/domains are configured, all remote URLs are allowed\n * (backwards-compatible — user hasn't opted into restriction).\n *\n * When patterns ARE configured, only matching URLs are allowed.\n * In development, non-matching URLs produce a console warning.\n * In production, non-matching URLs are blocked (src replaced with empty string).\n *\n * Private-IP hostnames are additionally rejected unless dangerouslyAllowLocalIP\n * is set, mirroring Next.js's fetchExternalImage guard.\n */\nfunction validateRemoteUrl(src: string): { allowed: boolean; reason?: string } {\n let url: URL;\n try {\n url = new URL(src, \"http://n\");\n } catch {\n return { allowed: false, reason: `Invalid URL: ${src}` };\n }\n\n if (!__dangerouslyAllowLocalIP && isPrivateIp(url.hostname)) {\n // Best-effort guard for literal-IP hostnames only. Domain names resolving\n // to private IPs cannot be caught without server-side DNS resolution.\n // See: Next.js fetchExternalImage in packages/next/src/server/image-optimizer.ts\n return {\n allowed: false,\n reason: `Image URL \"${src}\" resolved to private IP. If this is expected and you understand SSRF risk, use images.dangerouslyAllowLocalIP = true to continue.`,\n };\n }\n\n if (!__hasImageConfig) {\n // No image config — allow everything (backwards-compatible)\n return { allowed: true };\n }\n\n if (hasRemoteMatch(__imageDomains, __imageRemotePatterns, url)) {\n return { allowed: true };\n }\n\n return {\n allowed: false,\n reason: `Image URL \"${src}\" is not configured in images.remotePatterns or images.domains in next.config.js. See: https://nextjs.org/docs/messages/next-image-unconfigured-host`,\n };\n}\n\n/**\n * A version of useLayoutEffect that doesn't warn during SSR.\n * Do not rename this to \"isomorphic layout effect\". There is no such thing as\n * an isomorphic Layout Effect since there is no Layout on the server.\n * Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n */\nconst useNonWarningLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/**\n * Create a synthetic React load event for replaying onLoad/onLoadingComplete\n * during hydration when the image already completed loading.\n *\n * This function creates a native Event(\"load\") via the DOM Event constructor\n * and must only be called in a browser context (client-side layout effect).\n * It mirrors the pattern used in Next.js `handleLoading`.\n */\nfunction createSyntheticLoadEvent(img: HTMLImageElement): React.SyntheticEvent<HTMLImageElement> {\n const nativeEvent = new Event(\"load\");\n Object.defineProperty(nativeEvent, \"target\", { writable: false, value: img });\n let prevented = false;\n let stopped = false;\n return {\n bubbles: nativeEvent.bubbles,\n cancelable: nativeEvent.cancelable,\n currentTarget: img,\n defaultPrevented: false,\n eventPhase: nativeEvent.eventPhase,\n isTrusted: false,\n nativeEvent,\n target: img,\n timeStamp: nativeEvent.timeStamp,\n type: \"load\",\n isDefaultPrevented: () => prevented,\n isPropagationStopped: () => stopped,\n persist: () => {},\n preventDefault: () => {\n prevented = true;\n nativeEvent.preventDefault();\n },\n stopPropagation: () => {\n stopped = true;\n nativeEvent.stopPropagation();\n },\n };\n}\n\ntype ImageProps = {\n src: string | StaticImageData;\n alt: string;\n width?: number;\n height?: number;\n fill?: boolean;\n preload?: boolean;\n priority?: boolean;\n quality?: number;\n placeholder?: \"blur\" | \"empty\";\n blurDataURL?: string;\n loader?: (params: { src: string; width: number; quality?: number }) => string;\n sizes?: string;\n className?: string;\n style?: React.CSSProperties;\n onLoad?: React.ReactEventHandler<HTMLImageElement>;\n /** @deprecated Use onLoad instead. Still supported for migration compat. */\n onLoadingComplete?: (img: HTMLImageElement) => void;\n onError?: React.ReactEventHandler<HTMLImageElement>;\n onClick?: React.MouseEventHandler<HTMLImageElement>;\n id?: string;\n // Accept and ignore Next.js-specific props that don't apply\n unoptimized?: boolean;\n overrideSrc?: string;\n loading?: \"lazy\" | \"eager\";\n};\n\n/**\n * Sanitize a blurDataURL to prevent CSS injection.\n *\n * A crafted data URL containing `)` can break out of the `url()` CSS function,\n * allowing injection of arbitrary CSS properties or rules. Characters like `{`,\n * `}`, and `\\` can also assist in crafting injection payloads.\n *\n * This validates the URL starts with `data:image/` and rejects characters that\n * could escape the `url()` context. Semicolons are allowed since they're part\n * of valid data URLs (`data:image/png;base64,...`) and harmless inside `url()`.\n *\n * Returns undefined for invalid URLs, which causes the blur placeholder to be\n * skipped gracefully.\n */\nfunction sanitizeBlurDataURL(url: string): string | undefined {\n // Must be a data: image URL\n if (!url.startsWith(\"data:image/\")) return undefined;\n // Reject characters that can break out of CSS url():\n // ) - closes url()\n // ( - could open nested functions\n // { } - CSS rule boundaries\n // \\ - CSS escape sequences\n // newlines - break CSS parsing\n if (/[)(}{\\\\'\"\\n\\r]/.test(url)) return undefined;\n return url;\n}\n\n/**\n * Determine if a src is a remote URL (CDN-optimizable) or local.\n */\nfunction isRemoteUrl(src: string): boolean {\n return src.startsWith(\"http://\") || src.startsWith(\"https://\") || src.startsWith(\"//\");\n}\n\nfunction getFillStyle(\n style?: React.CSSProperties,\n backgroundStyle?: React.CSSProperties,\n): React.CSSProperties {\n return {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n ...backgroundStyle,\n ...style,\n };\n}\n\n/**\n * Resolve src, width, height, blurDataURL from Image props (string or StaticImageData).\n * Shared by the Image component and getImageProps to keep behavior in sync.\n */\nfunction resolveImageSource(v: {\n src: string | StaticImageData;\n width?: number;\n height?: number;\n blurDataURL?: string;\n}): { src: string; width?: number; height?: number; blurDataURL?: string } {\n const src = typeof v.src === \"string\" ? v.src : v.src.src;\n const imgWidth = v.width ?? (typeof v.src === \"object\" ? v.src.width : undefined);\n const imgHeight = v.height ?? (typeof v.src === \"object\" ? v.src.height : undefined);\n const imgBlurDataURL =\n v.blurDataURL ?? (typeof v.src === \"object\" ? v.src.blurDataURL : undefined);\n return { src, width: imgWidth, height: imgHeight, blurDataURL: imgBlurDataURL };\n}\n\n/**\n * Responsive image widths matching Next.js's device sizes config.\n * These are the breakpoints used for srcSet generation.\n * Configurable via `images.deviceSizes` in next.config.js.\n */\nconst RESPONSIVE_WIDTHS = __imageDeviceSizes;\n\n/**\n * Build a `/_vinext/image` optimization URL.\n *\n * In production (Cloudflare Workers), the worker intercepts this path and uses\n * the Images binding to resize/transcode on the fly. In dev, the Vite dev\n * server handles it as a passthrough (serves the original file).\n */\nexport function imageOptimizationUrl(src: string, width: number, quality: number = 75): string {\n return `/_vinext/image?url=${encodeURIComponent(src)}&w=${width}&q=${quality}`;\n}\n\nfunction preloadImageResource(input: {\n shouldPreload: boolean;\n src: string;\n srcSet?: string;\n sizes?: string;\n fetchPriority?: ReactDOM.PreloadOptions[\"fetchPriority\"];\n}): void {\n if (!input.shouldPreload) return;\n if (typeof ReactDOM.preload !== \"function\") return;\n ReactDOM.preload(input.src, {\n as: \"image\",\n imageSrcSet: input.srcSet,\n imageSizes: input.sizes,\n fetchPriority: input.fetchPriority,\n });\n}\n\n/**\n * Generate a srcSet string for responsive images.\n *\n * Each width points to the `/_vinext/image` optimization endpoint so the\n * server can resize and transcode the image. Only includes widths that are\n * <= 2x the original image width to avoid pointless upscaling.\n */\nfunction generateSrcSet(src: string, originalWidth: number, quality: number = 75): string {\n const widths = RESPONSIVE_WIDTHS.filter((w) => w <= originalWidth * 2);\n if (widths.length === 0)\n return `${imageOptimizationUrl(src, originalWidth, quality)} ${originalWidth}w`;\n return widths.map((w) => `${imageOptimizationUrl(src, w, quality)} ${w}w`).join(\", \");\n}\n\nconst Image = forwardRef<HTMLImageElement, ImageProps>(function Image(\n {\n src: srcProp,\n alt,\n width,\n height,\n fill,\n preload,\n priority,\n quality,\n placeholder,\n blurDataURL,\n loader,\n sizes,\n className,\n style,\n onLoad,\n onLoadingComplete,\n onError,\n unoptimized: _unoptimized,\n overrideSrc: _overrideSrc,\n loading,\n ...rest\n },\n ref,\n) {\n // Dedup refs: ensure onLoad and onError fire at most once per src per mount.\n // Matches Next.js behavior — prevents double-firing from React re-renders,\n // strict-mode double-invocation, or state updates inside the handler itself.\n // Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n const lastLoadedSrcRef = useRef<string | undefined>(undefined);\n const lastErrorSrcRef = useRef<string | undefined>(undefined);\n\n // Hydration-level onError replay: when an image fails to load during SSR\n // streaming or initial HTML parse (before React hydrates), the native browser\n // error event is lost. Re-trigger it via `img.src = img.src` in a layout\n // effect once hydration completes, mirroring the upstream Next.js fix.\n // Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n const didInsertRef = useRef(false);\n const imgElementRef = useRef<HTMLImageElement | null>(null);\n\n // Merge forwarded ref with internal img ref for layout effect access.\n const mergedRef = useMergedRef(ref, imgElementRef);\n\n // Stable refs for onLoad / onError / onLoadingComplete so the layout effect\n // does not re-run (and re-assign img.src) when handler identity changes.\n // Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n //\n // IMPORTANT: The useRef+useEffect sync pattern has a subtle timing gap:\n // during the first render, onLoadRef.current holds the initial value from\n // useRef(onLoad), and the useEffect to sync it runs AFTER the layout effect.\n // This means on first mount the layout effect reads the correct initial\n // value (passed to useRef). If someone changes useRef(onLoad) to\n // useRef(undefined), the layout effect would read undefined on first mount.\n const onLoadRef = useRef(onLoad);\n useEffect(() => {\n onLoadRef.current = onLoad;\n }, [onLoad]);\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n const onLoadingCompleteRef = useRef(onLoadingComplete);\n useEffect(() => {\n onLoadingCompleteRef.current = onLoadingComplete;\n }, [onLoadingComplete]);\n\n const {\n src,\n width: imgWidth,\n height: imgHeight,\n blurDataURL: imgBlurDataURL,\n } = resolveImageSource({ src: srcProp, width, height, blurDataURL });\n const shouldPreload = preload === true || priority === true;\n const priorityFetchPriority = priority ? \"high\" : undefined;\n const imageLoading = priority ? \"eager\" : shouldPreload ? loading : (loading ?? \"lazy\");\n\n const [completedBlurSrc, setCompletedBlurSrc] = useState<string | undefined>(undefined);\n const blurComplete = completedBlurSrc === src;\n\n const markBlurComplete = () => {\n if (placeholder !== \"blur\") return;\n setCompletedBlurSrc((current) => (current === src ? current : src));\n };\n\n useNonWarningLayoutEffect(() => {\n if (!didInsertRef.current && imgElementRef.current !== null) {\n const img = imgElementRef.current;\n // Replay error events lost during SSR/hydration.\n if (onErrorRef.current) {\n // eslint-disable-next-line no-self-assign\n img.src = img.src;\n }\n // Replay onLoad for images that completed loading before React hydrated\n // (e.g. SSR streaming where the image arrives and renders before hydration\n // finishes). Without this, onLoad never fires for those images.\n //\n // img.complete is true for both successfully-loaded and errored images\n // (the HTML spec defines complete as true when the browser finished\n // fetching, regardless of outcome). We must check naturalWidth > 0 to\n // distinguish success from error — a failed image has naturalWidth === 0.\n // Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n if (img.complete && img.naturalWidth > 0) {\n markBlurComplete();\n const currentOnLoad = onLoadRef.current;\n const currentOnLoadingComplete = onLoadingCompleteRef.current;\n if (currentOnLoad || currentOnLoadingComplete) {\n // Dedup — fire at most once per src per mount, matching onLoad dedup\n if (lastLoadedSrcRef.current !== src) {\n lastLoadedSrcRef.current = src;\n // Create a synthetic React event with the expected shape.\n // next/image uses a similar pattern in `handleLoading`.\n const syntheticEvent = createSyntheticLoadEvent(img);\n currentOnLoad?.(syntheticEvent);\n currentOnLoadingComplete?.(img);\n }\n }\n }\n didInsertRef.current = true;\n }\n }, [placeholder, sizes, _unoptimized]);\n\n // Wire onLoadingComplete (deprecated) into onLoad — matches Next.js behavior.\n // onLoad fires first, then onLoadingComplete receives the HTMLImageElement.\n const handleLoad = onLoadingComplete\n ? (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (lastLoadedSrcRef.current === src) return;\n lastLoadedSrcRef.current = src;\n markBlurComplete();\n onLoad?.(e);\n onLoadingComplete(e.currentTarget);\n }\n : onLoad\n ? (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (lastLoadedSrcRef.current === src) return;\n lastLoadedSrcRef.current = src;\n markBlurComplete();\n onLoad(e);\n }\n : placeholder === \"blur\"\n ? () => {\n if (lastLoadedSrcRef.current === src) return;\n lastLoadedSrcRef.current = src;\n markBlurComplete();\n }\n : undefined;\n\n const handleError = onError\n ? (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (lastErrorSrcRef.current === src) return;\n lastErrorSrcRef.current = src;\n markBlurComplete();\n onError(e);\n }\n : placeholder === \"blur\"\n ? () => {\n if (lastErrorSrcRef.current === src) return;\n lastErrorSrcRef.current = src;\n markBlurComplete();\n }\n : undefined;\n\n // If a custom loader is provided, use basic img with loader URL\n if (loader) {\n const resolvedSrc = loader({ src, width: imgWidth ?? 0, quality: quality ?? 75 });\n preloadImageResource({\n shouldPreload,\n src: resolvedSrc,\n sizes,\n fetchPriority: priorityFetchPriority,\n });\n return (\n <img\n ref={mergedRef}\n src={resolvedSrc}\n alt={alt}\n width={fill ? undefined : imgWidth}\n height={fill ? undefined : imgHeight}\n loading={imageLoading}\n decoding=\"async\"\n sizes={sizes}\n className={className}\n onLoad={handleLoad}\n onError={handleError}\n style={fill ? getFillStyle(style) : style}\n {...rest}\n />\n );\n }\n\n // For remote URLs, validate against remotePatterns. Non-fill images use\n // @unpic/react for CDN URL transforms; fill uses a plain img so the DOM\n // element keeps Next.js's absolute-positioned fill contract.\n if (isRemoteUrl(src)) {\n const validation = validateRemoteUrl(src);\n if (!validation.allowed) {\n if (__isDev) {\n console.warn(`[next/image] ${validation.reason}`);\n // In dev, render the image but with a warning — matches Next.js dev behavior\n } else {\n // In production, block the image entirely\n console.error(`[next/image] ${validation.reason}`);\n return null;\n }\n }\n\n const sanitizedBlur = imgBlurDataURL ? sanitizeBlurDataURL(imgBlurDataURL) : undefined;\n const showBlur = !blurComplete && placeholder === \"blur\" && sanitizedBlur;\n const blurStyle = showBlur\n ? {\n backgroundImage: `url(${sanitizedBlur})`,\n backgroundSize: \"cover\",\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: \"center\",\n }\n : undefined;\n const bg = showBlur ? `url(${sanitizedBlur})` : undefined;\n\n if (fill) {\n const fillSizes = sizes ?? \"100vw\";\n preloadImageResource({\n shouldPreload,\n src,\n sizes: fillSizes,\n fetchPriority: priorityFetchPriority,\n });\n return (\n <img\n ref={mergedRef}\n src={src}\n alt={alt}\n // `priority` is a Next.js concept — translate it to HTML attributes so\n // it is never forwarded to the DOM as a non-boolean attribute, which\n // would trigger React's \"Received `true` for a non-boolean attribute\"\n // warning.\n loading={imageLoading}\n fetchPriority={priorityFetchPriority}\n decoding=\"async\"\n sizes={fillSizes}\n className={className}\n data-nimg=\"fill\"\n onLoad={handleLoad}\n onError={handleError}\n style={getFillStyle(style, blurStyle)}\n {...rest}\n />\n );\n }\n // constrained layout requires width+height or aspectRatio\n if (imgWidth && imgHeight) {\n // @unpic/react forwards additional image props through transformProps and\n // merges `style` with generated layout styles at runtime, but its public\n // React type omits `style`.\n const unpicRuntimeStyleProps: { style?: React.CSSProperties } = { style };\n preloadImageResource({\n shouldPreload,\n src,\n sizes,\n fetchPriority: priorityFetchPriority,\n });\n return (\n <UnpicImage\n src={src}\n alt={alt}\n width={imgWidth}\n height={imgHeight}\n layout=\"constrained\"\n // Same translation as above — never pass `priority` to the DOM.\n loading={imageLoading}\n fetchPriority={priorityFetchPriority}\n sizes={sizes}\n className={className}\n {...unpicRuntimeStyleProps}\n background={bg}\n onLoad={handleLoad}\n onError={handleError}\n ref={mergedRef}\n />\n );\n }\n // Fall through to basic <img> if dimensions not provided\n // (unpic requires them for constrained layout)\n }\n\n // Route local images through the /_vinext/image optimization endpoint.\n // In production on Cloudflare Workers, this resizes and transcodes via\n // the Images binding. In dev, it serves the original file as a passthrough.\n // When `unoptimized` is true, bypass the endpoint entirely (Next.js compat).\n // SVG sources auto-skip unless dangerouslyAllowSVG is enabled, matching\n // Next.js behavior where .svg triggers unoptimized=true by default.\n const imgQuality = quality ?? 75;\n const isSvg = src.endsWith(\".svg\");\n const skipOptimization = _unoptimized === true || (isSvg && !__dangerouslyAllowSVG);\n\n // Build srcSet for responsive local images (common breakpoints).\n // Each entry points to /_vinext/image with the appropriate width.\n const srcSet =\n imgWidth && !fill && !skipOptimization\n ? generateSrcSet(src, imgWidth, imgQuality)\n : imgWidth && !fill\n ? RESPONSIVE_WIDTHS.filter((w) => w <= imgWidth * 2)\n .map((w) => `${src} ${w}w`)\n .join(\", \") || `${src} ${imgWidth}w`\n : undefined;\n\n // The main `src` also goes through the optimization endpoint. Use the\n // declared width (or the first responsive width as fallback).\n const optimizedSrc = skipOptimization\n ? src\n : imgWidth\n ? imageOptimizationUrl(src, imgWidth, imgQuality)\n : imageOptimizationUrl(src, RESPONSIVE_WIDTHS[0], imgQuality);\n\n // Blur placeholder: show a low-quality background while the image loads.\n // Sanitize blurDataURL to prevent CSS injection via crafted data URLs.\n const sanitizedLocalBlur = imgBlurDataURL ? sanitizeBlurDataURL(imgBlurDataURL) : undefined;\n const blurStyle =\n !blurComplete && placeholder === \"blur\" && sanitizedLocalBlur\n ? {\n backgroundImage: `url(${sanitizedLocalBlur})`,\n backgroundSize: \"cover\",\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: \"center\",\n }\n : undefined;\n\n const imageSizes = sizes ?? (fill ? \"100vw\" : undefined);\n preloadImageResource({\n shouldPreload,\n src: optimizedSrc,\n srcSet,\n sizes: imageSizes,\n fetchPriority: priorityFetchPriority,\n });\n\n // For local images, render a standard <img> tag with srcSet and blur support.\n // The src and srcSet point to the /_vinext/image optimization endpoint.\n return (\n <img\n ref={mergedRef}\n src={optimizedSrc}\n alt={alt}\n width={fill ? undefined : imgWidth}\n height={fill ? undefined : imgHeight}\n loading={imageLoading}\n fetchPriority={priorityFetchPriority}\n decoding=\"async\"\n srcSet={srcSet}\n sizes={imageSizes}\n className={className}\n data-nimg={fill ? \"fill\" : \"1\"}\n onLoad={handleLoad}\n onError={handleError}\n style={fill ? getFillStyle(style, blurStyle) : { ...blurStyle, ...style }}\n {...rest}\n />\n );\n});\n\n/**\n * getImageProps — for advanced use cases (picture elements, background images).\n * Returns the props that would be passed to the underlying <img> element.\n */\nexport function getImageProps(props: ImageProps): {\n props: React.ImgHTMLAttributes<HTMLImageElement>;\n} {\n const {\n src: srcProp,\n alt,\n width,\n height,\n fill,\n preload: _preload,\n priority,\n quality: _quality,\n placeholder,\n blurDataURL: blurDataURLProp,\n loader,\n sizes,\n className,\n style,\n onLoad: _onLoad,\n onLoadingComplete: _onLoadingComplete,\n unoptimized: _unoptimized,\n overrideSrc: _overrideSrc,\n loading,\n ...rest\n } = props;\n\n const {\n src,\n width: imgWidth,\n height: imgHeight,\n blurDataURL: imgBlurDataURL,\n } = resolveImageSource({ src: srcProp, width, height, blurDataURL: blurDataURLProp });\n const shouldPreload = _preload === true || priority === true;\n\n // Validate remote URLs against configured patterns\n let blockedInProd = false;\n if (isRemoteUrl(src)) {\n const validation = validateRemoteUrl(src);\n if (!validation.allowed) {\n if (__isDev) {\n console.warn(`[next/image] ${validation.reason}`);\n } else {\n console.error(`[next/image] ${validation.reason}`);\n blockedInProd = true;\n }\n }\n }\n\n // Resolve src through custom loader if provided\n const imgQuality = _quality ?? 75;\n const resolvedSrc = blockedInProd\n ? \"\"\n : loader\n ? loader({ src, width: imgWidth ?? 0, quality: imgQuality })\n : src;\n\n // For local images (no loader, not remote), route through optimization endpoint.\n // When `unoptimized` is true, bypass the endpoint entirely (Next.js compat).\n // SVG sources auto-skip unless dangerouslyAllowSVG is enabled.\n const isSvg = resolvedSrc.endsWith(\".svg\");\n const skipOpt =\n _unoptimized === true ||\n (isSvg && !__dangerouslyAllowSVG) ||\n blockedInProd ||\n !!loader ||\n isRemoteUrl(resolvedSrc);\n const optimizedSrc = skipOpt\n ? resolvedSrc\n : imgWidth\n ? imageOptimizationUrl(resolvedSrc, imgWidth, imgQuality)\n : imageOptimizationUrl(resolvedSrc, RESPONSIVE_WIDTHS[0], imgQuality);\n\n // Build srcSet for local images — each width points to /_vinext/image\n const srcSet =\n imgWidth && !fill && !isRemoteUrl(resolvedSrc) && !loader && !skipOpt\n ? generateSrcSet(resolvedSrc, imgWidth, imgQuality)\n : undefined;\n\n // Blur placeholder styles — sanitize to prevent CSS injection\n const sanitizedBlurURL = imgBlurDataURL ? sanitizeBlurDataURL(imgBlurDataURL) : undefined;\n const blurStyle =\n placeholder === \"blur\" && sanitizedBlurURL\n ? {\n backgroundImage: `url(${sanitizedBlurURL})`,\n backgroundSize: \"cover\",\n backgroundRepeat: \"no-repeat\" as const,\n backgroundPosition: \"center\" as const,\n }\n : undefined;\n\n return {\n props: {\n src: optimizedSrc,\n alt,\n width: fill ? undefined : imgWidth,\n height: fill ? undefined : imgHeight,\n loading: priority ? \"eager\" : shouldPreload ? loading : (loading ?? \"lazy\"),\n fetchPriority: priority ? (\"high\" as const) : undefined,\n decoding: \"async\" as const,\n srcSet,\n sizes: sizes ?? (fill ? \"100vw\" : undefined),\n className,\n \"data-nimg\": fill ? \"fill\" : \"1\",\n style: fill ? getFillStyle(style, blurStyle) : { ...blurStyle, ...style },\n ...rest,\n } as React.ImgHTMLAttributes<HTMLImageElement>,\n };\n}\n\nexport default Image;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,+BAAgD;CACpD,IAAI;EACF,OAAO,KAAK,MAAM,QAAQ,IAAI,kCAAkC,KAAK;SAC/D;EACN,OAAO,EAAE;;IAET;AACJ,MAAM,wBAAkC;CACtC,IAAI;EACF,OAAO,KAAK,MAAM,QAAQ,IAAI,0BAA0B,KAAK;SACvD;EACN,OAAO,EAAE;;IAET;AACJ,MAAM,mBAAmB,sBAAsB,SAAS,KAAK,eAAe,SAAS;AACrF,MAAM,UAAU,QAAQ,IAAI,aAAa;AACzC,MAAM,4BAAsC;CAC1C,IAAI;EACF,OAAO,KAAK,MACV,QAAQ,IAAI,+BAA+B,yCAC5C;SACK;EACN,OAAO;GAAC;GAAK;GAAK;GAAK;GAAM;GAAM;GAAM;GAAM;GAAK;;IAEpD;;;;;;;;AAQJ,MAAM,wBAAwB,QA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"file":"image.js","names":["UnpicImage"],"sources":["../../src/shims/image.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * next/image shim\n *\n * Translates Next.js Image props to @unpic/react Image component.\n * @unpic/react auto-detects CDN from URL and uses native transforms.\n * For local images (relative paths), routes through `/_next/image`\n * for server-side optimization (resize, format negotiation, quality).\n *\n * Remote images are validated against `images.remotePatterns` and\n * `images.domains` from next.config.js. Unmatched URLs are blocked\n * in production and warn in development, matching Next.js behavior.\n */\nimport React, { forwardRef, useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { Image as UnpicImage } from \"@unpic/react\";\nimport { hasRemoteMatch, isPrivateIp, type RemotePattern } from \"./image-config.js\";\nimport { useMergedRef } from \"./use-merged-ref.js\";\n\nexport type StaticImageData = {\n src: string;\n height: number;\n width: number;\n blurDataURL?: string;\n};\n\n/**\n * Image config injected at build time via Vite define.\n * Serialized as JSON — parsed once at module level.\n */\nconst __imageRemotePatterns: RemotePattern[] = (() => {\n try {\n return JSON.parse(process.env.__VINEXT_IMAGE_REMOTE_PATTERNS ?? \"[]\");\n } catch {\n return [];\n }\n})();\nconst __imageDomains: string[] = (() => {\n try {\n return JSON.parse(process.env.__VINEXT_IMAGE_DOMAINS ?? \"[]\");\n } catch {\n return [];\n }\n})();\nconst __hasImageConfig = __imageRemotePatterns.length > 0 || __imageDomains.length > 0;\nconst __isDev = process.env.NODE_ENV !== \"production\";\nconst __imageDeviceSizes: number[] = (() => {\n try {\n return JSON.parse(\n process.env.__VINEXT_IMAGE_DEVICE_SIZES ?? \"[640,750,828,1080,1200,1920,2048,3840]\",\n );\n } catch {\n return [640, 750, 828, 1080, 1200, 1920, 2048, 3840];\n }\n})();\n/**\n * Whether dangerouslyAllowSVG is enabled in next.config.js.\n * When false (default), .svg sources auto-skip the optimization endpoint\n * and are served directly, matching Next.js behavior.\n * When true, .svg sources are routed through the optimizer (served as-is\n * with security headers).\n */\nconst __dangerouslyAllowSVG = process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG === \"true\";\n/**\n * Whether dangerouslyAllowLocalIP is enabled in next.config.js.\n * When false (default), remote image URLs with literal private-IP hostnames\n * are blocked to mitigate SSRF risk.\n */\nconst __dangerouslyAllowLocalIP = process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP === \"true\";\n\n/**\n * Validate that a remote URL is allowed by the configured remote patterns.\n * Returns true if the URL is allowed, false otherwise.\n *\n * When no remotePatterns/domains are configured, all remote URLs are allowed\n * (backwards-compatible — user hasn't opted into restriction).\n *\n * When patterns ARE configured, only matching URLs are allowed.\n * In development, non-matching URLs produce a console warning.\n * In production, non-matching URLs are blocked (src replaced with empty string).\n *\n * Private-IP hostnames are additionally rejected unless dangerouslyAllowLocalIP\n * is set, mirroring Next.js's fetchExternalImage guard.\n */\nfunction validateRemoteUrl(src: string): { allowed: boolean; reason?: string } {\n let url: URL;\n try {\n url = new URL(src, \"http://n\");\n } catch {\n return { allowed: false, reason: `Invalid URL: ${src}` };\n }\n\n if (!__dangerouslyAllowLocalIP && isPrivateIp(url.hostname)) {\n // Best-effort guard for literal-IP hostnames only. Domain names resolving\n // to private IPs cannot be caught without server-side DNS resolution.\n // See: Next.js fetchExternalImage in packages/next/src/server/image-optimizer.ts\n return {\n allowed: false,\n reason: `Image URL \"${src}\" resolved to private IP. If this is expected and you understand SSRF risk, use images.dangerouslyAllowLocalIP = true to continue.`,\n };\n }\n\n if (!__hasImageConfig) {\n // No image config — allow everything (backwards-compatible)\n return { allowed: true };\n }\n\n if (hasRemoteMatch(__imageDomains, __imageRemotePatterns, url)) {\n return { allowed: true };\n }\n\n return {\n allowed: false,\n reason: `Image URL \"${src}\" is not configured in images.remotePatterns or images.domains in next.config.js. See: https://nextjs.org/docs/messages/next-image-unconfigured-host`,\n };\n}\n\n/**\n * A version of useLayoutEffect that doesn't warn during SSR.\n * Do not rename this to \"isomorphic layout effect\". There is no such thing as\n * an isomorphic Layout Effect since there is no Layout on the server.\n * Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n */\nconst useNonWarningLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/**\n * Create a synthetic React load event for replaying onLoad/onLoadingComplete\n * during hydration when the image already completed loading.\n *\n * This function creates a native Event(\"load\") via the DOM Event constructor\n * and must only be called in a browser context (client-side layout effect).\n * It mirrors the pattern used in Next.js `handleLoading`.\n */\nfunction createSyntheticLoadEvent(img: HTMLImageElement): React.SyntheticEvent<HTMLImageElement> {\n const nativeEvent = new Event(\"load\");\n Object.defineProperty(nativeEvent, \"target\", { writable: false, value: img });\n let prevented = false;\n let stopped = false;\n return {\n bubbles: nativeEvent.bubbles,\n cancelable: nativeEvent.cancelable,\n currentTarget: img,\n defaultPrevented: false,\n eventPhase: nativeEvent.eventPhase,\n isTrusted: false,\n nativeEvent,\n target: img,\n timeStamp: nativeEvent.timeStamp,\n type: \"load\",\n isDefaultPrevented: () => prevented,\n isPropagationStopped: () => stopped,\n persist: () => {},\n preventDefault: () => {\n prevented = true;\n nativeEvent.preventDefault();\n },\n stopPropagation: () => {\n stopped = true;\n nativeEvent.stopPropagation();\n },\n };\n}\n\ntype ImageProps = {\n src: string | StaticImageData;\n alt: string;\n width?: number;\n height?: number;\n fill?: boolean;\n preload?: boolean;\n priority?: boolean;\n quality?: number;\n placeholder?: \"blur\" | \"empty\";\n blurDataURL?: string;\n loader?: (params: { src: string; width: number; quality?: number }) => string;\n sizes?: string;\n className?: string;\n style?: React.CSSProperties;\n onLoad?: React.ReactEventHandler<HTMLImageElement>;\n /** @deprecated Use onLoad instead. Still supported for migration compat. */\n onLoadingComplete?: (img: HTMLImageElement) => void;\n onError?: React.ReactEventHandler<HTMLImageElement>;\n onClick?: React.MouseEventHandler<HTMLImageElement>;\n id?: string;\n // Accept and ignore Next.js-specific props that don't apply\n unoptimized?: boolean;\n overrideSrc?: string;\n loading?: \"lazy\" | \"eager\";\n};\n\n/**\n * Sanitize a blurDataURL to prevent CSS injection.\n *\n * A crafted data URL containing `)` can break out of the `url()` CSS function,\n * allowing injection of arbitrary CSS properties or rules. Characters like `{`,\n * `}`, and `\\` can also assist in crafting injection payloads.\n *\n * This validates the URL starts with `data:image/` and rejects characters that\n * could escape the `url()` context. Semicolons are allowed since they're part\n * of valid data URLs (`data:image/png;base64,...`) and harmless inside `url()`.\n *\n * Returns undefined for invalid URLs, which causes the blur placeholder to be\n * skipped gracefully.\n */\nfunction sanitizeBlurDataURL(url: string): string | undefined {\n // Must be a data: image URL\n if (!url.startsWith(\"data:image/\")) return undefined;\n // Reject characters that can break out of CSS url():\n // ) - closes url()\n // ( - could open nested functions\n // { } - CSS rule boundaries\n // \\ - CSS escape sequences\n // newlines - break CSS parsing\n if (/[)(}{\\\\'\"\\n\\r]/.test(url)) return undefined;\n return url;\n}\n\n/**\n * Determine if a src is a remote URL (CDN-optimizable) or local.\n */\nfunction isRemoteUrl(src: string): boolean {\n return src.startsWith(\"http://\") || src.startsWith(\"https://\") || src.startsWith(\"//\");\n}\n\nfunction getFillStyle(\n style?: React.CSSProperties,\n backgroundStyle?: React.CSSProperties,\n): React.CSSProperties {\n return {\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n ...backgroundStyle,\n ...style,\n };\n}\n\n/**\n * Resolve src, width, height, blurDataURL from Image props (string or StaticImageData).\n * Shared by the Image component and getImageProps to keep behavior in sync.\n */\nfunction resolveImageSource(v: {\n src: string | StaticImageData;\n width?: number;\n height?: number;\n blurDataURL?: string;\n}): { src: string; width?: number; height?: number; blurDataURL?: string } {\n const src = typeof v.src === \"string\" ? v.src : v.src.src;\n const imgWidth = v.width ?? (typeof v.src === \"object\" ? v.src.width : undefined);\n const imgHeight = v.height ?? (typeof v.src === \"object\" ? v.src.height : undefined);\n const imgBlurDataURL =\n v.blurDataURL ?? (typeof v.src === \"object\" ? v.src.blurDataURL : undefined);\n return { src, width: imgWidth, height: imgHeight, blurDataURL: imgBlurDataURL };\n}\n\n/**\n * Responsive image widths matching Next.js's device sizes config.\n * These are the breakpoints used for srcSet generation.\n * Configurable via `images.deviceSizes` in next.config.js.\n */\nconst RESPONSIVE_WIDTHS = __imageDeviceSizes;\n\n/**\n * Build a `/_next/image` optimization URL.\n *\n * In production (Cloudflare Workers), the worker intercepts this path and uses\n * the Images binding to resize/transcode on the fly. In dev, the Vite dev\n * server handles it as a passthrough (serves the original file).\n */\nexport function imageOptimizationUrl(src: string, width: number, quality: number = 75): string {\n return `/_next/image?url=${encodeURIComponent(src)}&w=${width}&q=${quality}`;\n}\n\nfunction preloadImageResource(input: {\n shouldPreload: boolean;\n src: string;\n srcSet?: string;\n sizes?: string;\n fetchPriority?: ReactDOM.PreloadOptions[\"fetchPriority\"];\n}): void {\n if (!input.shouldPreload) return;\n if (typeof ReactDOM.preload !== \"function\") return;\n ReactDOM.preload(input.src, {\n as: \"image\",\n imageSrcSet: input.srcSet,\n imageSizes: input.sizes,\n fetchPriority: input.fetchPriority,\n });\n}\n\n/**\n * Generate a srcSet string for responsive images.\n *\n * Each width points to the `/_next/image` optimization endpoint so the\n * server can resize and transcode the image. Only includes widths that are\n * <= 2x the original image width to avoid pointless upscaling.\n */\nfunction generateSrcSet(src: string, originalWidth: number, quality: number = 75): string {\n const widths = RESPONSIVE_WIDTHS.filter((w) => w <= originalWidth * 2);\n if (widths.length === 0)\n return `${imageOptimizationUrl(src, originalWidth, quality)} ${originalWidth}w`;\n return widths.map((w) => `${imageOptimizationUrl(src, w, quality)} ${w}w`).join(\", \");\n}\n\nconst Image = forwardRef<HTMLImageElement, ImageProps>(function Image(\n {\n src: srcProp,\n alt,\n width,\n height,\n fill,\n preload,\n priority,\n quality,\n placeholder,\n blurDataURL,\n loader,\n sizes,\n className,\n style,\n onLoad,\n onLoadingComplete,\n onError,\n unoptimized: _unoptimized,\n overrideSrc: _overrideSrc,\n loading,\n ...rest\n },\n ref,\n) {\n // Dedup refs: ensure onLoad and onError fire at most once per src per mount.\n // Matches Next.js behavior — prevents double-firing from React re-renders,\n // strict-mode double-invocation, or state updates inside the handler itself.\n // Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n const lastLoadedSrcRef = useRef<string | undefined>(undefined);\n const lastErrorSrcRef = useRef<string | undefined>(undefined);\n\n // Hydration-level onError replay: when an image fails to load during SSR\n // streaming or initial HTML parse (before React hydrates), the native browser\n // error event is lost. Re-trigger it via `img.src = img.src` in a layout\n // effect once hydration completes, mirroring the upstream Next.js fix.\n // Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n const didInsertRef = useRef(false);\n const imgElementRef = useRef<HTMLImageElement | null>(null);\n\n // Merge forwarded ref with internal img ref for layout effect access.\n const mergedRef = useMergedRef(ref, imgElementRef);\n\n // Stable refs for onLoad / onError / onLoadingComplete so the layout effect\n // does not re-run (and re-assign img.src) when handler identity changes.\n // Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n //\n // IMPORTANT: The useRef+useEffect sync pattern has a subtle timing gap:\n // during the first render, onLoadRef.current holds the initial value from\n // useRef(onLoad), and the useEffect to sync it runs AFTER the layout effect.\n // This means on first mount the layout effect reads the correct initial\n // value (passed to useRef). If someone changes useRef(onLoad) to\n // useRef(undefined), the layout effect would read undefined on first mount.\n const onLoadRef = useRef(onLoad);\n useEffect(() => {\n onLoadRef.current = onLoad;\n }, [onLoad]);\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n const onLoadingCompleteRef = useRef(onLoadingComplete);\n useEffect(() => {\n onLoadingCompleteRef.current = onLoadingComplete;\n }, [onLoadingComplete]);\n\n const {\n src,\n width: imgWidth,\n height: imgHeight,\n blurDataURL: imgBlurDataURL,\n } = resolveImageSource({ src: srcProp, width, height, blurDataURL });\n const shouldPreload = preload === true || priority === true;\n const priorityFetchPriority = priority ? \"high\" : undefined;\n const imageLoading = priority ? \"eager\" : shouldPreload ? loading : (loading ?? \"lazy\");\n\n const [completedBlurSrc, setCompletedBlurSrc] = useState<string | undefined>(undefined);\n const blurComplete = completedBlurSrc === src;\n\n const markBlurComplete = () => {\n if (placeholder !== \"blur\") return;\n setCompletedBlurSrc((current) => (current === src ? current : src));\n };\n\n useNonWarningLayoutEffect(() => {\n if (!didInsertRef.current && imgElementRef.current !== null) {\n const img = imgElementRef.current;\n // Replay error events lost during SSR/hydration.\n if (onErrorRef.current) {\n // eslint-disable-next-line no-self-assign\n img.src = img.src;\n }\n // Replay onLoad for images that completed loading before React hydrated\n // (e.g. SSR streaming where the image arrives and renders before hydration\n // finishes). Without this, onLoad never fires for those images.\n //\n // img.complete is true for both successfully-loaded and errored images\n // (the HTML spec defines complete as true when the browser finished\n // fetching, regardless of outcome). We must check naturalWidth > 0 to\n // distinguish success from error — a failed image has naturalWidth === 0.\n // Ported from Next.js: https://github.com/vercel/next.js/pull/93209\n if (img.complete && img.naturalWidth > 0) {\n markBlurComplete();\n const currentOnLoad = onLoadRef.current;\n const currentOnLoadingComplete = onLoadingCompleteRef.current;\n if (currentOnLoad || currentOnLoadingComplete) {\n // Dedup — fire at most once per src per mount, matching onLoad dedup\n if (lastLoadedSrcRef.current !== src) {\n lastLoadedSrcRef.current = src;\n // Create a synthetic React event with the expected shape.\n // next/image uses a similar pattern in `handleLoading`.\n const syntheticEvent = createSyntheticLoadEvent(img);\n currentOnLoad?.(syntheticEvent);\n currentOnLoadingComplete?.(img);\n }\n }\n }\n didInsertRef.current = true;\n }\n }, [placeholder, sizes, _unoptimized]);\n\n // Wire onLoadingComplete (deprecated) into onLoad — matches Next.js behavior.\n // onLoad fires first, then onLoadingComplete receives the HTMLImageElement.\n const handleLoad = onLoadingComplete\n ? (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (lastLoadedSrcRef.current === src) return;\n lastLoadedSrcRef.current = src;\n markBlurComplete();\n onLoad?.(e);\n onLoadingComplete(e.currentTarget);\n }\n : onLoad\n ? (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (lastLoadedSrcRef.current === src) return;\n lastLoadedSrcRef.current = src;\n markBlurComplete();\n onLoad(e);\n }\n : placeholder === \"blur\"\n ? () => {\n if (lastLoadedSrcRef.current === src) return;\n lastLoadedSrcRef.current = src;\n markBlurComplete();\n }\n : undefined;\n\n const handleError = onError\n ? (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (lastErrorSrcRef.current === src) return;\n lastErrorSrcRef.current = src;\n markBlurComplete();\n onError(e);\n }\n : placeholder === \"blur\"\n ? () => {\n if (lastErrorSrcRef.current === src) return;\n lastErrorSrcRef.current = src;\n markBlurComplete();\n }\n : undefined;\n\n // If a custom loader is provided, use basic img with loader URL\n if (loader) {\n const resolvedSrc = loader({ src, width: imgWidth ?? 0, quality: quality ?? 75 });\n preloadImageResource({\n shouldPreload,\n src: resolvedSrc,\n sizes,\n fetchPriority: priorityFetchPriority,\n });\n return (\n <img\n ref={mergedRef}\n src={resolvedSrc}\n alt={alt}\n width={fill ? undefined : imgWidth}\n height={fill ? undefined : imgHeight}\n loading={imageLoading}\n decoding=\"async\"\n sizes={sizes}\n className={className}\n onLoad={handleLoad}\n onError={handleError}\n style={fill ? getFillStyle(style) : style}\n {...rest}\n />\n );\n }\n\n // For remote URLs, validate against remotePatterns. Non-fill images use\n // @unpic/react for CDN URL transforms; fill uses a plain img so the DOM\n // element keeps Next.js's absolute-positioned fill contract.\n if (isRemoteUrl(src)) {\n const validation = validateRemoteUrl(src);\n if (!validation.allowed) {\n if (__isDev) {\n console.warn(`[next/image] ${validation.reason}`);\n // In dev, render the image but with a warning — matches Next.js dev behavior\n } else {\n // In production, block the image entirely\n console.error(`[next/image] ${validation.reason}`);\n return null;\n }\n }\n\n const sanitizedBlur = imgBlurDataURL ? sanitizeBlurDataURL(imgBlurDataURL) : undefined;\n const showBlur = !blurComplete && placeholder === \"blur\" && sanitizedBlur;\n const blurStyle = showBlur\n ? {\n backgroundImage: `url(${sanitizedBlur})`,\n backgroundSize: \"cover\",\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: \"center\",\n }\n : undefined;\n const bg = showBlur ? `url(${sanitizedBlur})` : undefined;\n\n if (fill) {\n const fillSizes = sizes ?? \"100vw\";\n preloadImageResource({\n shouldPreload,\n src,\n sizes: fillSizes,\n fetchPriority: priorityFetchPriority,\n });\n return (\n <img\n ref={mergedRef}\n src={src}\n alt={alt}\n // `priority` is a Next.js concept — translate it to HTML attributes so\n // it is never forwarded to the DOM as a non-boolean attribute, which\n // would trigger React's \"Received `true` for a non-boolean attribute\"\n // warning.\n loading={imageLoading}\n fetchPriority={priorityFetchPriority}\n decoding=\"async\"\n sizes={fillSizes}\n className={className}\n data-nimg=\"fill\"\n onLoad={handleLoad}\n onError={handleError}\n style={getFillStyle(style, blurStyle)}\n {...rest}\n />\n );\n }\n // constrained layout requires width+height or aspectRatio\n if (imgWidth && imgHeight) {\n // @unpic/react forwards additional image props through transformProps and\n // merges `style` with generated layout styles at runtime, but its public\n // React type omits `style`.\n const unpicRuntimeStyleProps: { style?: React.CSSProperties } = { style };\n preloadImageResource({\n shouldPreload,\n src,\n sizes,\n fetchPriority: priorityFetchPriority,\n });\n return (\n <UnpicImage\n src={src}\n alt={alt}\n width={imgWidth}\n height={imgHeight}\n layout=\"constrained\"\n // Same translation as above — never pass `priority` to the DOM.\n loading={imageLoading}\n fetchPriority={priorityFetchPriority}\n sizes={sizes}\n className={className}\n {...unpicRuntimeStyleProps}\n background={bg}\n onLoad={handleLoad}\n onError={handleError}\n ref={mergedRef}\n />\n );\n }\n // Fall through to basic <img> if dimensions not provided\n // (unpic requires them for constrained layout)\n }\n\n // Route local images through the /_next/image optimization endpoint.\n // In production on Cloudflare Workers, this resizes and transcodes via\n // the Images binding. In dev, it serves the original file as a passthrough.\n // When `unoptimized` is true, bypass the endpoint entirely (Next.js compat).\n // SVG sources auto-skip unless dangerouslyAllowSVG is enabled, matching\n // Next.js behavior where .svg triggers unoptimized=true by default.\n const imgQuality = quality ?? 75;\n const isSvg = src.endsWith(\".svg\");\n const skipOptimization = _unoptimized === true || (isSvg && !__dangerouslyAllowSVG);\n\n // Build srcSet for responsive local images (common breakpoints).\n // Each entry points to /_next/image with the appropriate width.\n const srcSet =\n imgWidth && !fill && !skipOptimization\n ? generateSrcSet(src, imgWidth, imgQuality)\n : imgWidth && !fill\n ? RESPONSIVE_WIDTHS.filter((w) => w <= imgWidth * 2)\n .map((w) => `${src} ${w}w`)\n .join(\", \") || `${src} ${imgWidth}w`\n : undefined;\n\n // The main `src` also goes through the optimization endpoint. Use the\n // declared width (or the first responsive width as fallback).\n const optimizedSrc = skipOptimization\n ? src\n : imgWidth\n ? imageOptimizationUrl(src, imgWidth, imgQuality)\n : imageOptimizationUrl(src, RESPONSIVE_WIDTHS[0], imgQuality);\n\n // Blur placeholder: show a low-quality background while the image loads.\n // Sanitize blurDataURL to prevent CSS injection via crafted data URLs.\n const sanitizedLocalBlur = imgBlurDataURL ? sanitizeBlurDataURL(imgBlurDataURL) : undefined;\n const blurStyle =\n !blurComplete && placeholder === \"blur\" && sanitizedLocalBlur\n ? {\n backgroundImage: `url(${sanitizedLocalBlur})`,\n backgroundSize: \"cover\",\n backgroundRepeat: \"no-repeat\",\n backgroundPosition: \"center\",\n }\n : undefined;\n\n const imageSizes = sizes ?? (fill ? \"100vw\" : undefined);\n preloadImageResource({\n shouldPreload,\n src: optimizedSrc,\n srcSet,\n sizes: imageSizes,\n fetchPriority: priorityFetchPriority,\n });\n\n // For local images, render a standard <img> tag with srcSet and blur support.\n // The src and srcSet point to the /_next/image optimization endpoint.\n return (\n <img\n ref={mergedRef}\n src={optimizedSrc}\n alt={alt}\n width={fill ? undefined : imgWidth}\n height={fill ? undefined : imgHeight}\n loading={imageLoading}\n fetchPriority={priorityFetchPriority}\n decoding=\"async\"\n srcSet={srcSet}\n sizes={imageSizes}\n className={className}\n data-nimg={fill ? \"fill\" : \"1\"}\n onLoad={handleLoad}\n onError={handleError}\n style={fill ? getFillStyle(style, blurStyle) : { ...blurStyle, ...style }}\n {...rest}\n />\n );\n});\n\n/**\n * getImageProps — for advanced use cases (picture elements, background images).\n * Returns the props that would be passed to the underlying <img> element.\n */\nexport function getImageProps(props: ImageProps): {\n props: React.ImgHTMLAttributes<HTMLImageElement>;\n} {\n const {\n src: srcProp,\n alt,\n width,\n height,\n fill,\n preload: _preload,\n priority,\n quality: _quality,\n placeholder,\n blurDataURL: blurDataURLProp,\n loader,\n sizes,\n className,\n style,\n onLoad: _onLoad,\n onLoadingComplete: _onLoadingComplete,\n unoptimized: _unoptimized,\n overrideSrc: _overrideSrc,\n loading,\n ...rest\n } = props;\n\n const {\n src,\n width: imgWidth,\n height: imgHeight,\n blurDataURL: imgBlurDataURL,\n } = resolveImageSource({ src: srcProp, width, height, blurDataURL: blurDataURLProp });\n const shouldPreload = _preload === true || priority === true;\n\n // Validate remote URLs against configured patterns\n let blockedInProd = false;\n if (isRemoteUrl(src)) {\n const validation = validateRemoteUrl(src);\n if (!validation.allowed) {\n if (__isDev) {\n console.warn(`[next/image] ${validation.reason}`);\n } else {\n console.error(`[next/image] ${validation.reason}`);\n blockedInProd = true;\n }\n }\n }\n\n // Resolve src through custom loader if provided\n const imgQuality = _quality ?? 75;\n const resolvedSrc = blockedInProd\n ? \"\"\n : loader\n ? loader({ src, width: imgWidth ?? 0, quality: imgQuality })\n : src;\n\n // For local images (no loader, not remote), route through optimization endpoint.\n // When `unoptimized` is true, bypass the endpoint entirely (Next.js compat).\n // SVG sources auto-skip unless dangerouslyAllowSVG is enabled.\n const isSvg = resolvedSrc.endsWith(\".svg\");\n const skipOpt =\n _unoptimized === true ||\n (isSvg && !__dangerouslyAllowSVG) ||\n blockedInProd ||\n !!loader ||\n isRemoteUrl(resolvedSrc);\n const optimizedSrc = skipOpt\n ? resolvedSrc\n : imgWidth\n ? imageOptimizationUrl(resolvedSrc, imgWidth, imgQuality)\n : imageOptimizationUrl(resolvedSrc, RESPONSIVE_WIDTHS[0], imgQuality);\n\n // Build srcSet for local images — each width points to /_next/image\n const srcSet =\n imgWidth && !fill && !isRemoteUrl(resolvedSrc) && !loader && !skipOpt\n ? generateSrcSet(resolvedSrc, imgWidth, imgQuality)\n : undefined;\n\n // Blur placeholder styles — sanitize to prevent CSS injection\n const sanitizedBlurURL = imgBlurDataURL ? sanitizeBlurDataURL(imgBlurDataURL) : undefined;\n const blurStyle =\n placeholder === \"blur\" && sanitizedBlurURL\n ? {\n backgroundImage: `url(${sanitizedBlurURL})`,\n backgroundSize: \"cover\",\n backgroundRepeat: \"no-repeat\" as const,\n backgroundPosition: \"center\" as const,\n }\n : undefined;\n\n return {\n props: {\n src: optimizedSrc,\n alt,\n width: fill ? undefined : imgWidth,\n height: fill ? undefined : imgHeight,\n loading: priority ? \"eager\" : shouldPreload ? loading : (loading ?? \"lazy\"),\n fetchPriority: priority ? (\"high\" as const) : undefined,\n decoding: \"async\" as const,\n srcSet,\n sizes: sizes ?? (fill ? \"100vw\" : undefined),\n className,\n \"data-nimg\": fill ? \"fill\" : \"1\",\n style: fill ? getFillStyle(style, blurStyle) : { ...blurStyle, ...style },\n ...rest,\n } as React.ImgHTMLAttributes<HTMLImageElement>,\n };\n}\n\nexport default Image;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,+BAAgD;CACpD,IAAI;EACF,OAAO,KAAK,MAAM,QAAQ,IAAI,kCAAkC,KAAK;SAC/D;EACN,OAAO,EAAE;;IAET;AACJ,MAAM,wBAAkC;CACtC,IAAI;EACF,OAAO,KAAK,MAAM,QAAQ,IAAI,0BAA0B,KAAK;SACvD;EACN,OAAO,EAAE;;IAET;AACJ,MAAM,mBAAmB,sBAAsB,SAAS,KAAK,eAAe,SAAS;AACrF,MAAM,UAAU,QAAQ,IAAI,aAAa;AACzC,MAAM,4BAAsC;CAC1C,IAAI;EACF,OAAO,KAAK,MACV,QAAQ,IAAI,+BAA+B,yCAC5C;SACK;EACN,OAAO;GAAC;GAAK;GAAK;GAAK;GAAM;GAAM;GAAM;GAAM;GAAK;;IAEpD;;;;;;;;AAQJ,MAAM,wBAAwB,QAAQ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
|
|
|
1
|
+
//#region src/shims/internal/pages-data-target.d.ts
|
|
2
|
+
type PagesDataTarget = {
|
|
3
|
+
/** Final fetch URL for the data endpoint, including basePath and search. */dataHref: string; /** Matched route pattern (e.g. `/blog/[slug]`). */
|
|
4
|
+
pattern: string; /** Dynamic params extracted from the URL by the pattern matcher. */
|
|
5
|
+
params: Record<string, string | string[]>; /** Code-split loader thunk for the matched route's page module. */
|
|
6
|
+
loader: () => Promise<{
|
|
7
|
+
default?: unknown;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}>; /** Current buildId snapshot, used by the data URL and consistency checks. */
|
|
10
|
+
buildId: string; /** Locale-prefixed (server-routable) page path. */
|
|
11
|
+
pagePath: string; /** URL search string including the leading `?`. */
|
|
12
|
+
search: string;
|
|
13
|
+
/**
|
|
14
|
+
* Locale prefix detected on the URL, or `undefined` when the URL is
|
|
15
|
+
* unprefixed (default locale, or no i18n configured). Lets the caller refresh
|
|
16
|
+
* locale state on locale transitions, which the data JSON envelope itself
|
|
17
|
+
* does not carry.
|
|
18
|
+
*/
|
|
19
|
+
locale: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Decide whether the JSON data-endpoint navigation path is usable for this
|
|
23
|
+
* browser URL. We require:
|
|
24
|
+
* - A registered code-split loader for the matched route pattern. Without
|
|
25
|
+
* this, the client has no chunk URL to import for the new page.
|
|
26
|
+
* - A buildId on the current `__NEXT_DATA__`, since the data URL embeds it.
|
|
27
|
+
* - Same-origin (cross-origin URLs do not hit our data endpoint).
|
|
28
|
+
*
|
|
29
|
+
* Locale handling: route patterns in `__VINEXT_PAGE_PATTERNS__` are
|
|
30
|
+
* locale-unaware (`/about`, not `/fr/about`), but the browser URL for a
|
|
31
|
+
* locale-prefixed page is `/fr/about`. We strip the locale prefix before
|
|
32
|
+
* pattern matching so locale transitions hit the JSON fast path. The data URL
|
|
33
|
+
* itself keeps the locale prefix because the server uses it to pick
|
|
34
|
+
* locale-specific gSSP data.
|
|
35
|
+
*
|
|
36
|
+
* Returns the resolved target, or `null` to signal the caller should fall
|
|
37
|
+
* back to the HTML extraction path (dev server, or a route that exists on the
|
|
38
|
+
* server but is not in the client loader map).
|
|
39
|
+
*
|
|
40
|
+
* Ported from Next.js: `packages/next/src/client/page-loader.ts`
|
|
41
|
+
* (`getDataHref`). vinext's equivalent uses an in-memory loader map instead
|
|
42
|
+
* of Next.js' `_buildManifest.js`.
|
|
43
|
+
*/
|
|
44
|
+
declare function resolvePagesDataNavigationTarget(browserUrl: string, basePath: string): PagesDataTarget | null;
|
|
45
|
+
/**
|
|
46
|
+
* Inject a `<link rel="prefetch">` for the data JSON and kick off the
|
|
47
|
+
* code-split loader so the chunk is warm by the time the user clicks.
|
|
48
|
+
*
|
|
49
|
+
* Used by both `Router.prefetch()` and `<Link>` hover/viewport prefetch. The
|
|
50
|
+
* loader's returned Promise is intentionally discarded — `import()` caches the
|
|
51
|
+
* result, so a subsequent navigation re-invocation hits the cache without
|
|
52
|
+
* paying for a second round trip. Errors are swallowed: prefetch is
|
|
53
|
+
* best-effort and must never break the page.
|
|
54
|
+
*/
|
|
55
|
+
declare function prefetchPagesData(target: PagesDataTarget): void;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { PagesDataTarget, prefetchPagesData, resolvePagesDataNavigationTarget };
|
|
58
|
+
//# sourceMappingURL=pages-data-target.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { stripBasePath } from "../../utils/base-path.js";
|
|
2
|
+
import { getLocalePathPrefix } from "../../utils/domain-locale.js";
|
|
3
|
+
import { buildPagesDataHref, matchPagesPattern } from "./pages-data-url.js";
|
|
4
|
+
//#region src/shims/internal/pages-data-target.ts
|
|
5
|
+
/**
|
|
6
|
+
* Shared decision helper for the Pages Router `/_next/data/<id>/<page>.json`
|
|
7
|
+
* navigation fast path. Used by both the router shim (for `navigateClient` and
|
|
8
|
+
* `Router.prefetch`) and the Link shim (for hover/viewport prefetch).
|
|
9
|
+
*
|
|
10
|
+
* Lives in `shims/internal/` so neither caller pulls in the router shim at
|
|
11
|
+
* module init time — link.tsx and router.ts must remain free of circular
|
|
12
|
+
* imports and SSR-side router-init side effects.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Decide whether the JSON data-endpoint navigation path is usable for this
|
|
16
|
+
* browser URL. We require:
|
|
17
|
+
* - A registered code-split loader for the matched route pattern. Without
|
|
18
|
+
* this, the client has no chunk URL to import for the new page.
|
|
19
|
+
* - A buildId on the current `__NEXT_DATA__`, since the data URL embeds it.
|
|
20
|
+
* - Same-origin (cross-origin URLs do not hit our data endpoint).
|
|
21
|
+
*
|
|
22
|
+
* Locale handling: route patterns in `__VINEXT_PAGE_PATTERNS__` are
|
|
23
|
+
* locale-unaware (`/about`, not `/fr/about`), but the browser URL for a
|
|
24
|
+
* locale-prefixed page is `/fr/about`. We strip the locale prefix before
|
|
25
|
+
* pattern matching so locale transitions hit the JSON fast path. The data URL
|
|
26
|
+
* itself keeps the locale prefix because the server uses it to pick
|
|
27
|
+
* locale-specific gSSP data.
|
|
28
|
+
*
|
|
29
|
+
* Returns the resolved target, or `null` to signal the caller should fall
|
|
30
|
+
* back to the HTML extraction path (dev server, or a route that exists on the
|
|
31
|
+
* server but is not in the client loader map).
|
|
32
|
+
*
|
|
33
|
+
* Ported from Next.js: `packages/next/src/client/page-loader.ts`
|
|
34
|
+
* (`getDataHref`). vinext's equivalent uses an in-memory loader map instead
|
|
35
|
+
* of Next.js' `_buildManifest.js`.
|
|
36
|
+
*/
|
|
37
|
+
function resolvePagesDataNavigationTarget(browserUrl, basePath) {
|
|
38
|
+
if (typeof window === "undefined") return null;
|
|
39
|
+
const loaders = window.__VINEXT_PAGE_LOADERS__;
|
|
40
|
+
const patterns = window.__VINEXT_PAGE_PATTERNS__;
|
|
41
|
+
if (!loaders || !patterns || patterns.length === 0) return null;
|
|
42
|
+
const buildId = window.__NEXT_DATA__?.buildId ?? void 0;
|
|
43
|
+
if (!buildId) return null;
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = new URL(browserUrl, window.location.href);
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (parsed.origin !== window.location.origin) return null;
|
|
51
|
+
const pagePath = stripBasePath(parsed.pathname, basePath);
|
|
52
|
+
const locale = getLocalePathPrefix(pagePath, window.__VINEXT_LOCALES__);
|
|
53
|
+
const match = matchPagesPattern(locale ? pagePath.slice(locale.length + 1) || "/" : pagePath, patterns);
|
|
54
|
+
if (!match) return null;
|
|
55
|
+
const loader = loaders[match.pattern];
|
|
56
|
+
if (!loader) return null;
|
|
57
|
+
return {
|
|
58
|
+
dataHref: buildPagesDataHref(basePath, buildId, pagePath, parsed.search),
|
|
59
|
+
pattern: match.pattern,
|
|
60
|
+
params: match.params,
|
|
61
|
+
loader,
|
|
62
|
+
buildId,
|
|
63
|
+
pagePath,
|
|
64
|
+
search: parsed.search,
|
|
65
|
+
locale
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Inject a `<link rel="prefetch">` for the data JSON and kick off the
|
|
70
|
+
* code-split loader so the chunk is warm by the time the user clicks.
|
|
71
|
+
*
|
|
72
|
+
* Used by both `Router.prefetch()` and `<Link>` hover/viewport prefetch. The
|
|
73
|
+
* loader's returned Promise is intentionally discarded — `import()` caches the
|
|
74
|
+
* result, so a subsequent navigation re-invocation hits the cache without
|
|
75
|
+
* paying for a second round trip. Errors are swallowed: prefetch is
|
|
76
|
+
* best-effort and must never break the page.
|
|
77
|
+
*/
|
|
78
|
+
function prefetchPagesData(target) {
|
|
79
|
+
if (typeof document === "undefined") return;
|
|
80
|
+
const link = document.createElement("link");
|
|
81
|
+
link.rel = "prefetch";
|
|
82
|
+
link.as = "fetch";
|
|
83
|
+
link.crossOrigin = "anonymous";
|
|
84
|
+
link.href = target.dataHref;
|
|
85
|
+
document.head.appendChild(link);
|
|
86
|
+
target.loader().catch(() => {});
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { prefetchPagesData, resolvePagesDataNavigationTarget };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=pages-data-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages-data-target.js","names":[],"sources":["../../../src/shims/internal/pages-data-target.ts"],"sourcesContent":["/**\n * Shared decision helper for the Pages Router `/_next/data/<id>/<page>.json`\n * navigation fast path. Used by both the router shim (for `navigateClient` and\n * `Router.prefetch`) and the Link shim (for hover/viewport prefetch).\n *\n * Lives in `shims/internal/` so neither caller pulls in the router shim at\n * module init time — link.tsx and router.ts must remain free of circular\n * imports and SSR-side router-init side effects.\n */\nimport { stripBasePath } from \"../../utils/base-path.js\";\nimport { getLocalePathPrefix } from \"../../utils/domain-locale.js\";\nimport type { VinextNextData } from \"../../client/vinext-next-data.js\";\nimport { buildPagesDataHref, matchPagesPattern } from \"./pages-data-url.js\";\n\nexport type PagesDataTarget = {\n /** Final fetch URL for the data endpoint, including basePath and search. */\n dataHref: string;\n /** Matched route pattern (e.g. `/blog/[slug]`). */\n pattern: string;\n /** Dynamic params extracted from the URL by the pattern matcher. */\n params: Record<string, string | string[]>;\n /** Code-split loader thunk for the matched route's page module. */\n loader: () => Promise<{ default?: unknown; [key: string]: unknown }>;\n /** Current buildId snapshot, used by the data URL and consistency checks. */\n buildId: string;\n /** Locale-prefixed (server-routable) page path. */\n pagePath: string;\n /** URL search string including the leading `?`. */\n search: string;\n /**\n * Locale prefix detected on the URL, or `undefined` when the URL is\n * unprefixed (default locale, or no i18n configured). Lets the caller refresh\n * locale state on locale transitions, which the data JSON envelope itself\n * does not carry.\n */\n locale: string | undefined;\n};\n\n/**\n * Decide whether the JSON data-endpoint navigation path is usable for this\n * browser URL. We require:\n * - A registered code-split loader for the matched route pattern. Without\n * this, the client has no chunk URL to import for the new page.\n * - A buildId on the current `__NEXT_DATA__`, since the data URL embeds it.\n * - Same-origin (cross-origin URLs do not hit our data endpoint).\n *\n * Locale handling: route patterns in `__VINEXT_PAGE_PATTERNS__` are\n * locale-unaware (`/about`, not `/fr/about`), but the browser URL for a\n * locale-prefixed page is `/fr/about`. We strip the locale prefix before\n * pattern matching so locale transitions hit the JSON fast path. The data URL\n * itself keeps the locale prefix because the server uses it to pick\n * locale-specific gSSP data.\n *\n * Returns the resolved target, or `null` to signal the caller should fall\n * back to the HTML extraction path (dev server, or a route that exists on the\n * server but is not in the client loader map).\n *\n * Ported from Next.js: `packages/next/src/client/page-loader.ts`\n * (`getDataHref`). vinext's equivalent uses an in-memory loader map instead\n * of Next.js' `_buildManifest.js`.\n */\nexport function resolvePagesDataNavigationTarget(\n browserUrl: string,\n basePath: string,\n): PagesDataTarget | null {\n if (typeof window === \"undefined\") return null;\n\n const loaders = window.__VINEXT_PAGE_LOADERS__;\n const patterns = window.__VINEXT_PAGE_PATTERNS__;\n if (!loaders || !patterns || patterns.length === 0) return null;\n\n const buildId = (window.__NEXT_DATA__ as VinextNextData | undefined)?.buildId ?? undefined;\n if (!buildId) return null;\n\n let parsed: URL;\n try {\n parsed = new URL(browserUrl, window.location.href);\n } catch {\n return null;\n }\n if (parsed.origin !== window.location.origin) return null;\n\n const pagePath = stripBasePath(parsed.pathname, basePath);\n const locale = getLocalePathPrefix(pagePath, window.__VINEXT_LOCALES__);\n // `locale.length + 1` skips the `/<locale>` segment. If only the locale was\n // present (`/fr`) the remainder is empty, which normalises to `/` (root).\n const pathForMatch = locale ? pagePath.slice(locale.length + 1) || \"/\" : pagePath;\n\n const match = matchPagesPattern(pathForMatch, patterns);\n if (!match) return null;\n\n const loader = loaders[match.pattern];\n if (!loader) return null;\n\n return {\n dataHref: buildPagesDataHref(basePath, buildId, pagePath, parsed.search),\n pattern: match.pattern,\n params: match.params,\n loader,\n buildId,\n pagePath,\n search: parsed.search,\n locale,\n };\n}\n\n/**\n * Inject a `<link rel=\"prefetch\">` for the data JSON and kick off the\n * code-split loader so the chunk is warm by the time the user clicks.\n *\n * Used by both `Router.prefetch()` and `<Link>` hover/viewport prefetch. The\n * loader's returned Promise is intentionally discarded — `import()` caches the\n * result, so a subsequent navigation re-invocation hits the cache without\n * paying for a second round trip. Errors are swallowed: prefetch is\n * best-effort and must never break the page.\n */\nexport function prefetchPagesData(target: PagesDataTarget): void {\n if (typeof document === \"undefined\") return;\n\n const link = document.createElement(\"link\");\n link.rel = \"prefetch\";\n link.as = \"fetch\";\n link.crossOrigin = \"anonymous\";\n link.href = target.dataHref;\n document.head.appendChild(link);\n\n void target.loader().catch(() => {});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,iCACd,YACA,UACwB;CACxB,IAAI,OAAO,WAAW,aAAa,OAAO;CAE1C,MAAM,UAAU,OAAO;CACvB,MAAM,WAAW,OAAO;CACxB,IAAI,CAAC,WAAW,CAAC,YAAY,SAAS,WAAW,GAAG,OAAO;CAE3D,MAAM,UAAW,OAAO,eAA8C,WAAW,KAAA;CACjF,IAAI,CAAC,SAAS,OAAO;CAErB,IAAI;CACJ,IAAI;EACF,SAAS,IAAI,IAAI,YAAY,OAAO,SAAS,KAAK;SAC5C;EACN,OAAO;;CAET,IAAI,OAAO,WAAW,OAAO,SAAS,QAAQ,OAAO;CAErD,MAAM,WAAW,cAAc,OAAO,UAAU,SAAS;CACzD,MAAM,SAAS,oBAAoB,UAAU,OAAO,mBAAmB;CAKvE,MAAM,QAAQ,kBAFO,SAAS,SAAS,MAAM,OAAO,SAAS,EAAE,IAAI,MAAM,UAE3B,SAAS;CACvD,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,SAAS,QAAQ,MAAM;CAC7B,IAAI,CAAC,QAAQ,OAAO;CAEpB,OAAO;EACL,UAAU,mBAAmB,UAAU,SAAS,UAAU,OAAO,OAAO;EACxE,SAAS,MAAM;EACf,QAAQ,MAAM;EACd;EACA;EACA;EACA,QAAQ,OAAO;EACf;EACD;;;;;;;;;;;;AAaH,SAAgB,kBAAkB,QAA+B;CAC/D,IAAI,OAAO,aAAa,aAAa;CAErC,MAAM,OAAO,SAAS,cAAc,OAAO;CAC3C,KAAK,MAAM;CACX,KAAK,KAAK;CACV,KAAK,cAAc;CACnB,KAAK,OAAO,OAAO;CACnB,SAAS,KAAK,YAAY,KAAK;CAE/B,OAAY,QAAQ,CAAC,YAAY,GAAG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/shims/internal/pages-data-url.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Append `.json` and the `/_next/data/<buildId>` prefix to a page pathname.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors Next.js' `getAssetPathFromRoute` + `getDataHref` behaviour:
|
|
6
|
+
* `/` → `/_next/data/<id>/index.json`
|
|
7
|
+
* `/about` → `/_next/data/<id>/about.json`
|
|
8
|
+
* `/index` → `/_next/data/<id>/index/index.json` (explicit `/index` page)
|
|
9
|
+
* `/blog/foo` → `/_next/data/<id>/blog/foo.json`
|
|
10
|
+
*
|
|
11
|
+
* `pagePath` is the resolved page pathname (already including any locale
|
|
12
|
+
* prefix and dynamic-param substitution), with a leading slash and NO
|
|
13
|
+
* trailing slash. The function does not URL-encode — the caller is expected
|
|
14
|
+
* to have produced a server-routable path.
|
|
15
|
+
*/
|
|
16
|
+
declare function buildPagesDataPath(buildId: string, pagePath: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Build the full data URL including the basePath, the search string, and the
|
|
19
|
+
* `/_next/data/<buildId>/<page>.json` segment.
|
|
20
|
+
*
|
|
21
|
+
* `pagePath` must already be the resolved pathname (param-substituted,
|
|
22
|
+
* locale-prefixed where applicable). `search` includes the leading `?`.
|
|
23
|
+
*/
|
|
24
|
+
declare function buildPagesDataHref(basePath: string, buildId: string, pagePath: string, search: string): string;
|
|
25
|
+
/** Result of matching a URL pathname against the registered route patterns. */
|
|
26
|
+
type PagesPatternMatch = {
|
|
27
|
+
/** The matched route pattern in Next.js bracket format (e.g. `/blog/[slug]`). */pattern: string; /** Dynamic route params extracted from the URL. */
|
|
28
|
+
params: Record<string, string | string[]>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Find the route pattern (Next.js bracket format) that matches `pathname`.
|
|
32
|
+
*
|
|
33
|
+
* Patterns are tried in `patterns` order — callers should pre-sort so more
|
|
34
|
+
* specific patterns come before catch-alls. Returns `null` when no pattern
|
|
35
|
+
* matches, so the caller can fall back to a hard navigation (this is how
|
|
36
|
+
* vinext handles routes that exist on the server but are not in the
|
|
37
|
+
* client-side loader map, e.g. dev-only pages).
|
|
38
|
+
*/
|
|
39
|
+
declare function matchPagesPattern(pathname: string, patterns: readonly string[]): PagesPatternMatch | null;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { buildPagesDataHref, buildPagesDataPath, matchPagesPattern };
|
|
42
|
+
//# sourceMappingURL=pages-data-url.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { matchRoutePattern, routePatternParts } from "../../routing/route-pattern.js";
|
|
2
|
+
//#region src/shims/internal/pages-data-url.ts
|
|
3
|
+
/**
|
|
4
|
+
* Client-side helpers for the Pages Router `/_next/data/<buildId>/<page>.json`
|
|
5
|
+
* endpoint.
|
|
6
|
+
*
|
|
7
|
+
* Ported from Next.js:
|
|
8
|
+
* - `packages/next/src/client/page-loader.ts` (`getDataHref`)
|
|
9
|
+
* - `packages/next/src/shared/lib/router/utils/get-asset-path-from-route.ts`
|
|
10
|
+
*
|
|
11
|
+
* The server-side counterpart lives in `server/pages-data-route.ts` and parses
|
|
12
|
+
* the URL shape this module generates. Keep the two in sync — they are the
|
|
13
|
+
* wire-format contract between vinext's client navigation and its data
|
|
14
|
+
* endpoint.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Append `.json` and the `/_next/data/<buildId>` prefix to a page pathname.
|
|
18
|
+
*
|
|
19
|
+
* Mirrors Next.js' `getAssetPathFromRoute` + `getDataHref` behaviour:
|
|
20
|
+
* `/` → `/_next/data/<id>/index.json`
|
|
21
|
+
* `/about` → `/_next/data/<id>/about.json`
|
|
22
|
+
* `/index` → `/_next/data/<id>/index/index.json` (explicit `/index` page)
|
|
23
|
+
* `/blog/foo` → `/_next/data/<id>/blog/foo.json`
|
|
24
|
+
*
|
|
25
|
+
* `pagePath` is the resolved page pathname (already including any locale
|
|
26
|
+
* prefix and dynamic-param substitution), with a leading slash and NO
|
|
27
|
+
* trailing slash. The function does not URL-encode — the caller is expected
|
|
28
|
+
* to have produced a server-routable path.
|
|
29
|
+
*/
|
|
30
|
+
function buildPagesDataPath(buildId, pagePath) {
|
|
31
|
+
let path = pagePath;
|
|
32
|
+
if (path.length > 1 && path.endsWith("/")) path = path.slice(0, -1);
|
|
33
|
+
let asset;
|
|
34
|
+
if (path === "/") asset = "/index";
|
|
35
|
+
else if (path === "/index" || path.startsWith("/index/")) asset = "/index" + path;
|
|
36
|
+
else asset = path;
|
|
37
|
+
return `/_next/data/${buildId}${asset}.json`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build the full data URL including the basePath, the search string, and the
|
|
41
|
+
* `/_next/data/<buildId>/<page>.json` segment.
|
|
42
|
+
*
|
|
43
|
+
* `pagePath` must already be the resolved pathname (param-substituted,
|
|
44
|
+
* locale-prefixed where applicable). `search` includes the leading `?`.
|
|
45
|
+
*/
|
|
46
|
+
function buildPagesDataHref(basePath, buildId, pagePath, search) {
|
|
47
|
+
const dataPath = buildPagesDataPath(buildId, pagePath);
|
|
48
|
+
return `${basePath ? basePath : ""}${dataPath}${search}`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Find the route pattern (Next.js bracket format) that matches `pathname`.
|
|
52
|
+
*
|
|
53
|
+
* Patterns are tried in `patterns` order — callers should pre-sort so more
|
|
54
|
+
* specific patterns come before catch-alls. Returns `null` when no pattern
|
|
55
|
+
* matches, so the caller can fall back to a hard navigation (this is how
|
|
56
|
+
* vinext handles routes that exist on the server but are not in the
|
|
57
|
+
* client-side loader map, e.g. dev-only pages).
|
|
58
|
+
*/
|
|
59
|
+
function matchPagesPattern(pathname, patterns) {
|
|
60
|
+
const urlParts = pathname.split("/").filter(Boolean);
|
|
61
|
+
for (const pattern of patterns) {
|
|
62
|
+
const params = matchRoutePattern(urlParts, routePatternParts(pattern));
|
|
63
|
+
if (params !== null) return {
|
|
64
|
+
pattern,
|
|
65
|
+
params
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { buildPagesDataHref, buildPagesDataPath, matchPagesPattern };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=pages-data-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages-data-url.js","names":[],"sources":["../../../src/shims/internal/pages-data-url.ts"],"sourcesContent":["/**\n * Client-side helpers for the Pages Router `/_next/data/<buildId>/<page>.json`\n * endpoint.\n *\n * Ported from Next.js:\n * - `packages/next/src/client/page-loader.ts` (`getDataHref`)\n * - `packages/next/src/shared/lib/router/utils/get-asset-path-from-route.ts`\n *\n * The server-side counterpart lives in `server/pages-data-route.ts` and parses\n * the URL shape this module generates. Keep the two in sync — they are the\n * wire-format contract between vinext's client navigation and its data\n * endpoint.\n */\nimport { matchRoutePattern, routePatternParts } from \"../../routing/route-pattern.js\";\n\n/**\n * Append `.json` and the `/_next/data/<buildId>` prefix to a page pathname.\n *\n * Mirrors Next.js' `getAssetPathFromRoute` + `getDataHref` behaviour:\n * `/` → `/_next/data/<id>/index.json`\n * `/about` → `/_next/data/<id>/about.json`\n * `/index` → `/_next/data/<id>/index/index.json` (explicit `/index` page)\n * `/blog/foo` → `/_next/data/<id>/blog/foo.json`\n *\n * `pagePath` is the resolved page pathname (already including any locale\n * prefix and dynamic-param substitution), with a leading slash and NO\n * trailing slash. The function does not URL-encode — the caller is expected\n * to have produced a server-routable path.\n */\nexport function buildPagesDataPath(buildId: string, pagePath: string): string {\n // Strip trailing slash except for the root path.\n let path = pagePath;\n if (path.length > 1 && path.endsWith(\"/\")) {\n path = path.slice(0, -1);\n }\n\n // Next.js' `getAssetPathFromRoute` denormalisation:\n // \"/\" → \"/index\"\n // \"/index\" → \"/index/index\"\n // \"/index/foo\" → \"/index/index/foo\"\n // This mirrors `pages/index.tsx → /` and disambiguates an explicit\n // `pages/index.tsx` nested under a folder.\n let asset: string;\n if (path === \"/\") {\n asset = \"/index\";\n } else if (path === \"/index\" || path.startsWith(\"/index/\")) {\n asset = \"/index\" + path;\n } else {\n asset = path;\n }\n\n return `/_next/data/${buildId}${asset}.json`;\n}\n\n/**\n * Build the full data URL including the basePath, the search string, and the\n * `/_next/data/<buildId>/<page>.json` segment.\n *\n * `pagePath` must already be the resolved pathname (param-substituted,\n * locale-prefixed where applicable). `search` includes the leading `?`.\n */\nexport function buildPagesDataHref(\n basePath: string,\n buildId: string,\n pagePath: string,\n search: string,\n): string {\n const dataPath = buildPagesDataPath(buildId, pagePath);\n const prefix = basePath ? basePath : \"\";\n return `${prefix}${dataPath}${search}`;\n}\n\n/** Result of matching a URL pathname against the registered route patterns. */\ntype PagesPatternMatch = {\n /** The matched route pattern in Next.js bracket format (e.g. `/blog/[slug]`). */\n pattern: string;\n /** Dynamic route params extracted from the URL. */\n params: Record<string, string | string[]>;\n};\n\n/**\n * Find the route pattern (Next.js bracket format) that matches `pathname`.\n *\n * Patterns are tried in `patterns` order — callers should pre-sort so more\n * specific patterns come before catch-alls. Returns `null` when no pattern\n * matches, so the caller can fall back to a hard navigation (this is how\n * vinext handles routes that exist on the server but are not in the\n * client-side loader map, e.g. dev-only pages).\n */\nexport function matchPagesPattern(\n pathname: string,\n patterns: readonly string[],\n): PagesPatternMatch | null {\n const urlParts = pathname.split(\"/\").filter(Boolean);\n for (const pattern of patterns) {\n const patternParts = routePatternParts(pattern);\n const params = matchRoutePattern(urlParts, patternParts);\n if (params !== null) {\n return { pattern, params };\n }\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,mBAAmB,SAAiB,UAA0B;CAE5E,IAAI,OAAO;CACX,IAAI,KAAK,SAAS,KAAK,KAAK,SAAS,IAAI,EACvC,OAAO,KAAK,MAAM,GAAG,GAAG;CAS1B,IAAI;CACJ,IAAI,SAAS,KACX,QAAQ;MACH,IAAI,SAAS,YAAY,KAAK,WAAW,UAAU,EACxD,QAAQ,WAAW;MAEnB,QAAQ;CAGV,OAAO,eAAe,UAAU,MAAM;;;;;;;;;AAUxC,SAAgB,mBACd,UACA,SACA,UACA,QACQ;CACR,MAAM,WAAW,mBAAmB,SAAS,SAAS;CAEtD,OAAO,GADQ,WAAW,WAAW,KAClB,WAAW;;;;;;;;;;;AAoBhC,SAAgB,kBACd,UACA,UAC0B;CAC1B,MAAM,WAAW,SAAS,MAAM,IAAI,CAAC,OAAO,QAAQ;CACpD,KAAK,MAAM,WAAW,UAAU;EAE9B,MAAM,SAAS,kBAAkB,UADZ,kBAAkB,QACgB,CAAC;EACxD,IAAI,WAAW,MACb,OAAO;GAAE;GAAS;GAAQ;;CAG9B,OAAO"}
|
package/dist/shims/link.d.ts
CHANGED
|
@@ -22,7 +22,14 @@ type LinkProps = {
|
|
|
22
22
|
*/
|
|
23
23
|
unstable_dynamicOnHover?: boolean; /** Whether to pass the href to the child element */
|
|
24
24
|
passHref?: boolean; /** Scroll to top on navigation (default: true) */
|
|
25
|
-
scroll?: boolean;
|
|
25
|
+
scroll?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Pages Router: update the URL without re-running data fetching methods
|
|
28
|
+
* (getServerSideProps / getStaticProps / getInitialProps). The shallow change
|
|
29
|
+
* still triggers the route change events and updates `router.query`. Only
|
|
30
|
+
* applies to navigations within the same page. No-op on the App Router.
|
|
31
|
+
*/
|
|
32
|
+
shallow?: boolean; /** Locale for i18n (used for locale-prefixed URLs) */
|
|
26
33
|
locale?: string | false; /** Called before navigation happens (Next.js 16). Return value is ignored. */
|
|
27
34
|
onNavigate?: (event: NavigateEvent) => void;
|
|
28
35
|
children?: React.ReactNode;
|
|
@@ -44,6 +51,10 @@ type LinkStatusContextValue = {
|
|
|
44
51
|
declare function useLinkStatus(): LinkStatusContextValue;
|
|
45
52
|
declare function resolveLinkPrefetchMode(prefetchProp: LinkProps["prefetch"], isDangerous: boolean): LinkPrefetchMode;
|
|
46
53
|
declare function canAutoPrefetchFullAppRoute(href: string): boolean;
|
|
54
|
+
declare function resolveAutoAppRoutePrefetch(href: string): {
|
|
55
|
+
cacheForNavigation: boolean;
|
|
56
|
+
shouldPrefetch: boolean;
|
|
57
|
+
};
|
|
47
58
|
declare const Link: React.ForwardRefExoticComponent<{
|
|
48
59
|
href: string | {
|
|
49
60
|
pathname?: string;
|
|
@@ -58,11 +69,18 @@ declare const Link: React.ForwardRefExoticComponent<{
|
|
|
58
69
|
*/
|
|
59
70
|
unstable_dynamicOnHover?: boolean; /** Whether to pass the href to the child element */
|
|
60
71
|
passHref?: boolean; /** Scroll to top on navigation (default: true) */
|
|
61
|
-
scroll?: boolean;
|
|
72
|
+
scroll?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Pages Router: update the URL without re-running data fetching methods
|
|
75
|
+
* (getServerSideProps / getStaticProps / getInitialProps). The shallow change
|
|
76
|
+
* still triggers the route change events and updates `router.query`. Only
|
|
77
|
+
* applies to navigations within the same page. No-op on the App Router.
|
|
78
|
+
*/
|
|
79
|
+
shallow?: boolean; /** Locale for i18n (used for locale-prefixed URLs) */
|
|
62
80
|
locale?: string | false; /** Called before navigation happens (Next.js 16). Return value is ignored. */
|
|
63
81
|
onNavigate?: (event: NavigateEvent) => void;
|
|
64
82
|
children?: React.ReactNode;
|
|
65
83
|
} & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
66
84
|
//#endregion
|
|
67
|
-
export { canAutoPrefetchFullAppRoute, Link as default, resolveLinkPrefetchMode, useLinkStatus };
|
|
85
|
+
export { canAutoPrefetchFullAppRoute, Link as default, resolveAutoAppRoutePrefetch, resolveLinkPrefetchMode, useLinkStatus };
|
|
68
86
|
//# sourceMappingURL=link.d.ts.map
|