cloudcommerce 0.23.0 → 0.23.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 (113) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
  3. package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
  4. package/ecomplus-stores/barra-doce/functions/ssr/src/main/Home.astro +18 -10
  5. package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
  6. package/ecomplus-stores/barra-doce/package.json +2 -3
  7. package/ecomplus-stores/iluminim/functions/many/package.json +3 -3
  8. package/ecomplus-stores/iluminim/functions/ssr/package.json +6 -6
  9. package/ecomplus-stores/iluminim/functions/with-apps/package.json +3 -3
  10. package/ecomplus-stores/iluminim/package.json +2 -3
  11. package/package.json +4 -4
  12. package/packages/api/package.json +1 -1
  13. package/packages/api/types/carts.d.ts +8 -0
  14. package/packages/api/types/orders.d.ts +8 -0
  15. package/packages/apps/affilate-program/package.json +1 -1
  16. package/packages/apps/correios/package.json +1 -1
  17. package/packages/apps/custom-payment/package.json +1 -1
  18. package/packages/apps/custom-shipping/package.json +1 -1
  19. package/packages/apps/datafrete/package.json +1 -1
  20. package/packages/apps/discounts/package.json +1 -1
  21. package/packages/apps/emails/package.json +1 -1
  22. package/packages/apps/fb-conversions/package.json +1 -1
  23. package/packages/apps/flash-courier/package.json +1 -1
  24. package/packages/apps/frenet/package.json +1 -1
  25. package/packages/apps/galaxpay/package.json +1 -1
  26. package/packages/apps/google-analytics/package.json +1 -1
  27. package/packages/apps/jadlog/package.json +1 -1
  28. package/packages/apps/loyalty-points/package.json +1 -1
  29. package/packages/apps/melhor-envio/package.json +1 -1
  30. package/packages/apps/mercadopago/package.json +1 -1
  31. package/packages/apps/pagarme/package.json +1 -1
  32. package/packages/apps/paghiper/package.json +1 -1
  33. package/packages/apps/pix/package.json +1 -1
  34. package/packages/apps/tiny-erp/package.json +1 -1
  35. package/packages/apps/webhooks/package.json +1 -1
  36. package/packages/cli/package.json +1 -1
  37. package/packages/config/package.json +1 -1
  38. package/packages/emails/package.json +1 -1
  39. package/packages/eslint/package.json +3 -3
  40. package/packages/events/package.json +1 -1
  41. package/packages/feeds/package.json +1 -1
  42. package/packages/firebase/package.json +1 -1
  43. package/packages/i18n/lib/en_us/i19minus.txt +1 -0
  44. package/packages/i18n/lib/en_us/i19plus.txt +1 -0
  45. package/packages/i18n/lib/en_us.d.ts +2 -0
  46. package/packages/i18n/lib/en_us.js +2 -0
  47. package/packages/i18n/lib/en_us.js.map +1 -1
  48. package/packages/i18n/lib/pt_br/i19minus.txt +1 -0
  49. package/packages/i18n/lib/pt_br/i19plus.txt +1 -0
  50. package/packages/i18n/lib/pt_br.d.ts +2 -0
  51. package/packages/i18n/lib/pt_br.js +2 -0
  52. package/packages/i18n/lib/pt_br.js.map +1 -1
  53. package/packages/i18n/package.json +1 -1
  54. package/packages/i18n/src/en_us.ts +2 -0
  55. package/packages/i18n/src/pt_br.ts +2 -0
  56. package/packages/modules/package.json +1 -1
  57. package/packages/passport/package.json +1 -1
  58. package/packages/ssr/cloudflare/README.md +3 -0
  59. package/packages/ssr/cloudflare/swr-worker.js +110 -0
  60. package/packages/ssr/lib/firebase/serve-storefront.js +13 -0
  61. package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
  62. package/packages/ssr/package.json +6 -4
  63. package/packages/ssr/src/cloudflare/swr-worker.ts +128 -0
  64. package/packages/ssr/src/cloudflare/tsconfig.json +9 -0
  65. package/packages/ssr/src/firebase/serve-storefront.ts +14 -0
  66. package/packages/ssr/tsconfig.json +2 -1
  67. package/packages/storefront/config/storefront.tailwind.cjs +1 -0
  68. package/packages/storefront/dist/client/_astro/Carousel.63d511ab.js +1 -0
  69. package/packages/storefront/dist/client/_astro/{HeroSlider.794b113c.js → HeroSlider.8d2ea532.js} +1 -1
  70. package/packages/storefront/dist/client/_astro/{PitchBar.a0503ba1.js → PitchBar.c2a2ad79.js} +1 -1
  71. package/packages/storefront/dist/client/_astro/Prices.8572765c.js +1 -0
  72. package/packages/storefront/dist/client/_astro/ProductShelf.4a105932.js +1 -0
  73. package/packages/storefront/dist/client/_astro/ShopHeader.2400b065.js +4 -0
  74. package/packages/storefront/dist/client/_astro/{_...slug_.caa8cb90.css → _...slug_.07c1fa58.css} +1 -1
  75. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.48e557ba.js +1 -0
  76. package/packages/storefront/dist/client/_astro/client.9dbf6b61.js +1 -0
  77. package/packages/storefront/dist/client/_astro/{img.abbe849f.js → img.7def76a1.js} +1 -1
  78. package/packages/storefront/dist/client/_astro/index.c0c35ead.js +1 -0
  79. package/packages/storefront/dist/client/sw.js +1 -1
  80. package/packages/storefront/dist/server/chunks/{_...e1758019.mjs → _...c5a36021.mjs} +3 -3
  81. package/packages/storefront/dist/server/chunks/{account@_@astro.f568e384.mjs → account@_@astro.3e90f29a.mjs} +3 -3
  82. package/packages/storefront/dist/server/chunks/{astro.b875de26.mjs → astro.6adaff02.mjs} +296 -1146
  83. package/packages/storefront/dist/server/chunks/{endpoint@_@js.32b9ab50.mjs → endpoint@_@js.b79eed3b.mjs} +3 -3
  84. package/packages/storefront/dist/server/chunks/{fallback@_@astro.4d902266.mjs → fallback@_@astro.9f73db0f.mjs} +3 -3
  85. package/packages/storefront/dist/server/chunks/{index@_@astro.a80337aa.mjs → index@_@astro.0221a7bd.mjs} +3 -3
  86. package/packages/storefront/dist/server/chunks/{index@_@astro.2072e1c3.mjs → index@_@astro.66b84ac2.mjs} +3 -3
  87. package/packages/storefront/dist/server/chunks/pages/{_...slug_.astro.7c69d6fe.mjs → _...slug_.astro.501582b9.mjs} +779 -119
  88. package/packages/storefront/dist/server/chunks/pages/{account.astro.4b8c2471.mjs → account.astro.53400a42.mjs} +1 -1
  89. package/packages/storefront/dist/server/chunks/pages/{endpoint.js.64061d33.mjs → endpoint.js.4c130895.mjs} +1 -1
  90. package/packages/storefront/dist/server/chunks/pages/{fallback.astro.f225bb85.mjs → fallback.astro.8d1c6076.mjs} +2 -2
  91. package/packages/storefront/dist/server/chunks/pages/{index.astro.a972914a.mjs → index.astro.f1104ab2.mjs} +15 -338
  92. package/packages/storefront/dist/server/entry.mjs +31 -23
  93. package/packages/storefront/dist/server/renderers.mjs +2 -2
  94. package/packages/storefront/package.json +10 -10
  95. package/packages/storefront/src/lib/components/Carousel.vue +0 -3
  96. package/packages/storefront/src/lib/components/CheckoutLink.vue +23 -0
  97. package/packages/storefront/src/lib/components/Drawer.vue +1 -1
  98. package/packages/storefront/src/lib/components/QuantitySelector.vue +107 -0
  99. package/packages/storefront/src/lib/components/QuantitySelectorControl.vue +35 -0
  100. package/packages/storefront/src/lib/composables/use-cart-item.ts +20 -14
  101. package/packages/storefront/src/lib/composables/use-sticky-header.ts +18 -2
  102. package/packages/storefront/src/lib/state/customer-session.ts +2 -2
  103. package/packages/storefront/src/lib/state/modules-info.ts +1 -1
  104. package/packages/storefront/src/lib/state/shopping-cart/parse-product.ts +23 -21
  105. package/packages/storefront/src/lib/state/shopping-cart.ts +13 -4
  106. package/packages/types/package.json +1 -1
  107. package/packages/storefront/dist/client/_astro/Carousel.6824b5e2.js +0 -1
  108. package/packages/storefront/dist/client/_astro/ProductShelf.7fca4465.js +0 -1
  109. package/packages/storefront/dist/client/_astro/ShopHeader.fe08e043.js +0 -4
  110. package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.4cb7dd76.js +0 -1
  111. package/packages/storefront/dist/client/_astro/api.4984c5be.js +0 -1
  112. package/packages/storefront/dist/client/_astro/client.0fb6b44e.js +0 -1
  113. package/packages/storefront/dist/client/_astro/index.c723d38d.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import { compile } from 'path-to-regexp';
2
2
  import { serialize, parse } from 'cookie';
3
- import { joinPaths, slash, prependForwardSlash, removeTrailingForwardSlash } from '@astrojs/internal-helpers/path';
3
+ import { joinPaths, slash, prependForwardSlash, removeTrailingForwardSlash, collapseDuplicateSlashes } from '@astrojs/internal-helpers/path';
4
4
  import { yellow, dim, bold, cyan, red, reset } from 'kleur/colors';
5
5
  import 'node:fs';
6
6
  import 'node:http';
@@ -9,1031 +9,155 @@ import mime from 'mime';
9
9
  import 'string-width';
10
10
  import { escape } from 'html-escaper';
11
11
 
12
- const AstroErrorData = {
13
- /**
14
- * @docs
15
- * @kind heading
16
- * @name Astro Errors
17
- */
18
- /**
19
- * @docs
20
- * @message
21
- * Unknown compiler error.
22
- * @see
23
- * - [withastro/compiler issues list](https://astro.build/issues/compiler)
24
- * @description
25
- * Astro encountered an unknown error while compiling your files. In most cases, this is not your fault, but an issue in our compiler.
26
- *
27
- * If there isn't one already, please [create an issue](https://astro.build/issues/compiler).
28
- */
29
- UnknownCompilerError: {
30
- title: "Unknown compiler error.",
31
- hint: "This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler."
32
- },
33
- // 1xxx and 2xxx codes are reserved for compiler errors and warnings respectively
34
- /**
35
- * @docs
36
- * @see
37
- * - [Enabling SSR in Your Project](https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project)
38
- * - [Astro.redirect](https://docs.astro.build/en/reference/api-reference/#astroredirect)
39
- * @description
40
- * The `Astro.redirect` function is only available when [Server-side rendering](/en/guides/server-side-rendering/) is enabled.
41
- *
42
- * To redirect on a static website, the [meta refresh attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) can be used. Certain hosts also provide config-based redirects (ex: [Netlify redirects](https://docs.netlify.com/routing/redirects/)).
43
- * @deprecated since version 2.6
44
- */
45
- StaticRedirectNotAvailable: {
46
- title: "`Astro.redirect` is not available in static mode.",
47
- message: "Redirects are only available when using `output: 'server'` or `output: 'hybrid'`. Update your Astro config if you need SSR features.",
48
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
49
- },
50
- /**
51
- * @docs
52
- * @see
53
- * - [Official integrations](https://docs.astro.build/en/guides/integrations-guide/#official-integrations)
54
- * - [Astro.clientAddress](https://docs.astro.build/en/reference/api-reference/#astroclientaddress)
55
- * @description
56
- * The adapter you're using unfortunately does not support `Astro.clientAddress`.
57
- */
58
- ClientAddressNotAvailable: {
59
- title: "`Astro.clientAddress` is not available in current adapter.",
60
- message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
61
- },
62
- /**
63
- * @docs
64
- * @see
65
- * - [Enabling SSR in Your Project](https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project)
66
- * - [Astro.clientAddress](https://docs.astro.build/en/reference/api-reference/#astroclientaddress)
67
- * @description
68
- * The `Astro.clientAddress` property is only available when [Server-side rendering](https://docs.astro.build/en/guides/server-side-rendering/) is enabled.
69
- *
70
- * To get the user's IP address in static mode, different APIs such as [Ipify](https://www.ipify.org/) can be used in a [Client-side script](https://docs.astro.build/en/guides/client-side-scripts/) or it may be possible to get the user's IP using a serverless function hosted on your hosting provider.
71
- */
72
- StaticClientAddressNotAvailable: {
73
- title: "`Astro.clientAddress` is not available in static mode.",
74
- message: "`Astro.clientAddress` is only available when using `output: 'server'` or `output: 'hybrid'`. Update your Astro config if you need SSR features.",
75
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
76
- },
77
- /**
78
- * @docs
79
- * @see
80
- * - [getStaticPaths()](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
81
- * @description
82
- * A [dynamic route](https://docs.astro.build/en/core-concepts/routing/#dynamic-routes) was matched, but no corresponding path was found for the requested parameters. This is often caused by a typo in either the generated or the requested path.
83
- */
84
- NoMatchingStaticPathFound: {
85
- title: "No static path found for requested path.",
86
- message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
87
- hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
88
- },
89
- /**
90
- * @docs
91
- * @message Route returned a `RETURNED_VALUE`. Only a Response can be returned from Astro files.
92
- * @see
93
- * - [Response](https://docs.astro.build/en/guides/server-side-rendering/#response)
94
- * @description
95
- * Only instances of [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned inside Astro files.
96
- * ```astro title="pages/login.astro"
97
- * ---
98
- * return new Response(null, {
99
- * status: 404,
100
- * statusText: 'Not found'
101
- * });
102
- *
103
- * // Alternatively, for redirects, Astro.redirect also returns an instance of Response
104
- * return Astro.redirect('/login');
105
- * ---
106
- * ```
107
- *
108
- */
109
- OnlyResponseCanBeReturned: {
110
- title: "Invalid type returned by Astro page.",
111
- message: (route, returnedValue) => `Route \`${route ? route : ""}\` returned a \`${returnedValue}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,
112
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
113
- },
114
- /**
115
- * @docs
116
- * @see
117
- * - [`client:media`](https://docs.astro.build/en/reference/directives-reference/#clientmedia)
118
- * @description
119
- * A [media query](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries) parameter is required when using the `client:media` directive.
120
- *
121
- * ```astro
122
- * <Counter client:media="(max-width: 640px)" />
123
- * ```
124
- */
125
- MissingMediaQueryDirective: {
126
- title: "Missing value for `client:media` directive.",
127
- message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
128
- },
129
- /**
130
- * @docs
131
- * @message Unable to render `COMPONENT_NAME`. There are `RENDERER_COUNT` renderer(s) configured in your `astro.config.mjs` file, but none were able to server-side render `COMPONENT_NAME`.
132
- * @see
133
- * - [Frameworks components](https://docs.astro.build/en/core-concepts/framework-components/)
134
- * - [UI Frameworks](https://docs.astro.build/en/guides/integrations-guide/#official-integrations)
135
- * @description
136
- * None of the installed integrations were able to render the component you imported. Make sure to install the appropriate integration for the type of component you are trying to include in your page.
137
- *
138
- * For JSX / TSX files, [@astrojs/react](https://docs.astro.build/en/guides/integrations-guide/react/), [@astrojs/preact](https://docs.astro.build/en/guides/integrations-guide/preact/) or [@astrojs/solid-js](https://docs.astro.build/en/guides/integrations-guide/solid-js/) can be used. For Vue and Svelte files, the [@astrojs/vue](https://docs.astro.build/en/guides/integrations-guide/vue/) and [@astrojs/svelte](https://docs.astro.build/en/guides/integrations-guide/svelte/) integrations can be used respectively
139
- */
140
- NoMatchingRenderer: {
141
- title: "No matching renderer found.",
142
- message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
12
+ const ClientAddressNotAvailable = {
13
+ name: "ClientAddressNotAvailable",
14
+ title: "`Astro.clientAddress` is not available in current adapter.",
15
+ message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
16
+ };
17
+ const StaticClientAddressNotAvailable = {
18
+ name: "StaticClientAddressNotAvailable",
19
+ title: "`Astro.clientAddress` is not available in static mode.",
20
+ message: "`Astro.clientAddress` is only available when using `output: 'server'` or `output: 'hybrid'`. Update your Astro config if you need SSR features.",
21
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
22
+ };
23
+ const NoMatchingStaticPathFound = {
24
+ name: "NoMatchingStaticPathFound",
25
+ title: "No static path found for requested path.",
26
+ message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
27
+ hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
28
+ };
29
+ const OnlyResponseCanBeReturned = {
30
+ name: "OnlyResponseCanBeReturned",
31
+ title: "Invalid type returned by Astro page.",
32
+ message: (route, returnedValue) => `Route \`${route ? route : ""}\` returned a \`${returnedValue}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,
33
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
34
+ };
35
+ const MissingMediaQueryDirective = {
36
+ name: "MissingMediaQueryDirective",
37
+ title: "Missing value for `client:media` directive.",
38
+ message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
39
+ };
40
+ const NoMatchingRenderer = {
41
+ name: "NoMatchingRenderer",
42
+ title: "No matching renderer found.",
43
+ message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
143
44
 
144
45
  ${validRenderersCount > 0 ? `There ${plural ? "are" : "is"} ${validRenderersCount} renderer${plural ? "s" : ""} configured in your \`astro.config.mjs\` file,
145
46
  but ${plural ? "none were" : "it was not"} able to server-side render \`${componentName}\`.` : `No valid renderer was found ${componentExtension ? `for the \`.${componentExtension}\` file extension.` : `for this file extension.`}`}`,
146
- hint: (probableRenderers) => `Did you mean to enable the ${probableRenderers} integration?
47
+ hint: (probableRenderers) => `Did you mean to enable the ${probableRenderers} integration?
147
48
 
148
49
  See https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`
149
- },
150
- /**
151
- * @docs
152
- * @see
153
- * - [addRenderer option](https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option)
154
- * - [Hydrating framework components](https://docs.astro.build/en/core-concepts/framework-components/#hydrating-interactive-components)
155
- * @description
156
- * Astro tried to hydrate a component on the client, but the renderer used does not provide a client entrypoint to use to hydrate.
157
- *
158
- */
159
- NoClientEntrypoint: {
160
- title: "No client entrypoint specified in renderer.",
161
- message: (componentName, clientDirective, rendererName) => `\`${componentName}\` component has a \`client:${clientDirective}\` directive, but no client entrypoint was provided by \`${rendererName}\`.`,
162
- hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."
163
- },
164
- /**
165
- * @docs
166
- * @see
167
- * - [`client:only`](https://docs.astro.build/en/reference/directives-reference/#clientonly)
168
- * @description
169
- *
170
- * `client:only` components are not run on the server, as such Astro does not know (and cannot guess) which renderer to use and require a hint. Like such:
171
- *
172
- * ```astro
173
- * <SomeReactComponent client:only="react" />
174
- * ```
175
- */
176
- NoClientOnlyHint: {
177
- title: "Missing hint on client:only directive.",
178
- message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
179
- 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`
180
- },
181
- /**
182
- * @docs
183
- * @see
184
- * - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
185
- * - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
186
- * @description
187
- * The `params` property in `getStaticPaths`'s return value (an array of objects) should also be an object.
188
- *
189
- * ```astro title="pages/blog/[id].astro"
190
- * ---
191
- * export async function getStaticPaths() {
192
- * return [
193
- * { params: { slug: "blog" } },
194
- * { params: { slug: "about" } }
195
- * ];
196
- *}
197
- *---
198
- * ```
199
- */
200
- InvalidGetStaticPathParam: {
201
- title: "Invalid value returned by a `getStaticPaths` path.",
202
- message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
203
- hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
204
- },
205
- /**
206
- * @docs
207
- * @see
208
- * - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
209
- * - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
210
- * @description
211
- * `getStaticPaths`'s return value must be an array of objects.
212
- *
213
- * ```ts title="pages/blog/[id].astro"
214
- * export async function getStaticPaths() {
215
- * return [ // <-- Array
216
- * { params: { slug: "blog" } },
217
- * { params: { slug: "about" } }
218
- * ];
219
- *}
220
- * ```
221
- */
222
- InvalidGetStaticPathsReturn: {
223
- title: "Invalid value returned by getStaticPaths.",
224
- message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
225
- hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
226
- },
227
- /**
228
- * @docs
229
- * @see
230
- * - [RSS Guide](https://docs.astro.build/en/guides/rss/)
231
- * @description
232
- * `getStaticPaths` no longer expose an helper for generating a RSS feed. We recommend migrating to the [@astrojs/rss](https://docs.astro.build/en/guides/rss/#setting-up-astrojsrss)integration instead.
233
- */
234
- GetStaticPathsRemovedRSSHelper: {
235
- title: "getStaticPaths RSS helper is not available anymore.",
236
- message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",
237
- hint: "See https://docs.astro.build/en/guides/rss/ for more information."
238
- },
239
- /**
240
- * @docs
241
- * @see
242
- * - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
243
- * - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
244
- * @description
245
- * Every route specified by `getStaticPaths` require a `params` property specifying the path parameters needed to match the route.
246
- *
247
- * For instance, the following code:
248
- * ```astro title="pages/blog/[id].astro"
249
- * ---
250
- * export async function getStaticPaths() {
251
- * return [
252
- * { params: { id: '1' } }
253
- * ];
254
- * }
255
- * ---
256
- * ```
257
- * Will create the following route: `site.com/blog/1`.
258
- */
259
- GetStaticPathsExpectedParams: {
260
- title: "Missing params property on `getStaticPaths` route.",
261
- message: "Missing or empty required `params` property on `getStaticPaths` route.",
262
- hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
263
- },
264
- /**
265
- * @docs
266
- * @see
267
- * - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
268
- * - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
269
- * @description
270
- * Since `params` are encoded into the URL, only certain types are supported as values.
271
- *
272
- * ```astro title="/route/[id].astro"
273
- * ---
274
- * export async function getStaticPaths() {
275
- * return [
276
- * { params: { id: '1' } } // Works
277
- * { params: { id: 2 } } // Works
278
- * { params: { id: false } } // Does not work
279
- * ];
280
- * }
281
- * ---
282
- * ```
283
- *
284
- * In routes using [rest parameters](https://docs.astro.build/en/core-concepts/routing/#rest-parameters), `undefined` can be used to represent a path with no parameters passed in the URL:
285
- *
286
- * ```astro title="/route/[...id].astro"
287
- * ---
288
- * export async function getStaticPaths() {
289
- * return [
290
- * { params: { id: 1 } } // /route/1
291
- * { params: { id: 2 } } // /route/2
292
- * { params: { id: undefined } } // /route/
293
- * ];
294
- * }
295
- * ---
296
- * ```
297
- */
298
- GetStaticPathsInvalidRouteParam: {
299
- title: "Invalid value for `getStaticPaths` route parameter.",
300
- message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
301
- hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
302
- },
303
- /**
304
- * @docs
305
- * @see
306
- * - [Dynamic Routes](https://docs.astro.build/en/core-concepts/routing/#dynamic-routes)
307
- * - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
308
- * - [Server-side Rendering](https://docs.astro.build/en/guides/server-side-rendering/)
309
- * @description
310
- * In [Static Mode](https://docs.astro.build/en/core-concepts/routing/#static-ssg-mode), all routes must be determined at build time. As such, dynamic routes must `export` a `getStaticPaths` function returning the different paths to generate.
311
- */
312
- GetStaticPathsRequired: {
313
- title: "`getStaticPaths()` function required for dynamic routes.",
314
- message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
315
- hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
50
+ };
51
+ const NoClientEntrypoint = {
52
+ name: "NoClientEntrypoint",
53
+ title: "No client entrypoint specified in renderer.",
54
+ message: (componentName, clientDirective, rendererName) => `\`${componentName}\` component has a \`client:${clientDirective}\` directive, but no client entrypoint was provided by \`${rendererName}\`.`,
55
+ hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."
56
+ };
57
+ const NoClientOnlyHint = {
58
+ name: "NoClientOnlyHint",
59
+ title: "Missing hint on client:only directive.",
60
+ message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
61
+ 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`
62
+ };
63
+ const InvalidGetStaticPathParam = {
64
+ name: "InvalidGetStaticPathParam",
65
+ title: "Invalid value returned by a `getStaticPaths` path.",
66
+ message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
67
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
68
+ };
69
+ const InvalidGetStaticPathsReturn = {
70
+ name: "InvalidGetStaticPathsReturn",
71
+ title: "Invalid value returned by getStaticPaths.",
72
+ message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
73
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
74
+ };
75
+ const GetStaticPathsRemovedRSSHelper = {
76
+ name: "GetStaticPathsRemovedRSSHelper",
77
+ title: "getStaticPaths RSS helper is not available anymore.",
78
+ message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",
79
+ hint: "See https://docs.astro.build/en/guides/rss/ for more information."
80
+ };
81
+ const GetStaticPathsExpectedParams = {
82
+ name: "GetStaticPathsExpectedParams",
83
+ title: "Missing params property on `getStaticPaths` route.",
84
+ message: "Missing or empty required `params` property on `getStaticPaths` route.",
85
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
86
+ };
87
+ const GetStaticPathsInvalidRouteParam = {
88
+ name: "GetStaticPathsInvalidRouteParam",
89
+ title: "Invalid value for `getStaticPaths` route parameter.",
90
+ message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
91
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
92
+ };
93
+ const GetStaticPathsRequired = {
94
+ name: "GetStaticPathsRequired",
95
+ title: "`getStaticPaths()` function required for dynamic routes.",
96
+ message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
97
+ hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
316
98
 
317
99
  Alternatively, set \`output: "server"\` in your Astro config file to switch to a non-static server build. This error can also occur if using \`export const prerender = true;\`.
318
100
  See https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.`
319
- },
320
- /**
321
- * @docs
322
- * @see
323
- * - [Named slots](https://docs.astro.build/en/core-concepts/astro-components/#named-slots)
324
- * @description
325
- * Certain words cannot be used for slot names due to being already used internally.
326
- */
327
- ReservedSlotName: {
328
- title: "Invalid slot name.",
329
- message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
330
- },
331
- /**
332
- * @docs
333
- * @see
334
- * - [Server-side Rendering](https://docs.astro.build/en/guides/server-side-rendering/)
335
- * - [Adding an Adapter](https://docs.astro.build/en/guides/server-side-rendering/#adding-an-adapter)
336
- * @description
337
- * To use server-side rendering, an adapter needs to be installed so Astro knows how to generate the proper output for your targeted deployment platform.
338
- */
339
- NoAdapterInstalled: {
340
- title: "Cannot use Server-side Rendering without an adapter.",
341
- message: `Cannot use \`output: 'server'\` or \`output: 'hybrid'\` without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
342
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information."
343
- },
344
- /**
345
- * @docs
346
- * @description
347
- * No import statement was found for one of the components. If there is an import statement, make sure you are using the same identifier in both the imports and the component usage.
348
- */
349
- NoMatchingImport: {
350
- title: "No import found for component.",
351
- message: (componentName) => `Could not render \`${componentName}\`. No matching import has been found for \`${componentName}\`.`,
352
- hint: "Please make sure the component is properly imported."
353
- },
354
- /**
355
- * @docs
356
- * @message
357
- * **Example error messages:**<br/>
358
- * InvalidPrerenderExport: A `prerender` export has been detected, but its value cannot be statically analyzed.
359
- * @description
360
- * The `prerender` feature only supports a subset of valid JavaScript — be sure to use exactly `export const prerender = true` so that our compiler can detect this directive at build time. Variables, `let`, and `var` declarations are not supported.
361
- */
362
- InvalidPrerenderExport: {
363
- title: "Invalid prerender export.",
364
- message: (prefix, suffix, isHydridOuput) => {
365
- const defaultExpectedValue = isHydridOuput ? "false" : "true";
366
- let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
367
- if (prefix !== "const")
368
- msg += `
369
- Expected \`const\` declaration but got \`${prefix}\`.`;
370
- if (suffix !== "true")
371
- msg += `
372
- Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
373
- return msg;
374
- },
375
- hint: "Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`."
376
- },
377
- /**
378
- * @docs
379
- * @message
380
- * **Example error messages:**<br/>
381
- * InvalidComponentArgs: Invalid arguments passed to `<MyAstroComponent>` component.
382
- * @description
383
- * Astro components cannot be rendered manually via a function call, such as `Component()` or `{items.map(Component)}`. Prefer the component syntax `<Component />` or `{items.map(item => <Component {...item} />)}`.
384
- */
385
- InvalidComponentArgs: {
386
- title: "Invalid component arguments.",
387
- message: (name) => `Invalid arguments passed to${name ? ` <${name}>` : ""} component.`,
388
- hint: "Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."
389
- },
390
- /**
391
- * @docs
392
- * @see
393
- * - [Pagination](https://docs.astro.build/en/core-concepts/routing/#pagination)
394
- * @description
395
- * The page number parameter was not found in your filepath.
396
- */
397
- PageNumberParamNotFound: {
398
- title: "Page number param not found.",
399
- message: (paramName) => `[paginate()] page number param \`${paramName}\` not found in your filepath.`,
400
- hint: "Rename your file to `[page].astro` or `[...page].astro`."
401
- },
402
- /**
403
- * @docs
404
- * @see
405
- * - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
406
- * - [Image component](https://docs.astro.build/en/guides/assets/#image--astroassets)
407
- * - [Image component#alt](https://docs.astro.build/en/guides/assets/#alt-required)
408
- * @description
409
- * The `alt` property allows you to provide descriptive alt text to users of screen readers and other assistive technologies. In order to ensure your images are accessible, the `Image` component requires that an `alt` be specified.
410
- *
411
- * If the image is merely decorative (i.e. doesn’t contribute to the understanding of the page), set `alt=""` so that screen readers know to ignore the image.
412
- */
413
- ImageMissingAlt: {
414
- title: "Missing alt property.",
415
- message: "The alt property is required.",
416
- hint: "The `alt` property is important for the purpose of accessibility, without it users using screen readers or other assistive technologies won't be able to understand what your image is supposed to represent. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-alt for more information."
417
- },
418
- /**
419
- * @docs
420
- * @see
421
- * - [Image Service API](https://docs.astro.build/en/reference/image-service-reference/)
422
- * @description
423
- * There was an error while loading the configured image service. This can be caused by various factors, such as your image service not properly exporting a compatible object in its default export, or an incorrect path.
424
- *
425
- * If you believe that your service is properly configured and this error is wrong, please [open an issue](https://astro.build/issues/).
426
- */
427
- InvalidImageService: {
428
- title: "Error while loading image service.",
429
- message: "There was an error loading the configured image service. Please see the stack trace for more information."
430
- },
431
- /**
432
- * @docs
433
- * @message
434
- * Missing width and height attributes for `IMAGE_URL`. When using remote images, both dimensions are always required in order to avoid cumulative layout shift (CLS).
435
- * @see
436
- * - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
437
- * - [Image component#width-and-height](https://docs.astro.build/en/guides/assets/#width-and-height)
438
- * @description
439
- * For remote images, `width` and `height` cannot be inferred from the original file. As such, in order to avoid CLS, those two properties are always required.
440
- *
441
- * 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).
442
- */
443
- MissingImageDimension: {
444
- title: "Missing image dimensions",
445
- message: (missingDimension, imageURL) => `Missing ${missingDimension === "both" ? "width and height attributes" : `${missingDimension} attribute`} for ${imageURL}. When using remote images, both dimensions are always required in order to avoid CLS.`,
446
- 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)."
447
- },
448
- /**
449
- * @docs
450
- * @description
451
- * The built-in image services do not currently support optimizing all image formats.
452
- *
453
- * For unsupported formats such as SVGs and GIFs, you may be able to use an `img` tag directly:
454
- * ```astro
455
- * ---
456
- * import rocket from '../assets/images/rocket.svg';
457
- * ---
458
- *
459
- * <img src={rocket.src} width={rocket.width} height={rocket.height} alt="A rocketship in space." />
460
- * ```
461
- */
462
- UnsupportedImageFormat: {
463
- title: "Unsupported image format",
464
- message: (format, imagePath, supportedFormats) => `Received unsupported format \`${format}\` from \`${imagePath}\`. Currently only ${supportedFormats.join(
465
- ", "
466
- )} are supported by our image services.`,
467
- hint: "Using an `img` tag directly instead of the `Image` component might be what you're looking for."
468
- },
469
- /**
470
- * @docs
471
- * @see
472
- * - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
473
- * - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
474
- * @description
475
- * The endpoint is prerendered with an `undefined` param so the generated path will collide with another route.
476
- *
477
- * If you cannot prevent passing `undefined`, then an additional extension can be added to the endpoint file name to generate the file with a different name. For example, renaming `pages/api/[slug].ts` to `pages/api/[slug].json.ts`.
478
- */
479
- PrerenderDynamicEndpointPathCollide: {
480
- title: "Prerendered dynamic endpoint has path collision.",
481
- message: (pathname) => `Could not render \`${pathname}\` with an \`undefined\` param as the generated path will collide during prerendering. Prevent passing \`undefined\` as \`params\` for the endpoint's \`getStaticPaths()\` function, or add an additional extension to the endpoint's filename.`,
482
- hint: (filename) => `Rename \`${filename}\` to \`${filename.replace(/\.(js|ts)/, (m) => `.json` + m)}\``
483
- },
484
- /**
485
- * @docs
486
- * @see
487
- * - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
488
- * @description
489
- * An image's `src` property is not valid. The Image component requires the `src` attribute to be either an image that has been ESM imported or a string. This is also true for the first parameter of `getImage()`.
490
- *
491
- * ```astro
492
- * ---
493
- * import { Image } from "astro:assets";
494
- * import myImage from "../assets/my_image.png";
495
- * ---
496
- *
497
- * <Image src={myImage} alt="..." />
498
- * <Image src="https://example.com/logo.png" width={300} height={300} alt="..." />
499
- * ```
500
- *
501
- * In most cases, this error happens when the value passed to `src` is undefined.
502
- */
503
- ExpectedImage: {
504
- title: "Expected src to be an image.",
505
- message: (options) => `Expected \`src\` property to be either an ESM imported image or a string with the path of a remote image. Received \`${options}\`.`,
506
- hint: "This error can often happen because of a wrong path. Make sure the path to your image is correct."
507
- },
508
- /**
509
- * @docs
510
- * @see
511
- * - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
512
- * @description
513
- * `getImage()`'s first parameter should be an object with the different properties to apply to your image.
514
- *
515
- * ```ts
516
- * import { getImage } from "astro:assets";
517
- * import myImage from "../assets/my_image.png";
518
- *
519
- * const optimizedImage = await getImage({src: myImage, width: 300, height: 300});
520
- * ```
521
- *
522
- * In most cases, this error happens because parameters were passed directly instead of inside an object.
523
- */
524
- ExpectedImageOptions: {
525
- title: "Expected image options.",
526
- message: (options) => `Expected getImage() parameter to be an object. Received \`${options}\`.`
527
- },
528
- /**
529
- * @docs
530
- * @message
531
- * Could not find requested image `IMAGE_PATH` at `FULL_IMAGE_PATH`.
532
- * @see
533
- * - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
534
- * @description
535
- * Astro could not find an image you included in your Markdown content. Usually, this is simply caused by a typo in the path.
536
- *
537
- * Images in Markdown are relative to the current file. To refer to an image that is located in the same folder as the `.md` file, the path should start with `./`
538
- */
539
- MarkdownImageNotFound: {
540
- title: "Image not found.",
541
- message: (imagePath, fullImagePath) => `Could not find requested image \`${imagePath}\`${fullImagePath ? ` at \`${fullImagePath}\`.` : "."}`,
542
- hint: "This is often caused by a typo in the image path. Please make sure the file exists, and is spelled correctly."
543
- },
544
- /**
545
- * @docs
546
- * @description
547
- * Making changes to the response, such as setting headers, cookies, and the status code cannot be done outside of page components.
548
- */
549
- ResponseSentError: {
550
- title: "Unable to set response.",
551
- message: "The response has already been sent to the browser and cannot be altered."
552
- },
553
- /**
554
- * @docs
555
- * @description
556
- * Thrown when the middleware does not return any data or call the `next` function.
557
- *
558
- * For example:
559
- * ```ts
560
- * import {defineMiddleware} from "astro/middleware";
561
- * export const onRequest = defineMiddleware((context, _) => {
562
- * // doesn't return anything or call `next`
563
- * context.locals.someData = false;
564
- * });
565
- * ```
566
- */
567
- MiddlewareNoDataOrNextCalled: {
568
- title: "The middleware didn't return a response or call `next`.",
569
- message: "The middleware needs to either return a `Response` object or call the `next` function."
570
- },
571
- /**
572
- * @docs
573
- * @description
574
- * Thrown in development mode when middleware returns something that is not a `Response` object.
575
- *
576
- * For example:
577
- * ```ts
578
- * import {defineMiddleware} from "astro/middleware";
579
- * export const onRequest = defineMiddleware(() => {
580
- * return "string"
581
- * });
582
- * ```
583
- */
584
- MiddlewareNotAResponse: {
585
- title: "The middleware returned something that is not a `Response` object.",
586
- message: "Any data returned from middleware must be a valid `Response` object."
587
- },
588
- /**
589
- * @docs
590
- * @description
591
- *
592
- * Thrown in development mode when `locals` is overwritten with something that is not an object
593
- *
594
- * For example:
595
- * ```ts
596
- * import {defineMiddleware} from "astro/middleware";
597
- * export const onRequest = defineMiddleware((context, next) => {
598
- * context.locals = 1541;
599
- * return next();
600
- * });
601
- * ```
602
- */
603
- LocalsNotAnObject: {
604
- title: "Value assigned to `locals` is not accepted.",
605
- message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",
606
- hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."
607
- },
608
- /**
609
- * @docs
610
- * @see
611
- * - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
612
- * @description
613
- * When using the default image services, `Image`'s and `getImage`'s `src` parameter must be either an imported image or an URL, it cannot be a filepath.
614
- *
615
- * ```astro
616
- * ---
617
- * import { Image } from "astro:assets";
618
- * import myImage from "../my_image.png";
619
- * ---
620
- *
621
- * <!-- GOOD: `src` is the full imported image. -->
622
- * <Image src={myImage} alt="Cool image" />
623
- *
624
- * <!-- BAD: `src` is an image's `src` path instead of the full image. -->
625
- * <Image src={myImage.src} alt="Cool image" />
626
- * ```
627
- */
628
- LocalImageUsedWrongly: {
629
- title: "ESM imported images must be passed as-is.",
630
- message: (imageFilePath) => `\`Image\`'s and \`getImage\`'s \`src\` parameter must be an imported image or an URL, it cannot be a filepath. Received \`${imageFilePath}\`.`
631
- },
632
- /**
633
- * @docs
634
- * @see
635
- * - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob)
636
- * @description
637
- * `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vitejs.dev/guide/features.html#glob-import) instead to acheive the same result.
638
- */
639
- AstroGlobUsedOutside: {
640
- title: "Astro.glob() used outside of an Astro file.",
641
- message: (globStr) => `\`Astro.glob(${globStr})\` can only be used in \`.astro\` files. \`import.meta.glob(${globStr})\` can be used instead to achieve a similar result.`,
642
- hint: "See Vite's documentation on `import.meta.glob` for more information: https://vitejs.dev/guide/features.html#glob-import"
643
- },
644
- /**
645
- * @docs
646
- * @see
647
- * - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob)
648
- * @description
649
- * `Astro.glob()` did not return any matching files. There might be a typo in the glob pattern.
650
- */
651
- AstroGlobNoMatch: {
652
- title: "Astro.glob() did not match any files.",
653
- message: (globStr) => `\`Astro.glob(${globStr})\` did not return any matching files. Check the pattern for typos.`
654
- },
655
- /**
656
- * @docs
657
- * @see
658
- * - [Astro.redirect](https://docs.astro.build/en/reference/api-reference/#astroredirect)
659
- * @description
660
- * A redirect must be given a location with the `Location` header.
661
- */
662
- RedirectWithNoLocation: {
663
- title: "A redirect must be given a location with the `Location` header."
664
- },
665
- /**
666
- * @docs
667
- * @see
668
- * - [Dynamic routes](https://docs.astro.build/en/core-concepts/routing/#dynamic-routes)
669
- * @description
670
- * A dynamic route param is invalid. This is often caused by an `undefined` parameter or a missing [rest parameter](https://docs.astro.build/en/core-concepts/routing/#rest-parameters).
671
- */
672
- InvalidDynamicRoute: {
673
- title: "Invalid dynamic route.",
674
- message: (route, invalidParam, received) => `The ${invalidParam} param for route ${route} is invalid. Received **${received}**.`
675
- },
676
- // No headings here, that way Vite errors are merged with Astro ones in the docs, which makes more sense to users.
677
- // Vite Errors - 4xxx
678
- /**
679
- * @docs
680
- * @see
681
- * - [Vite troubleshooting guide](https://vitejs.dev/guide/troubleshooting.html)
682
- * @description
683
- * Vite encountered an unknown error while rendering your project. We unfortunately do not know what happened (or we would tell you!)
684
- *
685
- * If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/)
686
- */
687
- UnknownViteError: {
688
- title: "Unknown Vite Error."
689
- },
690
- /**
691
- * @docs
692
- * @see
693
- * - [Type Imports](https://docs.astro.build/en/guides/typescript/#type-imports)
694
- * @description
695
- * Astro could not import the requested file. Oftentimes, this is caused by the import path being wrong (either because the file does not exist, or there is a typo in the path)
696
- *
697
- * This message can also appear when a type is imported without specifying that it is a [type import](https://docs.astro.build/en/guides/typescript/#type-imports).
698
- */
699
- FailedToLoadModuleSSR: {
700
- title: "Could not import file.",
701
- message: (importName) => `Could not import \`${importName}\`.`,
702
- hint: "This is often caused by a typo in the import path. Please make sure the file exists."
703
- },
704
- /**
705
- * @docs
706
- * @see
707
- * - [Glob Patterns](https://docs.astro.build/en/guides/imports/#glob-patterns)
708
- * @description
709
- * Astro encountered an invalid glob pattern. This is often caused by the glob pattern not being a valid file path.
710
- */
711
- InvalidGlob: {
712
- title: "Invalid glob pattern.",
713
- message: (globPattern) => `Invalid glob pattern: \`${globPattern}\`. Glob patterns must start with './', '../' or '/'.`,
714
- hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."
715
- },
716
- /**
717
- * @docs
718
- * @description
719
- * Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error.
720
- */
721
- FailedToFindPageMapSSR: {
722
- title: "Astro couldn't find the correct page to render",
723
- 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."
724
- },
725
- /**
726
- * @docs
727
- * @kind heading
728
- * @name CSS Errors
729
- */
730
- // CSS Errors - 5xxx
731
- /**
732
- * @docs
733
- * @see
734
- * - [Styles and CSS](https://docs.astro.build/en/guides/styling/)
735
- * @description
736
- * Astro encountered an unknown error while parsing your CSS. Oftentimes, this is caused by a syntax error and the error message should contain more information.
737
- */
738
- UnknownCSSError: {
739
- title: "Unknown CSS Error."
740
- },
741
- /**
742
- * @docs
743
- * @message
744
- * **Example error messages:**<br/>
745
- * CSSSyntaxError: Missed semicolon<br/>
746
- * CSSSyntaxError: Unclosed string<br/>
747
- * @description
748
- * Astro encountered an error while parsing your CSS, due to a syntax error. This is often caused by a missing semicolon.
749
- */
750
- CSSSyntaxError: {
751
- title: "CSS Syntax Error."
752
- },
753
- /**
754
- * @docs
755
- * @kind heading
756
- * @name Markdown Errors
757
- */
758
- // Markdown Errors - 6xxx
759
- /**
760
- * @docs
761
- * @description
762
- * Astro encountered an unknown error while parsing your Markdown. Oftentimes, this is caused by a syntax error and the error message should contain more information.
763
- */
764
- UnknownMarkdownError: {
765
- title: "Unknown Markdown Error."
766
- },
767
- /**
768
- * @docs
769
- * @message
770
- * **Example error messages:**<br/>
771
- * can not read an implicit mapping pair; a colon is missed<br/>
772
- * unexpected end of the stream within a double quoted scalar<br/>
773
- * can not read a block mapping entry; a multiline key may not be an implicit key
774
- * @description
775
- * Astro encountered an error while parsing the frontmatter of your Markdown file.
776
- * This is often caused by a mistake in the syntax, such as a missing colon or a missing end quote.
777
- */
778
- MarkdownFrontmatterParseError: {
779
- title: "Failed to parse Markdown frontmatter."
780
- },
781
- /**
782
- * @docs
783
- * @see
784
- * - [Modifying frontmatter programmatically](https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically)
785
- * @description
786
- * A remark or rehype plugin attempted to inject invalid frontmatter. This occurs when "astro.frontmatter" is set to `null`, `undefined`, or an invalid JSON object.
787
- */
788
- InvalidFrontmatterInjectionError: {
789
- title: "Invalid frontmatter injection.",
790
- message: 'A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',
791
- hint: "See the frontmatter injection docs https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically for more information."
792
- },
793
- /**
794
- * @docs
795
- * @see
796
- * - [MDX installation and usage](https://docs.astro.build/en/guides/integrations-guide/mdx/)
797
- * @description
798
- * Unable to find the official `@astrojs/mdx` integration. This error is raised when using MDX files without an MDX integration installed.
799
- */
800
- MdxIntegrationMissingError: {
801
- title: "MDX integration missing.",
802
- message: (file) => `Unable to render ${file}. Ensure that the \`@astrojs/mdx\` integration is installed.`,
803
- hint: "See the MDX integration docs for installation and usage instructions: https://docs.astro.build/en/guides/integrations-guide/mdx/"
804
- },
805
- // Config Errors - 7xxx
806
- /**
807
- * @docs
808
- * @see
809
- * - [Configuration Reference](https://docs.astro.build/en/reference/configuration-reference/)
810
- * @description
811
- * Astro encountered an unknown error loading your Astro configuration file.
812
- * This is often caused by a syntax error in your config and the message should offer more information.
813
- *
814
- * If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/)
815
- */
816
- UnknownConfigError: {
817
- title: "Unknown configuration error."
818
- },
819
- /**
820
- * @docs
821
- * @see
822
- * - [--config](https://docs.astro.build/en/reference/cli-reference/#--config-path)
823
- * @description
824
- * The specified configuration file using `--config` could not be found. Make sure that it exists or that the path is correct
825
- */
826
- ConfigNotFound: {
827
- title: "Specified configuration file not found.",
828
- message: (configFile) => `Unable to resolve \`--config "${configFile}"\`. Does the file exist?`
829
- },
830
- /**
831
- * @docs
832
- * @see
833
- * - [Configuration reference](https://docs.astro.build/en/reference/configuration-reference/)
834
- * @description
835
- * Astro detected a legacy configuration option in your configuration file.
836
- */
837
- ConfigLegacyKey: {
838
- title: "Legacy configuration detected.",
839
- message: (legacyConfigKey) => `Legacy configuration detected: \`${legacyConfigKey}\`.`,
840
- hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information."
841
- },
842
- /**
843
- * @docs
844
- * @kind heading
845
- * @name CLI Errors
846
- */
847
- // CLI Errors - 8xxx
848
- /**
849
- * @docs
850
- * @description
851
- * Astro encountered an unknown error while starting one of its CLI commands. The error message should contain more information.
852
- *
853
- * If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/)
854
- */
855
- UnknownCLIError: {
856
- title: "Unknown CLI Error."
857
- },
858
- /**
859
- * @docs
860
- * @description
861
- * `astro sync` command failed to generate content collection types.
862
- * @see
863
- * - [Content collections documentation](https://docs.astro.build/en/guides/content-collections/)
864
- */
865
- GenerateContentTypesError: {
866
- title: "Failed to generate content types.",
867
- message: (errorMessage) => `\`astro sync\` command failed to generate content collection types: ${errorMessage}`,
868
- hint: "Check your `src/content/config.*` file for typos."
869
- },
870
- /**
871
- * @docs
872
- * @kind heading
873
- * @name Content Collection Errors
874
- */
875
- // Content Collection Errors - 9xxx
876
- /**
877
- * @docs
878
- * @description
879
- * Astro encountered an unknown error loading your content collections.
880
- * This can be caused by certain errors inside your `src/content/config.ts` file or some internal errors.
881
- *
882
- * If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/)
883
- */
884
- UnknownContentCollectionError: {
885
- title: "Unknown Content Collection Error."
886
- },
887
- /**
888
- * @docs
889
- * @message
890
- * **Example error message:**<br/>
891
- * **blog** → **post.md** frontmatter does not match collection schema.<br/>
892
- * "title" is required.<br/>
893
- * "date" must be a valid date.
894
- * @description
895
- * A Markdown or MDX entry in `src/content/` does not match its collection schema.
896
- * Make sure that all required fields are present, and that all fields are of the correct type.
897
- * You can check against the collection schema in your `src/content/config.*` file.
898
- * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information.
899
- */
900
- InvalidContentEntryFrontmatterError: {
901
- title: "Content entry frontmatter does not match schema.",
902
- message: (collection, entryId, error) => {
903
- return [
904
- `**${String(collection)} \u2192 ${String(
905
- entryId
906
- )}** frontmatter does not match collection schema.`,
907
- ...error.errors.map((zodError) => zodError.message)
908
- ].join("\n");
909
- },
910
- hint: "See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas."
911
- },
912
- /**
913
- * @docs
914
- * @message `COLLECTION_NAME` → `ENTRY_ID` has an invalid slug. `slug` must be a string.
915
- * @see
916
- * - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
917
- * @description
918
- * An entry in `src/content/` has an invalid `slug`. This field is reserved for generating entry slugs, and must be a string when present.
919
- */
920
- InvalidContentEntrySlugError: {
921
- title: "Invalid content entry slug.",
922
- message: (collection, entryId) => {
923
- return `${String(collection)} \u2192 ${String(
924
- entryId
925
- )} has an invalid slug. \`slug\` must be a string.`;
926
- },
927
- hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
928
- },
929
- /**
930
- * @docs
931
- * @see
932
- * - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/#defining-custom-slugs)
933
- * @description
934
- * A content collection schema should not contain the `slug` field. This is reserved by Astro for generating entry slugs. Remove `slug` from your schema. You can still use custom slugs in your frontmatter.
935
- */
936
- ContentSchemaContainsSlugError: {
937
- title: "Content Schema should not contain `slug`.",
938
- message: (collectionName) => `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collectionName} collection schema.`,
939
- hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
940
- },
941
- /**
942
- * @docs
943
- * @message A collection queried via `getCollection()` does not exist.
944
- * @description
945
- * When querying a collection, ensure a collection directory with the requested name exists under `src/content/`.
946
- */
947
- CollectionDoesNotExistError: {
948
- title: "Collection does not exist",
949
- message: (collectionName) => `The collection **${collectionName}** does not exist. Ensure a collection directory with this name exists.`,
950
- hint: "See https://docs.astro.build/en/guides/content-collections/ for more on creating collections."
951
- },
952
- /**
953
- * @docs
954
- * @message `COLLECTION_NAME` contains a mix of content and data entries. All entries must be of the same type.
955
- * @see
956
- * - [Defining content collections](https://docs.astro.build/en/guides/content-collections/#defining-collections)
957
- * @description
958
- * A content collection cannot contain a mix of content and data entries. You must store entries in separate collections by type.
959
- */
960
- MixedContentDataCollectionError: {
961
- title: "Content and data cannot be in same collection.",
962
- message: (collection) => {
963
- return `**${collection}** contains a mix of content and data entries. All entries must be of the same type.`;
964
- },
965
- hint: "Store data entries in a new collection separate from your content collection."
966
- },
967
- /**
968
- * @docs
969
- * @message `COLLECTION_NAME` contains entries of type `ACTUAL_TYPE`, but is configured as a `EXPECTED_TYPE` collection.
970
- * @see
971
- * - [Defining content collections](https://docs.astro.build/en/guides/content-collections/#defining-collections)
972
- * @description
973
- * Content collections must contain entries of the type configured. Collections are `type: 'content'` by default. Try adding `type: 'data'` to your collection config for data collections.
974
- */
975
- ContentCollectionTypeMismatchError: {
976
- title: "Collection contains entries of a different type.",
977
- message: (collection, expectedType, actualType) => {
978
- return `${collection} contains ${expectedType} entries, but is configured as a ${actualType} collection.`;
979
- }
980
- },
981
- /**
982
- * @docs
983
- * @message `COLLECTION_ENTRY_NAME` failed to parse.
984
- * @description
985
- * Collection entries of `type: 'data'` must return an object with valid JSON (for `.json` entries) or YAML (for `.yaml` entries).
986
- */
987
- DataCollectionEntryParseError: {
988
- title: "Data collection entry failed to parse.",
989
- message: (entryId, errorMessage) => {
990
- return `**${entryId}** failed to parse: ${errorMessage}`;
991
- },
992
- hint: "Ensure your data entry is an object with valid JSON (for `.json` entries) or YAML (for `.yaml` entries)."
993
- },
994
- /**
995
- * @docs
996
- * @message `COLLECTION_NAME` contains multiple entries with the same slug: `SLUG`. Slugs must be unique.
997
- * @description
998
- * Content collection entries must have unique slugs. Duplicates are often caused by the `slug` frontmatter property.
999
- */
1000
- DuplicateContentEntrySlugError: {
1001
- title: "Duplicate content entry slug.",
1002
- message: (collection, slug) => {
1003
- return `**${collection}** contains multiple entries with the same slug: \`${slug}\`. Slugs must be unique.`;
1004
- }
1005
- },
1006
- /**
1007
- * @docs
1008
- * @see
1009
- * - [devalue library](https://github.com/rich-harris/devalue)
1010
- * @description
1011
- * `transform()` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
1012
- */
1013
- UnsupportedConfigTransformError: {
1014
- title: "Unsupported transform in content config.",
1015
- message: (parseError) => `\`transform()\` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
1016
- Full error: ${parseError}`,
1017
- hint: "See the devalue library for all supported types: https://github.com/rich-harris/devalue"
1018
- },
1019
- // Generic catch-all - Only use this in extreme cases, like if there was a cosmic ray bit flip
1020
- UnknownError: {
1021
- title: "Unknown Error."
1022
- }
101
+ };
102
+ const ReservedSlotName = {
103
+ name: "ReservedSlotName",
104
+ title: "Invalid slot name.",
105
+ message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
106
+ };
107
+ const InvalidComponentArgs = {
108
+ name: "InvalidComponentArgs",
109
+ title: "Invalid component arguments.",
110
+ message: (name) => `Invalid arguments passed to${name ? ` <${name}>` : ""} component.`,
111
+ hint: "Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."
112
+ };
113
+ const PageNumberParamNotFound = {
114
+ name: "PageNumberParamNotFound",
115
+ title: "Page number param not found.",
116
+ message: (paramName) => `[paginate()] page number param \`${paramName}\` not found in your filepath.`,
117
+ hint: "Rename your file to `[page].astro` or `[...page].astro`."
118
+ };
119
+ const PrerenderDynamicEndpointPathCollide = {
120
+ name: "PrerenderDynamicEndpointPathCollide",
121
+ title: "Prerendered dynamic endpoint has path collision.",
122
+ message: (pathname) => `Could not render \`${pathname}\` with an \`undefined\` param as the generated path will collide during prerendering. Prevent passing \`undefined\` as \`params\` for the endpoint's \`getStaticPaths()\` function, or add an additional extension to the endpoint's filename.`,
123
+ hint: (filename) => `Rename \`${filename}\` to \`${filename.replace(/\.(js|ts)/, (m) => `.json` + m)}\``
124
+ };
125
+ const ResponseSentError = {
126
+ name: "ResponseSentError",
127
+ title: "Unable to set response.",
128
+ message: "The response has already been sent to the browser and cannot be altered."
129
+ };
130
+ const MiddlewareNoDataOrNextCalled = {
131
+ name: "MiddlewareNoDataOrNextCalled",
132
+ title: "The middleware didn't return a response or call `next`.",
133
+ message: "The middleware needs to either return a `Response` object or call the `next` function."
134
+ };
135
+ const MiddlewareNotAResponse = {
136
+ name: "MiddlewareNotAResponse",
137
+ title: "The middleware returned something that is not a `Response` object.",
138
+ message: "Any data returned from middleware must be a valid `Response` object."
139
+ };
140
+ const LocalsNotAnObject = {
141
+ name: "LocalsNotAnObject",
142
+ title: "Value assigned to `locals` is not accepted.",
143
+ message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",
144
+ hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."
145
+ };
146
+ const AstroGlobUsedOutside = {
147
+ name: "AstroGlobUsedOutside",
148
+ title: "Astro.glob() used outside of an Astro file.",
149
+ message: (globStr) => `\`Astro.glob(${globStr})\` can only be used in \`.astro\` files. \`import.meta.glob(${globStr})\` can be used instead to achieve a similar result.`,
150
+ hint: "See Vite's documentation on `import.meta.glob` for more information: https://vitejs.dev/guide/features.html#glob-import"
151
+ };
152
+ const AstroGlobNoMatch = {
153
+ name: "AstroGlobNoMatch",
154
+ title: "Astro.glob() did not match any files.",
155
+ message: (globStr) => `\`Astro.glob(${globStr})\` did not return any matching files. Check the pattern for typos.`
1023
156
  };
1024
157
 
1025
158
  function normalizeLF(code) {
1026
159
  return code.replace(/\r\n|\r(?!\n)|\n/g, "\n");
1027
160
  }
1028
- function getErrorDataByTitle(title) {
1029
- const entry = Object.entries(AstroErrorData).find((data) => data[1].title === title);
1030
- if (entry) {
1031
- return {
1032
- name: entry[0],
1033
- data: entry[1]
1034
- };
1035
- }
1036
- }
1037
161
 
1038
162
  function codeFrame(src, loc) {
1039
163
  if (!loc || loc.line === void 0 || loc.column === void 0) {
@@ -1068,19 +192,11 @@ function codeFrame(src, loc) {
1068
192
 
1069
193
  class AstroError extends Error {
1070
194
  constructor(props, ...params) {
1071
- var _a;
1072
195
  super(...params);
1073
196
  this.type = "AstroError";
1074
197
  const { name, title, message, stack, location, hint, frame } = props;
1075
198
  this.title = title;
1076
- if (name && name !== "Error") {
1077
- this.name = name;
1078
- } else if (this.title) {
1079
- const errorData = (_a = getErrorDataByTitle(this.title)) == null ? void 0 : _a.name;
1080
- if (errorData) {
1081
- this.name = errorData;
1082
- }
1083
- }
199
+ this.name = name;
1084
200
  if (message)
1085
201
  this.message = message;
1086
202
  this.stack = stack ? stack : this.stack;
@@ -1121,8 +237,8 @@ function baseCreateComponent(cb, moduleId, propagation) {
1121
237
  const fn = (...args) => {
1122
238
  if (!validateArgs(args)) {
1123
239
  throw new AstroError({
1124
- ...AstroErrorData.InvalidComponentArgs,
1125
- message: AstroErrorData.InvalidComponentArgs.message(name)
240
+ ...InvalidComponentArgs,
241
+ message: InvalidComponentArgs.message(name)
1126
242
  });
1127
243
  }
1128
244
  return cb(...args);
@@ -1145,21 +261,21 @@ function createComponent(arg1, moduleId, propagation) {
1145
261
  }
1146
262
  }
1147
263
 
1148
- const ASTRO_VERSION = "2.9.6";
264
+ const ASTRO_VERSION = "2.10.2";
1149
265
 
1150
266
  function createAstroGlobFn() {
1151
267
  const globHandler = (importMetaGlobResult) => {
1152
268
  if (typeof importMetaGlobResult === "string") {
1153
269
  throw new AstroError({
1154
- ...AstroErrorData.AstroGlobUsedOutside,
1155
- message: AstroErrorData.AstroGlobUsedOutside.message(JSON.stringify(importMetaGlobResult))
270
+ ...AstroGlobUsedOutside,
271
+ message: AstroGlobUsedOutside.message(JSON.stringify(importMetaGlobResult))
1156
272
  });
1157
273
  }
1158
274
  let allEntries = [...Object.values(importMetaGlobResult)];
1159
275
  if (allEntries.length === 0) {
1160
276
  throw new AstroError({
1161
- ...AstroErrorData.AstroGlobNoMatch,
1162
- message: AstroErrorData.AstroGlobNoMatch.message(JSON.stringify(importMetaGlobResult))
277
+ ...AstroGlobNoMatch,
278
+ message: AstroGlobNoMatch.message(JSON.stringify(importMetaGlobResult))
1163
279
  });
1164
280
  }
1165
281
  return Promise.all(allEntries.map((fn) => fn()));
@@ -1438,6 +554,10 @@ function serializeProps(props, metadata) {
1438
554
  return serialized;
1439
555
  }
1440
556
 
557
+ const transitionDirectivesToCopyOnIsland = Object.freeze([
558
+ "data-astro-transition-scope",
559
+ "data-astro-transition-persist"
560
+ ]);
1441
561
  function extractDirectives(inputProps, clientDirectives) {
1442
562
  let extracted = {
1443
563
  isPage: false,
@@ -1484,7 +604,7 @@ function extractDirectives(inputProps, clientDirectives) {
1484
604
  );
1485
605
  }
1486
606
  if (extracted.hydration.directive === "media" && typeof extracted.hydration.value !== "string") {
1487
- throw new AstroError(AstroErrorData.MissingMediaQueryDirective);
607
+ throw new AstroError(MissingMediaQueryDirective);
1488
608
  }
1489
609
  break;
1490
610
  }
@@ -1540,6 +660,11 @@ async function generateHydrateScript(scriptOptions, metadata) {
1540
660
  value: metadata.hydrateArgs || ""
1541
661
  })
1542
662
  );
663
+ transitionDirectivesToCopyOnIsland.forEach((name) => {
664
+ if (props[name]) {
665
+ island.props[name] = props[name];
666
+ }
667
+ });
1543
668
  return island;
1544
669
  }
1545
670
 
@@ -1619,7 +744,7 @@ function isHeadAndContent(obj) {
1619
744
  return typeof obj === "object" && !!obj[headAndContentSym];
1620
745
  }
1621
746
 
1622
- var astro_island_prebuilt_default = `(()=>{var d;{let h={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,e)=>{if(t===""||!Array.isArray(e))return e;let[r,n]=e;return r in h?h[r](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var o;if(!this.hydrator||!this.isConnected)return;let e=(o=this.parentElement)==null?void 0:o.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let r=this.querySelectorAll("astro-slot"),n={},c=this.querySelectorAll("template[data-astro-template]");for(let s of c){let i=s.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[s.getAttribute("data-astro-template")||"default"]=s.innerHTML,s.remove())}for(let s of r){let i=s.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[s.getAttribute("name")||"default"]=s.innerHTML)}let l=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),a):{};await this.hydrator(this)(this.Component,l,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((e,r)=>{r.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}start(){let e=JSON.parse(this.getAttribute("opts")),r=this.getAttribute("client");if(Astro[r]===void 0){window.addEventListener(\`astro:\${r}\`,()=>this.start(),{once:!0});return}Astro[r](async()=>{let n=this.getAttribute("renderer-url"),[c,{default:l}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),o=this.getAttribute("component-export")||"default";if(!o.includes("."))this.Component=c[o];else{this.Component=c;for(let s of o.split("."))this.Component=this.Component[s]}return this.hydrator=l,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
747
+ var astro_island_prebuilt_default = `(()=>{var d;{let p={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,r)=>{if(t===""||!Array.isArray(r))return r;let[s,i]=r;return s in p?p[s](i):void 0};customElements.get("astro-island")||customElements.define("astro-island",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var o;if(!this.hydrator||!this.isConnected)return;let r=(o=this.parentElement)==null?void 0:o.closest("astro-island[ssr]");if(r){r.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let s=this.querySelectorAll("astro-slot"),i={},c=this.querySelectorAll("template[data-astro-template]");for(let e of c){let n=e.closest(this.tagName);n!=null&&n.isSameNode(this)&&(i[e.getAttribute("data-astro-template")||"default"]=e.innerHTML,e.remove())}for(let e of s){let n=e.closest(this.tagName);n!=null&&n.isSameNode(this)&&(i[e.getAttribute("name")||"default"]=e.innerHTML)}let l;try{l=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),a):{}}catch(e){let n=this.getAttribute("component-url")||"<unknown>",h=this.getAttribute("component-export");throw h&&(n+=\` (export \${h})\`),console.error(\`[hydrate] Error parsing props for component \${n}\`,this.getAttribute("props"),e),e}await this.hydrator(this)(this.Component,l,i,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((r,s)=>{s.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let r=this.getAttribute("before-hydration-url");r&&await import(r),this.start()}start(){let r=JSON.parse(this.getAttribute("opts")),s=this.getAttribute("client");if(Astro[s]===void 0){window.addEventListener(\`astro:\${s}\`,()=>this.start(),{once:!0});return}Astro[s](async()=>{let i=this.getAttribute("renderer-url"),[c,{default:l}]=await Promise.all([import(this.getAttribute("component-url")),i?import(i):()=>()=>{}]),o=this.getAttribute("component-export")||"default";if(!o.includes("."))this.Component=c[o];else{this.Component=c;for(let e of o.split("."))this.Component=this.Component[e]}return this.hydrator=l,this.hydrate},r,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
1623
748
 
1624
749
  const ISLAND_STYLES = `<style>astro-island,astro-slot,astro-static-slot{display:contents}</style>`;
1625
750
  function determineIfNeedsHydrationScript(result) {
@@ -2110,7 +1235,7 @@ async function renderToReadableStream(result, componentFactory, props, children,
2110
1235
  }
2111
1236
  if (chunk instanceof Response) {
2112
1237
  throw new AstroError({
2113
- ...AstroErrorData.ResponseSentError
1238
+ ...ResponseSentError
2114
1239
  });
2115
1240
  }
2116
1241
  const bytes = chunkToByteArray(result, chunk);
@@ -2139,8 +1264,8 @@ async function callComponentAsTemplateResultOrResponse(result, componentFactory,
2139
1264
  return factoryResult;
2140
1265
  } else if (!isRenderTemplateResult(factoryResult)) {
2141
1266
  throw new AstroError({
2142
- ...AstroErrorData.OnlyResponseCanBeReturned,
2143
- message: AstroErrorData.OnlyResponseCanBeReturned.message(route == null ? void 0 : route.route, typeof factoryResult),
1267
+ ...OnlyResponseCanBeReturned,
1268
+ message: OnlyResponseCanBeReturned.message(route == null ? void 0 : route.route, typeof factoryResult),
2144
1269
  location: {
2145
1270
  file: route == null ? void 0 : route.component
2146
1271
  }
@@ -2304,9 +1429,9 @@ Did you forget to import the component or is it possible there is a typo?`
2304
1429
  if (!renderer) {
2305
1430
  if (metadata.hydrate === "only") {
2306
1431
  throw new AstroError({
2307
- ...AstroErrorData.NoClientOnlyHint,
2308
- message: AstroErrorData.NoClientOnlyHint.message(metadata.displayName),
2309
- hint: AstroErrorData.NoClientOnlyHint.hint(
1432
+ ...NoClientOnlyHint,
1433
+ message: NoClientOnlyHint.message(metadata.displayName),
1434
+ hint: NoClientOnlyHint.hint(
2310
1435
  probableRendererNames.map((r) => r.replace("@astrojs/", "")).join("|")
2311
1436
  )
2312
1437
  });
@@ -2317,14 +1442,14 @@ Did you forget to import the component or is it possible there is a typo?`
2317
1442
  const plural = validRenderers.length > 1;
2318
1443
  if (matchingRenderers.length === 0) {
2319
1444
  throw new AstroError({
2320
- ...AstroErrorData.NoMatchingRenderer,
2321
- message: AstroErrorData.NoMatchingRenderer.message(
1445
+ ...NoMatchingRenderer,
1446
+ message: NoMatchingRenderer.message(
2322
1447
  metadata.displayName,
2323
1448
  (_b = metadata == null ? void 0 : metadata.componentUrl) == null ? void 0 : _b.split(".").pop(),
2324
1449
  plural,
2325
1450
  validRenderers.length
2326
1451
  ),
2327
- hint: AstroErrorData.NoMatchingRenderer.hint(
1452
+ hint: NoMatchingRenderer.hint(
2328
1453
  formatList(probableRendererNames.map((r) => "`" + r + "`"))
2329
1454
  )
2330
1455
  });
@@ -2366,8 +1491,8 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
2366
1491
  }
2367
1492
  if (renderer && !renderer.clientEntrypoint && renderer.name !== "@astrojs/lit" && metadata.hydrate) {
2368
1493
  throw new AstroError({
2369
- ...AstroErrorData.NoClientEntrypoint,
2370
- message: AstroErrorData.NoClientEntrypoint.message(
1494
+ ...NoClientEntrypoint,
1495
+ message: NoClientEntrypoint.message(
2371
1496
  displayName,
2372
1497
  metadata.hydrate,
2373
1498
  renderer.name
@@ -2484,18 +1609,21 @@ async function renderHTMLComponent(result, Component, _props, slots = {}) {
2484
1609
  }
2485
1610
  };
2486
1611
  }
2487
- async function renderAstroComponent(result, displayName, Component, props, slots = {}) {
1612
+ function renderAstroComponent(result, displayName, Component, props, slots = {}) {
2488
1613
  const instance = createAstroComponentInstance(result, displayName, Component, props, slots);
2489
- const chunks = [];
2490
- const temporaryDestination = {
2491
- write: (chunk) => chunks.push(chunk)
1614
+ const bufferChunks = [];
1615
+ const bufferDestination = {
1616
+ write: (chunk) => bufferChunks.push(chunk)
2492
1617
  };
2493
- await instance.render(temporaryDestination);
1618
+ const renderPromise = instance.render(bufferDestination);
2494
1619
  return {
2495
- render(destination) {
2496
- for (const chunk of chunks) {
1620
+ async render(destination) {
1621
+ for (const chunk of bufferChunks) {
2497
1622
  destination.write(chunk);
2498
1623
  }
1624
+ bufferChunks.length = 0;
1625
+ bufferDestination.write = (chunk) => destination.write(chunk);
1626
+ await renderPromise;
2499
1627
  }
2500
1628
  };
2501
1629
  }
@@ -2510,7 +1638,7 @@ async function renderComponent(result, displayName, Component, props, slots = {}
2510
1638
  return await renderHTMLComponent(result, Component, props, slots);
2511
1639
  }
2512
1640
  if (isAstroComponentFactory(Component)) {
2513
- return await renderAstroComponent(result, displayName, Component, props, slots);
1641
+ return renderAstroComponent(result, displayName, Component, props, slots);
2514
1642
  }
2515
1643
  return await renderFrameworkComponent(result, displayName, Component, props, slots);
2516
1644
  }
@@ -3194,7 +2322,7 @@ class AstroCookies {
3194
2322
  ]);
3195
2323
  if (this.#request[responseSentSymbol$2]) {
3196
2324
  throw new AstroError({
3197
- ...AstroErrorData.ResponseSentError
2325
+ ...ResponseSentError
3198
2326
  });
3199
2327
  }
3200
2328
  }
@@ -3398,20 +2526,20 @@ It's strongly suggested to use full ${bold("Response")} objects.`
3398
2526
  if (nextCalled) {
3399
2527
  if (typeof value !== "undefined") {
3400
2528
  if (value instanceof Response === false) {
3401
- throw new AstroError(AstroErrorData.MiddlewareNotAResponse);
2529
+ throw new AstroError(MiddlewareNotAResponse);
3402
2530
  }
3403
2531
  return value;
3404
2532
  } else {
3405
2533
  if (responseFunctionPromise) {
3406
2534
  return responseFunctionPromise;
3407
2535
  } else {
3408
- throw new AstroError(AstroErrorData.MiddlewareNotAResponse);
2536
+ throw new AstroError(MiddlewareNotAResponse);
3409
2537
  }
3410
2538
  }
3411
2539
  } else if (typeof value === "undefined") {
3412
- throw new AstroError(AstroErrorData.MiddlewareNoDataOrNextCalled);
2540
+ throw new AstroError(MiddlewareNoDataOrNextCalled);
3413
2541
  } else if (value instanceof Response === false) {
3414
- throw new AstroError(AstroErrorData.MiddlewareNotAResponse);
2542
+ throw new AstroError(MiddlewareNotAResponse);
3415
2543
  } else {
3416
2544
  return value;
3417
2545
  }
@@ -3450,11 +2578,11 @@ function createAPIContext({
3450
2578
  if (!(clientAddressSymbol$2 in request)) {
3451
2579
  if (adapterName) {
3452
2580
  throw new AstroError({
3453
- ...AstroErrorData.ClientAddressNotAvailable,
3454
- message: AstroErrorData.ClientAddressNotAvailable.message(adapterName)
2581
+ ...ClientAddressNotAvailable,
2582
+ message: ClientAddressNotAvailable.message(adapterName)
3455
2583
  });
3456
2584
  } else {
3457
- throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
2585
+ throw new AstroError(StaticClientAddressNotAvailable);
3458
2586
  }
3459
2587
  }
3460
2588
  return Reflect.get(request, clientAddressSymbol$2);
@@ -3467,7 +2595,7 @@ function createAPIContext({
3467
2595
  },
3468
2596
  set(val) {
3469
2597
  if (typeof val !== "object") {
3470
- throw new AstroError(AstroErrorData.LocalsNotAnObject);
2598
+ throw new AstroError(LocalsNotAnObject);
3471
2599
  } else {
3472
2600
  Reflect.set(request, clientLocalsSymbol$2, val);
3473
2601
  }
@@ -3550,8 +2678,8 @@ class Slots {
3550
2678
  for (const key of Object.keys(slots)) {
3551
2679
  if (this[key] !== void 0) {
3552
2680
  throw new AstroError({
3553
- ...AstroErrorData.ReservedSlotName,
3554
- message: AstroErrorData.ReservedSlotName.message(key)
2681
+ ...ReservedSlotName,
2682
+ message: ReservedSlotName.message(key)
3555
2683
  });
3556
2684
  }
3557
2685
  Object.defineProperty(this, key, {
@@ -3636,11 +2764,11 @@ function createResult(args) {
3636
2764
  if (!(clientAddressSymbol$1 in request)) {
3637
2765
  if (args.adapterName) {
3638
2766
  throw new AstroError({
3639
- ...AstroErrorData.ClientAddressNotAvailable,
3640
- message: AstroErrorData.ClientAddressNotAvailable.message(args.adapterName)
2767
+ ...ClientAddressNotAvailable,
2768
+ message: ClientAddressNotAvailable.message(args.adapterName)
3641
2769
  });
3642
2770
  } else {
3643
- throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
2771
+ throw new AstroError(StaticClientAddressNotAvailable);
3644
2772
  }
3645
2773
  }
3646
2774
  return Reflect.get(request, clientAddressSymbol$1);
@@ -3661,7 +2789,7 @@ function createResult(args) {
3661
2789
  redirect(path, status) {
3662
2790
  if (request[responseSentSymbol$1]) {
3663
2791
  throw new AstroError({
3664
- ...AstroErrorData.ResponseSentError
2792
+ ...ResponseSentError
3665
2793
  });
3666
2794
  }
3667
2795
  return new Response(null, {
@@ -3812,8 +2940,8 @@ const VALID_PARAM_TYPES = ["string", "number", "undefined"];
3812
2940
  function validateGetStaticPathsParameter([key, value], route) {
3813
2941
  if (!VALID_PARAM_TYPES.includes(typeof value)) {
3814
2942
  throw new AstroError({
3815
- ...AstroErrorData.GetStaticPathsInvalidRouteParam,
3816
- message: AstroErrorData.GetStaticPathsInvalidRouteParam.message(key, value, typeof value),
2943
+ ...GetStaticPathsInvalidRouteParam,
2944
+ message: GetStaticPathsInvalidRouteParam.message(key, value, typeof value),
3817
2945
  location: {
3818
2946
  file: route
3819
2947
  }
@@ -3826,7 +2954,7 @@ function validateDynamicRouteModule(mod, {
3826
2954
  }) {
3827
2955
  if ((!ssr || route.prerender) && !mod.getStaticPaths) {
3828
2956
  throw new AstroError({
3829
- ...AstroErrorData.GetStaticPathsRequired,
2957
+ ...GetStaticPathsRequired,
3830
2958
  location: { file: route.component }
3831
2959
  });
3832
2960
  }
@@ -3834,8 +2962,8 @@ function validateDynamicRouteModule(mod, {
3834
2962
  function validateGetStaticPathsResult(result, logging, route) {
3835
2963
  if (!Array.isArray(result)) {
3836
2964
  throw new AstroError({
3837
- ...AstroErrorData.InvalidGetStaticPathsReturn,
3838
- message: AstroErrorData.InvalidGetStaticPathsReturn.message(typeof result),
2965
+ ...InvalidGetStaticPathsReturn,
2966
+ message: InvalidGetStaticPathsReturn.message(typeof result),
3839
2967
  location: {
3840
2968
  file: route.component
3841
2969
  }
@@ -3844,7 +2972,7 @@ function validateGetStaticPathsResult(result, logging, route) {
3844
2972
  result.forEach((pathObject) => {
3845
2973
  if (pathObject.params === void 0 || pathObject.params === null || pathObject.params && Object.keys(pathObject.params).length === 0) {
3846
2974
  throw new AstroError({
3847
- ...AstroErrorData.GetStaticPathsExpectedParams,
2975
+ ...GetStaticPathsExpectedParams,
3848
2976
  location: {
3849
2977
  file: route.component
3850
2978
  }
@@ -3852,8 +2980,8 @@ function validateGetStaticPathsResult(result, logging, route) {
3852
2980
  }
3853
2981
  if (typeof pathObject.params !== "object") {
3854
2982
  throw new AstroError({
3855
- ...AstroErrorData.InvalidGetStaticPathParam,
3856
- message: AstroErrorData.InvalidGetStaticPathParam.message(typeof pathObject.params),
2983
+ ...InvalidGetStaticPathParam,
2984
+ message: InvalidGetStaticPathParam.message(typeof pathObject.params),
3857
2985
  location: {
3858
2986
  file: route.component
3859
2987
  }
@@ -3918,8 +3046,8 @@ function generatePaginateFunction(routeMatch) {
3918
3046
  includesFirstPageNumber = true;
3919
3047
  } else {
3920
3048
  throw new AstroError({
3921
- ...AstroErrorData.PageNumberParamNotFound,
3922
- message: AstroErrorData.PageNumberParamNotFound.message(paramName)
3049
+ ...PageNumberParamNotFound,
3050
+ message: PageNumberParamNotFound.message(paramName)
3923
3051
  });
3924
3052
  }
3925
3053
  const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
@@ -3990,7 +3118,7 @@ async function callGetStaticPaths({
3990
3118
  staticPaths = await mod.getStaticPaths({
3991
3119
  paginate: generatePaginateFunction(route),
3992
3120
  rss() {
3993
- throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
3121
+ throw new AstroError(GetStaticPathsRemovedRSSHelper);
3994
3122
  }
3995
3123
  });
3996
3124
  if (Array.isArray(staticPaths)) {
@@ -4060,9 +3188,9 @@ async function getParamsAndProps(opts) {
4060
3188
  const matchedStaticPath = findPathItemByKey(staticPaths, params, route);
4061
3189
  if (!matchedStaticPath && (ssr ? route.prerender : true)) {
4062
3190
  throw new AstroError({
4063
- ...AstroErrorData.NoMatchingStaticPathFound,
4064
- message: AstroErrorData.NoMatchingStaticPathFound.message(pathname),
4065
- hint: AstroErrorData.NoMatchingStaticPathFound.hint([route.component])
3191
+ ...NoMatchingStaticPathFound,
3192
+ message: NoMatchingStaticPathFound.message(pathname),
3193
+ hint: NoMatchingStaticPathFound.hint([route.component])
4066
3194
  });
4067
3195
  }
4068
3196
  const props = (matchedStaticPath == null ? void 0 : matchedStaticPath.props) ? { ...matchedStaticPath.props } : {};
@@ -4083,9 +3211,9 @@ function validatePrerenderEndpointCollision(route, mod, params) {
4083
3211
  const lastParam = paramValues[paramValues.length - 1];
4084
3212
  if (lastSegment.length === 1 && lastSegment[0].dynamic && lastParam === void 0) {
4085
3213
  throw new AstroError({
4086
- ...AstroErrorData.PrerenderDynamicEndpointPathCollide,
4087
- message: AstroErrorData.PrerenderDynamicEndpointPathCollide.message(route.route),
4088
- hint: AstroErrorData.PrerenderDynamicEndpointPathCollide.hint(route.component),
3214
+ ...PrerenderDynamicEndpointPathCollide,
3215
+ message: PrerenderDynamicEndpointPathCollide.message(route.route),
3216
+ hint: PrerenderDynamicEndpointPathCollide.hint(route.component),
4089
3217
  location: {
4090
3218
  file: route.component
4091
3219
  }
@@ -4119,7 +3247,7 @@ async function createRenderContext(options) {
4119
3247
  },
4120
3248
  set(val) {
4121
3249
  if (typeof val !== "object") {
4122
- throw new AstroError(AstroErrorData.LocalsNotAnObject);
3250
+ throw new AstroError(LocalsNotAnObject);
4123
3251
  } else {
4124
3252
  Reflect.set(request, clientLocalsSymbol$1, val);
4125
3253
  }
@@ -4190,6 +3318,7 @@ function matchRoute(pathname, manifest) {
4190
3318
 
4191
3319
  const clientLocalsSymbol = Symbol.for("astro.locals");
4192
3320
  const responseSentSymbol = Symbol.for("astro.responseSent");
3321
+ const STATUS_CODES = /* @__PURE__ */ new Set([404, 500]);
4193
3322
  class App {
4194
3323
  /**
4195
3324
  * The current environment of the application
@@ -4261,46 +3390,31 @@ class App {
4261
3390
  }
4262
3391
  return pathname;
4263
3392
  }
4264
- match(request, { matchNotFound = false } = {}) {
3393
+ // Disable no-unused-vars to avoid breaking signature change
3394
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3395
+ match(request, _opts = {}) {
4265
3396
  const url = new URL(request.url);
4266
- if (this.#manifest.assets.has(url.pathname)) {
3397
+ if (this.#manifest.assets.has(url.pathname))
4267
3398
  return void 0;
4268
- }
4269
- let pathname = prependForwardSlash(this.removeBase(url.pathname));
4270
- let routeData = matchRoute(pathname, this.#manifestData);
4271
- if (routeData) {
4272
- if (routeData.prerender)
4273
- return void 0;
4274
- return routeData;
4275
- } else if (matchNotFound) {
4276
- const notFoundRouteData = matchRoute("/404", this.#manifestData);
4277
- if (notFoundRouteData == null ? void 0 : notFoundRouteData.prerender)
4278
- return void 0;
4279
- return notFoundRouteData;
4280
- } else {
3399
+ const pathname = prependForwardSlash(this.removeBase(url.pathname));
3400
+ const routeData = matchRoute(pathname, this.#manifestData);
3401
+ if (!routeData || routeData.prerender)
4281
3402
  return void 0;
4282
- }
3403
+ return routeData;
4283
3404
  }
4284
3405
  async render(request, routeData, locals) {
4285
- let defaultStatus = 200;
3406
+ if (request.url !== collapseDuplicateSlashes(request.url)) {
3407
+ request = new Request(collapseDuplicateSlashes(request.url), request);
3408
+ }
4286
3409
  if (!routeData) {
4287
3410
  routeData = this.match(request);
4288
- if (!routeData) {
4289
- defaultStatus = 404;
4290
- routeData = this.match(request, { matchNotFound: true });
4291
- }
4292
- if (!routeData) {
4293
- return new Response(null, {
4294
- status: 404,
4295
- statusText: "Not found"
4296
- });
4297
- }
4298
3411
  }
4299
- Reflect.set(request, clientLocalsSymbol, locals ?? {});
4300
- if (routeData.route === "/404") {
4301
- defaultStatus = 404;
3412
+ if (!routeData) {
3413
+ return this.#renderError(request, { status: 404 });
4302
3414
  }
4303
- let mod = await this.#getModuleForRoute(routeData);
3415
+ Reflect.set(request, clientLocalsSymbol, locals ?? {});
3416
+ const defaultStatus = this.#getDefaultStatusCode(routeData.route);
3417
+ const mod = await this.#getModuleForRoute(routeData);
4304
3418
  const pageModule = await mod.page();
4305
3419
  const url = new URL(request.url);
4306
3420
  const renderContext = await this.#createRenderContext(
@@ -4321,46 +3435,24 @@ class App {
4321
3435
  );
4322
3436
  } catch (err) {
4323
3437
  error(this.#logging, "ssr", err.stack || err.message || String(err));
4324
- response = new Response(null, {
4325
- status: 500,
4326
- statusText: "Internal server error"
4327
- });
3438
+ return this.#renderError(request, { status: 500 });
4328
3439
  }
4329
3440
  if (isResponse(response, routeData.type)) {
4330
- if (response.status === 500 || response.status === 404) {
4331
- const errorRouteData = matchRoute("/" + response.status, this.#manifestData);
4332
- if (errorRouteData && errorRouteData.route !== routeData.route) {
4333
- mod = await this.#getModuleForRoute(errorRouteData);
4334
- try {
4335
- const newRenderContext = await this.#createRenderContext(
4336
- url,
4337
- request,
4338
- routeData,
4339
- mod,
4340
- response.status
4341
- );
4342
- const page = await mod.page();
4343
- const errorResponse = await tryRenderRoute(
4344
- routeData.type,
4345
- newRenderContext,
4346
- this.#env,
4347
- page
4348
- );
4349
- return errorResponse;
4350
- } catch {
4351
- }
4352
- }
3441
+ if (STATUS_CODES.has(response.status)) {
3442
+ return this.#renderError(request, {
3443
+ response,
3444
+ status: response.status
3445
+ });
4353
3446
  }
4354
3447
  Reflect.set(response, responseSentSymbol, true);
4355
3448
  return response;
4356
3449
  } else {
4357
3450
  if (response.type === "response") {
4358
3451
  if (response.response.headers.get("X-Astro-Response") === "Not-Found") {
4359
- const fourOhFourRequest = new Request(new URL("/404", request.url));
4360
- const fourOhFourRouteData = this.match(fourOhFourRequest);
4361
- if (fourOhFourRouteData) {
4362
- return this.render(fourOhFourRequest, fourOhFourRouteData);
4363
- }
3452
+ return this.#renderError(request, {
3453
+ response: response.response,
3454
+ status: 404
3455
+ });
4364
3456
  }
4365
3457
  return response.response;
4366
3458
  } else {
@@ -4435,6 +3527,64 @@ class App {
4435
3527
  });
4436
3528
  }
4437
3529
  }
3530
+ /**
3531
+ * If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro).
3532
+ * This also handles pre-rendered /404 or /500 routes
3533
+ */
3534
+ async #renderError(request, { status, response: originalResponse }) {
3535
+ const errorRouteData = matchRoute("/" + status, this.#manifestData);
3536
+ const url = new URL(request.url);
3537
+ if (errorRouteData) {
3538
+ if (errorRouteData.prerender && !errorRouteData.route.endsWith(`/${status}`)) {
3539
+ const statusURL = new URL(`${this.#baseWithoutTrailingSlash}/${status}`, url);
3540
+ const response2 = await fetch(statusURL.toString());
3541
+ return this.#mergeResponses(response2, originalResponse);
3542
+ }
3543
+ const mod = await this.#getModuleForRoute(errorRouteData);
3544
+ try {
3545
+ const newRenderContext = await this.#createRenderContext(
3546
+ url,
3547
+ request,
3548
+ errorRouteData,
3549
+ mod,
3550
+ status
3551
+ );
3552
+ const page = await mod.page();
3553
+ const response2 = await tryRenderRoute(
3554
+ "page",
3555
+ // this is hardcoded to ensure proper behavior for missing endpoints
3556
+ newRenderContext,
3557
+ this.#env,
3558
+ page
3559
+ );
3560
+ return this.#mergeResponses(response2, originalResponse);
3561
+ } catch {
3562
+ }
3563
+ }
3564
+ const response = this.#mergeResponses(new Response(null, { status }), originalResponse);
3565
+ Reflect.set(response, responseSentSymbol, true);
3566
+ return response;
3567
+ }
3568
+ #mergeResponses(newResponse, oldResponse) {
3569
+ if (!oldResponse)
3570
+ return newResponse;
3571
+ const { status, statusText, headers } = oldResponse;
3572
+ return new Response(newResponse.body, {
3573
+ // If the original status was 200 (default), override it with the new status (probably 404 or 500)
3574
+ // Otherwise, the user set a specific status while rendering and we should respect that one
3575
+ status: status === 200 ? newResponse.status : status,
3576
+ statusText: status === 200 ? newResponse.statusText : statusText,
3577
+ headers: new Headers(Array.from(headers))
3578
+ });
3579
+ }
3580
+ #getDefaultStatusCode(route) {
3581
+ route = removeTrailingForwardSlash(route);
3582
+ if (route.endsWith("/404"))
3583
+ return 404;
3584
+ if (route.endsWith("/500"))
3585
+ return 500;
3586
+ return 200;
3587
+ }
4438
3588
  async #getModuleForRoute(route) {
4439
3589
  if (route.type === "redirect") {
4440
3590
  return RedirectSinglePageBuiltModule;