vinext 0.1.0 → 0.1.2

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.
Files changed (205) hide show
  1. package/README.md +2 -5
  2. package/dist/build/assets-ignore.d.ts +32 -0
  3. package/dist/build/assets-ignore.js +48 -0
  4. package/dist/build/client-build-config.d.ts +33 -1
  5. package/dist/build/client-build-config.js +66 -1
  6. package/dist/check.js +4 -3
  7. package/dist/cli.js +2 -0
  8. package/dist/client/navigation-runtime.d.ts +11 -2
  9. package/dist/client/navigation-runtime.js +1 -1
  10. package/dist/client/vinext-next-data.d.ts +2 -1
  11. package/dist/client/window-next.d.ts +6 -4
  12. package/dist/config/config-matchers.d.ts +31 -5
  13. package/dist/config/config-matchers.js +50 -3
  14. package/dist/config/next-config.d.ts +29 -3
  15. package/dist/config/next-config.js +32 -2
  16. package/dist/deploy.js +47 -304
  17. package/dist/entries/app-rsc-entry.d.ts +8 -2
  18. package/dist/entries/app-rsc-entry.js +61 -5
  19. package/dist/entries/app-rsc-manifest.js +20 -2
  20. package/dist/entries/pages-client-entry.js +1 -1
  21. package/dist/entries/pages-server-entry.js +16 -7
  22. package/dist/index.d.ts +0 -2
  23. package/dist/index.js +233 -280
  24. package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
  25. package/dist/plugins/dynamic-preload-metadata.js +415 -0
  26. package/dist/plugins/og-assets.js +2 -2
  27. package/dist/plugins/optimize-imports.d.ts +8 -4
  28. package/dist/plugins/optimize-imports.js +16 -12
  29. package/dist/plugins/postcss.js +18 -14
  30. package/dist/plugins/require-context.d.ts +6 -0
  31. package/dist/plugins/require-context.js +184 -0
  32. package/dist/plugins/sass.d.ts +53 -24
  33. package/dist/plugins/sass.js +249 -1
  34. package/dist/plugins/wasm-module-import.d.ts +15 -0
  35. package/dist/plugins/wasm-module-import.js +50 -0
  36. package/dist/routing/app-route-graph.d.ts +35 -2
  37. package/dist/routing/app-route-graph.js +179 -8
  38. package/dist/routing/file-matcher.js +1 -1
  39. package/dist/routing/route-pattern.d.ts +2 -1
  40. package/dist/routing/route-pattern.js +16 -1
  41. package/dist/server/api-handler.js +4 -0
  42. package/dist/server/app-browser-entry.js +155 -215
  43. package/dist/server/app-browser-error.d.ts +4 -1
  44. package/dist/server/app-browser-error.js +7 -1
  45. package/dist/server/app-browser-history-controller.d.ts +104 -0
  46. package/dist/server/app-browser-history-controller.js +210 -0
  47. package/dist/server/app-browser-interception-context.d.ts +2 -1
  48. package/dist/server/app-browser-interception-context.js +15 -2
  49. package/dist/server/app-browser-navigation-controller.d.ts +13 -2
  50. package/dist/server/app-browser-navigation-controller.js +83 -4
  51. package/dist/server/app-browser-popstate.d.ts +12 -3
  52. package/dist/server/app-browser-popstate.js +19 -4
  53. package/dist/server/app-browser-rsc-redirect.d.ts +11 -2
  54. package/dist/server/app-browser-rsc-redirect.js +30 -8
  55. package/dist/server/app-browser-state.d.ts +3 -0
  56. package/dist/server/app-browser-state.js +10 -10
  57. package/dist/server/app-browser-visible-commit.js +10 -8
  58. package/dist/server/app-fallback-renderer.d.ts +2 -1
  59. package/dist/server/app-fallback-renderer.js +3 -1
  60. package/dist/server/app-history-state.d.ts +45 -1
  61. package/dist/server/app-history-state.js +109 -1
  62. package/dist/server/app-middleware.js +1 -0
  63. package/dist/server/app-optimistic-routing.js +22 -1
  64. package/dist/server/app-page-boundary-render.d.ts +2 -1
  65. package/dist/server/app-page-boundary-render.js +45 -21
  66. package/dist/server/app-page-cache.js +9 -7
  67. package/dist/server/app-page-dispatch.d.ts +14 -0
  68. package/dist/server/app-page-dispatch.js +21 -6
  69. package/dist/server/app-page-element-builder.d.ts +23 -2
  70. package/dist/server/app-page-element-builder.js +58 -17
  71. package/dist/server/app-page-execution.d.ts +1 -1
  72. package/dist/server/app-page-execution.js +32 -17
  73. package/dist/server/app-page-render.d.ts +7 -1
  74. package/dist/server/app-page-render.js +11 -16
  75. package/dist/server/app-page-request.d.ts +9 -6
  76. package/dist/server/app-page-request.js +14 -10
  77. package/dist/server/app-page-response.d.ts +2 -2
  78. package/dist/server/app-page-response.js +2 -2
  79. package/dist/server/app-page-route-wiring.d.ts +3 -1
  80. package/dist/server/app-page-route-wiring.js +10 -8
  81. package/dist/server/app-page-stream.d.ts +37 -7
  82. package/dist/server/app-page-stream.js +36 -6
  83. package/dist/server/app-pages-bridge.d.ts +16 -0
  84. package/dist/server/app-pages-bridge.js +23 -3
  85. package/dist/server/app-route-handler-cache.d.ts +1 -0
  86. package/dist/server/app-route-handler-cache.js +1 -0
  87. package/dist/server/app-route-handler-dispatch.d.ts +1 -0
  88. package/dist/server/app-route-handler-dispatch.js +2 -0
  89. package/dist/server/app-route-handler-execution.d.ts +1 -0
  90. package/dist/server/app-route-handler-execution.js +1 -0
  91. package/dist/server/app-route-handler-response.js +11 -10
  92. package/dist/server/app-route-handler-runtime.d.ts +1 -0
  93. package/dist/server/app-route-handler-runtime.js +15 -3
  94. package/dist/server/app-rsc-handler.d.ts +1 -0
  95. package/dist/server/app-rsc-handler.js +5 -4
  96. package/dist/server/app-rsc-response-finalizer.js +1 -1
  97. package/dist/server/app-rsc-route-matching.d.ts +20 -1
  98. package/dist/server/app-rsc-route-matching.js +29 -4
  99. package/dist/server/app-server-action-execution.d.ts +22 -1
  100. package/dist/server/app-server-action-execution.js +73 -12
  101. package/dist/server/app-ssr-entry.d.ts +6 -0
  102. package/dist/server/app-ssr-entry.js +19 -3
  103. package/dist/server/app-ssr-stream.js +9 -1
  104. package/dist/server/dev-lockfile.js +2 -1
  105. package/dist/server/dev-server.d.ts +1 -1
  106. package/dist/server/dev-server.js +97 -43
  107. package/dist/server/headers.d.ts +8 -1
  108. package/dist/server/headers.js +8 -1
  109. package/dist/server/instrumentation-runtime.d.ts +6 -0
  110. package/dist/server/instrumentation-runtime.js +8 -0
  111. package/dist/server/isr-cache.d.ts +37 -1
  112. package/dist/server/isr-cache.js +85 -1
  113. package/dist/server/isr-decision.d.ts +79 -0
  114. package/dist/server/isr-decision.js +70 -0
  115. package/dist/server/metadata-route-response.js +5 -3
  116. package/dist/server/middleware-runtime.d.ts +13 -0
  117. package/dist/server/middleware-runtime.js +11 -7
  118. package/dist/server/middleware.js +1 -0
  119. package/dist/server/navigation-planner.d.ts +62 -1
  120. package/dist/server/navigation-planner.js +193 -3
  121. package/dist/server/navigation-trace.d.ts +12 -2
  122. package/dist/server/navigation-trace.js +11 -1
  123. package/dist/server/normalize-path.d.ts +0 -8
  124. package/dist/server/normalize-path.js +3 -1
  125. package/dist/server/otel-tracer-extension.d.ts +45 -0
  126. package/dist/server/otel-tracer-extension.js +89 -0
  127. package/dist/server/pages-api-route.d.ts +14 -3
  128. package/dist/server/pages-api-route.js +6 -1
  129. package/dist/server/pages-asset-tags.d.ts +15 -4
  130. package/dist/server/pages-asset-tags.js +18 -12
  131. package/dist/server/pages-data-route.js +5 -1
  132. package/dist/server/pages-node-compat.d.ts +5 -11
  133. package/dist/server/pages-node-compat.js +175 -118
  134. package/dist/server/pages-page-data.d.ts +38 -7
  135. package/dist/server/pages-page-data.js +64 -18
  136. package/dist/server/pages-page-handler.d.ts +10 -2
  137. package/dist/server/pages-page-handler.js +49 -20
  138. package/dist/server/pages-page-response.d.ts +55 -2
  139. package/dist/server/pages-page-response.js +74 -6
  140. package/dist/server/pages-readiness.d.ts +36 -0
  141. package/dist/server/pages-readiness.js +21 -0
  142. package/dist/server/pages-request-pipeline.d.ts +113 -0
  143. package/dist/server/pages-request-pipeline.js +230 -0
  144. package/dist/server/pages-revalidate.d.ts +15 -0
  145. package/dist/server/pages-revalidate.js +19 -0
  146. package/dist/server/prod-server.d.ts +45 -3
  147. package/dist/server/prod-server.js +182 -234
  148. package/dist/server/socket-error-backstop.d.ts +19 -1
  149. package/dist/server/socket-error-backstop.js +77 -4
  150. package/dist/shims/app-router-scroll.js +22 -4
  151. package/dist/shims/cache-runtime.js +39 -2
  152. package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
  153. package/dist/shims/dynamic-preload-chunks.js +77 -0
  154. package/dist/shims/dynamic.d.ts +4 -0
  155. package/dist/shims/dynamic.js +4 -2
  156. package/dist/shims/error-boundary.d.ts +17 -7
  157. package/dist/shims/error-boundary.js +8 -1
  158. package/dist/shims/error.js +37 -11
  159. package/dist/shims/fetch-cache.d.ts +22 -1
  160. package/dist/shims/fetch-cache.js +28 -1
  161. package/dist/shims/hash-scroll.d.ts +1 -0
  162. package/dist/shims/hash-scroll.js +3 -1
  163. package/dist/shims/head.js +6 -1
  164. package/dist/shims/headers.d.ts +16 -2
  165. package/dist/shims/headers.js +37 -1
  166. package/dist/shims/image-config.js +7 -1
  167. package/dist/shims/internal/app-route-detection.d.ts +6 -3
  168. package/dist/shims/internal/app-route-detection.js +10 -6
  169. package/dist/shims/internal/app-router-context.d.ts +5 -0
  170. package/dist/shims/internal/link-status-registry.d.ts +43 -0
  171. package/dist/shims/internal/link-status-registry.js +42 -0
  172. package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
  173. package/dist/shims/internal/route-pattern-for-warning.js +40 -0
  174. package/dist/shims/internal/utils.d.ts +1 -0
  175. package/dist/shims/link.js +20 -6
  176. package/dist/shims/metadata.d.ts +6 -2
  177. package/dist/shims/metadata.js +32 -14
  178. package/dist/shims/navigation.d.ts +9 -18
  179. package/dist/shims/navigation.js +96 -23
  180. package/dist/shims/router-state.d.ts +1 -0
  181. package/dist/shims/router-state.js +2 -0
  182. package/dist/shims/router.d.ts +6 -3
  183. package/dist/shims/router.js +156 -22
  184. package/dist/shims/script-nonce-context.d.ts +1 -1
  185. package/dist/shims/script-nonce-context.js +11 -3
  186. package/dist/shims/server.d.ts +17 -1
  187. package/dist/shims/server.js +31 -6
  188. package/dist/shims/slot.js +1 -1
  189. package/dist/shims/unified-request-context.js +1 -0
  190. package/dist/typegen.js +1 -0
  191. package/dist/utils/client-build-manifest.d.ts +8 -1
  192. package/dist/utils/client-build-manifest.js +41 -6
  193. package/dist/utils/client-entry-manifest.d.ts +11 -0
  194. package/dist/utils/client-entry-manifest.js +29 -0
  195. package/dist/utils/client-runtime-metadata.d.ts +45 -0
  196. package/dist/utils/client-runtime-metadata.js +63 -0
  197. package/dist/utils/hash.d.ts +17 -1
  198. package/dist/utils/hash.js +36 -1
  199. package/dist/utils/lazy-chunks.d.ts +27 -1
  200. package/dist/utils/lazy-chunks.js +65 -1
  201. package/dist/utils/manifest-paths.d.ts +20 -2
  202. package/dist/utils/manifest-paths.js +38 -3
  203. package/dist/utils/path.d.ts +2 -1
  204. package/dist/utils/path.js +5 -1
  205. package/package.json +6 -2
@@ -1,4 +1,5 @@
1
- import { NavigateOptions, PrefetchOptions as PrefetchOptions$1 } from "./internal/app-router-context.js";
1
+ import { NavigationRuntimeVisibleCommitMode } from "../client/navigation-runtime.js";
2
+ import { AppRouterInstance, NavigateOptions, PrefetchOptions as PrefetchOptions$1 } from "./internal/app-router-context.js";
2
3
  import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
3
4
  import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
4
5
  import * as React$1 from "react";
@@ -205,6 +206,7 @@ type ClientNavigationRenderSnapshot = {
205
206
  };
206
207
  declare function getClientNavigationRenderContext(): React$1.Context<ClientNavigationRenderSnapshot | null> | null;
207
208
  declare function createClientNavigationRenderSnapshot(href: string, params: Record<string, string | string[]>): ClientNavigationRenderSnapshot;
209
+ declare function createSnapshotPathAndSearch(snapshot: ClientNavigationRenderSnapshot): string;
208
210
  declare function setClientParams(params: Record<string, string | string[]>): void;
209
211
  declare function replaceClientParamsWithoutNotify(params: Record<string, string | string[]>): void;
210
212
  /** Get the current client params (for testing referential stability). */
@@ -225,7 +227,7 @@ declare function clearPendingPathname(navId: number): void;
225
227
  * Returns the current pathname.
226
228
  * Server: from request context. Client: from window.location.
227
229
  */
228
- declare function usePathname(): string;
230
+ declare function usePathname(): string | null;
229
231
  /**
230
232
  * Returns the current search params as a read-only URLSearchParams.
231
233
  */
@@ -233,7 +235,7 @@ declare function useSearchParams(): ReadonlyURLSearchParams;
233
235
  /**
234
236
  * Returns the dynamic params for the current route.
235
237
  */
236
- declare function useParams<T extends Record<string, string | string[]> = Record<string, string | string[]>>(): T;
238
+ declare function useParams<T extends Record<string, string | string[]> = Record<string, string | string[]>>(): T | null;
237
239
  /**
238
240
  * Commit pending client navigation state to committed snapshots.
239
241
  *
@@ -256,7 +258,7 @@ declare function saveScrollPosition(): void;
256
258
  /**
257
259
  * Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.
258
260
  */
259
- declare function navigateClientSide(href: string, mode: "push" | "replace", scroll: boolean, programmaticTransition?: boolean): Promise<void>;
261
+ declare function navigateClientSide(href: string, mode: "push" | "replace", scroll: boolean, programmaticTransition?: boolean, visibleCommitMode?: NavigationRuntimeVisibleCommitMode): Promise<void>;
260
262
  /**
261
263
  * Public App Router instance, exposed for the browser entry so it can wire
262
264
  * `window.next.router` to the same singleton returned from `useRouter()`.
@@ -264,19 +266,7 @@ declare function navigateClientSide(href: string, mode: "push" | "replace", scro
264
266
  * Mirrors `publicAppRouterInstance` from Next.js's
265
267
  * `packages/next/src/client/components/app-router-instance.ts` (line 392).
266
268
  */
267
- declare const appRouterInstance: {
268
- bfcacheId: string;
269
- push(href: string, options?: {
270
- scroll?: boolean;
271
- }): void;
272
- replace(href: string, options?: {
273
- scroll?: boolean;
274
- }): void;
275
- back(): void;
276
- forward(): void;
277
- refresh(): void;
278
- prefetch(href: string, options?: PrefetchOptions): void;
279
- };
269
+ declare const appRouterInstance: AppRouterInstance;
280
270
  /**
281
271
  * App Router's useRouter — returns push/replace/back/forward/refresh.
282
272
  * Different from Pages Router's useRouter (next/router).
@@ -292,6 +282,7 @@ declare function useRouter(): {
292
282
  push(href: string, options?: NavigateOptions): void;
293
283
  replace(href: string, options?: NavigateOptions): void;
294
284
  prefetch(href: string, options?: PrefetchOptions$1): void;
285
+ experimental_gesturePush?(href: string, options?: NavigateOptions): void;
295
286
  };
296
287
  /**
297
288
  * Returns the active child segment one level below the layout where it's called.
@@ -574,4 +565,4 @@ declare function isDynamicServerError(error: unknown): error is DynamicServerErr
574
565
  */
575
566
  declare function unstable_rethrow(error: unknown): void;
576
567
  //#endregion
577
- export { BailoutToCSRError, CachedRscResponse, ClientNavigationRenderSnapshot, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, NavigationContext, PREFETCH_CACHE_TTL, PrefetchCacheEntry, PrefetchOptions, ReadonlyURLSearchParams, RedirectType, SegmentMap, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, decodeRedirectError, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
568
+ export { BailoutToCSRError, CachedRscResponse, ClientNavigationRenderSnapshot, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, NavigationContext, PREFETCH_CACHE_TTL, PrefetchCacheEntry, PrefetchOptions, ReadonlyURLSearchParams, RedirectType, SegmentMap, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
@@ -4,7 +4,7 @@ import { assertSafeNavigationUrl } from "./url-safety.js";
4
4
  import { AppElementsWire } from "../server/app-elements-wire.js";
5
5
  import "../server/app-elements.js";
6
6
  import { AppRouterContext } from "./internal/app-router-context.js";
7
- import { isAbsoluteOrProtocolRelativeUrl, isHashOnlyBrowserUrlChange, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
7
+ import { isAbsoluteOrProtocolRelativeUrl, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
8
8
  import { retryScrollTo, scrollToHashTarget } from "./hash-scroll.js";
9
9
  import { getNavigationRuntime, hasAppNavigationRuntime } from "../client/navigation-runtime.js";
10
10
  import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
@@ -13,6 +13,7 @@ import { resolveManifestNavigationInterceptionContext } from "../server/app-brow
13
13
  import { createExternalHistoryStatePreservingMetadata, createHashOnlyHistoryStatePreservingNavigationMetadata } from "../server/app-history-state.js";
14
14
  import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createRscRequestHeaders, createRscRequestUrl, stripRscCacheBustingSearchParam } from "../server/app-rsc-cache-busting.js";
15
15
  import { hasPendingAppRouterPageRedirect } from "../server/app-browser-mpa-navigation.js";
16
+ import { navigationPlanner } from "../server/navigation-planner.js";
16
17
  import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
17
18
  import { beginAppRouterScrollIntent, clearAppRouterScrollIntent, consumeAppRouterScrollIntent } from "./app-router-scroll-state.js";
18
19
  import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
@@ -74,6 +75,7 @@ function useChildSegments(parallelRoutesKey = "children") {
74
75
  }
75
76
  const _READONLY_SEARCH_PARAMS = Symbol("vinext.navigation.readonlySearchParams");
76
77
  const _READONLY_SEARCH_PARAMS_SOURCE = Symbol("vinext.navigation.readonlySearchParamsSource");
78
+ const _READONLY_SEARCH_PARAMS_SOURCE_KEY = Symbol("vinext.navigation.readonlySearchParamsSourceKey");
77
79
  const GLOBAL_ACCESSORS_KEY = Symbol.for("vinext.navigation.globalAccessors");
78
80
  const _GLOBAL_ACCESSORS_KEY = GLOBAL_ACCESSORS_KEY;
79
81
  const _GLOBAL_HYDRATION_CONTEXT_KEY = Symbol.for("vinext.navigation.clientHydrationContext");
@@ -87,6 +89,9 @@ function _getClientHydrationContext() {
87
89
  function _setClientHydrationContext(ctx) {
88
90
  globalThis[_GLOBAL_HYDRATION_CONTEXT_KEY] = ctx;
89
91
  }
92
+ function clearClientHydrationContext() {
93
+ if (typeof window !== "undefined") _setClientHydrationContext(null);
94
+ }
90
95
  let _serverContext = null;
91
96
  let _serverInsertedHTMLCallbacks = [];
92
97
  let _getServerContext = () => {
@@ -127,6 +132,7 @@ function _registerStateAccessors(accessors) {
127
132
  _clearInsertedHTMLCallbacks = accessors.clearInsertedHTMLCallbacks;
128
133
  }
129
134
  const PAGES_NAVIGATION_ACCESSOR_KEY = Symbol.for("vinext.navigation.pagesNavigationContextAccessor");
135
+ const PAGES_NAVIGATION_NOTIFY_KEY = Symbol.for("vinext.navigation.pagesNavigationNotify");
130
136
  function _getPagesNavigationContext() {
131
137
  const accessor = globalThis[PAGES_NAVIGATION_ACCESSOR_KEY];
132
138
  if (!accessor) return null;
@@ -583,7 +589,25 @@ function notifyNavigationListeners() {
583
589
  if (!state) return;
584
590
  for (const fn of state.listeners) fn();
585
591
  }
592
+ if (!isServer) globalThis[PAGES_NAVIGATION_NOTIFY_KEY] = notifyNavigationListeners;
586
593
  let _cachedEmptyServerSearchParams = null;
594
+ const _readonlyPagesSearchParamsCache = /* @__PURE__ */ new WeakMap();
595
+ let _cachedReadonlyPagesSearchParamsKey = null;
596
+ let _cachedReadonlyPagesSearchParams = null;
597
+ function getReadonlyPagesSearchParams(searchParams) {
598
+ const cached = _readonlyPagesSearchParamsCache.get(searchParams);
599
+ if (cached) return cached;
600
+ const key = searchParams.toString();
601
+ if (_cachedReadonlyPagesSearchParamsKey === key && _cachedReadonlyPagesSearchParams) {
602
+ _readonlyPagesSearchParamsCache.set(searchParams, _cachedReadonlyPagesSearchParams);
603
+ return _cachedReadonlyPagesSearchParams;
604
+ }
605
+ const readonly = new ReadonlyURLSearchParams(searchParams);
606
+ _readonlyPagesSearchParamsCache.set(searchParams, readonly);
607
+ _cachedReadonlyPagesSearchParamsKey = key;
608
+ _cachedReadonlyPagesSearchParams = readonly;
609
+ return readonly;
610
+ }
587
611
  /**
588
612
  * Get cached pathname snapshot for useSyncExternalStore.
589
613
  * Note: Returns cached value from ClientNavigationState, not live window.location.
@@ -593,6 +617,8 @@ let _cachedEmptyServerSearchParams = null;
593
617
  * be visible until the next commit.
594
618
  */
595
619
  function getPathnameSnapshot() {
620
+ const pagesCtx = _getPagesNavigationContext();
621
+ if (pagesCtx) return pagesCtx.pathname;
596
622
  return getClientNavigationState()?.cachedPathname ?? "/";
597
623
  }
598
624
  let _cachedEmptyClientSearchParams = null;
@@ -605,6 +631,9 @@ let _cachedEmptyClientSearchParams = null;
605
631
  * be visible until the next commit.
606
632
  */
607
633
  function getSearchParamsSnapshot() {
634
+ if (_getServerContext()) return getServerSearchParamsSnapshot();
635
+ const pagesCtx = _getPagesNavigationContext();
636
+ if (pagesCtx) return getReadonlyPagesSearchParams(pagesCtx.searchParams);
608
637
  const cached = getClientNavigationState()?.cachedReadonlySearchParams;
609
638
  if (cached) return cached;
610
639
  if (_cachedEmptyClientSearchParams === null) _cachedEmptyClientSearchParams = new ReadonlyURLSearchParams();
@@ -631,7 +660,7 @@ function getServerSearchParamsSnapshot() {
631
660
  const ctx = _getServerContext();
632
661
  if (!ctx) {
633
662
  const pagesCtx = _getPagesNavigationContext();
634
- if (pagesCtx) return new ReadonlyURLSearchParams(pagesCtx.searchParams);
663
+ if (pagesCtx) return getReadonlyPagesSearchParams(pagesCtx.searchParams);
635
664
  if (_cachedEmptyServerSearchParams === null) _cachedEmptyServerSearchParams = new ReadonlyURLSearchParams();
636
665
  return _cachedEmptyServerSearchParams;
637
666
  }
@@ -639,9 +668,15 @@ function getServerSearchParamsSnapshot() {
639
668
  const cached = ctx[_READONLY_SEARCH_PARAMS];
640
669
  const cachedSource = ctx[_READONLY_SEARCH_PARAMS_SOURCE];
641
670
  if (cached && cachedSource === source) return cached;
671
+ const sourceKey = source.toString();
672
+ if (cached && ctx[_READONLY_SEARCH_PARAMS_SOURCE_KEY] === sourceKey) {
673
+ ctx[_READONLY_SEARCH_PARAMS_SOURCE] = source;
674
+ return cached;
675
+ }
642
676
  const readonly = new ReadonlyURLSearchParams(source);
643
677
  ctx[_READONLY_SEARCH_PARAMS] = readonly;
644
678
  ctx[_READONLY_SEARCH_PARAMS_SOURCE] = source;
679
+ ctx[_READONLY_SEARCH_PARAMS_SOURCE_KEY] = sourceKey;
645
680
  return readonly;
646
681
  }
647
682
  /**
@@ -681,6 +716,10 @@ function createClientNavigationRenderSnapshot(href, params) {
681
716
  params
682
717
  };
683
718
  }
719
+ function createSnapshotPathAndSearch(snapshot) {
720
+ const query = snapshot.searchParams.toString();
721
+ return query === "" ? snapshot.pathname : `${snapshot.pathname}?${query}`;
722
+ }
684
723
  let _fallbackClientParams = _EMPTY_PARAMS;
685
724
  let _fallbackClientParamsJson = "{}";
686
725
  function setClientParams(params) {
@@ -742,15 +781,18 @@ function clearPendingPathname(navId) {
742
781
  }
743
782
  function getClientParamsSnapshot() {
744
783
  const state = getClientNavigationState();
784
+ const ctx = _getServerContext();
785
+ if (ctx) return ctx.params;
745
786
  const pagesCtx = _getPagesNavigationContext();
746
787
  if (pagesCtx) return pagesCtx.params;
747
- if (state && Object.keys(state.clientParams).length > 0) return state.clientParams;
748
788
  return state?.clientParams ?? _EMPTY_PARAMS;
749
789
  }
750
790
  function getServerParamsSnapshot() {
751
791
  const ctx = _getServerContext();
752
792
  if (ctx) return ctx.params;
753
- return _getPagesNavigationContext()?.params ?? _EMPTY_PARAMS;
793
+ const pagesCtx = _getPagesNavigationContext();
794
+ if (pagesCtx) return pagesCtx.params;
795
+ return _EMPTY_PARAMS;
754
796
  }
755
797
  function subscribeToNavigation(cb) {
756
798
  const state = getClientNavigationState();
@@ -768,10 +810,16 @@ function usePathname() {
768
810
  if (isServer) {
769
811
  const ctx = _getServerContext();
770
812
  if (ctx) return ctx.pathname;
771
- return _getPagesNavigationContext()?.pathname ?? "/";
813
+ const pagesCtx = _getPagesNavigationContext();
814
+ return pagesCtx ? pagesCtx.pathname : "/";
772
815
  }
773
816
  const renderSnapshot = useClientNavigationRenderSnapshot();
774
- const pathname = React$1.useSyncExternalStore(subscribeToNavigation, getPathnameSnapshot, () => _getServerContext()?.pathname ?? _getPagesNavigationContext()?.pathname ?? "/");
817
+ const pathname = React$1.useSyncExternalStore(subscribeToNavigation, getPathnameSnapshot, () => {
818
+ const ctx = _getServerContext();
819
+ if (ctx) return ctx.pathname;
820
+ const pagesCtx = _getPagesNavigationContext();
821
+ return pagesCtx ? pagesCtx.pathname : "/";
822
+ });
775
823
  if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.pathname;
776
824
  return pathname;
777
825
  }
@@ -801,14 +849,6 @@ function useParams() {
801
849
  function isExternalUrl(href) {
802
850
  return isAbsoluteOrProtocolRelativeUrl(href);
803
851
  }
804
- /**
805
- * Check if a href is only a hash change relative to the current URL.
806
- */
807
- function isHashOnlyChange(href) {
808
- if (typeof window === "undefined") return false;
809
- if (href.startsWith("#")) return true;
810
- return isHashOnlyBrowserUrlChange(href, window.location.href, __basePath);
811
- }
812
852
  function withSuppressedUrlNotifications(fn) {
813
853
  const state = getClientNavigationState();
814
854
  if (!state) return fn();
@@ -833,11 +873,13 @@ function commitClientNavigationState(navId, options) {
833
873
  if (!state) return;
834
874
  if ((navId !== void 0 || options?.releaseSnapshot === true) && state.navigationSnapshotActiveCount > 0) state.navigationSnapshotActiveCount -= 1;
835
875
  const urlChanged = syncCommittedUrlStateFromLocation();
876
+ let paramsChanged = false;
836
877
  if (state.pendingClientParams !== null && state.pendingClientParamsJson !== null) {
837
878
  state.clientParams = state.pendingClientParams;
838
879
  state.clientParamsJson = state.pendingClientParamsJson;
839
880
  state.pendingClientParams = null;
840
881
  state.pendingClientParamsJson = null;
882
+ paramsChanged = true;
841
883
  }
842
884
  if (state.pendingPathnameNavId === null || navId !== void 0 && state.pendingPathnameNavId === navId) {
843
885
  state.pendingPathname = null;
@@ -845,6 +887,7 @@ function commitClientNavigationState(navId, options) {
845
887
  }
846
888
  const shouldNotify = urlChanged || state.hasPendingNavigationUpdate;
847
889
  state.hasPendingNavigationUpdate = false;
890
+ if (urlChanged || paramsChanged) clearClientHydrationContext();
848
891
  if (shouldNotify) notifyNavigationListeners();
849
892
  }
850
893
  function pushHistoryStateWithoutNotify(data, unused, url) {
@@ -917,7 +960,8 @@ function restoreScrollPosition(state) {
917
960
  /**
918
961
  * Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.
919
962
  */
920
- async function navigateClientSide(href, mode, scroll, programmaticTransition = false) {
963
+ async function navigateClientSide(href, mode, scroll, programmaticTransition = false, visibleCommitMode = "transition") {
964
+ getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
921
965
  let normalizedHref = href;
922
966
  if (isExternalUrl(href)) {
923
967
  const localPath = toSameOriginAppPath(href, __basePath);
@@ -938,11 +982,17 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
938
982
  const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);
939
983
  notifyAppRouterTransitionStart(fullHref, mode);
940
984
  if (mode === "push") saveScrollPosition();
941
- if (isHashOnlyChange(fullHref)) {
942
- const hash = fullHref.includes("#") ? fullHref.slice(fullHref.indexOf("#")) : "";
943
- commitHashOnlyHistoryState(fullHref, mode, scroll);
985
+ const earlyIntent = navigationPlanner.classifyEarlyNavigationIntent({
986
+ basePath: __basePath,
987
+ currentHref: window.location.href,
988
+ mode,
989
+ scroll,
990
+ targetHref: fullHref
991
+ });
992
+ if (earlyIntent.kind === "sameDocumentScroll") {
993
+ commitHashOnlyHistoryState(fullHref, earlyIntent.mode, earlyIntent.scroll);
944
994
  commitClientNavigationState();
945
- if (scroll) scrollToHashTarget(hash);
995
+ if (earlyIntent.scroll) scrollToHashTarget(earlyIntent.hash);
946
996
  return;
947
997
  }
948
998
  if (hasPendingAppRouterPageRedirect(typeof document === "undefined" ? void 0 : document)) {
@@ -962,7 +1012,7 @@ async function navigateClientSide(href, mode, scroll, programmaticTransition = f
962
1012
  if (!scroll) clearAppRouterScrollIntent();
963
1013
  const appNavigate = getNavigationRuntime()?.functions.navigate;
964
1014
  try {
965
- if (appNavigate) await appNavigate(fullHref, 0, "navigate", mode, void 0, programmaticTransition, void 0, scrollIntent);
1015
+ if (appNavigate) await appNavigate(fullHref, 0, "navigate", mode, void 0, programmaticTransition, void 0, scrollIntent, visibleCommitMode);
966
1016
  else {
967
1017
  if (mode === "replace") replaceHistoryStateWithoutNotify(null, "", fullHref);
968
1018
  else pushHistoryStateWithoutNotify(null, "", fullHref);
@@ -1090,6 +1140,20 @@ const _appRouter = {
1090
1140
  });
1091
1141
  }
1092
1142
  };
1143
+ if (process.env.__NEXT_GESTURE_TRANSITION) _appRouter.experimental_gesturePush = (href, options) => {
1144
+ assertSafeNavigationUrl(href);
1145
+ if (isServer) return;
1146
+ if (!getNavigationRuntime()?.functions.navigate) return;
1147
+ let appHref = href;
1148
+ if (isAbsoluteOrProtocolRelativeUrl(href)) {
1149
+ const localPath = toSameOriginAppPath(href, __basePath);
1150
+ if (localPath === null) return;
1151
+ appHref = localPath;
1152
+ }
1153
+ const releaseNavigation = trackScheduledAppRouterNavigation();
1154
+ navigateClientSide(appHref, "push", options?.scroll !== false, false, "synchronous");
1155
+ releaseScheduledAppRouterNavigationAfterCurrentTask(releaseNavigation);
1156
+ };
1093
1157
  function formatPublicBfcacheId(value) {
1094
1158
  if (!value || value === "0") return PUBLIC_INITIAL_BFCACHE_ID;
1095
1159
  return value;
@@ -1512,6 +1576,9 @@ if (!isServer) {
1512
1576
  const state = getClientNavigationState();
1513
1577
  if (state && !state.patchInstalled) {
1514
1578
  state.patchInstalled = true;
1579
+ window.addEventListener("popstate", () => {
1580
+ getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
1581
+ });
1515
1582
  window.addEventListener("popstate", (event) => {
1516
1583
  if (!hasAppNavigationRuntime()) {
1517
1584
  commitClientNavigationState();
@@ -1520,13 +1587,19 @@ if (!isServer) {
1520
1587
  });
1521
1588
  window.history.pushState = function patchedPushState(data, unused, url) {
1522
1589
  state.originalPushState.call(window.history, createExternalHistoryStatePreservingMetadata(data, window.history.state), unused, url);
1523
- if (state.suppressUrlNotifyCount === 0) commitClientNavigationState();
1590
+ if (state.suppressUrlNotifyCount === 0) {
1591
+ getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
1592
+ commitClientNavigationState();
1593
+ }
1524
1594
  };
1525
1595
  window.history.replaceState = function patchedReplaceState(data, unused, url) {
1526
1596
  state.originalReplaceState.call(window.history, createExternalHistoryStatePreservingMetadata(data, window.history.state), unused, url);
1527
- if (state.suppressUrlNotifyCount === 0) commitClientNavigationState();
1597
+ if (state.suppressUrlNotifyCount === 0) {
1598
+ getNavigationRuntime()?.functions.notifyLinkNavigationStart?.();
1599
+ commitClientNavigationState();
1600
+ }
1528
1601
  };
1529
1602
  }
1530
1603
  }
1531
1604
  //#endregion
1532
- export { BailoutToCSRError, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, decodeRedirectError, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
1605
+ export { BailoutToCSRError, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
@@ -12,6 +12,7 @@ type SSRContext = {
12
12
  pathname: string;
13
13
  query: Record<string, string | string[]>;
14
14
  asPath: string;
15
+ navigationIsReady?: boolean;
15
16
  locale?: string;
16
17
  locales?: string[];
17
18
  defaultLocale?: string;
@@ -1,6 +1,7 @@
1
1
  import { getOrCreateAls } from "./internal/als-registry.js";
2
2
  import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
3
3
  import { _registerRouterStateAccessors } from "./router.js";
4
+ import { registerRoutePatternForWarningAccessor } from "./internal/route-pattern-for-warning.js";
4
5
  //#region src/shims/router-state.ts
5
6
  /**
6
7
  * Server-only Pages Router state backed by AsyncLocalStorage.
@@ -33,5 +34,6 @@ _registerRouterStateAccessors({
33
34
  _getState().ssrContext = ctx;
34
35
  }
35
36
  });
37
+ registerRoutePatternForWarningAccessor(() => _getState().ssrContext?.pathname ?? null);
36
38
  //#endregion
37
39
  export { runWithRouterState };
@@ -61,6 +61,8 @@ type SSRContext = {
61
61
  pathname: string;
62
62
  query: Record<string, string | string[]>;
63
63
  asPath: string;
64
+ navigationIsReady?: boolean;
65
+ nextData?: VinextNextData;
64
66
  locale?: string;
65
67
  locales?: string[];
66
68
  defaultLocale?: string;
@@ -84,9 +86,9 @@ declare function _registerRouterStateAccessors(accessors: {
84
86
  }): void;
85
87
  declare function setSSRContext(ctx: SSRContext | null): void;
86
88
  type PagesNavigationContextShape = {
87
- pathname: string;
89
+ pathname: string | null;
88
90
  searchParams: URLSearchParams;
89
- params: Record<string, string | string[]>;
91
+ params: Record<string, string | string[]> | null;
90
92
  };
91
93
  /**
92
94
  * Cross-router compat shim source for `next/navigation` hooks.
@@ -105,6 +107,7 @@ type PagesNavigationContextShape = {
105
107
  * treat null as "App Router context, use normal app-router state".
106
108
  */
107
109
  declare function getPagesNavigationContext(): PagesNavigationContextShape | null;
110
+ declare function getPagesNavigationIsReadyFromSerializedState(routePattern: string | undefined, searchString: string, nextData?: VinextNextData): boolean;
108
111
  /**
109
112
  * useRouter hook - Pages Router compatible.
110
113
  *
@@ -173,4 +176,4 @@ declare const RouterMethods: {
173
176
  };
174
177
  declare const Router: typeof RouterMethods & Omit<NextRouter, keyof typeof RouterMethods>;
175
178
  //#endregion
176
- export { ExcludeRouterProps, NextRouter, WithRouterProps, _registerRouterStateAccessors, applyNavigationLocale, Router as default, getPagesNavigationContext, isExternalUrl, isHashOnlyChange, setSSRContext, useRouter, withRouter, wrapWithRouterContext };
179
+ export { ExcludeRouterProps, NextRouter, WithRouterProps, _registerRouterStateAccessors, applyNavigationLocale, Router as default, getPagesNavigationContext, getPagesNavigationIsReadyFromSerializedState, isExternalUrl, isHashOnlyChange, setSSRContext, useRouter, withRouter, wrapWithRouterContext };