astro 7.0.0-alpha.0 → 7.0.0-alpha.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 (251) hide show
  1. package/components/Code.astro +1 -1
  2. package/dist/actions/handler.d.ts +32 -0
  3. package/dist/actions/handler.js +45 -0
  4. package/dist/actions/runtime/server.js +1 -1
  5. package/dist/assets/build/generate.js +1 -1
  6. package/dist/assets/build/remote.d.ts +3 -2
  7. package/dist/assets/build/remote.js +16 -9
  8. package/dist/assets/endpoint/dev.js +1 -1
  9. package/dist/assets/endpoint/generic.js +8 -20
  10. package/dist/assets/endpoint/loadImage.d.ts +11 -0
  11. package/dist/assets/endpoint/loadImage.js +19 -0
  12. package/dist/assets/endpoint/shared.js +7 -2
  13. package/dist/assets/fonts/config.d.ts +4 -4
  14. package/dist/assets/fonts/core/optimize-fallbacks.js +38 -13
  15. package/dist/assets/fonts/definitions.d.ts +2 -2
  16. package/dist/assets/fonts/infra/system-fallbacks-provider.d.ts +2 -2
  17. package/dist/assets/fonts/infra/system-fallbacks-provider.js +46 -9
  18. package/dist/assets/fonts/types.d.ts +1 -0
  19. package/dist/assets/index.d.ts +1 -0
  20. package/dist/assets/index.js +2 -0
  21. package/dist/assets/internal.js +22 -3
  22. package/dist/assets/services/service.d.ts +1 -1
  23. package/dist/assets/services/service.js +9 -9
  24. package/dist/assets/services/sharp.js +53 -18
  25. package/dist/assets/utils/generateImageStylesCSS.js +26 -6
  26. package/dist/assets/utils/index.d.ts +1 -0
  27. package/dist/assets/utils/index.js +2 -0
  28. package/dist/assets/utils/inferSourceFormat.d.ts +8 -3
  29. package/dist/assets/utils/inferSourceFormat.js +15 -4
  30. package/dist/assets/utils/metadata.js +1 -1
  31. package/dist/assets/utils/redirectValidation.d.ts +48 -0
  32. package/dist/assets/utils/redirectValidation.js +48 -0
  33. package/dist/assets/utils/remoteProbe.js +25 -2
  34. package/dist/assets/utils/vendor/image-size/types/svg.js +1 -1
  35. package/dist/cli/add/index.js +7 -58
  36. package/dist/cli/dev/background.d.ts +16 -0
  37. package/dist/cli/dev/background.js +116 -0
  38. package/dist/cli/dev/index.js +82 -3
  39. package/dist/cli/dev/logs.d.ts +6 -0
  40. package/dist/cli/dev/logs.js +72 -0
  41. package/dist/cli/dev/status.d.ts +15 -0
  42. package/dist/cli/dev/status.js +27 -0
  43. package/dist/cli/dev/stop.d.ts +12 -0
  44. package/dist/cli/dev/stop.js +43 -0
  45. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  46. package/dist/container/index.js +18 -14
  47. package/dist/content/content-layer.js +16 -11
  48. package/dist/content/data-store.d.ts +1 -1
  49. package/dist/content/loaders/types.d.ts +1 -1
  50. package/dist/content/runtime-assets.d.ts +2 -2
  51. package/dist/content/runtime.d.ts +1 -1
  52. package/dist/content/runtime.js +9 -4
  53. package/dist/content/server-listeners.js +0 -4
  54. package/dist/content/types-generator.js +5 -1
  55. package/dist/content/utils.d.ts +1 -1
  56. package/dist/content/utils.js +1 -1
  57. package/dist/content/vite-plugin-content-assets.js +1 -0
  58. package/dist/content/vite-plugin-content-virtual-mod.js +9 -1
  59. package/dist/core/app/base.d.ts +42 -15
  60. package/dist/core/app/base.js +151 -375
  61. package/dist/core/app/dev/app.d.ts +3 -2
  62. package/dist/core/app/dev/app.js +4 -60
  63. package/dist/core/app/entrypoints/node.d.ts +1 -1
  64. package/dist/core/app/entrypoints/node.js +2 -0
  65. package/dist/core/app/entrypoints/virtual/dev.js +2 -0
  66. package/dist/core/app/entrypoints/virtual/prod.js +4 -1
  67. package/dist/core/app/node.d.ts +16 -0
  68. package/dist/core/app/node.js +59 -13
  69. package/dist/core/app/prepare-response.d.ts +11 -0
  70. package/dist/core/app/prepare-response.js +18 -0
  71. package/dist/core/app/render-options.d.ts +11 -0
  72. package/dist/core/app/render-options.js +11 -0
  73. package/dist/core/base-pipeline.d.ts +48 -1
  74. package/dist/core/base-pipeline.js +63 -8
  75. package/dist/core/build/app.d.ts +3 -4
  76. package/dist/core/build/app.js +3 -17
  77. package/dist/core/build/generate.js +8 -1
  78. package/dist/core/build/index.d.ts +0 -11
  79. package/dist/core/build/index.js +0 -3
  80. package/dist/core/build/internal.d.ts +7 -0
  81. package/dist/core/build/plugins/plugin-chunk-imports.d.ts +6 -0
  82. package/dist/core/build/plugins/plugin-chunk-imports.js +29 -17
  83. package/dist/core/build/plugins/plugin-css.js +40 -1
  84. package/dist/core/build/plugins/plugin-internals.js +1 -1
  85. package/dist/core/build/plugins/plugin-manifest.js +11 -1
  86. package/dist/core/build/static-build.js +22 -141
  87. package/dist/core/build/types.d.ts +0 -1
  88. package/dist/core/build/util.js +8 -1
  89. package/dist/core/build/vite-build-config.d.ts +28 -0
  90. package/dist/core/build/vite-build-config.js +165 -0
  91. package/dist/core/cache/handler.d.ts +29 -0
  92. package/dist/core/cache/handler.js +81 -0
  93. package/dist/core/compile/style.js +18 -1
  94. package/dist/core/config/index.d.ts +1 -1
  95. package/dist/core/config/index.js +4 -1
  96. package/dist/core/config/merge.js +4 -0
  97. package/dist/core/config/schemas/base.d.ts +25 -13
  98. package/dist/core/config/schemas/base.js +39 -10
  99. package/dist/core/config/schemas/relative.d.ts +76 -49
  100. package/dist/core/config/schemas/relative.js +2 -3
  101. package/dist/core/config/settings.js +2 -4
  102. package/dist/core/config/tsconfig.d.ts +24 -9
  103. package/dist/core/config/tsconfig.js +54 -45
  104. package/dist/core/config/validate.js +59 -0
  105. package/dist/core/constants.d.ts +27 -1
  106. package/dist/core/constants.js +14 -1
  107. package/dist/core/cookies/cookies.d.ts +7 -2
  108. package/dist/core/cookies/cookies.js +11 -4
  109. package/dist/core/cookies/response.d.ts +1 -1
  110. package/dist/core/cookies/response.js +1 -2
  111. package/dist/core/create-vite.js +18 -1
  112. package/dist/core/csp/config.js +17 -5
  113. package/dist/core/csp/runtime.js +6 -4
  114. package/dist/core/dev/dev.d.ts +1 -0
  115. package/dist/core/dev/dev.js +4 -13
  116. package/dist/core/dev/lockfile.d.ts +54 -0
  117. package/dist/core/dev/lockfile.js +93 -0
  118. package/dist/core/errors/build-handler.d.ts +17 -0
  119. package/dist/core/errors/build-handler.js +22 -0
  120. package/dist/core/errors/default-handler.d.ts +14 -0
  121. package/dist/core/errors/default-handler.js +144 -0
  122. package/dist/core/errors/dev-handler.d.ts +21 -0
  123. package/dist/core/errors/dev-handler.js +82 -0
  124. package/dist/core/errors/errors-data.d.ts +43 -38
  125. package/dist/core/errors/errors-data.js +79 -73
  126. package/dist/core/errors/handler.d.ts +9 -0
  127. package/dist/core/errors/handler.js +0 -0
  128. package/dist/core/errors/zod-error-map.js +30 -1
  129. package/dist/core/fetch/default-handler.d.ts +17 -0
  130. package/dist/core/fetch/default-handler.js +45 -0
  131. package/dist/core/fetch/fetch-state.d.ts +230 -0
  132. package/dist/core/fetch/fetch-state.js +896 -0
  133. package/dist/core/fetch/index.d.ts +61 -0
  134. package/dist/core/fetch/index.js +121 -0
  135. package/dist/core/fetch/types.d.ts +25 -0
  136. package/dist/core/fetch/types.js +0 -0
  137. package/dist/core/fetch/vite-plugin.d.ts +5 -0
  138. package/dist/core/fetch/vite-plugin.js +76 -0
  139. package/dist/core/hono/index.d.ts +21 -0
  140. package/dist/core/hono/index.js +101 -0
  141. package/dist/core/i18n/domain.d.ts +12 -0
  142. package/dist/core/i18n/domain.js +66 -0
  143. package/dist/core/i18n/handler.d.ts +18 -0
  144. package/dist/core/i18n/handler.js +122 -0
  145. package/dist/core/logger/core.d.ts +9 -1
  146. package/dist/core/logger/core.js +17 -1
  147. package/dist/core/messages/runtime.d.ts +0 -3
  148. package/dist/core/messages/runtime.js +1 -9
  149. package/dist/core/middleware/astro-middleware.d.ts +27 -0
  150. package/dist/core/middleware/astro-middleware.js +51 -0
  151. package/dist/core/module-loader/vite.js +1 -2
  152. package/dist/core/pages/handler.d.ts +20 -0
  153. package/dist/core/pages/handler.js +75 -0
  154. package/dist/core/preview/index.js +6 -5
  155. package/dist/core/preview/static-preview-server.js +5 -2
  156. package/dist/core/redirects/render.d.ts +2 -2
  157. package/dist/core/redirects/render.js +7 -8
  158. package/dist/core/render/params-and-props.js +2 -2
  159. package/dist/core/render/route-cache.d.ts +1 -0
  160. package/dist/core/render/route-cache.js +4 -4
  161. package/dist/core/render/slots.js +9 -2
  162. package/dist/core/rewrites/handler.d.ts +37 -0
  163. package/dist/core/rewrites/handler.js +67 -0
  164. package/dist/core/routing/3xx.js +8 -4
  165. package/dist/core/routing/create-manifest.js +11 -1
  166. package/dist/core/routing/handler.d.ts +17 -0
  167. package/dist/core/routing/handler.js +171 -0
  168. package/dist/core/routing/match.d.ts +0 -7
  169. package/dist/core/routing/match.js +0 -5
  170. package/dist/core/routing/parse-route.js +1 -1
  171. package/dist/core/routing/pattern.js +1 -1
  172. package/dist/core/routing/rewrite.js +2 -5
  173. package/dist/core/routing/router.d.ts +8 -0
  174. package/dist/core/routing/router.js +28 -0
  175. package/dist/core/routing/trailing-slash-handler.d.ts +18 -0
  176. package/dist/core/routing/trailing-slash-handler.js +67 -0
  177. package/dist/core/routing/validation.js +1 -1
  178. package/dist/core/server-islands/vite-plugin-server-islands.d.ts +6 -1
  179. package/dist/core/server-islands/vite-plugin-server-islands.js +13 -3
  180. package/dist/core/session/config.d.ts +1 -1
  181. package/dist/core/session/drivers.d.ts +1 -1
  182. package/dist/core/session/handler.d.ts +11 -0
  183. package/dist/core/session/handler.js +33 -0
  184. package/dist/core/session/runtime.js +7 -2
  185. package/dist/core/util/normalized-url.d.ts +10 -0
  186. package/dist/core/util/normalized-url.js +24 -0
  187. package/dist/core/util/pathname.d.ts +10 -1
  188. package/dist/core/util/pathname.js +13 -4
  189. package/dist/environments.js +1 -1
  190. package/dist/events/session.d.ts +8 -0
  191. package/dist/events/session.js +11 -0
  192. package/dist/i18n/middleware.d.ts +10 -0
  193. package/dist/i18n/middleware.js +4 -88
  194. package/dist/i18n/utils.js +2 -2
  195. package/dist/jsx/rehype.d.ts +1 -1
  196. package/dist/manifest/virtual-module.js +3 -1
  197. package/dist/markdown/index.d.ts +4 -0
  198. package/dist/markdown/index.js +14 -0
  199. package/dist/prefetch/index.js +12 -7
  200. package/dist/prerender/utils.js +5 -1
  201. package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +9 -0
  202. package/dist/runtime/server/astro-island.js +57 -20
  203. package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
  204. package/dist/runtime/server/astro-island.prebuilt-dev.js +1 -1
  205. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  206. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  207. package/dist/runtime/server/jsx.js +1 -1
  208. package/dist/runtime/server/render/common.js +10 -4
  209. package/dist/runtime/server/render/component.js +8 -6
  210. package/dist/runtime/server/render/head.js +1 -5
  211. package/dist/runtime/server/render/server-islands.js +2 -1
  212. package/dist/runtime/server/render/util.js +2 -2
  213. package/dist/runtime/server/scripts.js +6 -0
  214. package/dist/runtime/server/transition.d.ts +1 -6
  215. package/dist/runtime/server/transition.js +0 -8
  216. package/dist/transitions/events.d.ts +0 -14
  217. package/dist/transitions/events.js +0 -14
  218. package/dist/transitions/index.d.ts +0 -1
  219. package/dist/transitions/index.js +0 -2
  220. package/dist/transitions/vite-plugin-transitions.js +2 -4
  221. package/dist/types/public/config.d.ts +96 -14
  222. package/dist/types/public/content.d.ts +5 -5
  223. package/dist/types/public/index.d.ts +2 -1
  224. package/dist/types/public/integrations.d.ts +11 -3
  225. package/dist/types/public/internal.d.ts +1 -1
  226. package/dist/types/public/manifest.d.ts +1 -1
  227. package/dist/virtual-modules/i18n.d.ts +2 -2
  228. package/dist/virtual-modules/i18n.js +1 -1
  229. package/dist/vite-plugin-app/app.d.ts +13 -6
  230. package/dist/vite-plugin-app/app.js +51 -89
  231. package/dist/vite-plugin-app/createAstroServerApp.d.ts +3 -1
  232. package/dist/vite-plugin-app/createAstroServerApp.js +4 -3
  233. package/dist/vite-plugin-astro-server/plugin.js +11 -5
  234. package/dist/vite-plugin-astro-server/route-guard.d.ts +33 -0
  235. package/dist/vite-plugin-astro-server/route-guard.js +42 -23
  236. package/dist/vite-plugin-dev-status/index.d.ts +2 -0
  237. package/dist/vite-plugin-dev-status/index.js +15 -0
  238. package/dist/vite-plugin-head/index.js +36 -19
  239. package/dist/vite-plugin-hmr-reload/index.d.ts +1 -1
  240. package/dist/vite-plugin-hmr-reload/index.js +23 -1
  241. package/dist/vite-plugin-integrations-container/index.js +15 -6
  242. package/dist/vite-plugin-markdown/content-entry-type.js +7 -4
  243. package/dist/vite-plugin-markdown/images.js +9 -11
  244. package/dist/vite-plugin-markdown/index.js +12 -11
  245. package/dist/vite-plugin-utils/index.d.ts +1 -0
  246. package/dist/vite-plugin-utils/index.js +10 -1
  247. package/package.json +23 -16
  248. package/templates/content/types.d.ts +1 -0
  249. package/types/transitions.d.ts +0 -7
  250. package/dist/core/render-context.d.ts +0 -77
  251. package/dist/core/render-context.js +0 -826
@@ -11,7 +11,7 @@ const ClientAddressNotAvailable = {
11
11
  const PrerenderClientAddressNotAvailable = {
12
12
  name: "PrerenderClientAddressNotAvailable",
13
13
  title: "`Astro.clientAddress` cannot be used inside prerendered routes.",
14
- message: (name) => `\`Astro.clientAddress\` cannot be used inside prerendered route ${name}`
14
+ message: (name) => `\`Astro.clientAddress\` cannot be used inside prerendered route ${name}.`
15
15
  };
16
16
  const StaticClientAddressNotAvailable = {
17
17
  name: "StaticClientAddressNotAvailable",
@@ -34,7 +34,7 @@ const OnlyResponseCanBeReturned = {
34
34
  const MissingMediaQueryDirective = {
35
35
  name: "MissingMediaQueryDirective",
36
36
  title: "Missing value for `client:media` directive.",
37
- message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
37
+ message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided.'
38
38
  };
39
39
  const NoMatchingRenderer = {
40
40
  name: "NoMatchingRenderer",
@@ -57,42 +57,42 @@ const NoClientOnlyHint = {
57
57
  name: "NoClientOnlyHint",
58
58
  title: "Missing hint on client:only directive.",
59
59
  message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
60
- hint: (probableRenderers) => `Did you mean to pass \`client:only="${probableRenderers}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`
60
+ hint: (probableRenderers) => `Did you mean to pass \`client:only="${probableRenderers}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on \`client:only\`.`
61
61
  };
62
62
  const InvalidGetStaticPathParam = {
63
63
  name: "InvalidGetStaticPathParam",
64
- title: "Invalid value returned by a `getStaticPaths` path.",
65
- message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
66
- hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
64
+ title: "Invalid value returned by a route from `getStaticPaths()`.",
65
+ message: (paramType) => `Invalid \`params\` value returned by a route from \`getStaticPaths()\`. Expected an \`object\`, got \`${paramType}\`.`,
66
+ hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on `getStaticPaths()`."
67
67
  };
68
68
  const InvalidGetStaticPathsEntry = {
69
69
  name: "InvalidGetStaticPathsEntry",
70
- title: "Invalid entry inside getStaticPath's return value",
71
- message: (entryType) => `Invalid entry returned by getStaticPaths. Expected an object, got \`${entryType}\``,
72
- hint: "If you're using a `.map` call, you might be looking for `.flatMap()` instead. See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
70
+ title: "Invalid entry inside `getStaticPaths()`'s return value.",
71
+ message: (entryType) => `Invalid entry returned by \`getStaticPaths()\`. Expected an object, got \`${entryType}\`.`,
72
+ hint: "If you're using a `.map` call, you might be looking for `.flatMap()` instead. See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on `getStaticPaths()`."
73
73
  };
74
74
  const InvalidGetStaticPathsReturn = {
75
75
  name: "InvalidGetStaticPathsReturn",
76
- title: "Invalid value returned by getStaticPaths.",
77
- message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
78
- hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
76
+ title: "Invalid value returned by `getStaticPaths()`.",
77
+ message: (returnType) => `Invalid type returned by \`getStaticPaths()\`. Expected an \`array\`, got \`${returnType}\`.`,
78
+ hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on `getStaticPaths()`."
79
79
  };
80
80
  const GetStaticPathsExpectedParams = {
81
81
  name: "GetStaticPathsExpectedParams",
82
- title: "Missing params property on `getStaticPaths` route.",
83
- message: "Missing or empty required `params` property on `getStaticPaths` route.",
84
- hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
82
+ title: "Missing params property on `getStaticPaths()` route.",
83
+ message: "Missing or empty required `params` property on `getStaticPaths()` route.",
84
+ hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on `getStaticPaths()`."
85
85
  };
86
86
  const GetStaticPathsInvalidRouteParam = {
87
87
  name: "GetStaticPathsInvalidRouteParam",
88
88
  title: "Invalid route parameter returned by `getStaticPaths()`.",
89
- message: (key, value, valueType) => `Invalid \`getStaticPaths()\` route parameter for \`${key}\`. Expected a string or undefined, received \`${valueType}\` (\`${value}\`)`,
90
- hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
89
+ message: (key, value, valueType) => `Invalid \`getStaticPaths()\` route parameter for \`${key}\`. Expected a string or undefined, received \`${valueType}\` (\`${value}\`).`,
90
+ hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on `getStaticPaths()`."
91
91
  };
92
92
  const GetStaticPathsRequired = {
93
93
  name: "GetStaticPathsRequired",
94
94
  title: "`getStaticPaths()` function required for dynamic routes.",
95
- message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
95
+ message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths()` function from your dynamic route.",
96
96
  hint: `See https://docs.astro.build/en/guides/routing/#dynamic-routes for more information on dynamic routes.
97
97
 
98
98
  If you meant for this route to be server-rendered, set \`export const prerender = false;\` in the page.`
@@ -104,7 +104,7 @@ const ReservedSlotName = {
104
104
  };
105
105
  const NoAdapterInstalled = {
106
106
  name: "NoAdapterInstalled",
107
- title: "Cannot use Server-side Rendering without an adapter.",
107
+ title: "Cannot use server-side rendering without an adapter.",
108
108
  message: `Cannot use server-rendered pages without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
109
109
  hint: "See https://docs.astro.build/en/guides/on-demand-rendering/ for more information."
110
110
  };
@@ -115,7 +115,7 @@ const AdapterSupportOutputMismatch = {
115
115
  };
116
116
  const NoAdapterInstalledServerIslands = {
117
117
  name: "NoAdapterInstalledServerIslands",
118
- title: "Cannot use Server Islands without an adapter.",
118
+ title: "Cannot use server islands without an adapter.",
119
119
  message: `Cannot use server islands without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
120
120
  hint: "See https://docs.astro.build/en/guides/on-demand-rendering/ for more information."
121
121
  };
@@ -128,8 +128,8 @@ const NoMatchingImport = {
128
128
  const InvalidPrerenderExport = {
129
129
  name: "InvalidPrerenderExport",
130
130
  title: "Invalid prerender export.",
131
- message(prefix, suffix, isHydridOutput) {
132
- const defaultExpectedValue = isHydridOutput ? "false" : "true";
131
+ message(prefix, suffix, isHybridOutput) {
132
+ const defaultExpectedValue = isHybridOutput ? "false" : "true";
133
133
  let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
134
134
  if (prefix !== "const") msg += `
135
135
  Expected \`const\` declaration but got \`${prefix}\`.`;
@@ -165,25 +165,25 @@ const InvalidImageService = {
165
165
  };
166
166
  const MissingImageDimension = {
167
167
  name: "MissingImageDimension",
168
- title: "Missing image dimensions",
168
+ title: "Missing image dimensions.",
169
169
  message: (missingDimension, imageURL) => `Missing ${missingDimension === "both" ? "width and height attributes" : `${missingDimension} attribute`} for ${imageURL}. When using remote images, both dimensions are required in order to avoid CLS.`,
170
170
  hint: "If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets). You can also use `inferSize={true}` for remote images to get the original dimensions."
171
171
  };
172
172
  const FailedToFetchRemoteImageDimensions = {
173
173
  name: "FailedToFetchRemoteImageDimensions",
174
- title: "Failed to retrieve remote image dimensions",
174
+ title: "Failed to retrieve remote image dimensions.",
175
175
  message: (imageURL) => `Failed to get the dimensions for ${imageURL}.`,
176
176
  hint: "Verify your remote image URL is accurate, and that you are not using `inferSize` with a file located in your `public/` folder."
177
177
  };
178
178
  const RemoteImageNotAllowed = {
179
179
  name: "RemoteImageNotAllowed",
180
- title: "Remote image is not allowed",
180
+ title: "Remote image is not allowed.",
181
181
  message: (imageURL) => `Remote image ${imageURL} is not allowed by your image configuration.`,
182
182
  hint: "Update `image.domains` or `image.remotePatterns`, or remove `inferSize` for this image."
183
183
  };
184
184
  const UnsupportedImageFormat = {
185
185
  name: "UnsupportedImageFormat",
186
- title: "Unsupported image format",
186
+ title: "Unsupported image format.",
187
187
  message: (format, imagePath, supportedFormats) => `Received unsupported format \`${format}\` from \`${imagePath}\`. Currently only ${supportedFormats.join(
188
188
  ", "
189
189
  )} are supported by our image services.`,
@@ -191,12 +191,12 @@ const UnsupportedImageFormat = {
191
191
  };
192
192
  const UnsupportedImageConversion = {
193
193
  name: "UnsupportedImageConversion",
194
- title: "Unsupported image conversion",
194
+ title: "Unsupported image conversion.",
195
195
  message: "Converting between vector (such as SVGs) and raster (such as PNGs and JPEGs) images is not currently supported."
196
196
  };
197
197
  const CannotOptimizeSvg = {
198
198
  name: "CannotOptimizeSvg",
199
- title: "Cannot optimize SVG",
199
+ title: "Cannot optimize SVG.",
200
200
  message: (path, name) => `An error occurred while optimizing SVG file "${path}" with the "${name}" optimizer.`,
201
201
  hint: "Review the included error message provided for guidance."
202
202
  };
@@ -223,7 +223,7 @@ Full serialized options received: \`${fullOptions}\`.`,
223
223
  const ExpectedImageOptions = {
224
224
  name: "ExpectedImageOptions",
225
225
  title: "Expected image options.",
226
- message: (options) => `Expected getImage() parameter to be an object. Received \`${options}\`.`
226
+ message: (options) => `Expected \`getImage()\` parameter to be an object. Received \`${options}\`.`
227
227
  };
228
228
  const ExpectedNotESMImage = {
229
229
  name: "ExpectedNotESMImage",
@@ -235,11 +235,11 @@ const GetImageNotUsedOnServer = {
235
235
  name: "GetImageNotUsedOnServer",
236
236
  title: "`getImage()` must be used on the server.",
237
237
  message: "`getImage()` should only be used on the server. To use images on the client, render the `src` from `getImage()` during the server render, then pass it to the client for usage.",
238
- hint: "See https://docs.astro.build/en/reference/modules/astro-assets/#getimage for more information on getImage()."
238
+ hint: "See https://docs.astro.build/en/reference/modules/astro-assets/#getimage for more information on `getImage()`."
239
239
  };
240
240
  const IncompatibleDescriptorOptions = {
241
241
  name: "IncompatibleDescriptorOptions",
242
- title: "Cannot set both `densities` and `widths`",
242
+ title: "Cannot set both `densities` and `widths`.",
243
243
  message: "Only one of `densities` or `widths` can be specified. In most cases, you'll probably want to use only `widths` if you require specific widths.",
244
244
  hint: "Those attributes are used to construct a `srcset` attribute, which cannot have both `x` and `w` descriptors."
245
245
  };
@@ -307,8 +307,8 @@ const MiddlewareCantBeLoaded = {
307
307
  const LocalImageUsedWrongly = {
308
308
  name: "LocalImageUsedWrongly",
309
309
  title: "Local images must be imported.",
310
- message: (imageFilePath) => `\`Image\`'s and \`getImage\`'s \`src\` parameter must be an imported image or an URL, it cannot be a string filepath. Received \`${imageFilePath}\`.`,
311
- hint: "If you want to use an image from your `src` folder, you need to either import it or if the image is coming from a content collection, use the [image() schema helper](https://docs.astro.build/en/guides/images/#images-in-content-collections). See https://docs.astro.build/en/guides/images/#src-required for more information on the `src` property."
310
+ message: (imageFilePath) => `\`Image\`'s and \`getImage\`'s \`src\` parameter must be an imported image or a URL, it cannot be a string filepath. Received \`${imageFilePath}\`.`,
311
+ hint: "If you want to use an image from your `src` folder, you need to either import it or if the image is coming from a content collection, use the [image() schema helper](https://docs.astro.build/en/guides/images/#images-in-content-collections). See https://docs.astro.build/en/reference/modules/astro-assets/#src-required for more information on the `src` property."
312
312
  };
313
313
  const AstroGlobUsedOutside = {
314
314
  name: "AstroGlobUsedOutside",
@@ -335,8 +335,14 @@ const UnsupportedExternalRedirect = {
335
335
  const InvalidRedirectDestination = {
336
336
  name: "InvalidRedirectDestination",
337
337
  title: "Invalid redirect destination.",
338
- message: (from, to) => `The redirect from "${from}" to "${to}" is invalid. The destination "${to}" does not match any existing route in your project.`,
339
- hint: 'If you are redirecting to a specific page of a dynamic route (e.g., "/posts/[slug]/1"), this is not supported. The destination must be either a static path or a route pattern that matches an existing page (e.g., "/posts/[slug]/[page]").'
338
+ message(from, to, missingParams) {
339
+ if (missingParams && missingParams.length > 0) {
340
+ const formatted = missingParams.map((p) => `[${p}]`).join(", ");
341
+ return `The redirect from "${from}" to "${to}" is invalid. The destination route is missing dynamic parameter(s) ${formatted} required by the source route "${from}".`;
342
+ }
343
+ return `The redirect from "${from}" to "${to}" is invalid. The destination "${to}" does not match any existing route in your project.`;
344
+ },
345
+ hint: 'The destination of a dynamic redirect must include all dynamic parameters from the source route. For example, a redirect from "/old/[slug]" must go to a route that also has a [slug] parameter, like "/new/[slug]".'
340
346
  };
341
347
  const InvalidDynamicRoute = {
342
348
  name: "InvalidDynamicRoute",
@@ -351,7 +357,7 @@ const MissingSharp = {
351
357
  };
352
358
  const UnknownViteError = {
353
359
  name: "UnknownViteError",
354
- title: "Unknown Vite Error."
360
+ title: "Unknown Vite error."
355
361
  };
356
362
  const FailedToLoadModuleSSR = {
357
363
  name: "FailedToLoadModuleSSR",
@@ -367,7 +373,7 @@ const InvalidGlob = {
367
373
  };
368
374
  const FailedToFindPageMapSSR = {
369
375
  name: "FailedToFindPageMapSSR",
370
- title: "Astro couldn't find the correct page to render",
376
+ title: "Astro couldn't find the correct page to render.",
371
377
  message: "Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error. Please file an issue."
372
378
  };
373
379
  const MissingLocale = {
@@ -383,13 +389,13 @@ const MissingIndexForInternationalization = {
383
389
  };
384
390
  const IncorrectStrategyForI18n = {
385
391
  name: "IncorrectStrategyForI18n",
386
- title: "You can't use the current function with the current strategy",
392
+ title: "Function incompatible with the current strategy.",
387
393
  message: (functionName) => `The function \`${functionName}\` can only be used when the \`i18n.routing.strategy\` is set to \`"manual"\`.`
388
394
  };
389
395
  const NoPrerenderedRoutesWithDomains = {
390
396
  name: "NoPrerenderedRoutesWithDomains",
391
397
  title: "Prerendered routes aren't supported when internationalization domains are enabled.",
392
- message: (component) => `Static pages aren't yet supported with multiple domains. To enable this feature, you must disable prerendering for the page ${component}`
398
+ message: (component) => `Static pages aren't yet supported with multiple domains. To enable this feature, you must disable prerendering for the page ${component}.`
393
399
  };
394
400
  const MissingMiddlewareForInternationalization = {
395
401
  name: "MissingMiddlewareForInternationalization",
@@ -398,31 +404,31 @@ const MissingMiddlewareForInternationalization = {
398
404
  };
399
405
  const InvalidI18nMiddlewareConfiguration = {
400
406
  name: "InvalidI18nMiddlewareConfiguration",
401
- title: "Invalid internationalization middleware configuration",
407
+ title: "Invalid internationalization middleware configuration.",
402
408
  message: "The option `redirectToDefaultLocale` can be enabled only when `prefixDefaultLocale` is also set to `true`; otherwise, redirects might cause infinite loops. Enable the option `prefixDefaultLocale` to continue to use `redirectToDefaultLocale`, or ensure both are set to `false`."
403
409
  };
404
410
  const CantRenderPage = {
405
411
  name: "CantRenderPage",
406
412
  title: "Astro can't render the route.",
407
413
  message: "Astro cannot find any content to render for this route. There is no file or redirect associated with this route.",
408
- hint: "If you expect to find a route here, this may be an Astro bug. Please file an issue/restart the dev server"
414
+ hint: "If you expect to find a route here, this may be an Astro bug. Please file an issue/restart the dev server."
409
415
  };
410
416
  const UnhandledRejection = {
411
417
  name: "UnhandledRejection",
412
- title: "Unhandled rejection",
418
+ title: "Unhandled rejection.",
413
419
  message: (stack) => `Astro detected an unhandled rejection. Here's the stack trace:
414
420
  ${stack}`,
415
421
  hint: "Make sure your promises all have an `await` or a `.catch()` handler."
416
422
  };
417
423
  const i18nNotEnabled = {
418
424
  name: "i18nNotEnabled",
419
- title: "i18n Not Enabled",
420
- message: "The `astro:i18n` module cannot be used without enabling i18n in your Astro config.",
425
+ title: "Internationalization routing is not enabled.",
426
+ message: "The `astro:i18n` module cannot be used without enabling `i18n` in your Astro config.",
421
427
  hint: "See https://docs.astro.build/en/guides/internationalization for a guide on setting up i18n."
422
428
  };
423
429
  const i18nNoLocaleFoundInPath = {
424
430
  name: "i18nNoLocaleFoundInPath",
425
- title: "The path doesn't contain any locale",
431
+ title: "The path doesn't contain any locale.",
426
432
  message: "You tried to use an i18n utility on a path that doesn't contain any locale. You can use `pathHasLocale` first to determine if the path has a locale."
427
433
  };
428
434
  const RouteNotFound = {
@@ -432,7 +438,7 @@ const RouteNotFound = {
432
438
  };
433
439
  const EnvInvalidVariables = {
434
440
  name: "EnvInvalidVariables",
435
- title: "Invalid Environment Variables",
441
+ title: "Invalid environment variables.",
436
442
  message: (errors) => `The following environment variables defined in \`env.schema\` are invalid:
437
443
 
438
444
  ${errors.map((err) => `- ${err}`).join("\n")}
@@ -440,7 +446,7 @@ ${errors.map((err) => `- ${err}`).join("\n")}
440
446
  };
441
447
  const EnvPrefixConflictsWithSecret = {
442
448
  name: "EnvPrefixConflictsWithSecret",
443
- title: "envPrefix conflicts with secret environment variables",
449
+ title: "`envPrefix` conflicts with secret environment variables.",
444
450
  message: (conflicts) => `The following environment variables are declared with \`access: "secret"\` in \`env.schema\`, but their names match a prefix in \`vite.envPrefix\`, which would expose them in client-side bundles:
445
451
 
446
452
  ${conflicts.map((c) => `- ${c}`).join("\n")}
@@ -449,13 +455,13 @@ Either remove the conflicting prefixes from \`vite.envPrefix\`, or rename these
449
455
  };
450
456
  const ServerOnlyModule = {
451
457
  name: "ServerOnlyModule",
452
- title: "Module is only available server-side",
458
+ title: "Module is only available server-side.",
453
459
  message: (name) => `The "${name}" module is only available server-side.`
454
460
  };
455
461
  const RewriteWithBodyUsed = {
456
462
  name: "RewriteWithBodyUsed",
457
- title: "Cannot use Astro.rewrite after the request body has been read",
458
- message: "Astro.rewrite() cannot be used if the request body has already been read. If you need to read the body, first clone the request."
463
+ title: "Cannot use `Astro.rewrite()` after the request body has been read.",
464
+ message: "`Astro.rewrite()` cannot be used if the request body has already been read. If you need to read the body, first clone the request."
459
465
  };
460
466
  const ForbiddenRewrite = {
461
467
  name: "ForbiddenRewrite",
@@ -465,7 +471,7 @@ const ForbiddenRewrite = {
465
471
  The static route '${to}' is rendered by the component
466
472
  '${component}', which is marked as prerendered. This is a forbidden operation because during the build, the component '${component}' is compiled to an
467
473
  HTML file, which can't be retrieved at runtime by Astro.`,
468
- hint: (component) => `Add \`export const prerender = false\` to the component '${component}', or use a Astro.redirect().`
474
+ hint: (component) => `Add \`export const prerender = false\` to the component '${component}', or use \`Astro.redirect()\`.`
469
475
  };
470
476
  const UnknownFilesystemError = {
471
477
  name: "UnknownFilesystemError",
@@ -475,30 +481,30 @@ const UnknownFilesystemError = {
475
481
  const CannotExtractFontType = {
476
482
  name: "CannotExtractFontType",
477
483
  title: "Cannot extract the font type from the given URL.",
478
- message: (url) => `An error occurred while trying to extract the font type from ${url}`,
484
+ message: (url) => `An error occurred while trying to extract the font type from ${url}.`,
479
485
  hint: "Open an issue at https://github.com/withastro/astro/issues."
480
486
  };
481
487
  const CannotDetermineWeightAndStyleFromFontFile = {
482
488
  name: "CannotDetermineWeightAndStyleFromFontFile",
483
489
  title: "Cannot determine weight and style from font file.",
484
- message: (family, url) => `An error occurred while determining the \`weight\` and \`style\` from local family "${family}" font file: ${url}`,
490
+ message: (family, url) => `An error occurred while determining the \`weight\` and \`style\` from local family "${family}" font file: ${url}.`,
485
491
  hint: "Update your family config and set `weight` and `style` manually instead."
486
492
  };
487
493
  const CannotFetchFontFile = {
488
494
  name: "CannotFetchFontFile",
489
495
  title: "Cannot fetch the given font file.",
490
- message: (url) => `An error occurred while fetching the font file from ${url}`,
496
+ message: (url) => `An error occurred while fetching the font file from ${url}.`,
491
497
  hint: "This is often caused by connectivity issues. If the error persists, open an issue at https://github.com/withastro/astro/issues."
492
498
  };
493
499
  const FontFamilyNotFound = {
494
500
  name: "FontFamilyNotFound",
495
- title: "Font family not found",
501
+ title: "Font family not found.",
496
502
  message: (family) => `No data was found for the \`"${family}"\` family passed to the \`<Font>\` component.`,
497
503
  hint: "This is often caused by a typo. Check that the `<Font />` component is using a `cssVariable` specified in your config."
498
504
  };
499
505
  const FontFileUrlNotFound = {
500
506
  name: "FontFileUrlNotFound",
501
- title: "Font file URL not found",
507
+ title: "Font file URL not found.",
502
508
  message: (url) => `The \`"${url}"\` URL passed to the \`experimental_getFontFileURL()\` function is invalid.`,
503
509
  hint: "Make sure you pass a valid URL, obtained via the `fontData` object."
504
510
  };
@@ -509,8 +515,8 @@ const MissingGetFontFileRequestUrl = {
509
515
  };
510
516
  const UnavailableAstroGlobal = {
511
517
  name: "UnavailableAstroGlobal",
512
- title: "Unavailable Astro global in getStaticPaths()",
513
- message: (name) => `The Astro global is not available in this scope. Please remove "Astro.${name}" from your getStaticPaths() function.`
518
+ title: "Unavailable Astro global in `getStaticPaths()`.",
519
+ message: (name) => `The Astro global is not available in this scope. Please remove \`Astro.${name}\` from your \`getStaticPaths()\` function.`
514
520
  };
515
521
  const UnableToLoadLogger = {
516
522
  name: "UnableToLoadLogger",
@@ -519,19 +525,19 @@ const UnableToLoadLogger = {
519
525
  };
520
526
  const LoggerConfigurationNotSerializable = {
521
527
  name: "LoggerConfigurationNotSerializable",
522
- title: "The configuration of the logger is not serializable"
528
+ title: "The configuration of the logger is not serializable."
523
529
  };
524
530
  const UnknownCSSError = {
525
531
  name: "UnknownCSSError",
526
- title: "Unknown CSS Error."
532
+ title: "Unknown CSS error."
527
533
  };
528
534
  const CSSSyntaxError = {
529
535
  name: "CSSSyntaxError",
530
- title: "CSS Syntax Error."
536
+ title: "CSS syntax error."
531
537
  };
532
538
  const UnknownMarkdownError = {
533
539
  name: "UnknownMarkdownError",
534
- title: "Unknown Markdown Error."
540
+ title: "Unknown Markdown error."
535
541
  };
536
542
  const MarkdownFrontmatterParseError = {
537
543
  name: "MarkdownFrontmatterParseError",
@@ -566,22 +572,22 @@ const ConfigLegacyKey = {
566
572
  };
567
573
  const UnknownCLIError = {
568
574
  name: "UnknownCLIError",
569
- title: "Unknown CLI Error."
575
+ title: "Unknown CLI error."
570
576
  };
571
577
  const GenerateContentTypesError = {
572
578
  name: "GenerateContentTypesError",
573
579
  title: "Failed to generate content types.",
574
- message: (errorMessage) => `\`astro sync\` command failed to generate content collection types: ${errorMessage}`,
580
+ message: (errorMessage) => `\`astro sync\` command failed to generate content collection types: ${errorMessage}.`,
575
581
  hint: (fileName) => `This error is often caused by a syntax error inside your content, or your content configuration file. Check your ${fileName ?? "content config"} file for typos.`
576
582
  };
577
583
  const UnknownContentCollectionError = {
578
584
  name: "UnknownContentCollectionError",
579
- title: "Unknown Content Collection Error."
585
+ title: "Unknown content collection error."
580
586
  };
581
587
  const RenderUndefinedEntryError = {
582
588
  name: "RenderUndefinedEntryError",
583
589
  title: "Attempted to render an undefined content collection entry.",
584
- hint: "Check if the entry is undefined before passing it to `render()`"
590
+ hint: "Check if the entry is undefined before passing it to `render()`."
585
591
  };
586
592
  const GetEntryDeprecationError = {
587
593
  name: "GetEntryDeprecationError",
@@ -665,7 +671,7 @@ const LiveContentConfigError = {
665
671
  };
666
672
  const ContentLoaderInvalidDataError = {
667
673
  name: "ContentLoaderInvalidDataError",
668
- title: "Content entry is missing an ID",
674
+ title: "Content entry is missing an ID.",
669
675
  message(collection, extra) {
670
676
  return `**${String(collection)}** entry is missing an ID.
671
677
  ${extra}`;
@@ -684,7 +690,7 @@ const InvalidContentEntrySlugError = {
684
690
  };
685
691
  const ContentSchemaContainsSlugError = {
686
692
  name: "ContentSchemaContainsSlugError",
687
- title: "Content Schema should not contain `slug`.",
693
+ title: "Content schema should not contain `slug`.",
688
694
  message: (collectionName) => `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collectionName} collection schema.`,
689
695
  hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
690
696
  };
@@ -727,19 +733,19 @@ Full error: ${parseError}`,
727
733
  };
728
734
  const FileParserNotFound = {
729
735
  name: "FileParserNotFound",
730
- title: "File parser not found",
736
+ title: "File parser not found.",
731
737
  message: (fileName) => `No parser was found for '${fileName}'. Pass a parser function (e.g. \`parser: csv\`) to the \`file\` loader.`
732
738
  };
733
739
  const FileGlobNotSupported = {
734
740
  name: "FileGlobNotSupported",
735
- title: "Glob patterns are not supported in the file loader",
741
+ title: "Glob patterns are not supported in the file loader.",
736
742
  message: "Glob patterns are not supported in the `file` loader. Use the `glob` loader instead.",
737
743
  hint: `See Astro's file loader https://docs.astro.build/en/reference/content-loader-reference/#file-loader for supported usage.`
738
744
  };
739
745
  const ActionsWithoutServerOutputError = {
740
746
  name: "ActionsWithoutServerOutputError",
741
747
  title: "Actions must be used with server output.",
742
- message: "A server is required to create callable backend functions. To deploy routes to a server, add an adapter to your Astro config and configure your route for on-demand rendering",
748
+ message: "A server is required to create callable backend functions. To deploy routes to a server, add an adapter to your Astro config and configure your route for on-demand rendering.",
743
749
  hint: "Add an adapter and enable on-demand rendering: https://docs.astro.build/en/guides/on-demand-rendering/"
744
750
  };
745
751
  const ActionsReturnedInvalidDataError = {
@@ -756,8 +762,8 @@ const ActionNotFoundError = {
756
762
  };
757
763
  const ActionCalledFromServerError = {
758
764
  name: "ActionCalledFromServerError",
759
- title: "Action unexpected called from the server.",
760
- message: "Action called from a server page or endpoint without using `Astro.callAction()`. This wrapper must be used to call actions from server code.",
765
+ title: "Action called from the server without `Astro.callAction()`.",
766
+ message: "Action called from a server-rendered page or endpoint without using `Astro.callAction()`. This wrapper must be used to call actions from server code.",
761
767
  hint: "See the `Astro.callAction()` reference for usage examples: https://docs.astro.build/en/reference/api-reference/#callaction"
762
768
  };
763
769
  const UnknownError = { name: "UnknownError", title: "Unknown Error." };
@@ -0,0 +1,9 @@
1
+ import type { RenderErrorOptions } from '../app/base.js';
2
+ /**
3
+ * A strategy for rendering error responses (404, 500, etc.). Each execution
4
+ * environment (prod SSR, build/prerender, dev server) supplies its own
5
+ * implementation rather than overriding a method on the app.
6
+ */
7
+ export interface ErrorHandler {
8
+ renderError(request: Request, options: RenderErrorOptions): Promise<Response>;
9
+ }
File without changes
@@ -24,6 +24,17 @@ const errorMap = (issue) => {
24
24
  `> ${getTypeOrLiteralMsg(error)}`
25
25
  ) : `> ${prefix(key, getTypeOrLiteralMsg(error))}`
26
26
  );
27
+ if (details.length === 0) {
28
+ if ("discriminator" in issue && issue.discriminator && "options" in issue) {
29
+ const options = issue.options;
30
+ if (Array.isArray(options)) {
31
+ details.push(
32
+ `> Expected \`${issue.discriminator}\` to be ${options.map((o) => `\`${stringify(o)}\``).join(" | ")}`
33
+ );
34
+ details.push("> Received `" + stringify(issue.input) + "`");
35
+ }
36
+ }
37
+ }
27
38
  if (details.length === 0) {
28
39
  const expectedShapes = [];
29
40
  for (const unionErrors of issue.errors) {
@@ -33,7 +44,9 @@ const errorMap = (issue) => {
33
44
  return errorMap(_issue);
34
45
  }
35
46
  const relativePath = flattenErrorPath(_issue.path).replace(baseErrorPath, "").replace(leadingPeriod, "");
36
- if ("expected" in _issue && typeof _issue.expected === "string") {
47
+ if (_issue.code === "custom" && _issue.message && _issue.message.includes("security.csp")) {
48
+ expectedShape.push(_issue.message);
49
+ } else if ("expected" in _issue && typeof _issue.expected === "string") {
37
50
  expectedShape.push(
38
51
  relativePath ? `${relativePath}: ${_issue.expected}` : _issue.expected
39
52
  );
@@ -59,6 +72,22 @@ const errorMap = (issue) => {
59
72
  return {
60
73
  message: messages.concat(details).join("\n")
61
74
  };
75
+ } else if (issue.code === "invalid_key") {
76
+ const keyIssues = issue.issues;
77
+ if (Array.isArray(keyIssues) && keyIssues.length > 0) {
78
+ const firstIssue = keyIssues[0];
79
+ const msg = firstIssue.message || "Invalid key in record";
80
+ return { message: prefix(baseErrorPath, msg) };
81
+ }
82
+ return { message: prefix(baseErrorPath, "Invalid key in record") };
83
+ } else if (issue.code === "invalid_element") {
84
+ const elementIssues = issue.issues;
85
+ if (Array.isArray(elementIssues) && elementIssues.length > 0) {
86
+ const firstIssue = elementIssues[0];
87
+ const msg = firstIssue.message || "Invalid element";
88
+ return { message: prefix(baseErrorPath, msg) };
89
+ }
90
+ return { message: prefix(baseErrorPath, "Invalid element") };
62
91
  } else if (issue.code === "invalid_type") {
63
92
  return {
64
93
  message: prefix(
@@ -0,0 +1,17 @@
1
+ import type { BaseApp, ResolvedRenderOptions } from '../app/base.js';
2
+ import type { Pipeline } from '../base-pipeline.js';
3
+ import type { FetchHandler } from './types.js';
4
+ /**
5
+ * The default request handler for `BaseApp`. Builds the per-request
6
+ * `FetchState` and delegates to an `AstroHandler`.
7
+ */
8
+ export declare class DefaultFetchHandler {
9
+ #private;
10
+ constructor(app?: BaseApp<Pipeline>);
11
+ /**
12
+ * Fast path: called directly by `BaseApp.render()` with pre-resolved
13
+ * options, avoiding the `Reflect.set/get` round-trip through the request.
14
+ */
15
+ renderWithOptions(request: Request, options: ResolvedRenderOptions): Promise<Response>;
16
+ fetch: FetchHandler;
17
+ }
@@ -0,0 +1,45 @@
1
+ import { FetchState } from "./fetch-state.js";
2
+ import { appSymbol } from "../constants.js";
3
+ import { AstroHandler } from "../routing/handler.js";
4
+ class DefaultFetchHandler {
5
+ #app;
6
+ #handler;
7
+ constructor(app) {
8
+ this.#app = app ?? null;
9
+ this.#handler = app ? new AstroHandler(app) : null;
10
+ }
11
+ /**
12
+ * Fast path: called directly by `BaseApp.render()` with pre-resolved
13
+ * options, avoiding the `Reflect.set/get` round-trip through the request.
14
+ */
15
+ renderWithOptions(request, options) {
16
+ if (!this.#app) {
17
+ const app = Reflect.get(request, appSymbol);
18
+ if (!app) {
19
+ throw new Error("No fetch handler provided.");
20
+ }
21
+ this.#app = app;
22
+ this.#handler = new AstroHandler(app);
23
+ }
24
+ const state = new FetchState(this.#app.pipeline, request, options);
25
+ return this.#handler.handle(state);
26
+ }
27
+ fetch = (request) => {
28
+ if (!this.#app) {
29
+ const app = Reflect.get(request, appSymbol);
30
+ if (!app) {
31
+ throw new Error("No fetch handler provided.");
32
+ }
33
+ this.#app = app;
34
+ this.#handler = new AstroHandler(app);
35
+ }
36
+ const state = new FetchState(this.#app.pipeline, request);
37
+ if (!this.#handler) {
38
+ throw new Error("No fetch handler provided.");
39
+ }
40
+ return this.#handler.handle(state);
41
+ };
42
+ }
43
+ export {
44
+ DefaultFetchHandler
45
+ };