vinext 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/build/static-export.d.ts +78 -0
  4. package/dist/build/static-export.d.ts.map +1 -0
  5. package/dist/build/static-export.js +553 -0
  6. package/dist/build/static-export.js.map +1 -0
  7. package/dist/check.d.ts +52 -0
  8. package/dist/check.d.ts.map +1 -0
  9. package/dist/check.js +483 -0
  10. package/dist/check.js.map +1 -0
  11. package/dist/cli.d.ts +15 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +565 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/client/entry.d.ts +2 -0
  16. package/dist/client/entry.d.ts.map +1 -0
  17. package/dist/client/entry.js +85 -0
  18. package/dist/client/entry.js.map +1 -0
  19. package/dist/cloudflare/index.d.ts +8 -0
  20. package/dist/cloudflare/index.d.ts.map +1 -0
  21. package/dist/cloudflare/index.js +8 -0
  22. package/dist/cloudflare/index.js.map +1 -0
  23. package/dist/cloudflare/kv-cache-handler.d.ts +68 -0
  24. package/dist/cloudflare/kv-cache-handler.d.ts.map +1 -0
  25. package/dist/cloudflare/kv-cache-handler.js +304 -0
  26. package/dist/cloudflare/kv-cache-handler.js.map +1 -0
  27. package/dist/cloudflare/tpr.d.ts +78 -0
  28. package/dist/cloudflare/tpr.d.ts.map +1 -0
  29. package/dist/cloudflare/tpr.js +672 -0
  30. package/dist/cloudflare/tpr.js.map +1 -0
  31. package/dist/config/config-matchers.d.ts +106 -0
  32. package/dist/config/config-matchers.d.ts.map +1 -0
  33. package/dist/config/config-matchers.js +499 -0
  34. package/dist/config/config-matchers.js.map +1 -0
  35. package/dist/config/next-config.d.ts +153 -0
  36. package/dist/config/next-config.d.ts.map +1 -0
  37. package/dist/config/next-config.js +274 -0
  38. package/dist/config/next-config.js.map +1 -0
  39. package/dist/deploy.d.ts +87 -0
  40. package/dist/deploy.d.ts.map +1 -0
  41. package/dist/deploy.js +644 -0
  42. package/dist/deploy.js.map +1 -0
  43. package/dist/index.d.ts +156 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +3296 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/init.d.ts +55 -0
  48. package/dist/init.d.ts.map +1 -0
  49. package/dist/init.js +201 -0
  50. package/dist/init.js.map +1 -0
  51. package/dist/routing/app-router.d.ts +96 -0
  52. package/dist/routing/app-router.d.ts.map +1 -0
  53. package/dist/routing/app-router.js +815 -0
  54. package/dist/routing/app-router.js.map +1 -0
  55. package/dist/routing/pages-router.d.ts +52 -0
  56. package/dist/routing/pages-router.d.ts.map +1 -0
  57. package/dist/routing/pages-router.js +239 -0
  58. package/dist/routing/pages-router.js.map +1 -0
  59. package/dist/server/api-handler.d.ts +18 -0
  60. package/dist/server/api-handler.d.ts.map +1 -0
  61. package/dist/server/api-handler.js +169 -0
  62. package/dist/server/api-handler.js.map +1 -0
  63. package/dist/server/app-dev-server.d.ts +42 -0
  64. package/dist/server/app-dev-server.d.ts.map +1 -0
  65. package/dist/server/app-dev-server.js +2718 -0
  66. package/dist/server/app-dev-server.js.map +1 -0
  67. package/dist/server/app-router-entry.d.ts +18 -0
  68. package/dist/server/app-router-entry.d.ts.map +1 -0
  69. package/dist/server/app-router-entry.js +34 -0
  70. package/dist/server/app-router-entry.js.map +1 -0
  71. package/dist/server/dev-server.d.ts +40 -0
  72. package/dist/server/dev-server.d.ts.map +1 -0
  73. package/dist/server/dev-server.js +758 -0
  74. package/dist/server/dev-server.js.map +1 -0
  75. package/dist/server/html.d.ts +22 -0
  76. package/dist/server/html.d.ts.map +1 -0
  77. package/dist/server/html.js +29 -0
  78. package/dist/server/html.js.map +1 -0
  79. package/dist/server/image-optimization.d.ts +56 -0
  80. package/dist/server/image-optimization.d.ts.map +1 -0
  81. package/dist/server/image-optimization.js +103 -0
  82. package/dist/server/image-optimization.js.map +1 -0
  83. package/dist/server/instrumentation.d.ts +68 -0
  84. package/dist/server/instrumentation.d.ts.map +1 -0
  85. package/dist/server/instrumentation.js +90 -0
  86. package/dist/server/instrumentation.js.map +1 -0
  87. package/dist/server/isr-cache.d.ts +61 -0
  88. package/dist/server/isr-cache.d.ts.map +1 -0
  89. package/dist/server/isr-cache.js +134 -0
  90. package/dist/server/isr-cache.js.map +1 -0
  91. package/dist/server/metadata-routes.d.ts +103 -0
  92. package/dist/server/metadata-routes.d.ts.map +1 -0
  93. package/dist/server/metadata-routes.js +270 -0
  94. package/dist/server/metadata-routes.js.map +1 -0
  95. package/dist/server/middleware.d.ts +77 -0
  96. package/dist/server/middleware.d.ts.map +1 -0
  97. package/dist/server/middleware.js +228 -0
  98. package/dist/server/middleware.js.map +1 -0
  99. package/dist/server/prod-server.d.ts +78 -0
  100. package/dist/server/prod-server.d.ts.map +1 -0
  101. package/dist/server/prod-server.js +712 -0
  102. package/dist/server/prod-server.js.map +1 -0
  103. package/dist/shims/amp.d.ts +17 -0
  104. package/dist/shims/amp.d.ts.map +1 -0
  105. package/dist/shims/amp.js +21 -0
  106. package/dist/shims/amp.js.map +1 -0
  107. package/dist/shims/app.d.ts +12 -0
  108. package/dist/shims/app.d.ts.map +1 -0
  109. package/dist/shims/app.js +2 -0
  110. package/dist/shims/app.js.map +1 -0
  111. package/dist/shims/cache-runtime.d.ts +68 -0
  112. package/dist/shims/cache-runtime.d.ts.map +1 -0
  113. package/dist/shims/cache-runtime.js +437 -0
  114. package/dist/shims/cache-runtime.js.map +1 -0
  115. package/dist/shims/cache.d.ts +243 -0
  116. package/dist/shims/cache.d.ts.map +1 -0
  117. package/dist/shims/cache.js +415 -0
  118. package/dist/shims/cache.js.map +1 -0
  119. package/dist/shims/client-only.d.ts +18 -0
  120. package/dist/shims/client-only.d.ts.map +1 -0
  121. package/dist/shims/client-only.js +18 -0
  122. package/dist/shims/client-only.js.map +1 -0
  123. package/dist/shims/config.d.ts +27 -0
  124. package/dist/shims/config.d.ts.map +1 -0
  125. package/dist/shims/config.js +30 -0
  126. package/dist/shims/config.js.map +1 -0
  127. package/dist/shims/constants.d.ts +13 -0
  128. package/dist/shims/constants.d.ts.map +1 -0
  129. package/dist/shims/constants.js +13 -0
  130. package/dist/shims/constants.js.map +1 -0
  131. package/dist/shims/document.d.ts +33 -0
  132. package/dist/shims/document.d.ts.map +1 -0
  133. package/dist/shims/document.js +32 -0
  134. package/dist/shims/document.js.map +1 -0
  135. package/dist/shims/dynamic.d.ts +33 -0
  136. package/dist/shims/dynamic.d.ts.map +1 -0
  137. package/dist/shims/dynamic.js +149 -0
  138. package/dist/shims/dynamic.js.map +1 -0
  139. package/dist/shims/error-boundary.d.ts +33 -0
  140. package/dist/shims/error-boundary.d.ts.map +1 -0
  141. package/dist/shims/error-boundary.js +88 -0
  142. package/dist/shims/error-boundary.js.map +1 -0
  143. package/dist/shims/error.d.ts +16 -0
  144. package/dist/shims/error.d.ts.map +1 -0
  145. package/dist/shims/error.js +45 -0
  146. package/dist/shims/error.js.map +1 -0
  147. package/dist/shims/fetch-cache.d.ts +61 -0
  148. package/dist/shims/fetch-cache.d.ts.map +1 -0
  149. package/dist/shims/fetch-cache.js +307 -0
  150. package/dist/shims/fetch-cache.js.map +1 -0
  151. package/dist/shims/font-google.d.ts +122 -0
  152. package/dist/shims/font-google.d.ts.map +1 -0
  153. package/dist/shims/font-google.js +387 -0
  154. package/dist/shims/font-google.js.map +1 -0
  155. package/dist/shims/font-local.d.ts +61 -0
  156. package/dist/shims/font-local.d.ts.map +1 -0
  157. package/dist/shims/font-local.js +303 -0
  158. package/dist/shims/font-local.js.map +1 -0
  159. package/dist/shims/form.d.ts +30 -0
  160. package/dist/shims/form.d.ts.map +1 -0
  161. package/dist/shims/form.js +78 -0
  162. package/dist/shims/form.js.map +1 -0
  163. package/dist/shims/head-state.d.ts +11 -0
  164. package/dist/shims/head-state.d.ts.map +1 -0
  165. package/dist/shims/head-state.js +47 -0
  166. package/dist/shims/head-state.js.map +1 -0
  167. package/dist/shims/head.d.ts +28 -0
  168. package/dist/shims/head.d.ts.map +1 -0
  169. package/dist/shims/head.js +148 -0
  170. package/dist/shims/head.js.map +1 -0
  171. package/dist/shims/headers.d.ts +150 -0
  172. package/dist/shims/headers.d.ts.map +1 -0
  173. package/dist/shims/headers.js +412 -0
  174. package/dist/shims/headers.js.map +1 -0
  175. package/dist/shims/image-config.d.ts +30 -0
  176. package/dist/shims/image-config.d.ts.map +1 -0
  177. package/dist/shims/image-config.js +91 -0
  178. package/dist/shims/image-config.js.map +1 -0
  179. package/dist/shims/image.d.ts +63 -0
  180. package/dist/shims/image.d.ts.map +1 -0
  181. package/dist/shims/image.js +284 -0
  182. package/dist/shims/image.js.map +1 -0
  183. package/dist/shims/internal/api-utils.d.ts +12 -0
  184. package/dist/shims/internal/api-utils.d.ts.map +1 -0
  185. package/dist/shims/internal/api-utils.js +7 -0
  186. package/dist/shims/internal/api-utils.js.map +1 -0
  187. package/dist/shims/internal/app-router-context.d.ts +21 -0
  188. package/dist/shims/internal/app-router-context.d.ts.map +1 -0
  189. package/dist/shims/internal/app-router-context.js +15 -0
  190. package/dist/shims/internal/app-router-context.js.map +1 -0
  191. package/dist/shims/internal/cookies.d.ts +9 -0
  192. package/dist/shims/internal/cookies.d.ts.map +1 -0
  193. package/dist/shims/internal/cookies.js +9 -0
  194. package/dist/shims/internal/cookies.js.map +1 -0
  195. package/dist/shims/internal/router-context.d.ts +2 -0
  196. package/dist/shims/internal/router-context.d.ts.map +1 -0
  197. package/dist/shims/internal/router-context.js +9 -0
  198. package/dist/shims/internal/router-context.js.map +1 -0
  199. package/dist/shims/internal/utils.d.ts +48 -0
  200. package/dist/shims/internal/utils.d.ts.map +1 -0
  201. package/dist/shims/internal/utils.js +35 -0
  202. package/dist/shims/internal/utils.js.map +1 -0
  203. package/dist/shims/internal/work-unit-async-storage.d.ts +12 -0
  204. package/dist/shims/internal/work-unit-async-storage.d.ts.map +1 -0
  205. package/dist/shims/internal/work-unit-async-storage.js +13 -0
  206. package/dist/shims/internal/work-unit-async-storage.js.map +1 -0
  207. package/dist/shims/layout-segment-context.d.ts +21 -0
  208. package/dist/shims/layout-segment-context.d.ts.map +1 -0
  209. package/dist/shims/layout-segment-context.js +27 -0
  210. package/dist/shims/layout-segment-context.js.map +1 -0
  211. package/dist/shims/legacy-image.d.ts +52 -0
  212. package/dist/shims/legacy-image.d.ts.map +1 -0
  213. package/dist/shims/legacy-image.js +46 -0
  214. package/dist/shims/legacy-image.js.map +1 -0
  215. package/dist/shims/link.d.ts +48 -0
  216. package/dist/shims/link.d.ts.map +1 -0
  217. package/dist/shims/link.js +395 -0
  218. package/dist/shims/link.js.map +1 -0
  219. package/dist/shims/metadata.d.ts +184 -0
  220. package/dist/shims/metadata.d.ts.map +1 -0
  221. package/dist/shims/metadata.js +472 -0
  222. package/dist/shims/metadata.js.map +1 -0
  223. package/dist/shims/navigation-state.d.ts +14 -0
  224. package/dist/shims/navigation-state.d.ts.map +1 -0
  225. package/dist/shims/navigation-state.js +77 -0
  226. package/dist/shims/navigation-state.js.map +1 -0
  227. package/dist/shims/navigation.d.ts +201 -0
  228. package/dist/shims/navigation.d.ts.map +1 -0
  229. package/dist/shims/navigation.js +672 -0
  230. package/dist/shims/navigation.js.map +1 -0
  231. package/dist/shims/og.d.ts +20 -0
  232. package/dist/shims/og.d.ts.map +1 -0
  233. package/dist/shims/og.js +19 -0
  234. package/dist/shims/og.js.map +1 -0
  235. package/dist/shims/router-state.d.ts +11 -0
  236. package/dist/shims/router-state.d.ts.map +1 -0
  237. package/dist/shims/router-state.js +56 -0
  238. package/dist/shims/router-state.js.map +1 -0
  239. package/dist/shims/router.d.ts +103 -0
  240. package/dist/shims/router.d.ts.map +1 -0
  241. package/dist/shims/router.js +536 -0
  242. package/dist/shims/router.js.map +1 -0
  243. package/dist/shims/script.d.ts +58 -0
  244. package/dist/shims/script.d.ts.map +1 -0
  245. package/dist/shims/script.js +163 -0
  246. package/dist/shims/script.js.map +1 -0
  247. package/dist/shims/server-only.d.ts +19 -0
  248. package/dist/shims/server-only.d.ts.map +1 -0
  249. package/dist/shims/server-only.js +19 -0
  250. package/dist/shims/server-only.js.map +1 -0
  251. package/dist/shims/server.d.ts +178 -0
  252. package/dist/shims/server.d.ts.map +1 -0
  253. package/dist/shims/server.js +377 -0
  254. package/dist/shims/server.js.map +1 -0
  255. package/dist/shims/web-vitals.d.ts +24 -0
  256. package/dist/shims/web-vitals.d.ts.map +1 -0
  257. package/dist/shims/web-vitals.js +17 -0
  258. package/dist/shims/web-vitals.js.map +1 -0
  259. package/dist/utils/hash.d.ts +6 -0
  260. package/dist/utils/hash.d.ts.map +1 -0
  261. package/dist/utils/hash.js +20 -0
  262. package/dist/utils/hash.js.map +1 -0
  263. package/dist/utils/project.d.ts +36 -0
  264. package/dist/utils/project.d.ts.map +1 -0
  265. package/dist/utils/project.js +112 -0
  266. package/dist/utils/project.js.map +1 -0
  267. package/dist/utils/query.d.ts +10 -0
  268. package/dist/utils/query.d.ts.map +1 -0
  269. package/dist/utils/query.js +27 -0
  270. package/dist/utils/query.js.map +1 -0
  271. package/package.json +65 -7
  272. package/index.js +0 -1
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Layout segment context provider.
3
+ *
4
+ * This is a "use client" module because it needs React's createContext
5
+ * and useContext, which are NOT available in the react-server condition.
6
+ * The RSC entry renders this as a client component boundary.
7
+ *
8
+ * The context is shared with navigation.ts via getLayoutSegmentContext()
9
+ * to avoid creating separate contexts in different modules.
10
+ */
11
+ import { type ReactNode } from "react";
12
+ /**
13
+ * Wraps children with the layout segment depth context.
14
+ * Each layout in the App Router tree wraps its children with this provider,
15
+ * passing the number of URL segments consumed up to that layout's level.
16
+ */
17
+ export declare function LayoutSegmentProvider({ depth, children, }: {
18
+ depth: number;
19
+ children: ReactNode;
20
+ }): any;
21
+ //# sourceMappingURL=layout-segment-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-segment-context.d.ts","sourceRoot":"","sources":["../../src/shims/layout-segment-context.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGtD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB,OAOA"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ /**
3
+ * Layout segment context provider.
4
+ *
5
+ * This is a "use client" module because it needs React's createContext
6
+ * and useContext, which are NOT available in the react-server condition.
7
+ * The RSC entry renders this as a client component boundary.
8
+ *
9
+ * The context is shared with navigation.ts via getLayoutSegmentContext()
10
+ * to avoid creating separate contexts in different modules.
11
+ */
12
+ import { createElement } from "react";
13
+ import { getLayoutSegmentContext } from "next/navigation";
14
+ /**
15
+ * Wraps children with the layout segment depth context.
16
+ * Each layout in the App Router tree wraps its children with this provider,
17
+ * passing the number of URL segments consumed up to that layout's level.
18
+ */
19
+ export function LayoutSegmentProvider({ depth, children, }) {
20
+ const ctx = getLayoutSegmentContext();
21
+ if (!ctx) {
22
+ // Fallback: no context available (shouldn't happen in SSR/Browser)
23
+ return children;
24
+ }
25
+ return createElement(ctx.Provider, { value: depth }, children);
26
+ }
27
+ //# sourceMappingURL=layout-segment-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-segment-context.js","sourceRoot":"","sources":["../../src/shims/layout-segment-context.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,KAAK,EACL,QAAQ,GAIT;IACC,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,mEAAmE;QACnE,OAAO,QAAe,CAAC;IACzB,CAAC;IACD,OAAO,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,CAAC;AACjE,CAAC","sourcesContent":["\"use client\";\n\n/**\n * Layout segment context provider.\n *\n * This is a \"use client\" module because it needs React's createContext\n * and useContext, which are NOT available in the react-server condition.\n * The RSC entry renders this as a client component boundary.\n *\n * The context is shared with navigation.ts via getLayoutSegmentContext()\n * to avoid creating separate contexts in different modules.\n */\nimport { createElement, type ReactNode } from \"react\";\nimport { getLayoutSegmentContext } from \"next/navigation\";\n\n/**\n * Wraps children with the layout segment depth context.\n * Each layout in the App Router tree wraps its children with this provider,\n * passing the number of URL segments consumed up to that layout's level.\n */\nexport function LayoutSegmentProvider({\n depth,\n children,\n}: {\n depth: number;\n children: ReactNode;\n}) {\n const ctx = getLayoutSegmentContext();\n if (!ctx) {\n // Fallback: no context available (shouldn't happen in SSR/Browser)\n return children as any;\n }\n return createElement(ctx.Provider, { value: depth }, children);\n}\n"]}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * next/legacy/image shim
3
+ *
4
+ * Provides the pre-Next.js 13 Image component API with layout prop.
5
+ * Translates legacy props (layout, objectFit, objectPosition) to the
6
+ * modern Image component's fill/style props.
7
+ *
8
+ * This module is used by apps that ran the `next-image-to-legacy-image`
9
+ * codemod when upgrading from Next.js 12.
10
+ */
11
+ import React from "react";
12
+ interface LegacyImageProps {
13
+ src: string | {
14
+ src: string;
15
+ width: number;
16
+ height: number;
17
+ blurDataURL?: string;
18
+ };
19
+ alt: string;
20
+ width?: number | string;
21
+ height?: number | string;
22
+ /** Legacy layout mode */
23
+ layout?: "fixed" | "intrinsic" | "responsive" | "fill";
24
+ /** CSS object-fit (used with layout="fill") */
25
+ objectFit?: React.CSSProperties["objectFit"];
26
+ /** CSS object-position (used with layout="fill") */
27
+ objectPosition?: string;
28
+ priority?: boolean;
29
+ quality?: number;
30
+ placeholder?: "blur" | "empty";
31
+ blurDataURL?: string;
32
+ loader?: (params: {
33
+ src: string;
34
+ width: number;
35
+ quality?: number;
36
+ }) => string;
37
+ sizes?: string;
38
+ className?: string;
39
+ style?: React.CSSProperties;
40
+ onLoad?: React.ReactEventHandler<HTMLImageElement>;
41
+ onLoadingComplete?: (result: {
42
+ naturalWidth: number;
43
+ naturalHeight: number;
44
+ }) => void;
45
+ onError?: React.ReactEventHandler<HTMLImageElement>;
46
+ loading?: "lazy" | "eager";
47
+ unoptimized?: boolean;
48
+ id?: string;
49
+ }
50
+ declare const LegacyImage: React.ForwardRefExoticComponent<LegacyImageProps & React.RefAttributes<HTMLImageElement>>;
51
+ export default LegacyImage;
52
+ //# sourceMappingURL=legacy-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-image.d.ts","sourceRoot":"","sources":["../../src/shims/legacy-image.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnF,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,yBAAyB;IACzB,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,CAAC;IACvD,+CAA+C;IAC/C,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACnD,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACtF,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,QAAA,MAAM,WAAW,2FAgEhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * next/legacy/image shim
4
+ *
5
+ * Provides the pre-Next.js 13 Image component API with layout prop.
6
+ * Translates legacy props (layout, objectFit, objectPosition) to the
7
+ * modern Image component's fill/style props.
8
+ *
9
+ * This module is used by apps that ran the `next-image-to-legacy-image`
10
+ * codemod when upgrading from Next.js 12.
11
+ */
12
+ import { forwardRef } from "react";
13
+ import Image from "./image.js";
14
+ const LegacyImage = forwardRef(function LegacyImage(props, ref) {
15
+ const { layout = "intrinsic", objectFit, objectPosition, onLoadingComplete, onLoad, width, height, style, ...rest } = props;
16
+ // Translate legacy props to modern Image props
17
+ const modernStyle = { ...style };
18
+ if (objectFit)
19
+ modernStyle.objectFit = objectFit;
20
+ if (objectPosition)
21
+ modernStyle.objectPosition = objectPosition;
22
+ const handleLoad = onLoadingComplete
23
+ ? (e) => {
24
+ const img = e.currentTarget;
25
+ onLoadingComplete({
26
+ naturalWidth: img.naturalWidth,
27
+ naturalHeight: img.naturalHeight,
28
+ });
29
+ onLoad?.(e);
30
+ }
31
+ : onLoad;
32
+ if (layout === "fill") {
33
+ return (_jsx(Image, { ref: ref, fill: true, style: modernStyle, onLoad: handleLoad, ...rest }));
34
+ }
35
+ if (layout === "responsive") {
36
+ // Responsive: takes full width, maintains aspect ratio
37
+ modernStyle.width = "100%";
38
+ modernStyle.height = "auto";
39
+ }
40
+ // For "fixed" and "intrinsic", pass width/height directly
41
+ const w = typeof width === "string" ? parseInt(width, 10) : width;
42
+ const h = typeof height === "string" ? parseInt(height, 10) : height;
43
+ return (_jsx(Image, { ref: ref, width: w, height: h, style: modernStyle, onLoad: handleLoad, ...rest }));
44
+ });
45
+ export default LegacyImage;
46
+ //# sourceMappingURL=legacy-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-image.js","sourceRoot":"","sources":["../../src/shims/legacy-image.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AACH,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,MAAM,YAAY,CAAC;AA6B/B,MAAM,WAAW,GAAG,UAAU,CAC5B,SAAS,WAAW,CAAC,KAAK,EAAE,GAAG;IAC7B,MAAM,EACJ,MAAM,GAAG,WAAW,EACpB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,+CAA+C;IAC/C,MAAM,WAAW,GAAwB,EAAE,GAAG,KAAK,EAAE,CAAC;IAEtD,IAAI,SAAS;QAAE,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;IACjD,IAAI,cAAc;QAAE,WAAW,CAAC,cAAc,GAAG,cAAc,CAAC;IAEhE,MAAM,UAAU,GAAG,iBAAiB;QAClC,CAAC,CAAC,CAAC,CAAyC,EAAE,EAAE;YAC5C,MAAM,GAAG,GAAG,CAAC,CAAC,aAAa,CAAC;YAC5B,iBAAiB,CAAC;gBAChB,YAAY,EAAE,GAAG,CAAC,YAAY;gBAC9B,aAAa,EAAE,GAAG,CAAC,aAAa;aACjC,CAAC,CAAC;YACH,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;QACH,CAAC,CAAC,MAAM,CAAC;IAEX,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,CACL,KAAC,KAAK,IACJ,GAAG,EAAE,GAAG,EACR,IAAI,QACJ,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,UAAU,KACd,IAAI,GACR,CACH,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,KAAK,YAAY,EAAE,CAAC;QAC5B,uDAAuD;QACvD,WAAW,CAAC,KAAK,GAAG,MAAM,CAAC;QAC3B,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;IAC9B,CAAC;IAED,0DAA0D;IAC1D,MAAM,CAAC,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,MAAM,CAAC,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAErE,OAAO,CACL,KAAC,KAAK,IACJ,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,UAAU,KACd,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["/**\n * next/legacy/image shim\n *\n * Provides the pre-Next.js 13 Image component API with layout prop.\n * Translates legacy props (layout, objectFit, objectPosition) to the\n * modern Image component's fill/style props.\n *\n * This module is used by apps that ran the `next-image-to-legacy-image`\n * codemod when upgrading from Next.js 12.\n */\nimport React, { forwardRef } from \"react\";\nimport Image from \"./image.js\";\n\ninterface LegacyImageProps {\n src: string | { src: string; width: number; height: number; blurDataURL?: string };\n alt: string;\n width?: number | string;\n height?: number | string;\n /** Legacy layout mode */\n layout?: \"fixed\" | \"intrinsic\" | \"responsive\" | \"fill\";\n /** CSS object-fit (used with layout=\"fill\") */\n objectFit?: React.CSSProperties[\"objectFit\"];\n /** CSS object-position (used with layout=\"fill\") */\n objectPosition?: string;\n priority?: boolean;\n quality?: number;\n placeholder?: \"blur\" | \"empty\";\n blurDataURL?: string;\n loader?: (params: { src: string; width: number; quality?: number }) => string;\n sizes?: string;\n className?: string;\n style?: React.CSSProperties;\n onLoad?: React.ReactEventHandler<HTMLImageElement>;\n onLoadingComplete?: (result: { naturalWidth: number; naturalHeight: number }) => void;\n onError?: React.ReactEventHandler<HTMLImageElement>;\n loading?: \"lazy\" | \"eager\";\n unoptimized?: boolean;\n id?: string;\n}\n\nconst LegacyImage = forwardRef<HTMLImageElement, LegacyImageProps>(\n function LegacyImage(props, ref) {\n const {\n layout = \"intrinsic\",\n objectFit,\n objectPosition,\n onLoadingComplete,\n onLoad,\n width,\n height,\n style,\n ...rest\n } = props;\n\n // Translate legacy props to modern Image props\n const modernStyle: React.CSSProperties = { ...style };\n\n if (objectFit) modernStyle.objectFit = objectFit;\n if (objectPosition) modernStyle.objectPosition = objectPosition;\n\n const handleLoad = onLoadingComplete\n ? (e: React.SyntheticEvent<HTMLImageElement>) => {\n const img = e.currentTarget;\n onLoadingComplete({\n naturalWidth: img.naturalWidth,\n naturalHeight: img.naturalHeight,\n });\n onLoad?.(e);\n }\n : onLoad;\n\n if (layout === \"fill\") {\n return (\n <Image\n ref={ref}\n fill\n style={modernStyle}\n onLoad={handleLoad}\n {...rest}\n />\n );\n }\n\n if (layout === \"responsive\") {\n // Responsive: takes full width, maintains aspect ratio\n modernStyle.width = \"100%\";\n modernStyle.height = \"auto\";\n }\n\n // For \"fixed\" and \"intrinsic\", pass width/height directly\n const w = typeof width === \"string\" ? parseInt(width, 10) : width;\n const h = typeof height === \"string\" ? parseInt(height, 10) : height;\n\n return (\n <Image\n ref={ref}\n width={w}\n height={h}\n style={modernStyle}\n onLoad={handleLoad}\n {...rest}\n />\n );\n },\n);\n\nexport default LegacyImage;\n"]}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * next/link shim
3
+ *
4
+ * Renders an <a> tag with client-side navigation support.
5
+ * On click, prevents full page reload and triggers client-side
6
+ * page swap via the router's navigation system.
7
+ */
8
+ import React, { type AnchorHTMLAttributes } from "react";
9
+ interface NavigateEvent {
10
+ url: URL;
11
+ /** Call to prevent the Link's default navigation (e.g. for View Transitions). */
12
+ preventDefault(): void;
13
+ /** Whether preventDefault() has been called. */
14
+ defaultPrevented: boolean;
15
+ }
16
+ interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href"> {
17
+ href: string | {
18
+ pathname?: string;
19
+ query?: Record<string, string>;
20
+ };
21
+ /** URL displayed in the browser (when href is a route pattern like /user/[id]) */
22
+ as?: string;
23
+ /** Replace the current history entry instead of pushing */
24
+ replace?: boolean;
25
+ /** Prefetch the page in the background (default: true, uses IntersectionObserver) */
26
+ prefetch?: boolean;
27
+ /** Whether to pass the href to the child element */
28
+ passHref?: boolean;
29
+ /** Scroll to top on navigation (default: true) */
30
+ scroll?: boolean;
31
+ /** Locale for i18n (used for locale-prefixed URLs) */
32
+ locale?: string | false;
33
+ /** Called before navigation happens (Next.js 16). Return value is ignored. */
34
+ onNavigate?: (event: NavigateEvent) => void;
35
+ children?: React.ReactNode;
36
+ }
37
+ interface LinkStatusContextValue {
38
+ pending: boolean;
39
+ }
40
+ /**
41
+ * useLinkStatus returns the pending state of the enclosing <Link>.
42
+ * In Next.js, this is used to show loading indicators while a
43
+ * prefetch-triggered navigation is in progress.
44
+ */
45
+ export declare function useLinkStatus(): LinkStatusContextValue;
46
+ declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
47
+ export default Link;
48
+ //# sourceMappingURL=link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/shims/link.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,EAAmF,KAAK,oBAAoB,EAAmB,MAAM,OAAO,CAAC;AAK3J,UAAU,aAAa;IACrB,GAAG,EAAE,GAAG,CAAC;IACT,iFAAiF;IACjF,cAAc,IAAI,IAAI,CAAC;IACvB,gDAAgD;IAChD,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,UAAU,SAAU,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC/E,IAAI,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACrE,kFAAkF;IAClF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACxB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAMD,UAAU,sBAAsB;IAC9B,OAAO,EAAE,OAAO,CAAC;CAClB;AAID;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,sBAAsB,CAEtD;AAmND,QAAA,MAAM,IAAI,qFAwMR,CAAC;AAEH,eAAe,IAAI,CAAC"}
@@ -0,0 +1,395 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ /**
4
+ * next/link shim
5
+ *
6
+ * Renders an <a> tag with client-side navigation support.
7
+ * On click, prevents full page reload and triggers client-side
8
+ * page swap via the router's navigation system.
9
+ */
10
+ import React, { forwardRef, useRef, useEffect, useCallback, useContext, createContext, useState } from "react";
11
+ // Import shared RSC prefetch utilities from navigation shim (relative path
12
+ // so this resolves both via the Vite plugin and in direct vitest imports)
13
+ import { toRscUrl, getPrefetchedUrls, storePrefetchResponse } from "./navigation.js";
14
+ const LinkStatusContext = createContext({ pending: false });
15
+ /**
16
+ * useLinkStatus returns the pending state of the enclosing <Link>.
17
+ * In Next.js, this is used to show loading indicators while a
18
+ * prefetch-triggered navigation is in progress.
19
+ */
20
+ export function useLinkStatus() {
21
+ return useContext(LinkStatusContext);
22
+ }
23
+ /** basePath from next.config.js, injected by the plugin at build time */
24
+ const __basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
25
+ function resolveHref(href) {
26
+ if (typeof href === "string")
27
+ return href;
28
+ let url = href.pathname ?? "/";
29
+ if (href.query) {
30
+ const params = new URLSearchParams(href.query);
31
+ url += `?${params.toString()}`;
32
+ }
33
+ return url;
34
+ }
35
+ /** Prepend basePath to an internal path for browser URLs / fetches */
36
+ function withBasePath(path) {
37
+ if (!__basePath || path.startsWith("http://") || path.startsWith("https://") || path.startsWith("//")) {
38
+ return path;
39
+ }
40
+ return __basePath + path;
41
+ }
42
+ /**
43
+ * Check if a href is only a hash change (same pathname, different/added hash).
44
+ * Handles relative hashes like "#foo" and "?query#foo".
45
+ */
46
+ function isHashOnlyChange(href) {
47
+ if (href.startsWith("#"))
48
+ return true;
49
+ try {
50
+ const current = new URL(window.location.href);
51
+ const next = new URL(href, window.location.href);
52
+ return current.pathname === next.pathname && current.search === next.search && next.hash !== "";
53
+ }
54
+ catch {
55
+ return false;
56
+ }
57
+ }
58
+ /**
59
+ * Resolve a potentially relative href against the current URL.
60
+ * Handles: "#hash", "?query", "?query#hash", relative paths.
61
+ */
62
+ function resolveRelativeHref(href) {
63
+ if (typeof window === "undefined")
64
+ return href;
65
+ // Already absolute
66
+ if (href.startsWith("/") || href.startsWith("http://") || href.startsWith("https://") || href.startsWith("//")) {
67
+ return href;
68
+ }
69
+ // Relative: resolve against current location
70
+ try {
71
+ const resolved = new URL(href, window.location.href);
72
+ return resolved.pathname + resolved.search + resolved.hash;
73
+ }
74
+ catch {
75
+ return href;
76
+ }
77
+ }
78
+ /**
79
+ * Scroll to a hash target element, or to the top if no hash.
80
+ */
81
+ function scrollToHash(hash) {
82
+ if (!hash || hash === "#") {
83
+ window.scrollTo(0, 0);
84
+ return;
85
+ }
86
+ const id = hash.slice(1); // Remove leading #
87
+ const element = document.getElementById(id);
88
+ if (element) {
89
+ element.scrollIntoView({ behavior: "auto" });
90
+ }
91
+ }
92
+ // ---------------------------------------------------------------------------
93
+ // Prefetching infrastructure
94
+ // ---------------------------------------------------------------------------
95
+ /**
96
+ * Prefetch a URL for faster navigation.
97
+ *
98
+ * For App Router (RSC): fetches the .rsc payload in the background and
99
+ * stores it in an in-memory cache for instant use during navigation.
100
+ * For Pages Router: injects a <link rel="prefetch"> for the page module.
101
+ *
102
+ * Uses `requestIdleCallback` (or `setTimeout` fallback) to avoid blocking
103
+ * the main thread during initial page load.
104
+ */
105
+ function prefetchUrl(href) {
106
+ if (typeof window === "undefined")
107
+ return;
108
+ const fullHref = withBasePath(href);
109
+ // Don't prefetch external URLs
110
+ if (fullHref.startsWith("http://") || fullHref.startsWith("https://") || fullHref.startsWith("//"))
111
+ return;
112
+ // Don't prefetch the same URL twice (keyed by rscUrl so the browser
113
+ // entry can clear the key when a cache entry is consumed)
114
+ const rscUrl = toRscUrl(fullHref);
115
+ const prefetched = getPrefetchedUrls();
116
+ if (prefetched.has(rscUrl))
117
+ return;
118
+ prefetched.add(rscUrl);
119
+ const schedule = window.requestIdleCallback ?? ((fn) => setTimeout(fn, 100));
120
+ schedule(() => {
121
+ const win = window;
122
+ if (typeof win.__VINEXT_RSC_NAVIGATE__ === "function") {
123
+ // App Router: prefetch the RSC payload and store in cache
124
+ fetch(rscUrl, {
125
+ headers: { Accept: "text/x-component" },
126
+ priority: "low",
127
+ // @ts-expect-error — purpose is a valid fetch option in some browsers
128
+ purpose: "prefetch",
129
+ }).then((response) => {
130
+ if (response.ok) {
131
+ storePrefetchResponse(rscUrl, response);
132
+ }
133
+ else {
134
+ // Non-ok response: allow retry on next viewport intersection
135
+ prefetched.delete(rscUrl);
136
+ }
137
+ }).catch(() => {
138
+ // Network error: allow retry on next viewport intersection
139
+ prefetched.delete(rscUrl);
140
+ });
141
+ }
142
+ else if (win.__NEXT_DATA__?.__vinext?.pageModuleUrl) {
143
+ // Pages Router: inject a prefetch link for the target page module
144
+ // We can't easily resolve the target page's module URL from the Link,
145
+ // so we create a <link rel="prefetch"> for the HTML page which helps
146
+ // the browser's preload scanner.
147
+ const link = document.createElement("link");
148
+ link.rel = "prefetch";
149
+ link.href = fullHref;
150
+ link.as = "document";
151
+ document.head.appendChild(link);
152
+ }
153
+ });
154
+ }
155
+ /**
156
+ * Shared IntersectionObserver for viewport-based prefetching.
157
+ * All Link elements use the same observer to minimize resource usage.
158
+ */
159
+ let sharedObserver = null;
160
+ const observerCallbacks = new WeakMap();
161
+ function getSharedObserver() {
162
+ if (typeof window === "undefined" || typeof IntersectionObserver === "undefined")
163
+ return null;
164
+ if (sharedObserver)
165
+ return sharedObserver;
166
+ sharedObserver = new IntersectionObserver((entries) => {
167
+ for (const entry of entries) {
168
+ if (entry.isIntersecting) {
169
+ const callback = observerCallbacks.get(entry.target);
170
+ if (callback) {
171
+ callback();
172
+ // Unobserve after prefetching — only prefetch once
173
+ sharedObserver?.unobserve(entry.target);
174
+ observerCallbacks.delete(entry.target);
175
+ }
176
+ }
177
+ }
178
+ }, {
179
+ // Start prefetching when the link is within 250px of the viewport.
180
+ // This gives the browser a head start before the user scrolls to it.
181
+ rootMargin: "250px",
182
+ });
183
+ return sharedObserver;
184
+ }
185
+ function getDefaultLocale() {
186
+ if (typeof window !== "undefined") {
187
+ return window.__VINEXT_DEFAULT_LOCALE__;
188
+ }
189
+ return globalThis.__VINEXT_DEFAULT_LOCALE__;
190
+ }
191
+ /**
192
+ * Apply locale prefix to a URL path based on the locale prop.
193
+ * - locale="fr" → prepend /fr (unless it already has a locale prefix)
194
+ * - locale={false} → use the href as-is (no locale prefix, link to default)
195
+ * - locale=undefined → use current locale (href as-is in most cases)
196
+ */
197
+ function applyLocaleToHref(href, locale) {
198
+ if (locale === false) {
199
+ // Explicit false: no locale prefix
200
+ return href;
201
+ }
202
+ if (locale === undefined) {
203
+ // No locale prop: keep current behavior (href as-is)
204
+ return href;
205
+ }
206
+ // locale is a string: prepend the locale prefix if not already present
207
+ const defaultLocale = getDefaultLocale();
208
+ // For the default locale, Next.js doesn't add a prefix
209
+ if (locale === defaultLocale) {
210
+ return href;
211
+ }
212
+ // Check if href already starts with the locale
213
+ if (href.startsWith(`/${locale}/`) || href === `/${locale}`) {
214
+ return href;
215
+ }
216
+ return `/${locale}${href.startsWith("/") ? href : `/${href}`}`;
217
+ }
218
+ const Link = forwardRef(function Link({ href, as, replace = false, prefetch: prefetchProp, scroll = true, children, onClick, onNavigate, ...rest }, forwardedRef) {
219
+ // Extract locale from rest props
220
+ const { locale, ...restWithoutLocale } = rest;
221
+ // If `as` is provided, use it as the actual URL (legacy Next.js pattern
222
+ // where href is a route pattern like "/user/[id]" and as is "/user/1")
223
+ const resolvedHref = as ?? resolveHref(href);
224
+ // Apply locale prefix if specified
225
+ const localizedHref = applyLocaleToHref(resolvedHref, locale);
226
+ // Full href with basePath for browser URLs and fetches
227
+ const fullHref = withBasePath(localizedHref);
228
+ // Track pending state for useLinkStatus()
229
+ const [pending, setPending] = useState(false);
230
+ const mountedRef = useRef(true);
231
+ useEffect(() => {
232
+ mountedRef.current = true;
233
+ return () => { mountedRef.current = false; };
234
+ }, []);
235
+ // Prefetching: observe the element when it enters the viewport.
236
+ // prefetch={false} disables, prefetch={true} or undefined/null (default) enables.
237
+ const internalRef = useRef(null);
238
+ const shouldPrefetch = prefetchProp !== false;
239
+ const setRefs = useCallback((node) => {
240
+ internalRef.current = node;
241
+ if (typeof forwardedRef === "function")
242
+ forwardedRef(node);
243
+ else if (forwardedRef)
244
+ forwardedRef.current = node;
245
+ }, [forwardedRef]);
246
+ useEffect(() => {
247
+ if (!shouldPrefetch || typeof window === "undefined")
248
+ return;
249
+ const node = internalRef.current;
250
+ if (!node)
251
+ return;
252
+ // Don't prefetch external URLs
253
+ if (localizedHref.startsWith("http://") || localizedHref.startsWith("https://") || localizedHref.startsWith("//"))
254
+ return;
255
+ const observer = getSharedObserver();
256
+ if (!observer)
257
+ return;
258
+ observerCallbacks.set(node, () => prefetchUrl(localizedHref));
259
+ observer.observe(node);
260
+ return () => {
261
+ observer.unobserve(node);
262
+ observerCallbacks.delete(node);
263
+ };
264
+ }, [shouldPrefetch, localizedHref]);
265
+ const handleClick = async (e) => {
266
+ if (onClick)
267
+ onClick(e);
268
+ if (e.defaultPrevented)
269
+ return;
270
+ // Only intercept left clicks without modifiers (standard link behavior)
271
+ if (e.button !== 0 ||
272
+ e.metaKey ||
273
+ e.ctrlKey ||
274
+ e.shiftKey ||
275
+ e.altKey) {
276
+ return;
277
+ }
278
+ // Don't intercept links with target (e.g. target="_blank")
279
+ if (e.currentTarget.target && e.currentTarget.target !== "_self") {
280
+ return;
281
+ }
282
+ // External links: let the browser handle it
283
+ if (resolvedHref.startsWith("http://") ||
284
+ resolvedHref.startsWith("https://") ||
285
+ resolvedHref.startsWith("//")) {
286
+ return;
287
+ }
288
+ e.preventDefault();
289
+ // Call onNavigate callback if provided (Next.js 16 View Transitions support)
290
+ if (onNavigate) {
291
+ try {
292
+ const navUrl = new URL(resolvedHref, window.location.origin);
293
+ let prevented = false;
294
+ const navEvent = {
295
+ url: navUrl,
296
+ preventDefault() { prevented = true; },
297
+ get defaultPrevented() { return prevented; },
298
+ };
299
+ onNavigate(navEvent);
300
+ // If the callback called preventDefault(), skip Link's default navigation.
301
+ // The callback is responsible for its own navigation (e.g. via View Transitions API).
302
+ if (navEvent.defaultPrevented) {
303
+ return;
304
+ }
305
+ }
306
+ catch {
307
+ // Ignore URL parsing errors for relative/hash hrefs
308
+ }
309
+ }
310
+ // Save scroll position for back/forward restoration
311
+ if (!replace) {
312
+ const state = window.history.state ?? {};
313
+ window.history.replaceState({ ...state, __vinext_scrollX: window.scrollX, __vinext_scrollY: window.scrollY }, "");
314
+ }
315
+ // Resolve relative hrefs (#hash, ?query) against current URL
316
+ const absoluteHref = resolveRelativeHref(resolvedHref);
317
+ const absoluteFullHref = withBasePath(absoluteHref);
318
+ // Hash-only change: update URL and scroll to target, skip RSC fetch
319
+ if (typeof window !== "undefined" && isHashOnlyChange(absoluteFullHref)) {
320
+ const hash = absoluteFullHref.includes("#") ? absoluteFullHref.slice(absoluteFullHref.indexOf("#")) : "";
321
+ if (replace) {
322
+ window.history.replaceState(null, "", absoluteFullHref);
323
+ }
324
+ else {
325
+ window.history.pushState(null, "", absoluteFullHref);
326
+ }
327
+ if (scroll) {
328
+ scrollToHash(hash);
329
+ }
330
+ return;
331
+ }
332
+ // Extract hash for scroll-after-navigation
333
+ const hashIdx = absoluteFullHref.indexOf("#");
334
+ const hash = hashIdx !== -1 ? absoluteFullHref.slice(hashIdx) : "";
335
+ // Try RSC navigation first (App Router), then Pages Router
336
+ const win = window;
337
+ if (typeof win.__VINEXT_RSC_NAVIGATE__ === "function") {
338
+ // App Router: push/replace history state, then fetch RSC stream.
339
+ // Await the RSC navigate so scroll-to-top happens after the new
340
+ // content is committed to the DOM (prevents flash of old page at top).
341
+ if (replace) {
342
+ window.history.replaceState(null, "", absoluteFullHref);
343
+ }
344
+ else {
345
+ window.history.pushState(null, "", absoluteFullHref);
346
+ }
347
+ setPending(true);
348
+ try {
349
+ await win.__VINEXT_RSC_NAVIGATE__(absoluteFullHref);
350
+ }
351
+ finally {
352
+ if (mountedRef.current)
353
+ setPending(false);
354
+ }
355
+ }
356
+ else {
357
+ // Pages Router: use the Router singleton
358
+ try {
359
+ const routerModule = await import("next/router");
360
+ // eslint-disable-next-line -- vinext's Router shim accepts (url, as, options)
361
+ const Router = routerModule.default;
362
+ if (replace) {
363
+ await Router.replace(absoluteHref, undefined, { scroll });
364
+ }
365
+ else {
366
+ await Router.push(absoluteHref, undefined, { scroll });
367
+ }
368
+ }
369
+ catch {
370
+ // Fallback to hard navigation if router fails
371
+ if (replace) {
372
+ window.history.replaceState({}, "", absoluteFullHref);
373
+ }
374
+ else {
375
+ window.history.pushState({}, "", absoluteFullHref);
376
+ }
377
+ window.dispatchEvent(new PopStateEvent("popstate"));
378
+ }
379
+ }
380
+ if (scroll) {
381
+ if (hash) {
382
+ scrollToHash(hash);
383
+ }
384
+ else {
385
+ window.scrollTo(0, 0);
386
+ }
387
+ }
388
+ };
389
+ // Remove props that shouldn't be on <a>
390
+ const { passHref: _p, ...anchorProps } = restWithoutLocale;
391
+ const linkStatusValue = React.useMemo(() => ({ pending }), [pending]);
392
+ return (_jsx(LinkStatusContext.Provider, { value: linkStatusValue, children: _jsx("a", { ref: setRefs, href: fullHref, onClick: handleClick, ...anchorProps, children: children }) }));
393
+ });
394
+ export default Link;
395
+ //# sourceMappingURL=link.js.map