@qzsy/vinext 0.1.7

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 (803) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +773 -0
  3. package/dist/build/assets-ignore.d.ts +32 -0
  4. package/dist/build/assets-ignore.js +48 -0
  5. package/dist/build/clean-output.d.ts +13 -0
  6. package/dist/build/clean-output.js +34 -0
  7. package/dist/build/client-build-config.d.ts +171 -0
  8. package/dist/build/client-build-config.js +270 -0
  9. package/dist/build/css-url-assets.d.ts +29 -0
  10. package/dist/build/css-url-assets.js +213 -0
  11. package/dist/build/google-fonts/build-url.d.ts +9 -0
  12. package/dist/build/google-fonts/build-url.js +28 -0
  13. package/dist/build/google-fonts/fallback-metrics-data.js +14029 -0
  14. package/dist/build/google-fonts/fallback-metrics.d.ts +12 -0
  15. package/dist/build/google-fonts/fallback-metrics.js +44 -0
  16. package/dist/build/google-fonts/find-font-files-in-css.d.ts +16 -0
  17. package/dist/build/google-fonts/find-font-files-in-css.js +28 -0
  18. package/dist/build/google-fonts/font-data.js +24983 -0
  19. package/dist/build/google-fonts/font-metadata.d.ts +16 -0
  20. package/dist/build/google-fonts/font-metadata.js +5 -0
  21. package/dist/build/google-fonts/get-axes.d.ts +6 -0
  22. package/dist/build/google-fonts/get-axes.js +37 -0
  23. package/dist/build/google-fonts/sort-variants.d.ts +4 -0
  24. package/dist/build/google-fonts/sort-variants.js +12 -0
  25. package/dist/build/google-fonts/validate.d.ts +27 -0
  26. package/dist/build/google-fonts/validate.js +54 -0
  27. package/dist/build/inline-css.d.ts +6 -0
  28. package/dist/build/inline-css.js +48 -0
  29. package/dist/build/layout-classification-types.d.ts +61 -0
  30. package/dist/build/layout-classification-types.js +1 -0
  31. package/dist/build/layout-classification.d.ts +59 -0
  32. package/dist/build/layout-classification.js +98 -0
  33. package/dist/build/next-client-runtime-manifests.d.ts +14 -0
  34. package/dist/build/next-client-runtime-manifests.js +39 -0
  35. package/dist/build/nitro-route-rules.d.ts +49 -0
  36. package/dist/build/nitro-route-rules.js +79 -0
  37. package/dist/build/precompress.d.ts +27 -0
  38. package/dist/build/precompress.js +110 -0
  39. package/dist/build/prerender.d.ts +209 -0
  40. package/dist/build/prerender.js +932 -0
  41. package/dist/build/report.d.ts +132 -0
  42. package/dist/build/report.js +504 -0
  43. package/dist/build/route-classification-injector.d.ts +34 -0
  44. package/dist/build/route-classification-injector.js +59 -0
  45. package/dist/build/route-classification-manifest.d.ts +52 -0
  46. package/dist/build/route-classification-manifest.js +143 -0
  47. package/dist/build/run-prerender.d.ts +61 -0
  48. package/dist/build/run-prerender.js +224 -0
  49. package/dist/build/server-manifest.d.ts +18 -0
  50. package/dist/build/server-manifest.js +22 -0
  51. package/dist/build/ssr-manifest.d.ts +18 -0
  52. package/dist/build/ssr-manifest.js +69 -0
  53. package/dist/build/standalone.d.ts +31 -0
  54. package/dist/build/standalone.js +203 -0
  55. package/dist/build/static-export.d.ts +55 -0
  56. package/dist/build/static-export.js +60 -0
  57. package/dist/cache/cache-adapters-virtual.d.ts +50 -0
  58. package/dist/cache/cache-adapters-virtual.js +45 -0
  59. package/dist/cache.d.ts +2 -0
  60. package/dist/cache.js +2 -0
  61. package/dist/check.d.ts +87 -0
  62. package/dist/check.js +1037 -0
  63. package/dist/cli-args.d.ts +33 -0
  64. package/dist/cli-args.js +124 -0
  65. package/dist/cli.d.ts +1 -0
  66. package/dist/cli.js +744 -0
  67. package/dist/client/app-nav-failure-handler.d.ts +8 -0
  68. package/dist/client/app-nav-failure-handler.js +44 -0
  69. package/dist/client/empty-module.d.ts +1 -0
  70. package/dist/client/empty-module.js +1 -0
  71. package/dist/client/instrumentation-client-inject.d.ts +33 -0
  72. package/dist/client/instrumentation-client-inject.js +55 -0
  73. package/dist/client/instrumentation-client-state.d.ts +9 -0
  74. package/dist/client/instrumentation-client-state.js +17 -0
  75. package/dist/client/instrumentation-client.d.ts +7 -0
  76. package/dist/client/instrumentation-client.js +6 -0
  77. package/dist/client/navigation-runtime.d.ts +70 -0
  78. package/dist/client/navigation-runtime.js +169 -0
  79. package/dist/client/pages-router-link-navigation.d.ts +61 -0
  80. package/dist/client/pages-router-link-navigation.js +42 -0
  81. package/dist/client/validate-module-path.d.ts +17 -0
  82. package/dist/client/validate-module-path.js +24 -0
  83. package/dist/client/vinext-next-data.d.ts +44 -0
  84. package/dist/client/vinext-next-data.js +50 -0
  85. package/dist/client/window-next.d.ts +168 -0
  86. package/dist/client/window-next.js +57 -0
  87. package/dist/cloudflare/index.d.ts +3 -0
  88. package/dist/cloudflare/index.js +3 -0
  89. package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +102 -0
  90. package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +126 -0
  91. package/dist/cloudflare/src/cache/kv-data-adapter.runtime.js +435 -0
  92. package/dist/cloudflare/src/utils/cache-control-metadata.js +20 -0
  93. package/dist/cloudflare/tpr.d.ts +82 -0
  94. package/dist/cloudflare/tpr.js +558 -0
  95. package/dist/config/config-matchers.d.ts +257 -0
  96. package/dist/config/config-matchers.js +1046 -0
  97. package/dist/config/dotenv.d.ts +56 -0
  98. package/dist/config/dotenv.js +88 -0
  99. package/dist/config/next-config.d.ts +540 -0
  100. package/dist/config/next-config.js +1050 -0
  101. package/dist/config/tsconfig-paths.d.ts +21 -0
  102. package/dist/config/tsconfig-paths.js +157 -0
  103. package/dist/deploy.d.ts +190 -0
  104. package/dist/deploy.js +1033 -0
  105. package/dist/entries/app-browser-entry.d.ts +29 -0
  106. package/dist/entries/app-browser-entry.js +83 -0
  107. package/dist/entries/app-rsc-entry.d.ts +81 -0
  108. package/dist/entries/app-rsc-entry.js +943 -0
  109. package/dist/entries/app-rsc-manifest.d.ts +53 -0
  110. package/dist/entries/app-rsc-manifest.js +294 -0
  111. package/dist/entries/app-ssr-entry.d.ts +15 -0
  112. package/dist/entries/app-ssr-entry.js +24 -0
  113. package/dist/entries/pages-client-entry.d.ts +11 -0
  114. package/dist/entries/pages-client-entry.js +204 -0
  115. package/dist/entries/pages-entry-helpers.d.ts +2 -0
  116. package/dist/entries/pages-entry-helpers.js +2 -0
  117. package/dist/entries/pages-server-entry.d.ts +11 -0
  118. package/dist/entries/pages-server-entry.js +398 -0
  119. package/dist/entries/runtime-entry-module.d.ts +25 -0
  120. package/dist/entries/runtime-entry-module.js +46 -0
  121. package/dist/index.d.ts +115 -0
  122. package/dist/index.js +2661 -0
  123. package/dist/init.d.ts +69 -0
  124. package/dist/init.js +253 -0
  125. package/dist/plugins/ast-utils.d.ts +20 -0
  126. package/dist/plugins/ast-utils.js +78 -0
  127. package/dist/plugins/async-hooks-stub.d.ts +18 -0
  128. package/dist/plugins/async-hooks-stub.js +40 -0
  129. package/dist/plugins/client-reference-dedup.d.ts +35 -0
  130. package/dist/plugins/client-reference-dedup.js +189 -0
  131. package/dist/plugins/css-data-url.d.ts +6 -0
  132. package/dist/plugins/css-data-url.js +83 -0
  133. package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
  134. package/dist/plugins/dynamic-preload-metadata.js +413 -0
  135. package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
  136. package/dist/plugins/extensionless-dynamic-import.js +155 -0
  137. package/dist/plugins/fonts.d.ts +95 -0
  138. package/dist/plugins/fonts.js +711 -0
  139. package/dist/plugins/import-meta-url.d.ts +16 -0
  140. package/dist/plugins/import-meta-url.js +353 -0
  141. package/dist/plugins/instrumentation-client.d.ts +6 -0
  142. package/dist/plugins/instrumentation-client.js +27 -0
  143. package/dist/plugins/middleware-export-validation.d.ts +5 -0
  144. package/dist/plugins/middleware-export-validation.js +36 -0
  145. package/dist/plugins/middleware-server-only.d.ts +53 -0
  146. package/dist/plugins/middleware-server-only.js +90 -0
  147. package/dist/plugins/og-asset-ownership.d.ts +27 -0
  148. package/dist/plugins/og-asset-ownership.js +285 -0
  149. package/dist/plugins/og-assets.d.ts +50 -0
  150. package/dist/plugins/og-assets.js +229 -0
  151. package/dist/plugins/optimize-imports.d.ts +42 -0
  152. package/dist/plugins/optimize-imports.js +587 -0
  153. package/dist/plugins/postcss.d.ts +26 -0
  154. package/dist/plugins/postcss.js +96 -0
  155. package/dist/plugins/remove-console.d.ts +21 -0
  156. package/dist/plugins/remove-console.js +177 -0
  157. package/dist/plugins/require-context.d.ts +6 -0
  158. package/dist/plugins/require-context.js +185 -0
  159. package/dist/plugins/rsc-client-reference-loaders.d.ts +6 -0
  160. package/dist/plugins/rsc-client-reference-loaders.js +46 -0
  161. package/dist/plugins/rsc-client-shim-excludes.d.ts +6 -0
  162. package/dist/plugins/rsc-client-shim-excludes.js +35 -0
  163. package/dist/plugins/sass.d.ts +62 -0
  164. package/dist/plugins/sass.js +268 -0
  165. package/dist/plugins/server-externals-manifest.d.ts +26 -0
  166. package/dist/plugins/server-externals-manifest.js +81 -0
  167. package/dist/plugins/strip-server-exports.d.ts +21 -0
  168. package/dist/plugins/strip-server-exports.js +519 -0
  169. package/dist/plugins/typeof-window.d.ts +14 -0
  170. package/dist/plugins/typeof-window.js +150 -0
  171. package/dist/plugins/wasm-module-import.d.ts +15 -0
  172. package/dist/plugins/wasm-module-import.js +50 -0
  173. package/dist/routing/app-route-graph.d.ts +336 -0
  174. package/dist/routing/app-route-graph.js +1518 -0
  175. package/dist/routing/app-router.d.ts +30 -0
  176. package/dist/routing/app-router.js +59 -0
  177. package/dist/routing/file-matcher.d.ts +60 -0
  178. package/dist/routing/file-matcher.js +147 -0
  179. package/dist/routing/pages-router.d.ts +48 -0
  180. package/dist/routing/pages-router.js +163 -0
  181. package/dist/routing/route-matching.d.ts +27 -0
  182. package/dist/routing/route-matching.js +42 -0
  183. package/dist/routing/route-pattern.d.ts +64 -0
  184. package/dist/routing/route-pattern.js +165 -0
  185. package/dist/routing/route-trie.d.ts +67 -0
  186. package/dist/routing/route-trie.js +143 -0
  187. package/dist/routing/route-validation.d.ts +10 -0
  188. package/dist/routing/route-validation.js +101 -0
  189. package/dist/routing/utils.d.ts +117 -0
  190. package/dist/routing/utils.js +242 -0
  191. package/dist/server/accept-encoding.d.ts +29 -0
  192. package/dist/server/accept-encoding.js +95 -0
  193. package/dist/server/api-handler.d.ts +17 -0
  194. package/dist/server/api-handler.js +276 -0
  195. package/dist/server/app-action-request.d.ts +4 -0
  196. package/dist/server/app-action-request.js +9 -0
  197. package/dist/server/app-bfcache-id.d.ts +5 -0
  198. package/dist/server/app-bfcache-id.js +5 -0
  199. package/dist/server/app-bfcache-identity.d.ts +36 -0
  200. package/dist/server/app-bfcache-identity.js +156 -0
  201. package/dist/server/app-browser-action-result.d.ts +64 -0
  202. package/dist/server/app-browser-action-result.js +111 -0
  203. package/dist/server/app-browser-client-reuse-manifest.d.ts +12 -0
  204. package/dist/server/app-browser-client-reuse-manifest.js +101 -0
  205. package/dist/server/app-browser-entry.d.ts +1 -0
  206. package/dist/server/app-browser-entry.js +1087 -0
  207. package/dist/server/app-browser-error.d.ts +13 -0
  208. package/dist/server/app-browser-error.js +52 -0
  209. package/dist/server/app-browser-history-controller.d.ts +104 -0
  210. package/dist/server/app-browser-history-controller.js +210 -0
  211. package/dist/server/app-browser-hydration.d.ts +32 -0
  212. package/dist/server/app-browser-hydration.js +29 -0
  213. package/dist/server/app-browser-interception-context.d.ts +24 -0
  214. package/dist/server/app-browser-interception-context.js +43 -0
  215. package/dist/server/app-browser-mpa-navigation.d.ts +16 -0
  216. package/dist/server/app-browser-mpa-navigation.js +42 -0
  217. package/dist/server/app-browser-navigation-controller.d.ts +109 -0
  218. package/dist/server/app-browser-navigation-controller.js +465 -0
  219. package/dist/server/app-browser-popstate.d.ts +26 -0
  220. package/dist/server/app-browser-popstate.js +44 -0
  221. package/dist/server/app-browser-rsc-redirect.d.ts +38 -0
  222. package/dist/server/app-browser-rsc-redirect.js +64 -0
  223. package/dist/server/app-browser-server-action-client.d.ts +32 -0
  224. package/dist/server/app-browser-server-action-client.js +128 -0
  225. package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
  226. package/dist/server/app-browser-server-action-navigation.js +9 -0
  227. package/dist/server/app-browser-state.d.ts +140 -0
  228. package/dist/server/app-browser-state.js +315 -0
  229. package/dist/server/app-browser-stream.d.ts +28 -0
  230. package/dist/server/app-browser-stream.js +122 -0
  231. package/dist/server/app-browser-visible-commit.d.ts +78 -0
  232. package/dist/server/app-browser-visible-commit.js +241 -0
  233. package/dist/server/app-client-reference-preloader.d.ts +14 -0
  234. package/dist/server/app-client-reference-preloader.js +44 -0
  235. package/dist/server/app-elements-wire.d.ts +192 -0
  236. package/dist/server/app-elements-wire.js +443 -0
  237. package/dist/server/app-elements.d.ts +9 -0
  238. package/dist/server/app-elements.js +18 -0
  239. package/dist/server/app-fallback-renderer.d.ts +89 -0
  240. package/dist/server/app-fallback-renderer.js +136 -0
  241. package/dist/server/app-history-state.d.ts +85 -0
  242. package/dist/server/app-history-state.js +223 -0
  243. package/dist/server/app-hook-warning-suppression.d.ts +6 -0
  244. package/dist/server/app-hook-warning-suppression.js +10 -0
  245. package/dist/server/app-inline-css-client.d.ts +6 -0
  246. package/dist/server/app-inline-css-client.js +35 -0
  247. package/dist/server/app-interception-context-header.d.ts +32 -0
  248. package/dist/server/app-interception-context-header.js +42 -0
  249. package/dist/server/app-layout-param-observation.d.ts +43 -0
  250. package/dist/server/app-layout-param-observation.js +168 -0
  251. package/dist/server/app-middleware.d.ts +46 -0
  252. package/dist/server/app-middleware.js +168 -0
  253. package/dist/server/app-mounted-slots-header.d.ts +35 -0
  254. package/dist/server/app-mounted-slots-header.js +58 -0
  255. package/dist/server/app-optimistic-routing.d.ts +53 -0
  256. package/dist/server/app-optimistic-routing.js +227 -0
  257. package/dist/server/app-page-boundary-render.d.ts +85 -0
  258. package/dist/server/app-page-boundary-render.js +305 -0
  259. package/dist/server/app-page-boundary.d.ts +102 -0
  260. package/dist/server/app-page-boundary.js +120 -0
  261. package/dist/server/app-page-cache-finalizer.d.ts +62 -0
  262. package/dist/server/app-page-cache-finalizer.js +122 -0
  263. package/dist/server/app-page-cache-render.d.ts +53 -0
  264. package/dist/server/app-page-cache-render.js +91 -0
  265. package/dist/server/app-page-cache.d.ts +83 -0
  266. package/dist/server/app-page-cache.js +272 -0
  267. package/dist/server/app-page-dispatch.d.ts +223 -0
  268. package/dist/server/app-page-dispatch.js +610 -0
  269. package/dist/server/app-page-element-builder.d.ts +96 -0
  270. package/dist/server/app-page-element-builder.js +205 -0
  271. package/dist/server/app-page-execution.d.ts +138 -0
  272. package/dist/server/app-page-execution.js +328 -0
  273. package/dist/server/app-page-head.d.ts +65 -0
  274. package/dist/server/app-page-head.js +228 -0
  275. package/dist/server/app-page-method.d.ts +15 -0
  276. package/dist/server/app-page-method.js +25 -0
  277. package/dist/server/app-page-params.d.ts +8 -0
  278. package/dist/server/app-page-params.js +39 -0
  279. package/dist/server/app-page-ppr-runtime.d.ts +7 -0
  280. package/dist/server/app-page-ppr-runtime.js +70 -0
  281. package/dist/server/app-page-probe.d.ts +134 -0
  282. package/dist/server/app-page-probe.js +276 -0
  283. package/dist/server/app-page-render-identity.d.ts +21 -0
  284. package/dist/server/app-page-render-identity.js +40 -0
  285. package/dist/server/app-page-render-observation.d.ts +36 -0
  286. package/dist/server/app-page-render-observation.js +82 -0
  287. package/dist/server/app-page-render.d.ts +111 -0
  288. package/dist/server/app-page-render.js +602 -0
  289. package/dist/server/app-page-request.d.ts +137 -0
  290. package/dist/server/app-page-request.js +216 -0
  291. package/dist/server/app-page-response.d.ts +68 -0
  292. package/dist/server/app-page-response.js +120 -0
  293. package/dist/server/app-page-route-wiring.d.ts +151 -0
  294. package/dist/server/app-page-route-wiring.js +452 -0
  295. package/dist/server/app-page-search-params-observation.d.ts +10 -0
  296. package/dist/server/app-page-search-params-observation.js +20 -0
  297. package/dist/server/app-page-segment-state.d.ts +9 -0
  298. package/dist/server/app-page-segment-state.js +80 -0
  299. package/dist/server/app-page-stream.d.ts +151 -0
  300. package/dist/server/app-page-stream.js +143 -0
  301. package/dist/server/app-pages-bridge.d.ts +63 -0
  302. package/dist/server/app-pages-bridge.js +63 -0
  303. package/dist/server/app-post-middleware-context.d.ts +15 -0
  304. package/dist/server/app-post-middleware-context.js +26 -0
  305. package/dist/server/app-ppr-fallback-shell-render.d.ts +18 -0
  306. package/dist/server/app-ppr-fallback-shell-render.js +26 -0
  307. package/dist/server/app-ppr-fallback-shell.d.ts +33 -0
  308. package/dist/server/app-ppr-fallback-shell.js +89 -0
  309. package/dist/server/app-prerender-endpoints.d.ts +18 -0
  310. package/dist/server/app-prerender-endpoints.js +94 -0
  311. package/dist/server/app-prerender-static-params.d.ts +30 -0
  312. package/dist/server/app-prerender-static-params.js +81 -0
  313. package/dist/server/app-render-dependency.d.ts +14 -0
  314. package/dist/server/app-render-dependency.js +41 -0
  315. package/dist/server/app-request-context.d.ts +20 -0
  316. package/dist/server/app-request-context.js +29 -0
  317. package/dist/server/app-route-handler-cache.d.ts +46 -0
  318. package/dist/server/app-route-handler-cache.js +78 -0
  319. package/dist/server/app-route-handler-dispatch.d.ts +49 -0
  320. package/dist/server/app-route-handler-dispatch.js +163 -0
  321. package/dist/server/app-route-handler-execution.d.ts +86 -0
  322. package/dist/server/app-route-handler-execution.js +128 -0
  323. package/dist/server/app-route-handler-policy.d.ts +55 -0
  324. package/dist/server/app-route-handler-policy.js +58 -0
  325. package/dist/server/app-route-handler-response.d.ts +28 -0
  326. package/dist/server/app-route-handler-response.js +145 -0
  327. package/dist/server/app-route-handler-runtime.d.ts +39 -0
  328. package/dist/server/app-route-handler-runtime.js +250 -0
  329. package/dist/server/app-route-module-loader.d.ts +91 -0
  330. package/dist/server/app-route-module-loader.js +83 -0
  331. package/dist/server/app-router-entry.d.ts +13 -0
  332. package/dist/server/app-router-entry.js +49 -0
  333. package/dist/server/app-rsc-cache-busting.d.ts +64 -0
  334. package/dist/server/app-rsc-cache-busting.js +206 -0
  335. package/dist/server/app-rsc-embedded-chunks.d.ts +8 -0
  336. package/dist/server/app-rsc-embedded-chunks.js +32 -0
  337. package/dist/server/app-rsc-error-handler.d.ts +20 -0
  338. package/dist/server/app-rsc-error-handler.js +28 -0
  339. package/dist/server/app-rsc-errors.d.ts +40 -0
  340. package/dist/server/app-rsc-errors.js +60 -0
  341. package/dist/server/app-rsc-handler.d.ts +201 -0
  342. package/dist/server/app-rsc-handler.js +538 -0
  343. package/dist/server/app-rsc-render-mode.d.ts +11 -0
  344. package/dist/server/app-rsc-render-mode.js +25 -0
  345. package/dist/server/app-rsc-request-normalization.d.ts +48 -0
  346. package/dist/server/app-rsc-request-normalization.js +75 -0
  347. package/dist/server/app-rsc-response-finalizer.d.ts +37 -0
  348. package/dist/server/app-rsc-response-finalizer.js +54 -0
  349. package/dist/server/app-rsc-route-matching.d.ts +93 -0
  350. package/dist/server/app-rsc-route-matching.js +134 -0
  351. package/dist/server/app-segment-config.d.ts +46 -0
  352. package/dist/server/app-segment-config.js +113 -0
  353. package/dist/server/app-server-action-execution.d.ts +219 -0
  354. package/dist/server/app-server-action-execution.js +767 -0
  355. package/dist/server/app-ssr-entry.d.ts +52 -0
  356. package/dist/server/app-ssr-entry.js +295 -0
  357. package/dist/server/app-ssr-error-meta.d.ts +13 -0
  358. package/dist/server/app-ssr-error-meta.js +48 -0
  359. package/dist/server/app-ssr-router-instance.d.ts +6 -0
  360. package/dist/server/app-ssr-router-instance.js +24 -0
  361. package/dist/server/app-ssr-stream.d.ts +60 -0
  362. package/dist/server/app-ssr-stream.js +408 -0
  363. package/dist/server/app-static-generation.d.ts +15 -0
  364. package/dist/server/app-static-generation.js +19 -0
  365. package/dist/server/app-visited-response-cache.d.ts +23 -0
  366. package/dist/server/app-visited-response-cache.js +19 -0
  367. package/dist/server/artifact-compatibility.d.ts +54 -0
  368. package/dist/server/artifact-compatibility.js +91 -0
  369. package/dist/server/before-interactive-head.d.ts +17 -0
  370. package/dist/server/before-interactive-head.js +35 -0
  371. package/dist/server/cache-control.d.ts +37 -0
  372. package/dist/server/cache-control.js +56 -0
  373. package/dist/server/cache-headers.d.ts +6 -0
  374. package/dist/server/cache-headers.js +17 -0
  375. package/dist/server/cache-proof.d.ts +364 -0
  376. package/dist/server/cache-proof.js +794 -0
  377. package/dist/server/client-reuse-manifest.d.ts +104 -0
  378. package/dist/server/client-reuse-manifest.js +209 -0
  379. package/dist/server/client-trace-metadata.d.ts +30 -0
  380. package/dist/server/client-trace-metadata.js +81 -0
  381. package/dist/server/cookie-utils.d.ts +12 -0
  382. package/dist/server/cookie-utils.js +18 -0
  383. package/dist/server/csp.d.ts +10 -0
  384. package/dist/server/csp.js +41 -0
  385. package/dist/server/default-global-error-module.d.ts +19 -0
  386. package/dist/server/default-global-error-module.js +18 -0
  387. package/dist/server/default-not-found-module.d.ts +19 -0
  388. package/dist/server/default-not-found-module.js +18 -0
  389. package/dist/server/defer-until-stream-consumed.d.ts +7 -0
  390. package/dist/server/defer-until-stream-consumed.js +34 -0
  391. package/dist/server/dev-error-overlay-store.d.ts +39 -0
  392. package/dist/server/dev-error-overlay-store.js +86 -0
  393. package/dist/server/dev-error-overlay.d.ts +51 -0
  394. package/dist/server/dev-error-overlay.js +1341 -0
  395. package/dist/server/dev-initial-server-error.d.ts +9 -0
  396. package/dist/server/dev-initial-server-error.js +26 -0
  397. package/dist/server/dev-lockfile.d.ts +109 -0
  398. package/dist/server/dev-lockfile.js +179 -0
  399. package/dist/server/dev-module-runner.d.ts +30 -0
  400. package/dist/server/dev-module-runner.js +91 -0
  401. package/dist/server/dev-origin-check.d.ts +62 -0
  402. package/dist/server/dev-origin-check.js +156 -0
  403. package/dist/server/dev-route-files.d.ts +6 -0
  404. package/dist/server/dev-route-files.js +71 -0
  405. package/dist/server/dev-server.d.ts +58 -0
  406. package/dist/server/dev-server.js +1114 -0
  407. package/dist/server/dev-stack-sourcemap-endpoint.d.ts +4 -0
  408. package/dist/server/dev-stack-sourcemap-endpoint.js +4 -0
  409. package/dist/server/dev-stack-sourcemap.d.ts +43 -0
  410. package/dist/server/dev-stack-sourcemap.js +443 -0
  411. package/dist/server/document-initial-head.d.ts +6 -0
  412. package/dist/server/document-initial-head.js +33 -0
  413. package/dist/server/edge-api-runtime.d.ts +4 -0
  414. package/dist/server/edge-api-runtime.js +6 -0
  415. package/dist/server/file-based-metadata.d.ts +29 -0
  416. package/dist/server/file-based-metadata.js +401 -0
  417. package/dist/server/headers.d.ts +114 -0
  418. package/dist/server/headers.js +136 -0
  419. package/dist/server/html.d.ts +28 -0
  420. package/dist/server/html.js +41 -0
  421. package/dist/server/http-error-responses.d.ts +91 -0
  422. package/dist/server/http-error-responses.js +105 -0
  423. package/dist/server/hybrid-route-priority.d.ts +22 -0
  424. package/dist/server/hybrid-route-priority.js +33 -0
  425. package/dist/server/image-optimization.d.ts +130 -0
  426. package/dist/server/image-optimization.js +247 -0
  427. package/dist/server/implicit-tags.d.ts +6 -0
  428. package/dist/server/implicit-tags.js +44 -0
  429. package/dist/server/instrumentation-runtime.d.ts +49 -0
  430. package/dist/server/instrumentation-runtime.js +35 -0
  431. package/dist/server/instrumentation.d.ts +85 -0
  432. package/dist/server/instrumentation.js +130 -0
  433. package/dist/server/isr-cache.d.ts +127 -0
  434. package/dist/server/isr-cache.js +282 -0
  435. package/dist/server/isr-decision.d.ts +79 -0
  436. package/dist/server/isr-decision.js +70 -0
  437. package/dist/server/metadata-route-build-data.d.ts +24 -0
  438. package/dist/server/metadata-route-build-data.js +148 -0
  439. package/dist/server/metadata-route-response.d.ts +16 -0
  440. package/dist/server/metadata-route-response.js +205 -0
  441. package/dist/server/metadata-routes.d.ts +139 -0
  442. package/dist/server/metadata-routes.js +433 -0
  443. package/dist/server/middleware-matcher.d.ts +14 -0
  444. package/dist/server/middleware-matcher.js +111 -0
  445. package/dist/server/middleware-request-headers.d.ts +11 -0
  446. package/dist/server/middleware-request-headers.js +65 -0
  447. package/dist/server/middleware-response-headers.d.ts +12 -0
  448. package/dist/server/middleware-response-headers.js +42 -0
  449. package/dist/server/middleware-runtime.d.ts +67 -0
  450. package/dist/server/middleware-runtime.js +240 -0
  451. package/dist/server/middleware.d.ts +62 -0
  452. package/dist/server/middleware.js +114 -0
  453. package/dist/server/navigation-planner.d.ts +308 -0
  454. package/dist/server/navigation-planner.js +831 -0
  455. package/dist/server/navigation-trace.d.ts +68 -0
  456. package/dist/server/navigation-trace.js +71 -0
  457. package/dist/server/next-error-digest.d.ts +44 -0
  458. package/dist/server/next-error-digest.js +40 -0
  459. package/dist/server/normalize-path.d.ts +38 -0
  460. package/dist/server/normalize-path.js +70 -0
  461. package/dist/server/open-redirect.d.ts +12 -0
  462. package/dist/server/open-redirect.js +21 -0
  463. package/dist/server/operation-token.d.ts +40 -0
  464. package/dist/server/operation-token.js +85 -0
  465. package/dist/server/otel-tracer-extension.d.ts +45 -0
  466. package/dist/server/otel-tracer-extension.js +89 -0
  467. package/dist/server/pages-api-route.d.ts +83 -0
  468. package/dist/server/pages-api-route.js +75 -0
  469. package/dist/server/pages-asset-tags.d.ts +78 -0
  470. package/dist/server/pages-asset-tags.js +126 -0
  471. package/dist/server/pages-body-parser-config.d.ts +59 -0
  472. package/dist/server/pages-body-parser-config.js +77 -0
  473. package/dist/server/pages-data-route.d.ts +121 -0
  474. package/dist/server/pages-data-route.js +157 -0
  475. package/dist/server/pages-default-404.d.ts +30 -0
  476. package/dist/server/pages-default-404.js +38 -0
  477. package/dist/server/pages-dev-module-url.d.ts +4 -0
  478. package/dist/server/pages-dev-module-url.js +15 -0
  479. package/dist/server/pages-document-initial-props.d.ts +77 -0
  480. package/dist/server/pages-document-initial-props.js +109 -0
  481. package/dist/server/pages-get-initial-props.d.ts +67 -0
  482. package/dist/server/pages-get-initial-props.js +92 -0
  483. package/dist/server/pages-i18n.d.ts +106 -0
  484. package/dist/server/pages-i18n.js +183 -0
  485. package/dist/server/pages-media-type.d.ts +15 -0
  486. package/dist/server/pages-media-type.js +24 -0
  487. package/dist/server/pages-node-compat.d.ts +55 -0
  488. package/dist/server/pages-node-compat.js +235 -0
  489. package/dist/server/pages-page-data.d.ts +223 -0
  490. package/dist/server/pages-page-data.js +484 -0
  491. package/dist/server/pages-page-handler.d.ts +100 -0
  492. package/dist/server/pages-page-handler.js +403 -0
  493. package/dist/server/pages-page-method.d.ts +47 -0
  494. package/dist/server/pages-page-method.js +17 -0
  495. package/dist/server/pages-page-response.d.ts +138 -0
  496. package/dist/server/pages-page-response.js +285 -0
  497. package/dist/server/pages-readiness.d.ts +36 -0
  498. package/dist/server/pages-readiness.js +21 -0
  499. package/dist/server/pages-request-pipeline.d.ts +116 -0
  500. package/dist/server/pages-request-pipeline.js +311 -0
  501. package/dist/server/pages-revalidate.d.ts +15 -0
  502. package/dist/server/pages-revalidate.js +19 -0
  503. package/dist/server/pages-serializable-props.d.ts +24 -0
  504. package/dist/server/pages-serializable-props.js +67 -0
  505. package/dist/server/pregenerated-concrete-paths.d.ts +16 -0
  506. package/dist/server/pregenerated-concrete-paths.js +61 -0
  507. package/dist/server/prerender-manifest.d.ts +33 -0
  508. package/dist/server/prerender-manifest.js +54 -0
  509. package/dist/server/prerender-route-params.d.ts +23 -0
  510. package/dist/server/prerender-route-params.js +113 -0
  511. package/dist/server/prerender-work-unit-setup.d.ts +6 -0
  512. package/dist/server/prerender-work-unit-setup.js +28 -0
  513. package/dist/server/prod-server.d.ts +148 -0
  514. package/dist/server/prod-server.js +1136 -0
  515. package/dist/server/proxy-trust.d.ts +40 -0
  516. package/dist/server/proxy-trust.js +68 -0
  517. package/dist/server/request-log.d.ts +39 -0
  518. package/dist/server/request-log.js +56 -0
  519. package/dist/server/request-pipeline.d.ts +187 -0
  520. package/dist/server/request-pipeline.js +447 -0
  521. package/dist/server/rsc-stream-hints.d.ts +10 -0
  522. package/dist/server/rsc-stream-hints.js +41 -0
  523. package/dist/server/seed-cache.d.ts +29 -0
  524. package/dist/server/seed-cache.js +125 -0
  525. package/dist/server/server-action-not-found.d.ts +21 -0
  526. package/dist/server/server-action-not-found.js +62 -0
  527. package/dist/server/server-globals.d.ts +4 -0
  528. package/dist/server/server-globals.js +35 -0
  529. package/dist/server/skip-cache-proof.d.ts +61 -0
  530. package/dist/server/skip-cache-proof.js +168 -0
  531. package/dist/server/socket-error-backstop.d.ts +34 -0
  532. package/dist/server/socket-error-backstop.js +200 -0
  533. package/dist/server/static-file-cache.d.ts +56 -0
  534. package/dist/server/static-file-cache.js +231 -0
  535. package/dist/server/static-layout-client-reuse-proof.d.ts +15 -0
  536. package/dist/server/static-layout-client-reuse-proof.js +33 -0
  537. package/dist/server/streaming-metadata.d.ts +4 -0
  538. package/dist/server/streaming-metadata.js +8 -0
  539. package/dist/server/worker-utils.d.ts +7 -0
  540. package/dist/server/worker-utils.js +99 -0
  541. package/dist/shims/amp.d.ts +19 -0
  542. package/dist/shims/amp.js +23 -0
  543. package/dist/shims/app-router-scroll-state.d.ts +15 -0
  544. package/dist/shims/app-router-scroll-state.js +61 -0
  545. package/dist/shims/app-router-scroll.d.ts +29 -0
  546. package/dist/shims/app-router-scroll.js +141 -0
  547. package/dist/shims/app.d.ts +42 -0
  548. package/dist/shims/app.js +48 -0
  549. package/dist/shims/before-interactive-context.d.ts +40 -0
  550. package/dist/shims/before-interactive-context.js +8 -0
  551. package/dist/shims/cache-for-request.d.ts +57 -0
  552. package/dist/shims/cache-for-request.js +72 -0
  553. package/dist/shims/cache-handler.d.ts +106 -0
  554. package/dist/shims/cache-handler.js +176 -0
  555. package/dist/shims/cache-request-state.d.ts +47 -0
  556. package/dist/shims/cache-request-state.js +126 -0
  557. package/dist/shims/cache-runtime.d.ts +83 -0
  558. package/dist/shims/cache-runtime.js +452 -0
  559. package/dist/shims/cache.d.ts +145 -0
  560. package/dist/shims/cache.js +401 -0
  561. package/dist/shims/cdn-cache.d.ts +125 -0
  562. package/dist/shims/cdn-cache.js +100 -0
  563. package/dist/shims/client-hook-error.d.ts +13 -0
  564. package/dist/shims/client-hook-error.js +17 -0
  565. package/dist/shims/client-locale.d.ts +14 -0
  566. package/dist/shims/client-locale.js +11 -0
  567. package/dist/shims/client-only.d.ts +1 -0
  568. package/dist/shims/client-only.js +1 -0
  569. package/dist/shims/compat-router.d.ts +16 -0
  570. package/dist/shims/compat-router.js +25 -0
  571. package/dist/shims/config.d.ts +28 -0
  572. package/dist/shims/config.js +21 -0
  573. package/dist/shims/constants.d.ts +130 -0
  574. package/dist/shims/constants.js +167 -0
  575. package/dist/shims/default-global-error.d.ts +31 -0
  576. package/dist/shims/default-global-error.js +179 -0
  577. package/dist/shims/default-not-found.d.ts +11 -0
  578. package/dist/shims/default-not-found.js +59 -0
  579. package/dist/shims/document.d.ts +92 -0
  580. package/dist/shims/document.js +76 -0
  581. package/dist/shims/dynamic-preload-chunks.d.ts +8 -0
  582. package/dist/shims/dynamic-preload-chunks.js +79 -0
  583. package/dist/shims/dynamic.d.ts +35 -0
  584. package/dist/shims/dynamic.js +204 -0
  585. package/dist/shims/error-boundary-navigation.d.ts +7 -0
  586. package/dist/shims/error-boundary-navigation.js +44 -0
  587. package/dist/shims/error-boundary.d.ts +155 -0
  588. package/dist/shims/error-boundary.js +342 -0
  589. package/dist/shims/error.d.ts +31 -0
  590. package/dist/shims/error.js +123 -0
  591. package/dist/shims/error.react-server.d.ts +9 -0
  592. package/dist/shims/error.react-server.js +6 -0
  593. package/dist/shims/fetch-cache.d.ts +136 -0
  594. package/dist/shims/fetch-cache.js +766 -0
  595. package/dist/shims/font-google-base.d.ts +83 -0
  596. package/dist/shims/font-google-base.js +290 -0
  597. package/dist/shims/font-google.d.ts +2 -0
  598. package/dist/shims/font-google.js +2 -0
  599. package/dist/shims/font-local.d.ts +50 -0
  600. package/dist/shims/font-local.js +195 -0
  601. package/dist/shims/font-utils.d.ts +56 -0
  602. package/dist/shims/font-utils.js +107 -0
  603. package/dist/shims/form.d.ts +19 -0
  604. package/dist/shims/form.js +236 -0
  605. package/dist/shims/hash-scroll.d.ts +10 -0
  606. package/dist/shims/hash-scroll.js +47 -0
  607. package/dist/shims/head-state.d.ts +16 -0
  608. package/dist/shims/head-state.js +43 -0
  609. package/dist/shims/head.d.ts +73 -0
  610. package/dist/shims/head.js +340 -0
  611. package/dist/shims/headers.d.ts +253 -0
  612. package/dist/shims/headers.js +754 -0
  613. package/dist/shims/i18n-context.d.ts +22 -0
  614. package/dist/shims/i18n-context.js +42 -0
  615. package/dist/shims/i18n-state.d.ts +14 -0
  616. package/dist/shims/i18n-state.js +38 -0
  617. package/dist/shims/image-config.d.ts +45 -0
  618. package/dist/shims/image-config.js +85 -0
  619. package/dist/shims/image.d.ts +55 -0
  620. package/dist/shims/image.js +582 -0
  621. package/dist/shims/internal/als-registry.d.ts +14 -0
  622. package/dist/shims/internal/als-registry.js +80 -0
  623. package/dist/shims/internal/api-utils.d.ts +14 -0
  624. package/dist/shims/internal/api-utils.js +1 -0
  625. package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
  626. package/dist/shims/internal/app-page-props-cache-key.js +16 -0
  627. package/dist/shims/internal/app-route-detection.d.ts +39 -0
  628. package/dist/shims/internal/app-route-detection.js +62 -0
  629. package/dist/shims/internal/app-router-context.d.ts +31 -0
  630. package/dist/shims/internal/app-router-context.js +28 -0
  631. package/dist/shims/internal/cookie-serialize.d.ts +45 -0
  632. package/dist/shims/internal/cookie-serialize.js +49 -0
  633. package/dist/shims/internal/cookies.d.ts +2 -0
  634. package/dist/shims/internal/cookies.js +2 -0
  635. package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
  636. package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
  637. package/dist/shims/internal/interpolate-as.d.ts +25 -0
  638. package/dist/shims/internal/interpolate-as.js +196 -0
  639. package/dist/shims/internal/link-status-registry.d.ts +43 -0
  640. package/dist/shims/internal/link-status-registry.js +42 -0
  641. package/dist/shims/internal/make-hanging-promise.d.ts +15 -0
  642. package/dist/shims/internal/make-hanging-promise.js +44 -0
  643. package/dist/shims/internal/navigation-untracked.d.ts +35 -0
  644. package/dist/shims/internal/navigation-untracked.js +56 -0
  645. package/dist/shims/internal/pages-data-fetch-dedup.d.ts +54 -0
  646. package/dist/shims/internal/pages-data-fetch-dedup.js +121 -0
  647. package/dist/shims/internal/pages-data-target.d.ts +62 -0
  648. package/dist/shims/internal/pages-data-target.js +98 -0
  649. package/dist/shims/internal/pages-data-url.d.ts +41 -0
  650. package/dist/shims/internal/pages-data-url.js +71 -0
  651. package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
  652. package/dist/shims/internal/pages-router-accessor.js +13 -0
  653. package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
  654. package/dist/shims/internal/route-pattern-for-warning.js +40 -0
  655. package/dist/shims/internal/router-context.d.ts +7 -0
  656. package/dist/shims/internal/router-context.js +13 -0
  657. package/dist/shims/internal/utils.d.ts +52 -0
  658. package/dist/shims/internal/utils.js +27 -0
  659. package/dist/shims/internal/work-unit-async-storage.d.ts +30 -0
  660. package/dist/shims/internal/work-unit-async-storage.js +17 -0
  661. package/dist/shims/layout-segment-context.d.ts +24 -0
  662. package/dist/shims/layout-segment-context.js +39 -0
  663. package/dist/shims/legacy-image.d.ts +41 -0
  664. package/dist/shims/legacy-image.js +49 -0
  665. package/dist/shims/link-prefetch.d.ts +41 -0
  666. package/dist/shims/link-prefetch.js +43 -0
  667. package/dist/shims/link.d.ts +102 -0
  668. package/dist/shims/link.js +687 -0
  669. package/dist/shims/metadata.d.ts +285 -0
  670. package/dist/shims/metadata.js +820 -0
  671. package/dist/shims/navigation-context-state.d.ts +40 -0
  672. package/dist/shims/navigation-context-state.js +116 -0
  673. package/dist/shims/navigation-errors.d.ts +55 -0
  674. package/dist/shims/navigation-errors.js +110 -0
  675. package/dist/shims/navigation-server.d.ts +3 -0
  676. package/dist/shims/navigation-server.js +3 -0
  677. package/dist/shims/navigation-state.d.ts +25 -0
  678. package/dist/shims/navigation-state.js +66 -0
  679. package/dist/shims/navigation.d.ts +286 -0
  680. package/dist/shims/navigation.js +1206 -0
  681. package/dist/shims/navigation.react-server.d.ts +14 -0
  682. package/dist/shims/navigation.react-server.js +32 -0
  683. package/dist/shims/offline.d.ts +4 -0
  684. package/dist/shims/offline.js +15 -0
  685. package/dist/shims/og.d.ts +17 -0
  686. package/dist/shims/og.js +48 -0
  687. package/dist/shims/pages-router-runtime.d.ts +12 -0
  688. package/dist/shims/pages-router-runtime.js +24 -0
  689. package/dist/shims/ppr-fallback-shell.d.ts +33 -0
  690. package/dist/shims/ppr-fallback-shell.js +170 -0
  691. package/dist/shims/readonly-url-search-params.d.ts +13 -0
  692. package/dist/shims/readonly-url-search-params.js +26 -0
  693. package/dist/shims/request-context.d.ts +58 -0
  694. package/dist/shims/request-context.js +45 -0
  695. package/dist/shims/request-state-types.d.ts +12 -0
  696. package/dist/shims/request-state-types.js +1 -0
  697. package/dist/shims/root-params.d.ts +12 -0
  698. package/dist/shims/root-params.js +30 -0
  699. package/dist/shims/router-state.d.ts +32 -0
  700. package/dist/shims/router-state.js +39 -0
  701. package/dist/shims/router.d.ts +192 -0
  702. package/dist/shims/router.js +1786 -0
  703. package/dist/shims/script-nonce-context.d.ts +11 -0
  704. package/dist/shims/script-nonce-context.js +23 -0
  705. package/dist/shims/script.d.ts +43 -0
  706. package/dist/shims/script.js +370 -0
  707. package/dist/shims/server-only.d.ts +1 -0
  708. package/dist/shims/server-only.js +1 -0
  709. package/dist/shims/server.d.ts +323 -0
  710. package/dist/shims/server.js +729 -0
  711. package/dist/shims/slot.d.ts +45 -0
  712. package/dist/shims/slot.js +230 -0
  713. package/dist/shims/thenable-params.d.ts +11 -0
  714. package/dist/shims/thenable-params.js +176 -0
  715. package/dist/shims/unified-request-context.d.ts +68 -0
  716. package/dist/shims/unified-request-context.js +86 -0
  717. package/dist/shims/unrecognized-action-error.d.ts +34 -0
  718. package/dist/shims/unrecognized-action-error.js +39 -0
  719. package/dist/shims/url-safety.d.ts +34 -0
  720. package/dist/shims/url-safety.js +70 -0
  721. package/dist/shims/url-utils.d.ts +51 -0
  722. package/dist/shims/url-utils.js +156 -0
  723. package/dist/shims/use-merged-ref.d.ts +6 -0
  724. package/dist/shims/use-merged-ref.js +38 -0
  725. package/dist/shims/web-vitals.d.ts +8 -0
  726. package/dist/shims/web-vitals.js +22 -0
  727. package/dist/typegen.d.ts +9 -0
  728. package/dist/typegen.js +228 -0
  729. package/dist/utils/asset-prefix.d.ts +96 -0
  730. package/dist/utils/asset-prefix.js +122 -0
  731. package/dist/utils/base-path.d.ts +31 -0
  732. package/dist/utils/base-path.js +45 -0
  733. package/dist/utils/built-asset-url.d.ts +4 -0
  734. package/dist/utils/built-asset-url.js +11 -0
  735. package/dist/utils/cache-control-metadata.d.ts +4 -0
  736. package/dist/utils/cache-control-metadata.js +12 -0
  737. package/dist/utils/client-build-manifest.d.ts +21 -0
  738. package/dist/utils/client-build-manifest.js +87 -0
  739. package/dist/utils/client-entry-manifest.d.ts +11 -0
  740. package/dist/utils/client-entry-manifest.js +29 -0
  741. package/dist/utils/client-runtime-metadata.d.ts +45 -0
  742. package/dist/utils/client-runtime-metadata.js +63 -0
  743. package/dist/utils/commonjs-loader.d.ts +16 -0
  744. package/dist/utils/commonjs-loader.js +100 -0
  745. package/dist/utils/compare.d.ts +4 -0
  746. package/dist/utils/compare.js +8 -0
  747. package/dist/utils/deployment-id.d.ts +8 -0
  748. package/dist/utils/deployment-id.js +22 -0
  749. package/dist/utils/dev-error-recovery-event.d.ts +4 -0
  750. package/dist/utils/dev-error-recovery-event.js +4 -0
  751. package/dist/utils/domain-locale.d.ts +26 -0
  752. package/dist/utils/domain-locale.js +50 -0
  753. package/dist/utils/encode-cache-tag.d.ts +30 -0
  754. package/dist/utils/encode-cache-tag.js +36 -0
  755. package/dist/utils/error-cause.d.ts +4 -0
  756. package/dist/utils/error-cause.js +95 -0
  757. package/dist/utils/has-trailing-comma.d.ts +24 -0
  758. package/dist/utils/has-trailing-comma.js +62 -0
  759. package/dist/utils/hash.d.ts +24 -0
  760. package/dist/utils/hash.js +55 -0
  761. package/dist/utils/html-limited-bots.d.ts +21 -0
  762. package/dist/utils/html-limited-bots.js +35 -0
  763. package/dist/utils/lazy-chunks.d.ts +59 -0
  764. package/dist/utils/lazy-chunks.js +112 -0
  765. package/dist/utils/manifest-paths.d.ts +30 -0
  766. package/dist/utils/manifest-paths.js +66 -0
  767. package/dist/utils/mdx-scan.d.ts +9 -0
  768. package/dist/utils/mdx-scan.js +34 -0
  769. package/dist/utils/navigation-signal.d.ts +4 -0
  770. package/dist/utils/navigation-signal.js +12 -0
  771. package/dist/utils/number.d.ts +4 -0
  772. package/dist/utils/number.js +6 -0
  773. package/dist/utils/parse-cookie.d.ts +13 -0
  774. package/dist/utils/parse-cookie.js +52 -0
  775. package/dist/utils/path.d.ts +22 -0
  776. package/dist/utils/path.js +30 -0
  777. package/dist/utils/prerender-output-paths.d.ts +14 -0
  778. package/dist/utils/prerender-output-paths.js +22 -0
  779. package/dist/utils/project.d.ts +76 -0
  780. package/dist/utils/project.js +213 -0
  781. package/dist/utils/promise.d.ts +4 -0
  782. package/dist/utils/promise.js +6 -0
  783. package/dist/utils/public-routes.d.ts +4 -0
  784. package/dist/utils/public-routes.js +48 -0
  785. package/dist/utils/query.d.ts +49 -0
  786. package/dist/utils/query.js +122 -0
  787. package/dist/utils/record.d.ts +4 -0
  788. package/dist/utils/record.js +6 -0
  789. package/dist/utils/regex.d.ts +4 -0
  790. package/dist/utils/regex.js +6 -0
  791. package/dist/utils/safe-json-file.d.ts +17 -0
  792. package/dist/utils/safe-json-file.js +23 -0
  793. package/dist/utils/sorted-array.d.ts +8 -0
  794. package/dist/utils/sorted-array.js +20 -0
  795. package/dist/utils/text-stream.d.ts +28 -0
  796. package/dist/utils/text-stream.js +64 -0
  797. package/dist/utils/vinext-root.d.ts +23 -0
  798. package/dist/utils/vinext-root.js +29 -0
  799. package/dist/utils/virtual-module.d.ts +5 -0
  800. package/dist/utils/virtual-module.js +0 -0
  801. package/dist/utils/vite-version.d.ts +21 -0
  802. package/dist/utils/vite-version.js +42 -0
  803. package/package.json +145 -0
@@ -0,0 +1,1786 @@
1
+ import { splitPathSegments } from "../routing/utils.js";
2
+ import { removeTrailingSlash, stripBasePath } from "../utils/base-path.js";
3
+ import { assertSafeNavigationUrl } from "./url-safety.js";
4
+ import { fillRoutePatternSegments, matchRoutePattern, routePatternParts } from "../routing/route-pattern.js";
5
+ import { isUnknownRecord } from "../utils/record.js";
6
+ import { AppRouterContext } from "./internal/app-router-context.js";
7
+ import { RouterContext } from "./internal/router-context.js";
8
+ import { applyVinextLocaleGlobals, extractVinextNextDataJson, parseVinextNextDataJson } from "../client/vinext-next-data.js";
9
+ import { isValidModulePath } from "../client/validate-module-path.js";
10
+ import { addLocalePrefix, getDomainLocaleUrl, getLocalePathPrefix } from "../utils/domain-locale.js";
11
+ import { buildPagesDataHref } from "./internal/pages-data-url.js";
12
+ import { NEXT_DEPLOYMENT_ID_HEADER, getDeploymentId } from "../utils/deployment-id.js";
13
+ import { dedupedPagesDataFetch } from "./internal/pages-data-fetch-dedup.js";
14
+ import { prefetchPagesData, resolvePagesDataNavigationTarget } from "./internal/pages-data-target.js";
15
+ import { addQueryParam, appendSearchParamsToUrl, mergeRouteParamsIntoQuery, parseQueryString, urlQueryToSearchParams } from "../utils/query.js";
16
+ import { resolveHybridClientRouteOwner } from "./internal/hybrid-client-route-owner.js";
17
+ import { getPagesRouterComponentsMap, markAppRouteDetectedOnPrefetch } from "./internal/app-route-detection.js";
18
+ import { installWindowNext } from "../client/window-next.js";
19
+ import { getWindowOrigin, isAbsoluteOrProtocolRelativeUrl, isHashOnlyBrowserUrlChange, normalizePathTrailingSlash, toBrowserNavigationHref, toSameOriginAppPath, withBasePath } from "./url-utils.js";
20
+ import { scrollToHashTarget } from "./hash-scroll.js";
21
+ import { installPagesRouterRuntime, setPagesRouterPopStateHandler, setStampInitialHistoryState } from "./pages-router-runtime.js";
22
+ import { interpolateDynamicRouteHref } from "./internal/interpolate-as.js";
23
+ import { getCurrentBrowserLocale } from "./client-locale.js";
24
+ import { Component, Fragment, createElement, useContext, useEffect, useLayoutEffect, useMemo, useState } from "react";
25
+ //#region src/shims/router.ts
26
+ /**
27
+ * next/router shim
28
+ *
29
+ * Provides useRouter() hook and Router singleton for Pages Router.
30
+ * Backed by the browser History API. Supports client-side navigation
31
+ * by fetching new page data and re-rendering the React root.
32
+ */
33
+ /** basePath from next.config.js, injected by the plugin at build time */
34
+ const __basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
35
+ /** trailingSlash from next.config.js, injected by the plugin at build time */
36
+ const __trailingSlash = process.env.__VINEXT_TRAILING_SLASH === "true";
37
+ /** experimental.scrollRestoration from next.config.js, injected by the plugin at build time */
38
+ const __scrollRestoration = process.env.__NEXT_SCROLL_RESTORATION === "true";
39
+ const noopCommit = () => {};
40
+ const SCROLL_RESTORE_MAX_FRAMES = 60;
41
+ const SCROLL_RESTORE_TOLERANCE_PX = 1;
42
+ /**
43
+ * A version of useLayoutEffect that doesn't warn during SSR.
44
+ * `wrapWithRouterContext` is shared with the server-side Pages Router render
45
+ * path, where a raw useLayoutEffect would log React's "useLayoutEffect does
46
+ * nothing on the server" warning on every render. Same pattern as
47
+ * `shims/image.tsx`; Next.js only runs the commit callback on the client.
48
+ */
49
+ const useNonWarningLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
50
+ var PagesRouterCommitBoundary = class extends Component {
51
+ componentDidCatch(error) {
52
+ this.props.onError(error);
53
+ }
54
+ render() {
55
+ return createElement(PagesRouterCommitBoundaryHelper, { onCommit: this.props.onCommit }, this.props.children);
56
+ }
57
+ };
58
+ function PagesRouterCommitBoundaryHelper({ children, onCommit }) {
59
+ useNonWarningLayoutEffect(() => {
60
+ onCommit();
61
+ }, [onCommit]);
62
+ return createElement(Fragment, null, children);
63
+ }
64
+ function renderPagesRouterElement(element, scroll) {
65
+ const root = window.__VINEXT_ROOT__;
66
+ if (!root) return Promise.resolve();
67
+ cancelPreviousRenderCommit();
68
+ return new Promise((resolve, reject) => {
69
+ const cancel = () => {
70
+ if (routerRuntimeState.cancelPendingRenderCommit === cancel) routerRuntimeState.cancelPendingRenderCommit = null;
71
+ reject(new NavigationCancelledError("superseded"));
72
+ };
73
+ routerRuntimeState.cancelPendingRenderCommit = cancel;
74
+ const clearIfCurrent = () => {
75
+ if (routerRuntimeState.cancelPendingRenderCommit === cancel) routerRuntimeState.cancelPendingRenderCommit = null;
76
+ };
77
+ const isCurrent = () => routerRuntimeState.cancelPendingRenderCommit === cancel;
78
+ const scrollHandler = async () => {
79
+ if (scroll) await restorePagesRouterScrollPosition(scroll, isCurrent);
80
+ };
81
+ root.render(wrapWithRouterContext(element, () => {
82
+ (async () => {
83
+ if (!isCurrent()) return;
84
+ try {
85
+ await scrollHandler();
86
+ if (!isCurrent()) return;
87
+ clearIfCurrent();
88
+ resolve();
89
+ } catch (err) {
90
+ clearIfCurrent();
91
+ reject(err);
92
+ }
93
+ })();
94
+ }, (error) => {
95
+ clearIfCurrent();
96
+ reject(error);
97
+ }));
98
+ if (!hasBrowserDocument()) {
99
+ clearIfCurrent();
100
+ resolve();
101
+ }
102
+ });
103
+ }
104
+ function hasBrowserDocument() {
105
+ return typeof document !== "undefined" && document.documentElement !== void 0;
106
+ }
107
+ async function restorePagesRouterScrollPosition(scroll, shouldContinue) {
108
+ if (!shouldContinue()) return;
109
+ scrollToPagesRouterPosition(scroll);
110
+ if (isAtScrollPosition(scroll)) return;
111
+ let previousScrollPosition = getWindowScrollPosition();
112
+ for (let frame = 0; frame < SCROLL_RESTORE_MAX_FRAMES; frame += 1) {
113
+ await waitForNextAnimationFrame();
114
+ if (!shouldContinue()) return;
115
+ scrollToPagesRouterPosition(scroll);
116
+ if (isAtScrollPosition(scroll)) return;
117
+ const currentScrollPosition = getWindowScrollPosition();
118
+ if (currentScrollPosition.x === previousScrollPosition.x && currentScrollPosition.y === previousScrollPosition.y) break;
119
+ previousScrollPosition = currentScrollPosition;
120
+ }
121
+ }
122
+ function scrollToPagesRouterPosition({ x, y }) {
123
+ if (!hasBrowserDocument()) {
124
+ window.scrollTo(x, y);
125
+ return;
126
+ }
127
+ const htmlElement = document.documentElement;
128
+ if (!(htmlElement.dataset.scrollBehavior === "smooth")) {
129
+ window.scrollTo(x, y);
130
+ return;
131
+ }
132
+ const previousScrollBehavior = htmlElement.style.scrollBehavior;
133
+ htmlElement.style.scrollBehavior = "auto";
134
+ htmlElement.getClientRects();
135
+ window.scrollTo(x, y);
136
+ htmlElement.style.scrollBehavior = previousScrollBehavior;
137
+ }
138
+ function isAtScrollPosition({ x, y }) {
139
+ return Math.abs(window.scrollX - x) <= SCROLL_RESTORE_TOLERANCE_PX && Math.abs(window.scrollY - y) <= SCROLL_RESTORE_TOLERANCE_PX;
140
+ }
141
+ function waitForNextAnimationFrame() {
142
+ return new Promise((resolve) => {
143
+ if (typeof requestAnimationFrame === "function") {
144
+ requestAnimationFrame(() => resolve());
145
+ return;
146
+ }
147
+ setTimeout(resolve, 16);
148
+ });
149
+ }
150
+ function canUseSessionStorageForScrollRestoration() {
151
+ if (typeof window === "undefined") return false;
152
+ try {
153
+ const key = "__next";
154
+ window.sessionStorage.setItem(key, key);
155
+ window.sessionStorage.removeItem(key);
156
+ return true;
157
+ } catch {
158
+ return false;
159
+ }
160
+ }
161
+ const manualScrollRestoration = __scrollRestoration && typeof window !== "undefined" && window.next?.appDir !== true && "scrollRestoration" in window.history && canUseSessionStorageForScrollRestoration();
162
+ function installManualScrollRestoration() {
163
+ if (manualScrollRestoration) window.history.scrollRestoration = "manual";
164
+ }
165
+ function createRouterEvents() {
166
+ const listeners = /* @__PURE__ */ new Map();
167
+ return {
168
+ on(event, handler) {
169
+ if (!listeners.has(event)) listeners.set(event, /* @__PURE__ */ new Set());
170
+ listeners.get(event).add(handler);
171
+ },
172
+ off(event, handler) {
173
+ listeners.get(event)?.delete(handler);
174
+ },
175
+ emit(event, ...args) {
176
+ listeners.get(event)?.forEach((handler) => handler(...args));
177
+ }
178
+ };
179
+ }
180
+ const PAGES_ROUTER_RUNTIME_STATE_KEY = Symbol.for("vinext.pagesRouter.runtimeState");
181
+ function createPagesRouterRuntimeState() {
182
+ return {
183
+ events: createRouterEvents(),
184
+ historyKeyCounter: 0,
185
+ navigationId: 0,
186
+ activeAbortController: null,
187
+ cancelPendingRenderCommit: null,
188
+ lastPathnameAndSearch: typeof window !== "undefined" ? window.location.pathname + window.location.search : "",
189
+ isFirstPopStateEvent: true,
190
+ routerDidNavigate: false,
191
+ deprecatedEventBridgeInstalled: false,
192
+ pagesRouterReady: typeof window === "undefined" || !shouldDeferInitialPagesRouterReady()
193
+ };
194
+ }
195
+ function getPagesRouterRuntimeState() {
196
+ if (typeof window === "undefined") return createPagesRouterRuntimeState();
197
+ const globalObject = window;
198
+ const existing = globalObject[PAGES_ROUTER_RUNTIME_STATE_KEY];
199
+ if (existing) return existing;
200
+ const state = createPagesRouterRuntimeState();
201
+ globalObject[PAGES_ROUTER_RUNTIME_STATE_KEY] = state;
202
+ return state;
203
+ }
204
+ const routerRuntimeState = getPagesRouterRuntimeState();
205
+ const routerEvents = routerRuntimeState.events;
206
+ function getPagesRouterRuntimeComponents() {
207
+ const existing = routerRuntimeState.components;
208
+ if (existing) return existing;
209
+ const components = {
210
+ CommitBoundary: PagesRouterCommitBoundary,
211
+ Provider: PagesRouterProvider
212
+ };
213
+ routerRuntimeState.components = components;
214
+ return components;
215
+ }
216
+ function resolveUrl(url) {
217
+ if (typeof url === "string") return url;
218
+ const hasQuery = url.query !== void 0 && Object.keys(url.query).length > 0;
219
+ const hasSearch = typeof url.search === "string" && url.search.length > 0;
220
+ const hasHash = typeof url.hash === "string" && url.hash.length > 0;
221
+ const inheritsVisiblePath = url.pathname === void 0 && (hasQuery || hasSearch || hasHash);
222
+ let result = url.pathname ?? (typeof window !== "undefined" ? inheritsVisiblePath ? stripBasePath(window.location.pathname, __basePath) : window.__NEXT_DATA__?.page ?? stripBasePath(window.location.pathname, __basePath) : "/");
223
+ if (hasSearch) {
224
+ const search = url.search.startsWith("?") ? url.search : `?${url.search}`;
225
+ const hashIndex = search.indexOf("#");
226
+ result += hashIndex === -1 ? search : `${search.slice(0, hashIndex)}%23${search.slice(hashIndex + 1)}`;
227
+ } else if (hasQuery) {
228
+ const params = urlQueryToSearchParams(url.query);
229
+ result = appendSearchParamsToUrl(result, params);
230
+ } else if (hasHash && typeof window !== "undefined") result += window.location.search;
231
+ if (hasHash) result += url.hash.startsWith("#") ? url.hash : `#${url.hash}`;
232
+ return result;
233
+ }
234
+ /**
235
+ * When `as` is provided, use it as the navigation target. This is a
236
+ * simplification: Next.js keeps `url` and `as` as separate values (url for
237
+ * data fetching, as for the browser URL). We collapse them because vinext's
238
+ * navigateClient() fetches HTML from the target URL, so `as` must be a
239
+ * server-resolvable path. Purely decorative `as` values are not supported.
240
+ * Pages error routes are handled as a narrow exception below because Next.js
241
+ * treats their href as the component route while preserving `as` in history.
242
+ */
243
+ function resolveNavigationTarget(url, as, locale, replaceExistingLocale = false) {
244
+ return applyNavigationLocale(as ?? resolveUrl(url), locale, replaceExistingLocale);
245
+ }
246
+ var HrefInterpolationError = class extends Error {};
247
+ function interpolateCurrentDynamicRoute(resolved) {
248
+ if (typeof window === "undefined") return resolved;
249
+ const routePattern = window.__NEXT_DATA__?.page;
250
+ if (!routePattern || extractRouteParamNames(routePattern).length === 0) return resolved;
251
+ try {
252
+ const target = new URL(resolved, "http://vinext.local");
253
+ const currentOrigin = getWindowOrigin();
254
+ if (currentOrigin && target.origin !== "http://vinext.local" && target.origin !== currentOrigin) return resolved;
255
+ const visiblePath = stripBasePath(window.location.pathname, __basePath);
256
+ const visibleLocale = getLocalePathPrefix(visiblePath, window.__VINEXT_LOCALES__);
257
+ if (extractRouteParamsFromPath(routePattern, visibleLocale ? visiblePath.slice(visibleLocale.length + 1) || "/" : visiblePath) === null) return resolved;
258
+ const query = parseQueryString(target.search);
259
+ const missingParams = routePatternParts(routePattern).filter((part) => part.startsWith(":") && !part.endsWith("*")).map((part) => part.slice(1, part.endsWith("+") ? -1 : void 0)).filter((paramName) => {
260
+ const value = query[paramName];
261
+ return value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
262
+ });
263
+ if (missingParams.length > 0) throw new HrefInterpolationError(`The provided \`href\` (${`${routePattern}${target.search}${target.hash}`}) value is missing query values (${missingParams.join(", ")}) to be interpolated properly. Read more: https://nextjs.org/docs/messages/href-interpolation-failed`);
264
+ const routeParams = getRouteParamsFromQuery(routePattern, query);
265
+ if (!routeParams) return resolved;
266
+ const pathname = fillRoutePatternSegments(routePattern, Object.fromEntries(Object.entries(routeParams).map(([key, value]) => [key, Array.isArray(value) ? value.map(encodeURIComponent) : encodeURIComponent(value)])));
267
+ if (!pathname) return resolved;
268
+ const targetLocale = getLocalePathPrefix(target.pathname, window.__VINEXT_LOCALES__);
269
+ target.pathname = targetLocale ? `/${targetLocale}${pathname}` : pathname;
270
+ for (const paramName of extractRouteParamNames(routePattern)) target.searchParams.delete(paramName);
271
+ return target.href.slice(target.origin.length);
272
+ } catch (error) {
273
+ if (error instanceof HrefInterpolationError) throw error;
274
+ return resolved;
275
+ }
276
+ }
277
+ function getCurrentUrlLocale() {
278
+ return getCurrentBrowserLocale({
279
+ basePath: __basePath,
280
+ domainLocales: getDomainLocales(),
281
+ hostname: getCurrentHostname()
282
+ });
283
+ }
284
+ function getLocalPathname(url) {
285
+ if (typeof window === "undefined") return null;
286
+ if (isAbsoluteOrProtocolRelativeUrl(url)) {
287
+ const localPath = toSameOriginAppPath(url, __basePath);
288
+ if (localPath == null) return null;
289
+ return stripBasePath(new URL(localPath, window.location.href).pathname, __basePath);
290
+ }
291
+ try {
292
+ return stripBasePath(new URL(url, window.location.href).pathname, __basePath);
293
+ } catch {
294
+ return null;
295
+ }
296
+ }
297
+ function resolvePagesErrorHtmlFetchUrl(url, locale) {
298
+ const href = resolveUrl(url);
299
+ const errorRoutePathname = getLocalPathname(href);
300
+ if (errorRoutePathname !== "/404" && errorRoutePathname !== "/_error") return null;
301
+ const resolvedUrl = applyNavigationLocale(errorRoutePathname === "/_error" ? replaceUrlPathname(href, "/404") : href, locale);
302
+ let parsed;
303
+ try {
304
+ parsed = new URL(resolvedUrl, window.location.href);
305
+ } catch {
306
+ return null;
307
+ }
308
+ return normalizePathTrailingSlash(toBrowserNavigationHref(`${stripBasePath(parsed.pathname, __basePath)}${parsed.search}${parsed.hash}`, window.location.href, __basePath), __trailingSlash);
309
+ }
310
+ function replaceUrlPathname(url, pathname) {
311
+ try {
312
+ const parsed = new URL(url, window.location.href);
313
+ return `${pathname}${parsed.search}${parsed.hash}`;
314
+ } catch {
315
+ return pathname;
316
+ }
317
+ }
318
+ function resolveTransitionLocale(locale) {
319
+ if (typeof window === "undefined") return void 0;
320
+ if (locale === false) return window.__VINEXT_DEFAULT_LOCALE__;
321
+ return locale ?? getCurrentUrlLocale();
322
+ }
323
+ function getDomainLocales() {
324
+ return window.__NEXT_DATA__?.domainLocales;
325
+ }
326
+ function getCurrentHostname() {
327
+ return window.location?.hostname;
328
+ }
329
+ function getDomainLocalePath(url, locale) {
330
+ return getDomainLocaleUrl(url, locale, {
331
+ basePath: __basePath,
332
+ currentHostname: getCurrentHostname(),
333
+ domainItems: getDomainLocales()
334
+ });
335
+ }
336
+ /**
337
+ * Apply locale prefix to a URL for client-side navigation.
338
+ * Same logic as Link's applyLocaleToHref but reads from window globals.
339
+ */
340
+ function applyNavigationLocale(url, locale, replaceExistingLocale = false) {
341
+ if (!locale || typeof window === "undefined") return url;
342
+ if (isAbsoluteOrProtocolRelativeUrl(url)) return url;
343
+ if (!replaceExistingLocale && getLocalePathPrefix(url, window.__VINEXT_LOCALES__)) return url;
344
+ const normalizedUrl = replaceExistingLocale ? removeNavigationLocalePrefix(url) : url;
345
+ const domainLocalePath = getDomainLocalePath(normalizedUrl, locale);
346
+ if (domainLocalePath) return domainLocalePath;
347
+ return addLocalePrefix(normalizedUrl, locale, window.__VINEXT_DEFAULT_LOCALE__ ?? "");
348
+ }
349
+ function removeNavigationLocalePrefix(url) {
350
+ const locales = window.__VINEXT_LOCALES__;
351
+ if (!locales?.length) return url;
352
+ try {
353
+ const parsed = new URL(url, "http://vinext.local");
354
+ const locale = getLocalePathPrefix(parsed.pathname, locales);
355
+ if (!locale) return url;
356
+ return `${parsed.pathname.slice(locale.length + 1) || "/"}${parsed.search}${parsed.hash}`;
357
+ } catch {
358
+ return url;
359
+ }
360
+ }
361
+ function isDefaultLocaleRootNavigation(url, locale) {
362
+ if (typeof window === "undefined") return false;
363
+ if (!locale || locale !== window.__VINEXT_DEFAULT_LOCALE__) return false;
364
+ let parsed;
365
+ try {
366
+ parsed = new URL(url, window.location.href);
367
+ } catch {
368
+ return false;
369
+ }
370
+ return stripBasePath(parsed.pathname, __basePath) === "/";
371
+ }
372
+ function getPagesHtmlFetchUrl(browserUrl, locale) {
373
+ if (!isDefaultLocaleRootNavigation(browserUrl, locale)) return browserUrl;
374
+ const parsed = new URL(browserUrl, window.location.href);
375
+ return normalizePathTrailingSlash(toBrowserNavigationHref(`${normalizePathTrailingSlash(`/${locale}`, __trailingSlash)}${parsed.search}${parsed.hash}`, window.location.href, __basePath), __trailingSlash);
376
+ }
377
+ /** Check if a URL is external (any URL scheme per RFC 3986, or protocol-relative) */
378
+ function isExternalUrl(url) {
379
+ return isAbsoluteOrProtocolRelativeUrl(url);
380
+ }
381
+ /** Resolve a hash URL to a basePath-stripped app URL for event payloads */
382
+ function resolveHashUrl(url) {
383
+ if (typeof window === "undefined") return url;
384
+ if (url.startsWith("#")) return stripBasePath(window.location.pathname, __basePath) + window.location.search + url;
385
+ try {
386
+ const parsed = new URL(url, window.location.href);
387
+ return stripBasePath(parsed.pathname, __basePath) + parsed.search + parsed.hash;
388
+ } catch {
389
+ return url;
390
+ }
391
+ }
392
+ /** Check if a href is only a hash change relative to the current URL */
393
+ function isHashOnlyChange(href) {
394
+ if (href.startsWith("#")) return true;
395
+ if (typeof window === "undefined") return false;
396
+ return isHashOnlyBrowserUrlChange(href, window.location.href, __basePath);
397
+ }
398
+ /**
399
+ * Build router-shaped state for the initial document entry. Captures the
400
+ * active locale (from `window.__VINEXT_LOCALE__`) so a back-navigation
401
+ * popstate to this entry can recover its locale instead of falling back to
402
+ * the live window global — the locale may have changed by the time the user
403
+ * navigates back.
404
+ */
405
+ function buildInitialRouterState() {
406
+ const appPath = stripBasePath(window.location.pathname, __basePath) + window.location.search;
407
+ const options = {};
408
+ if (window.__VINEXT_LOCALE__ !== void 0) options.locale = window.__VINEXT_LOCALE__;
409
+ return {
410
+ url: appPath,
411
+ as: appPath,
412
+ options,
413
+ __N: true,
414
+ key: createHistoryKey()
415
+ };
416
+ }
417
+ /**
418
+ * Stamp the initial document entry with router-shaped state (only if no
419
+ * state is present). Called once at runtime install so the entry has a
420
+ * locale stamped before any push could overwrite the active locale global.
421
+ */
422
+ function stampInitialHistoryState() {
423
+ installManualScrollRestoration();
424
+ if (!window.history) return;
425
+ const existingState = window.history.state;
426
+ if (existingState !== null && existingState !== void 0) {
427
+ routerRuntimeState.currentHistoryKey = getRouterStateKey(existingState) ?? routerRuntimeState.currentHistoryKey;
428
+ return;
429
+ }
430
+ const initialState = buildInitialRouterState();
431
+ routerRuntimeState.currentHistoryKey = initialState.key;
432
+ window.history.replaceState(initialState, "");
433
+ }
434
+ setStampInitialHistoryState(stampInitialHistoryState);
435
+ /** Save current scroll position into history state for back/forward restoration.
436
+ *
437
+ * Merging into the existing state preserves any router-owned fields (`__N`,
438
+ * `url`, `as`, `options`, `key`). If the install-time stamp didn't run
439
+ * (Router.push called before installPagesRouterRuntime), fall back to
440
+ * minting the same shape here so the entry isn't treated as foreign.
441
+ */
442
+ function saveScrollPosition() {
443
+ const position = getWindowScrollPosition();
444
+ const existing = isUnknownRecord(window.history.state) ? window.history.state : null;
445
+ const scroll = {
446
+ __vinext_scrollX: position.x,
447
+ __vinext_scrollY: position.y
448
+ };
449
+ const base = existing ?? buildInitialRouterState();
450
+ const key = getRouterStateKey(base);
451
+ if (key !== void 0) {
452
+ routerRuntimeState.currentHistoryKey = key;
453
+ saveScrollPositionToSessionStorage(key, position);
454
+ }
455
+ window.history.replaceState({
456
+ ...base,
457
+ ...scroll
458
+ }, "");
459
+ }
460
+ function getWindowScrollPosition() {
461
+ return {
462
+ x: window.scrollX,
463
+ y: window.scrollY
464
+ };
465
+ }
466
+ function getScrollStorageKey(historyKey) {
467
+ return `__next_scroll_${historyKey}`;
468
+ }
469
+ function readScrollPosition(value) {
470
+ if (!isUnknownRecord(value)) return null;
471
+ const nextX = value.x;
472
+ const nextY = value.y;
473
+ if (typeof nextX === "number" && typeof nextY === "number") return {
474
+ x: nextX,
475
+ y: nextY
476
+ };
477
+ const vinextX = value.__vinext_scrollX;
478
+ const vinextY = value.__vinext_scrollY;
479
+ if (typeof vinextX === "number" && typeof vinextY === "number") return {
480
+ x: vinextX,
481
+ y: vinextY
482
+ };
483
+ return null;
484
+ }
485
+ function saveScrollPositionToSessionStorage(key, position) {
486
+ if (!manualScrollRestoration) return;
487
+ try {
488
+ window.sessionStorage.setItem(getScrollStorageKey(key), JSON.stringify(position));
489
+ } catch {}
490
+ }
491
+ function readScrollPositionFromSessionStorage(key) {
492
+ if (!manualScrollRestoration) return null;
493
+ try {
494
+ const value = window.sessionStorage.getItem(getScrollStorageKey(key));
495
+ if (value === null) return null;
496
+ return readScrollPosition(JSON.parse(value));
497
+ } catch {
498
+ return null;
499
+ }
500
+ }
501
+ let _ssrContext = null;
502
+ let _getSSRContext = () => _ssrContext;
503
+ let _setSSRContextImpl = (ctx) => {
504
+ _ssrContext = ctx;
505
+ };
506
+ /**
507
+ * Register ALS-backed state accessors. Called by router-state.ts on import.
508
+ * @internal
509
+ */
510
+ function _registerRouterStateAccessors(accessors) {
511
+ _getSSRContext = accessors.getSSRContext;
512
+ _setSSRContextImpl = accessors.setSSRContext;
513
+ }
514
+ function setSSRContext(ctx) {
515
+ _setSSRContextImpl(ctx);
516
+ }
517
+ const PAGES_NAVIGATION_NOTIFY_KEY = Symbol.for("vinext.navigation.pagesNavigationNotify");
518
+ let _cachedClientPagesNavCtx = null;
519
+ let _cachedClientPagesNavCtxKey = null;
520
+ function _buildClientPagesNavigationContext(routePattern, resolvedPath, searchString, isReady, nextData) {
521
+ const cacheKey = `${isReady ? "1" : "0"}|${routePattern}|${resolvedPath}|${searchString}`;
522
+ if (_cachedClientPagesNavCtxKey === cacheKey && _cachedClientPagesNavCtx) return _cachedClientPagesNavCtx;
523
+ const searchParams = isReady ? new URLSearchParams(searchString) : new URLSearchParams();
524
+ const params = isReady ? extractRouteParamsFromPath(routePattern, resolvedPath) ?? getRouteParamsFromQuery(routePattern, nextData?.query ?? {}) ?? {} : null;
525
+ const isAutoExportDynamic = nextData?.autoExport === true && extractRouteParamNames(routePattern).length > 0;
526
+ const ctx = {
527
+ pathname: resolvePagesNavigationPathname(resolvedPath, nextData?.isFallback === true, isAutoExportDynamic, isReady),
528
+ searchParams,
529
+ params
530
+ };
531
+ _cachedClientPagesNavCtx = ctx;
532
+ _cachedClientPagesNavCtxKey = cacheKey;
533
+ return ctx;
534
+ }
535
+ const _ssrPagesNavCtxCache = /* @__PURE__ */ new WeakMap();
536
+ /**
537
+ * Cross-router compat shim source for `next/navigation` hooks.
538
+ *
539
+ * Returns the current Pages Router state shaped as a navigation context so
540
+ * the App Router hooks (useParams/useSearchParams/usePathname) can act as
541
+ * compat shims when invoked inside a Pages Router render. Mirrors Next.js's
542
+ * `adaptForPathParams` and `adaptForSearchParams` in
543
+ * .nextjs-ref/packages/next/src/shared/lib/router/adapters.tsx, which Next.js
544
+ * uses to populate SearchParamsContext / PathParamsContext for the Pages
545
+ * Router (see packages/next/src/server/render.tsx and
546
+ * packages/next/src/client/index.tsx).
547
+ *
548
+ * Returns `null` when there is no Pages Router state available — e.g. App
549
+ * Router pages, RSC-only renders, or pre-router renders. Callers should
550
+ * treat null as "App Router context, use normal app-router state".
551
+ */
552
+ function getPagesNavigationContext() {
553
+ if (typeof window === "undefined") {
554
+ const ssrCtx = _getSSRContext();
555
+ if (!ssrCtx) return null;
556
+ const cached = _ssrPagesNavCtxCache.get(ssrCtx);
557
+ if (cached) return cached;
558
+ let searchString = "";
559
+ let resolvedPath;
560
+ try {
561
+ const url = new URL(ssrCtx.asPath, "http://_");
562
+ searchString = url.search;
563
+ resolvedPath = url.pathname;
564
+ } catch {
565
+ resolvedPath = ssrCtx.pathname;
566
+ }
567
+ const isReady = ssrCtx.navigationIsReady ?? true;
568
+ const searchParams = isReady ? new URLSearchParams(searchString) : new URLSearchParams();
569
+ const params = isReady ? extractRouteParamsFromPath(ssrCtx.pathname, resolvedPath) ?? getRouteParamsFromQuery(ssrCtx.pathname, ssrCtx.query) ?? {} : null;
570
+ const isAutoExportDynamic = ssrCtx.nextData?.autoExport === true && extractRouteParamNames(ssrCtx.pathname).length > 0;
571
+ const ctx = {
572
+ pathname: resolvePagesNavigationPathname(resolvedPath, ssrCtx.isFallback === true, isAutoExportDynamic, isReady),
573
+ searchParams,
574
+ params
575
+ };
576
+ _ssrPagesNavCtxCache.set(ssrCtx, ctx);
577
+ return ctx;
578
+ }
579
+ if (!isPagesRouterDocumentActive()) return null;
580
+ const resolvedPath = stripBasePath(window.location.pathname, __basePath);
581
+ const nextData = window.__NEXT_DATA__;
582
+ const pattern = resolvePagesRoutePatternForPath(nextData?.page, resolvedPath);
583
+ if (!pattern) return null;
584
+ return _buildClientPagesNavigationContext(pattern, resolvedPath, window.location.search, isPagesRouterReady(), nextData);
585
+ }
586
+ /**
587
+ * Extract param names from a Next.js route pattern.
588
+ * E.g., "/posts/[id]" → ["id"], "/docs/[...slug]" → ["slug"],
589
+ * "/shop/[[...path]]" → ["path"], "/blog/[year]/[month]" → ["year", "month"]
590
+ * Also handles internal format: "/posts/:id" → ["id"], "/docs/:slug+" → ["slug"]
591
+ */
592
+ function extractRouteParamNames(pattern) {
593
+ const names = [];
594
+ const bracketMatches = pattern.matchAll(/\[{1,2}(?:\.\.\.)?([^\]]+)\]{1,2}/g);
595
+ for (const m of bracketMatches) names.push(m[1]);
596
+ if (names.length > 0) return names;
597
+ const colonMatches = pattern.matchAll(/:([^/+*]+)[+*]?/g);
598
+ for (const m of colonMatches) names.push(m[1]);
599
+ return names;
600
+ }
601
+ /**
602
+ * Resolve the `pathname` snapshot for the Pages Router navigation context.
603
+ * Shared by the client and SSR branches of `getPagesNavigationContext` so both
604
+ * runtimes derive identical null-ness — diverging here would reintroduce a
605
+ * hydration mismatch. Returns `null` for a `getStaticPaths` fallback shell or a
606
+ * pre-ready auto-export dynamic route (the live path is published once the
607
+ * client router becomes ready).
608
+ */
609
+ function resolvePagesNavigationPathname(resolvedPath, isFallback, isAutoExportDynamic, isReady) {
610
+ return isFallback || isAutoExportDynamic && !isReady ? null : resolvedPath;
611
+ }
612
+ let _cachedPagesRoutePatternKey = null;
613
+ let _cachedPagesRoutePattern;
614
+ function resolvePagesRoutePatternForPath(nextDataPage, resolvedPath) {
615
+ if (nextDataPage && extractRouteParamNames(nextDataPage).length > 0) return nextDataPage;
616
+ const cacheKey = `${nextDataPage ?? ""}|${resolvedPath}`;
617
+ if (_cachedPagesRoutePatternKey === cacheKey) return _cachedPagesRoutePattern;
618
+ let resolved = nextDataPage;
619
+ for (const pattern of window.__VINEXT_PAGE_PATTERNS__ ?? []) if (matchRoutePattern(splitPathSegments(resolvedPath), routePatternParts(pattern))) {
620
+ resolved = pattern;
621
+ break;
622
+ }
623
+ _cachedPagesRoutePatternKey = cacheKey;
624
+ _cachedPagesRoutePattern = resolved;
625
+ return resolved;
626
+ }
627
+ function extractRouteParamsFromPath(pattern, pathname) {
628
+ return matchRoutePattern(splitPathSegments(pathname), routePatternParts(pattern));
629
+ }
630
+ function getRouteParamsFromQuery(pattern, query) {
631
+ const names = extractRouteParamNames(pattern);
632
+ if (names.length === 0) return null;
633
+ const params = {};
634
+ let hasParam = false;
635
+ for (const name of names) {
636
+ const value = query[name];
637
+ if (typeof value === "string") {
638
+ params[name] = value;
639
+ hasParam = true;
640
+ } else if (Array.isArray(value)) {
641
+ params[name] = [...value];
642
+ hasParam = true;
643
+ }
644
+ }
645
+ return hasParam ? params : null;
646
+ }
647
+ function getRouteQueryFromNextData(nextData, resolvedPath) {
648
+ const routeQuery = {};
649
+ if (!nextData?.query || !nextData.page) return routeQuery;
650
+ if (extractRouteParamsFromPath(nextData.page, resolvedPath) === null) {
651
+ for (const [key, value] of Object.entries(nextData.query)) if (typeof value === "string") routeQuery[key] = value;
652
+ else if (Array.isArray(value)) routeQuery[key] = [...value];
653
+ return routeQuery;
654
+ }
655
+ const routeParamNames = extractRouteParamNames(nextData.page);
656
+ if (routeParamNames.length === 0) return routeQuery;
657
+ const currentRouteParams = extractRouteParamsFromPath(nextData.page, resolvedPath);
658
+ if (currentRouteParams) return currentRouteParams;
659
+ for (const key of routeParamNames) {
660
+ const value = nextData.query[key];
661
+ if (typeof value === "string") routeQuery[key] = value;
662
+ else if (Array.isArray(value)) routeQuery[key] = [...value];
663
+ }
664
+ return routeQuery;
665
+ }
666
+ function getPathnameAndQuery() {
667
+ if (typeof window === "undefined") {
668
+ const _ssrCtx = _getSSRContext();
669
+ if (_ssrCtx) {
670
+ const query = {};
671
+ for (const [key, value] of Object.entries(_ssrCtx.query)) query[key] = Array.isArray(value) ? [...value] : value;
672
+ return {
673
+ pathname: _ssrCtx.pathname,
674
+ query,
675
+ asPath: _ssrCtx.asPath
676
+ };
677
+ }
678
+ return {
679
+ pathname: "/",
680
+ query: {},
681
+ asPath: "/"
682
+ };
683
+ }
684
+ const resolvedPath = stripBasePath(window.location.pathname, __basePath);
685
+ const pathname = window.__NEXT_DATA__?.page ?? resolvedPath;
686
+ const nextData = window.__NEXT_DATA__;
687
+ const routeQuery = getRouteQueryFromNextData(nextData, resolvedPath);
688
+ const searchQuery = {};
689
+ const params = new URLSearchParams(window.location.search);
690
+ for (const [key, value] of params) addQueryParam(searchQuery, key, value);
691
+ return {
692
+ pathname,
693
+ query: {
694
+ ...searchQuery,
695
+ ...routeQuery
696
+ },
697
+ asPath: getCurrentHistoryAsPath() ?? resolvedPath + window.location.search + window.location.hash
698
+ };
699
+ }
700
+ function getCurrentHistoryAsPath() {
701
+ const state = window.history?.state;
702
+ if (!isNextRouterState(state) || typeof state.as !== "string") return null;
703
+ try {
704
+ const browserUrl = new URL(window.location.href);
705
+ const stateUrl = new URL(toBrowserNavigationHref(state.as, window.location.href, __basePath), window.location.href);
706
+ if (stateUrl.pathname !== browserUrl.pathname || stateUrl.search !== browserUrl.search) return null;
707
+ const stateAs = stripHash(state.as);
708
+ const visibleAs = `${stripBasePath(window.location.pathname, __basePath)}${window.location.search}`;
709
+ return `${stateAs || visibleAs}${window.location.hash}`;
710
+ } catch {
711
+ return null;
712
+ }
713
+ }
714
+ function getPagesNavigationIsReadyFromSerializedState(routePattern, searchString, nextData) {
715
+ if (!routePattern) return true;
716
+ if (nextData?.gssp === true || nextData?.gip === true || nextData?.isExperimentalCompile === true || nextData?.appGip === true && nextData.gsp !== true) return true;
717
+ const autoExportDynamic = nextData?.autoExport === true && extractRouteParamNames(routePattern).length > 0;
718
+ const hasSearch = searchString.length > 0;
719
+ const hasRewrites = nextData?.__vinext?.hasRewrites === true;
720
+ return !autoExportDynamic && !hasSearch && !hasRewrites;
721
+ }
722
+ function shouldDeferInitialPagesRouterReady() {
723
+ if (typeof window === "undefined") return false;
724
+ const nextData = window.__NEXT_DATA__;
725
+ if (!nextData) return false;
726
+ return !getPagesNavigationIsReadyFromSerializedState(nextData.page, window.location.search, nextData);
727
+ }
728
+ function isPagesRouterReady() {
729
+ return routerRuntimeState.pagesRouterReady;
730
+ }
731
+ function isPagesRouterDocumentActive() {
732
+ if (typeof window === "undefined") return true;
733
+ if (window.__VINEXT_PAGE_LOADERS__) return true;
734
+ if (window.next?.appDir === true) return false;
735
+ if (window.next?.router) return true;
736
+ return Boolean(window.__VINEXT_APP__ || window.__VINEXT_APP_LOADER__);
737
+ }
738
+ function markPagesRouterReady() {
739
+ if (typeof window === "undefined" || routerRuntimeState.pagesRouterReady) return false;
740
+ routerRuntimeState.pagesRouterReady = true;
741
+ return true;
742
+ }
743
+ function initializePagesRouterReadyFromNextData(nextData) {
744
+ if (typeof window === "undefined") return;
745
+ routerRuntimeState.pagesRouterReady = getPagesNavigationIsReadyFromSerializedState(nextData.page, window.location.search, nextData);
746
+ }
747
+ function markPagesRouterHydrated() {
748
+ if (typeof window === "undefined" || window.__NEXT_HYDRATED === true) return;
749
+ const hydratedAt = performance.now();
750
+ window.__VINEXT_HYDRATED_AT = hydratedAt;
751
+ window.__NEXT_HYDRATED = true;
752
+ window.__NEXT_HYDRATED_AT = hydratedAt;
753
+ window.__NEXT_HYDRATED_CB?.();
754
+ }
755
+ function PagesRouterHydrationMarker() {
756
+ useEffect(() => {
757
+ markPagesRouterHydrated();
758
+ }, []);
759
+ return null;
760
+ }
761
+ function getRouterSnapshot() {
762
+ const isReady = typeof window === "undefined" ? _getSSRContext()?.navigationIsReady ?? true : isPagesRouterReady();
763
+ return {
764
+ ...getPathnameAndQuery(),
765
+ isReady
766
+ };
767
+ }
768
+ function notifyNextNavigationPagesContext() {
769
+ const notify = globalThis[PAGES_NAVIGATION_NOTIFY_KEY];
770
+ notify?.();
771
+ }
772
+ /**
773
+ * Error thrown when a navigation is superseded by a newer one.
774
+ * Matches Next.js's convention of an Error with `.cancelled = true`.
775
+ */
776
+ var NavigationCancelledError = class extends Error {
777
+ cancelled = true;
778
+ constructor(route) {
779
+ super(`Abort fetching component for route: "${route}"`);
780
+ this.name = "NavigationCancelledError";
781
+ }
782
+ };
783
+ /**
784
+ * Error thrown after queueing a hard navigation fallback for a known failure
785
+ * mode. Callers can use this to avoid scheduling the same hard navigation twice.
786
+ */
787
+ var HardNavigationScheduledError = class extends Error {
788
+ hardNavigationScheduled = true;
789
+ constructor(message) {
790
+ super(message);
791
+ this.name = "HardNavigationScheduledError";
792
+ }
793
+ };
794
+ function cancelPreviousRenderCommit() {
795
+ routerRuntimeState.cancelPendingRenderCommit?.();
796
+ routerRuntimeState.cancelPendingRenderCommit = null;
797
+ }
798
+ function scheduleHardNavigationAndThrow(url, message) {
799
+ if (typeof window === "undefined") throw new HardNavigationScheduledError(message);
800
+ window.location.href = url;
801
+ throw new HardNavigationScheduledError(message);
802
+ }
803
+ function isPageComponent(value) {
804
+ if (typeof value === "function") return true;
805
+ if (!isUnknownRecord(value)) return false;
806
+ return value.$$typeof === Symbol.for("react.forward_ref") || value.$$typeof === Symbol.for("react.memo");
807
+ }
808
+ function isAppComponent(value) {
809
+ return isPageComponent(value);
810
+ }
811
+ function resolveSameOriginRedirectedUrl(responseUrl) {
812
+ const appPath = toSameOriginAppPath(responseUrl, __basePath);
813
+ if (appPath === null) return null;
814
+ return normalizePathTrailingSlash(toBrowserNavigationHref(appPath, window.location.href, __basePath), __trailingSlash);
815
+ }
816
+ function stripLocalePrefixForApiRedirect(appPath) {
817
+ const locales = window.__VINEXT_LOCALES__;
818
+ if (!locales || locales.length === 0) return appPath;
819
+ try {
820
+ const parsed = new URL(appPath, "http://vinext.local");
821
+ const pathname = stripBasePath(parsed.pathname, __basePath);
822
+ const firstSegment = pathname.split("/")[1];
823
+ if (!firstSegment || !locales.includes(firstSegment)) return appPath;
824
+ const withoutLocale = pathname.slice(firstSegment.length + 1) || "/";
825
+ if (withoutLocale !== "/api" && !withoutLocale.startsWith("/api/")) return appPath;
826
+ return `${withoutLocale}${parsed.search}${parsed.hash}`;
827
+ } catch {
828
+ return appPath;
829
+ }
830
+ }
831
+ function resolveLocalRedirectUrl(location) {
832
+ let appPath;
833
+ if (location.startsWith("/") && !location.startsWith("//")) try {
834
+ const parsed = new URL(location, "http://vinext.local");
835
+ appPath = stripBasePath(parsed.pathname, __basePath) + parsed.search + parsed.hash;
836
+ } catch {
837
+ appPath = location;
838
+ }
839
+ else appPath = toSameOriginAppPath(location, __basePath);
840
+ if (appPath === null) return null;
841
+ return normalizePathTrailingSlash(toBrowserNavigationHref(stripLocalePrefixForApiRedirect(appPath), window.location.href, __basePath), __trailingSlash);
842
+ }
843
+ function hasVinextMiddleware(nextData) {
844
+ if (!isUnknownRecord(nextData)) return false;
845
+ const vinext = nextData.__vinext;
846
+ return isUnknownRecord(vinext) && vinext.hasMiddleware === true;
847
+ }
848
+ function getMiddlewarePagesDataFetchUrl(browserUrl) {
849
+ const nextData = window.__NEXT_DATA__;
850
+ if (!nextData || !hasVinextMiddleware(nextData)) return null;
851
+ const buildId = nextData.buildId;
852
+ if (typeof buildId !== "string" || buildId.length === 0) return null;
853
+ let parsed;
854
+ try {
855
+ parsed = new URL(browserUrl, window.location.href);
856
+ } catch {
857
+ return null;
858
+ }
859
+ if (parsed.origin !== getWindowOrigin()) return null;
860
+ return buildPagesDataHref(__basePath, buildId, stripBasePath(parsed.pathname, __basePath), parsed.search);
861
+ }
862
+ async function resolveMiddlewareDataEffect(browserUrl, signal) {
863
+ const dataUrl = getMiddlewarePagesDataFetchUrl(browserUrl);
864
+ if (!dataUrl) return null;
865
+ if (signal.aborted) throw new DOMException("Aborted", "AbortError");
866
+ try {
867
+ const res = await dedupedPagesDataFetch(dataUrl, {
868
+ headers: {
869
+ Accept: "application/json",
870
+ "x-nextjs-data": "1"
871
+ },
872
+ signal
873
+ });
874
+ return {
875
+ redirectLocation: res.headers.get("x-nextjs-redirect"),
876
+ rewriteTarget: res.headers.get("x-nextjs-rewrite"),
877
+ response: res
878
+ };
879
+ } catch {
880
+ return null;
881
+ }
882
+ }
883
+ /**
884
+ * React to a gSSP/gSP `__N_REDIRECT` marker returned on a client data
885
+ * navigation.
886
+ *
887
+ * Internal destinations (absolute paths, unless the redirect opted out of
888
+ * basePath via `__N_REDIRECT_BASE_PATH === false`) are followed with a fresh
889
+ * client-side navigation that preserves the originating push/replace mode. The
890
+ * fresh navigation increments the navigation id, so the navigation that
891
+ * produced this redirect is superseded and never commits the intermediate
892
+ * page. External (or non-absolute) destinations fall back to a hard navigation.
893
+ *
894
+ * Ported from Next.js: packages/next/src/shared/lib/router/router.ts
895
+ * (`pageProps.__N_REDIRECT` handling — internal `this.change` vs
896
+ * `handleHardNavigation`).
897
+ */
898
+ function handleDataRedirect(destination, redirectBasePath, mode = "push") {
899
+ if (!(destination.startsWith("/") && redirectBasePath !== false)) scheduleHardNavigationAndThrow(destination, "Navigation redirected externally");
900
+ performNavigation(destination, void 0, { locale: false }, mode);
901
+ }
902
+ /**
903
+ * Perform client-side navigation via the `/_next/data/<id>/<page>.json`
904
+ * endpoint. Used when `__VINEXT_PAGE_LOADERS__` has a matching code-split
905
+ * loader for the target pattern (the prod hot path). Falls back to the
906
+ * HTML extraction path (`navigateClientHtml`) when this returns `null`.
907
+ *
908
+ * Failure modes (404, 5xx, network, parse, missing loader, soft redirect)
909
+ * all queue a hard navigation and throw `HardNavigationScheduledError`,
910
+ * mirroring the existing HTML-path failure protocol. The hard reload is
911
+ * the deploy-skew safety net: when the server's buildId has rotated, the
912
+ * data endpoint returns 404 and the client lands on the new build via a
913
+ * full document load.
914
+ */
915
+ async function navigateClientData(url, initialTarget, controller, navId, assertStillCurrent, options = {}, prefetchedResponse) {
916
+ if (!window.__VINEXT_ROOT__) {
917
+ window.location.href = url;
918
+ return;
919
+ }
920
+ if (controller.signal.aborted) throw new NavigationCancelledError(url);
921
+ let res = prefetchedResponse;
922
+ if (!res) try {
923
+ const headers = {
924
+ Accept: "application/json",
925
+ "x-nextjs-data": "1"
926
+ };
927
+ const deploymentId = getDeploymentId();
928
+ if (deploymentId) headers[NEXT_DEPLOYMENT_ID_HEADER] = deploymentId;
929
+ res = await dedupedPagesDataFetch(initialTarget.dataHref, {
930
+ headers,
931
+ signal: controller.signal
932
+ });
933
+ } catch (err) {
934
+ if (err instanceof DOMException && err.name === "AbortError") throw new NavigationCancelledError(url);
935
+ throw err;
936
+ }
937
+ assertStillCurrent();
938
+ const softRedirect = res.headers.get("x-nextjs-redirect");
939
+ if (softRedirect) {
940
+ const redirectedUrl = resolveLocalRedirectUrl(softRedirect);
941
+ if (!redirectedUrl) scheduleHardNavigationAndThrow(softRedirect, "Navigation redirected externally");
942
+ window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
943
+ routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
944
+ await navigateClientHtml(redirectedUrl, redirectedUrl, controller, navId, assertStillCurrent);
945
+ return;
946
+ }
947
+ if (!res.ok) scheduleHardNavigationAndThrow(url, `Data navigation failed: ${res.status} ${res.statusText}`);
948
+ const rewriteTarget = res.headers.get("x-nextjs-rewrite");
949
+ const target = rewriteTarget ? resolvePagesDataNavigationTarget(rewriteTarget, __basePath) : initialTarget;
950
+ if (!target) scheduleHardNavigationAndThrow(url, "Data navigation failed: rewrite target has no page loader");
951
+ let body;
952
+ try {
953
+ body = await res.json();
954
+ } catch {
955
+ scheduleHardNavigationAndThrow(url, "Data navigation failed: invalid JSON response");
956
+ }
957
+ assertStillCurrent();
958
+ const props = isUnknownRecord(body) ? body : {};
959
+ const rawPageProps = props.pageProps;
960
+ const pageProps = isUnknownRecord(rawPageProps) ? rawPageProps : {};
961
+ const redirectDestination = pageProps.__N_REDIRECT;
962
+ if (typeof redirectDestination === "string") {
963
+ handleDataRedirect(redirectDestination, pageProps.__N_REDIRECT_BASE_PATH, options.mode);
964
+ throw new NavigationCancelledError(url);
965
+ }
966
+ let pageModule;
967
+ try {
968
+ pageModule = await target.loader();
969
+ } catch (err) {
970
+ console.error("[vinext] Page loader threw during navigation:", err);
971
+ scheduleHardNavigationAndThrow(url, "Data navigation failed: page loader threw");
972
+ }
973
+ assertStillCurrent();
974
+ const PageComponent = pageModule.default;
975
+ if (!isPageComponent(PageComponent)) scheduleHardNavigationAndThrow(url, "Data navigation failed: page module default export is not a component");
976
+ let AppComponent = window.__VINEXT_APP__;
977
+ if (!AppComponent && typeof window.__VINEXT_APP_LOADER__ === "function") try {
978
+ const appModule = await window.__VINEXT_APP_LOADER__();
979
+ AppComponent = isAppComponent(appModule.default) ? appModule.default : void 0;
980
+ if (AppComponent) window.__VINEXT_APP__ = AppComponent;
981
+ } catch {}
982
+ assertStillCurrent();
983
+ const React = (await import("react")).default;
984
+ assertStillCurrent();
985
+ let element;
986
+ if (AppComponent) element = React.createElement(AppComponent, {
987
+ ...props,
988
+ Component: PageComponent,
989
+ pageProps: rawPageProps,
990
+ router: Router
991
+ });
992
+ else element = React.createElement(PageComponent, pageProps);
993
+ const mergedQuery = mergeRouteParamsIntoQuery(parseQueryString(target.search), target.params);
994
+ const prev = window.__NEXT_DATA__;
995
+ const nextLocale = (window.__VINEXT_LOCALES__?.length ?? 0) > 0 ? target.locale ?? window.__VINEXT_DEFAULT_LOCALE__ : prev?.locale;
996
+ const nextData = {
997
+ ...prev,
998
+ props,
999
+ page: target.pattern,
1000
+ query: mergedQuery,
1001
+ buildId: target.buildId,
1002
+ isFallback: false,
1003
+ ...nextLocale !== void 0 ? { locale: nextLocale } : {}
1004
+ };
1005
+ window.__NEXT_DATA__ = nextData;
1006
+ applyVinextLocaleGlobals(window, nextData);
1007
+ await renderPagesRouterElement(element, options.scroll);
1008
+ assertStillCurrent();
1009
+ }
1010
+ /**
1011
+ * Perform client-side navigation by fetching the page's full HTML and
1012
+ * extracting `__NEXT_DATA__` plus the page module URL. Used in dev (where
1013
+ * the per-page inline hydration script does not populate the loader map) and
1014
+ * as a generic fallback when the data path is not available.
1015
+ *
1016
+ * Throws NavigationCancelledError if a newer navigation supersedes this one.
1017
+ * Throws on hard-navigation failures (non-OK response, missing data) so the
1018
+ * caller can distinguish success from failure for event emission.
1019
+ */
1020
+ async function navigateClientHtml(url, fetchUrl, controller, navId, assertStillCurrent, options = {}) {
1021
+ let browserUrl = url;
1022
+ let pendingRedirectHistoryUrl = fetchUrl === url ? null : url;
1023
+ if (!window.__VINEXT_ROOT__) {
1024
+ window.location.href = browserUrl;
1025
+ return;
1026
+ }
1027
+ let res;
1028
+ try {
1029
+ res = await fetch(fetchUrl, {
1030
+ headers: { Accept: "text/html" },
1031
+ signal: controller.signal
1032
+ });
1033
+ } catch (err) {
1034
+ if (err instanceof DOMException && err.name === "AbortError") throw new NavigationCancelledError(url);
1035
+ throw err;
1036
+ }
1037
+ assertStillCurrent();
1038
+ if (res.redirected && res.url) {
1039
+ const redirectedUrl = resolveSameOriginRedirectedUrl(res.url);
1040
+ if (redirectedUrl) {
1041
+ browserUrl = redirectedUrl;
1042
+ pendingRedirectHistoryUrl = redirectedUrl;
1043
+ }
1044
+ }
1045
+ if (!res.ok && !(options.allowNotFoundResponse === true && res.status === 404)) scheduleHardNavigationAndThrow(browserUrl, `Navigation failed: ${res.status} ${res.statusText}`);
1046
+ const html = await res.text();
1047
+ assertStillCurrent();
1048
+ const nextDataJson = extractVinextNextDataJson(html);
1049
+ if (!nextDataJson) scheduleHardNavigationAndThrow(url, "Navigation failed: missing __NEXT_DATA__ in response");
1050
+ const nextData = parseVinextNextDataJson(nextDataJson);
1051
+ const props = nextData.props && typeof nextData.props === "object" ? nextData.props : {};
1052
+ const rawPageProps = props.pageProps;
1053
+ const pageProps = isUnknownRecord(rawPageProps) ? rawPageProps : {};
1054
+ let pageModuleUrl = nextData.__vinext?.pageModuleUrl;
1055
+ if (!pageModuleUrl) {
1056
+ const moduleMatch = html.match(/import\("([^"]+)"\);\s*\n\s*const PageComponent/);
1057
+ const altMatch = html.match(/await import\("([^"]+pages\/[^"]+)"\)/);
1058
+ pageModuleUrl = moduleMatch?.[1] ?? altMatch?.[1] ?? void 0;
1059
+ }
1060
+ let pageModule;
1061
+ const loader = window.__VINEXT_PAGE_LOADERS__?.[nextData.page];
1062
+ if (loader) pageModule = await loader();
1063
+ else if (!pageModuleUrl) scheduleHardNavigationAndThrow(browserUrl, "Navigation failed: no page module URL found");
1064
+ else {
1065
+ if (!isValidModulePath(pageModuleUrl)) {
1066
+ console.error("[vinext] Blocked import of invalid page module path:", pageModuleUrl);
1067
+ scheduleHardNavigationAndThrow(browserUrl, "Navigation failed: invalid page module path");
1068
+ }
1069
+ pageModule = await import(
1070
+ /* @vite-ignore */
1071
+ pageModuleUrl
1072
+ );
1073
+ }
1074
+ assertStillCurrent();
1075
+ const PageComponent = pageModule.default;
1076
+ if (!isPageComponent(PageComponent)) scheduleHardNavigationAndThrow(browserUrl, "Navigation failed: page module default export is not a component");
1077
+ const React = (await import("react")).default;
1078
+ assertStillCurrent();
1079
+ let AppComponent = window.__VINEXT_APP__;
1080
+ const appModuleUrl = nextData.__vinext?.appModuleUrl;
1081
+ if (!AppComponent && appModuleUrl) if (!isValidModulePath(appModuleUrl)) console.error("[vinext] Blocked import of invalid app module path:", appModuleUrl);
1082
+ else try {
1083
+ const appModule = await import(
1084
+ /* @vite-ignore */
1085
+ appModuleUrl
1086
+ );
1087
+ AppComponent = isAppComponent(appModule.default) ? appModule.default : void 0;
1088
+ window.__VINEXT_APP__ = AppComponent;
1089
+ } catch {}
1090
+ assertStillCurrent();
1091
+ let element;
1092
+ if (AppComponent) element = React.createElement(AppComponent, {
1093
+ ...props,
1094
+ Component: PageComponent,
1095
+ pageProps: rawPageProps,
1096
+ router: Router
1097
+ });
1098
+ else element = React.createElement(PageComponent, pageProps);
1099
+ if (pendingRedirectHistoryUrl) {
1100
+ window.history.replaceState(window.history.state ?? {}, "", pendingRedirectHistoryUrl);
1101
+ routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
1102
+ }
1103
+ window.__NEXT_DATA__ = nextData;
1104
+ applyVinextLocaleGlobals(window, nextData);
1105
+ await renderPagesRouterElement(element, options.scroll);
1106
+ assertStillCurrent();
1107
+ }
1108
+ /**
1109
+ * Perform client-side navigation. Prefers the JSON data endpoint when the
1110
+ * client has a registered code-split loader for the target route (the prod
1111
+ * hot path); otherwise falls back to fetching the page's full HTML (dev and
1112
+ * any unmapped route).
1113
+ *
1114
+ * Throws NavigationCancelledError if a newer navigation supersedes this one.
1115
+ * Throws on hard-navigation failures (non-OK response, missing data) so the
1116
+ * caller can distinguish success from failure for event emission.
1117
+ *
1118
+ * `fetchUrl` is the HTML-path fetch URL (already includes locale-root
1119
+ * fixups). The JSON path derives its own URL from the browser-facing `url`
1120
+ * because the data endpoint speaks the unprefixed path.
1121
+ */
1122
+ async function navigateClient(url, fetchUrl = url, options = {}, routeUrl = url) {
1123
+ if (typeof window === "undefined") return;
1124
+ const previousAbortController = routerRuntimeState.activeAbortController;
1125
+ if (previousAbortController) queueMicrotask(() => previousAbortController.abort());
1126
+ cancelPreviousRenderCommit();
1127
+ const controller = new AbortController();
1128
+ routerRuntimeState.activeAbortController = controller;
1129
+ const navId = ++routerRuntimeState.navigationId;
1130
+ /** Check if this navigation is still the active one. If not, throw. */
1131
+ function assertStillCurrent() {
1132
+ if (navId !== routerRuntimeState.navigationId) throw new NavigationCancelledError(url);
1133
+ }
1134
+ try {
1135
+ if (options.allowNotFoundResponse === true) await navigateClientHtml(url, fetchUrl, controller, navId, assertStillCurrent, options);
1136
+ else {
1137
+ let browserUrl = url;
1138
+ let htmlFetchUrl = fetchUrl;
1139
+ let dataTarget = resolvePagesDataNavigationTarget(routeUrl, __basePath);
1140
+ let middlewareDataResponse;
1141
+ if (!dataTarget) {
1142
+ let middlewareEffect;
1143
+ try {
1144
+ middlewareEffect = await resolveMiddlewareDataEffect(browserUrl, controller.signal);
1145
+ } catch (err) {
1146
+ if (err instanceof DOMException && err.name === "AbortError") throw new NavigationCancelledError(browserUrl);
1147
+ throw err;
1148
+ }
1149
+ assertStillCurrent();
1150
+ const redirectLocation = middlewareEffect?.redirectLocation ?? null;
1151
+ if (redirectLocation) {
1152
+ const redirectedUrl = resolveLocalRedirectUrl(redirectLocation);
1153
+ if (!redirectedUrl) scheduleHardNavigationAndThrow(redirectLocation, "Navigation redirected externally");
1154
+ window.history.replaceState(window.history.state ?? {}, "", redirectedUrl);
1155
+ routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
1156
+ browserUrl = redirectedUrl;
1157
+ htmlFetchUrl = redirectedUrl;
1158
+ } else if (middlewareEffect?.rewriteTarget) {
1159
+ dataTarget = resolvePagesDataNavigationTarget(middlewareEffect.rewriteTarget, __basePath);
1160
+ if (dataTarget) middlewareDataResponse = middlewareEffect.response;
1161
+ }
1162
+ }
1163
+ if (dataTarget) await navigateClientData(browserUrl, dataTarget, controller, navId, assertStillCurrent, options, middlewareDataResponse);
1164
+ else await navigateClientHtml(browserUrl, htmlFetchUrl, controller, navId, assertStillCurrent, options);
1165
+ }
1166
+ } finally {
1167
+ if (navId === routerRuntimeState.navigationId) routerRuntimeState.activeAbortController = null;
1168
+ }
1169
+ }
1170
+ /**
1171
+ * Run navigateClient and handle errors: emit routeChangeError on failure,
1172
+ * and fall back to a hard navigation for non-cancel errors so the browser
1173
+ * recovers to a consistent state.
1174
+ *
1175
+ * Returns:
1176
+ * - "completed" — navigation finished, caller should emit routeChangeComplete
1177
+ * - "cancelled" — superseded by a newer navigation, caller should return true
1178
+ * without emitting routeChangeComplete (matches Next.js behaviour)
1179
+ * - "failed" — genuine error, caller should return false (hard nav is already
1180
+ * scheduled as recovery)
1181
+ */
1182
+ async function runNavigateClient(fullUrl, resolvedUrl, fetchUrl = fullUrl, options = {}, routeUrl = fullUrl) {
1183
+ try {
1184
+ await navigateClient(fullUrl, fetchUrl, options, routeUrl);
1185
+ return "completed";
1186
+ } catch (err) {
1187
+ routerEvents.emit("routeChangeError", err, resolvedUrl, { shallow: false });
1188
+ if (err instanceof NavigationCancelledError) return "cancelled";
1189
+ if (typeof window !== "undefined" && !(err instanceof HardNavigationScheduledError)) window.location.href = fullUrl;
1190
+ return "failed";
1191
+ }
1192
+ }
1193
+ /**
1194
+ * Build the full router value object from the current pathname, query, asPath,
1195
+ * and a set of navigation methods. Shared by the Pages Router context provider
1196
+ * and tests so the public router shape stays in sync.
1197
+ */
1198
+ function buildRouterValue(pathname, query, asPath, isReady, methods) {
1199
+ const _ssrState = _getSSRContext();
1200
+ const nextData = typeof window !== "undefined" ? window.__NEXT_DATA__ : void 0;
1201
+ const locale = typeof window === "undefined" ? _ssrState?.locale : window.__VINEXT_LOCALE__;
1202
+ const locales = typeof window === "undefined" ? _ssrState?.locales : window.__VINEXT_LOCALES__;
1203
+ const defaultLocale = typeof window === "undefined" ? _ssrState?.defaultLocale : window.__VINEXT_DEFAULT_LOCALE__;
1204
+ const domainLocales = typeof window === "undefined" ? _ssrState?.domainLocales : nextData?.domainLocales;
1205
+ return {
1206
+ pathname,
1207
+ route: typeof window !== "undefined" ? nextData?.page ?? pathname : pathname,
1208
+ query,
1209
+ asPath,
1210
+ basePath: __basePath,
1211
+ locale,
1212
+ locales,
1213
+ defaultLocale,
1214
+ domainLocales,
1215
+ isReady,
1216
+ isPreview: false,
1217
+ isFallback: typeof window !== "undefined" ? nextData?.isFallback === true : _ssrState?.isFallback === true,
1218
+ ...methods,
1219
+ events: routerEvents
1220
+ };
1221
+ }
1222
+ /** Extract the hash fragment from a URL, including the leading `#`. */
1223
+ function extractHash(url) {
1224
+ const i = url.indexOf("#");
1225
+ return i === -1 ? "" : url.slice(i);
1226
+ }
1227
+ /** Return the URL with any trailing `#fragment` removed. */
1228
+ function stripHash(url) {
1229
+ const i = url.indexOf("#");
1230
+ return i === -1 ? url : url.slice(0, i);
1231
+ }
1232
+ /** Notify in-page listeners (e.g. useRouter hooks) that navigation occurred. */
1233
+ function dispatchNavigateEvent() {
1234
+ notifyNextNavigationPagesContext();
1235
+ window.dispatchEvent(new CustomEvent("vinext:navigate"));
1236
+ }
1237
+ /**
1238
+ * Update history with the new URL and refresh the hash-only-detection tracker.
1239
+ * Centralises the `pushState`/`replaceState` branch so callers don't repeat it.
1240
+ *
1241
+ * Writes a Next.js-compatible state shape so popstate can detect non-router
1242
+ * entries, ignore stale Safari-style replays, and recover the active locale
1243
+ * across browser back/forward. Mirrors `Router.changeState` in
1244
+ * .nextjs-ref/packages/next/src/shared/lib/router/router.ts (around L1916).
1245
+ *
1246
+ * @param mode push or replace
1247
+ * @param fullUrl absolute URL committed to the browser (with basePath)
1248
+ * @param navState router-level metadata (`url`, `as`, `options`) the popstate
1249
+ * handler needs to honour stickiness — most importantly the active
1250
+ * locale and the canonical app-relative `as` path.
1251
+ */
1252
+ function updateHistory(mode, fullUrl, navState) {
1253
+ const previousKey = getRouterStateKey(window.history.state);
1254
+ const key = mode === "push" ? createHistoryKey() : previousKey ?? routerRuntimeState.currentHistoryKey ?? createHistoryKey();
1255
+ const state = {
1256
+ url: navState.url,
1257
+ as: navState.as,
1258
+ options: navState.options,
1259
+ __N: true,
1260
+ key
1261
+ };
1262
+ if (mode === "push") window.history.pushState(state, "", fullUrl);
1263
+ else window.history.replaceState(state, "", fullUrl);
1264
+ routerRuntimeState.currentHistoryKey = key;
1265
+ routerRuntimeState.lastPathnameAndSearch = window.location.pathname + window.location.search;
1266
+ routerRuntimeState.routerDidNavigate = true;
1267
+ }
1268
+ function createHistoryKey() {
1269
+ routerRuntimeState.historyKeyCounter += 1;
1270
+ return `vinext_${routerRuntimeState.historyKeyCounter.toString(36)}_${Math.random().toString(36).slice(2, 9)}`;
1271
+ }
1272
+ /**
1273
+ * Throw the canonical "no router instance" error used when a Pages Router
1274
+ * navigation method (push/replace/back/reload/prefetch/beforePopState) is
1275
+ * invoked during SSR or prerendering.
1276
+ *
1277
+ * Mirrors Next.js's `ServerRouter.push`/`replace`/etc. which all call
1278
+ * `noRouter()` in `packages/next/src/server/render.tsx`. The error message
1279
+ * matches Next.js verbatim so userland error handling and docs links work
1280
+ * unchanged.
1281
+ *
1282
+ * Ported from Next.js: packages/next/src/server/render.tsx
1283
+ * https://github.com/vercel/next.js/blob/canary/packages/next/src/server/render.tsx
1284
+ */
1285
+ function throwNoRouterInstance() {
1286
+ throw new Error("No router instance found. you should only use \"next/router\" inside the client side of your app. https://nextjs.org/docs/messages/no-router-instance");
1287
+ }
1288
+ /**
1289
+ * Shared client-side navigation flow used by both `useRouter()` and the
1290
+ * `Router` singleton. The only differences between push/replace are the
1291
+ * history method (`pushState` vs `replaceState`), the external-URL fallback
1292
+ * (`assign` vs `replace`), and the fact that push saves scroll position for
1293
+ * back/forward restoration while replace does not.
1294
+ *
1295
+ * `onStateUpdate` lets the hook trigger a `setState` re-render at the same
1296
+ * point that hashChangeComplete/routeChangeComplete fires; the singleton
1297
+ * passes no callback.
1298
+ */
1299
+ async function performNavigation(url, as, options, mode, onStateUpdate) {
1300
+ if (typeof window === "undefined") throwNoRouterInstance();
1301
+ assertSafeNavigationUrl(resolveUrl(url));
1302
+ if (as !== void 0) assertSafeNavigationUrl(String(as));
1303
+ const navigationLocale = resolveTransitionLocale(options?.locale);
1304
+ const replaceInheritedLocale = as === void 0 && options?.locale !== void 0 && typeof url !== "string" && url.pathname === void 0 && (url.query !== void 0 && Object.keys(url.query).length > 0 || typeof url.search === "string" && url.search.length > 0 || typeof url.hash === "string" && url.hash.length > 0);
1305
+ let resolved = resolveNavigationTarget(url, as, navigationLocale, replaceInheritedLocale);
1306
+ let resolvedRoute = applyNavigationLocale(resolveUrl(url), navigationLocale, replaceInheritedLocale);
1307
+ if (as === void 0 && (typeof url === "string" && options?._vinextInterpolateDynamicRoute === true || typeof url !== "string" && url.pathname === void 0 && (url.query !== void 0 && Object.keys(url.query).length > 0 || typeof url.search === "string" && url.search.length > 0))) {
1308
+ resolved = interpolateCurrentDynamicRoute(resolved);
1309
+ resolvedRoute = interpolateCurrentDynamicRoute(resolvedRoute);
1310
+ }
1311
+ if (isExternalUrl(resolved)) {
1312
+ const localPath = toSameOriginAppPath(resolved, __basePath);
1313
+ if (localPath == null) {
1314
+ if (mode === "push") window.location.assign(resolved);
1315
+ else window.location.replace(resolved);
1316
+ return true;
1317
+ }
1318
+ resolved = localPath;
1319
+ }
1320
+ if (isExternalUrl(resolvedRoute)) {
1321
+ const localPath = toSameOriginAppPath(resolvedRoute, __basePath);
1322
+ if (localPath != null) resolvedRoute = localPath;
1323
+ }
1324
+ resolved = normalizePathTrailingSlash(resolved, __trailingSlash);
1325
+ resolvedRoute = normalizePathTrailingSlash(resolvedRoute, __trailingSlash);
1326
+ let interpolatedRoute = resolvedRoute;
1327
+ if (resolvedRoute.includes("[")) {
1328
+ const projection = interpolateDynamicRouteHref(resolvedRoute, resolved, typeof url === "string" ? void 0 : url.query);
1329
+ if (projection?.href) {
1330
+ interpolatedRoute = projection.href;
1331
+ if (as === void 0 && stripHash(resolved).split("?", 1)[0] === projection.routePathname) {
1332
+ const remaining = new URLSearchParams();
1333
+ const consumed = new Set(projection.params);
1334
+ for (const [k, v] of Object.entries(projection.query)) {
1335
+ if (consumed.has(k)) continue;
1336
+ if (v === void 0) continue;
1337
+ if (Array.isArray(v)) v.forEach((entry) => remaining.append(k, entry));
1338
+ else remaining.append(k, v);
1339
+ }
1340
+ const searchStr = remaining.toString();
1341
+ const hashStr = extractHash(resolved);
1342
+ resolved = normalizePathTrailingSlash(`${projection.href.split(/[?#]/, 1)[0]}${searchStr ? `?${searchStr}` : ""}${hashStr}`, __trailingSlash);
1343
+ }
1344
+ } else interpolatedRoute = resolved;
1345
+ }
1346
+ const full = normalizePathTrailingSlash(toBrowserNavigationHref(resolved, window.location.href, __basePath), __trailingSlash);
1347
+ const fullRouteUrl = interpolatedRoute !== resolved ? normalizePathTrailingSlash(toBrowserNavigationHref(interpolatedRoute, window.location.href, __basePath), __trailingSlash) : full;
1348
+ const errorRouteHtmlFetchUrl = resolvePagesErrorHtmlFetchUrl(url, navigationLocale);
1349
+ const htmlFetchUrl = errorRouteHtmlFetchUrl ?? getPagesHtmlFetchUrl(fullRouteUrl, navigationLocale);
1350
+ const shallow = options?.shallow ?? false;
1351
+ const doScroll = options?.scroll !== false;
1352
+ const hash = extractHash(resolved);
1353
+ const scrollTarget = doScroll ? {
1354
+ x: 0,
1355
+ y: 0
1356
+ } : null;
1357
+ const navigateOptions = errorRouteHtmlFetchUrl ? {
1358
+ allowNotFoundResponse: true,
1359
+ mode,
1360
+ scroll: scrollTarget
1361
+ } : {
1362
+ mode,
1363
+ scroll: scrollTarget
1364
+ };
1365
+ const currentLocale = getCurrentUrlLocale();
1366
+ if (mode === "push" && interpolatedRoute !== resolved && stripHash(full) === routerRuntimeState.lastPathnameAndSearch && navigationLocale === currentLocale) mode = "replace";
1367
+ const navStateOptions = { shallow };
1368
+ if (navigationLocale !== void 0) navStateOptions.locale = navigationLocale;
1369
+ const resolvedNoHash = stripHash(resolved);
1370
+ const navState = {
1371
+ url: stripHash(interpolatedRoute),
1372
+ as: resolvedNoHash,
1373
+ options: navStateOptions
1374
+ };
1375
+ if (options?._h !== 1 && interpolatedRoute === resolved && isHashOnlyChange(full)) {
1376
+ if (mode === "push") saveScrollPosition();
1377
+ const eventUrl = resolveHashUrl(full);
1378
+ routerEvents.emit("hashChangeStart", eventUrl, { shallow });
1379
+ updateHistory(mode, resolved.startsWith("#") ? resolved : full, navState);
1380
+ if (doScroll) scrollToHashTarget(extractHash(resolved));
1381
+ onStateUpdate?.();
1382
+ routerEvents.emit("hashChangeComplete", eventUrl, { shallow });
1383
+ dispatchNavigateEvent();
1384
+ return true;
1385
+ }
1386
+ const appPath = getLocalPathname(resolved);
1387
+ const appPathNorm = appPath !== null ? removeTrailingSlash(appPath) : null;
1388
+ const appPathEntry = appPathNorm !== null ? getPagesRouterComponentsMap()[appPathNorm] : void 0;
1389
+ if (appPathEntry !== void 0 && "__appRouter" in appPathEntry && appPathEntry.__appRouter || ["app", "document"].includes(resolveHybridClientRouteOwner(resolved, __basePath) ?? "")) {
1390
+ if (mode === "push") window.location.assign(full);
1391
+ else window.location.replace(full);
1392
+ return new Promise(() => {});
1393
+ }
1394
+ if (mode === "push") saveScrollPosition();
1395
+ const isQueryUpdating = options?._h === 1;
1396
+ if (!isQueryUpdating) routerEvents.emit("routeChangeStart", resolved, { shallow });
1397
+ routerEvents.emit("beforeHistoryChange", resolved, { shallow });
1398
+ updateHistory(mode, full, navState);
1399
+ if (!shallow) {
1400
+ const result = await runNavigateClient(full, resolved, htmlFetchUrl, navigateOptions, fullRouteUrl);
1401
+ if (result === "cancelled") return true;
1402
+ if (result === "failed") return false;
1403
+ } else if (doScroll) if (hash) scrollToHashTarget(hash);
1404
+ else window.scrollTo(0, 0);
1405
+ onStateUpdate?.();
1406
+ if (!isQueryUpdating) routerEvents.emit("routeChangeComplete", resolved, { shallow });
1407
+ if (doScroll && hash && !shallow) scrollToHashTarget(hash);
1408
+ dispatchNavigateEvent();
1409
+ return true;
1410
+ }
1411
+ /**
1412
+ * Prefetch the resources needed for a future Pages Router navigation.
1413
+ *
1414
+ * When the client has a registered code-split loader for the target route
1415
+ * (the prod hot path), we prefetch in parallel:
1416
+ * 1. The `/_next/data/<buildId>/<page>.json` payload — same URL the actual
1417
+ * navigation will request, so a cache hit is automatic.
1418
+ * 2. The page's JS chunk — by invoking the loader thunk now. Vite's
1419
+ * dynamic `import()` machinery is responsible for fetching + caching;
1420
+ * the returned Promise is intentionally discarded.
1421
+ *
1422
+ * When no loader is registered (dev server, or an unmapped route), we fall
1423
+ * back to the legacy `<link rel="prefetch" as="document">` hint, which lets
1424
+ * the browser preload the HTML document. This matches the pre-`_next/data`
1425
+ * behaviour so dev doesn't regress.
1426
+ *
1427
+ * Ported from Next.js: `packages/next/src/client/page-loader.ts` `prefetch`
1428
+ * (the data + chunk parallel prefetch shape).
1429
+ */
1430
+ async function prefetchUrl(url) {
1431
+ if (typeof document === "undefined") return;
1432
+ const dataTarget = resolvePagesDataNavigationTarget(url, __basePath);
1433
+ if (dataTarget) {
1434
+ prefetchPagesData(dataTarget);
1435
+ return;
1436
+ }
1437
+ markAppRouteDetectedOnPrefetch(url, __basePath);
1438
+ const link = document.createElement("link");
1439
+ link.rel = "prefetch";
1440
+ link.href = url;
1441
+ link.as = "document";
1442
+ document.head.appendChild(link);
1443
+ }
1444
+ /**
1445
+ * useRouter hook - Pages Router compatible.
1446
+ *
1447
+ * Ported from Next.js: packages/next/src/client/router.ts
1448
+ * https://github.com/vercel/next.js/blob/canary/packages/next/src/client/router.ts
1449
+ */
1450
+ function useRouter() {
1451
+ const router = useContext(RouterContext);
1452
+ if (router) return router;
1453
+ if (typeof window !== "undefined" && window.__VINEXT_PAGE_LOADERS__ !== void 0) return Router;
1454
+ throw new Error("NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted");
1455
+ }
1456
+ function PagesRouterProvider({ children }) {
1457
+ const [{ pathname, query, asPath, isReady }, setState] = useState(getRouterSnapshot);
1458
+ useEffect(() => {
1459
+ const onNavigate = ((_e) => {
1460
+ setState(getRouterSnapshot());
1461
+ });
1462
+ window.addEventListener("vinext:navigate", onNavigate);
1463
+ let cancelled = false;
1464
+ const readyTimer = window.setTimeout(() => {
1465
+ if (cancelled) return;
1466
+ if (markPagesRouterReady()) {
1467
+ setState(getRouterSnapshot());
1468
+ notifyNextNavigationPagesContext();
1469
+ }
1470
+ }, 0);
1471
+ return () => {
1472
+ cancelled = true;
1473
+ window.clearTimeout(readyTimer);
1474
+ window.removeEventListener("vinext:navigate", onNavigate);
1475
+ };
1476
+ }, []);
1477
+ const router = useMemo(() => buildRouterValue(pathname, query, asPath, isReady, {
1478
+ push: Router.push,
1479
+ replace: Router.replace,
1480
+ back: Router.back,
1481
+ reload: Router.reload,
1482
+ prefetch: Router.prefetch,
1483
+ beforePopState: Router.beforePopState
1484
+ }), [
1485
+ pathname,
1486
+ query,
1487
+ asPath,
1488
+ isReady
1489
+ ]);
1490
+ const appRouter = useMemo(() => ({
1491
+ bfcacheId: "0",
1492
+ back() {
1493
+ Router.back();
1494
+ },
1495
+ forward() {
1496
+ if (typeof window === "undefined") throwNoRouterInstance();
1497
+ window.history.forward();
1498
+ },
1499
+ refresh() {
1500
+ Router.reload();
1501
+ },
1502
+ push(href, options) {
1503
+ Router.push(href, void 0, { scroll: options?.scroll });
1504
+ },
1505
+ replace(href, options) {
1506
+ Router.replace(href, void 0, { scroll: options?.scroll });
1507
+ },
1508
+ prefetch(href) {
1509
+ Router.prefetch(href);
1510
+ }
1511
+ }), []);
1512
+ const content = createElement(RouterContext.Provider, { value: router }, createElement(Fragment, null, children, createElement(PagesRouterHydrationMarker)));
1513
+ return AppRouterContext ? createElement(AppRouterContext.Provider, { value: appRouter }, content) : content;
1514
+ }
1515
+ function isNextRouterState(state) {
1516
+ return typeof state === "object" && state !== null && "__N" in state && state.__N === true && "url" in state && typeof state.url === "string" && "as" in state && typeof state.as === "string" && "options" in state && typeof state.options === "object" && state.options !== null;
1517
+ }
1518
+ function getRouterStateKey(state) {
1519
+ if (!isNextRouterState(state)) return void 0;
1520
+ return typeof state.key === "string" ? state.key : void 0;
1521
+ }
1522
+ function handlePagesRouterPopState(e) {
1523
+ const browserUrl = window.location.pathname + window.location.search;
1524
+ const appUrl = stripBasePath(window.location.pathname, __basePath) + window.location.search;
1525
+ const state = e.state;
1526
+ const wasFirst = routerRuntimeState.isFirstPopStateEvent;
1527
+ routerRuntimeState.isFirstPopStateEvent = false;
1528
+ if (state !== null && state !== void 0 && !isNextRouterState(state)) return;
1529
+ if (wasFirst && !routerRuntimeState.routerDidNavigate && isNextRouterState(state)) {
1530
+ const currentLocale = window.__VINEXT_LOCALE__;
1531
+ if (state.options?.locale === currentLocale && typeof state.as === "string" && withBasePath(state.as, __basePath) === routerRuntimeState.lastPathnameAndSearch) return;
1532
+ }
1533
+ const isHashOnly = browserUrl === routerRuntimeState.lastPathnameAndSearch;
1534
+ const targetKey = getRouterStateKey(state);
1535
+ let forcedScroll;
1536
+ if (manualScrollRestoration) {
1537
+ const currentKey = routerRuntimeState.currentHistoryKey;
1538
+ if (currentKey !== void 0 && currentKey !== targetKey) saveScrollPositionToSessionStorage(currentKey, getWindowScrollPosition());
1539
+ if (targetKey !== void 0 && currentKey !== targetKey) forcedScroll = readScrollPositionFromSessionStorage(targetKey) ?? {
1540
+ x: 0,
1541
+ y: 0
1542
+ };
1543
+ }
1544
+ if (routerRuntimeState.beforePopStateCb !== void 0) {
1545
+ const beforePopStateState = isNextRouterState(state) ? {
1546
+ url: state.url,
1547
+ as: state.as,
1548
+ options: state.options
1549
+ } : {
1550
+ url: appUrl,
1551
+ as: appUrl,
1552
+ options: { shallow: false }
1553
+ };
1554
+ if (!routerRuntimeState.beforePopStateCb({ ...beforePopStateState })) return;
1555
+ }
1556
+ if (targetKey !== void 0) routerRuntimeState.currentHistoryKey = targetKey;
1557
+ routerRuntimeState.lastPathnameAndSearch = browserUrl;
1558
+ if (isHashOnly) {
1559
+ const hashUrl = appUrl + window.location.hash;
1560
+ routerEvents.emit("hashChangeStart", hashUrl, { shallow: false });
1561
+ scrollToHashTarget(window.location.hash);
1562
+ routerEvents.emit("hashChangeComplete", hashUrl, { shallow: false });
1563
+ dispatchNavigateEvent();
1564
+ return;
1565
+ }
1566
+ const stateLocale = isNextRouterState(state) ? state.options?.locale : void 0;
1567
+ const effectiveLocale = typeof stateLocale === "string" ? stateLocale : window.__VINEXT_LOCALE__;
1568
+ const fullAppUrl = appUrl + window.location.hash;
1569
+ routerEvents.emit("routeChangeStart", fullAppUrl, { shallow: false });
1570
+ routerEvents.emit("beforeHistoryChange", fullAppUrl, { shallow: false });
1571
+ (async () => {
1572
+ const scrollTarget = manualScrollRestoration ? forcedScroll ?? readScrollPosition(state) ?? {
1573
+ x: 0,
1574
+ y: 0
1575
+ } : readScrollPosition(state);
1576
+ const stateRouteUrl = (() => {
1577
+ if (isNextRouterState(state) && typeof state.url === "string" && typeof state.as === "string" && state.url !== state.as) return normalizePathTrailingSlash(withBasePath(state.url, __basePath), __trailingSlash);
1578
+ return browserUrl;
1579
+ })();
1580
+ if (await runNavigateClient(browserUrl, fullAppUrl, getPagesHtmlFetchUrl(stateRouteUrl, effectiveLocale), { scroll: scrollTarget }, stateRouteUrl) === "completed") {
1581
+ routerEvents.emit("routeChangeComplete", fullAppUrl, { shallow: false });
1582
+ dispatchNavigateEvent();
1583
+ }
1584
+ })();
1585
+ }
1586
+ setPagesRouterPopStateHandler(handlePagesRouterPopState);
1587
+ /**
1588
+ * Wrap a React element in a RouterContext.Provider so that
1589
+ * next/compat/router's useRouter() returns the real Pages Router value.
1590
+ *
1591
+ * The provider owns the reactive Pages Router snapshot so next/router and
1592
+ * next/compat/router consumers share one context value instead of each hook
1593
+ * installing its own global URL-change listener.
1594
+ *
1595
+ * The PagesRouterCommitBoundary exists for client navigations: its layout
1596
+ * callback runs scroll restoration at commit time and resolves the navigation
1597
+ * at the same root-commit boundary Next.js awaits before routeChangeComplete.
1598
+ * Its onError rejection drives the hard-navigation fallback in runNavigateClient.
1599
+ * The same boundary intentionally also wraps SSR and initial hydration, where
1600
+ * callbacks default to noopCommit: a hydration-time render error is caught
1601
+ * here (React still console.error's it) instead of propagating, matching the
1602
+ * navigation-path containment.
1603
+ */
1604
+ function wrapWithRouterContext(element, onCommit = noopCommit, onError = noopCommit) {
1605
+ const { CommitBoundary, Provider } = getPagesRouterRuntimeComponents();
1606
+ return createElement(CommitBoundary, {
1607
+ onCommit,
1608
+ onError
1609
+ }, createElement(Provider, null, element));
1610
+ }
1611
+ /**
1612
+ * Higher-order component that injects the Pages Router `router` instance as
1613
+ * a `router` prop into a wrapped component. Primarily used by class
1614
+ * components (which cannot call hooks) to access the router. The wrapped
1615
+ * component receives the same props as the original, minus `router`, which
1616
+ * is filled in by the HOC.
1617
+ *
1618
+ * Ported from Next.js: packages/next/src/client/with-router.tsx
1619
+ * https://github.com/vercel/next.js/blob/canary/packages/next/src/client/with-router.tsx
1620
+ *
1621
+ * Differences from Next.js:
1622
+ * - We type the composed component as `ComponentType<P>` instead of
1623
+ * `NextComponentType<C, any, P>` because vinext does not expose
1624
+ * `NextComponentType` from this shim. The runtime shape (and the props
1625
+ * the wrapper forwards) is identical.
1626
+ * - We forward `getInitialProps` and `origGetInitialProps` from the
1627
+ * composed component so `_app` parity holds for class components that
1628
+ * define `getInitialProps`.
1629
+ */
1630
+ function withRouter(ComposedComponent) {
1631
+ function WithRouterWrapper(props) {
1632
+ return createElement(ComposedComponent, {
1633
+ router: useRouter(),
1634
+ ...props
1635
+ });
1636
+ }
1637
+ const composed = ComposedComponent;
1638
+ WithRouterWrapper.getInitialProps = composed.getInitialProps;
1639
+ WithRouterWrapper.origGetInitialProps = composed.origGetInitialProps;
1640
+ if (process.env.NODE_ENV !== "production") WithRouterWrapper.displayName = `withRouter(${composed.displayName || composed.name || "Unknown"})`;
1641
+ return WithRouterWrapper;
1642
+ }
1643
+ const RouterMethods = {
1644
+ /** See `_components` comment above for the dual role this map plays. */
1645
+ components: getPagesRouterComponentsMap(),
1646
+ push: (url, as, options) => {
1647
+ if (typeof window === "undefined") throwNoRouterInstance();
1648
+ assertSafeNavigationUrl(resolveUrl(url));
1649
+ if (as !== void 0) assertSafeNavigationUrl(String(as));
1650
+ return performNavigation(url, as, options, "push");
1651
+ },
1652
+ replace: (url, as, options) => {
1653
+ if (typeof window === "undefined") throwNoRouterInstance();
1654
+ assertSafeNavigationUrl(resolveUrl(url));
1655
+ if (as !== void 0) assertSafeNavigationUrl(String(as));
1656
+ return performNavigation(url, as, options, "replace");
1657
+ },
1658
+ back: () => {
1659
+ if (typeof window === "undefined") throwNoRouterInstance();
1660
+ window.history.back();
1661
+ },
1662
+ reload: () => {
1663
+ if (typeof window === "undefined") throwNoRouterInstance();
1664
+ window.location.reload();
1665
+ },
1666
+ prefetch: (url) => {
1667
+ if (typeof window === "undefined") throwNoRouterInstance();
1668
+ return prefetchUrl(url);
1669
+ },
1670
+ beforePopState: (cb) => {
1671
+ if (typeof window === "undefined") throwNoRouterInstance();
1672
+ routerRuntimeState.beforePopStateCb = cb;
1673
+ },
1674
+ events: routerEvents
1675
+ };
1676
+ const Router = Object.defineProperties(RouterMethods, {
1677
+ pathname: {
1678
+ enumerable: true,
1679
+ get() {
1680
+ return getPathnameAndQuery().pathname;
1681
+ }
1682
+ },
1683
+ route: {
1684
+ enumerable: true,
1685
+ get() {
1686
+ const { pathname } = getPathnameAndQuery();
1687
+ if (typeof window === "undefined") return pathname;
1688
+ return window.__NEXT_DATA__?.page ?? pathname;
1689
+ }
1690
+ },
1691
+ query: {
1692
+ enumerable: true,
1693
+ get() {
1694
+ return getPathnameAndQuery().query;
1695
+ }
1696
+ },
1697
+ asPath: {
1698
+ enumerable: true,
1699
+ get() {
1700
+ return getPathnameAndQuery().asPath;
1701
+ }
1702
+ },
1703
+ basePath: {
1704
+ enumerable: true,
1705
+ value: __basePath,
1706
+ writable: false
1707
+ },
1708
+ locale: {
1709
+ enumerable: true,
1710
+ get() {
1711
+ if (typeof window === "undefined") return _getSSRContext()?.locale;
1712
+ return window.__VINEXT_LOCALE__;
1713
+ }
1714
+ },
1715
+ locales: {
1716
+ enumerable: true,
1717
+ get() {
1718
+ if (typeof window === "undefined") return _getSSRContext()?.locales;
1719
+ return window.__VINEXT_LOCALES__;
1720
+ }
1721
+ },
1722
+ defaultLocale: {
1723
+ enumerable: true,
1724
+ get() {
1725
+ if (typeof window === "undefined") return _getSSRContext()?.defaultLocale;
1726
+ return window.__VINEXT_DEFAULT_LOCALE__;
1727
+ }
1728
+ },
1729
+ domainLocales: {
1730
+ enumerable: true,
1731
+ get() {
1732
+ if (typeof window === "undefined") return _getSSRContext()?.domainLocales;
1733
+ return window.__NEXT_DATA__?.domainLocales;
1734
+ }
1735
+ },
1736
+ isReady: {
1737
+ enumerable: true,
1738
+ get() {
1739
+ return isPagesRouterReady() && (typeof window === "undefined" || window.__NEXT_HYDRATED === true);
1740
+ }
1741
+ },
1742
+ isPreview: {
1743
+ enumerable: true,
1744
+ value: false,
1745
+ writable: false
1746
+ },
1747
+ isFallback: {
1748
+ enumerable: true,
1749
+ get() {
1750
+ if (typeof window === "undefined") return _getSSRContext()?.isFallback === true;
1751
+ return window.__NEXT_DATA__?.isFallback === true;
1752
+ }
1753
+ }
1754
+ });
1755
+ routerRuntimeState.publicRouter = Router;
1756
+ const deprecatedRouterEvents = [
1757
+ "routeChangeStart",
1758
+ "beforeHistoryChange",
1759
+ "routeChangeComplete",
1760
+ "routeChangeError",
1761
+ "hashChangeStart",
1762
+ "hashChangeComplete"
1763
+ ];
1764
+ if (!routerRuntimeState.deprecatedEventBridgeInstalled) {
1765
+ routerRuntimeState.deprecatedEventBridgeInstalled = true;
1766
+ for (const event of deprecatedRouterEvents) {
1767
+ const eventField = `on${event.charAt(0).toUpperCase()}${event.substring(1)}`;
1768
+ routerEvents.on(event, (...args) => {
1769
+ const handler = (routerRuntimeState.publicRouter ?? Router)[eventField];
1770
+ if (typeof handler === "function") try {
1771
+ handler(...args);
1772
+ } catch (err) {
1773
+ console.error(`Error when running the Router event: ${eventField}`);
1774
+ console.error(err instanceof Error ? `${err.message}\n${err.stack}` : String(err));
1775
+ }
1776
+ });
1777
+ }
1778
+ }
1779
+ if (typeof window !== "undefined") {
1780
+ installPagesRouterRuntime();
1781
+ installWindowNext({ router: Router });
1782
+ }
1783
+ const _PAGES_NAVIGATION_ACCESSOR_KEY = Symbol.for("vinext.navigation.pagesNavigationContextAccessor");
1784
+ globalThis[_PAGES_NAVIGATION_ACCESSOR_KEY] = getPagesNavigationContext;
1785
+ //#endregion
1786
+ export { initializePagesRouterReadyFromNextData as _initializePagesRouterReadyFromNextData, markPagesRouterReady as _markPagesRouterReady, _registerRouterStateAccessors, applyNavigationLocale, Router as default, getPagesNavigationContext, getPagesNavigationIsReadyFromSerializedState, isExternalUrl, isHashOnlyChange, setSSRContext, useRouter, withRouter, wrapWithRouterContext };