vinext 1.0.0-beta.0 → 1.0.0-beta.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 (305) hide show
  1. package/README.md +21 -2
  2. package/dist/build/assets-ignore.js +1 -1
  3. package/dist/build/clean-output.js +1 -1
  4. package/dist/build/client-build-config.js +7 -4
  5. package/dist/build/css-url-assets.js +3 -3
  6. package/dist/build/google-fonts/fallback-metrics.js +1 -1
  7. package/dist/build/google-fonts/font-metadata.js +1 -1
  8. package/dist/build/inject-pregenerated-paths.js +1 -1
  9. package/dist/build/inline-css.js +2 -5
  10. package/dist/build/module-dependency-cache.d.ts +4 -0
  11. package/dist/build/module-dependency-cache.js +13 -0
  12. package/dist/build/next-client-runtime-manifests.js +1 -1
  13. package/dist/build/pages-client-assets-module.js +1 -1
  14. package/dist/build/precompress.js +7 -7
  15. package/dist/build/prerender-paths.d.ts +2 -2
  16. package/dist/build/prerender-paths.js +10 -15
  17. package/dist/build/prerender-server-pool.js +2 -2
  18. package/dist/build/prerender.js +1 -1
  19. package/dist/build/preview-credentials.d.ts +11 -0
  20. package/dist/build/preview-credentials.js +19 -0
  21. package/dist/build/report.d.ts +8 -4
  22. package/dist/build/report.js +14 -6
  23. package/dist/build/run-prerender.d.ts +2 -11
  24. package/dist/build/run-prerender.js +2 -10
  25. package/dist/build/server-manifest.js +1 -1
  26. package/dist/build/ssr-manifest.d.ts +4 -0
  27. package/dist/build/ssr-manifest.js +10 -6
  28. package/dist/build/standalone.js +37 -37
  29. package/dist/cache/cache-adapters-virtual.d.ts +1 -17
  30. package/dist/cache/cache-adapters-virtual.js +20 -11
  31. package/dist/check.d.ts +0 -16
  32. package/dist/check.js +27 -36
  33. package/dist/cli.js +61 -55
  34. package/dist/client/instrumentation-client-inject.js +1 -1
  35. package/dist/client/pages-router-link-navigation.js +1 -1
  36. package/dist/config/config-matchers.d.ts +13 -37
  37. package/dist/config/config-matchers.js +33 -123
  38. package/dist/config/dotenv.js +1 -1
  39. package/dist/config/next-config.d.ts +7 -3
  40. package/dist/config/next-config.js +84 -15
  41. package/dist/config/prerender.d.ts +2 -2
  42. package/dist/config/prerender.js +7 -15
  43. package/dist/config/request-context.d.ts +14 -0
  44. package/dist/config/request-context.js +26 -0
  45. package/dist/config/server-external-packages.js +1 -1
  46. package/dist/config/tsconfig-paths.js +2 -2
  47. package/dist/{node_modules/.pnpm/am-i-vibing@0.5.0/node_modules → deps/.pnpm/am-i-vibing@0.5.0/deps}/am-i-vibing/dist/detector-1yx2Hoe0.js +2 -2
  48. package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
  49. package/dist/entries/app-rsc-entry.js +39 -14
  50. package/dist/entries/app-rsc-manifest.js +21 -4
  51. package/dist/entries/pages-client-entry.js +6 -5
  52. package/dist/entries/pages-server-entry.js +18 -28
  53. package/dist/entries/runtime-entry-module.js +2 -2
  54. package/dist/index.js +314 -230
  55. package/dist/init-cloudflare.js +1 -1
  56. package/dist/init-platform.js +1 -1
  57. package/dist/init.d.ts +6 -4
  58. package/dist/init.js +25 -27
  59. package/dist/plugins/ast-utils.js +1 -1
  60. package/dist/plugins/dynamic-preload-metadata.js +7 -7
  61. package/dist/plugins/extensionless-dynamic-import.js +1 -1
  62. package/dist/plugins/fonts.js +3 -3
  63. package/dist/plugins/ignore-dynamic-requests.js +13 -8
  64. package/dist/plugins/import-meta-url.js +16 -17
  65. package/dist/plugins/middleware-export-validation.js +1 -1
  66. package/dist/plugins/middleware-server-only.js +2 -2
  67. package/dist/plugins/og-asset-ownership.js +7 -6
  68. package/dist/plugins/og-assets.js +5 -6
  69. package/dist/plugins/optimize-imports.js +12 -13
  70. package/dist/plugins/postcss.js +1 -1
  71. package/dist/plugins/remove-console.js +1 -1
  72. package/dist/plugins/require-context.js +1 -1
  73. package/dist/plugins/sass.js +2 -2
  74. package/dist/plugins/server-externals-manifest.js +1 -1
  75. package/dist/plugins/strip-server-exports.js +1 -1
  76. package/dist/plugins/styled-jsx.js +3 -2
  77. package/dist/plugins/typeof-window.js +1 -1
  78. package/dist/routing/app-route-graph.d.ts +16 -15
  79. package/dist/routing/app-route-graph.js +86 -88
  80. package/dist/routing/app-router.d.ts +0 -5
  81. package/dist/routing/app-router.js +12 -11
  82. package/dist/routing/file-matcher.d.ts +13 -28
  83. package/dist/routing/file-matcher.js +31 -44
  84. package/dist/routing/pages-router.js +26 -32
  85. package/dist/routing/route-matching.d.ts +14 -1
  86. package/dist/routing/route-matching.js +13 -1
  87. package/dist/routing/route-pattern.d.ts +2 -1
  88. package/dist/routing/route-pattern.js +7 -4
  89. package/dist/routing/route-trie.d.ts +5 -1
  90. package/dist/routing/route-trie.js +5 -2
  91. package/dist/server/api-handler.js +41 -33
  92. package/dist/server/app-browser-entry.js +18 -11
  93. package/dist/server/app-browser-history-controller.d.ts +1 -1
  94. package/dist/server/app-browser-history-controller.js +3 -3
  95. package/dist/server/app-browser-navigation-controller.js +4 -2
  96. package/dist/server/app-browser-server-action-client.js +1 -1
  97. package/dist/server/app-elements-wire.d.ts +2 -1
  98. package/dist/server/app-fallback-renderer.d.ts +11 -0
  99. package/dist/server/app-fallback-renderer.js +16 -2
  100. package/dist/server/app-middleware.js +2 -1
  101. package/dist/server/app-page-boundary-render.d.ts +26 -2
  102. package/dist/server/app-page-boundary-render.js +190 -55
  103. package/dist/server/app-page-cache-finalizer.d.ts +1 -1
  104. package/dist/server/app-page-cache.d.ts +1 -1
  105. package/dist/server/app-page-dispatch.d.ts +12 -2
  106. package/dist/server/app-page-dispatch.js +37 -51
  107. package/dist/server/app-page-element-builder.d.ts +8 -2
  108. package/dist/server/app-page-element-builder.js +112 -27
  109. package/dist/server/app-page-execution.d.ts +3 -1
  110. package/dist/server/app-page-execution.js +31 -39
  111. package/dist/server/app-page-head.d.ts +54 -2
  112. package/dist/server/app-page-head.js +164 -78
  113. package/dist/server/app-page-http-access-fallback-metadata.d.ts +29 -0
  114. package/dist/server/app-page-http-access-fallback-metadata.js +106 -0
  115. package/dist/server/app-page-render.d.ts +2 -2
  116. package/dist/server/app-page-render.js +1 -1
  117. package/dist/server/app-page-request.d.ts +12 -0
  118. package/dist/server/app-page-request.js +134 -14
  119. package/dist/server/app-page-route-wiring.d.ts +9 -0
  120. package/dist/server/app-page-route-wiring.js +44 -4
  121. package/dist/server/app-post-middleware-context.d.ts +1 -1
  122. package/dist/server/app-post-middleware-context.js +1 -1
  123. package/dist/server/app-route-handler-dispatch.js +31 -17
  124. package/dist/server/app-route-handler-execution.d.ts +6 -1
  125. package/dist/server/app-route-handler-execution.js +41 -15
  126. package/dist/server/app-route-handler-policy.d.ts +2 -0
  127. package/dist/server/app-route-handler-policy.js +3 -3
  128. package/dist/server/app-route-module-loader.d.ts +3 -1
  129. package/dist/server/app-route-module-loader.js +1 -0
  130. package/dist/server/app-route-tree-prefetch.js +1 -1
  131. package/dist/server/app-rsc-cache-busting.d.ts +1 -1
  132. package/dist/server/app-rsc-cache-busting.js +1 -1
  133. package/dist/server/app-rsc-errors.d.ts +1 -1
  134. package/dist/server/app-rsc-errors.js +12 -2
  135. package/dist/server/app-rsc-handler.d.ts +10 -5
  136. package/dist/server/app-rsc-handler.js +51 -23
  137. package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
  138. package/dist/server/app-rsc-redirect-flight.js +71 -0
  139. package/dist/server/app-rsc-request-normalization.d.ts +3 -2
  140. package/dist/server/app-rsc-request-normalization.js +8 -2
  141. package/dist/server/app-rsc-response-finalizer.d.ts +2 -2
  142. package/dist/server/app-rsc-response-finalizer.js +5 -11
  143. package/dist/server/app-rsc-route-matching.d.ts +20 -0
  144. package/dist/server/app-rsc-route-matching.js +87 -11
  145. package/dist/server/app-segment-config.js +15 -5
  146. package/dist/server/app-server-action-execution.d.ts +3 -1
  147. package/dist/server/app-server-action-execution.js +8 -6
  148. package/dist/server/app-ssr-entry.js +4 -1
  149. package/dist/server/app-ssr-stream.d.ts +2 -7
  150. package/dist/server/app-ssr-stream.js +5 -10
  151. package/dist/server/cache-proof.js +1 -1
  152. package/dist/server/config-headers.d.ts +24 -0
  153. package/dist/server/config-headers.js +52 -0
  154. package/dist/server/default-global-error-module.d.ts +3 -1
  155. package/dist/server/default-not-found-module.d.ts +3 -1
  156. package/dist/server/dev-initial-server-error.d.ts +1 -1
  157. package/dist/server/dev-lockfile.js +2 -3
  158. package/dist/server/dev-route-files.js +1 -1
  159. package/dist/server/dev-server.js +281 -173
  160. package/dist/server/dev-stack-sourcemap.js +4 -3
  161. package/dist/server/headers.d.ts +3 -1
  162. package/dist/server/headers.js +3 -1
  163. package/dist/server/image-optimization.js +2 -2
  164. package/dist/server/implicit-tags.js +2 -1
  165. package/dist/server/instrumentation.js +2 -2
  166. package/dist/server/isr-cache.d.ts +1 -1
  167. package/dist/server/isr-cache.js +1 -1
  168. package/dist/server/metadata-routes.js +4 -4
  169. package/dist/server/middleware-matcher-pattern.d.ts +22 -0
  170. package/dist/server/middleware-matcher-pattern.js +219 -0
  171. package/dist/server/middleware-matcher.d.ts +2 -7
  172. package/dist/server/middleware-matcher.js +13 -60
  173. package/dist/server/middleware-path-to-regexp.d.ts +14 -0
  174. package/dist/server/middleware-path-to-regexp.js +228 -0
  175. package/dist/server/middleware-response-headers.js +1 -1
  176. package/dist/server/middleware-runtime.js +5 -4
  177. package/dist/server/middleware.d.ts +2 -1
  178. package/dist/server/middleware.js +3 -2
  179. package/dist/server/navigation-planner.d.ts +2 -0
  180. package/dist/server/navigation-planner.js +8 -2
  181. package/dist/server/next-error-digest.d.ts +9 -24
  182. package/dist/server/next-error-digest.js +23 -15
  183. package/dist/server/operation-token.js +1 -1
  184. package/dist/server/pages-body-parser-config.js +2 -1
  185. package/dist/server/pages-data-route.d.ts +11 -1
  186. package/dist/server/pages-data-route.js +16 -1
  187. package/dist/server/pages-dev-hydration.d.ts +14 -0
  188. package/dist/server/pages-dev-hydration.js +83 -0
  189. package/dist/server/pages-dev-module-url.js +2 -2
  190. package/dist/server/pages-get-initial-props.d.ts +15 -2
  191. package/dist/server/pages-get-initial-props.js +16 -6
  192. package/dist/server/pages-node-compat.d.ts +13 -6
  193. package/dist/server/pages-node-compat.js +44 -45
  194. package/dist/server/pages-page-data.d.ts +4 -2
  195. package/dist/server/pages-page-data.js +20 -10
  196. package/dist/server/pages-page-handler.d.ts +4 -2
  197. package/dist/server/pages-page-handler.js +74 -43
  198. package/dist/server/pages-page-response.d.ts +2 -2
  199. package/dist/server/pages-page-response.js +1 -1
  200. package/dist/server/pages-preview.d.ts +26 -0
  201. package/dist/server/pages-preview.js +165 -0
  202. package/dist/server/pages-readiness.d.ts +5 -4
  203. package/dist/server/pages-readiness.js +4 -2
  204. package/dist/server/pages-request-pipeline.d.ts +1 -0
  205. package/dist/server/pages-request-pipeline.js +25 -11
  206. package/dist/server/pages-router-entry.js +6 -0
  207. package/dist/server/prerender-route-params.js +2 -2
  208. package/dist/server/prod-server.d.ts +1 -4
  209. package/dist/server/prod-server.js +44 -30
  210. package/dist/server/request-pipeline.d.ts +15 -29
  211. package/dist/server/request-pipeline.js +25 -60
  212. package/dist/server/rsc-stream-hints.js +122 -18
  213. package/dist/server/seed-cache.js +1 -1
  214. package/dist/server/socket-error-backstop.js +1 -1
  215. package/dist/server/static-file-cache.js +7 -8
  216. package/dist/server/worker-utils.js +1 -1
  217. package/dist/shims/app.d.ts +1 -1
  218. package/dist/shims/cache-request-state.d.ts +27 -1
  219. package/dist/shims/cache-request-state.js +60 -1
  220. package/dist/shims/cache-runtime.d.ts +12 -1
  221. package/dist/shims/cache-runtime.js +22 -7
  222. package/dist/shims/cache.d.ts +5 -5
  223. package/dist/shims/cache.js +28 -11
  224. package/dist/shims/constants.js +1 -1
  225. package/dist/shims/document.d.ts +42 -83
  226. package/dist/shims/document.js +62 -53
  227. package/dist/shims/dynamic.d.ts +5 -25
  228. package/dist/shims/dynamic.js +29 -8
  229. package/dist/shims/error-boundary.d.ts +4 -4
  230. package/dist/shims/error.d.ts +22 -6
  231. package/dist/shims/error.js +53 -15
  232. package/dist/shims/fetch-cache.js +13 -4
  233. package/dist/shims/font-google-base.d.ts +11 -4
  234. package/dist/shims/font-local.d.ts +10 -3
  235. package/dist/shims/font-utils.js +1 -1
  236. package/dist/shims/form.d.ts +1 -1
  237. package/dist/shims/head.d.ts +13 -2
  238. package/dist/shims/head.js +6 -6
  239. package/dist/shims/headers.d.ts +28 -31
  240. package/dist/shims/headers.js +115 -53
  241. package/dist/shims/image.d.ts +27 -37
  242. package/dist/shims/image.js +21 -14
  243. package/dist/shims/internal/cookie-serialize.d.ts +3 -1
  244. package/dist/shims/internal/cookie-serialize.js +3 -1
  245. package/dist/shims/internal/hybrid-client-route-owner.js +3 -1
  246. package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
  247. package/dist/shims/internal/utils.d.ts +3 -3
  248. package/dist/shims/layout-segment-context.d.ts +1 -1
  249. package/dist/shims/legacy-image.d.ts +3 -37
  250. package/dist/shims/legacy-image.js +6 -16
  251. package/dist/shims/link.d.ts +16 -21
  252. package/dist/shims/link.js +25 -13
  253. package/dist/shims/navigation-context-state.d.ts +1 -1
  254. package/dist/shims/navigation-errors.d.ts +2 -1
  255. package/dist/shims/navigation-errors.js +9 -13
  256. package/dist/shims/navigation.d.ts +8 -4
  257. package/dist/shims/navigation.js +29 -18
  258. package/dist/shims/next-shims-augmentations.d.ts +1 -0
  259. package/dist/shims/next-shims-public.d.ts +1 -0
  260. package/dist/shims/public-shim-map.json.js +103 -0
  261. package/dist/shims/readonly-url-search-params.d.ts +3 -3
  262. package/dist/shims/readonly-url-search-params.js +3 -3
  263. package/dist/shims/request-state-types.d.ts +1 -1
  264. package/dist/shims/router-state.d.ts +1 -0
  265. package/dist/shims/router.d.ts +57 -22
  266. package/dist/shims/router.js +178 -46
  267. package/dist/shims/script.d.ts +6 -10
  268. package/dist/shims/script.js +7 -4
  269. package/dist/shims/server.d.ts +45 -22
  270. package/dist/shims/server.js +46 -7
  271. package/dist/shims/slot.d.ts +1 -1
  272. package/dist/shims/thenable-params.js +1 -1
  273. package/dist/shims/unified-request-context.d.ts +1 -1
  274. package/dist/shims/unified-request-context.js +2 -0
  275. package/dist/shims/url-safety.d.ts +1 -1
  276. package/dist/shims/url-safety.js +2 -2
  277. package/dist/typegen.d.ts +8 -2
  278. package/dist/typegen.js +84 -25
  279. package/dist/utils/client-build-manifest.js +2 -2
  280. package/dist/utils/client-entry-manifest.js +1 -1
  281. package/dist/utils/client-runtime-metadata.js +1 -1
  282. package/dist/utils/commonjs-loader.js +3 -3
  283. package/dist/utils/domain-locale.d.ts +2 -2
  284. package/dist/utils/external-url.d.ts +5 -0
  285. package/dist/utils/external-url.js +7 -0
  286. package/dist/utils/mdx-scan.js +1 -1
  287. package/dist/utils/path.d.ts +1 -13
  288. package/dist/utils/path.js +1 -15
  289. package/dist/utils/plugin-options.d.ts +4 -0
  290. package/dist/utils/plugin-options.js +8 -0
  291. package/dist/utils/project.d.ts +0 -6
  292. package/dist/utils/project.js +2 -8
  293. package/dist/utils/public-routes.js +2 -2
  294. package/dist/utils/react-version.js +1 -1
  295. package/dist/utils/redirect-digest.d.ts +9 -0
  296. package/dist/utils/redirect-digest.js +25 -0
  297. package/dist/utils/regex-safety.d.ts +8 -0
  298. package/dist/utils/regex-safety.js +737 -0
  299. package/dist/utils/vinext-root.js +1 -1
  300. package/dist/utils/vite-version.d.ts +5 -2
  301. package/dist/utils/vite-version.js +43 -17
  302. package/package.json +16 -4
  303. /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
  304. /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
  305. /package/dist/{node_modules/.pnpm/process-ancestry@0.1.0/node_modules → deps/.pnpm/process-ancestry@0.1.0/deps}/process-ancestry/dist/index.js +0 -0
@@ -78,9 +78,12 @@ function buildBeforeInteractiveScriptProps(options) {
78
78
  if (options.src) scriptProps.src = options.src;
79
79
  if (options.id) scriptProps.id = options.id;
80
80
  if (options.resolvedNonce) scriptProps.nonce = options.resolvedNonce;
81
- if (options.dangerouslySetInnerHTML) scriptProps.dangerouslySetInnerHTML = { __html: escapeInlineContent(options.dangerouslySetInnerHTML.__html, "script") };
81
+ if (options.dangerouslySetInnerHTML) scriptProps.dangerouslySetInnerHTML = { __html: escapeInlineContent(stringifyInlineContent(options.dangerouslySetInnerHTML.__html), "script") };
82
82
  return scriptProps;
83
83
  }
84
+ function stringifyInlineContent(value) {
85
+ return String(value);
86
+ }
84
87
  /**
85
88
  * Extract the inline script content for a `beforeInteractive` Script element
86
89
  * with no `src`. Returns `null` when the element has neither a string-shaped
@@ -93,7 +96,7 @@ function buildBeforeInteractiveScriptProps(options) {
93
96
  * to the emit point so the rule is obvious at the boundary).
94
97
  */
95
98
  function extractBeforeInteractiveInlineContent(children, dangerouslySetInnerHTML) {
96
- if (dangerouslySetInnerHTML && typeof dangerouslySetInnerHTML.__html === "string" && dangerouslySetInnerHTML.__html.length > 0) return dangerouslySetInnerHTML.__html;
99
+ if (dangerouslySetInnerHTML && stringifyInlineContent(dangerouslySetInnerHTML.__html).length > 0) return stringifyInlineContent(dangerouslySetInnerHTML.__html);
97
100
  if (typeof children === "string" && children.length > 0) return children;
98
101
  if (Array.isArray(children) && children.every((c) => typeof c === "string")) {
99
102
  const joined = children.join("");
@@ -130,7 +133,7 @@ const REACT_TO_HTML_ATTR = {
130
133
  * `REACT_TO_HTML_ATTR`.
131
134
  */
132
135
  function collectBeforeInteractiveAttributes(rest) {
133
- const RESERVED = new Set([
136
+ const RESERVED = /* @__PURE__ */ new Set([
134
137
  "id",
135
138
  "nonce",
136
139
  "src",
@@ -220,7 +223,7 @@ function loadClientScript(props, options) {
220
223
  onReady?.();
221
224
  };
222
225
  if (dangerouslySetInnerHTML?.__html) {
223
- el.innerHTML = dangerouslySetInnerHTML.__html;
226
+ el.innerHTML = stringifyInlineContent(dangerouslySetInnerHTML.__html);
224
227
  markLoaded();
225
228
  } else if (children && typeof children === "string") {
226
229
  el.textContent = children;
@@ -9,28 +9,36 @@
9
9
  * This is a pragmatic subset — we implement the most commonly used APIs
10
10
  * rather than bug-for-bug parity with Next.js internals.
11
11
  */
12
+ /** @deprecated Import ImageResponse from `next/og` instead. */
13
+ declare function ImageResponse(): never;
14
+ type RequestInit = globalThis.RequestInit & {
15
+ nextConfig?: {
16
+ basePath?: string;
17
+ i18n?: {
18
+ locales: readonly string[];
19
+ defaultLocale: string;
20
+ domains?: ReadonlyArray<{
21
+ domain: string;
22
+ defaultLocale: string;
23
+ locales?: readonly string[];
24
+ http?: true;
25
+ }>;
26
+ } | null;
27
+ trailingSlash?: boolean;
28
+ };
29
+ signal?: AbortSignal;
30
+ duplex?: "half";
31
+ };
12
32
  declare class NextRequest extends Request {
13
33
  private _nextUrl;
14
34
  private _url;
15
35
  private _cookies;
16
- constructor(input: URL | RequestInfo, init?: RequestInit & {
17
- nextConfig?: {
18
- basePath?: string;
19
- i18n?: {
20
- locales: string[];
21
- defaultLocale: string;
22
- domains?: Array<{
23
- domain: string;
24
- defaultLocale: string;
25
- locales?: string[];
26
- }>;
27
- };
28
- trailingSlash?: boolean;
29
- };
30
- });
36
+ constructor(input: URL | RequestInfo, init?: RequestInit);
31
37
  get nextUrl(): NextURL;
32
38
  get url(): string;
33
39
  get cookies(): RequestCookies;
40
+ get page(): void;
41
+ get ua(): void;
34
42
  /**
35
43
  * Client IP address. Prefers Cloudflare's trusted CF-Connecting-IP header
36
44
  * over the spoofable X-Forwarded-For. Returns undefined if unavailable.
@@ -65,12 +73,16 @@ declare class NextResponse<_Body = unknown> extends Response {
65
73
  /**
66
74
  * Create a redirect response.
67
75
  */
68
- static redirect(url: string | URL | NextURL, init?: number | ResponseInit): NextResponse;
76
+ static redirect(url: string | URL | {
77
+ toString(): string;
78
+ }, init?: number | ResponseInit): NextResponse;
69
79
  /**
70
80
  * Create a rewrite response (middleware pattern).
71
81
  * Sets the x-middleware-rewrite header.
72
82
  */
73
- static rewrite(destination: string | URL | NextURL, init?: MiddlewareResponseInit): NextResponse;
83
+ static rewrite(destination: string | URL | {
84
+ toString(): string;
85
+ }, init?: MiddlewareResponseInit): NextResponse;
74
86
  /**
75
87
  * Continue to the next handler (middleware pattern).
76
88
  * Sets the x-middleware-next header.
@@ -176,6 +188,7 @@ declare class NextURL {
176
188
  get locales(): string[] | undefined;
177
189
  clone(): NextURL;
178
190
  toString(): string;
191
+ toJSON(): string;
179
192
  /**
180
193
  * The build ID of the Next.js application.
181
194
  * Set from `generateBuildId` in next.config.js, or a random UUID if not configured.
@@ -202,7 +215,7 @@ declare class RequestCookies {
202
215
  toString(): string;
203
216
  private _serialize;
204
217
  private _syncHeader;
205
- [Symbol.iterator](): IterableIterator<[string, CookieEntry]>;
218
+ [Symbol.iterator](): MapIterator<[string, CookieEntry]>;
206
219
  }
207
220
  declare function sealRequestHeaders(headers: Headers): Headers;
208
221
  declare function sealRequestCookies(cookies: RequestCookies): RequestCookies;
@@ -225,7 +238,7 @@ declare class ResponseCookies {
225
238
  delete(...args: [name: string] | [options: Omit<CookieOptions & {
226
239
  name: string;
227
240
  }, "maxAge" | "expires">]): this;
228
- [Symbol.iterator](): IterableIterator<[string, CookieEntry]>;
241
+ [Symbol.iterator](): MapIterator<[string, CookieEntry]>;
229
242
  /** Delete all Set-Cookie headers and re-append from the internal map. */
230
243
  private _syncHeaders;
231
244
  }
@@ -233,10 +246,12 @@ type CookieOptions = {
233
246
  path?: string;
234
247
  domain?: string;
235
248
  maxAge?: number;
236
- expires?: Date;
249
+ expires?: Date | number;
237
250
  httpOnly?: boolean;
238
251
  secure?: boolean;
239
- sameSite?: "Strict" | "Lax" | "None";
252
+ sameSite?: true | false | "strict" | "lax" | "none" | "Strict" | "Lax" | "None";
253
+ partitioned?: boolean;
254
+ priority?: "low" | "medium" | "high";
240
255
  };
241
256
  type MiddlewareResponseInit = {
242
257
  request?: {
@@ -253,8 +268,16 @@ declare class NextFetchEvent {
253
268
  sourcePage: string;
254
269
  private _waitUntilPromises;
255
270
  constructor(params: {
271
+ request?: Request;
256
272
  page: string;
273
+ context?: {
274
+ waitUntil(promise: Promise<unknown>): void;
275
+ };
257
276
  });
277
+ private _externalWaitUntil?;
278
+ get request(): void;
279
+ respondWith(): void;
280
+ passThroughOnException(): void;
258
281
  waitUntil(promise: Promise<unknown>): void;
259
282
  get waitUntilPromises(): Promise<unknown>[];
260
283
  /** Drain all waitUntil promises. Returns a single promise that settles when all are done. */
@@ -320,4 +343,4 @@ declare function connection(): Promise<void>;
320
343
  */
321
344
  declare const URLPattern: typeof globalThis.URLPattern;
322
345
  //#endregion
323
- export { MiddlewareResponseInit, NextFetchEvent, NextMiddleware, NextMiddlewareResult, NextRequest, NextResponse, NextURL, NextURLConfig, RequestCookies, ResponseCookies, URLPattern, UserAgent, after, connection, sealRequestCookies, sealRequestHeaders, userAgent, userAgentFromString };
346
+ export { ImageResponse, MiddlewareResponseInit, NextFetchEvent, NextMiddleware, NextMiddlewareResult, NextRequest, NextResponse, NextURL, NextURLConfig, RequestCookies, RequestInit, ResponseCookies, URLPattern, UserAgent, after, connection, sealRequestCookies, sealRequestHeaders, userAgent, userAgentFromString };
@@ -17,6 +17,10 @@ import { assertSafeNavigationUrl } from "./url-safety.js";
17
17
  * This is a pragmatic subset — we implement the most commonly used APIs
18
18
  * rather than bug-for-bug parity with Next.js internals.
19
19
  */
20
+ /** @deprecated Import ImageResponse from `next/og` instead. */
21
+ function ImageResponse() {
22
+ throw new Error("ImageResponse has moved from next/server to next/og");
23
+ }
20
24
  const _USE_CACHE_ALS_KEY = Symbol.for("vinext.cacheRuntime.contextAls");
21
25
  const _UNSTABLE_CACHE_ALS_KEY = Symbol.for("vinext.unstableCache.als");
22
26
  const _g = globalThis;
@@ -60,10 +64,18 @@ var NextRequest = class extends Request {
60
64
  });
61
65
  } else super(input, requestInit);
62
66
  const url = typeof input === "string" ? new URL(input, "http://localhost") : input instanceof URL ? input : new URL(input.url, "http://localhost");
67
+ const i18n = _nextConfig?.i18n ? {
68
+ locales: [..._nextConfig.i18n.locales],
69
+ defaultLocale: _nextConfig.i18n.defaultLocale,
70
+ domains: _nextConfig.i18n.domains?.map((domain) => ({
71
+ ...domain,
72
+ locales: domain.locales ? [...domain.locales] : void 0
73
+ }))
74
+ } : void 0;
63
75
  const urlConfig = _nextConfig ? {
64
76
  basePath: _nextConfig.basePath,
65
77
  nextConfig: {
66
- i18n: _nextConfig.i18n,
78
+ i18n,
67
79
  trailingSlash: _nextConfig.trailingSlash
68
80
  }
69
81
  } : void 0;
@@ -80,6 +92,12 @@ var NextRequest = class extends Request {
80
92
  get cookies() {
81
93
  return this._cookies;
82
94
  }
95
+ get page() {
96
+ throw new Error("NextRequest.page has been removed; use URLPattern instead");
97
+ }
98
+ get ua() {
99
+ throw new Error("NextRequest.ua has been removed; use userAgent() instead");
100
+ }
83
101
  /**
84
102
  * Client IP address. Prefers Cloudflare's trusted CF-Connecting-IP header
85
103
  * over the spoofable X-Forwarded-For. Returns undefined if unavailable.
@@ -112,7 +130,7 @@ var NextRequest = class extends Request {
112
130
  }
113
131
  };
114
132
  /** Valid HTTP redirect status codes, matching Next.js's REDIRECTS set. */
115
- const REDIRECT_STATUSES = new Set([
133
+ const REDIRECT_STATUSES = /* @__PURE__ */ new Set([
116
134
  301,
117
135
  302,
118
136
  303,
@@ -407,6 +425,9 @@ var NextURL = class NextURL {
407
425
  toString() {
408
426
  return this.href;
409
427
  }
428
+ toJSON() {
429
+ return this.href;
430
+ }
410
431
  /**
411
432
  * The build ID of the Next.js application.
412
433
  * Set from `generateBuildId` in next.config.js, or a random UUID if not configured.
@@ -489,7 +510,7 @@ var RequestCookies = class {
489
510
  else this._headers.set("cookie", this._serialize());
490
511
  }
491
512
  [Symbol.iterator]() {
492
- return this.getAll().map((c) => [c.name, c])[Symbol.iterator]();
513
+ return new Map(this.getAll().map((cookie) => [cookie.name, cookie])).entries();
493
514
  }
494
515
  };
495
516
  var ReadonlyRequestCookiesError = class ReadonlyRequestCookiesError extends Error {
@@ -500,7 +521,7 @@ var ReadonlyRequestCookiesError = class ReadonlyRequestCookiesError extends Erro
500
521
  throw new ReadonlyRequestCookiesError();
501
522
  }
502
523
  };
503
- const REQUEST_HEADERS_MUTATING_METHODS = new Set([
524
+ const REQUEST_HEADERS_MUTATING_METHODS = /* @__PURE__ */ new Set([
504
525
  "set",
505
526
  "delete",
506
527
  "append"
@@ -557,7 +578,12 @@ var ResponseCookies = class {
557
578
  set(...args) {
558
579
  const [name, value, opts] = parseCookieSetArgs(args);
559
580
  validateCookieName(name);
560
- const serialized = serializeSetCookie(name, value, opts);
581
+ const sameSite = opts?.sameSite === true ? "Strict" : typeof opts?.sameSite === "string" ? opts.sameSite[0].toUpperCase() + opts.sameSite.slice(1) : void 0;
582
+ const serialized = serializeSetCookie(name, value, {
583
+ ...opts,
584
+ expires: typeof opts?.expires === "number" ? new Date(opts.expires) : opts?.expires,
585
+ sameSite
586
+ });
561
587
  this._parsed.set(name, {
562
588
  serialized,
563
589
  entry: {
@@ -595,7 +621,7 @@ var ResponseCookies = class {
595
621
  });
596
622
  }
597
623
  [Symbol.iterator]() {
598
- return [...this._parsed.values()].map((v) => [v.entry.name, v.entry])[Symbol.iterator]();
624
+ return new Map([...this._parsed.values()].map(({ entry }) => [entry.name, entry])).entries();
599
625
  }
600
626
  /** Delete all Set-Cookie headers and re-append from the internal map. */
601
627
  _syncHeaders() {
@@ -655,8 +681,21 @@ var NextFetchEvent = class {
655
681
  _waitUntilPromises = [];
656
682
  constructor(params) {
657
683
  this.sourcePage = params.page;
684
+ if (params.context) this._externalWaitUntil = params.context.waitUntil.bind(params.context);
685
+ }
686
+ _externalWaitUntil;
687
+ get request() {
688
+ throw new Error(`The middleware signature for ${this.sourcePage} no longer exposes event.request`);
658
689
  }
690
+ respondWith() {
691
+ throw new Error(`The middleware signature for ${this.sourcePage} no longer uses respondWith()`);
692
+ }
693
+ passThroughOnException() {}
659
694
  waitUntil(promise) {
695
+ if (this._externalWaitUntil) {
696
+ this._externalWaitUntil(promise);
697
+ return;
698
+ }
660
699
  this._waitUntilPromises.push(promise);
661
700
  }
662
701
  get waitUntilPromises() {
@@ -727,4 +766,4 @@ const URLPattern = globalThis.URLPattern ?? (() => {
727
766
  throw new Error("URLPattern is not available in this runtime. Install the `urlpattern-polyfill` package or upgrade to Node 20+.");
728
767
  });
729
768
  //#endregion
730
- export { NextFetchEvent, NextRequest, NextResponse, NextURL, RequestCookies, ResponseCookies, URLPattern, after, connection, sealRequestCookies, sealRequestHeaders, userAgent, userAgentFromString };
769
+ export { ImageResponse, NextFetchEvent, NextRequest, NextResponse, NextURL, RequestCookies, ResponseCookies, URLPattern, after, connection, sealRequestCookies, sealRequestHeaders, userAgent, userAgentFromString };
@@ -40,6 +40,6 @@ declare function ParallelSlot({
40
40
  name
41
41
  }: {
42
42
  name: string;
43
- }): string | number | bigint | boolean | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | null;
43
+ }): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React$1.ReactNode> | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | React$1.ReactPortal | null | undefined> | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | null;
44
44
  //#endregion
45
45
  export { BfcacheSlotEntry, BfcacheStateKeyMapContext, Children, ChildrenContext, ElementsContext, ParallelSlot, ParallelSlotsContext, Slot, UNMATCHED_SLOT, mergeElements, updateBfcacheSlotEntryOrder };
@@ -3,7 +3,7 @@ import { createPprFallbackShellSuspensePromiseForState, getPprFallbackShellState
3
3
  function hasParamProperty(obj, prop) {
4
4
  return Object.prototype.hasOwnProperty.call(obj, prop);
5
5
  }
6
- const wellKnownProperties = new Set([
6
+ const wellKnownProperties = /* @__PURE__ */ new Set([
7
7
  "hasOwnProperty",
8
8
  "isPrototypeOf",
9
9
  "propertyIsEnumerable",
@@ -1,5 +1,5 @@
1
- import { RootParamsState } from "./root-params.js";
2
1
  import { CacheState } from "./cache-request-state.js";
2
+ import { RootParamsState } from "./root-params.js";
3
3
  import { ExecutionContextLike } from "./request-context.js";
4
4
  import { FetchCacheState } from "./fetch-cache.js";
5
5
  import { VinextHeadersShimState } from "./headers.js";
@@ -16,6 +16,8 @@ function createRequestContext(opts) {
16
16
  return {
17
17
  headersContext: null,
18
18
  actionRevalidationKind: 0,
19
+ pendingRevalidatedTags: /* @__PURE__ */ new Set(),
20
+ pendingRevalidations: /* @__PURE__ */ new Set(),
19
21
  dynamicUsageDetected: false,
20
22
  renderRequestApiUsage: /* @__PURE__ */ new Set(),
21
23
  connectionProbe: null,
@@ -29,6 +29,6 @@ declare function isDangerousScheme(url: string): boolean;
29
29
  * packages/next/src/shared/lib/router/router.ts:1025,1057
30
30
  */
31
31
  declare function reportBlockedDangerousNavigation(): void;
32
- declare function assertSafeNavigationUrl(url: string): void;
32
+ declare function assertSafeNavigationUrl(url: string, ErrorConstructor?: new (message: string) => Error): void;
33
33
  //#endregion
34
34
  export { DANGEROUS_URL_BLOCK_MESSAGE, assertSafeNavigationUrl, isDangerousScheme, reportBlockedDangerousNavigation };
@@ -60,10 +60,10 @@ function isDangerousScheme(url) {
60
60
  function reportBlockedDangerousNavigation() {
61
61
  console.error(DANGEROUS_URL_BLOCK_MESSAGE);
62
62
  }
63
- function assertSafeNavigationUrl(url) {
63
+ function assertSafeNavigationUrl(url, ErrorConstructor = Error) {
64
64
  if (isDangerousScheme(url)) {
65
65
  reportBlockedDangerousNavigation();
66
- throw new Error(DANGEROUS_URL_BLOCK_MESSAGE);
66
+ throw new ErrorConstructor(DANGEROUS_URL_BLOCK_MESSAGE);
67
67
  }
68
68
  }
69
69
  //#endregion
package/dist/typegen.d.ts CHANGED
@@ -4,6 +4,12 @@ type GenerateRouteTypesOptions = {
4
4
  appDir?: string | null;
5
5
  pageExtensions?: readonly string[];
6
6
  };
7
- declare function generateRouteTypes(options: GenerateRouteTypesOptions): Promise<string>;
7
+ type GenerateRouteTypesResult = {
8
+ routeTypesPath: string;
9
+ nextEnvPath: string;
10
+ nextEnvStatus: "created" | "updated" | "unchanged";
11
+ };
12
+ declare function nextEnvFileContent(hasNext: boolean, hasAppDir: boolean, eol?: string): string;
13
+ declare function generateRouteTypes(options: GenerateRouteTypesOptions): Promise<GenerateRouteTypesResult>;
8
14
  //#endregion
9
- export { generateRouteTypes };
15
+ export { GenerateRouteTypesResult, generateRouteTypes, nextEnvFileContent };
package/dist/typegen.js CHANGED
@@ -1,39 +1,85 @@
1
+ import path from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { findDir } from "./utils/project.js";
2
- import { normalizePathSeparators } from "./utils/path.js";
3
3
  import { decodeRouteSegment, isInvisibleSegment } from "./routing/utils.js";
4
4
  import { patternToNextFormat } from "./routing/route-validation.js";
5
5
  import { compareStrings } from "./utils/compare.js";
6
- import "./routing/app-route-graph.js";
7
6
  import { appRouteGraph } from "./routing/app-router.js";
8
- import path from "node:path";
9
- import fs from "node:fs/promises";
7
+ import { createRequire } from "node:module";
8
+ import fsp from "node:fs/promises";
9
+ import os from "node:os";
10
10
  //#region src/typegen.ts
11
- const NEXT_ENV_FILE_CONTENT = `/// <reference types="next" />
11
+ function nextEnvFileContent(hasNext, hasAppDir, eol = "\n") {
12
+ return `${hasNext ? `/// <reference types="next" />
12
13
  /// <reference types="next/image-types/global" />
13
- import "./.next/types/routes.d.ts";
14
+ import "vinext/types/augmentations";
15
+ ` : `import "vinext/types";
16
+ `}import "./.next/types/routes.d.ts";
14
17
 
15
18
  // NOTE: This file should not be edited
16
- // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
17
- `;
19
+ // see https://nextjs.org/docs/${hasAppDir ? "app" : "pages"}/api-reference/config/typescript for more information.
20
+ `.replaceAll("\n", eol);
21
+ }
18
22
  async function generateRouteTypes(options) {
19
- const root = normalizePathSeparators(path.resolve(options.root));
20
- const appDir = options.appDir ? normalizePathSeparators(path.resolve(options.appDir)) : findDir(root, "app", "src/app");
21
- const outPath = path.posix.join(root, ".next", "types", "routes.d.ts");
22
- const content = appDir ? renderRouteTypes(await collectRouteTypeModel(appDir, options.pageExtensions)) : renderRouteTypes(emptyRouteTypeModel());
23
- await fs.mkdir(path.posix.dirname(outPath), { recursive: true });
24
- await fs.writeFile(outPath, content, "utf-8");
25
- await ensureNextEnvFile(root);
26
- return outPath;
27
- }
28
- async function ensureNextEnvFile(root) {
29
- const envPath = path.posix.join(root, "next-env.d.ts");
23
+ const root = path.resolve(options.root);
24
+ const appDir = options.appDir === null ? null : options.appDir ? path.resolve(options.appDir) : findDir(root, "app", "src/app");
25
+ const outPath = path.join(root, ".next", "types", "routes.d.ts");
26
+ const pagesDir = findDir(root, "pages", "src/pages");
27
+ const content = appDir ? renderRouteTypes(await collectRouteTypeModel(appDir, options.pageExtensions), pagesDir !== null) : renderRouteTypes(emptyRouteTypeModel(), false);
28
+ await fsp.mkdir(path.dirname(outPath), { recursive: true });
29
+ await fsp.writeFile(outPath, content, "utf-8");
30
+ const nextEnv = await ensureNextEnvFile(root, appDir !== null);
31
+ return {
32
+ routeTypesPath: outPath,
33
+ nextEnvPath: nextEnv.path,
34
+ nextEnvStatus: nextEnv.status
35
+ };
36
+ }
37
+ async function ensureNextEnvFile(root, hasAppDir) {
38
+ const envPath = path.join(root, "next-env.d.ts");
39
+ let eol = os.EOL;
40
+ let existing;
41
+ try {
42
+ existing = await fsp.readFile(envPath, "utf-8");
43
+ const newline = existing.indexOf("\n", 1);
44
+ if (newline !== -1) eol = existing[newline - 1] === "\r" ? "\r\n" : "\n";
45
+ } catch (error) {
46
+ if (error.code !== "ENOENT") throw error;
47
+ }
48
+ const content = nextEnvFileContent(await hasNextPackage(root), hasAppDir, eol);
49
+ if (existing === content) return {
50
+ path: envPath,
51
+ status: "unchanged"
52
+ };
53
+ await fsp.writeFile(envPath, content, "utf-8");
54
+ return {
55
+ path: envPath,
56
+ status: existing === void 0 ? "created" : "updated"
57
+ };
58
+ }
59
+ async function hasNextPackage(root) {
60
+ const manifestPath = path.join(root, "package.json");
61
+ let declaresNext;
30
62
  try {
31
- await fs.writeFile(envPath, NEXT_ENV_FILE_CONTENT, {
32
- encoding: "utf-8",
33
- flag: "wx"
63
+ const manifest = JSON.parse(await fsp.readFile(manifestPath, "utf-8"));
64
+ declaresNext = [
65
+ "dependencies",
66
+ "devDependencies",
67
+ "peerDependencies",
68
+ "optionalDependencies"
69
+ ].some((field) => {
70
+ const dependencies = manifest[field];
71
+ return typeof dependencies === "object" && dependencies !== null && Object.hasOwn(dependencies, "next");
34
72
  });
35
73
  } catch (error) {
36
- if (error.code !== "EEXIST") throw error;
74
+ if (error.code !== "ENOENT") throw error;
75
+ }
76
+ if (declaresNext === false) return false;
77
+ try {
78
+ const packageJsonPath = createRequire(manifestPath).resolve("next/package.json");
79
+ await fsp.access(packageJsonPath);
80
+ return true;
81
+ } catch {
82
+ return false;
37
83
  }
38
84
  }
39
85
  function emptyRouteTypeModel() {
@@ -86,12 +132,23 @@ async function collectRouteTypeModel(appDir, pageExtensions) {
86
132
  for (const slotNames of model.layoutSlots.values()) slotNames.sort(compareStrings);
87
133
  return model;
88
134
  }
89
- function renderRouteTypes(model) {
135
+ function renderRouteTypes(model, hasPagesCompat) {
90
136
  const allRoutes = uniqueSorted([
91
137
  ...model.pageRoutes,
92
138
  ...model.layoutRoutes,
93
139
  ...model.routeHandlerRoutes
94
140
  ]);
141
+ const navigationCompat = hasPagesCompat ? `
142
+ declare module "next/navigation" {
143
+ function useSearchParams(): import("next/navigation").ReadonlyURLSearchParams | null;
144
+ function usePathname(): string | null;
145
+ function useParams<
146
+ T extends Record<string, string | string[]> = Record<string, string | string[]>,
147
+ >(): T | null;
148
+ function useSelectedLayoutSegments(): string[] | null;
149
+ function useSelectedLayoutSegment(): string | null;
150
+ }
151
+ ` : "";
95
152
  return `// This file is generated by vinext. Do not edit.
96
153
  import type * as React from "react";
97
154
 
@@ -128,6 +185,8 @@ ${renderLayoutSlotMap(model.layoutRoutes, model.layoutSlots)}
128
185
  }
129
186
  }
130
187
 
188
+ ${navigationCompat}
189
+
131
190
  export {};
132
191
  `;
133
192
  }
@@ -226,4 +285,4 @@ function quote(value) {
226
285
  return JSON.stringify(value);
227
286
  }
228
287
  //#endregion
229
- export { generateRouteTypes };
288
+ export { generateRouteTypes, nextEnvFileContent };
@@ -1,7 +1,7 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { isUnknownRecord } from "./record.js";
2
3
  import { manifestFileWithBase } from "./manifest-paths.js";
3
4
  import fs from "node:fs";
4
- import path from "node:path";
5
5
  //#region src/utils/client-build-manifest.ts
6
6
  const PAGES_CLIENT_ENTRY_MARKERS = ["vinext-client-entry"];
7
7
  const CLIENT_ENTRY_MARKERS = [...PAGES_CLIENT_ENTRY_MARKERS, "vinext-app-browser-entry"];
@@ -66,7 +66,7 @@ function findClientEntryFileInAssetsDir(options) {
66
66
  if (entryFull) break;
67
67
  }
68
68
  if (!entryFull) return void 0;
69
- return manifestFileWithBase(path.relative(options.clientDir, entryFull).split(path.sep).join("/"), options.assetBase);
69
+ return manifestFileWithBase(path.relative(options.clientDir, entryFull), options.assetBase);
70
70
  }
71
71
  function findClientEntryFile(options) {
72
72
  return (options.buildManifest ? findClientEntryFileFromManifest(options.buildManifest, options.assetBase) : void 0) ?? findClientEntryFileInAssetsDir({
@@ -1,7 +1,7 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { isUnknownRecord } from "./record.js";
2
3
  import { manifestFileWithBase } from "./manifest-paths.js";
3
4
  import fs from "node:fs";
4
- import path from "node:path";
5
5
  //#region src/utils/client-entry-manifest.ts
6
6
  const VINEXT_CLIENT_ENTRY_MANIFEST = "vinext-client-entry-manifest.json";
7
7
  function readClientEntryManifest(clientDir) {
@@ -1,9 +1,9 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import { isAbsoluteAssetPrefix, resolveAssetsDir } from "./asset-prefix.js";
2
3
  import { manifestFileWithAssetPrefix, manifestFileWithBase } from "./manifest-paths.js";
3
4
  import { findClientEntryFile, findPagesClientEntryFile, readClientBuildManifest } from "./client-build-manifest.js";
4
5
  import { findClientEntryFileFromVinextManifest, findPagesClientEntryFileFromVinextManifest, readClientEntryManifest } from "./client-entry-manifest.js";
5
6
  import { computeDynamicImportPreloads, computeLazyChunks, dynamicImportPreloadsWithBase } from "./lazy-chunks.js";
6
- import path from "node:path";
7
7
  //#region src/utils/client-runtime-metadata.ts
8
8
  function collectAppBootstrapPreinitModules(buildManifest, appBrowserEntry, applyBase) {
9
9
  if (!appBrowserEntry) return void 0;
@@ -1,6 +1,6 @@
1
1
  import { Module, createRequire } from "node:module";
2
2
  import fs from "node:fs";
3
- import path from "node:path";
3
+ import nodePath from "node:path";
4
4
  import { fileURLToPath, pathToFileURL } from "node:url";
5
5
  //#region src/utils/commonjs-loader.ts
6
6
  const CommonJsModule = Module;
@@ -10,7 +10,7 @@ function canonicalPath(filePath) {
10
10
  try {
11
11
  return fs.realpathSync.native(resolvedPath);
12
12
  } catch {
13
- return path.resolve(resolvedPath);
13
+ return nodePath.resolve(resolvedPath);
14
14
  }
15
15
  }
16
16
  function shouldRetryAsCommonJs(error, resolvedPath) {
@@ -47,7 +47,7 @@ function compileCommonJsModule(resolvedPath, parent) {
47
47
  if (cached) return cached.exports;
48
48
  const mod = new CommonJsModule(resolvedPath, parent);
49
49
  mod.filename = resolvedPath;
50
- mod.paths = CommonJsModule._nodeModulePaths(path.dirname(resolvedPath));
50
+ mod.paths = CommonJsModule._nodeModulePaths(nodePath.dirname(resolvedPath));
51
51
  req.cache[resolvedPath] = mod;
52
52
  const originalRequire = mod.require.bind(mod);
53
53
  mod.require = ((specifier) => {
@@ -2,8 +2,8 @@
2
2
  type DomainLocale = {
3
3
  domain: string;
4
4
  defaultLocale: string;
5
- locales?: string[];
6
- http?: boolean;
5
+ locales?: readonly string[];
6
+ http?: true;
7
7
  };
8
8
  declare function normalizeDomainHostname(hostname: string | null | undefined): string | undefined;
9
9
  /**
@@ -0,0 +1,5 @@
1
+ //#region src/utils/external-url.d.ts
2
+ /** Detect an absolute URL with any scheme, or a protocol-relative URL. */
3
+ declare function isExternalUrl(url: string): boolean;
4
+ //#endregion
5
+ export { isExternalUrl };
@@ -0,0 +1,7 @@
1
+ //#region src/utils/external-url.ts
2
+ /** Detect an absolute URL with any scheme, or a protocol-relative URL. */
3
+ function isExternalUrl(url) {
4
+ return /^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith("//");
5
+ }
6
+ //#endregion
7
+ export { isExternalUrl };
@@ -1,5 +1,5 @@
1
+ import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
1
2
  import fs from "node:fs";
2
- import path from "node:path";
3
3
  //#region src/utils/mdx-scan.ts
4
4
  /** Module-level cache for hasMdxFiles — avoids re-scanning per Vite environment. */
5
5
  const mdxScanCache = /* @__PURE__ */ new Map();
@@ -1,17 +1,5 @@
1
1
  //#region src/utils/path.d.ts
2
2
  declare const isWindows: boolean;
3
- /**
4
- * Convert Windows-style backslash path separators to forward slashes.
5
- *
6
- * Generated entry modules embed absolute filesystem paths inside `import`
7
- * statements. On Windows the OS-native paths use `\` which is invalid in JS
8
- * module specifiers, so every entry generator normalizes paths through this
9
- * helper before stringifying them into the emitted code.
10
- *
11
- * No-op on POSIX — skips the regex scan entirely since backslashes never
12
- * appear in filesystem paths on Linux/macOS.
13
- */
14
- declare function normalizePathSeparators(p: string): string;
15
3
  declare function stripViteModuleQuery(id: string): string;
16
4
  /** Strip a trailing `.js` extension from a module specifier so
17
5
  * `resolveShimModulePath` looks for the correct base name (e.g. `headers.js`
@@ -20,4 +8,4 @@ declare function stripViteModuleQuery(id: string): string;
20
8
  * files like `headers.js.ts`. */
21
9
  declare function stripJsExtension(name: string): string;
22
10
  //#endregion
23
- export { isWindows, normalizePathSeparators, stripJsExtension, stripViteModuleQuery };
11
+ export { isWindows, stripJsExtension, stripViteModuleQuery };