vinext 0.0.30 → 0.0.32

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 (435) hide show
  1. package/README.md +15 -7
  2. package/dist/build/prerender.d.ts +188 -0
  3. package/dist/build/prerender.js +675 -0
  4. package/dist/build/prerender.js.map +1 -0
  5. package/dist/build/report.d.ts +45 -46
  6. package/dist/build/report.js +581 -276
  7. package/dist/build/report.js.map +1 -1
  8. package/dist/build/run-prerender.d.ts +62 -0
  9. package/dist/build/run-prerender.js +183 -0
  10. package/dist/build/run-prerender.js.map +1 -0
  11. package/dist/build/server-manifest.d.ts +19 -0
  12. package/dist/build/server-manifest.js +29 -0
  13. package/dist/build/server-manifest.js.map +1 -0
  14. package/dist/build/static-export.d.ts +51 -66
  15. package/dist/build/static-export.js +51 -545
  16. package/dist/build/static-export.js.map +1 -1
  17. package/dist/check.d.ts +26 -24
  18. package/dist/check.js +681 -571
  19. package/dist/check.js.map +1 -1
  20. package/dist/cli.d.ts +1 -15
  21. package/dist/cli.js +432 -491
  22. package/dist/cli.js.map +1 -1
  23. package/dist/client/entry.d.ts +1 -2
  24. package/dist/client/entry.js +49 -62
  25. package/dist/client/entry.js.map +1 -1
  26. package/dist/client/validate-module-path.d.ts +4 -1
  27. package/dist/client/validate-module-path.js +23 -28
  28. package/dist/client/validate-module-path.js.map +1 -1
  29. package/dist/client/vinext-next-data.d.ts +15 -20
  30. package/dist/client/vinext-next-data.js +0 -1
  31. package/dist/cloudflare/index.d.ts +3 -8
  32. package/dist/cloudflare/index.js +3 -8
  33. package/dist/cloudflare/kv-cache-handler.d.ts +95 -105
  34. package/dist/cloudflare/kv-cache-handler.js +354 -380
  35. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  36. package/dist/cloudflare/tpr.d.ts +36 -34
  37. package/dist/cloudflare/tpr.js +460 -603
  38. package/dist/cloudflare/tpr.js.map +1 -1
  39. package/dist/config/config-matchers.d.ts +31 -40
  40. package/dist/config/config-matchers.js +727 -936
  41. package/dist/config/config-matchers.js.map +1 -1
  42. package/dist/config/dotenv.d.ts +18 -11
  43. package/dist/config/dotenv.js +79 -84
  44. package/dist/config/dotenv.js.map +1 -1
  45. package/dist/config/next-config.d.ts +156 -146
  46. package/dist/config/next-config.js +376 -464
  47. package/dist/config/next-config.js.map +1 -1
  48. package/dist/deploy.d.ts +87 -96
  49. package/dist/deploy.js +490 -628
  50. package/dist/deploy.js.map +1 -1
  51. package/dist/entries/app-browser-entry.d.ts +4 -1
  52. package/dist/entries/app-browser-entry.js +12 -8
  53. package/dist/entries/app-browser-entry.js.map +1 -1
  54. package/dist/entries/app-rsc-entry.d.ts +33 -20
  55. package/dist/entries/app-rsc-entry.js +444 -212
  56. package/dist/entries/app-rsc-entry.js.map +1 -1
  57. package/dist/entries/app-ssr-entry.d.ts +9 -1
  58. package/dist/entries/app-ssr-entry.js +61 -28
  59. package/dist/entries/app-ssr-entry.js.map +1 -1
  60. package/dist/entries/pages-client-entry.d.ts +6 -2
  61. package/dist/entries/pages-client-entry.js +30 -33
  62. package/dist/entries/pages-client-entry.js.map +1 -1
  63. package/dist/entries/pages-entry-helpers.d.ts +5 -1
  64. package/dist/entries/pages-entry-helpers.js +17 -14
  65. package/dist/entries/pages-entry-helpers.js.map +1 -1
  66. package/dist/entries/pages-server-entry.d.ts +6 -2
  67. package/dist/entries/pages-server-entry.js +86 -114
  68. package/dist/entries/pages-server-entry.js.map +1 -1
  69. package/dist/index.d.ts +92 -60
  70. package/dist/index.js +2151 -3133
  71. package/dist/index.js.map +1 -1
  72. package/dist/init.d.ts +40 -37
  73. package/dist/init.js +201 -258
  74. package/dist/init.js.map +1 -1
  75. package/dist/plugins/async-hooks-stub.d.ts +7 -3
  76. package/dist/plugins/async-hooks-stub.js +39 -42
  77. package/dist/plugins/async-hooks-stub.js.map +1 -1
  78. package/dist/plugins/client-reference-dedup.d.ts +7 -3
  79. package/dist/plugins/client-reference-dedup.js +63 -88
  80. package/dist/plugins/client-reference-dedup.js.map +1 -1
  81. package/dist/routing/app-router.d.ts +100 -96
  82. package/dist/routing/app-router.js +560 -670
  83. package/dist/routing/app-router.js.map +1 -1
  84. package/dist/routing/file-matcher.d.ts +18 -15
  85. package/dist/routing/file-matcher.js +65 -65
  86. package/dist/routing/file-matcher.js.map +1 -1
  87. package/dist/routing/pages-router.d.ts +23 -24
  88. package/dist/routing/pages-router.js +147 -172
  89. package/dist/routing/pages-router.js.map +1 -1
  90. package/dist/routing/route-trie.d.ts +23 -20
  91. package/dist/routing/route-trie.js +131 -151
  92. package/dist/routing/route-trie.js.map +1 -1
  93. package/dist/routing/route-validation.d.ts +5 -2
  94. package/dist/routing/route-validation.js +98 -130
  95. package/dist/routing/route-validation.js.map +1 -1
  96. package/dist/routing/utils.d.ts +10 -7
  97. package/dist/routing/utils.js +75 -111
  98. package/dist/routing/utils.js.map +1 -1
  99. package/dist/server/api-handler.d.ts +8 -13
  100. package/dist/server/api-handler.js +160 -193
  101. package/dist/server/api-handler.js.map +1 -1
  102. package/dist/server/app-router-entry.d.ts +6 -16
  103. package/dist/server/app-router-entry.js +26 -54
  104. package/dist/server/app-router-entry.js.map +1 -1
  105. package/dist/server/dev-module-runner.d.ts +11 -64
  106. package/dist/server/dev-module-runner.js +89 -101
  107. package/dist/server/dev-module-runner.js.map +1 -1
  108. package/dist/server/dev-origin-check.d.ts +12 -10
  109. package/dist/server/dev-origin-check.js +98 -108
  110. package/dist/server/dev-origin-check.js.map +1 -1
  111. package/dist/server/dev-server.d.ts +19 -15
  112. package/dist/server/dev-server.js +543 -871
  113. package/dist/server/dev-server.js.map +1 -1
  114. package/dist/server/html.d.ts +4 -1
  115. package/dist/server/html.js +25 -26
  116. package/dist/server/html.js.map +1 -1
  117. package/dist/server/image-optimization.d.ts +31 -28
  118. package/dist/server/image-optimization.js +181 -210
  119. package/dist/server/image-optimization.js.map +1 -1
  120. package/dist/server/instrumentation.d.ts +34 -59
  121. package/dist/server/instrumentation.js +112 -125
  122. package/dist/server/instrumentation.js.map +1 -1
  123. package/dist/server/isr-cache.d.ts +16 -26
  124. package/dist/server/isr-cache.js +106 -128
  125. package/dist/server/isr-cache.js.map +1 -1
  126. package/dist/server/metadata-routes.d.ts +85 -88
  127. package/dist/server/metadata-routes.js +270 -317
  128. package/dist/server/metadata-routes.js.map +1 -1
  129. package/dist/server/middleware-codegen.d.ts +7 -4
  130. package/dist/server/middleware-codegen.js +61 -61
  131. package/dist/server/middleware-codegen.js.map +1 -1
  132. package/dist/server/middleware-request-headers.d.ts +8 -6
  133. package/dist/server/middleware-request-headers.js +47 -65
  134. package/dist/server/middleware-request-headers.js.map +1 -1
  135. package/dist/server/middleware.d.ts +32 -47
  136. package/dist/server/middleware.js +261 -409
  137. package/dist/server/middleware.js.map +1 -1
  138. package/dist/server/normalize-path.d.ts +4 -1
  139. package/dist/server/normalize-path.js +33 -47
  140. package/dist/server/normalize-path.js.map +1 -1
  141. package/dist/server/pages-i18n.d.ts +38 -30
  142. package/dist/server/pages-i18n.js +112 -139
  143. package/dist/server/pages-i18n.js.map +1 -1
  144. package/dist/server/prod-server.d.ts +19 -31
  145. package/dist/server/prod-server.js +715 -945
  146. package/dist/server/prod-server.js.map +1 -1
  147. package/dist/server/request-log.d.ts +18 -12
  148. package/dist/server/request-log.js +45 -52
  149. package/dist/server/request-log.js.map +1 -1
  150. package/dist/server/request-pipeline.d.ts +9 -17
  151. package/dist/server/request-pipeline.js +133 -184
  152. package/dist/server/request-pipeline.js.map +1 -1
  153. package/dist/server/worker-utils.d.ts +4 -1
  154. package/dist/server/worker-utils.js +31 -37
  155. package/dist/server/worker-utils.js.map +1 -1
  156. package/dist/shims/amp.d.ts +5 -2
  157. package/dist/shims/amp.js +19 -15
  158. package/dist/shims/amp.js.map +1 -1
  159. package/dist/shims/app.d.ts +8 -10
  160. package/dist/shims/app.js +0 -1
  161. package/dist/shims/cache-runtime.d.ts +20 -45
  162. package/dist/shims/cache-runtime.js +271 -422
  163. package/dist/shims/cache-runtime.js.map +1 -1
  164. package/dist/shims/cache.d.ts +130 -121
  165. package/dist/shims/cache.js +339 -427
  166. package/dist/shims/cache.js.map +1 -1
  167. package/dist/shims/client-only.d.ts +1 -18
  168. package/dist/shims/client-only.js +0 -17
  169. package/dist/shims/compat-router.d.ts +6 -1
  170. package/dist/shims/compat-router.js +23 -19
  171. package/dist/shims/compat-router.js.map +1 -1
  172. package/dist/shims/config.d.ts +7 -5
  173. package/dist/shims/config.js +16 -23
  174. package/dist/shims/config.js.map +1 -1
  175. package/dist/shims/constants.d.ts +119 -118
  176. package/dist/shims/constants.js +159 -164
  177. package/dist/shims/constants.js.map +1 -1
  178. package/dist/shims/document.d.ts +20 -16
  179. package/dist/shims/document.js +41 -22
  180. package/dist/shims/document.js.map +1 -1
  181. package/dist/shims/dynamic.d.ts +13 -22
  182. package/dist/shims/dynamic.js +122 -136
  183. package/dist/shims/dynamic.js.map +1 -1
  184. package/dist/shims/error-boundary.d.ts +22 -15
  185. package/dist/shims/error-boundary.js +81 -79
  186. package/dist/shims/error-boundary.js.map +1 -1
  187. package/dist/shims/error.d.ts +11 -12
  188. package/dist/shims/error.js +35 -39
  189. package/dist/shims/error.js.map +1 -1
  190. package/dist/shims/fetch-cache.d.ts +16 -14
  191. package/dist/shims/fetch-cache.js +439 -645
  192. package/dist/shims/fetch-cache.js.map +1 -1
  193. package/dist/shims/font-google-base.d.ts +28 -26
  194. package/dist/shims/font-google-base.js +238 -325
  195. package/dist/shims/font-google-base.js.map +1 -1
  196. package/dist/shims/font-google.d.ts +3 -3
  197. package/dist/shims/font-google.generated.d.ts +1928 -1924
  198. package/dist/shims/font-google.generated.js +1928 -2133
  199. package/dist/shims/font-google.generated.js.map +1 -1
  200. package/dist/shims/font-google.js +3 -3
  201. package/dist/shims/font-local.d.ts +28 -26
  202. package/dist/shims/font-local.js +204 -260
  203. package/dist/shims/font-local.js.map +1 -1
  204. package/dist/shims/form.d.ts +13 -27
  205. package/dist/shims/form.js +128 -180
  206. package/dist/shims/form.js.map +1 -1
  207. package/dist/shims/head-state.d.ts +8 -13
  208. package/dist/shims/head-state.js +25 -42
  209. package/dist/shims/head-state.js.map +1 -1
  210. package/dist/shims/head.d.ts +17 -20
  211. package/dist/shims/head.js +194 -250
  212. package/dist/shims/head.js.map +1 -1
  213. package/dist/shims/headers.d.ts +84 -78
  214. package/dist/shims/headers.js +447 -575
  215. package/dist/shims/headers.js.map +1 -1
  216. package/dist/shims/i18n-context.d.ts +16 -20
  217. package/dist/shims/i18n-context.js +35 -48
  218. package/dist/shims/i18n-context.js.map +1 -1
  219. package/dist/shims/i18n-state.d.ts +8 -14
  220. package/dist/shims/i18n-state.js +34 -42
  221. package/dist/shims/i18n-state.js.map +1 -1
  222. package/dist/shims/image-config.d.ts +11 -8
  223. package/dist/shims/image-config.js +50 -83
  224. package/dist/shims/image-config.js.map +1 -1
  225. package/dist/shims/image.d.ts +37 -46
  226. package/dist/shims/image.js +283 -308
  227. package/dist/shims/image.js.map +1 -1
  228. package/dist/shims/internal/api-utils.d.ts +7 -4
  229. package/dist/shims/internal/api-utils.js +0 -6
  230. package/dist/shims/internal/app-router-context.d.ts +22 -17
  231. package/dist/shims/internal/app-router-context.js +17 -13
  232. package/dist/shims/internal/app-router-context.js.map +1 -1
  233. package/dist/shims/internal/cookies.d.ts +2 -9
  234. package/dist/shims/internal/cookies.js +2 -9
  235. package/dist/shims/internal/parse-cookie-header.d.ts +4 -1
  236. package/dist/shims/internal/parse-cookie-header.js +29 -29
  237. package/dist/shims/internal/parse-cookie-header.js.map +1 -1
  238. package/dist/shims/internal/router-context.d.ts +7 -1
  239. package/dist/shims/internal/router-context.js +11 -7
  240. package/dist/shims/internal/router-context.js.map +1 -1
  241. package/dist/shims/internal/utils.d.ts +40 -37
  242. package/dist/shims/internal/utils.js +24 -30
  243. package/dist/shims/internal/utils.js.map +1 -1
  244. package/dist/shims/internal/work-unit-async-storage.d.ts +6 -10
  245. package/dist/shims/internal/work-unit-async-storage.js +14 -11
  246. package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
  247. package/dist/shims/layout-segment-context.d.ts +11 -14
  248. package/dist/shims/layout-segment-context.js +24 -23
  249. package/dist/shims/layout-segment-context.js.map +1 -1
  250. package/dist/shims/legacy-image.d.ts +39 -46
  251. package/dist/shims/legacy-image.js +47 -42
  252. package/dist/shims/legacy-image.js.map +1 -1
  253. package/dist/shims/link.d.ts +32 -36
  254. package/dist/shims/link.js +255 -391
  255. package/dist/shims/link.js.map +1 -1
  256. package/dist/shims/metadata.d.ts +210 -202
  257. package/dist/shims/metadata.js +545 -546
  258. package/dist/shims/metadata.js.map +1 -1
  259. package/dist/shims/navigation-state.d.ts +10 -18
  260. package/dist/shims/navigation-state.js +66 -74
  261. package/dist/shims/navigation-state.js.map +1 -1
  262. package/dist/shims/navigation.d.ts +59 -63
  263. package/dist/shims/navigation.js +505 -704
  264. package/dist/shims/navigation.js.map +1 -1
  265. package/dist/shims/og.d.ts +2 -20
  266. package/dist/shims/og.js +2 -19
  267. package/dist/shims/readonly-url-search-params.d.ts +8 -5
  268. package/dist/shims/readonly-url-search-params.js +26 -22
  269. package/dist/shims/readonly-url-search-params.js.map +1 -1
  270. package/dist/shims/request-context.d.ts +8 -5
  271. package/dist/shims/request-context.js +50 -60
  272. package/dist/shims/request-context.js.map +1 -1
  273. package/dist/shims/request-state-types.d.ts +11 -11
  274. package/dist/shims/request-state-types.js +0 -1
  275. package/dist/shims/router-state.d.ts +13 -10
  276. package/dist/shims/router-state.js +34 -43
  277. package/dist/shims/router-state.js.map +1 -1
  278. package/dist/shims/router.d.ts +81 -85
  279. package/dist/shims/router.js +506 -628
  280. package/dist/shims/router.js.map +1 -1
  281. package/dist/shims/script.d.ts +39 -48
  282. package/dist/shims/script.js +107 -160
  283. package/dist/shims/script.js.map +1 -1
  284. package/dist/shims/server-only.d.ts +1 -19
  285. package/dist/shims/server-only.js +0 -18
  286. package/dist/shims/server.d.ts +213 -164
  287. package/dist/shims/server.js +545 -478
  288. package/dist/shims/server.js.map +1 -1
  289. package/dist/shims/unified-request-context.d.ts +20 -20
  290. package/dist/shims/unified-request-context.js +81 -99
  291. package/dist/shims/unified-request-context.js.map +1 -1
  292. package/dist/shims/url-safety.d.ts +4 -1
  293. package/dist/shims/url-safety.js +15 -11
  294. package/dist/shims/url-safety.js.map +1 -1
  295. package/dist/shims/url-utils.d.ts +8 -5
  296. package/dist/shims/url-utils.js +62 -93
  297. package/dist/shims/url-utils.js.map +1 -1
  298. package/dist/shims/web-vitals.d.ts +10 -8
  299. package/dist/shims/web-vitals.js +9 -15
  300. package/dist/shims/web-vitals.js.map +1 -1
  301. package/dist/utils/base-path.d.ts +5 -2
  302. package/dist/utils/base-path.js +21 -19
  303. package/dist/utils/base-path.js.map +1 -1
  304. package/dist/utils/domain-locale.d.ts +17 -9
  305. package/dist/utils/domain-locale.js +36 -56
  306. package/dist/utils/domain-locale.js.map +1 -1
  307. package/dist/utils/hash.d.ts +4 -1
  308. package/dist/utils/hash.js +19 -17
  309. package/dist/utils/hash.js.map +1 -1
  310. package/dist/utils/manifest-paths.d.ts +6 -3
  311. package/dist/utils/manifest-paths.js +15 -16
  312. package/dist/utils/manifest-paths.js.map +1 -1
  313. package/dist/utils/project.d.ts +13 -11
  314. package/dist/utils/project.js +169 -216
  315. package/dist/utils/project.js.map +1 -1
  316. package/dist/utils/query.d.ts +8 -6
  317. package/dist/utils/query.js +57 -67
  318. package/dist/utils/query.js.map +1 -1
  319. package/package.json +10 -9
  320. package/dist/build/report.d.ts.map +0 -1
  321. package/dist/build/static-export.d.ts.map +0 -1
  322. package/dist/check.d.ts.map +0 -1
  323. package/dist/cli.d.ts.map +0 -1
  324. package/dist/client/entry.d.ts.map +0 -1
  325. package/dist/client/validate-module-path.d.ts.map +0 -1
  326. package/dist/client/vinext-next-data.d.ts.map +0 -1
  327. package/dist/client/vinext-next-data.js.map +0 -1
  328. package/dist/cloudflare/index.d.ts.map +0 -1
  329. package/dist/cloudflare/index.js.map +0 -1
  330. package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
  331. package/dist/cloudflare/tpr.d.ts.map +0 -1
  332. package/dist/config/config-matchers.d.ts.map +0 -1
  333. package/dist/config/dotenv.d.ts.map +0 -1
  334. package/dist/config/next-config.d.ts.map +0 -1
  335. package/dist/deploy.d.ts.map +0 -1
  336. package/dist/entries/app-browser-entry.d.ts.map +0 -1
  337. package/dist/entries/app-rsc-entry.d.ts.map +0 -1
  338. package/dist/entries/app-ssr-entry.d.ts.map +0 -1
  339. package/dist/entries/pages-client-entry.d.ts.map +0 -1
  340. package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
  341. package/dist/entries/pages-server-entry.d.ts.map +0 -1
  342. package/dist/index.d.ts.map +0 -1
  343. package/dist/init.d.ts.map +0 -1
  344. package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
  345. package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
  346. package/dist/routing/app-router.d.ts.map +0 -1
  347. package/dist/routing/file-matcher.d.ts.map +0 -1
  348. package/dist/routing/pages-router.d.ts.map +0 -1
  349. package/dist/routing/route-trie.d.ts.map +0 -1
  350. package/dist/routing/route-validation.d.ts.map +0 -1
  351. package/dist/routing/utils.d.ts.map +0 -1
  352. package/dist/server/api-handler.d.ts.map +0 -1
  353. package/dist/server/app-router-entry.d.ts.map +0 -1
  354. package/dist/server/dev-module-runner.d.ts.map +0 -1
  355. package/dist/server/dev-origin-check.d.ts.map +0 -1
  356. package/dist/server/dev-server.d.ts.map +0 -1
  357. package/dist/server/html.d.ts.map +0 -1
  358. package/dist/server/image-optimization.d.ts.map +0 -1
  359. package/dist/server/instrumentation.d.ts.map +0 -1
  360. package/dist/server/isr-cache.d.ts.map +0 -1
  361. package/dist/server/metadata-routes.d.ts.map +0 -1
  362. package/dist/server/middleware-codegen.d.ts.map +0 -1
  363. package/dist/server/middleware-request-headers.d.ts.map +0 -1
  364. package/dist/server/middleware.d.ts.map +0 -1
  365. package/dist/server/normalize-path.d.ts.map +0 -1
  366. package/dist/server/pages-i18n.d.ts.map +0 -1
  367. package/dist/server/prod-server.d.ts.map +0 -1
  368. package/dist/server/request-log.d.ts.map +0 -1
  369. package/dist/server/request-pipeline.d.ts.map +0 -1
  370. package/dist/server/worker-utils.d.ts.map +0 -1
  371. package/dist/shims/amp.d.ts.map +0 -1
  372. package/dist/shims/app.d.ts.map +0 -1
  373. package/dist/shims/app.js.map +0 -1
  374. package/dist/shims/cache-runtime.d.ts.map +0 -1
  375. package/dist/shims/cache.d.ts.map +0 -1
  376. package/dist/shims/client-only.d.ts.map +0 -1
  377. package/dist/shims/client-only.js.map +0 -1
  378. package/dist/shims/compat-router.d.ts.map +0 -1
  379. package/dist/shims/config.d.ts.map +0 -1
  380. package/dist/shims/constants.d.ts.map +0 -1
  381. package/dist/shims/document.d.ts.map +0 -1
  382. package/dist/shims/dynamic.d.ts.map +0 -1
  383. package/dist/shims/error-boundary.d.ts.map +0 -1
  384. package/dist/shims/error.d.ts.map +0 -1
  385. package/dist/shims/fetch-cache.d.ts.map +0 -1
  386. package/dist/shims/font-google-base.d.ts.map +0 -1
  387. package/dist/shims/font-google.d.ts.map +0 -1
  388. package/dist/shims/font-google.generated.d.ts.map +0 -1
  389. package/dist/shims/font-google.js.map +0 -1
  390. package/dist/shims/font-local.d.ts.map +0 -1
  391. package/dist/shims/form.d.ts.map +0 -1
  392. package/dist/shims/head-state.d.ts.map +0 -1
  393. package/dist/shims/head.d.ts.map +0 -1
  394. package/dist/shims/headers.d.ts.map +0 -1
  395. package/dist/shims/i18n-context.d.ts.map +0 -1
  396. package/dist/shims/i18n-state.d.ts.map +0 -1
  397. package/dist/shims/image-config.d.ts.map +0 -1
  398. package/dist/shims/image.d.ts.map +0 -1
  399. package/dist/shims/internal/api-utils.d.ts.map +0 -1
  400. package/dist/shims/internal/api-utils.js.map +0 -1
  401. package/dist/shims/internal/app-router-context.d.ts.map +0 -1
  402. package/dist/shims/internal/cookies.d.ts.map +0 -1
  403. package/dist/shims/internal/cookies.js.map +0 -1
  404. package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
  405. package/dist/shims/internal/router-context.d.ts.map +0 -1
  406. package/dist/shims/internal/utils.d.ts.map +0 -1
  407. package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
  408. package/dist/shims/layout-segment-context.d.ts.map +0 -1
  409. package/dist/shims/legacy-image.d.ts.map +0 -1
  410. package/dist/shims/link.d.ts.map +0 -1
  411. package/dist/shims/metadata.d.ts.map +0 -1
  412. package/dist/shims/navigation-state.d.ts.map +0 -1
  413. package/dist/shims/navigation.d.ts.map +0 -1
  414. package/dist/shims/og.d.ts.map +0 -1
  415. package/dist/shims/og.js.map +0 -1
  416. package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
  417. package/dist/shims/request-context.d.ts.map +0 -1
  418. package/dist/shims/request-state-types.d.ts.map +0 -1
  419. package/dist/shims/request-state-types.js.map +0 -1
  420. package/dist/shims/router-state.d.ts.map +0 -1
  421. package/dist/shims/router.d.ts.map +0 -1
  422. package/dist/shims/script.d.ts.map +0 -1
  423. package/dist/shims/server-only.d.ts.map +0 -1
  424. package/dist/shims/server-only.js.map +0 -1
  425. package/dist/shims/server.d.ts.map +0 -1
  426. package/dist/shims/unified-request-context.d.ts.map +0 -1
  427. package/dist/shims/url-safety.d.ts.map +0 -1
  428. package/dist/shims/url-utils.d.ts.map +0 -1
  429. package/dist/shims/web-vitals.d.ts.map +0 -1
  430. package/dist/utils/base-path.d.ts.map +0 -1
  431. package/dist/utils/domain-locale.d.ts.map +0 -1
  432. package/dist/utils/hash.d.ts.map +0 -1
  433. package/dist/utils/manifest-paths.d.ts.map +0 -1
  434. package/dist/utils/project.d.ts.map +0 -1
  435. package/dist/utils/query.d.ts.map +0 -1
@@ -1,341 +1,294 @@
1
- /**
2
- * File-based metadata route handling.
3
- *
4
- * Next.js supports special files in the app/ directory that auto-generate
5
- * metadata routes:
6
- * - sitemap.ts/.xml → /sitemap.xml (application/xml)
7
- * - robots.ts/.txt → /robots.txt (text/plain)
8
- * - manifest.ts/.json/.webmanifest → /manifest.webmanifest (application/manifest+json)
9
- * - icon.tsx/.png → /icon (image/*)
10
- * - opengraph-image.tsx/.png → /opengraph-image (image/*)
11
- * - twitter-image.tsx/.png → /twitter-image (image/*)
12
- * - apple-icon.tsx/.png → /apple-icon (image/*)
13
- * - favicon.ico → /favicon.ico (image/x-icon)
14
- *
15
- * Dynamic versions (ts/tsx/js) export a default function that returns the data.
16
- * Static versions (xml/txt/json/png/etc.) are served as-is.
17
- */
18
1
  import fs from "node:fs";
19
2
  import path from "node:path";
20
- // -------------------------------------------------------------------
21
- // Known metadata file patterns
22
- // -------------------------------------------------------------------
3
+ //#region src/server/metadata-routes.ts
4
+ /**
5
+ * File-based metadata route handling.
6
+ *
7
+ * Next.js supports special files in the app/ directory that auto-generate
8
+ * metadata routes:
9
+ * - sitemap.ts/.xml → /sitemap.xml (application/xml)
10
+ * - robots.ts/.txt → /robots.txt (text/plain)
11
+ * - manifest.ts/.json/.webmanifest → /manifest.webmanifest (application/manifest+json)
12
+ * - icon.tsx/.png → /icon (image/*)
13
+ * - opengraph-image.tsx/.png → /opengraph-image (image/*)
14
+ * - twitter-image.tsx/.png → /twitter-image (image/*)
15
+ * - apple-icon.tsx/.png → /apple-icon (image/*)
16
+ * - favicon.ico → /favicon.ico (image/x-icon)
17
+ *
18
+ * Dynamic versions (ts/tsx/js) export a default function that returns the data.
19
+ * Static versions (xml/txt/json/png/etc.) are served as-is.
20
+ */
23
21
  /** Map of metadata file base names to their URL path and content type. */
24
- export const METADATA_FILE_MAP = {
25
- sitemap: {
26
- urlPath: "/sitemap.xml",
27
- contentType: "application/xml",
28
- canBeDynamic: true,
29
- staticExtensions: [".xml"],
30
- dynamicExtensions: [".ts", ".js"],
31
- nestable: true,
32
- },
33
- robots: {
34
- urlPath: "/robots.txt",
35
- contentType: "text/plain",
36
- canBeDynamic: true,
37
- staticExtensions: [".txt"],
38
- dynamicExtensions: [".ts", ".js"],
39
- nestable: false,
40
- },
41
- manifest: {
42
- urlPath: "/manifest.webmanifest",
43
- contentType: "application/manifest+json",
44
- canBeDynamic: true,
45
- staticExtensions: [".json", ".webmanifest"],
46
- dynamicExtensions: [".ts", ".js"],
47
- nestable: false,
48
- },
49
- favicon: {
50
- urlPath: "/favicon.ico",
51
- contentType: "image/x-icon",
52
- canBeDynamic: false,
53
- staticExtensions: [".ico"],
54
- dynamicExtensions: [],
55
- nestable: false,
56
- },
57
- icon: {
58
- urlPath: "/icon",
59
- contentType: "image/png",
60
- canBeDynamic: true,
61
- staticExtensions: [".ico", ".jpg", ".jpeg", ".png", ".svg"],
62
- dynamicExtensions: [".ts", ".tsx", ".js"],
63
- nestable: true,
64
- },
65
- "opengraph-image": {
66
- urlPath: "/opengraph-image",
67
- contentType: "image/png",
68
- canBeDynamic: true,
69
- staticExtensions: [".jpg", ".jpeg", ".png", ".gif"],
70
- dynamicExtensions: [".ts", ".tsx", ".js"],
71
- nestable: true,
72
- },
73
- "twitter-image": {
74
- urlPath: "/twitter-image",
75
- contentType: "image/png",
76
- canBeDynamic: true,
77
- staticExtensions: [".jpg", ".jpeg", ".png", ".gif"],
78
- dynamicExtensions: [".ts", ".tsx", ".js"],
79
- nestable: true,
80
- },
81
- "apple-icon": {
82
- urlPath: "/apple-icon",
83
- contentType: "image/png",
84
- canBeDynamic: true,
85
- staticExtensions: [".jpg", ".jpeg", ".png"],
86
- dynamicExtensions: [".ts", ".tsx", ".js"],
87
- nestable: true,
88
- },
22
+ const METADATA_FILE_MAP = {
23
+ sitemap: {
24
+ urlPath: "/sitemap.xml",
25
+ contentType: "application/xml",
26
+ canBeDynamic: true,
27
+ staticExtensions: [".xml"],
28
+ dynamicExtensions: [".ts", ".js"],
29
+ nestable: true
30
+ },
31
+ robots: {
32
+ urlPath: "/robots.txt",
33
+ contentType: "text/plain",
34
+ canBeDynamic: true,
35
+ staticExtensions: [".txt"],
36
+ dynamicExtensions: [".ts", ".js"],
37
+ nestable: false
38
+ },
39
+ manifest: {
40
+ urlPath: "/manifest.webmanifest",
41
+ contentType: "application/manifest+json",
42
+ canBeDynamic: true,
43
+ staticExtensions: [".json", ".webmanifest"],
44
+ dynamicExtensions: [".ts", ".js"],
45
+ nestable: false
46
+ },
47
+ favicon: {
48
+ urlPath: "/favicon.ico",
49
+ contentType: "image/x-icon",
50
+ canBeDynamic: false,
51
+ staticExtensions: [".ico"],
52
+ dynamicExtensions: [],
53
+ nestable: false
54
+ },
55
+ icon: {
56
+ urlPath: "/icon",
57
+ contentType: "image/png",
58
+ canBeDynamic: true,
59
+ staticExtensions: [
60
+ ".ico",
61
+ ".jpg",
62
+ ".jpeg",
63
+ ".png",
64
+ ".svg"
65
+ ],
66
+ dynamicExtensions: [
67
+ ".ts",
68
+ ".tsx",
69
+ ".js"
70
+ ],
71
+ nestable: true
72
+ },
73
+ "opengraph-image": {
74
+ urlPath: "/opengraph-image",
75
+ contentType: "image/png",
76
+ canBeDynamic: true,
77
+ staticExtensions: [
78
+ ".jpg",
79
+ ".jpeg",
80
+ ".png",
81
+ ".gif"
82
+ ],
83
+ dynamicExtensions: [
84
+ ".ts",
85
+ ".tsx",
86
+ ".js"
87
+ ],
88
+ nestable: true
89
+ },
90
+ "twitter-image": {
91
+ urlPath: "/twitter-image",
92
+ contentType: "image/png",
93
+ canBeDynamic: true,
94
+ staticExtensions: [
95
+ ".jpg",
96
+ ".jpeg",
97
+ ".png",
98
+ ".gif"
99
+ ],
100
+ dynamicExtensions: [
101
+ ".ts",
102
+ ".tsx",
103
+ ".js"
104
+ ],
105
+ nestable: true
106
+ },
107
+ "apple-icon": {
108
+ urlPath: "/apple-icon",
109
+ contentType: "image/png",
110
+ canBeDynamic: true,
111
+ staticExtensions: [
112
+ ".jpg",
113
+ ".jpeg",
114
+ ".png"
115
+ ],
116
+ dynamicExtensions: [
117
+ ".ts",
118
+ ".tsx",
119
+ ".js"
120
+ ],
121
+ nestable: true
122
+ }
89
123
  };
90
- // -------------------------------------------------------------------
91
- // Serializers
92
- // -------------------------------------------------------------------
93
124
  /** Escape the five XML special characters in text content and attribute values. */
94
125
  function escapeXml(s) {
95
- return s
96
- .replace(/&/g, "&")
97
- .replace(/</g, "&lt;")
98
- .replace(/>/g, "&gt;")
99
- .replace(/"/g, "&quot;")
100
- .replace(/'/g, "&apos;");
126
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
101
127
  }
102
128
  /**
103
- * Convert a sitemap array to XML string.
104
- */
105
- export function sitemapToXml(entries) {
106
- const hasAlternates = entries.some((entry) => Object.keys(entry.alternates ?? {}).length > 0);
107
- const hasImages = entries.some((entry) => Boolean(entry.images?.length));
108
- const hasVideos = entries.some((entry) => Boolean(entry.videos?.length));
109
- let content = "";
110
- content += '<?xml version="1.0" encoding="UTF-8"?>\n';
111
- content += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
112
- if (hasImages) {
113
- content += ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"';
114
- }
115
- if (hasVideos) {
116
- content += ' xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"';
117
- }
118
- if (hasAlternates) {
119
- content += ' xmlns:xhtml="http://www.w3.org/1999/xhtml">\n';
120
- }
121
- else {
122
- content += ">\n";
123
- }
124
- for (const entry of entries) {
125
- content += "<url>\n";
126
- content += `<loc>${escapeXml(entry.url)}</loc>\n`;
127
- const languages = entry.alternates?.languages;
128
- if (languages && Object.keys(languages).length) {
129
- for (const language in languages) {
130
- content += `<xhtml:link rel="alternate" hreflang="${escapeXml(language)}" href="${escapeXml(languages[language])}" />\n`;
131
- }
132
- }
133
- if (entry.images?.length) {
134
- for (const image of entry.images) {
135
- content += `<image:image>\n<image:loc>${escapeXml(image)}</image:loc>\n</image:image>\n`;
136
- }
137
- }
138
- if (entry.videos?.length) {
139
- for (const video of entry.videos) {
140
- const videoFields = [
141
- "<video:video>",
142
- `<video:title>${escapeXml(String(video.title))}</video:title>`,
143
- `<video:thumbnail_loc>${escapeXml(String(video.thumbnail_loc))}</video:thumbnail_loc>`,
144
- `<video:description>${escapeXml(String(video.description))}</video:description>`,
145
- video.content_loc &&
146
- `<video:content_loc>${escapeXml(String(video.content_loc))}</video:content_loc>`,
147
- video.player_loc &&
148
- `<video:player_loc>${escapeXml(String(video.player_loc))}</video:player_loc>`,
149
- video.duration && `<video:duration>${video.duration}</video:duration>`,
150
- video.view_count && `<video:view_count>${video.view_count}</video:view_count>`,
151
- video.tag && `<video:tag>${escapeXml(String(video.tag))}</video:tag>`,
152
- video.rating && `<video:rating>${video.rating}</video:rating>`,
153
- video.expiration_date &&
154
- `<video:expiration_date>${video.expiration_date}</video:expiration_date>`,
155
- video.publication_date &&
156
- `<video:publication_date>${video.publication_date}</video:publication_date>`,
157
- video.family_friendly &&
158
- `<video:family_friendly>${video.family_friendly}</video:family_friendly>`,
159
- video.requires_subscription &&
160
- `<video:requires_subscription>${video.requires_subscription}</video:requires_subscription>`,
161
- video.live && `<video:live>${video.live}</video:live>`,
162
- video.restriction &&
163
- `<video:restriction relationship="${escapeXml(String(video.restriction.relationship))}">${escapeXml(String(video.restriction.content))}</video:restriction>`,
164
- video.platform &&
165
- `<video:platform relationship="${escapeXml(String(video.platform.relationship))}">${escapeXml(String(video.platform.content))}</video:platform>`,
166
- video.uploader &&
167
- `<video:uploader${video.uploader.info ? ` info="${escapeXml(String(video.uploader.info))}"` : ""}>${escapeXml(String(video.uploader.content))}</video:uploader>`,
168
- "</video:video>\n",
169
- ].filter(Boolean);
170
- content += videoFields.join("\n");
171
- }
172
- }
173
- if (entry.lastModified) {
174
- content += `<lastmod>${serializeDate(entry.lastModified)}</lastmod>\n`;
175
- }
176
- if (entry.changeFrequency) {
177
- content += `<changefreq>${entry.changeFrequency}</changefreq>\n`;
178
- }
179
- if (typeof entry.priority === "number") {
180
- content += `<priority>${entry.priority}</priority>\n`;
181
- }
182
- content += "</url>\n";
183
- }
184
- content += "</urlset>\n";
185
- return content;
129
+ * Convert a sitemap array to XML string.
130
+ */
131
+ function sitemapToXml(entries) {
132
+ const hasAlternates = entries.some((entry) => Object.keys(entry.alternates ?? {}).length > 0);
133
+ const hasImages = entries.some((entry) => Boolean(entry.images?.length));
134
+ const hasVideos = entries.some((entry) => Boolean(entry.videos?.length));
135
+ let content = "";
136
+ content += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
137
+ content += "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"";
138
+ if (hasImages) content += " xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"";
139
+ if (hasVideos) content += " xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"";
140
+ if (hasAlternates) content += " xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n";
141
+ else content += ">\n";
142
+ for (const entry of entries) {
143
+ content += "<url>\n";
144
+ content += `<loc>${escapeXml(entry.url)}</loc>\n`;
145
+ const languages = entry.alternates?.languages;
146
+ if (languages && Object.keys(languages).length) for (const language in languages) content += `<xhtml:link rel="alternate" hreflang="${escapeXml(language)}" href="${escapeXml(languages[language])}" />\n`;
147
+ if (entry.images?.length) for (const image of entry.images) content += `<image:image>\n<image:loc>${escapeXml(image)}</image:loc>\n</image:image>\n`;
148
+ if (entry.videos?.length) for (const video of entry.videos) {
149
+ const videoFields = [
150
+ "<video:video>",
151
+ `<video:title>${escapeXml(String(video.title))}</video:title>`,
152
+ `<video:thumbnail_loc>${escapeXml(String(video.thumbnail_loc))}</video:thumbnail_loc>`,
153
+ `<video:description>${escapeXml(String(video.description))}</video:description>`,
154
+ video.content_loc && `<video:content_loc>${escapeXml(String(video.content_loc))}</video:content_loc>`,
155
+ video.player_loc && `<video:player_loc>${escapeXml(String(video.player_loc))}</video:player_loc>`,
156
+ video.duration && `<video:duration>${video.duration}</video:duration>`,
157
+ video.view_count && `<video:view_count>${video.view_count}</video:view_count>`,
158
+ video.tag && `<video:tag>${escapeXml(String(video.tag))}</video:tag>`,
159
+ video.rating && `<video:rating>${video.rating}</video:rating>`,
160
+ video.expiration_date && `<video:expiration_date>${escapeXml(String(video.expiration_date))}</video:expiration_date>`,
161
+ video.publication_date && `<video:publication_date>${escapeXml(String(video.publication_date))}</video:publication_date>`,
162
+ video.family_friendly && `<video:family_friendly>${video.family_friendly}</video:family_friendly>`,
163
+ video.requires_subscription && `<video:requires_subscription>${video.requires_subscription}</video:requires_subscription>`,
164
+ video.live && `<video:live>${video.live}</video:live>`,
165
+ video.restriction && `<video:restriction relationship="${escapeXml(String(video.restriction.relationship))}">${escapeXml(String(video.restriction.content))}</video:restriction>`,
166
+ video.platform && `<video:platform relationship="${escapeXml(String(video.platform.relationship))}">${escapeXml(String(video.platform.content))}</video:platform>`,
167
+ video.uploader && `<video:uploader${video.uploader.info ? ` info="${escapeXml(String(video.uploader.info))}"` : ""}>${escapeXml(String(video.uploader.content))}</video:uploader>`,
168
+ "</video:video>\n"
169
+ ].filter(Boolean);
170
+ content += videoFields.join("\n");
171
+ }
172
+ if (entry.lastModified) content += `<lastmod>${serializeDate(entry.lastModified)}</lastmod>\n`;
173
+ if (entry.changeFrequency) content += `<changefreq>${entry.changeFrequency}</changefreq>\n`;
174
+ if (typeof entry.priority === "number") content += `<priority>${entry.priority}</priority>\n`;
175
+ content += "</url>\n";
176
+ }
177
+ content += "</urlset>\n";
178
+ return content;
186
179
  }
187
180
  /**
188
- * Convert a robots config to text format.
189
- */
190
- export function robotsToText(config) {
191
- const lines = [];
192
- const rules = Array.isArray(config.rules) ? config.rules : [config.rules];
193
- for (const rule of rules) {
194
- const agents = Array.isArray(rule.userAgent) ? rule.userAgent : [rule.userAgent ?? "*"];
195
- for (const agent of agents) {
196
- lines.push(`User-Agent: ${agent}`);
197
- }
198
- if (rule.allow) {
199
- const allows = Array.isArray(rule.allow) ? rule.allow : [rule.allow];
200
- for (const allow of allows) {
201
- lines.push(`Allow: ${allow}`);
202
- }
203
- }
204
- if (rule.disallow) {
205
- const disallows = Array.isArray(rule.disallow) ? rule.disallow : [rule.disallow];
206
- for (const disallow of disallows) {
207
- lines.push(`Disallow: ${disallow}`);
208
- }
209
- }
210
- if (rule.crawlDelay !== undefined) {
211
- lines.push(`Crawl-delay: ${rule.crawlDelay}`);
212
- }
213
- lines.push("");
214
- }
215
- if (config.sitemap) {
216
- const sitemaps = Array.isArray(config.sitemap) ? config.sitemap : [config.sitemap];
217
- for (const sitemap of sitemaps) {
218
- lines.push(`Sitemap: ${sitemap}`);
219
- }
220
- }
221
- if (config.host) {
222
- lines.push(`Host: ${config.host}`);
223
- }
224
- return lines.join("\n").trim() + "\n";
181
+ * Convert a robots config to text format.
182
+ */
183
+ function robotsToText(config) {
184
+ const lines = [];
185
+ const rules = Array.isArray(config.rules) ? config.rules : [config.rules];
186
+ for (const rule of rules) {
187
+ const agents = Array.isArray(rule.userAgent) ? rule.userAgent : [rule.userAgent ?? "*"];
188
+ for (const agent of agents) lines.push(`User-Agent: ${agent}`);
189
+ if (rule.allow) {
190
+ const allows = Array.isArray(rule.allow) ? rule.allow : [rule.allow];
191
+ for (const allow of allows) lines.push(`Allow: ${allow}`);
192
+ }
193
+ if (rule.disallow) {
194
+ const disallows = Array.isArray(rule.disallow) ? rule.disallow : [rule.disallow];
195
+ for (const disallow of disallows) lines.push(`Disallow: ${disallow}`);
196
+ }
197
+ if (rule.crawlDelay !== void 0) lines.push(`Crawl-delay: ${rule.crawlDelay}`);
198
+ lines.push("");
199
+ }
200
+ if (config.sitemap) {
201
+ const sitemaps = Array.isArray(config.sitemap) ? config.sitemap : [config.sitemap];
202
+ for (const sitemap of sitemaps) lines.push(`Sitemap: ${sitemap}`);
203
+ }
204
+ if (config.host) lines.push(`Host: ${config.host}`);
205
+ return lines.join("\n").trim() + "\n";
225
206
  }
226
207
  /**
227
- * Convert a manifest config to JSON string.
228
- */
229
- export function manifestToJson(config) {
230
- return JSON.stringify(config, null, 2);
208
+ * Convert a manifest config to JSON string.
209
+ */
210
+ function manifestToJson(config) {
211
+ return JSON.stringify(config, null, 2);
231
212
  }
232
213
  function serializeDate(value) {
233
- return value instanceof Date ? value.toISOString() : value;
214
+ return value instanceof Date ? value.toISOString() : value;
234
215
  }
235
216
  function metadataRouteSuffix(parentSegments, metaType) {
236
- if (metaType === "sitemap" || metaType === "robots" || metaType === "manifest") {
237
- // Sitemap is exempt per Next.js. Robots and manifest are also safe to
238
- // exempt because they are root-only in vinext, so invisible parents never apply.
239
- return "";
240
- }
241
- const hasInvisibleParent = parentSegments.some((segment) => (segment.startsWith("(") && segment.endsWith(")")) ||
242
- (segment.startsWith("@") && segment !== "@children"));
243
- if (!hasInvisibleParent)
244
- return "";
245
- const parentPath = `/${parentSegments.join("/")}`;
246
- let hash = 5381;
247
- for (let i = 0; i < parentPath.length; i++) {
248
- hash = ((hash << 5) + hash + parentPath.charCodeAt(i)) & 0xffffffff;
249
- }
250
- return (hash >>> 0).toString(36).slice(0, 6);
217
+ if (metaType === "sitemap" || metaType === "robots" || metaType === "manifest") return "";
218
+ if (!parentSegments.some((segment) => segment.startsWith("(") && segment.endsWith(")") || segment.startsWith("@") && segment !== "@children")) return "";
219
+ const parentPath = `/${parentSegments.join("/")}`;
220
+ let hash = 5381;
221
+ for (let i = 0; i < parentPath.length; i++) hash = (hash << 5) + hash + parentPath.charCodeAt(i) & 4294967295;
222
+ return (hash >>> 0).toString(36).slice(0, 6);
251
223
  }
252
224
  function withMetadataSuffix(urlPath, suffix) {
253
- if (!suffix)
254
- return urlPath;
255
- const parsed = path.posix.parse(urlPath);
256
- return path.posix.join(parsed.dir || "/", `${parsed.name}-${suffix}${parsed.ext}`);
225
+ if (!suffix) return urlPath;
226
+ const parsed = path.posix.parse(urlPath);
227
+ return path.posix.join(parsed.dir || "/", `${parsed.name}-${suffix}${parsed.ext}`);
257
228
  }
258
229
  /**
259
- * Scan an app directory for metadata files.
260
- */
261
- export function scanMetadataFiles(appDir) {
262
- const routes = [];
263
- // Scan the app directory recursively
264
- function scan(dir, urlPrefix, parentSegments) {
265
- if (!fs.existsSync(dir))
266
- return;
267
- const entries = fs.readdirSync(dir, { withFileTypes: true });
268
- for (const entry of entries) {
269
- if (entry.isDirectory()) {
270
- const dirName = entry.name;
271
- if (dirName.startsWith("_"))
272
- continue;
273
- const isRouteGroup = dirName.startsWith("(") && dirName.endsWith(")");
274
- const isParallelRoute = dirName.startsWith("@");
275
- const nextUrlPrefix = isRouteGroup || isParallelRoute ? urlPrefix : `${urlPrefix}/${dirName}`;
276
- scan(path.join(dir, dirName), nextUrlPrefix, [...parentSegments, dirName]);
277
- continue;
278
- }
279
- // Check each metadata file pattern
280
- const fileName = entry.name;
281
- const baseName = fileName.replace(/\.[^.]+$/, "");
282
- const ext = fileName.slice(baseName.length);
283
- for (const [metaType, config] of Object.entries(METADATA_FILE_MAP)) {
284
- // Check if the base name matches
285
- if (baseName !== metaType)
286
- continue;
287
- // Check nestability — non-nestable types only at root
288
- if (!config.nestable && urlPrefix !== "")
289
- continue;
290
- // Check if this is a static or dynamic variant
291
- const isStatic = config.staticExtensions.includes(ext);
292
- const isDynamic = config.dynamicExtensions.includes(ext);
293
- if (!isStatic && !isDynamic)
294
- continue;
295
- const suffix = metadataRouteSuffix(parentSegments, metaType);
296
- const urlPath = withMetadataSuffix(config.urlPath, suffix);
297
- routes.push({
298
- type: metaType,
299
- isDynamic,
300
- filePath: path.join(dir, fileName),
301
- servedUrl: urlPrefix === "" ? urlPath : `${urlPrefix}${urlPath}`,
302
- contentType: isStatic
303
- ? getStaticContentType(ext, config.contentType)
304
- : config.contentType,
305
- });
306
- }
307
- }
308
- }
309
- scan(appDir, "", []);
310
- // Deduplicate: if both dynamic and static variants exist at the same URL,
311
- // keep only the dynamic one (matches Next.js behavior).
312
- const byUrl = new Map();
313
- for (const route of routes) {
314
- const existing = byUrl.get(route.servedUrl);
315
- if (!existing) {
316
- byUrl.set(route.servedUrl, route);
317
- }
318
- else if (route.isDynamic && !existing.isDynamic) {
319
- // Dynamic takes priority over static
320
- byUrl.set(route.servedUrl, route);
321
- }
322
- // If both are static or both dynamic, keep the first one found
323
- }
324
- return Array.from(byUrl.values());
230
+ * Scan an app directory for metadata files.
231
+ */
232
+ function scanMetadataFiles(appDir) {
233
+ const routes = [];
234
+ function scan(dir, urlPrefix, parentSegments) {
235
+ if (!fs.existsSync(dir)) return;
236
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
237
+ for (const entry of entries) {
238
+ if (entry.isDirectory()) {
239
+ const dirName = entry.name;
240
+ if (dirName.startsWith("_")) continue;
241
+ const isRouteGroup = dirName.startsWith("(") && dirName.endsWith(")");
242
+ const isParallelRoute = dirName.startsWith("@");
243
+ const nextUrlPrefix = isRouteGroup || isParallelRoute ? urlPrefix : `${urlPrefix}/${dirName}`;
244
+ scan(path.join(dir, dirName), nextUrlPrefix, [...parentSegments, dirName]);
245
+ continue;
246
+ }
247
+ const fileName = entry.name;
248
+ const baseName = fileName.replace(/\.[^.]+$/, "");
249
+ const ext = fileName.slice(baseName.length);
250
+ for (const [metaType, config] of Object.entries(METADATA_FILE_MAP)) {
251
+ if (baseName !== metaType) continue;
252
+ if (!config.nestable && urlPrefix !== "") continue;
253
+ const isStatic = config.staticExtensions.includes(ext);
254
+ const isDynamic = config.dynamicExtensions.includes(ext);
255
+ if (!isStatic && !isDynamic) continue;
256
+ const suffix = metadataRouteSuffix(parentSegments, metaType);
257
+ const urlPath = withMetadataSuffix(config.urlPath, suffix);
258
+ routes.push({
259
+ type: metaType,
260
+ isDynamic,
261
+ filePath: path.join(dir, fileName),
262
+ servedUrl: urlPrefix === "" ? urlPath : `${urlPrefix}${urlPath}`,
263
+ contentType: isStatic ? getStaticContentType(ext, config.contentType) : config.contentType
264
+ });
265
+ }
266
+ }
267
+ }
268
+ scan(appDir, "", []);
269
+ const byUrl = /* @__PURE__ */ new Map();
270
+ for (const route of routes) {
271
+ const existing = byUrl.get(route.servedUrl);
272
+ if (!existing) byUrl.set(route.servedUrl, route);
273
+ else if (route.isDynamic && !existing.isDynamic) byUrl.set(route.servedUrl, route);
274
+ }
275
+ return Array.from(byUrl.values());
325
276
  }
326
277
  function getStaticContentType(ext, fallback) {
327
- const map = {
328
- ".xml": "application/xml",
329
- ".txt": "text/plain",
330
- ".json": "application/json",
331
- ".webmanifest": "application/manifest+json",
332
- ".ico": "image/x-icon",
333
- ".png": "image/png",
334
- ".jpg": "image/jpeg",
335
- ".jpeg": "image/jpeg",
336
- ".gif": "image/gif",
337
- ".svg": "image/svg+xml",
338
- };
339
- return map[ext] ?? fallback;
278
+ return {
279
+ ".xml": "application/xml",
280
+ ".txt": "text/plain",
281
+ ".json": "application/json",
282
+ ".webmanifest": "application/manifest+json",
283
+ ".ico": "image/x-icon",
284
+ ".png": "image/png",
285
+ ".jpg": "image/jpeg",
286
+ ".jpeg": "image/jpeg",
287
+ ".gif": "image/gif",
288
+ ".svg": "image/svg+xml"
289
+ }[ext] ?? fallback;
340
290
  }
291
+ //#endregion
292
+ export { METADATA_FILE_MAP, manifestToJson, robotsToText, scanMetadataFiles, sitemapToXml };
293
+
341
294
  //# sourceMappingURL=metadata-routes.js.map