vinext 1.0.0-beta.1 → 1.0.0-beta.3
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 +10 -10
- package/dist/build/client-build-config.js +8 -1
- package/dist/build/report.d.ts +8 -1
- package/dist/build/report.js +12 -2
- package/dist/check.js +19 -2
- package/dist/cli.js +3 -2
- package/dist/config/config-matchers.d.ts +13 -37
- package/dist/config/config-matchers.js +35 -122
- package/dist/config/next-config.d.ts +15 -5
- package/dist/config/next-config.js +7 -1
- package/dist/config/request-context.d.ts +14 -0
- package/dist/config/request-context.js +26 -0
- package/dist/entries/app-browser-entry.d.ts +4 -10
- package/dist/entries/app-browser-entry.js +20 -4
- package/dist/entries/app-rsc-entry.js +30 -9
- package/dist/entries/app-rsc-manifest.js +36 -0
- package/dist/entries/pages-client-entry.js +0 -1
- package/dist/entries/pages-server-entry.js +13 -5
- package/dist/index.js +194 -101
- package/dist/init-cloudflare.d.ts +3 -1
- package/dist/init-cloudflare.js +59 -5
- package/dist/init.d.ts +6 -4
- package/dist/init.js +20 -22
- package/dist/plugins/extensionless-dynamic-import.js +23 -18
- package/dist/plugins/ignore-dynamic-requests.js +3 -1
- package/dist/plugins/import-meta-url.js +17 -6
- package/dist/plugins/og-assets.js +1 -1
- package/dist/plugins/require-context.js +20 -15
- package/dist/plugins/transform-cache.d.ts +19 -0
- package/dist/plugins/transform-cache.js +36 -0
- package/dist/routing/app-route-graph.d.ts +27 -11
- package/dist/routing/app-route-graph.js +158 -22
- package/dist/routing/app-router.js +12 -6
- package/dist/routing/file-matcher.d.ts +11 -22
- package/dist/routing/file-matcher.js +21 -33
- package/dist/routing/pages-router.js +23 -29
- package/dist/routing/route-matching.d.ts +14 -1
- package/dist/routing/route-matching.js +13 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/routing/route-pattern.js +7 -4
- package/dist/routing/route-trie.d.ts +5 -1
- package/dist/routing/route-trie.js +5 -2
- package/dist/server/api-handler.d.ts +2 -0
- package/dist/server/api-handler.js +3 -3
- package/dist/server/app-browser-entry.js +110 -37
- package/dist/server/app-browser-history-controller.d.ts +1 -1
- package/dist/server/app-browser-history-controller.js +3 -3
- package/dist/server/app-browser-navigation-controller.d.ts +23 -21
- package/dist/server/app-browser-navigation-controller.js +2 -2
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-visible-commit.js +1 -1
- package/dist/server/app-fallback-renderer.d.ts +3 -0
- package/dist/server/app-fallback-renderer.js +4 -2
- package/dist/server/app-middleware.js +2 -1
- package/dist/server/app-page-boundary-render.d.ts +12 -1
- package/dist/server/app-page-boundary-render.js +84 -2
- package/dist/server/app-page-cache-finalizer.d.ts +1 -1
- package/dist/server/app-page-cache-finalizer.js +1 -1
- package/dist/server/app-page-cache.d.ts +2 -2
- package/dist/server/app-page-cache.js +16 -2
- package/dist/server/app-page-dispatch.d.ts +19 -2
- package/dist/server/app-page-dispatch.js +45 -23
- package/dist/server/app-page-element-builder.d.ts +9 -2
- package/dist/server/app-page-element-builder.js +144 -33
- package/dist/server/app-page-head.d.ts +56 -4
- package/dist/server/app-page-head.js +216 -85
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +29 -0
- package/dist/server/app-page-http-access-fallback-metadata.js +114 -0
- package/dist/server/app-page-probe.d.ts +4 -0
- package/dist/server/app-page-probe.js +6 -2
- package/dist/server/app-page-render.d.ts +2 -2
- package/dist/server/app-page-render.js +1 -1
- package/dist/server/app-page-request.d.ts +15 -0
- package/dist/server/app-page-request.js +134 -14
- package/dist/server/app-page-response.js +1 -1
- package/dist/server/app-page-route-wiring.d.ts +16 -0
- package/dist/server/app-page-route-wiring.js +254 -52
- package/dist/server/app-pages-bridge.d.ts +1 -1
- package/dist/server/app-pages-bridge.js +2 -1
- package/dist/server/app-post-middleware-context.d.ts +1 -1
- package/dist/server/app-post-middleware-context.js +1 -1
- package/dist/server/app-route-handler-cache.js +4 -0
- package/dist/server/app-route-handler-dispatch.js +40 -20
- package/dist/server/app-route-handler-execution.d.ts +6 -1
- package/dist/server/app-route-handler-execution.js +42 -16
- package/dist/server/app-route-handler-policy.d.ts +2 -0
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-handler-response.js +1 -1
- package/dist/server/app-route-module-loader.d.ts +9 -1
- package/dist/server/app-route-module-loader.js +4 -0
- package/dist/server/app-router-entry.js +6 -3
- package/dist/server/app-rsc-cache-busting.d.ts +1 -1
- package/dist/server/app-rsc-errors.d.ts +1 -1
- package/dist/server/app-rsc-errors.js +22 -2
- package/dist/server/app-rsc-handler.d.ts +10 -5
- package/dist/server/app-rsc-handler.js +73 -33
- package/dist/server/app-rsc-request-normalization.d.ts +3 -2
- package/dist/server/app-rsc-request-normalization.js +8 -2
- package/dist/server/app-rsc-response-finalizer.d.ts +2 -2
- package/dist/server/app-rsc-response-finalizer.js +5 -11
- package/dist/server/app-rsc-route-matching.d.ts +29 -0
- package/dist/server/app-rsc-route-matching.js +93 -11
- package/dist/server/app-segment-config.js +13 -3
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +9 -7
- package/dist/server/app-ssr-entry.js +6 -6
- package/dist/server/app-ssr-stream.d.ts +1 -7
- package/dist/server/app-ssr-stream.js +2 -10
- package/dist/server/cache-control.d.ts +2 -2
- package/dist/server/cache-control.js +2 -1
- package/dist/server/config-headers.d.ts +24 -0
- package/dist/server/config-headers.js +52 -0
- package/dist/server/dev-initial-server-error.d.ts +1 -1
- package/dist/server/dev-server.d.ts +3 -1
- package/dist/server/dev-server.js +170 -321
- package/dist/server/headers.d.ts +2 -2
- package/dist/server/headers.js +4 -3
- package/dist/server/isr-cache.d.ts +11 -34
- package/dist/server/isr-cache.js +33 -43
- package/dist/server/isr-decision.d.ts +2 -2
- package/dist/server/middleware-matcher-pattern.d.ts +22 -0
- package/dist/server/middleware-matcher-pattern.js +219 -0
- package/dist/server/middleware-matcher.d.ts +2 -7
- package/dist/server/middleware-matcher.js +13 -60
- package/dist/server/middleware-path-to-regexp.d.ts +14 -0
- package/dist/server/middleware-path-to-regexp.js +228 -0
- package/dist/server/middleware-runtime.js +4 -3
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +2 -1
- package/dist/server/pages-api-route.d.ts +2 -0
- package/dist/server/pages-api-route.js +4 -1
- package/dist/server/pages-data-route.d.ts +11 -1
- package/dist/server/pages-data-route.js +16 -1
- package/dist/server/pages-dev-hydration.js +0 -1
- package/dist/server/pages-get-initial-props.d.ts +16 -3
- package/dist/server/pages-get-initial-props.js +17 -10
- package/dist/server/pages-i18n.js +64 -16
- package/dist/server/pages-node-compat.d.ts +2 -0
- package/dist/server/pages-node-compat.js +7 -3
- package/dist/server/pages-page-data.d.ts +64 -10
- package/dist/server/pages-page-data.js +349 -80
- package/dist/server/pages-page-handler.d.ts +9 -3
- package/dist/server/pages-page-handler.js +131 -36
- package/dist/server/pages-page-response.d.ts +5 -3
- package/dist/server/pages-page-response.js +24 -27
- package/dist/server/pages-readiness.d.ts +3 -3
- package/dist/server/pages-request-pipeline.d.ts +8 -0
- package/dist/server/pages-request-pipeline.js +30 -12
- package/dist/server/pages-revalidate.d.ts +1 -1
- package/dist/server/pages-revalidate.js +54 -8
- package/dist/server/pages-router-entry.d.ts +1 -0
- package/dist/server/pages-router-entry.js +16 -4
- package/dist/server/prerender-route-params.js +2 -2
- package/dist/server/prod-server.d.ts +3 -5
- package/dist/server/prod-server.js +72 -35
- package/dist/server/request-pipeline.d.ts +15 -29
- package/dist/server/request-pipeline.js +24 -59
- package/dist/server/revalidation-host.d.ts +11 -0
- package/dist/server/revalidation-host.js +19 -0
- package/dist/server/rsc-stream-hints.js +122 -18
- package/dist/server/worker-revalidation-context.d.ts +13 -0
- package/dist/server/worker-revalidation-context.js +29 -0
- package/dist/shims/app.d.ts +1 -1
- package/dist/shims/cache-handler.d.ts +1 -1
- package/dist/shims/cache-handler.js +10 -7
- package/dist/shims/cache-request-state.d.ts +27 -1
- package/dist/shims/cache-request-state.js +60 -1
- package/dist/shims/cache-runtime.d.ts +18 -1
- package/dist/shims/cache-runtime.js +26 -8
- package/dist/shims/cache.d.ts +5 -5
- package/dist/shims/cache.js +27 -11
- package/dist/shims/document.d.ts +42 -83
- package/dist/shims/document.js +62 -53
- package/dist/shims/dynamic.d.ts +5 -25
- package/dist/shims/dynamic.js +29 -8
- package/dist/shims/error.d.ts +1 -1
- package/dist/shims/error.js +2 -2
- package/dist/shims/fetch-cache.js +13 -4
- package/dist/shims/font-google-base.d.ts +11 -4
- package/dist/shims/font-google-base.js +17 -8
- package/dist/shims/font-local.d.ts +10 -3
- package/dist/shims/font-local.js +41 -10
- package/dist/shims/head.d.ts +13 -2
- package/dist/shims/head.js +3 -3
- package/dist/shims/headers.d.ts +37 -43
- package/dist/shims/headers.js +183 -74
- package/dist/shims/image.d.ts +27 -37
- package/dist/shims/image.js +21 -14
- package/dist/shims/internal/cookie-serialize.d.ts +12 -9
- package/dist/shims/internal/cookie-serialize.js +10 -7
- package/dist/shims/internal/hybrid-client-route-owner.js +3 -1
- package/dist/shims/internal/interpolate-as.d.ts +15 -1
- package/dist/shims/internal/interpolate-as.js +27 -2
- package/dist/shims/internal/utils.d.ts +3 -3
- package/dist/shims/legacy-image.d.ts +3 -37
- package/dist/shims/legacy-image.js +6 -16
- package/dist/shims/link.d.ts +15 -22
- package/dist/shims/link.js +34 -13
- package/dist/shims/metadata.d.ts +7 -17
- package/dist/shims/metadata.js +74 -24
- package/dist/shims/navigation-context-state.d.ts +1 -1
- package/dist/shims/navigation.d.ts +7 -3
- package/dist/shims/navigation.js +25 -14
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/next-shims-augmentations.d.ts +1 -0
- package/dist/shims/next-shims-public.d.ts +1 -0
- package/dist/shims/public-shim-map.json.js +103 -0
- package/dist/shims/readonly-url-search-params.d.ts +3 -3
- package/dist/shims/readonly-url-search-params.js +3 -3
- package/dist/shims/request-context.d.ts +4 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router.d.ts +55 -21
- package/dist/shims/router.js +180 -44
- package/dist/shims/script.d.ts +6 -10
- package/dist/shims/script.js +7 -4
- package/dist/shims/server.d.ts +50 -26
- package/dist/shims/server.js +193 -55
- package/dist/shims/unified-request-context.d.ts +22 -3
- package/dist/shims/unified-request-context.js +84 -1
- package/dist/shims/url-safety.d.ts +1 -1
- package/dist/shims/url-safety.js +2 -2
- package/dist/typegen.d.ts +8 -2
- package/dist/typegen.js +76 -15
- package/dist/utils/cache-control-metadata.d.ts +2 -1
- package/dist/utils/cache-control-metadata.js +5 -1
- package/dist/utils/domain-locale.d.ts +2 -2
- package/dist/utils/external-url.d.ts +5 -0
- package/dist/utils/external-url.js +7 -0
- package/dist/utils/html-limited-bots.js +1 -1
- package/dist/utils/protocol-headers.d.ts +7 -1
- package/dist/utils/protocol-headers.js +7 -1
- package/dist/utils/regex-safety.d.ts +8 -0
- package/dist/utils/regex-safety.js +737 -0
- package/package.json +13 -2
|
@@ -6,8 +6,12 @@ import { GLOBAL_ACCESSORS_KEY, NavigationContext, NavigationStateAccessors, Segm
|
|
|
6
6
|
import { BailoutToCSRError, DynamicServerError, HTTP_ERROR_FALLBACK_ERROR_CODE, RedirectType, decodeRedirectError, forbidden, getAccessFallbackHTTPStatus, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, notFound, permanentRedirect, redirect, unauthorized, unstable_rethrow } from "./navigation-errors.js";
|
|
7
7
|
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
8
8
|
import * as React$1 from "react";
|
|
9
|
+
import { Params } from "@vinext/types/next/upstream/dist/server/request/params";
|
|
9
10
|
|
|
10
11
|
//#region src/shims/navigation.d.ts
|
|
12
|
+
/** Load rewrite-aware hybrid route ownership before navigation becomes interactive. */
|
|
13
|
+
declare function preloadHybridClientRouteOwner(): Promise<void>;
|
|
14
|
+
declare function resolveLoadedHybridClientRewriteHref(href: string, basePath: string): string | null;
|
|
11
15
|
/** basePath from next.config.js, injected by the plugin at build time */
|
|
12
16
|
declare const __basePath: string;
|
|
13
17
|
/** Maximum buffered bytes in the RSC prefetch cache. Mirrors Next.js' 50 MB LRU. */
|
|
@@ -203,7 +207,7 @@ declare function clearPendingPathname(navId: number): void;
|
|
|
203
207
|
* Returns the current pathname.
|
|
204
208
|
* Server: from request context. Client: from window.location.
|
|
205
209
|
*/
|
|
206
|
-
declare function usePathname(): string
|
|
210
|
+
declare function usePathname(): string;
|
|
207
211
|
/**
|
|
208
212
|
* Returns the current search params as a read-only URLSearchParams.
|
|
209
213
|
*/
|
|
@@ -211,7 +215,7 @@ declare function useSearchParams(): ReadonlyURLSearchParams;
|
|
|
211
215
|
/**
|
|
212
216
|
* Returns the dynamic params for the current route.
|
|
213
217
|
*/
|
|
214
|
-
declare function useParams<T extends
|
|
218
|
+
declare function useParams<T extends Params = Params>(): T | null;
|
|
215
219
|
/**
|
|
216
220
|
* Commit pending client navigation state to committed snapshots.
|
|
217
221
|
*
|
|
@@ -299,4 +303,4 @@ declare function useSelectedLayoutSegments(parallelRoutesKey?: string): string[]
|
|
|
299
303
|
*/
|
|
300
304
|
declare function useServerInsertedHTML(callback: () => unknown): void;
|
|
301
305
|
//#endregion
|
|
302
|
-
export { BailoutToCSRError, CachedRscResponse, ClientNavigationRenderSnapshot, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, type NavigationContext, type NavigationStateAccessors, PREFETCH_CACHE_TTL, PrefetchCacheEntry, PrefetchCacheKind, PrefetchOptions, ReadonlyURLSearchParams, RedirectType, type SegmentMap, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
306
|
+
export { BailoutToCSRError, CachedRscResponse, ClientNavigationRenderSnapshot, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, type NavigationContext, type NavigationStateAccessors, PREFETCH_CACHE_TTL, PrefetchCacheEntry, PrefetchCacheKind, PrefetchOptions, ReadonlyURLSearchParams, RedirectType, type SegmentMap, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, preloadHybridClientRouteOwner, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolveLoadedHybridClientRewriteHref, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
package/dist/shims/navigation.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { stripBasePath } from "../utils/base-path.js";
|
|
2
2
|
import { VINEXT_DYNAMIC_STALE_TIME_HEADER, VINEXT_MOUNTED_SLOTS_HEADER, VINEXT_PARAMS_HEADER, VINEXT_RENDERED_PATH_AND_SEARCH_HEADER } from "../server/headers.js";
|
|
3
3
|
import { assertSafeNavigationUrl } from "./url-safety.js";
|
|
4
|
+
import { isExternalUrl } from "../utils/external-url.js";
|
|
4
5
|
import { AppElementsWire } from "../server/app-elements-wire.js";
|
|
5
6
|
import "../server/app-elements.js";
|
|
6
7
|
import { markPprFallbackShellDynamicBoundary } from "./ppr-fallback-shell.js";
|
|
7
8
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
8
|
-
import {
|
|
9
|
+
import { resolveDirectHybridClientRouteOwner } from "./internal/hybrid-client-route-owner-direct.js";
|
|
10
|
+
import { toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
|
|
9
11
|
import { retryScrollTo, scrollToHashTarget } from "./hash-scroll.js";
|
|
12
|
+
import { isBotUserAgent } from "../utils/html-limited-bots.js";
|
|
10
13
|
import { GLOBAL_ACCESSORS_KEY, ServerInsertedHTMLContext, _registerStateAccessors, clearClientHydrationContext, clearServerInsertedHTML, flushServerInsertedHTML, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getLayoutSegmentContext, getNavigationContext, registerServerInsertedHTMLCallback, renderServerInsertedHTML, setNavigationContext } from "./navigation-context-state.js";
|
|
11
14
|
import { BailoutToCSRError, DynamicServerError, HTTP_ERROR_FALLBACK_ERROR_CODE, RedirectType, decodeRedirectError, forbidden, getAccessFallbackHTTPStatus, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, notFound, permanentRedirect, redirect, unauthorized, unstable_rethrow } from "./navigation-errors.js";
|
|
12
|
-
import { isBotUserAgent } from "../utils/html-limited-bots.js";
|
|
13
15
|
import { clearAppNavigationFailureTarget, stageAppNavigationFailureTarget } from "../client/app-nav-failure-handler.js";
|
|
14
16
|
import { beginAppRouterScrollIntent, clearAppRouterScrollIntent, consumeAppRouterScrollIntent, getPendingAppRouterScrollIntent } from "./app-router-scroll-state.js";
|
|
15
17
|
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createRscRequestHeaders, createRscRequestUrl, stripRscCacheBustingSearchParam, stripRscSuffix } from "../server/app-rsc-cache-busting.js";
|
|
@@ -22,7 +24,6 @@ import { hasPendingAppRouterPageRedirect } from "../server/app-browser-mpa-navig
|
|
|
22
24
|
import { navigationPlanner } from "../server/navigation-planner.js";
|
|
23
25
|
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
24
26
|
import { getPagesNavigationContext } from "./internal/pages-router-accessor.js";
|
|
25
|
-
import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
|
|
26
27
|
import { releaseAppPrefetchFetchSlot, scheduleAppPrefetchFetch } from "./internal/app-prefetch-fetch-queue.js";
|
|
27
28
|
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
28
29
|
import * as React$1 from "react";
|
|
@@ -34,6 +35,22 @@ import * as React$1 from "react";
|
|
|
34
35
|
* Server-side: reads from a request context set by the RSC handler.
|
|
35
36
|
* Client-side: reads from browser Location API and provides navigation.
|
|
36
37
|
*/
|
|
38
|
+
const HAS_PAGES_ROUTER = process.env.__VINEXT_HAS_PAGES_ROUTER !== "false";
|
|
39
|
+
let hybridClientRouteOwnerModule = null;
|
|
40
|
+
let hybridClientRouteOwnerModulePromise = null;
|
|
41
|
+
/** Load rewrite-aware hybrid route ownership before navigation becomes interactive. */
|
|
42
|
+
async function preloadHybridClientRouteOwner() {
|
|
43
|
+
if (hybridClientRouteOwnerModule) return;
|
|
44
|
+
hybridClientRouteOwnerModulePromise ??= import("./internal/hybrid-client-route-owner.js");
|
|
45
|
+
hybridClientRouteOwnerModule = await hybridClientRouteOwnerModulePromise;
|
|
46
|
+
}
|
|
47
|
+
function resolveLoadedHybridClientRewriteHref(href, basePath) {
|
|
48
|
+
return hybridClientRouteOwnerModule?.resolveHybridClientRewriteHref(href, basePath) ?? null;
|
|
49
|
+
}
|
|
50
|
+
function resolveHybridClientRouteOwner(href) {
|
|
51
|
+
if (!HAS_PAGES_ROUTER) return null;
|
|
52
|
+
return hybridClientRouteOwnerModule ? hybridClientRouteOwnerModule.resolveHybridClientRouteOwner(href, __basePath) : resolveDirectHybridClientRouteOwner(href, __basePath);
|
|
53
|
+
}
|
|
37
54
|
/**
|
|
38
55
|
* Read the child segments for a parallel route below the current layout.
|
|
39
56
|
* Returns [] if no context is available (RSC environment, outside React tree)
|
|
@@ -941,12 +958,6 @@ function useParams() {
|
|
|
941
958
|
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.params;
|
|
942
959
|
return params;
|
|
943
960
|
}
|
|
944
|
-
/**
|
|
945
|
-
* Check if a href is an external URL (any URL scheme per RFC 3986, or protocol-relative).
|
|
946
|
-
*/
|
|
947
|
-
function isExternalUrl(href) {
|
|
948
|
-
return isAbsoluteOrProtocolRelativeUrl(href);
|
|
949
|
-
}
|
|
950
961
|
function withSuppressedUrlNotifications(fn) {
|
|
951
962
|
const state = getClientNavigationState();
|
|
952
963
|
if (!state) return fn();
|
|
@@ -1094,7 +1105,7 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
|
|
|
1094
1105
|
}
|
|
1095
1106
|
normalizedHref = localPath;
|
|
1096
1107
|
}
|
|
1097
|
-
const hybridOwner = resolveHybridClientRouteOwner(normalizedHref
|
|
1108
|
+
const hybridOwner = resolveHybridClientRouteOwner(normalizedHref);
|
|
1098
1109
|
if (hybridOwner === "pages" || hybridOwner === "document") {
|
|
1099
1110
|
const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);
|
|
1100
1111
|
notifyAppRouterTransitionStart(fullHref, mode);
|
|
@@ -1238,12 +1249,12 @@ const _appRouter = {
|
|
|
1238
1249
|
}
|
|
1239
1250
|
(async () => {
|
|
1240
1251
|
let prefetchHref = href;
|
|
1241
|
-
if (
|
|
1252
|
+
if (isExternalUrl(href)) {
|
|
1242
1253
|
const localPath = toSameOriginAppPath(href, __basePath);
|
|
1243
1254
|
if (localPath == null) return;
|
|
1244
1255
|
prefetchHref = localPath;
|
|
1245
1256
|
}
|
|
1246
|
-
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref
|
|
1257
|
+
const hybridOwner = resolveHybridClientRouteOwner(prefetchHref);
|
|
1247
1258
|
if (hybridOwner === "pages" || hybridOwner === "document") return;
|
|
1248
1259
|
const fullHref = toBrowserNavigationHref(prefetchHref, window.location.href, __basePath);
|
|
1249
1260
|
const interceptionContext = getPrefetchInterceptionContext(fullHref);
|
|
@@ -1273,7 +1284,7 @@ if (process.env.__NEXT_GESTURE_TRANSITION) _appRouter.experimental_gesturePush =
|
|
|
1273
1284
|
if (isServer) return;
|
|
1274
1285
|
if (!getNavigationRuntime()?.functions.navigate) return;
|
|
1275
1286
|
let appHref = href;
|
|
1276
|
-
if (
|
|
1287
|
+
if (isExternalUrl(href)) {
|
|
1277
1288
|
const localPath = toSameOriginAppPath(href, __basePath);
|
|
1278
1289
|
if (localPath === null) return;
|
|
1279
1290
|
appHref = localPath;
|
|
@@ -1401,4 +1412,4 @@ if (!isServer) {
|
|
|
1401
1412
|
}
|
|
1402
1413
|
}
|
|
1403
1414
|
//#endregion
|
|
1404
|
-
export { BailoutToCSRError, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
1415
|
+
export { BailoutToCSRError, DYNAMIC_NAVIGATION_CACHE_TTL, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, deletePrefetchResponseSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, hasSearchAgnosticPrefetchShellForRoute, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, peekPrefetchResponseForNavigation, permanentRedirect, prefetchRscResponse, preloadHybridClientRouteOwner, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolveLoadedHybridClientRewriteHref, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, seedPrefetchResponseSnapshot, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GLOBAL_ACCESSORS_KEY, ServerInsertedHTMLContext, _registerStateAccessors, clearServerInsertedHTML, flushServerInsertedHTML, getLayoutSegmentContext, getNavigationContext, renderServerInsertedHTML, setNavigationContext } from "./navigation-context-state.js";
|
|
2
2
|
import { BailoutToCSRError, DynamicServerError, HTTP_ERROR_FALLBACK_ERROR_CODE, RedirectType, forbidden, getAccessFallbackHTTPStatus, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, notFound, permanentRedirect, redirect, unauthorized, unstable_rethrow } from "./navigation-errors.js";
|
|
3
3
|
import "./navigation-server.js";
|
|
4
|
-
import { throwClientHookError } from "./client-hook-error.js";
|
|
5
4
|
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
5
|
+
import { throwClientHookError } from "./client-hook-error.js";
|
|
6
6
|
//#region src/shims/navigation.react-server.ts
|
|
7
7
|
function usePathname() {
|
|
8
8
|
throwClientHookError("usePathname()");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vinext/types/next/augmentations";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vinext/types/next";
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/shims/public-shim-map.json
|
|
2
|
+
var public_shim_map_default = {
|
|
3
|
+
"next/link": {
|
|
4
|
+
"shim": "link",
|
|
5
|
+
"types": "upstream"
|
|
6
|
+
},
|
|
7
|
+
"next/head": {
|
|
8
|
+
"shim": "head",
|
|
9
|
+
"types": "upstream"
|
|
10
|
+
},
|
|
11
|
+
"next/router": {
|
|
12
|
+
"shim": "router",
|
|
13
|
+
"types": "upstream"
|
|
14
|
+
},
|
|
15
|
+
"next/compat/router": {
|
|
16
|
+
"shim": "compat-router",
|
|
17
|
+
"types": "upstream"
|
|
18
|
+
},
|
|
19
|
+
"next/image": {
|
|
20
|
+
"shim": "image",
|
|
21
|
+
"types": "upstream"
|
|
22
|
+
},
|
|
23
|
+
"next/legacy/image": {
|
|
24
|
+
"shim": "legacy-image",
|
|
25
|
+
"types": "upstream"
|
|
26
|
+
},
|
|
27
|
+
"next/dynamic": {
|
|
28
|
+
"shim": "dynamic",
|
|
29
|
+
"types": "upstream"
|
|
30
|
+
},
|
|
31
|
+
"next/app": {
|
|
32
|
+
"shim": "app",
|
|
33
|
+
"types": "upstream"
|
|
34
|
+
},
|
|
35
|
+
"next/document": {
|
|
36
|
+
"shim": "document",
|
|
37
|
+
"types": "upstream"
|
|
38
|
+
},
|
|
39
|
+
"next/config": {
|
|
40
|
+
"shim": "config",
|
|
41
|
+
"types": "vinext"
|
|
42
|
+
},
|
|
43
|
+
"next/script": {
|
|
44
|
+
"shim": "script",
|
|
45
|
+
"types": "upstream"
|
|
46
|
+
},
|
|
47
|
+
"next/server": {
|
|
48
|
+
"shim": "server",
|
|
49
|
+
"types": "upstream"
|
|
50
|
+
},
|
|
51
|
+
"next/navigation": {
|
|
52
|
+
"shim": "navigation",
|
|
53
|
+
"types": "upstream",
|
|
54
|
+
"reactServer": true
|
|
55
|
+
},
|
|
56
|
+
"next/headers": {
|
|
57
|
+
"shim": "headers",
|
|
58
|
+
"types": "upstream"
|
|
59
|
+
},
|
|
60
|
+
"next/font/google": {
|
|
61
|
+
"shim": "font-google",
|
|
62
|
+
"types": "upstream"
|
|
63
|
+
},
|
|
64
|
+
"next/font/local": {
|
|
65
|
+
"shim": "font-local",
|
|
66
|
+
"types": "upstream"
|
|
67
|
+
},
|
|
68
|
+
"next/cache": {
|
|
69
|
+
"shim": "cache",
|
|
70
|
+
"types": "upstream"
|
|
71
|
+
},
|
|
72
|
+
"next/form": {
|
|
73
|
+
"shim": "form",
|
|
74
|
+
"types": "upstream"
|
|
75
|
+
},
|
|
76
|
+
"next/og": {
|
|
77
|
+
"shim": "og",
|
|
78
|
+
"types": "upstream"
|
|
79
|
+
},
|
|
80
|
+
"next/web-vitals": {
|
|
81
|
+
"shim": "web-vitals",
|
|
82
|
+
"types": "vinext"
|
|
83
|
+
},
|
|
84
|
+
"next/amp": {
|
|
85
|
+
"shim": "amp",
|
|
86
|
+
"types": "vinext"
|
|
87
|
+
},
|
|
88
|
+
"next/offline": {
|
|
89
|
+
"shim": "offline",
|
|
90
|
+
"types": "vinext"
|
|
91
|
+
},
|
|
92
|
+
"next/error": {
|
|
93
|
+
"shim": "error",
|
|
94
|
+
"types": "upstream",
|
|
95
|
+
"reactServer": true
|
|
96
|
+
},
|
|
97
|
+
"next/constants": {
|
|
98
|
+
"shim": "constants",
|
|
99
|
+
"types": "upstream"
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
export { public_shim_map_default as default };
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Mutation methods remain present for instanceof/API compatibility but throw.
|
|
5
5
|
*/
|
|
6
6
|
declare class ReadonlyURLSearchParams extends URLSearchParams {
|
|
7
|
-
append(
|
|
8
|
-
delete(
|
|
9
|
-
set(
|
|
7
|
+
append(): never;
|
|
8
|
+
delete(): never;
|
|
9
|
+
set(): never;
|
|
10
10
|
sort(): never;
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
@@ -9,13 +9,13 @@ var ReadonlyURLSearchParamsError = class extends Error {
|
|
|
9
9
|
* Mutation methods remain present for instanceof/API compatibility but throw.
|
|
10
10
|
*/
|
|
11
11
|
var ReadonlyURLSearchParams = class extends URLSearchParams {
|
|
12
|
-
append(
|
|
12
|
+
append() {
|
|
13
13
|
throw new ReadonlyURLSearchParamsError();
|
|
14
14
|
}
|
|
15
|
-
delete(
|
|
15
|
+
delete() {
|
|
16
16
|
throw new ReadonlyURLSearchParamsError();
|
|
17
17
|
}
|
|
18
|
-
set(
|
|
18
|
+
set() {
|
|
19
19
|
throw new ReadonlyURLSearchParamsError();
|
|
20
20
|
}
|
|
21
21
|
sort() {
|
|
@@ -33,7 +33,10 @@ type ExecutionContextLike = {
|
|
|
33
33
|
* execution context. Typed as `unknown` to keep this module runtime-agnostic;
|
|
34
34
|
* CDN cache adapters that know the concrete shape narrow it themselves.
|
|
35
35
|
*/
|
|
36
|
-
cache?: unknown;
|
|
36
|
+
cache?: unknown; /** Server-owned origin for credential-bearing Pages revalidation loopbacks. */
|
|
37
|
+
trustedRevalidateOrigin?: string; /** Worker-owned in-process dispatcher for authenticated Pages revalidation. */
|
|
38
|
+
dispatchPagesRevalidate?: (request: Request) => Promise<Response>; /** Marks a request currently executing through the internal revalidation dispatcher. */
|
|
39
|
+
isInternalPagesRevalidation?: boolean;
|
|
37
40
|
};
|
|
38
41
|
/**
|
|
39
42
|
* Run `fn` with the given `ExecutionContext` available via
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NavigationContext } from "./navigation-context-state.js";
|
|
2
|
-
import { RootParamsState } from "./root-params.js";
|
|
3
2
|
import { CacheLifeConfig, CacheState } from "./cache-request-state.js";
|
|
3
|
+
import { RootParamsState } from "./root-params.js";
|
|
4
4
|
import { ExecutionContextLike } from "./request-context.js";
|
|
5
5
|
import { FetchCacheState } from "./fetch-cache.js";
|
|
6
6
|
import { HeadersAccessPhase, HeadersContext, VinextHeadersShimState } from "./headers.js";
|
package/dist/shims/router.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { VinextNextData } from "../client/vinext-next-data.js";
|
|
2
|
+
import { isExternalUrl } from "../utils/external-url.js";
|
|
2
3
|
import { PagesRouterComponentsMap } from "./internal/pages-router-components.js";
|
|
3
|
-
import {
|
|
4
|
+
import { UrlObject } from "node:url";
|
|
4
5
|
import { ComponentType, ReactElement } from "react";
|
|
6
|
+
import { ParsedUrlQuery } from "node:querystring";
|
|
7
|
+
import { BaseContext, NextComponentType, NextPageContext } from "@vinext/types/next/upstream/dist/shared/lib/utils";
|
|
5
8
|
|
|
6
9
|
//#region src/shims/router.d.ts
|
|
7
10
|
type BeforePopStateCallback = (state: {
|
|
@@ -12,30 +15,27 @@ type BeforePopStateCallback = (state: {
|
|
|
12
15
|
type NextRouter = {
|
|
13
16
|
/** Current pathname */pathname: string; /** Current route pattern (e.g., "/posts/[id]") */
|
|
14
17
|
route: string; /** Query parameters */
|
|
15
|
-
query:
|
|
18
|
+
query: ParsedUrlQuery; /** Full URL including query string */
|
|
16
19
|
asPath: string; /** Base path */
|
|
17
20
|
basePath: string; /** Current locale */
|
|
18
21
|
locale?: string; /** Available locales */
|
|
19
|
-
locales?: string[]; /** Default locale */
|
|
22
|
+
locales?: readonly string[]; /** Default locale */
|
|
20
23
|
defaultLocale?: string; /** Configured domain locales */
|
|
21
|
-
domainLocales?: VinextNextData["domainLocales"]; /** Whether the
|
|
24
|
+
domainLocales?: VinextNextData["domainLocales"]; /** Whether the active hostname matches a configured locale domain */
|
|
25
|
+
isLocaleDomain: boolean; /** Whether the router is ready */
|
|
22
26
|
isReady: boolean; /** Whether this is a preview */
|
|
23
27
|
isPreview: boolean; /** Whether this is a fallback page */
|
|
24
28
|
isFallback: boolean; /** Navigate to a new URL */
|
|
25
|
-
push(url: string | UrlObject, as?: string, options?: TransitionOptions): Promise<boolean>; /** Replace current URL */
|
|
26
|
-
replace(url: string | UrlObject, as?: string, options?: TransitionOptions): Promise<boolean>; /** Go back */
|
|
27
|
-
back(): void; /**
|
|
29
|
+
push(url: string | UrlObject$1, as?: string, options?: TransitionOptions): Promise<boolean>; /** Replace current URL */
|
|
30
|
+
replace(url: string | UrlObject$1, as?: string, options?: TransitionOptions): Promise<boolean>; /** Go back */
|
|
31
|
+
back(): void; /** Go forward */
|
|
32
|
+
forward(): void; /** Reload the page */
|
|
28
33
|
reload(): void; /** Prefetch a page (injects <link rel="prefetch">) */
|
|
29
34
|
prefetch(url: string, as?: string): Promise<void>; /** Register a callback to run before popstate navigation */
|
|
30
35
|
beforePopState(cb: BeforePopStateCallback): void; /** Listen for route changes */
|
|
31
36
|
events: RouterEvents;
|
|
32
37
|
};
|
|
33
|
-
type UrlObject =
|
|
34
|
-
pathname?: string;
|
|
35
|
-
query?: UrlQuery;
|
|
36
|
-
search?: string;
|
|
37
|
-
hash?: string;
|
|
38
|
-
};
|
|
38
|
+
type UrlObject$1 = UrlObject;
|
|
39
39
|
type TransitionOptions = {
|
|
40
40
|
_h?: 1;
|
|
41
41
|
shallow?: boolean;
|
|
@@ -53,8 +53,6 @@ type RouterEvents = {
|
|
|
53
53
|
* Same logic as Link's applyLocaleToHref but reads from window globals.
|
|
54
54
|
*/
|
|
55
55
|
declare function applyNavigationLocale(url: string, locale?: string, replaceExistingLocale?: boolean): string;
|
|
56
|
-
/** Check if a URL is external (any URL scheme per RFC 3986, or protocol-relative) */
|
|
57
|
-
declare function isExternalUrl(url: string): boolean;
|
|
58
56
|
/** Check if a href is only a hash change relative to the current URL */
|
|
59
57
|
declare function isHashOnlyChange(href: string): boolean;
|
|
60
58
|
/**
|
|
@@ -174,18 +172,54 @@ type ExcludeRouterProps<P> = Pick<P, Exclude<keyof P, keyof WithRouterProps>>;
|
|
|
174
172
|
* composed component so `_app` parity holds for class components that
|
|
175
173
|
* define `getInitialProps`.
|
|
176
174
|
*/
|
|
177
|
-
declare function withRouter<P extends WithRouterProps>(ComposedComponent:
|
|
175
|
+
declare function withRouter<P extends WithRouterProps, C extends BaseContext = NextPageContext>(ComposedComponent: NextComponentType<C, any, P>): ComponentType<ExcludeRouterProps<P>>;
|
|
178
176
|
declare const RouterMethods: {
|
|
179
|
-
|
|
177
|
+
router: null;
|
|
178
|
+
readyCallbacks: Array<() => unknown>;
|
|
179
|
+
ready(callback: () => unknown): void; /** See `_components` comment above for the dual role this map plays. */
|
|
180
|
+
components: PagesRouterComponentsMap;
|
|
180
181
|
sdc: Record<string, Promise<Response>>;
|
|
181
|
-
push: (url: string | UrlObject, as?: string, options?: TransitionOptions) => Promise<boolean>;
|
|
182
|
-
replace: (url: string | UrlObject, as?: string, options?: TransitionOptions) => Promise<boolean>;
|
|
182
|
+
push: (url: string | UrlObject$1, as?: string, options?: TransitionOptions) => Promise<boolean>;
|
|
183
|
+
replace: (url: string | UrlObject$1, as?: string, options?: TransitionOptions) => Promise<boolean>;
|
|
183
184
|
back: () => void;
|
|
185
|
+
forward: () => void;
|
|
184
186
|
reload: () => void;
|
|
185
187
|
prefetch: (url: string, as?: string) => Promise<void>;
|
|
186
188
|
beforePopState: (cb: BeforePopStateCallback) => void;
|
|
187
189
|
events: RouterEvents;
|
|
188
190
|
};
|
|
189
|
-
declare const
|
|
191
|
+
declare const singletonRouter: typeof RouterMethods & Omit<NextRouter, keyof typeof RouterMethods>;
|
|
192
|
+
/**
|
|
193
|
+
* Constructible named export matching `next/router`'s Router class surface.
|
|
194
|
+
* Vinext owns one browser history runtime, so instances delegate to that
|
|
195
|
+
* shared runtime while preserving the class/static-events API used by apps.
|
|
196
|
+
*/
|
|
197
|
+
declare class Router {
|
|
198
|
+
static events: RouterEvents;
|
|
199
|
+
constructor(..._args: unknown[]);
|
|
200
|
+
get route(): string;
|
|
201
|
+
get pathname(): string;
|
|
202
|
+
get query(): ParsedUrlQuery;
|
|
203
|
+
get asPath(): string;
|
|
204
|
+
get basePath(): string;
|
|
205
|
+
get locale(): string | undefined;
|
|
206
|
+
get locales(): readonly string[] | undefined;
|
|
207
|
+
get defaultLocale(): string | undefined;
|
|
208
|
+
get domainLocales(): VinextNextData["domainLocales"];
|
|
209
|
+
get isLocaleDomain(): boolean;
|
|
210
|
+
get isReady(): boolean;
|
|
211
|
+
get isPreview(): boolean;
|
|
212
|
+
get isFallback(): boolean;
|
|
213
|
+
get events(): RouterEvents;
|
|
214
|
+
get components(): PagesRouterComponentsMap;
|
|
215
|
+
get sdc(): Record<string, Promise<Response>>;
|
|
216
|
+
push(url: string | UrlObject$1, as?: string, options?: TransitionOptions): Promise<boolean>;
|
|
217
|
+
replace(url: string | UrlObject$1, as?: string, options?: TransitionOptions): Promise<boolean>;
|
|
218
|
+
reload(): void;
|
|
219
|
+
back(): void;
|
|
220
|
+
forward(): void;
|
|
221
|
+
prefetch(url: string, as?: string): Promise<void>;
|
|
222
|
+
beforePopState(cb: BeforePopStateCallback): void;
|
|
223
|
+
}
|
|
190
224
|
//#endregion
|
|
191
|
-
export { ExcludeRouterProps, NextRouter, WithRouterProps, initializePagesRouterReadyFromNextData as _initializePagesRouterReadyFromNextData, markPagesRouterReady as _markPagesRouterReady, _registerRouterStateAccessors, applyNavigationLocale,
|
|
225
|
+
export { ExcludeRouterProps, NextRouter, Router, WithRouterProps, initializePagesRouterReadyFromNextData as _initializePagesRouterReadyFromNextData, markPagesRouterReady as _markPagesRouterReady, _registerRouterStateAccessors, applyNavigationLocale, singletonRouter as default, getPagesNavigationContext, getPagesNavigationIsReadyFromSerializedState, isExternalUrl, isHashOnlyChange, setSSRContext, useRouter, withRouter, wrapWithRouterContext };
|