astro 6.3.3 → 6.3.5

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 (39) hide show
  1. package/dist/assets/internal.js +0 -16
  2. package/dist/assets/utils/generateImageStylesCSS.js +26 -6
  3. package/dist/assets/utils/metadata.js +1 -1
  4. package/dist/assets/utils/vendor/image-size/types/svg.js +1 -1
  5. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  6. package/dist/content/content-layer.js +3 -3
  7. package/dist/content/runtime.js +5 -2
  8. package/dist/core/build/generate.js +8 -1
  9. package/dist/core/build/plugins/plugin-internals.js +1 -1
  10. package/dist/core/build/static-build.js +9 -147
  11. package/dist/core/build/vite-build-config.d.ts +28 -0
  12. package/dist/core/build/vite-build-config.js +160 -0
  13. package/dist/core/config/schemas/base.d.ts +3 -1
  14. package/dist/core/config/schemas/base.js +6 -1
  15. package/dist/core/config/schemas/relative.d.ts +9 -3
  16. package/dist/core/constants.js +1 -1
  17. package/dist/core/dev/dev.js +1 -1
  18. package/dist/core/errors/errors-data.d.ts +29 -29
  19. package/dist/core/errors/errors-data.js +71 -71
  20. package/dist/core/fetch/fetch-state.d.ts +7 -0
  21. package/dist/core/fetch/fetch-state.js +5 -0
  22. package/dist/core/fetch/types.d.ts +19 -0
  23. package/dist/core/fetch/vite-plugin.js +11 -4
  24. package/dist/core/hono/index.d.ts +1 -1
  25. package/dist/core/hono/index.js +6 -3
  26. package/dist/core/messages/runtime.js +1 -1
  27. package/dist/core/middleware/astro-middleware.js +3 -1
  28. package/dist/core/module-loader/vite.js +1 -2
  29. package/dist/core/pages/handler.js +1 -0
  30. package/dist/types/public/config.d.ts +20 -3
  31. package/dist/types/public/context.d.ts +1 -1
  32. package/dist/types/public/extendables.d.ts +19 -0
  33. package/dist/types/public/index.d.ts +1 -0
  34. package/dist/vite-plugin-app/app.js +11 -11
  35. package/dist/vite-plugin-astro-server/plugin.js +8 -7
  36. package/dist/vite-plugin-hmr-reload/index.d.ts +1 -1
  37. package/dist/vite-plugin-hmr-reload/index.js +15 -1
  38. package/package.json +6 -6
  39. package/templates/content/types.d.ts +1 -0
@@ -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",
@@ -351,7 +351,7 @@ const MissingSharp = {
351
351
  };
352
352
  const UnknownViteError = {
353
353
  name: "UnknownViteError",
354
- title: "Unknown Vite Error."
354
+ title: "Unknown Vite error."
355
355
  };
356
356
  const FailedToLoadModuleSSR = {
357
357
  name: "FailedToLoadModuleSSR",
@@ -367,7 +367,7 @@ const InvalidGlob = {
367
367
  };
368
368
  const FailedToFindPageMapSSR = {
369
369
  name: "FailedToFindPageMapSSR",
370
- title: "Astro couldn't find the correct page to render",
370
+ title: "Astro couldn't find the correct page to render.",
371
371
  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
372
  };
373
373
  const MissingLocale = {
@@ -383,13 +383,13 @@ const MissingIndexForInternationalization = {
383
383
  };
384
384
  const IncorrectStrategyForI18n = {
385
385
  name: "IncorrectStrategyForI18n",
386
- title: "You can't use the current function with the current strategy",
386
+ title: "Function incompatible with the current strategy.",
387
387
  message: (functionName) => `The function \`${functionName}\` can only be used when the \`i18n.routing.strategy\` is set to \`"manual"\`.`
388
388
  };
389
389
  const NoPrerenderedRoutesWithDomains = {
390
390
  name: "NoPrerenderedRoutesWithDomains",
391
391
  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}`
392
+ message: (component) => `Static pages aren't yet supported with multiple domains. To enable this feature, you must disable prerendering for the page ${component}.`
393
393
  };
394
394
  const MissingMiddlewareForInternationalization = {
395
395
  name: "MissingMiddlewareForInternationalization",
@@ -398,31 +398,31 @@ const MissingMiddlewareForInternationalization = {
398
398
  };
399
399
  const InvalidI18nMiddlewareConfiguration = {
400
400
  name: "InvalidI18nMiddlewareConfiguration",
401
- title: "Invalid internationalization middleware configuration",
401
+ title: "Invalid internationalization middleware configuration.",
402
402
  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
403
  };
404
404
  const CantRenderPage = {
405
405
  name: "CantRenderPage",
406
406
  title: "Astro can't render the route.",
407
407
  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"
408
+ hint: "If you expect to find a route here, this may be an Astro bug. Please file an issue/restart the dev server."
409
409
  };
410
410
  const UnhandledRejection = {
411
411
  name: "UnhandledRejection",
412
- title: "Unhandled rejection",
412
+ title: "Unhandled rejection.",
413
413
  message: (stack) => `Astro detected an unhandled rejection. Here's the stack trace:
414
414
  ${stack}`,
415
415
  hint: "Make sure your promises all have an `await` or a `.catch()` handler."
416
416
  };
417
417
  const i18nNotEnabled = {
418
418
  name: "i18nNotEnabled",
419
- title: "i18n Not Enabled",
420
- message: "The `astro:i18n` module cannot be used without enabling i18n in your Astro config.",
419
+ title: "Internationalization routing is not enabled.",
420
+ message: "The `astro:i18n` module cannot be used without enabling `i18n` in your Astro config.",
421
421
  hint: "See https://docs.astro.build/en/guides/internationalization for a guide on setting up i18n."
422
422
  };
423
423
  const i18nNoLocaleFoundInPath = {
424
424
  name: "i18nNoLocaleFoundInPath",
425
- title: "The path doesn't contain any locale",
425
+ title: "The path doesn't contain any locale.",
426
426
  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
427
  };
428
428
  const RouteNotFound = {
@@ -432,7 +432,7 @@ const RouteNotFound = {
432
432
  };
433
433
  const EnvInvalidVariables = {
434
434
  name: "EnvInvalidVariables",
435
- title: "Invalid Environment Variables",
435
+ title: "Invalid environment variables.",
436
436
  message: (errors) => `The following environment variables defined in \`env.schema\` are invalid:
437
437
 
438
438
  ${errors.map((err) => `- ${err}`).join("\n")}
@@ -440,7 +440,7 @@ ${errors.map((err) => `- ${err}`).join("\n")}
440
440
  };
441
441
  const EnvPrefixConflictsWithSecret = {
442
442
  name: "EnvPrefixConflictsWithSecret",
443
- title: "envPrefix conflicts with secret environment variables",
443
+ title: "`envPrefix` conflicts with secret environment variables.",
444
444
  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
445
 
446
446
  ${conflicts.map((c) => `- ${c}`).join("\n")}
@@ -449,13 +449,13 @@ Either remove the conflicting prefixes from \`vite.envPrefix\`, or rename these
449
449
  };
450
450
  const ServerOnlyModule = {
451
451
  name: "ServerOnlyModule",
452
- title: "Module is only available server-side",
452
+ title: "Module is only available server-side.",
453
453
  message: (name) => `The "${name}" module is only available server-side.`
454
454
  };
455
455
  const RewriteWithBodyUsed = {
456
456
  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."
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."
459
459
  };
460
460
  const ForbiddenRewrite = {
461
461
  name: "ForbiddenRewrite",
@@ -465,7 +465,7 @@ const ForbiddenRewrite = {
465
465
  The static route '${to}' is rendered by the component
466
466
  '${component}', which is marked as prerendered. This is a forbidden operation because during the build, the component '${component}' is compiled to an
467
467
  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().`
468
+ hint: (component) => `Add \`export const prerender = false\` to the component '${component}', or use \`Astro.redirect()\`.`
469
469
  };
470
470
  const UnknownFilesystemError = {
471
471
  name: "UnknownFilesystemError",
@@ -475,30 +475,30 @@ const UnknownFilesystemError = {
475
475
  const CannotExtractFontType = {
476
476
  name: "CannotExtractFontType",
477
477
  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}`,
478
+ message: (url) => `An error occurred while trying to extract the font type from ${url}.`,
479
479
  hint: "Open an issue at https://github.com/withastro/astro/issues."
480
480
  };
481
481
  const CannotDetermineWeightAndStyleFromFontFile = {
482
482
  name: "CannotDetermineWeightAndStyleFromFontFile",
483
483
  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}`,
484
+ message: (family, url) => `An error occurred while determining the \`weight\` and \`style\` from local family "${family}" font file: ${url}.`,
485
485
  hint: "Update your family config and set `weight` and `style` manually instead."
486
486
  };
487
487
  const CannotFetchFontFile = {
488
488
  name: "CannotFetchFontFile",
489
489
  title: "Cannot fetch the given font file.",
490
- message: (url) => `An error occurred while fetching the font file from ${url}`,
490
+ message: (url) => `An error occurred while fetching the font file from ${url}.`,
491
491
  hint: "This is often caused by connectivity issues. If the error persists, open an issue at https://github.com/withastro/astro/issues."
492
492
  };
493
493
  const FontFamilyNotFound = {
494
494
  name: "FontFamilyNotFound",
495
- title: "Font family not found",
495
+ title: "Font family not found.",
496
496
  message: (family) => `No data was found for the \`"${family}"\` family passed to the \`<Font>\` component.`,
497
497
  hint: "This is often caused by a typo. Check that the `<Font />` component is using a `cssVariable` specified in your config."
498
498
  };
499
499
  const FontFileUrlNotFound = {
500
500
  name: "FontFileUrlNotFound",
501
- title: "Font file URL not found",
501
+ title: "Font file URL not found.",
502
502
  message: (url) => `The \`"${url}"\` URL passed to the \`experimental_getFontFileURL()\` function is invalid.`,
503
503
  hint: "Make sure you pass a valid URL, obtained via the `fontData` object."
504
504
  };
@@ -509,8 +509,8 @@ const MissingGetFontFileRequestUrl = {
509
509
  };
510
510
  const UnavailableAstroGlobal = {
511
511
  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.`
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.`
514
514
  };
515
515
  const UnableToLoadLogger = {
516
516
  name: "UnableToLoadLogger",
@@ -519,19 +519,19 @@ const UnableToLoadLogger = {
519
519
  };
520
520
  const LoggerConfigurationNotSerializable = {
521
521
  name: "LoggerConfigurationNotSerializable",
522
- title: "The configuration of the logger is not serializable"
522
+ title: "The configuration of the logger is not serializable."
523
523
  };
524
524
  const UnknownCSSError = {
525
525
  name: "UnknownCSSError",
526
- title: "Unknown CSS Error."
526
+ title: "Unknown CSS error."
527
527
  };
528
528
  const CSSSyntaxError = {
529
529
  name: "CSSSyntaxError",
530
- title: "CSS Syntax Error."
530
+ title: "CSS syntax error."
531
531
  };
532
532
  const UnknownMarkdownError = {
533
533
  name: "UnknownMarkdownError",
534
- title: "Unknown Markdown Error."
534
+ title: "Unknown Markdown error."
535
535
  };
536
536
  const MarkdownFrontmatterParseError = {
537
537
  name: "MarkdownFrontmatterParseError",
@@ -566,22 +566,22 @@ const ConfigLegacyKey = {
566
566
  };
567
567
  const UnknownCLIError = {
568
568
  name: "UnknownCLIError",
569
- title: "Unknown CLI Error."
569
+ title: "Unknown CLI error."
570
570
  };
571
571
  const GenerateContentTypesError = {
572
572
  name: "GenerateContentTypesError",
573
573
  title: "Failed to generate content types.",
574
- message: (errorMessage) => `\`astro sync\` command failed to generate content collection types: ${errorMessage}`,
574
+ message: (errorMessage) => `\`astro sync\` command failed to generate content collection types: ${errorMessage}.`,
575
575
  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
576
  };
577
577
  const UnknownContentCollectionError = {
578
578
  name: "UnknownContentCollectionError",
579
- title: "Unknown Content Collection Error."
579
+ title: "Unknown content collection error."
580
580
  };
581
581
  const RenderUndefinedEntryError = {
582
582
  name: "RenderUndefinedEntryError",
583
583
  title: "Attempted to render an undefined content collection entry.",
584
- hint: "Check if the entry is undefined before passing it to `render()`"
584
+ hint: "Check if the entry is undefined before passing it to `render()`."
585
585
  };
586
586
  const GetEntryDeprecationError = {
587
587
  name: "GetEntryDeprecationError",
@@ -665,7 +665,7 @@ const LiveContentConfigError = {
665
665
  };
666
666
  const ContentLoaderInvalidDataError = {
667
667
  name: "ContentLoaderInvalidDataError",
668
- title: "Content entry is missing an ID",
668
+ title: "Content entry is missing an ID.",
669
669
  message(collection, extra) {
670
670
  return `**${String(collection)}** entry is missing an ID.
671
671
  ${extra}`;
@@ -684,7 +684,7 @@ const InvalidContentEntrySlugError = {
684
684
  };
685
685
  const ContentSchemaContainsSlugError = {
686
686
  name: "ContentSchemaContainsSlugError",
687
- title: "Content Schema should not contain `slug`.",
687
+ title: "Content schema should not contain `slug`.",
688
688
  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
689
  hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
690
690
  };
@@ -727,19 +727,19 @@ Full error: ${parseError}`,
727
727
  };
728
728
  const FileParserNotFound = {
729
729
  name: "FileParserNotFound",
730
- title: "File parser not found",
730
+ title: "File parser not found.",
731
731
  message: (fileName) => `No parser was found for '${fileName}'. Pass a parser function (e.g. \`parser: csv\`) to the \`file\` loader.`
732
732
  };
733
733
  const FileGlobNotSupported = {
734
734
  name: "FileGlobNotSupported",
735
- title: "Glob patterns are not supported in the file loader",
735
+ title: "Glob patterns are not supported in the file loader.",
736
736
  message: "Glob patterns are not supported in the `file` loader. Use the `glob` loader instead.",
737
737
  hint: `See Astro's file loader https://docs.astro.build/en/reference/content-loader-reference/#file-loader for supported usage.`
738
738
  };
739
739
  const ActionsWithoutServerOutputError = {
740
740
  name: "ActionsWithoutServerOutputError",
741
741
  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",
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.",
743
743
  hint: "Add an adapter and enable on-demand rendering: https://docs.astro.build/en/guides/on-demand-rendering/"
744
744
  };
745
745
  const ActionsReturnedInvalidDataError = {
@@ -756,8 +756,8 @@ const ActionNotFoundError = {
756
756
  };
757
757
  const ActionCalledFromServerError = {
758
758
  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.",
759
+ title: "Action called from the server without `Astro.callAction()`.",
760
+ 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
761
  hint: "See the `Astro.callAction()` reference for usage examples: https://docs.astro.build/en/reference/api-reference/#callaction"
762
762
  };
763
763
  const UnknownError = { name: "UnknownError", title: "Unknown Error." };
@@ -44,6 +44,8 @@ export interface AstroFetchState {
44
44
  readonly locals: App.Locals;
45
45
  /** Route params derived from routeData + pathname. */
46
46
  readonly params: Params | undefined;
47
+ /** The `Response` produced by handlers, if any. Set after rendering. */
48
+ response: Response | undefined;
47
49
  /** Default HTTP status for the rendered response. */
48
50
  status: number;
49
51
  /**
@@ -119,6 +121,11 @@ export declare class FetchState implements AstroFetchState {
119
121
  * allocate an empty object per request.
120
122
  */
121
123
  slots: Record<string, any> | undefined;
124
+ /**
125
+ * The `Response` produced by handlers, if any. Set after page
126
+ * rendering or middleware completes.
127
+ */
128
+ response: Response | undefined;
122
129
  /**
123
130
  * Default HTTP status for the rendered response. Callers override
124
131
  * before rendering runs (e.g. `AstroHandler` sets this from
@@ -72,6 +72,11 @@ class FetchState {
72
72
  * allocate an empty object per request.
73
73
  */
74
74
  slots;
75
+ /**
76
+ * The `Response` produced by handlers, if any. Set after page
77
+ * rendering or middleware completes.
78
+ */
79
+ response;
75
80
  /**
76
81
  * Default HTTP status for the rendered response. Callers override
77
82
  * before rendering runs (e.g. `AstroHandler` sets this from
@@ -4,3 +4,22 @@
4
4
  * lets handlers compose easily with other middleware systems later.
5
5
  */
6
6
  export type FetchHandler = (request: Request) => Promise<Response>;
7
+ /**
8
+ * An object with a `fetch` method that handles incoming requests.
9
+ * This is the shape expected by `src/app.ts` and aligns with the
10
+ * convention used by Cloudflare Workers, Bun, and Hono.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import type { Fetchable } from 'astro';
15
+ *
16
+ * export default {
17
+ * async fetch(request) {
18
+ * return new Response('ok');
19
+ * }
20
+ * } satisfies Fetchable;
21
+ * ```
22
+ */
23
+ export interface Fetchable {
24
+ fetch(request: Request): Response | Promise<Response>;
25
+ }
@@ -5,11 +5,14 @@ import {
5
5
  import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../constants.js";
6
6
  const FETCHABLE_MODULE_ID = "virtual:astro:fetchable";
7
7
  const FETCHABLE_RESOLVED_MODULE_ID = "\0" + FETCHABLE_MODULE_ID;
8
- const APP_PATH_SEGMENT_NAME = "app";
8
+ const DEFAULT_FETCH_FILE = "app";
9
9
  function vitePluginFetchable({ settings }) {
10
10
  let resolvedUserAppId;
11
11
  let userAppPresent = false;
12
- const advancedRoutingEnabled = settings.config.experimental.advancedRouting;
12
+ const advancedRoutingConfig = settings.config.experimental.advancedRouting;
13
+ const advancedRoutingEnabled = !!advancedRoutingConfig;
14
+ const fetchFile = (typeof advancedRoutingConfig === "object" ? advancedRoutingConfig.fetchFile : void 0) ?? DEFAULT_FETCH_FILE;
15
+ const fetchFileDisabled = typeof advancedRoutingConfig === "object" && advancedRoutingConfig.fetchFile === null;
13
16
  const normalizedSrcDir = viteNormalizePath(fileURLToPath(settings.config.srcDir));
14
17
  return {
15
18
  name: "@astro/plugin-fetchable",
@@ -21,7 +24,7 @@ function vitePluginFetchable({ settings }) {
21
24
  const normalizedPath = viteNormalizePath(path);
22
25
  if (!normalizedPath.startsWith(normalizedSrcDir)) return;
23
26
  const relativePath = normalizedPath.slice(normalizedSrcDir.length);
24
- if (!relativePath.startsWith(`${APP_PATH_SEGMENT_NAME}.`)) return;
27
+ if (!relativePath.startsWith(`${fetchFile}.`)) return;
25
28
  for (const name of [
26
29
  ASTRO_VITE_ENVIRONMENT_NAMES.ssr,
27
30
  ASTRO_VITE_ENVIRONMENT_NAMES.astro
@@ -40,7 +43,11 @@ function vitePluginFetchable({ settings }) {
40
43
  id: new RegExp(`^${FETCHABLE_MODULE_ID}$`)
41
44
  },
42
45
  async handler() {
43
- const resolved = await this.resolve(`${normalizedSrcDir}${APP_PATH_SEGMENT_NAME}`);
46
+ if (fetchFileDisabled) {
47
+ userAppPresent = false;
48
+ return FETCHABLE_RESOLVED_MODULE_ID;
49
+ }
50
+ const resolved = await this.resolve(`${normalizedSrcDir}${fetchFile}`);
44
51
  userAppPresent = advancedRoutingEnabled && !!resolved;
45
52
  resolvedUserAppId = resolved?.id;
46
53
  return FETCHABLE_RESOLVED_MODULE_ID;
@@ -17,5 +17,5 @@ export declare function redirects(): HonoMiddlewareHandler;
17
17
  export declare function actions(): HonoMiddlewareHandler;
18
18
  export declare function pages(): HonoMiddlewareHandler;
19
19
  export declare function sessions(): HonoMiddlewareHandler;
20
- export declare function cache(next: () => Promise<Response>): HonoMiddlewareHandler;
20
+ export declare function cache(): HonoMiddlewareHandler;
21
21
  export declare function i18n(): HonoMiddlewareHandler;
@@ -73,9 +73,12 @@ function sessions() {
73
73
  }
74
74
  };
75
75
  }
76
- function cache(next) {
77
- return async (context, _honoNext) => {
78
- return fetchCache(getFetchState(context), next);
76
+ function cache() {
77
+ return async (context, honoNext) => {
78
+ return fetchCache(getFetchState(context), async () => {
79
+ await honoNext();
80
+ return context.res;
81
+ });
79
82
  };
80
83
  }
81
84
  function i18n() {
@@ -276,7 +276,7 @@ function printHelp({
276
276
  message.push(
277
277
  linebreak(),
278
278
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"6.3.3"}`
279
+ `v${"6.3.5"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
@@ -38,7 +38,9 @@ class AstroMiddleware {
38
38
  const composed = sequence(...pipeline.internalMiddleware, pipelineMiddleware);
39
39
  response = await callMiddleware(composed, apiContext, next);
40
40
  }
41
- return this.#finalize(state, response);
41
+ response = this.#finalize(state, response);
42
+ state.response = response;
43
+ return response;
42
44
  }
43
45
  #finalize(state, response) {
44
46
  if (response.headers.get(ROUTE_TYPE_HEADER)) {
@@ -3,7 +3,6 @@ import path from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import { collectErrorMetadata } from "../errors/dev/utils.js";
5
5
  import { getViteErrorPayload } from "../errors/dev/vite.js";
6
- import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../constants.js";
7
6
  function createViteLoader(viteServer, ssrEnvironment) {
8
7
  const events = new EventEmitter();
9
8
  let isTsconfigUpdated = false;
@@ -90,7 +89,7 @@ function createViteLoader(viteServer, ssrEnvironment) {
90
89
  return viteServer.environments.client.hot.send(msg);
91
90
  },
92
91
  getSSREnvironment() {
93
- return viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
92
+ return ssrEnvironment;
94
93
  },
95
94
  isHttps() {
96
95
  return !!ssrEnvironment.config.server.https;
@@ -66,6 +66,7 @@ class PagesHandler {
66
66
  if (responseCookies) {
67
67
  state.cookies.merge(responseCookies);
68
68
  }
69
+ state.response = response;
69
70
  return response;
70
71
  }
71
72
  }