vinext 0.0.50 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/google-fonts/fallback-metrics-data.js +14031 -0
- package/dist/build/google-fonts/fallback-metrics-data.js.map +1 -0
- package/dist/build/google-fonts/fallback-metrics.d.ts +13 -0
- package/dist/build/google-fonts/fallback-metrics.js +46 -0
- package/dist/build/google-fonts/fallback-metrics.js.map +1 -0
- package/dist/build/precompress.d.ts +13 -2
- package/dist/build/precompress.js +23 -13
- package/dist/build/precompress.js.map +1 -1
- package/dist/build/prerender.d.ts +4 -15
- package/dist/build/prerender.js +83 -53
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/report.d.ts +5 -4
- package/dist/build/report.js +196 -348
- package/dist/build/report.js.map +1 -1
- package/dist/check.js +5 -0
- package/dist/check.js.map +1 -1
- package/dist/cli-args.d.ts +1 -0
- package/dist/cli-args.js +5 -0
- package/dist/cli-args.js.map +1 -1
- package/dist/cli.js +99 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/navigation-runtime.d.ts +47 -0
- package/dist/client/navigation-runtime.js +156 -0
- package/dist/client/navigation-runtime.js.map +1 -0
- package/dist/client/pages-router-link-navigation.d.ts +26 -0
- package/dist/client/pages-router-link-navigation.js +14 -0
- package/dist/client/pages-router-link-navigation.js.map +1 -0
- package/dist/client/vinext-next-data.d.ts +12 -2
- package/dist/client/vinext-next-data.js +50 -1
- package/dist/client/vinext-next-data.js.map +1 -0
- package/dist/client/window-next.d.ts +3 -1
- package/dist/client/window-next.js.map +1 -1
- package/dist/cloudflare/kv-cache-handler.js +2 -1
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/config/config-matchers.d.ts +63 -16
- package/dist/config/config-matchers.js +143 -8
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.d.ts +11 -1
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +107 -5
- package/dist/config/next-config.js +233 -7
- package/dist/config/next-config.js.map +1 -1
- package/dist/config/tsconfig-paths.d.ts +13 -0
- package/dist/config/tsconfig-paths.js +117 -0
- package/dist/config/tsconfig-paths.js.map +1 -0
- package/dist/deploy.js +104 -41
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +2 -2
- package/dist/entries/app-browser-entry.js +34 -3
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +19 -1
- package/dist/entries/app-rsc-entry.js +89 -23
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-rsc-manifest.d.ts +10 -0
- package/dist/entries/app-rsc-manifest.js +57 -7
- package/dist/entries/app-rsc-manifest.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +3 -3
- package/dist/entries/app-ssr-entry.js +4 -4
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js +21 -7
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +77 -9
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/entries/runtime-entry-module.d.ts +2 -1
- package/dist/entries/runtime-entry-module.js +9 -3
- package/dist/entries/runtime-entry-module.js.map +1 -1
- package/dist/index.js +260 -75
- package/dist/index.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +15 -2
- package/dist/plugins/client-reference-dedup.js +138 -16
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/plugins/css-data-url.d.ts +7 -0
- package/dist/plugins/css-data-url.js +81 -0
- package/dist/plugins/css-data-url.js.map +1 -0
- package/dist/plugins/fonts.d.ts +2 -2
- package/dist/plugins/fonts.js +20 -9
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/middleware-server-only.d.ts +54 -0
- package/dist/plugins/middleware-server-only.js +91 -0
- package/dist/plugins/middleware-server-only.js.map +1 -0
- package/dist/plugins/optimize-imports.js +4 -4
- package/dist/plugins/optimize-imports.js.map +1 -1
- package/dist/plugins/sass.d.ts +34 -0
- package/dist/plugins/sass.js +22 -0
- package/dist/plugins/sass.js.map +1 -0
- package/dist/plugins/strip-server-exports.js +5 -8
- package/dist/plugins/strip-server-exports.js.map +1 -1
- package/dist/routing/app-route-graph.d.ts +50 -2
- package/dist/routing/app-route-graph.js +140 -16
- package/dist/routing/app-route-graph.js.map +1 -1
- package/dist/routing/app-router.d.ts +2 -2
- package/dist/routing/app-router.js +2 -2
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/route-pattern.d.ts +56 -1
- package/dist/routing/route-pattern.js +60 -1
- package/dist/routing/route-pattern.js.map +1 -1
- package/dist/routing/utils.d.ts +2 -1
- package/dist/routing/utils.js +4 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +139 -37
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +27 -2
- package/dist/server/app-browser-action-result.js +63 -2
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +493 -195
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-hydration.d.ts +13 -1
- package/dist/server/app-browser-hydration.js +9 -1
- package/dist/server/app-browser-hydration.js.map +1 -1
- package/dist/server/app-browser-interception-context.d.ts +24 -0
- package/dist/server/app-browser-interception-context.js +32 -0
- package/dist/server/app-browser-interception-context.js.map +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +17 -2
- package/dist/server/app-browser-navigation-controller.js +33 -10
- package/dist/server/app-browser-navigation-controller.js.map +1 -1
- package/dist/server/app-browser-popstate.d.ts +16 -0
- package/dist/server/app-browser-popstate.js +17 -0
- package/dist/server/app-browser-popstate.js.map +1 -0
- package/dist/server/app-browser-rsc-redirect.d.ts +29 -0
- package/dist/server/app-browser-rsc-redirect.js +37 -0
- package/dist/server/app-browser-rsc-redirect.js.map +1 -0
- package/dist/server/app-browser-state.d.ts +28 -7
- package/dist/server/app-browser-state.js +63 -27
- package/dist/server/app-browser-state.js.map +1 -1
- package/dist/server/app-browser-stream.d.ts +9 -17
- package/dist/server/app-browser-stream.js +18 -13
- package/dist/server/app-browser-stream.js.map +1 -1
- package/dist/server/app-browser-visible-commit.d.ts +7 -1
- package/dist/server/app-browser-visible-commit.js +39 -5
- package/dist/server/app-browser-visible-commit.js.map +1 -1
- package/dist/server/app-elements-wire.d.ts +43 -6
- package/dist/server/app-elements-wire.js +189 -7
- package/dist/server/app-elements-wire.js.map +1 -1
- package/dist/server/app-elements.d.ts +3 -2
- package/dist/server/app-elements.js +3 -2
- package/dist/server/app-elements.js.map +1 -1
- package/dist/server/app-fallback-renderer.d.ts +10 -1
- package/dist/server/app-fallback-renderer.js +41 -3
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.d.ts +26 -0
- package/dist/server/app-history-state.js +53 -0
- package/dist/server/app-history-state.js.map +1 -0
- package/dist/server/app-middleware.d.ts +13 -0
- package/dist/server/app-middleware.js +3 -1
- package/dist/server/app-middleware.js.map +1 -1
- package/dist/server/app-optimistic-routing.d.ts +54 -0
- package/dist/server/app-optimistic-routing.js +200 -0
- package/dist/server/app-optimistic-routing.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +10 -1
- package/dist/server/app-page-boundary-render.js +13 -6
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.js +3 -2
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +26 -1
- package/dist/server/app-page-cache.js +86 -14
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +7 -0
- package/dist/server/app-page-dispatch.js +96 -12
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +7 -0
- package/dist/server/app-page-element-builder.js +34 -5
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +28 -1
- package/dist/server/app-page-execution.js +91 -7
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +7 -0
- package/dist/server/app-page-head.js +23 -3
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +23 -1
- package/dist/server/app-page-probe.js +29 -1
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render-observation.d.ts +35 -0
- package/dist/server/app-page-render-observation.js +68 -0
- package/dist/server/app-page-render-observation.js.map +1 -0
- package/dist/server/app-page-render.d.ts +7 -1
- package/dist/server/app-page-render.js +81 -4
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +1 -0
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.js +7 -5
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +3 -1
- package/dist/server/app-page-route-wiring.js +59 -24
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +5 -0
- package/dist/server/app-page-stream.js +2 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-prerender-static-params.d.ts +2 -1
- package/dist/server/app-prerender-static-params.js +44 -8
- package/dist/server/app-prerender-static-params.js.map +1 -1
- package/dist/server/app-route-handler-cache.d.ts +2 -2
- package/dist/server/app-route-handler-cache.js +3 -2
- package/dist/server/app-route-handler-cache.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +6 -1
- package/dist/server/app-route-handler-dispatch.js +1 -1
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +17 -2
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +5 -4
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-router-entry.js +7 -15
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +19 -1
- package/dist/server/app-rsc-cache-busting.js +36 -1
- package/dist/server/app-rsc-cache-busting.js.map +1 -1
- package/dist/server/app-rsc-embedded-chunks.d.ts +9 -0
- package/dist/server/app-rsc-embedded-chunks.js +34 -0
- package/dist/server/app-rsc-embedded-chunks.js.map +1 -0
- package/dist/server/app-rsc-errors.d.ts +4 -1
- package/dist/server/app-rsc-errors.js +1 -1
- package/dist/server/app-rsc-errors.js.map +1 -1
- package/dist/server/app-rsc-handler.d.ts +21 -5
- package/dist/server/app-rsc-handler.js +38 -15
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-render-mode.d.ts +4 -3
- package/dist/server/app-rsc-render-mode.js +7 -1
- package/dist/server/app-rsc-render-mode.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.d.ts +4 -1
- package/dist/server/app-rsc-request-normalization.js +4 -1
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-rsc-response-finalizer.d.ts +8 -1
- package/dist/server/app-rsc-response-finalizer.js +10 -3
- package/dist/server/app-rsc-response-finalizer.js.map +1 -1
- package/dist/server/app-rsc-route-matching.d.ts +23 -0
- package/dist/server/app-rsc-route-matching.js +47 -25
- package/dist/server/app-rsc-route-matching.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +35 -3
- package/dist/server/app-server-action-execution.js +87 -33
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +83 -58
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-error-meta.d.ts +14 -0
- package/dist/server/app-ssr-error-meta.js +50 -0
- package/dist/server/app-ssr-error-meta.js.map +1 -0
- package/dist/server/app-ssr-stream.d.ts +7 -2
- package/dist/server/app-ssr-stream.js +26 -15
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/artifact-compatibility.d.ts +13 -3
- package/dist/server/artifact-compatibility.js +12 -8
- package/dist/server/artifact-compatibility.js.map +1 -1
- package/dist/server/cache-headers.d.ts +7 -0
- package/dist/server/cache-headers.js +19 -0
- package/dist/server/cache-headers.js.map +1 -0
- package/dist/server/cache-proof.d.ts +170 -5
- package/dist/server/cache-proof.js +472 -18
- package/dist/server/cache-proof.js.map +1 -1
- package/dist/server/client-reuse-manifest.d.ts +99 -0
- package/dist/server/client-reuse-manifest.js +212 -0
- package/dist/server/client-reuse-manifest.js.map +1 -0
- package/dist/server/default-global-error-module.d.ts +20 -0
- package/dist/server/default-global-error-module.js +20 -0
- package/dist/server/default-global-error-module.js.map +1 -0
- package/dist/server/dev-lockfile.d.ts +110 -0
- package/dist/server/dev-lockfile.js +180 -0
- package/dist/server/dev-lockfile.js.map +1 -0
- package/dist/server/dev-server.d.ts +9 -1
- package/dist/server/dev-server.js +76 -19
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/edge-api-runtime.d.ts +5 -0
- package/dist/server/edge-api-runtime.js +8 -0
- package/dist/server/edge-api-runtime.js.map +1 -0
- package/dist/server/file-based-metadata.d.ts +13 -0
- package/dist/server/file-based-metadata.js +49 -2
- package/dist/server/file-based-metadata.js.map +1 -1
- package/dist/server/headers.d.ts +20 -1
- package/dist/server/headers.js +22 -2
- package/dist/server/headers.js.map +1 -1
- package/dist/server/html.js +1 -1
- package/dist/server/html.js.map +1 -1
- package/dist/server/http-error-responses.d.ts +26 -1
- package/dist/server/http-error-responses.js +32 -2
- package/dist/server/http-error-responses.js.map +1 -1
- package/dist/server/isr-cache.d.ts +8 -3
- package/dist/server/isr-cache.js +24 -6
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-route-response.js +22 -5
- package/dist/server/metadata-route-response.js.map +1 -1
- package/dist/server/metadata-routes.js +27 -8
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-runtime.d.ts +15 -0
- package/dist/server/middleware-runtime.js +60 -7
- package/dist/server/middleware-runtime.js.map +1 -1
- package/dist/server/middleware.d.ts +13 -1
- package/dist/server/middleware.js +16 -2
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/navigation-planner.d.ts +26 -6
- package/dist/server/navigation-planner.js +358 -24
- package/dist/server/navigation-planner.js.map +1 -1
- package/dist/server/navigation-trace.d.ts +9 -1
- package/dist/server/navigation-trace.js +8 -0
- package/dist/server/navigation-trace.js.map +1 -1
- package/dist/server/normalize-path.d.ts +2 -1
- package/dist/server/normalize-path.js +4 -1
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +27 -1
- package/dist/server/pages-api-route.js +25 -3
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-data-route.d.ts +77 -0
- package/dist/server/pages-data-route.js +97 -0
- package/dist/server/pages-data-route.js.map +1 -0
- package/dist/server/pages-i18n.d.ts +51 -1
- package/dist/server/pages-i18n.js +61 -1
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +32 -4
- package/dist/server/pages-page-data.js +52 -19
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +11 -1
- package/dist/server/pages-page-response.js +6 -4
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prod-server.d.ts +26 -1
- package/dist/server/prod-server.js +150 -44
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +11 -2
- package/dist/server/request-pipeline.js +28 -11
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.d.ts +12 -31
- package/dist/server/seed-cache.js +22 -35
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/server-action-not-found.d.ts +16 -3
- package/dist/server/server-action-not-found.js +27 -4
- package/dist/server/server-action-not-found.js.map +1 -1
- package/dist/server/server-globals.d.ts +5 -0
- package/dist/server/server-globals.js +37 -0
- package/dist/server/server-globals.js.map +1 -0
- package/dist/server/skip-cache-proof.d.ts +41 -0
- package/dist/server/skip-cache-proof.js +101 -0
- package/dist/server/skip-cache-proof.js.map +1 -0
- package/dist/server/static-file-cache.d.ts +1 -1
- package/dist/server/static-file-cache.js +7 -6
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/shims/cache-runtime.d.ts +19 -2
- package/dist/shims/cache-runtime.js +67 -11
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +5 -18
- package/dist/shims/cache.js +2 -0
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-locale.d.ts +15 -0
- package/dist/shims/client-locale.js +13 -0
- package/dist/shims/client-locale.js.map +1 -0
- package/dist/shims/default-global-error.d.ts +32 -0
- package/dist/shims/default-global-error.js +181 -0
- package/dist/shims/default-global-error.js.map +1 -0
- package/dist/shims/document.d.ts +59 -3
- package/dist/shims/document.js +36 -5
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +2 -2
- package/dist/shims/error-boundary.js +6 -8
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts +18 -1
- package/dist/shims/error.js +56 -1
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +4 -1
- package/dist/shims/fetch-cache.js +40 -5
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +22 -8
- package/dist/shims/font-google-base.js +41 -71
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-local.d.ts +3 -20
- package/dist/shims/font-local.js +23 -75
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/font-utils.d.ts +51 -0
- package/dist/shims/font-utils.js +97 -0
- package/dist/shims/font-utils.js.map +1 -0
- package/dist/shims/form.js +13 -6
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/hash-scroll.d.ts +7 -0
- package/dist/shims/hash-scroll.js +30 -0
- package/dist/shims/hash-scroll.js.map +1 -0
- package/dist/shims/headers.d.ts +8 -11
- package/dist/shims/headers.js +22 -2
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -0
- package/dist/shims/image.js +144 -78
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/app-router-context.d.ts +6 -6
- package/dist/shims/internal/app-router-context.js +17 -6
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/link-prefetch.d.ts +9 -1
- package/dist/shims/link-prefetch.js +11 -6
- package/dist/shims/link-prefetch.js.map +1 -1
- package/dist/shims/link.d.ts +33 -5
- package/dist/shims/link.js +205 -50
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +16 -30
- package/dist/shims/metadata.js +91 -32
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.d.ts +164 -17
- package/dist/shims/navigation.js +355 -84
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.d.ts +3 -2
- package/dist/shims/navigation.react-server.js +5 -2
- package/dist/shims/navigation.react-server.js.map +1 -1
- package/dist/shims/og.d.ts +18 -2
- package/dist/shims/og.js +49 -1
- package/dist/shims/og.js.map +1 -0
- package/dist/shims/pages-router-runtime.d.ts +7 -0
- package/dist/shims/pages-router-runtime.js +16 -0
- package/dist/shims/pages-router-runtime.js.map +1 -0
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/root-params.d.ts +3 -1
- package/dist/shims/root-params.js +11 -3
- package/dist/shims/root-params.js.map +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +40 -7
- package/dist/shims/router.js +355 -250
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.js +110 -32
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts +21 -4
- package/dist/shims/server.js +31 -10
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/slot.d.ts +1 -0
- package/dist/shims/slot.js +45 -1
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/unrecognized-action-error.d.ts +35 -0
- package/dist/shims/unrecognized-action-error.js +41 -0
- package/dist/shims/unrecognized-action-error.js.map +1 -0
- package/dist/shims/url-safety.d.ts +23 -1
- package/dist/shims/url-safety.js +29 -2
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +21 -1
- package/dist/shims/url-utils.js +67 -3
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/typegen.d.ts +10 -0
- package/dist/typegen.js +242 -0
- package/dist/typegen.js.map +1 -0
- package/dist/utils/asset-prefix.d.ts +97 -0
- package/dist/utils/asset-prefix.js +124 -0
- package/dist/utils/asset-prefix.js.map +1 -0
- package/dist/utils/base-path.d.ts +7 -1
- package/dist/utils/base-path.js +10 -1
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/cache-control-metadata.d.ts +2 -1
- package/dist/utils/cache-control-metadata.js +1 -3
- package/dist/utils/cache-control-metadata.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +2 -1
- package/dist/utils/domain-locale.js +9 -1
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/lazy-chunks.d.ts +1 -1
- package/dist/utils/lazy-chunks.js +1 -1
- package/dist/utils/lazy-chunks.js.map +1 -1
- package/dist/utils/navigation-signal.d.ts +1 -2
- package/dist/utils/navigation-signal.js +1 -1
- package/dist/utils/navigation-signal.js.map +1 -1
- package/dist/utils/prerender-output-paths.d.ts +15 -0
- package/dist/utils/prerender-output-paths.js +24 -0
- package/dist/utils/prerender-output-paths.js.map +1 -0
- package/dist/utils/query.d.ts +17 -1
- package/dist/utils/query.js +36 -1
- package/dist/utils/query.js.map +1 -1
- package/dist/utils/record.d.ts +5 -0
- package/dist/utils/record.js +8 -0
- package/dist/utils/record.js.map +1 -0
- package/dist/utils/sorted-array.d.ts +9 -0
- package/dist/utils/sorted-array.js +22 -0
- package/dist/utils/sorted-array.js.map +1 -0
- package/package.json +13 -5
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/shims/unrecognized-action-error.ts
|
|
2
|
+
/**
|
|
3
|
+
* Unrecognized server-action errors.
|
|
4
|
+
*
|
|
5
|
+
* When a server action call fails because the server did not recognize the
|
|
6
|
+
* action id, the client bundle and the server are typically from different
|
|
7
|
+
* deployments and a hard reload is required.
|
|
8
|
+
*
|
|
9
|
+
* This module is intentionally dependency-free: both the `next/navigation`
|
|
10
|
+
* shim (which re-exports these for user code) and vinext's client
|
|
11
|
+
* server-action dispatcher import `UnrecognizedActionError` from here, so the
|
|
12
|
+
* `instanceof` check inside `unstable_isUnrecognizedActionError` resolves
|
|
13
|
+
* against a single shared class.
|
|
14
|
+
*
|
|
15
|
+
* Ported 1:1 from Next.js:
|
|
16
|
+
* https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/unrecognized-action-error.ts
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Error class for unrecognized server-action calls. Thrown by vinext's client
|
|
20
|
+
* server-action dispatcher when the server reports the requested action id as
|
|
21
|
+
* unknown (the `x-nextjs-action-not-found` response header).
|
|
22
|
+
*/
|
|
23
|
+
var UnrecognizedActionError = class extends Error {
|
|
24
|
+
constructor(...args) {
|
|
25
|
+
super(...args);
|
|
26
|
+
this.name = "UnrecognizedActionError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Returns true if the error came from a server action whose id was not
|
|
31
|
+
* recognized by the server. Useful inside `catch` blocks that surround
|
|
32
|
+
* `await myAction(...)` calls; reloading the page generally fixes the
|
|
33
|
+
* underlying client/server deployment mismatch.
|
|
34
|
+
*/
|
|
35
|
+
function unstable_isUnrecognizedActionError(error) {
|
|
36
|
+
return !!(error && typeof error === "object" && error instanceof UnrecognizedActionError);
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { UnrecognizedActionError, unstable_isUnrecognizedActionError };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=unrecognized-action-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unrecognized-action-error.js","names":[],"sources":["../../src/shims/unrecognized-action-error.ts"],"sourcesContent":["/**\n * Unrecognized server-action errors.\n *\n * When a server action call fails because the server did not recognize the\n * action id, the client bundle and the server are typically from different\n * deployments and a hard reload is required.\n *\n * This module is intentionally dependency-free: both the `next/navigation`\n * shim (which re-exports these for user code) and vinext's client\n * server-action dispatcher import `UnrecognizedActionError` from here, so the\n * `instanceof` check inside `unstable_isUnrecognizedActionError` resolves\n * against a single shared class.\n *\n * Ported 1:1 from Next.js:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/unrecognized-action-error.ts\n */\n\n/**\n * Error class for unrecognized server-action calls. Thrown by vinext's client\n * server-action dispatcher when the server reports the requested action id as\n * unknown (the `x-nextjs-action-not-found` response header).\n */\nexport class UnrecognizedActionError extends Error {\n constructor(...args: ConstructorParameters<typeof Error>) {\n super(...args);\n this.name = \"UnrecognizedActionError\";\n }\n}\n\n/**\n * Returns true if the error came from a server action whose id was not\n * recognized by the server. Useful inside `catch` blocks that surround\n * `await myAction(...)` calls; reloading the page generally fixes the\n * underlying client/server deployment mismatch.\n */\nexport function unstable_isUnrecognizedActionError(\n error: unknown,\n): error is UnrecognizedActionError {\n return !!(error && typeof error === \"object\" && error instanceof UnrecognizedActionError);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,0BAAb,cAA6C,MAAM;CACjD,YAAY,GAAG,MAA2C;EACxD,MAAM,GAAG,KAAK;EACd,KAAK,OAAO;;;;;;;;;AAUhB,SAAgB,mCACd,OACkC;CAClC,OAAO,CAAC,EAAE,SAAS,OAAO,UAAU,YAAY,iBAAiB"}
|
|
@@ -7,7 +7,29 @@
|
|
|
7
7
|
*/
|
|
8
8
|
declare const DANGEROUS_URL_BLOCK_MESSAGE = "Next.js has blocked a javascript: URL as a security precaution.";
|
|
9
9
|
declare function isDangerousScheme(url: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Emit a `console.error` matching Next.js's blocked-navigation message.
|
|
12
|
+
*
|
|
13
|
+
* Next.js's `router.push` / `router.replace` / `router.prefetch` (and the
|
|
14
|
+
* Pages Router equivalents) throw an `Error` when the URL has a dangerous
|
|
15
|
+
* scheme. In the browser, React's event-handler runtime catches that throw
|
|
16
|
+
* and reports it through `console.error`, which is what the Next.js E2E
|
|
17
|
+
* `test/e2e/app-dir/javascript-urls` suite asserts on.
|
|
18
|
+
*
|
|
19
|
+
* Vinext's navigation guards run synchronously inside async event handlers
|
|
20
|
+
* (e.g. Link's `void handleClick(event)`), so a raw throw is dropped on the
|
|
21
|
+
* floor instead of bubbling up to React. Emitting the same `console.error`
|
|
22
|
+
* explicitly keeps observable behaviour aligned with Next.js — the test
|
|
23
|
+
* matcher uses `.includes("has blocked a javascript: URL as a security
|
|
24
|
+
* precaution.")` so any message containing that phrase satisfies it.
|
|
25
|
+
*
|
|
26
|
+
* Source reference (Next.js):
|
|
27
|
+
* packages/next/src/client/components/segment-cache/navigation.ts:537
|
|
28
|
+
* packages/next/src/client/components/app-router-instance.ts:345,402,442,460
|
|
29
|
+
* packages/next/src/shared/lib/router/router.ts:1025,1057
|
|
30
|
+
*/
|
|
31
|
+
declare function reportBlockedDangerousNavigation(): void;
|
|
10
32
|
declare function assertSafeNavigationUrl(url: string): void;
|
|
11
33
|
//#endregion
|
|
12
|
-
export { DANGEROUS_URL_BLOCK_MESSAGE, assertSafeNavigationUrl, isDangerousScheme };
|
|
34
|
+
export { DANGEROUS_URL_BLOCK_MESSAGE, assertSafeNavigationUrl, isDangerousScheme, reportBlockedDangerousNavigation };
|
|
13
35
|
//# sourceMappingURL=url-safety.d.ts.map
|
package/dist/shims/url-safety.js
CHANGED
|
@@ -36,10 +36,37 @@ function isDangerousScheme(url) {
|
|
|
36
36
|
const str = "" + url;
|
|
37
37
|
return DANGEROUS_SCHEME_RES.some((re) => re.test(str));
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Emit a `console.error` matching Next.js's blocked-navigation message.
|
|
41
|
+
*
|
|
42
|
+
* Next.js's `router.push` / `router.replace` / `router.prefetch` (and the
|
|
43
|
+
* Pages Router equivalents) throw an `Error` when the URL has a dangerous
|
|
44
|
+
* scheme. In the browser, React's event-handler runtime catches that throw
|
|
45
|
+
* and reports it through `console.error`, which is what the Next.js E2E
|
|
46
|
+
* `test/e2e/app-dir/javascript-urls` suite asserts on.
|
|
47
|
+
*
|
|
48
|
+
* Vinext's navigation guards run synchronously inside async event handlers
|
|
49
|
+
* (e.g. Link's `void handleClick(event)`), so a raw throw is dropped on the
|
|
50
|
+
* floor instead of bubbling up to React. Emitting the same `console.error`
|
|
51
|
+
* explicitly keeps observable behaviour aligned with Next.js — the test
|
|
52
|
+
* matcher uses `.includes("has blocked a javascript: URL as a security
|
|
53
|
+
* precaution.")` so any message containing that phrase satisfies it.
|
|
54
|
+
*
|
|
55
|
+
* Source reference (Next.js):
|
|
56
|
+
* packages/next/src/client/components/segment-cache/navigation.ts:537
|
|
57
|
+
* packages/next/src/client/components/app-router-instance.ts:345,402,442,460
|
|
58
|
+
* packages/next/src/shared/lib/router/router.ts:1025,1057
|
|
59
|
+
*/
|
|
60
|
+
function reportBlockedDangerousNavigation() {
|
|
61
|
+
console.error(DANGEROUS_URL_BLOCK_MESSAGE);
|
|
62
|
+
}
|
|
39
63
|
function assertSafeNavigationUrl(url) {
|
|
40
|
-
if (isDangerousScheme(url))
|
|
64
|
+
if (isDangerousScheme(url)) {
|
|
65
|
+
reportBlockedDangerousNavigation();
|
|
66
|
+
throw new Error(DANGEROUS_URL_BLOCK_MESSAGE);
|
|
67
|
+
}
|
|
41
68
|
}
|
|
42
69
|
//#endregion
|
|
43
|
-
export { DANGEROUS_URL_BLOCK_MESSAGE, assertSafeNavigationUrl, isDangerousScheme };
|
|
70
|
+
export { DANGEROUS_URL_BLOCK_MESSAGE, assertSafeNavigationUrl, isDangerousScheme, reportBlockedDangerousNavigation };
|
|
44
71
|
|
|
45
72
|
//# sourceMappingURL=url-safety.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-safety.js","names":[],"sources":["../../src/shims/url-safety.ts"],"sourcesContent":["/**\n * Shared URL safety utilities for Link, Form, and navigation shims.\n *\n * Centralizes dangerous URI scheme detection so all components and\n * navigation functions use the same validation logic.\n */\n\n/**\n * Detect dangerous URI schemes that should never be navigated to.\n *\n * Adapted from Next.js's javascript URL detector:\n * packages/next/src/client/lib/javascript-url.ts\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/client/lib/javascript-url.ts\n *\n * URL parsing ignores leading C0 control characters / spaces, and treats\n * embedded tab/newline characters in the scheme as insignificant. We mirror\n * that behavior here so obfuscated values like `java\\nscript:` and\n * `\\x00javascript:` are still blocked.\n *\n * Vinext intentionally extends this handling to `data:` and `vbscript:` too,\n * since both are also dangerous navigation targets.\n */\nconst LEADING_IGNORED = \"[\\\\u0000-\\\\u001F \\\\u200B\\\\uFEFF]*\";\nconst SCHEME_IGNORED = \"[\\\\r\\\\n\\\\t]*\";\n\nfunction buildDangerousSchemeRegex(scheme: string): RegExp {\n const chars = scheme.split(\"\").join(SCHEME_IGNORED);\n return new RegExp(`^${LEADING_IGNORED}${chars}${SCHEME_IGNORED}:`, \"i\");\n}\n\nconst DANGEROUS_SCHEME_RES = [\n buildDangerousSchemeRegex(\"javascript\"),\n buildDangerousSchemeRegex(\"data\"),\n buildDangerousSchemeRegex(\"vbscript\"),\n];\n\nexport const DANGEROUS_URL_BLOCK_MESSAGE =\n \"Next.js has blocked a javascript: URL as a security precaution.\";\n\nexport function isDangerousScheme(url: string): boolean {\n const str = \"\" + (url as unknown as string);\n return DANGEROUS_SCHEME_RES.some((re) => re.test(str));\n}\n\nexport function assertSafeNavigationUrl(url: string): void {\n if (isDangerousScheme(url)) {\n throw new Error(DANGEROUS_URL_BLOCK_MESSAGE);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AAEvB,SAAS,0BAA0B,QAAwB;CACzD,MAAM,QAAQ,OAAO,MAAM,GAAG,CAAC,KAAK,eAAe;CACnD,OAAO,IAAI,OAAO,IAAI,kBAAkB,QAAQ,eAAe,IAAI,IAAI;;AAGzE,MAAM,uBAAuB;CAC3B,0BAA0B,aAAa;CACvC,0BAA0B,OAAO;CACjC,0BAA0B,WAAW;CACtC;AAED,MAAa,8BACX;AAEF,SAAgB,kBAAkB,KAAsB;CACtD,MAAM,MAAM,KAAM;CAClB,OAAO,qBAAqB,MAAM,OAAO,GAAG,KAAK,IAAI,CAAC;;
|
|
1
|
+
{"version":3,"file":"url-safety.js","names":[],"sources":["../../src/shims/url-safety.ts"],"sourcesContent":["/**\n * Shared URL safety utilities for Link, Form, and navigation shims.\n *\n * Centralizes dangerous URI scheme detection so all components and\n * navigation functions use the same validation logic.\n */\n\n/**\n * Detect dangerous URI schemes that should never be navigated to.\n *\n * Adapted from Next.js's javascript URL detector:\n * packages/next/src/client/lib/javascript-url.ts\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/client/lib/javascript-url.ts\n *\n * URL parsing ignores leading C0 control characters / spaces, and treats\n * embedded tab/newline characters in the scheme as insignificant. We mirror\n * that behavior here so obfuscated values like `java\\nscript:` and\n * `\\x00javascript:` are still blocked.\n *\n * Vinext intentionally extends this handling to `data:` and `vbscript:` too,\n * since both are also dangerous navigation targets.\n */\nconst LEADING_IGNORED = \"[\\\\u0000-\\\\u001F \\\\u200B\\\\uFEFF]*\";\nconst SCHEME_IGNORED = \"[\\\\r\\\\n\\\\t]*\";\n\nfunction buildDangerousSchemeRegex(scheme: string): RegExp {\n const chars = scheme.split(\"\").join(SCHEME_IGNORED);\n return new RegExp(`^${LEADING_IGNORED}${chars}${SCHEME_IGNORED}:`, \"i\");\n}\n\nconst DANGEROUS_SCHEME_RES = [\n buildDangerousSchemeRegex(\"javascript\"),\n buildDangerousSchemeRegex(\"data\"),\n buildDangerousSchemeRegex(\"vbscript\"),\n];\n\nexport const DANGEROUS_URL_BLOCK_MESSAGE =\n \"Next.js has blocked a javascript: URL as a security precaution.\";\n\nexport function isDangerousScheme(url: string): boolean {\n const str = \"\" + (url as unknown as string);\n return DANGEROUS_SCHEME_RES.some((re) => re.test(str));\n}\n\n/**\n * Emit a `console.error` matching Next.js's blocked-navigation message.\n *\n * Next.js's `router.push` / `router.replace` / `router.prefetch` (and the\n * Pages Router equivalents) throw an `Error` when the URL has a dangerous\n * scheme. In the browser, React's event-handler runtime catches that throw\n * and reports it through `console.error`, which is what the Next.js E2E\n * `test/e2e/app-dir/javascript-urls` suite asserts on.\n *\n * Vinext's navigation guards run synchronously inside async event handlers\n * (e.g. Link's `void handleClick(event)`), so a raw throw is dropped on the\n * floor instead of bubbling up to React. Emitting the same `console.error`\n * explicitly keeps observable behaviour aligned with Next.js — the test\n * matcher uses `.includes(\"has blocked a javascript: URL as a security\n * precaution.\")` so any message containing that phrase satisfies it.\n *\n * Source reference (Next.js):\n * packages/next/src/client/components/segment-cache/navigation.ts:537\n * packages/next/src/client/components/app-router-instance.ts:345,402,442,460\n * packages/next/src/shared/lib/router/router.ts:1025,1057\n */\nexport function reportBlockedDangerousNavigation(): void {\n console.error(DANGEROUS_URL_BLOCK_MESSAGE);\n}\n\nexport function assertSafeNavigationUrl(url: string): void {\n if (isDangerousScheme(url)) {\n reportBlockedDangerousNavigation();\n throw new Error(DANGEROUS_URL_BLOCK_MESSAGE);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AAEvB,SAAS,0BAA0B,QAAwB;CACzD,MAAM,QAAQ,OAAO,MAAM,GAAG,CAAC,KAAK,eAAe;CACnD,OAAO,IAAI,OAAO,IAAI,kBAAkB,QAAQ,eAAe,IAAI,IAAI;;AAGzE,MAAM,uBAAuB;CAC3B,0BAA0B,aAAa;CACvC,0BAA0B,OAAO;CACjC,0BAA0B,WAAW;CACtC;AAED,MAAa,8BACX;AAEF,SAAgB,kBAAkB,KAAsB;CACtD,MAAM,MAAM,KAAM;CAClB,OAAO,qBAAqB,MAAM,OAAO,GAAG,KAAK,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAwBxD,SAAgB,mCAAyC;CACvD,QAAQ,MAAM,4BAA4B;;AAG5C,SAAgB,wBAAwB,KAAmB;CACzD,IAAI,kBAAkB,IAAI,EAAE;EAC1B,kCAAkC;EAClC,MAAM,IAAI,MAAM,4BAA4B"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
//#region src/shims/url-utils.d.ts
|
|
2
|
+
declare function isAbsoluteUrl(url: string): boolean;
|
|
3
|
+
declare function isAbsoluteOrProtocolRelativeUrl(url: string): boolean;
|
|
2
4
|
/**
|
|
3
5
|
* If `url` is an absolute same-origin URL, return the local path
|
|
4
6
|
* (pathname + search + hash). Returns null for truly external URLs
|
|
@@ -11,6 +13,24 @@ declare function toSameOriginPath(url: string): string | null;
|
|
|
11
13
|
* truly external URLs or on the server.
|
|
12
14
|
*/
|
|
13
15
|
declare function toSameOriginAppPath(url: string, basePath: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Normalise the trailing slash of a local URL according to the
|
|
18
|
+
* `trailingSlash` config option in `next.config.js`. Used by the `<Link>`
|
|
19
|
+
* shim so that rendered `href` attributes match the canonical URL form
|
|
20
|
+
* (which is what the server-side redirect would otherwise enforce).
|
|
21
|
+
*
|
|
22
|
+
* Behaviour matches Next.js's client-side `normalizePathTrailingSlash`:
|
|
23
|
+
* packages/next/src/client/normalize-trailing-slash.ts
|
|
24
|
+
*
|
|
25
|
+
* - Absolute URLs (`http://`, `https://`, `//`) and non-local strings are
|
|
26
|
+
* returned unchanged.
|
|
27
|
+
* - Paths whose final segment looks like a filename (`...\.ext`) have any
|
|
28
|
+
* trailing slash stripped even when `trailingSlash: true`, mirroring the
|
|
29
|
+
* `.well-known`-aware redirect rule shipped in `routes-manifest.json`.
|
|
30
|
+
* - Query strings and hash fragments are preserved verbatim.
|
|
31
|
+
* - Idempotent: already-canonical paths round-trip unchanged.
|
|
32
|
+
*/
|
|
33
|
+
declare function normalizePathTrailingSlash(path: string, trailingSlash: boolean): string;
|
|
14
34
|
/**
|
|
15
35
|
* Prepend basePath to a local path for browser URLs / fetches.
|
|
16
36
|
*/
|
|
@@ -27,5 +47,5 @@ declare function resolveRelativeHref(href: string, currentUrl?: string, basePath
|
|
|
27
47
|
declare function toBrowserNavigationHref(href: string, currentUrl?: string, basePath?: string): string;
|
|
28
48
|
declare function isHashOnlyBrowserUrlChange(href: string, currentHref: string, basePath?: string): boolean;
|
|
29
49
|
//#endregion
|
|
30
|
-
export { isHashOnlyBrowserUrlChange, resolveRelativeHref, toBrowserNavigationHref, toSameOriginAppPath, toSameOriginPath, withBasePath };
|
|
50
|
+
export { isAbsoluteOrProtocolRelativeUrl, isAbsoluteUrl, isHashOnlyBrowserUrlChange, normalizePathTrailingSlash, resolveRelativeHref, toBrowserNavigationHref, toSameOriginAppPath, toSameOriginPath, withBasePath };
|
|
31
51
|
//# sourceMappingURL=url-utils.d.ts.map
|
package/dist/shims/url-utils.js
CHANGED
|
@@ -6,6 +6,14 @@ import { hasBasePath, stripBasePath } from "../utils/base-path.js";
|
|
|
6
6
|
* Used by link.tsx, navigation.ts, and router.ts to normalize
|
|
7
7
|
* same-origin absolute URLs to local paths for client-side navigation.
|
|
8
8
|
*/
|
|
9
|
+
const ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
|
|
10
|
+
function isAbsoluteUrl(url) {
|
|
11
|
+
const firstChar = url.charCodeAt(0);
|
|
12
|
+
return (firstChar >= 65 && firstChar <= 90 || firstChar >= 97 && firstChar <= 122) && ABSOLUTE_URL_REGEX.test(url);
|
|
13
|
+
}
|
|
14
|
+
function isAbsoluteOrProtocolRelativeUrl(url) {
|
|
15
|
+
return isAbsoluteUrl(url) || url.startsWith("//");
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
18
|
* If `url` is an absolute same-origin URL, return the local path
|
|
11
19
|
* (pathname + search + hash). Returns null for truly external URLs
|
|
@@ -36,10 +44,66 @@ function toSameOriginAppPath(url, basePath) {
|
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
/**
|
|
47
|
+
* Split a path string into pathname, query, and hash without depending on
|
|
48
|
+
* the URL constructor (which would resolve relative paths against an origin).
|
|
49
|
+
*
|
|
50
|
+
* Ported from Next.js: packages/next/src/shared/lib/router/utils/parse-path.ts
|
|
51
|
+
*/
|
|
52
|
+
function parsePath(path) {
|
|
53
|
+
const hashIndex = path.indexOf("#");
|
|
54
|
+
const queryIndex = path.indexOf("?");
|
|
55
|
+
const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex);
|
|
56
|
+
if (hasQuery || hashIndex > -1) return {
|
|
57
|
+
pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),
|
|
58
|
+
query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : void 0) : "",
|
|
59
|
+
hash: hashIndex > -1 ? path.slice(hashIndex) : ""
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
pathname: path,
|
|
63
|
+
query: "",
|
|
64
|
+
hash: ""
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Drop trailing slashes from a route while preserving the bare root.
|
|
69
|
+
*
|
|
70
|
+
* Ported from Next.js: packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts
|
|
71
|
+
*/
|
|
72
|
+
function removeRouteTrailingSlash(route) {
|
|
73
|
+
return route.replace(/\/$/, "") || "/";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Normalise the trailing slash of a local URL according to the
|
|
77
|
+
* `trailingSlash` config option in `next.config.js`. Used by the `<Link>`
|
|
78
|
+
* shim so that rendered `href` attributes match the canonical URL form
|
|
79
|
+
* (which is what the server-side redirect would otherwise enforce).
|
|
80
|
+
*
|
|
81
|
+
* Behaviour matches Next.js's client-side `normalizePathTrailingSlash`:
|
|
82
|
+
* packages/next/src/client/normalize-trailing-slash.ts
|
|
83
|
+
*
|
|
84
|
+
* - Absolute URLs (`http://`, `https://`, `//`) and non-local strings are
|
|
85
|
+
* returned unchanged.
|
|
86
|
+
* - Paths whose final segment looks like a filename (`...\.ext`) have any
|
|
87
|
+
* trailing slash stripped even when `trailingSlash: true`, mirroring the
|
|
88
|
+
* `.well-known`-aware redirect rule shipped in `routes-manifest.json`.
|
|
89
|
+
* - Query strings and hash fragments are preserved verbatim.
|
|
90
|
+
* - Idempotent: already-canonical paths round-trip unchanged.
|
|
91
|
+
*/
|
|
92
|
+
function normalizePathTrailingSlash(path, trailingSlash) {
|
|
93
|
+
if (!path.startsWith("/") || path.startsWith("//")) return path;
|
|
94
|
+
const { pathname, query, hash } = parsePath(path);
|
|
95
|
+
if (trailingSlash) {
|
|
96
|
+
if (/\.[^/]+\/?$/.test(pathname)) return `${removeRouteTrailingSlash(pathname)}${query}${hash}`;
|
|
97
|
+
if (pathname.endsWith("/")) return `${pathname}${query}${hash}`;
|
|
98
|
+
return `${pathname}/${query}${hash}`;
|
|
99
|
+
}
|
|
100
|
+
return `${removeRouteTrailingSlash(pathname)}${query}${hash}`;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
39
103
|
* Prepend basePath to a local path for browser URLs / fetches.
|
|
40
104
|
*/
|
|
41
105
|
function withBasePath(path, basePath) {
|
|
42
|
-
if (!basePath || !path.startsWith("/") ||
|
|
106
|
+
if (!basePath || !path.startsWith("/") || isAbsoluteOrProtocolRelativeUrl(path)) return path;
|
|
43
107
|
return basePath + path;
|
|
44
108
|
}
|
|
45
109
|
/**
|
|
@@ -49,7 +113,7 @@ function withBasePath(path, basePath) {
|
|
|
49
113
|
function resolveRelativeHref(href, currentUrl, basePath = "") {
|
|
50
114
|
const base = currentUrl ?? (typeof window !== "undefined" ? window.location.href : void 0);
|
|
51
115
|
if (!base) return href;
|
|
52
|
-
if (href.startsWith("/") ||
|
|
116
|
+
if (href.startsWith("/") || isAbsoluteOrProtocolRelativeUrl(href)) return href;
|
|
53
117
|
try {
|
|
54
118
|
const resolved = new URL(href, base);
|
|
55
119
|
return (basePath && resolved.pathname === basePath ? "" : basePath ? stripBasePath(resolved.pathname, basePath) : resolved.pathname) + resolved.search + resolved.hash;
|
|
@@ -78,6 +142,6 @@ function isHashOnlyBrowserUrlChange(href, currentHref, basePath = "") {
|
|
|
78
142
|
}
|
|
79
143
|
}
|
|
80
144
|
//#endregion
|
|
81
|
-
export { isHashOnlyBrowserUrlChange, resolveRelativeHref, toBrowserNavigationHref, toSameOriginAppPath, toSameOriginPath, withBasePath };
|
|
145
|
+
export { isAbsoluteOrProtocolRelativeUrl, isAbsoluteUrl, isHashOnlyBrowserUrlChange, normalizePathTrailingSlash, resolveRelativeHref, toBrowserNavigationHref, toSameOriginAppPath, toSameOriginPath, withBasePath };
|
|
82
146
|
|
|
83
147
|
//# sourceMappingURL=url-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-utils.js","names":[],"sources":["../../src/shims/url-utils.ts"],"sourcesContent":["/**\n * Shared URL utilities for same-origin detection.\n *\n * Used by link.tsx, navigation.ts, and router.ts to normalize\n * same-origin absolute URLs to local paths for client-side navigation.\n */\nimport { hasBasePath, stripBasePath } from \"../utils/base-path.js\";\n\n/**\n * If `url` is an absolute same-origin URL, return the local path\n * (pathname + search + hash). Returns null for truly external URLs\n * or on the server (where origin is unknown).\n */\nexport function toSameOriginPath(url: string): string | null {\n if (typeof window === \"undefined\") return null;\n try {\n const parsed = url.startsWith(\"//\") ? new URL(url, window.location.origin) : new URL(url);\n if (parsed.origin === window.location.origin) {\n return parsed.pathname + parsed.search + parsed.hash;\n }\n } catch {\n // not a valid absolute URL — ignore\n }\n return null;\n}\n\n/**\n * If `url` is an absolute same-origin URL, return the app-relative path\n * (basePath stripped from the pathname, if configured). Returns null for\n * truly external URLs or on the server.\n */\nexport function toSameOriginAppPath(url: string, basePath: string): string | null {\n const localPath = toSameOriginPath(url);\n if (localPath == null || !basePath) return localPath;\n\n try {\n const parsed = new URL(localPath, \"http://vinext.local\");\n if (!hasBasePath(parsed.pathname, basePath)) {\n return null;\n }\n const pathname = stripBasePath(parsed.pathname, basePath);\n return pathname + parsed.search + parsed.hash;\n } catch {\n return localPath;\n }\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"url-utils.js","names":[],"sources":["../../src/shims/url-utils.ts"],"sourcesContent":["/**\n * Shared URL utilities for same-origin detection.\n *\n * Used by link.tsx, navigation.ts, and router.ts to normalize\n * same-origin absolute URLs to local paths for client-side navigation.\n */\nimport { hasBasePath, stripBasePath } from \"../utils/base-path.js\";\n\n// Mirrors Next.js's absolute URL classification:\n// packages/next/src/shared/lib/utils.ts\nconst ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\\d+\\-.]*?:/;\n\nexport function isAbsoluteUrl(url: string): boolean {\n const firstChar = url.charCodeAt(0);\n const startsWithLetter =\n (firstChar >= 65 && firstChar <= 90) || (firstChar >= 97 && firstChar <= 122);\n\n return startsWithLetter && ABSOLUTE_URL_REGEX.test(url);\n}\n\nexport function isAbsoluteOrProtocolRelativeUrl(url: string): boolean {\n return isAbsoluteUrl(url) || url.startsWith(\"//\");\n}\n\n/**\n * If `url` is an absolute same-origin URL, return the local path\n * (pathname + search + hash). Returns null for truly external URLs\n * or on the server (where origin is unknown).\n */\nexport function toSameOriginPath(url: string): string | null {\n if (typeof window === \"undefined\") return null;\n try {\n const parsed = url.startsWith(\"//\") ? new URL(url, window.location.origin) : new URL(url);\n if (parsed.origin === window.location.origin) {\n return parsed.pathname + parsed.search + parsed.hash;\n }\n } catch {\n // not a valid absolute URL — ignore\n }\n return null;\n}\n\n/**\n * If `url` is an absolute same-origin URL, return the app-relative path\n * (basePath stripped from the pathname, if configured). Returns null for\n * truly external URLs or on the server.\n */\nexport function toSameOriginAppPath(url: string, basePath: string): string | null {\n const localPath = toSameOriginPath(url);\n if (localPath == null || !basePath) return localPath;\n\n try {\n const parsed = new URL(localPath, \"http://vinext.local\");\n if (!hasBasePath(parsed.pathname, basePath)) {\n return null;\n }\n const pathname = stripBasePath(parsed.pathname, basePath);\n return pathname + parsed.search + parsed.hash;\n } catch {\n return localPath;\n }\n}\n\n/**\n * Split a path string into pathname, query, and hash without depending on\n * the URL constructor (which would resolve relative paths against an origin).\n *\n * Ported from Next.js: packages/next/src/shared/lib/router/utils/parse-path.ts\n */\nfunction parsePath(path: string): { pathname: string; query: string; hash: string } {\n const hashIndex = path.indexOf(\"#\");\n const queryIndex = path.indexOf(\"?\");\n const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex);\n\n if (hasQuery || hashIndex > -1) {\n return {\n pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),\n query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : undefined) : \"\",\n hash: hashIndex > -1 ? path.slice(hashIndex) : \"\",\n };\n }\n\n return { pathname: path, query: \"\", hash: \"\" };\n}\n\n/**\n * Drop trailing slashes from a route while preserving the bare root.\n *\n * Ported from Next.js: packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts\n */\nfunction removeRouteTrailingSlash(route: string): string {\n return route.replace(/\\/$/, \"\") || \"/\";\n}\n\n/**\n * Normalise the trailing slash of a local URL according to the\n * `trailingSlash` config option in `next.config.js`. Used by the `<Link>`\n * shim so that rendered `href` attributes match the canonical URL form\n * (which is what the server-side redirect would otherwise enforce).\n *\n * Behaviour matches Next.js's client-side `normalizePathTrailingSlash`:\n * packages/next/src/client/normalize-trailing-slash.ts\n *\n * - Absolute URLs (`http://`, `https://`, `//`) and non-local strings are\n * returned unchanged.\n * - Paths whose final segment looks like a filename (`...\\.ext`) have any\n * trailing slash stripped even when `trailingSlash: true`, mirroring the\n * `.well-known`-aware redirect rule shipped in `routes-manifest.json`.\n * - Query strings and hash fragments are preserved verbatim.\n * - Idempotent: already-canonical paths round-trip unchanged.\n */\nexport function normalizePathTrailingSlash(path: string, trailingSlash: boolean): string {\n if (!path.startsWith(\"/\") || path.startsWith(\"//\")) {\n return path;\n }\n\n const { pathname, query, hash } = parsePath(path);\n\n if (trailingSlash) {\n if (/\\.[^/]+\\/?$/.test(pathname)) {\n // Looks like a filename — strip trailing slash even with trailingSlash: true.\n return `${removeRouteTrailingSlash(pathname)}${query}${hash}`;\n }\n if (pathname.endsWith(\"/\")) {\n return `${pathname}${query}${hash}`;\n }\n return `${pathname}/${query}${hash}`;\n }\n\n return `${removeRouteTrailingSlash(pathname)}${query}${hash}`;\n}\n\n/**\n * Prepend basePath to a local path for browser URLs / fetches.\n */\nexport function withBasePath(path: string, basePath: string): string {\n if (!basePath || !path.startsWith(\"/\") || isAbsoluteOrProtocolRelativeUrl(path)) {\n return path;\n }\n\n return basePath + path;\n}\n\n/**\n * Resolve a potentially relative href against the current URL.\n * Handles: \"#hash\", \"?query\", \"?query#hash\", and relative paths.\n */\nexport function resolveRelativeHref(href: string, currentUrl?: string, basePath = \"\"): string {\n const base = currentUrl ?? (typeof window !== \"undefined\" ? window.location.href : undefined);\n\n if (!base) return href;\n\n if (href.startsWith(\"/\") || isAbsoluteOrProtocolRelativeUrl(href)) {\n return href;\n }\n\n try {\n const resolved = new URL(href, base);\n const pathname =\n basePath && resolved.pathname === basePath\n ? \"\"\n : basePath\n ? stripBasePath(resolved.pathname, basePath)\n : resolved.pathname;\n return pathname + resolved.search + resolved.hash;\n } catch {\n return href;\n }\n}\n\n/**\n * Convert a local navigation target into the browser URL that should be used\n * for history entries, fetches, and onNavigate callbacks.\n */\nexport function toBrowserNavigationHref(href: string, currentUrl?: string, basePath = \"\"): string {\n const resolved = resolveRelativeHref(href, currentUrl, basePath);\n\n if (!basePath) {\n return withBasePath(resolved, basePath);\n }\n\n if (resolved === \"\") {\n return basePath;\n }\n\n if (resolved.startsWith(\"?\") || resolved.startsWith(\"#\")) {\n return basePath + resolved;\n }\n\n return withBasePath(resolved, basePath);\n}\n\nexport function isHashOnlyBrowserUrlChange(\n href: string,\n currentHref: string,\n basePath = \"\",\n): boolean {\n try {\n const current = new URL(currentHref);\n const next = new URL(href, currentHref);\n const currentPathname = stripBasePath(current.pathname, basePath);\n const nextPathname = stripBasePath(next.pathname, basePath);\n return currentPathname === nextPathname && current.search === next.search && next.hash !== \"\";\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,qBAAqB;AAE3B,SAAgB,cAAc,KAAsB;CAClD,MAAM,YAAY,IAAI,WAAW,EAAE;CAInC,QAFG,aAAa,MAAM,aAAa,MAAQ,aAAa,MAAM,aAAa,QAEhD,mBAAmB,KAAK,IAAI;;AAGzD,SAAgB,gCAAgC,KAAsB;CACpE,OAAO,cAAc,IAAI,IAAI,IAAI,WAAW,KAAK;;;;;;;AAQnD,SAAgB,iBAAiB,KAA4B;CAC3D,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,IAAI;EACF,MAAM,SAAS,IAAI,WAAW,KAAK,GAAG,IAAI,IAAI,KAAK,OAAO,SAAS,OAAO,GAAG,IAAI,IAAI,IAAI;EACzF,IAAI,OAAO,WAAW,OAAO,SAAS,QACpC,OAAO,OAAO,WAAW,OAAO,SAAS,OAAO;SAE5C;CAGR,OAAO;;;;;;;AAQT,SAAgB,oBAAoB,KAAa,UAAiC;CAChF,MAAM,YAAY,iBAAiB,IAAI;CACvC,IAAI,aAAa,QAAQ,CAAC,UAAU,OAAO;CAE3C,IAAI;EACF,MAAM,SAAS,IAAI,IAAI,WAAW,sBAAsB;EACxD,IAAI,CAAC,YAAY,OAAO,UAAU,SAAS,EACzC,OAAO;EAGT,OADiB,cAAc,OAAO,UAAU,SACjC,GAAG,OAAO,SAAS,OAAO;SACnC;EACN,OAAO;;;;;;;;;AAUX,SAAS,UAAU,MAAiE;CAClF,MAAM,YAAY,KAAK,QAAQ,IAAI;CACnC,MAAM,aAAa,KAAK,QAAQ,IAAI;CACpC,MAAM,WAAW,aAAa,OAAO,YAAY,KAAK,aAAa;CAEnE,IAAI,YAAY,YAAY,IAC1B,OAAO;EACL,UAAU,KAAK,UAAU,GAAG,WAA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;;;;;;AAQX,SAAgB,wBAAwB,MAAc,YAAqB,WAAW,IAAY;CAChG,MAAM,WAAW,oBAAoB,MAAM,YAAY,SAAS;CAEhE,IAAI,CAAC,UACH,OAAO,aAAa,UAAU,SAAS;CAGzC,IAAI,aAAa,IACf,OAAO;CAGT,IAAI,SAAS,WAAW,IAAI,IAAI,SAAS,WAAW,IAAI,EACtD,OAAO,WAAW;CAGpB,OAAO,aAAa,UAAU,SAAS;;AAGzC,SAAgB,2BACd,MACA,aACA,WAAW,IACF;CACT,IAAI;EACF,MAAM,UAAU,IAAI,IAAI,YAAY;EACpC,MAAM,OAAO,IAAI,IAAI,MAAM,YAAY;EAGvC,OAFwB,cAAc,QAAQ,UAAU,SAElC,KADD,cAAc,KAAK,UAAU,SACX,IAAI,QAAQ,WAAW,KAAK,UAAU,KAAK,SAAS;SACrF;EACN,OAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/typegen.d.ts
|
|
2
|
+
type GenerateRouteTypesOptions = {
|
|
3
|
+
root: string;
|
|
4
|
+
appDir?: string | null;
|
|
5
|
+
pageExtensions?: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
declare function generateRouteTypes(options: GenerateRouteTypesOptions): Promise<string>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { generateRouteTypes };
|
|
10
|
+
//# sourceMappingURL=typegen.d.ts.map
|
package/dist/typegen.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { decodeRouteSegment } from "./routing/utils.js";
|
|
2
|
+
import { patternToNextFormat } from "./routing/route-validation.js";
|
|
3
|
+
import { isInvisibleSegment } from "./routing/app-route-graph.js";
|
|
4
|
+
import { appRouteGraph } from "./routing/app-router.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
|
+
//#region src/typegen.ts
|
|
8
|
+
const NEXT_ENV_FILE_CONTENT = `/// <reference types="next" />
|
|
9
|
+
/// <reference types="next/image-types/global" />
|
|
10
|
+
import "./.next/types/routes.d.ts";
|
|
11
|
+
|
|
12
|
+
// NOTE: This file should not be edited
|
|
13
|
+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
|
14
|
+
`;
|
|
15
|
+
async function generateRouteTypes(options) {
|
|
16
|
+
const root = path.resolve(options.root);
|
|
17
|
+
const appDir = options.appDir ? path.resolve(options.appDir) : await findAppDir(root);
|
|
18
|
+
const outPath = path.join(root, ".next", "types", "routes.d.ts");
|
|
19
|
+
const content = appDir ? renderRouteTypes(await collectRouteTypeModel(appDir, options.pageExtensions)) : renderRouteTypes(emptyRouteTypeModel());
|
|
20
|
+
await fs.mkdir(path.dirname(outPath), { recursive: true });
|
|
21
|
+
await fs.writeFile(outPath, content, "utf-8");
|
|
22
|
+
await ensureNextEnvFile(root);
|
|
23
|
+
return outPath;
|
|
24
|
+
}
|
|
25
|
+
async function ensureNextEnvFile(root) {
|
|
26
|
+
const envPath = path.join(root, "next-env.d.ts");
|
|
27
|
+
try {
|
|
28
|
+
await fs.writeFile(envPath, NEXT_ENV_FILE_CONTENT, {
|
|
29
|
+
encoding: "utf-8",
|
|
30
|
+
flag: "wx"
|
|
31
|
+
});
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (error.code !== "EEXIST") throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function emptyRouteTypeModel() {
|
|
37
|
+
return {
|
|
38
|
+
pageRoutes: [],
|
|
39
|
+
layoutRoutes: [],
|
|
40
|
+
routeHandlerRoutes: [],
|
|
41
|
+
params: /* @__PURE__ */ new Map(),
|
|
42
|
+
layoutSlots: /* @__PURE__ */ new Map()
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function collectRouteTypeModel(appDir, pageExtensions) {
|
|
46
|
+
const graph = await appRouteGraph(appDir, pageExtensions);
|
|
47
|
+
const model = emptyRouteTypeModel();
|
|
48
|
+
const segmentGraph = graph.routeManifest.segmentGraph;
|
|
49
|
+
const layoutRouteKeys = createLayoutRouteKeyMap(segmentGraph.layouts.values());
|
|
50
|
+
const pageRouteSet = /* @__PURE__ */ new Set();
|
|
51
|
+
const layoutRouteSet = /* @__PURE__ */ new Set();
|
|
52
|
+
const routeHandlerRouteSet = /* @__PURE__ */ new Set();
|
|
53
|
+
for (const route of segmentGraph.pages.values()) {
|
|
54
|
+
const routeEntry = segmentGraph.routes.get(route.routeId);
|
|
55
|
+
addRoute(model.pageRoutes, pageRouteSet, model.params, patternToNextFormat(route.pattern), paramsForPatternParts(routeEntry?.patternParts ?? []));
|
|
56
|
+
}
|
|
57
|
+
for (const route of segmentGraph.routeHandlers.values()) {
|
|
58
|
+
const routeEntry = segmentGraph.routes.get(route.routeId);
|
|
59
|
+
addRoute(model.routeHandlerRoutes, routeHandlerRouteSet, model.params, patternToNextFormat(route.pattern), paramsForPatternParts(routeEntry?.patternParts ?? []));
|
|
60
|
+
}
|
|
61
|
+
for (const layout of segmentGraph.layouts.values()) {
|
|
62
|
+
const route = layoutRouteKeys.get(layout.treePath) ?? treePathToRouteLiteral(layout.treePath);
|
|
63
|
+
addRoute(model.layoutRoutes, layoutRouteSet, model.params, route, paramsForPatternParts(layout.patternParts));
|
|
64
|
+
}
|
|
65
|
+
const layoutSlotSets = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const slot of segmentGraph.slots.values()) {
|
|
67
|
+
const layoutRoute = layoutRouteKeyForSlot(slot, segmentGraph.layouts, layoutRouteKeys);
|
|
68
|
+
if (!layoutRoute) continue;
|
|
69
|
+
let slotNames = layoutSlotSets.get(layoutRoute);
|
|
70
|
+
if (!slotNames) {
|
|
71
|
+
slotNames = /* @__PURE__ */ new Set();
|
|
72
|
+
layoutSlotSets.set(layoutRoute, slotNames);
|
|
73
|
+
model.layoutSlots.set(layoutRoute, []);
|
|
74
|
+
}
|
|
75
|
+
if (!slotNames.has(slot.name)) {
|
|
76
|
+
slotNames.add(slot.name);
|
|
77
|
+
model.layoutSlots.get(layoutRoute)?.push(slot.name);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
model.pageRoutes.sort(compareStrings);
|
|
81
|
+
model.layoutRoutes.sort(compareStrings);
|
|
82
|
+
model.routeHandlerRoutes.sort(compareStrings);
|
|
83
|
+
for (const slotNames of model.layoutSlots.values()) slotNames.sort(compareStrings);
|
|
84
|
+
return model;
|
|
85
|
+
}
|
|
86
|
+
async function findAppDir(root) {
|
|
87
|
+
for (const rel of ["app", path.join("src", "app")]) {
|
|
88
|
+
const candidate = path.join(root, rel);
|
|
89
|
+
try {
|
|
90
|
+
if ((await fs.stat(candidate)).isDirectory()) return candidate;
|
|
91
|
+
} catch {}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function renderRouteTypes(model) {
|
|
96
|
+
const allRoutes = uniqueSorted([
|
|
97
|
+
...model.pageRoutes,
|
|
98
|
+
...model.layoutRoutes,
|
|
99
|
+
...model.routeHandlerRoutes
|
|
100
|
+
]);
|
|
101
|
+
return `// This file is generated by vinext. Do not edit.
|
|
102
|
+
import type * as React from "react";
|
|
103
|
+
|
|
104
|
+
declare global {
|
|
105
|
+
type PageProps<Route extends VinextRouteTypes.PageRoute = VinextRouteTypes.PageRoute> = {
|
|
106
|
+
params: Promise<VinextRouteTypes.ParamMap[Route]>;
|
|
107
|
+
searchParams: Promise<Record<string, string | string[] | undefined>>;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
type LayoutProps<Route extends VinextRouteTypes.LayoutRoute> = {
|
|
111
|
+
params: Promise<VinextRouteTypes.ParamMap[Route]>;
|
|
112
|
+
children: React.ReactNode;
|
|
113
|
+
} & {
|
|
114
|
+
[K in VinextRouteTypes.LayoutSlotMap[Route]]: React.ReactNode;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
type RouteContext<Route extends VinextRouteTypes.RouteHandlerRoute = VinextRouteTypes.RouteHandlerRoute> = {
|
|
118
|
+
params: Promise<VinextRouteTypes.ParamMap[Route]>;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare namespace VinextRouteTypes {
|
|
123
|
+
type PageRoute = ${routeUnion(model.pageRoutes)};
|
|
124
|
+
type LayoutRoute = ${routeUnion(model.layoutRoutes)};
|
|
125
|
+
type RouteHandlerRoute = ${routeUnion(model.routeHandlerRoutes)};
|
|
126
|
+
type AppRoute = ${routeUnion(allRoutes)};
|
|
127
|
+
|
|
128
|
+
interface ParamMap {
|
|
129
|
+
${renderParamMap(allRoutes, model.params)}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface LayoutSlotMap {
|
|
133
|
+
${renderLayoutSlotMap(model.layoutRoutes, model.layoutSlots)}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export {};
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
function renderParamMap(routes, params) {
|
|
141
|
+
if (routes.length === 0) return " [route: string]: {};\n";
|
|
142
|
+
return routes.map((route) => ` ${quote(route)}: ${renderParamShape(params.get(route) ?? /* @__PURE__ */ new Map())};`).join("\n");
|
|
143
|
+
}
|
|
144
|
+
function renderParamShape(params) {
|
|
145
|
+
if (params.size === 0) return "{}";
|
|
146
|
+
return `{ ${Array.from(params.entries()).sort(([left], [right]) => compareStrings(left, right)).map(([name, kind]) => {
|
|
147
|
+
const optional = kind === "string[]?";
|
|
148
|
+
const valueType = optional ? "string[]" : kind;
|
|
149
|
+
return `${propertyName(name)}${optional ? "?" : ""}: ${valueType};`;
|
|
150
|
+
}).join(" ")} }`;
|
|
151
|
+
}
|
|
152
|
+
function renderLayoutSlotMap(layoutRoutes, layoutSlots) {
|
|
153
|
+
if (layoutRoutes.length === 0) return " [route: string]: never;\n";
|
|
154
|
+
return layoutRoutes.map((route) => {
|
|
155
|
+
const slots = layoutSlots.get(route) ?? [];
|
|
156
|
+
return ` ${quote(route)}: ${routeUnion(slots)};`;
|
|
157
|
+
}).join("\n");
|
|
158
|
+
}
|
|
159
|
+
function paramsForPatternParts(patternParts) {
|
|
160
|
+
const params = /* @__PURE__ */ new Map();
|
|
161
|
+
for (const part of patternParts) {
|
|
162
|
+
if (!part.startsWith(":")) continue;
|
|
163
|
+
if (part.endsWith("+")) params.set(part.slice(1, -1), "string[]");
|
|
164
|
+
else if (part.endsWith("*")) params.set(part.slice(1, -1), "string[]?");
|
|
165
|
+
else params.set(part.slice(1), "string");
|
|
166
|
+
}
|
|
167
|
+
return params;
|
|
168
|
+
}
|
|
169
|
+
function createLayoutRouteKeyMap(layouts) {
|
|
170
|
+
const treePathsByRoute = /* @__PURE__ */ new Map();
|
|
171
|
+
for (const { treePath } of layouts) {
|
|
172
|
+
const route = treePathToRouteLiteral(treePath);
|
|
173
|
+
const treePaths = treePathsByRoute.get(route) ?? [];
|
|
174
|
+
treePaths.push(treePath);
|
|
175
|
+
treePathsByRoute.set(route, treePaths);
|
|
176
|
+
}
|
|
177
|
+
const keys = /* @__PURE__ */ new Map();
|
|
178
|
+
for (const [route, treePaths] of treePathsByRoute) for (const treePath of treePaths) keys.set(treePath, treePaths.length === 1 ? route : treePathToScopedLayoutRouteLiteral(treePath));
|
|
179
|
+
return keys;
|
|
180
|
+
}
|
|
181
|
+
function layoutRouteKeyForSlot(slot, layouts, layoutRouteKeys) {
|
|
182
|
+
if (!slot.ownerLayoutId) return null;
|
|
183
|
+
const layout = layouts.get(slot.ownerLayoutId);
|
|
184
|
+
if (!layout) throw new Error(`[vinext] App route graph invariant violated: slot ${slot.id} references missing owner layout ${slot.ownerLayoutId}`);
|
|
185
|
+
return layoutRouteKeys.get(layout.treePath) ?? treePathToRouteLiteral(layout.treePath);
|
|
186
|
+
}
|
|
187
|
+
/** Convert a layout tree path to its URL route literal, stripping invisible segments. */
|
|
188
|
+
function treePathToRouteLiteral(treePath) {
|
|
189
|
+
if (treePath === "/") return "/";
|
|
190
|
+
const segments = treePath.split("/").filter(Boolean).filter((segment) => !isInvisibleSegment(segment)).map((segment) => decodeRouteSegment(segment));
|
|
191
|
+
return segments.length === 0 ? "/" : `/${segments.join("/")}`;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Convert a layout tree path to a scoped route literal that preserves
|
|
195
|
+
* route-group and `@slot` segments. Used only as a fallback key when multiple
|
|
196
|
+
* layouts collapse to the same URL route literal, so consumers can keep their
|
|
197
|
+
* slot/params typings distinct.
|
|
198
|
+
*/
|
|
199
|
+
function treePathToScopedLayoutRouteLiteral(treePath) {
|
|
200
|
+
if (treePath === "/") return "/";
|
|
201
|
+
const segments = treePath.split("/").filter(Boolean).filter((segment) => segment !== ".").map((segment) => decodeRouteSegment(segment));
|
|
202
|
+
return segments.length === 0 ? "/" : `/${segments.join("/")}`;
|
|
203
|
+
}
|
|
204
|
+
function addRoute(routes, seen, params, route, paramShape) {
|
|
205
|
+
if (!seen.has(route)) {
|
|
206
|
+
seen.add(route);
|
|
207
|
+
routes.push(route);
|
|
208
|
+
}
|
|
209
|
+
const existingParamShape = params.get(route);
|
|
210
|
+
if (existingParamShape) {
|
|
211
|
+
if (!paramShapesEqual(existingParamShape, paramShape)) throw new Error(`[vinext] Conflicting route param shapes generated for ${route}`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
params.set(route, paramShape);
|
|
215
|
+
}
|
|
216
|
+
function paramShapesEqual(left, right) {
|
|
217
|
+
if (left.size !== right.size) return false;
|
|
218
|
+
for (const [name, kind] of left) if (right.get(name) !== kind) return false;
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
function uniqueSorted(values) {
|
|
222
|
+
return Array.from(new Set(values)).sort(compareStrings);
|
|
223
|
+
}
|
|
224
|
+
function routeUnion(routes) {
|
|
225
|
+
if (routes.length === 0) return "never";
|
|
226
|
+
return routes.map(quote).join(" | ");
|
|
227
|
+
}
|
|
228
|
+
function propertyName(name) {
|
|
229
|
+
return /^[A-Za-z_$][\w$]*$/.test(name) ? name : quote(name);
|
|
230
|
+
}
|
|
231
|
+
function quote(value) {
|
|
232
|
+
return JSON.stringify(value);
|
|
233
|
+
}
|
|
234
|
+
function compareStrings(left, right) {
|
|
235
|
+
if (left < right) return -1;
|
|
236
|
+
if (left > right) return 1;
|
|
237
|
+
return 0;
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
export { generateRouteTypes };
|
|
241
|
+
|
|
242
|
+
//# sourceMappingURL=typegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typegen.js","names":[],"sources":["../src/typegen.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { isInvisibleSegment } from \"./routing/app-route-graph.js\";\nimport { appRouteGraph } from \"./routing/app-router.js\";\nimport { patternToNextFormat } from \"./routing/route-validation.js\";\nimport { decodeRouteSegment } from \"./routing/utils.js\";\n\ntype GenerateRouteTypesOptions = {\n root: string;\n appDir?: string | null;\n pageExtensions?: readonly string[];\n};\n\ntype ParamShape = Map<string, \"string\" | \"string[]\" | \"string[]?\">;\n\nconst NEXT_ENV_FILE_CONTENT = `/// <reference types=\"next\" />\n/// <reference types=\"next/image-types/global\" />\nimport \"./.next/types/routes.d.ts\";\n\n// NOTE: This file should not be edited\n// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.\n`;\n\nexport async function generateRouteTypes(options: GenerateRouteTypesOptions): Promise<string> {\n const root = path.resolve(options.root);\n const appDir = options.appDir ? path.resolve(options.appDir) : await findAppDir(root);\n const outPath = path.join(root, \".next\", \"types\", \"routes.d.ts\");\n\n const content = appDir\n ? renderRouteTypes(await collectRouteTypeModel(appDir, options.pageExtensions))\n : renderRouteTypes(emptyRouteTypeModel());\n\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, content, \"utf-8\");\n await ensureNextEnvFile(root);\n return outPath;\n}\n\nasync function ensureNextEnvFile(root: string): Promise<void> {\n const envPath = path.join(root, \"next-env.d.ts\");\n try {\n await fs.writeFile(envPath, NEXT_ENV_FILE_CONTENT, { encoding: \"utf-8\", flag: \"wx\" });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n }\n}\n\ntype RouteTypeModel = {\n pageRoutes: string[];\n layoutRoutes: string[];\n routeHandlerRoutes: string[];\n params: Map<string, ParamShape>;\n layoutSlots: Map<string, string[]>;\n};\n\nfunction emptyRouteTypeModel(): RouteTypeModel {\n return {\n pageRoutes: [],\n layoutRoutes: [],\n routeHandlerRoutes: [],\n params: new Map(),\n layoutSlots: new Map(),\n };\n}\n\nasync function collectRouteTypeModel(\n appDir: string,\n pageExtensions?: readonly string[],\n): Promise<RouteTypeModel> {\n const graph = await appRouteGraph(appDir, pageExtensions);\n const model = emptyRouteTypeModel();\n const segmentGraph = graph.routeManifest.segmentGraph;\n const layoutRouteKeys = createLayoutRouteKeyMap(segmentGraph.layouts.values());\n const pageRouteSet = new Set<string>();\n const layoutRouteSet = new Set<string>();\n const routeHandlerRouteSet = new Set<string>();\n\n for (const route of segmentGraph.pages.values()) {\n const routeEntry = segmentGraph.routes.get(route.routeId);\n addRoute(\n model.pageRoutes,\n pageRouteSet,\n model.params,\n patternToNextFormat(route.pattern),\n paramsForPatternParts(routeEntry?.patternParts ?? []),\n );\n }\n\n for (const route of segmentGraph.routeHandlers.values()) {\n const routeEntry = segmentGraph.routes.get(route.routeId);\n addRoute(\n model.routeHandlerRoutes,\n routeHandlerRouteSet,\n model.params,\n patternToNextFormat(route.pattern),\n paramsForPatternParts(routeEntry?.patternParts ?? []),\n );\n }\n\n for (const layout of segmentGraph.layouts.values()) {\n const route = layoutRouteKeys.get(layout.treePath) ?? treePathToRouteLiteral(layout.treePath);\n addRoute(\n model.layoutRoutes,\n layoutRouteSet,\n model.params,\n route,\n paramsForPatternParts(layout.patternParts),\n );\n }\n\n const layoutSlotSets = new Map<string, Set<string>>();\n for (const slot of segmentGraph.slots.values()) {\n const layoutRoute = layoutRouteKeyForSlot(slot, segmentGraph.layouts, layoutRouteKeys);\n if (!layoutRoute) continue;\n\n let slotNames = layoutSlotSets.get(layoutRoute);\n if (!slotNames) {\n slotNames = new Set();\n layoutSlotSets.set(layoutRoute, slotNames);\n model.layoutSlots.set(layoutRoute, []);\n }\n if (!slotNames.has(slot.name)) {\n slotNames.add(slot.name);\n model.layoutSlots.get(layoutRoute)?.push(slot.name);\n }\n }\n\n // Sort all collected route lists once after collection. addRoute() and the\n // slot loop above intentionally skip per-insertion sorts to keep collection\n // O(n) — the rendered output relies on stable sorted order, so the single\n // pass here is enough.\n model.pageRoutes.sort(compareStrings);\n model.layoutRoutes.sort(compareStrings);\n model.routeHandlerRoutes.sort(compareStrings);\n for (const slotNames of model.layoutSlots.values()) slotNames.sort(compareStrings);\n\n return model;\n}\n\nasync function findAppDir(root: string): Promise<string | null> {\n for (const rel of [\"app\", path.join(\"src\", \"app\")]) {\n const candidate = path.join(root, rel);\n try {\n const stat = await fs.stat(candidate);\n if (stat.isDirectory()) return candidate;\n } catch {\n // Try the next conventional app directory.\n }\n }\n return null;\n}\n\nfunction renderRouteTypes(model: RouteTypeModel): string {\n const allRoutes = uniqueSorted([\n ...model.pageRoutes,\n ...model.layoutRoutes,\n ...model.routeHandlerRoutes,\n ]);\n\n return `// This file is generated by vinext. Do not edit.\nimport type * as React from \"react\";\n\ndeclare global {\n type PageProps<Route extends VinextRouteTypes.PageRoute = VinextRouteTypes.PageRoute> = {\n params: Promise<VinextRouteTypes.ParamMap[Route]>;\n searchParams: Promise<Record<string, string | string[] | undefined>>;\n };\n\n type LayoutProps<Route extends VinextRouteTypes.LayoutRoute> = {\n params: Promise<VinextRouteTypes.ParamMap[Route]>;\n children: React.ReactNode;\n } & {\n [K in VinextRouteTypes.LayoutSlotMap[Route]]: React.ReactNode;\n };\n\n type RouteContext<Route extends VinextRouteTypes.RouteHandlerRoute = VinextRouteTypes.RouteHandlerRoute> = {\n params: Promise<VinextRouteTypes.ParamMap[Route]>;\n };\n}\n\ndeclare namespace VinextRouteTypes {\n type PageRoute = ${routeUnion(model.pageRoutes)};\n type LayoutRoute = ${routeUnion(model.layoutRoutes)};\n type RouteHandlerRoute = ${routeUnion(model.routeHandlerRoutes)};\n type AppRoute = ${routeUnion(allRoutes)};\n\n interface ParamMap {\n${renderParamMap(allRoutes, model.params)}\n }\n\n interface LayoutSlotMap {\n${renderLayoutSlotMap(model.layoutRoutes, model.layoutSlots)}\n }\n}\n\nexport {};\n`;\n}\n\nfunction renderParamMap(\n routes: readonly string[],\n params: ReadonlyMap<string, ParamShape>,\n): string {\n if (routes.length === 0) return \" [route: string]: {};\\n\";\n\n return routes\n .map((route) => ` ${quote(route)}: ${renderParamShape(params.get(route) ?? new Map())};`)\n .join(\"\\n\");\n}\n\nfunction renderParamShape(params: ParamShape): string {\n if (params.size === 0) return \"{}\";\n\n const fields = Array.from(params.entries())\n .sort(([left], [right]) => compareStrings(left, right))\n .map(([name, kind]) => {\n const optional = kind === \"string[]?\";\n const valueType = optional ? \"string[]\" : kind;\n return `${propertyName(name)}${optional ? \"?\" : \"\"}: ${valueType};`;\n });\n\n return `{ ${fields.join(\" \")} }`;\n}\n\nfunction renderLayoutSlotMap(\n layoutRoutes: readonly string[],\n layoutSlots: ReadonlyMap<string, readonly string[]>,\n): string {\n if (layoutRoutes.length === 0) return \" [route: string]: never;\\n\";\n\n return layoutRoutes\n .map((route) => {\n const slots = layoutSlots.get(route) ?? [];\n return ` ${quote(route)}: ${routeUnion(slots)};`;\n })\n .join(\"\\n\");\n}\n\nfunction paramsForPatternParts(patternParts: readonly string[]): ParamShape {\n const params: ParamShape = new Map();\n for (const part of patternParts) {\n if (!part.startsWith(\":\")) continue;\n\n if (part.endsWith(\"+\")) {\n params.set(part.slice(1, -1), \"string[]\");\n } else if (part.endsWith(\"*\")) {\n params.set(part.slice(1, -1), \"string[]?\");\n } else {\n params.set(part.slice(1), \"string\");\n }\n }\n return params;\n}\n\nfunction createLayoutRouteKeyMap(layouts: Iterable<{ treePath: string }>): Map<string, string> {\n const treePathsByRoute = new Map<string, string[]>();\n for (const { treePath } of layouts) {\n const route = treePathToRouteLiteral(treePath);\n const treePaths = treePathsByRoute.get(route) ?? [];\n treePaths.push(treePath);\n treePathsByRoute.set(route, treePaths);\n }\n\n const keys = new Map<string, string>();\n for (const [route, treePaths] of treePathsByRoute) {\n for (const treePath of treePaths) {\n keys.set(\n treePath,\n treePaths.length === 1 ? route : treePathToScopedLayoutRouteLiteral(treePath),\n );\n }\n }\n return keys;\n}\n\nfunction layoutRouteKeyForSlot(\n slot: { id: string; ownerLayoutId: string | null },\n layouts: ReadonlyMap<string, { treePath: string }>,\n layoutRouteKeys: ReadonlyMap<string, string>,\n): string | null {\n if (!slot.ownerLayoutId) return null;\n\n const layout = layouts.get(slot.ownerLayoutId);\n if (!layout) {\n throw new Error(\n `[vinext] App route graph invariant violated: slot ${slot.id} references missing owner layout ${slot.ownerLayoutId}`,\n );\n }\n\n return layoutRouteKeys.get(layout.treePath) ?? treePathToRouteLiteral(layout.treePath);\n}\n\n/** Convert a layout tree path to its URL route literal, stripping invisible segments. */\nfunction treePathToRouteLiteral(treePath: string): string {\n if (treePath === \"/\") return \"/\";\n\n const segments = treePath\n .split(\"/\")\n .filter(Boolean)\n .filter((segment) => !isInvisibleSegment(segment))\n .map((segment) => decodeRouteSegment(segment));\n return segments.length === 0 ? \"/\" : `/${segments.join(\"/\")}`;\n}\n\n/**\n * Convert a layout tree path to a scoped route literal that preserves\n * route-group and `@slot` segments. Used only as a fallback key when multiple\n * layouts collapse to the same URL route literal, so consumers can keep their\n * slot/params typings distinct.\n */\nfunction treePathToScopedLayoutRouteLiteral(treePath: string): string {\n if (treePath === \"/\") return \"/\";\n\n const segments = treePath\n .split(\"/\")\n .filter(Boolean)\n .filter((segment) => segment !== \".\")\n .map((segment) => decodeRouteSegment(segment));\n return segments.length === 0 ? \"/\" : `/${segments.join(\"/\")}`;\n}\n\nfunction addRoute(\n routes: string[],\n seen: Set<string>,\n params: Map<string, ParamShape>,\n route: string,\n paramShape: ParamShape,\n): void {\n if (!seen.has(route)) {\n seen.add(route);\n routes.push(route);\n }\n const existingParamShape = params.get(route);\n if (existingParamShape) {\n if (!paramShapesEqual(existingParamShape, paramShape)) {\n throw new Error(`[vinext] Conflicting route param shapes generated for ${route}`);\n }\n return;\n }\n params.set(route, paramShape);\n}\n\nfunction paramShapesEqual(left: ParamShape, right: ParamShape): boolean {\n if (left.size !== right.size) return false;\n for (const [name, kind] of left) {\n if (right.get(name) !== kind) return false;\n }\n return true;\n}\n\nfunction uniqueSorted(values: readonly string[]): string[] {\n return Array.from(new Set(values)).sort(compareStrings);\n}\n\nfunction routeUnion(routes: readonly string[]): string {\n if (routes.length === 0) return \"never\";\n return routes.map(quote).join(\" | \");\n}\n\nfunction propertyName(name: string): string {\n return /^[A-Za-z_$][\\w$]*$/.test(name) ? name : quote(name);\n}\n\nfunction quote(value: string): string {\n return JSON.stringify(value);\n}\n\nfunction compareStrings(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n"],"mappings":";;;;;;;AAeA,MAAM,wBAAwB;;;;;;;AAQ9B,eAAsB,mBAAmB,SAAqD;CAC5F,MAAM,OAAO,KAAK,QAAQ,QAAQ,KAAK;CACvC,MAAM,SAAS,QAAQ,SAAS,KAAK,QAAQ,QAAQ,OAAO,GAAG,MAAM,WAAW,KAAK;CACrF,MAAM,UAAU,KAAK,KAAK,MAAM,SAAS,SAAS,cAAc;CAEhE,MAAM,UAAU,SACZ,iBAAiB,MAAM,sBAAsB,QAAQ,QAAQ,eAAe,CAAC,GAC7E,iBAAiB,qBAAqB,CAAC;CAE3C,MAAM,GAAG,MAAM,KAAK,QAAQ,QAAQ,EAAE,EAAE,WAAW,MAAM,CAAC;CAC1D,MAAM,GAAG,UAAU,SAAS,SAAS,QAAQ;CAC7C,MAAM,kBAAkB,KAAK;CAC7B,OAAO;;AAGT,eAAe,kBAAkB,MAA6B;CAC5D,MAAM,UAAU,KAAK,KAAK,MAAM,gBAAgB;CAChD,IAAI;EACF,MAAM,GAAG,UAAU,SAAS,u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