cloudcommerce 2.10.2 → 2.10.4

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 (156) hide show
  1. package/.vscode/settings.json +3 -3
  2. package/CHANGELOG.md +15 -0
  3. package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
  4. package/ecomplus-stores/barradoce/functions/ssr/content/pages/products.json +1 -4
  5. package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
  6. package/ecomplus-stores/barradoce/functions/ssr/{tailwind.config.cjs → tailwind.config.js} +3 -3
  7. package/ecomplus-stores/barradoce/functions/ssr/uno.config.js +4 -0
  8. package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
  9. package/ecomplus-stores/barradoce/package.json +2 -2
  10. package/ecomplus-stores/barradoce/tailwind.config.js +8 -0
  11. package/package.json +4 -4
  12. package/packages/api/package.json +1 -1
  13. package/packages/apps/affiliate-program/package.json +2 -2
  14. package/packages/apps/correios/package.json +2 -2
  15. package/packages/apps/custom-payment/package.json +1 -1
  16. package/packages/apps/custom-shipping/package.json +1 -1
  17. package/packages/apps/datafrete/package.json +3 -3
  18. package/packages/apps/discounts/package.json +1 -1
  19. package/packages/apps/emails/package.json +3 -3
  20. package/packages/apps/fb-conversions/package.json +3 -3
  21. package/packages/apps/flash-courier/package.json +2 -2
  22. package/packages/apps/frenet/package.json +3 -3
  23. package/packages/apps/galaxpay/package.json +3 -3
  24. package/packages/apps/google-analytics/package.json +3 -3
  25. package/packages/apps/jadlog/package.json +1 -1
  26. package/packages/apps/loyalty-points/package.json +1 -1
  27. package/packages/apps/mandae/package.json +2 -2
  28. package/packages/apps/melhor-envio/package.json +3 -3
  29. package/packages/apps/mercadopago/package.json +3 -3
  30. package/packages/apps/pagarme/package.json +3 -3
  31. package/packages/apps/pagarme-v5/package.json +2 -2
  32. package/packages/apps/paghiper/package.json +3 -3
  33. package/packages/apps/pix/package.json +3 -3
  34. package/packages/apps/tiny-erp/package.json +3 -3
  35. package/packages/apps/webhooks/package.json +3 -3
  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/base.eslintrc.cjs +1 -0
  40. package/packages/eslint/package.json +4 -4
  41. package/packages/events/package.json +3 -3
  42. package/packages/feeds/package.json +2 -2
  43. package/packages/firebase/package.json +3 -3
  44. package/packages/i18n/package.json +1 -1
  45. package/packages/modules/package.json +3 -3
  46. package/packages/passport/package.json +3 -3
  47. package/packages/ssr/package.json +3 -3
  48. package/packages/storefront/config/{storefront.tailwind.cjs → storefront.tailwind.mjs} +19 -19
  49. package/packages/storefront/config/{storefront.unocss.cjs → storefront.unocss.mjs} +9 -9
  50. package/packages/storefront/dist/client/_astro/AccountPage.Cf0WE6GF.js +1 -0
  51. package/packages/storefront/dist/client/_astro/CartSidebar.DAvJKL2c.js +1 -0
  52. package/packages/storefront/dist/client/_astro/HeroSlider.DyjSOy4Q.js +1 -0
  53. package/packages/storefront/dist/client/_astro/PitchBar.CEGsee2q.js +1 -0
  54. package/packages/storefront/dist/client/_astro/Prices.9RhV7hCY.js +1 -0
  55. package/packages/storefront/dist/client/_astro/ProductDetails.BpZtnS8j.js +7 -0
  56. package/packages/storefront/dist/client/_astro/ProductShelf.C0TU_sRb.js +1 -0
  57. package/packages/storefront/dist/client/_astro/SearchModal.DWNSfxML.js +1 -0
  58. package/packages/storefront/dist/client/_astro/SearchShowcase.CUkbXIRk.js +1 -0
  59. package/packages/storefront/dist/client/_astro/ShippingCalculator.DZSCK4xv.js +1 -0
  60. package/packages/storefront/dist/client/_astro/ShopHeader.D7qqQxFD.js +7 -0
  61. package/packages/storefront/dist/client/_astro/{_plugin-vue_export-helper.3R8ooc_r.js → _plugin-vue_export-helper.6K9uDcVo.js} +1 -1
  62. package/packages/storefront/dist/client/_astro/_slug_.HhgCFKHv.css +1 -0
  63. package/packages/storefront/dist/client/_astro/client.D_V8TfA5.js +1 -0
  64. package/packages/storefront/dist/client/_astro/customer-session.Cctko5_9.js +7 -0
  65. package/packages/storefront/dist/client/_astro/{firebase-app.CBckq0Sj.js → firebase-app.CmI1zl7o.js} +1 -1
  66. package/packages/storefront/dist/client/_astro/{format-money.vLicYTv9.js → format-money.D19_eJVX.js} +1 -1
  67. package/packages/storefront/dist/client/_astro/{grid-title.CxNZApGL.js → grid-title.CZdq2sDS.js} +1 -1
  68. package/packages/storefront/dist/client/_astro/hoisted.BeKMioW4.js +1 -0
  69. package/packages/storefront/dist/client/_astro/hoisted.Bf1gCkSN.js +1 -0
  70. package/packages/storefront/dist/client/_astro/hoisted.CSjieYcR.js +8 -0
  71. package/packages/storefront/dist/client/_astro/{i18n.BE5r_SIU.js → i18n.DPcLqMFO.js} +1 -1
  72. package/packages/storefront/dist/client/_astro/{img.CB-F9VLo.js → img.Be85e5da.js} +1 -1
  73. package/packages/storefront/dist/client/_astro/{index-bea2a320.CHELEM8n.js → index-a8cf6c8f.k99a-gIB.js} +99 -99
  74. package/packages/storefront/dist/client/_astro/index.BCNoXz_Z.js +1 -0
  75. package/packages/storefront/dist/client/_astro/index.BgtOIB20.js +1 -0
  76. package/packages/storefront/dist/client/_astro/index.DlxZwqDP.js +1 -0
  77. package/packages/storefront/dist/client/_astro/modules-info.BswYf_-7.js +1 -0
  78. package/packages/storefront/dist/client/_astro/name.Dll7Wwmg.js +1 -0
  79. package/packages/storefront/dist/client/_astro/page.FdSlRisw.js +1 -0
  80. package/packages/storefront/dist/client/_astro/sf-utils.C9ygvYIB.js +13 -0
  81. package/packages/storefront/dist/client/_astro/shopping-cart.Cqc6p5UR.js +1 -0
  82. package/packages/storefront/dist/client/_astro/use-analytics.bP3a5cR0.js +1 -0
  83. package/packages/storefront/dist/client/_astro/{use-cms-preview.CPGTKut8.js → use-cms-preview.BxKK4a1X.js} +1 -1
  84. package/packages/storefront/dist/client/_astro/use-product-card.Cj9Q-Y1A.js +1 -0
  85. package/packages/storefront/dist/client/_astro/{use-text-value.D4Rw7N4D.js → use-text-value.DT0v9Yj_.js} +2 -2
  86. package/packages/storefront/dist/server/_astro-internal_middleware.mjs +4 -0
  87. package/packages/storefront/dist/server/chunks/404_jTV5wvby.mjs +5 -0
  88. package/packages/storefront/dist/server/chunks/{CartSidebar_lUckG0fs.mjs → CartSidebar_CV9qwGNE.mjs} +2 -1
  89. package/packages/storefront/dist/server/chunks/{SearchModal_B2f22Mff.mjs → SearchModal_Cw1ECnXI.mjs} +37 -15
  90. package/packages/storefront/dist/server/chunks/_.._k1NruPDv.mjs +5 -0
  91. package/packages/storefront/dist/server/chunks/_astro-internal_middleware_DIG56BhA.mjs +40 -0
  92. package/packages/storefront/dist/server/chunks/{_page__Ex4FhYrc.mjs → _page__BKNX3RH7.mjs} +1 -1
  93. package/packages/storefront/dist/server/chunks/{account_B7sLjsXD.mjs → account_BZOa6Kmc.mjs} +1 -1
  94. package/packages/storefront/dist/server/chunks/astro/{assets-service_BOyOfKDQ.mjs → assets-service_MW85B416.mjs} +5 -2
  95. package/packages/storefront/dist/server/chunks/{astro_B5LBy7PI.mjs → astro_8KdHu_Gf.mjs} +83 -113
  96. package/packages/storefront/dist/server/chunks/{index_C2hkTn-w.mjs → index_CZ6FSUEb.mjs} +1 -1
  97. package/packages/storefront/dist/server/chunks/{index_BOh755yP.mjs → index_D1o9pXka.mjs} +1 -1
  98. package/packages/storefront/dist/server/chunks/{node_DavlI8UF.mjs → node_Khrf-0bH.mjs} +1 -1
  99. package/packages/storefront/dist/server/chunks/pages/{__RXg_hYeF.mjs → 404_BPSxJtl3.mjs} +675 -4955
  100. package/packages/storefront/dist/server/chunks/pages/__ByRpsTnC.mjs +4630 -0
  101. package/packages/storefront/dist/server/chunks/pages/{_page__Dyte93f2.mjs → _page__BasreLue.mjs} +32 -9
  102. package/packages/storefront/dist/server/chunks/pages/{account_C66y6_Y9.mjs → account_MZBvNAyZ.mjs} +2 -2
  103. package/packages/storefront/dist/server/chunks/pages/{index_EO1hhrt8.mjs → index_CV2ET14h.mjs} +24 -9
  104. package/packages/storefront/dist/server/chunks/pages/{node_hc25rqYt.mjs → node_1tKTIKG-.mjs} +145 -11
  105. package/packages/storefront/dist/server/chunks/pages/{~fallback_-K3esUV3.mjs → ~fallback_BVYzgZ5p.mjs} +2 -28
  106. package/packages/storefront/dist/server/chunks/{~fallback_DQ6yB81s.mjs → ~fallback_xH9bJF7E.mjs} +1 -1
  107. package/packages/storefront/dist/server/entry.mjs +469 -507
  108. package/packages/storefront/dist/server/manifest_S9lE9v48.mjs +206 -0
  109. package/packages/storefront/dist/server/middleware.mjs +4 -0
  110. package/packages/storefront/dist/server/renderers.mjs +39 -50
  111. package/packages/storefront/package.json +7 -7
  112. package/packages/storefront/src/decap-cms/get-cms-config.ts +0 -1
  113. package/packages/storefront/src/images/picture-base.ts +1 -1
  114. package/packages/storefront/src/lib/assets/decap-cms.css +13 -3
  115. package/packages/storefront/src/lib/components/Picture.astro +1 -1
  116. package/packages/storefront/src/lib/composables/use-product-shelf.ts +1 -1
  117. package/packages/storefront/tailwind.config.js +3 -0
  118. package/packages/storefront/uno.config.js +3 -0
  119. package/packages/test-base/package.json +1 -1
  120. package/packages/types/package.json +1 -1
  121. package/tailwind.config.js +6 -0
  122. package/ecomplus-stores/barradoce/functions/ssr/uno.config.cjs +0 -5
  123. package/ecomplus-stores/barradoce/tailwind.config.cjs +0 -7
  124. package/packages/storefront/dist/client/_astro/AccountPage.Cq0jrJE5.js +0 -1
  125. package/packages/storefront/dist/client/_astro/CartSidebar.DkX2BE1w.js +0 -1
  126. package/packages/storefront/dist/client/_astro/HeroSlider.CZujn8cU.js +0 -1
  127. package/packages/storefront/dist/client/_astro/PitchBar.DhcSEQPV.js +0 -1
  128. package/packages/storefront/dist/client/_astro/Prices.D1uItqV5.js +0 -1
  129. package/packages/storefront/dist/client/_astro/ProductDetails.DDNMc2oj.js +0 -7
  130. package/packages/storefront/dist/client/_astro/ProductShelf.BwRDTU-V.js +0 -1
  131. package/packages/storefront/dist/client/_astro/SearchModal.DgrtGsIu.js +0 -1
  132. package/packages/storefront/dist/client/_astro/SearchShowcase.DggdcmcI.js +0 -1
  133. package/packages/storefront/dist/client/_astro/ShippingCalculator.B5JIh5xw.js +0 -1
  134. package/packages/storefront/dist/client/_astro/ShopHeader.CIsQLhMR.js +0 -7
  135. package/packages/storefront/dist/client/_astro/_slug_.CnXAH2gj.css +0 -1
  136. package/packages/storefront/dist/client/_astro/client.mwowSQrH.js +0 -1
  137. package/packages/storefront/dist/client/_astro/customer-session.BAjMMoBA.js +0 -7
  138. package/packages/storefront/dist/client/_astro/hoisted.B8Lw6O9a.js +0 -1
  139. package/packages/storefront/dist/client/_astro/hoisted.D4m7OTKi.js +0 -8
  140. package/packages/storefront/dist/client/_astro/hoisted.DSAg3dYh.js +0 -1
  141. package/packages/storefront/dist/client/_astro/hoisted.D_dlmSy5.js +0 -1
  142. package/packages/storefront/dist/client/_astro/index.BAyyMfaO.js +0 -1
  143. package/packages/storefront/dist/client/_astro/index.CTTHpJlV.js +0 -1
  144. package/packages/storefront/dist/client/_astro/modules-info.C6KJuGeB.js +0 -1
  145. package/packages/storefront/dist/client/_astro/name.CIPngEFN.js +0 -1
  146. package/packages/storefront/dist/client/_astro/server-data.CUHTES8a.js +0 -1
  147. package/packages/storefront/dist/client/_astro/sf-utils.xmJHVMAX.js +0 -13
  148. package/packages/storefront/dist/client/_astro/shopping-cart.DGvCZWRZ.js +0 -1
  149. package/packages/storefront/dist/client/_astro/use-analytics.BWhF_fCv.js +0 -1
  150. package/packages/storefront/dist/client/_astro/use-product-card.C-RbCwna.js +0 -1
  151. package/packages/storefront/dist/server/_noop-middleware.mjs +0 -3
  152. package/packages/storefront/dist/server/chunks/_.._CvgSOb3Z.mjs +0 -5
  153. package/packages/storefront/dist/server/manifest_bZVxjk3o.mjs +0 -201
  154. package/packages/storefront/tailwind.config.cjs +0 -3
  155. package/packages/storefront/uno.config.cjs +0 -3
  156. package/tailwind.config.cjs +0 -5
@@ -1,22 +1,23 @@
1
1
  import { renderers } from './renderers.mjs';
2
- import { l as levels, g as getEventPrefix, L as Logger, A as AstroIntegrationLogger, manifest } from './manifest_bZVxjk3o.mjs';
3
- import { appendForwardSlash as appendForwardSlash$1, joinPaths, trimSlashes, slash, prependForwardSlash as prependForwardSlash$1, removeTrailingForwardSlash, collapseDuplicateSlashes } from '@astrojs/internal-helpers/path';
4
- import { A as AstroError, R as ResponseSentError, p as MiddlewareNoDataOrNextCalled, q as MiddlewareNotAResponse, t as ROUTE_TYPE_HEADER, G as GetStaticPathsRequired, v as InvalidGetStaticPathsReturn, w as InvalidGetStaticPathsEntry, x as GetStaticPathsExpectedParams, y as GetStaticPathsInvalidRouteParam, P as PageNumberParamNotFound, N as NoMatchingStaticPathFound, z as PrerenderDynamicEndpointPathCollide, B as ReservedSlotName, k as renderSlotToString, C as renderJSX, D as chunkToString, H as clientAddressSymbol$1, J as ClientAddressNotAvailable, S as StaticClientAddressNotAvailable, K as responseSentSymbol$1, O as LocalsNotAnObject, Q as clientLocalsSymbol, T as ASTRO_VERSION, V as renderEndpoint, W as renderPage, X as REROUTABLE_STATUS_CODES, Y as REROUTE_DIRECTIVE_HEADER } from './chunks/astro_B5LBy7PI.mjs';
2
+ import { l as levels, g as getEventPrefix, L as Logger, A as AstroIntegrationLogger, manifest } from './manifest_S9lE9v48.mjs';
3
+ import { appendForwardSlash as appendForwardSlash$1, joinPaths, trimSlashes, fileExtension, slash, prependForwardSlash as prependForwardSlash$1, removeTrailingForwardSlash, collapseDuplicateSlashes } from '@astrojs/internal-helpers/path';
4
+ import { A as AstroError, R as ResponseSentError, o as MiddlewareNoDataOrNextCalled, p as MiddlewareNotAResponse, q as ROUTE_TYPE_HEADER, t as REROUTE_DIRECTIVE_HEADER, G as GetStaticPathsRequired, v as InvalidGetStaticPathsReturn, w as InvalidGetStaticPathsEntry, x as GetStaticPathsExpectedParams, y as GetStaticPathsInvalidRouteParam, P as PageNumberParamNotFound, D as DEFAULT_404_COMPONENT, N as NoMatchingStaticPathFound, z as PrerenderDynamicEndpointPathCollide, B as ReservedSlotName, i as renderSlotToString, C as renderJSX, H as chunkToString, J as LocalsNotAnObject, K as clientLocalsSymbol, O as clientAddressSymbol$1, Q as ClientAddressNotAvailable, S as StaticClientAddressNotAvailable, T as ASTRO_VERSION, V as responseSentSymbol$1, W as AstroResponseHeadersReassigned, X as renderPage, Y as renderEndpoint, Z as REROUTABLE_STATUS_CODES } from './chunks/astro_8KdHu_Gf.mjs';
5
5
  import { serialize, parse } from 'cookie';
6
6
  import 'clsx';
7
+ import { s as sequence, o as onRequest } from './chunks/_astro-internal_middleware_DIG56BhA.mjs';
7
8
  import 'kleur/colors';
8
- import http from 'node:http';
9
+ import { AsyncLocalStorage } from 'node:async_hooks';
9
10
  import https$1 from 'https';
10
11
  import fs from 'node:fs';
12
+ import http from 'node:http';
11
13
  import enableDestroy from 'server-destroy';
14
+ import https from 'node:https';
15
+ import os from 'node:os';
12
16
  import path from 'node:path';
13
17
  import url from 'node:url';
14
18
  import send from 'send';
15
- import os from 'node:os';
16
- import https from 'node:https';
17
19
  import buffer from 'node:buffer';
18
20
  import crypto from 'node:crypto';
19
- import { onRequest } from './_noop-middleware.mjs';
20
21
 
21
22
  function shouldAppendForwardSlash(trailingSlash, buildFormat) {
22
23
  switch (trailingSlash) {
@@ -72,6 +73,140 @@ class Unreachable extends Error {
72
73
  }
73
74
  }
74
75
 
76
+ function parseLocale(header) {
77
+ if (header === "*") {
78
+ return [{ locale: header, qualityValue: void 0 }];
79
+ }
80
+ const result = [];
81
+ const localeValues = header.split(",").map((str) => str.trim());
82
+ for (const localeValue of localeValues) {
83
+ const split = localeValue.split(";").map((str) => str.trim());
84
+ const localeName = split[0];
85
+ const qualityValue = split[1];
86
+ if (!split) {
87
+ continue;
88
+ }
89
+ if (qualityValue && qualityValue.startsWith("q=")) {
90
+ const qualityValueAsFloat = Number.parseFloat(qualityValue.slice("q=".length));
91
+ if (Number.isNaN(qualityValueAsFloat) || qualityValueAsFloat > 1) {
92
+ result.push({
93
+ locale: localeName,
94
+ qualityValue: void 0
95
+ });
96
+ } else {
97
+ result.push({
98
+ locale: localeName,
99
+ qualityValue: qualityValueAsFloat
100
+ });
101
+ }
102
+ } else {
103
+ result.push({
104
+ locale: localeName,
105
+ qualityValue: void 0
106
+ });
107
+ }
108
+ }
109
+ return result;
110
+ }
111
+ function sortAndFilterLocales(browserLocaleList, locales) {
112
+ const normalizedLocales = toCodes(locales).map(normalizeTheLocale);
113
+ return browserLocaleList.filter((browserLocale) => {
114
+ if (browserLocale.locale !== "*") {
115
+ return normalizedLocales.includes(normalizeTheLocale(browserLocale.locale));
116
+ }
117
+ return true;
118
+ }).sort((a, b) => {
119
+ if (a.qualityValue && b.qualityValue) {
120
+ if (a.qualityValue > b.qualityValue) {
121
+ return -1;
122
+ } else if (a.qualityValue < b.qualityValue) {
123
+ return 1;
124
+ }
125
+ }
126
+ return 0;
127
+ });
128
+ }
129
+ function computePreferredLocale(request, locales) {
130
+ const acceptHeader = request.headers.get("Accept-Language");
131
+ let result = void 0;
132
+ if (acceptHeader) {
133
+ const browserLocaleList = sortAndFilterLocales(parseLocale(acceptHeader), locales);
134
+ const firstResult = browserLocaleList.at(0);
135
+ if (firstResult && firstResult.locale !== "*") {
136
+ for (const currentLocale of locales) {
137
+ if (typeof currentLocale === "string") {
138
+ if (normalizeTheLocale(currentLocale) === normalizeTheLocale(firstResult.locale)) {
139
+ result = currentLocale;
140
+ }
141
+ } else {
142
+ for (const currentCode of currentLocale.codes) {
143
+ if (normalizeTheLocale(currentCode) === normalizeTheLocale(firstResult.locale)) {
144
+ result = currentLocale.path;
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ return result;
152
+ }
153
+ function computePreferredLocaleList(request, locales) {
154
+ const acceptHeader = request.headers.get("Accept-Language");
155
+ let result = [];
156
+ if (acceptHeader) {
157
+ const browserLocaleList = sortAndFilterLocales(parseLocale(acceptHeader), locales);
158
+ if (browserLocaleList.length === 1 && browserLocaleList.at(0).locale === "*") {
159
+ return locales.map((locale) => {
160
+ if (typeof locale === "string") {
161
+ return locale;
162
+ } else {
163
+ return locale.codes.at(0);
164
+ }
165
+ });
166
+ } else if (browserLocaleList.length > 0) {
167
+ for (const browserLocale of browserLocaleList) {
168
+ for (const loopLocale of locales) {
169
+ if (typeof loopLocale === "string") {
170
+ if (normalizeTheLocale(loopLocale) === normalizeTheLocale(browserLocale.locale)) {
171
+ result.push(loopLocale);
172
+ }
173
+ } else {
174
+ for (const code of loopLocale.codes) {
175
+ if (code === browserLocale.locale) {
176
+ result.push(loopLocale.path);
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ return result;
185
+ }
186
+ function computeCurrentLocale(pathname, locales) {
187
+ for (const segment of pathname.split("/")) {
188
+ for (const locale of locales) {
189
+ if (typeof locale === "string") {
190
+ if (!segment.includes(locale))
191
+ continue;
192
+ if (normalizeTheLocale(locale) === normalizeTheLocale(segment)) {
193
+ return locale;
194
+ }
195
+ } else {
196
+ if (locale.path === segment) {
197
+ return locale.codes.at(0);
198
+ } else {
199
+ for (const code of locale.codes) {
200
+ if (normalizeTheLocale(code) === normalizeTheLocale(segment)) {
201
+ return code;
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+
75
210
  const DELETED_EXPIRATION = /* @__PURE__ */ new Date(0);
76
211
  const DELETED_VALUE = "deleted";
77
212
  const responseSentSymbol = Symbol.for("astro.responseSent");
@@ -318,7 +453,7 @@ async function renderRedirect(renderContext) {
318
453
  } = renderContext;
319
454
  const { redirect, redirectRoute } = routeData;
320
455
  const status = redirectRoute && typeof redirect === "object" ? redirect.status : method === "GET" ? 301 : 308;
321
- const headers = { location: redirectRouteGenerate(renderContext) };
456
+ const headers = { location: encodeURI(redirectRouteGenerate(renderContext)) };
322
457
  return new Response(null, { status, headers });
323
458
  }
324
459
  function redirectRouteGenerate(renderContext) {
@@ -342,144 +477,6 @@ function redirectRouteGenerate(renderContext) {
342
477
  return redirect.destination;
343
478
  }
344
479
 
345
- function parseLocale(header) {
346
- if (header === "*") {
347
- return [{ locale: header, qualityValue: void 0 }];
348
- }
349
- const result = [];
350
- const localeValues = header.split(",").map((str) => str.trim());
351
- for (const localeValue of localeValues) {
352
- const split = localeValue.split(";").map((str) => str.trim());
353
- const localeName = split[0];
354
- const qualityValue = split[1];
355
- if (!split) {
356
- continue;
357
- }
358
- if (qualityValue && qualityValue.startsWith("q=")) {
359
- const qualityValueAsFloat = Number.parseFloat(qualityValue.slice("q=".length));
360
- if (Number.isNaN(qualityValueAsFloat) || qualityValueAsFloat > 1) {
361
- result.push({
362
- locale: localeName,
363
- qualityValue: void 0
364
- });
365
- } else {
366
- result.push({
367
- locale: localeName,
368
- qualityValue: qualityValueAsFloat
369
- });
370
- }
371
- } else {
372
- result.push({
373
- locale: localeName,
374
- qualityValue: void 0
375
- });
376
- }
377
- }
378
- return result;
379
- }
380
- function sortAndFilterLocales(browserLocaleList, locales) {
381
- const normalizedLocales = toCodes(locales).map(normalizeTheLocale);
382
- return browserLocaleList.filter((browserLocale) => {
383
- if (browserLocale.locale !== "*") {
384
- return normalizedLocales.includes(normalizeTheLocale(browserLocale.locale));
385
- }
386
- return true;
387
- }).sort((a, b) => {
388
- if (a.qualityValue && b.qualityValue) {
389
- if (a.qualityValue > b.qualityValue) {
390
- return -1;
391
- } else if (a.qualityValue < b.qualityValue) {
392
- return 1;
393
- }
394
- }
395
- return 0;
396
- });
397
- }
398
- function computePreferredLocale(request, locales) {
399
- const acceptHeader = request.headers.get("Accept-Language");
400
- let result = void 0;
401
- if (acceptHeader) {
402
- const browserLocaleList = sortAndFilterLocales(parseLocale(acceptHeader), locales);
403
- const firstResult = browserLocaleList.at(0);
404
- if (firstResult && firstResult.locale !== "*") {
405
- for (const currentLocale of locales) {
406
- if (typeof currentLocale === "string") {
407
- if (normalizeTheLocale(currentLocale) === normalizeTheLocale(firstResult.locale)) {
408
- result = currentLocale;
409
- }
410
- } else {
411
- for (const currentCode of currentLocale.codes) {
412
- if (normalizeTheLocale(currentCode) === normalizeTheLocale(firstResult.locale)) {
413
- result = currentLocale.path;
414
- }
415
- }
416
- }
417
- }
418
- }
419
- }
420
- return result;
421
- }
422
- function computePreferredLocaleList(request, locales) {
423
- const acceptHeader = request.headers.get("Accept-Language");
424
- let result = [];
425
- if (acceptHeader) {
426
- const browserLocaleList = sortAndFilterLocales(parseLocale(acceptHeader), locales);
427
- if (browserLocaleList.length === 1 && browserLocaleList.at(0).locale === "*") {
428
- return locales.map((locale) => {
429
- if (typeof locale === "string") {
430
- return locale;
431
- } else {
432
- return locale.codes.at(0);
433
- }
434
- });
435
- } else if (browserLocaleList.length > 0) {
436
- for (const browserLocale of browserLocaleList) {
437
- for (const loopLocale of locales) {
438
- if (typeof loopLocale === "string") {
439
- if (normalizeTheLocale(loopLocale) === normalizeTheLocale(browserLocale.locale)) {
440
- result.push(loopLocale);
441
- }
442
- } else {
443
- for (const code of loopLocale.codes) {
444
- if (code === browserLocale.locale) {
445
- result.push(loopLocale.path);
446
- }
447
- }
448
- }
449
- }
450
- }
451
- }
452
- }
453
- return result;
454
- }
455
- function computeCurrentLocale(pathname, locales, routingStrategy, defaultLocale) {
456
- for (const segment of pathname.split("/")) {
457
- for (const locale of locales) {
458
- if (typeof locale === "string") {
459
- if (!segment.includes(locale))
460
- continue;
461
- if (normalizeTheLocale(locale) === normalizeTheLocale(segment)) {
462
- return locale;
463
- }
464
- } else {
465
- if (locale.path === segment) {
466
- return locale.codes.at(0);
467
- } else {
468
- for (const code of locale.codes) {
469
- if (normalizeTheLocale(code) === normalizeTheLocale(segment)) {
470
- return code;
471
- }
472
- }
473
- }
474
- }
475
- }
476
- }
477
- if (routingStrategy === "pathname-prefix-other-locales" || routingStrategy === "domains-prefix-other-locales") {
478
- return defaultLocale;
479
- }
480
- return void 0;
481
- }
482
-
483
480
  async function callMiddleware(onRequest, apiContext, responseFunction) {
484
481
  let nextCalled = false;
485
482
  let responseFunctionPromise = void 0;
@@ -513,35 +510,6 @@ async function callMiddleware(onRequest, apiContext, responseFunction) {
513
510
  });
514
511
  }
515
512
 
516
- function sequence(...handlers) {
517
- const filtered = handlers.filter((h) => !!h);
518
- const length = filtered.length;
519
- if (!length) {
520
- const handler = defineMiddleware((context, next) => {
521
- return next();
522
- });
523
- return handler;
524
- }
525
- return defineMiddleware((context, next) => {
526
- return applyHandle(0, context);
527
- function applyHandle(i, handleContext) {
528
- const handle = filtered[i];
529
- const result = handle(handleContext, async () => {
530
- if (i < length - 1) {
531
- return applyHandle(i + 1, handleContext);
532
- } else {
533
- return next();
534
- }
535
- });
536
- return result;
537
- }
538
- });
539
- }
540
-
541
- function defineMiddleware(fn) {
542
- return fn;
543
- }
544
-
545
513
  function pathnameHasLocale(pathname, locales) {
546
514
  const segments = pathname.split("/");
547
515
  for (const segment of segments) {
@@ -568,10 +536,7 @@ function createI18nMiddleware(i18n, base, trailingSlash, buildFormat) {
568
536
  return context.redirect(`${joinPaths(base, i18n.defaultLocale)}`);
569
537
  }
570
538
  } else if (!pathnameHasLocale(url.pathname, i18n.locales)) {
571
- return new Response(null, {
572
- status: 404,
573
- headers: response.headers
574
- });
539
+ return notFound(response);
575
540
  }
576
541
  return void 0;
577
542
  };
@@ -586,20 +551,14 @@ function createI18nMiddleware(i18n, base, trailingSlash, buildFormat) {
586
551
  if (pathnameContainsDefaultLocale) {
587
552
  const newLocation = url.pathname.replace(`/${i18n.defaultLocale}`, "");
588
553
  response.headers.set("Location", newLocation);
589
- return new Response(null, {
590
- status: 404,
591
- headers: response.headers
592
- });
554
+ return notFound(response);
593
555
  }
594
556
  return void 0;
595
557
  };
596
558
  const prefixAlwaysNoRedirect = (url, response) => {
597
559
  const isRoot = url.pathname === base + "/" || url.pathname === base;
598
560
  if (!(isRoot || pathnameHasLocale(url.pathname, i18n.locales))) {
599
- return new Response(null, {
600
- status: 404,
601
- headers: response.headers
602
- });
561
+ return notFound(response);
603
562
  }
604
563
  return void 0;
605
564
  };
@@ -691,6 +650,14 @@ function createI18nMiddleware(i18n, base, trailingSlash, buildFormat) {
691
650
  return response;
692
651
  };
693
652
  }
653
+ function notFound(response) {
654
+ if (response.headers.get(REROUTE_DIRECTIVE_HEADER) === "no")
655
+ return response;
656
+ return new Response(null, {
657
+ status: 404,
658
+ headers: response.headers
659
+ });
660
+ }
694
661
  function localeHasntDomain(i18n, currentLocale) {
695
662
  for (const domainLocale of Object.values(i18n.domainLookupTable)) {
696
663
  if (domainLocale === currentLocale) {
@@ -918,7 +885,7 @@ function findPathItemByKey(staticPaths, params, route, logger) {
918
885
  }
919
886
 
920
887
  class Pipeline {
921
- constructor(logger, manifest, mode, renderers, resolve, serverLike, streaming, adapterName = manifest.adapterName, clientDirectives = manifest.clientDirectives, compressHTML = manifest.compressHTML, i18n = manifest.i18n, middleware = manifest.middleware, routeCache = new RouteCache(logger, mode), site = manifest.site) {
888
+ constructor(logger, manifest, mode, renderers, resolve, serverLike, streaming, adapterName = manifest.adapterName, clientDirectives = manifest.clientDirectives, inlinedScripts = manifest.inlinedScripts, compressHTML = manifest.compressHTML, i18n = manifest.i18n, middleware = manifest.middleware, routeCache = new RouteCache(logger, mode), site = manifest.site ? new URL(manifest.site) : void 0) {
922
889
  this.logger = logger;
923
890
  this.manifest = manifest;
924
891
  this.mode = mode;
@@ -928,6 +895,7 @@ class Pipeline {
928
895
  this.streaming = streaming;
929
896
  this.adapterName = adapterName;
930
897
  this.clientDirectives = clientDirectives;
898
+ this.inlinedScripts = inlinedScripts;
931
899
  this.compressHTML = compressHTML;
932
900
  this.i18n = i18n;
933
901
  this.middleware = middleware;
@@ -945,7 +913,7 @@ async function getProps(opts) {
945
913
  if (!route || route.pathname) {
946
914
  return {};
947
915
  }
948
- if (routeIsRedirect(route) || routeIsFallback(route)) {
916
+ if (routeIsRedirect(route) || routeIsFallback(route) || route.component === DEFAULT_404_COMPONENT) {
949
917
  return {};
950
918
  }
951
919
  const params = getParams(route, pathname);
@@ -1071,137 +1039,6 @@ class Slots {
1071
1039
  return outHTML;
1072
1040
  }
1073
1041
  }
1074
- function createResult(args) {
1075
- const { params, request, resolve, locals } = args;
1076
- const url = new URL(request.url);
1077
- const headers = new Headers();
1078
- headers.set("Content-Type", "text/html");
1079
- const response = {
1080
- status: args.status,
1081
- statusText: "OK",
1082
- headers
1083
- };
1084
- Object.defineProperty(response, "headers", {
1085
- value: response.headers,
1086
- enumerable: true,
1087
- writable: false
1088
- });
1089
- let cookies = args.cookies;
1090
- let preferredLocale = void 0;
1091
- let preferredLocaleList = void 0;
1092
- let currentLocale = void 0;
1093
- const result = {
1094
- styles: args.styles ?? /* @__PURE__ */ new Set(),
1095
- scripts: args.scripts ?? /* @__PURE__ */ new Set(),
1096
- links: args.links ?? /* @__PURE__ */ new Set(),
1097
- componentMetadata: args.componentMetadata ?? /* @__PURE__ */ new Map(),
1098
- renderers: args.renderers,
1099
- clientDirectives: args.clientDirectives,
1100
- compressHTML: args.compressHTML,
1101
- partial: args.partial,
1102
- pathname: args.pathname,
1103
- cookies,
1104
- /** This function returns the `Astro` faux-global */
1105
- createAstro(astroGlobal, props, slots) {
1106
- const astroSlots = new Slots(result, slots, args.logger);
1107
- const Astro = {
1108
- // @ts-expect-error
1109
- __proto__: astroGlobal,
1110
- get clientAddress() {
1111
- if (!(clientAddressSymbol$1 in request)) {
1112
- if (args.adapterName) {
1113
- throw new AstroError({
1114
- ...ClientAddressNotAvailable,
1115
- message: ClientAddressNotAvailable.message(args.adapterName)
1116
- });
1117
- } else {
1118
- throw new AstroError(StaticClientAddressNotAvailable);
1119
- }
1120
- }
1121
- return Reflect.get(request, clientAddressSymbol$1);
1122
- },
1123
- get cookies() {
1124
- if (cookies) {
1125
- return cookies;
1126
- }
1127
- cookies = new AstroCookies(request);
1128
- result.cookies = cookies;
1129
- return cookies;
1130
- },
1131
- get preferredLocale() {
1132
- if (preferredLocale) {
1133
- return preferredLocale;
1134
- }
1135
- if (args.locales) {
1136
- preferredLocale = computePreferredLocale(request, args.locales);
1137
- return preferredLocale;
1138
- }
1139
- return void 0;
1140
- },
1141
- get preferredLocaleList() {
1142
- if (preferredLocaleList) {
1143
- return preferredLocaleList;
1144
- }
1145
- if (args.locales) {
1146
- preferredLocaleList = computePreferredLocaleList(request, args.locales);
1147
- return preferredLocaleList;
1148
- }
1149
- return void 0;
1150
- },
1151
- get currentLocale() {
1152
- if (currentLocale) {
1153
- return currentLocale;
1154
- }
1155
- if (args.locales) {
1156
- currentLocale = computeCurrentLocale(
1157
- url.pathname,
1158
- args.locales,
1159
- args.strategy,
1160
- args.defaultLocale
1161
- );
1162
- if (currentLocale) {
1163
- return currentLocale;
1164
- }
1165
- }
1166
- return void 0;
1167
- },
1168
- params,
1169
- props,
1170
- locals,
1171
- request,
1172
- url,
1173
- redirect(path, status) {
1174
- if (request[responseSentSymbol$1]) {
1175
- throw new AstroError({
1176
- ...ResponseSentError
1177
- });
1178
- }
1179
- return new Response(null, {
1180
- status: status || 302,
1181
- headers: {
1182
- Location: path
1183
- }
1184
- });
1185
- },
1186
- response,
1187
- slots: astroSlots
1188
- };
1189
- return Astro;
1190
- },
1191
- resolve,
1192
- response,
1193
- _metadata: {
1194
- hasHydrationScript: false,
1195
- rendererSpecificHydrationScripts: /* @__PURE__ */ new Set(),
1196
- hasRenderedHead: false,
1197
- hasDirectives: /* @__PURE__ */ new Set(),
1198
- headInTree: false,
1199
- extraHead: [],
1200
- propagators: /* @__PURE__ */ new Set()
1201
- }
1202
- };
1203
- return result;
1204
- }
1205
1042
 
1206
1043
  class RenderContext {
1207
1044
  constructor(pipeline, locals, middleware, pathname, request, routeData, status, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url)) {
@@ -1258,21 +1095,38 @@ class RenderContext {
1258
1095
  serverLike
1259
1096
  });
1260
1097
  const apiContext = this.createAPIContext(props);
1261
- const { type } = routeData;
1262
- const lastNext = type === "endpoint" ? () => renderEndpoint(componentInstance, apiContext, serverLike, logger) : type === "redirect" ? () => renderRedirect(this) : type === "page" ? async () => {
1263
- const result = await this.createResult(componentInstance);
1264
- const response2 = await renderPage(
1265
- result,
1266
- componentInstance?.default,
1267
- props,
1268
- {},
1269
- streaming,
1270
- routeData
1271
- );
1272
- response2.headers.set(ROUTE_TYPE_HEADER, "page");
1273
- return response2;
1274
- } : type === "fallback" ? () => new Response(null, { status: 500, headers: { [ROUTE_TYPE_HEADER]: "fallback" } }) : () => {
1275
- throw new Error("Unknown type of route: " + type);
1098
+ const lastNext = async () => {
1099
+ switch (routeData.type) {
1100
+ case "endpoint":
1101
+ return renderEndpoint(componentInstance, apiContext, serverLike, logger);
1102
+ case "redirect":
1103
+ return renderRedirect(this);
1104
+ case "page": {
1105
+ const result = await this.createResult(componentInstance);
1106
+ let response2;
1107
+ try {
1108
+ response2 = await renderPage(
1109
+ result,
1110
+ componentInstance?.default,
1111
+ props,
1112
+ {},
1113
+ streaming,
1114
+ routeData
1115
+ );
1116
+ } catch (e) {
1117
+ result.cancelled = true;
1118
+ throw e;
1119
+ }
1120
+ response2.headers.set(ROUTE_TYPE_HEADER, "page");
1121
+ if (routeData.route === "/404" || routeData.route === "/500") {
1122
+ response2.headers.set(REROUTE_DIRECTIVE_HEADER, "no");
1123
+ }
1124
+ return response2;
1125
+ }
1126
+ case "fallback": {
1127
+ return new Response(null, { status: 500, headers: { [ROUTE_TYPE_HEADER]: "fallback" } });
1128
+ }
1129
+ }
1276
1130
  };
1277
1131
  const response = await callMiddleware(middleware, apiContext, lastNext);
1278
1132
  if (response.headers.get(ROUTE_TYPE_HEADER)) {
@@ -1286,38 +1140,15 @@ class RenderContext {
1286
1140
  const { cookies, params, pipeline, request, url } = this;
1287
1141
  const generator = `Astro v${ASTRO_VERSION}`;
1288
1142
  const redirect = (path, status = 302) => new Response(null, { status, headers: { Location: path } });
1289
- const site = pipeline.site ? new URL(pipeline.site) : void 0;
1290
1143
  return {
1291
1144
  cookies,
1292
- get currentLocale() {
1293
- return renderContext.computeCurrentLocale();
1294
- },
1295
- generator,
1296
- params,
1297
- get preferredLocale() {
1298
- return renderContext.computePreferredLocale();
1299
- },
1300
- get preferredLocaleList() {
1301
- return renderContext.computePreferredLocaleList();
1302
- },
1303
- props,
1304
- redirect,
1305
- request,
1306
- site,
1307
- url,
1308
1145
  get clientAddress() {
1309
- if (clientAddressSymbol$1 in request) {
1310
- return Reflect.get(request, clientAddressSymbol$1);
1311
- }
1312
- if (pipeline.adapterName) {
1313
- throw new AstroError({
1314
- ...ClientAddressNotAvailable,
1315
- message: ClientAddressNotAvailable.message(pipeline.adapterName)
1316
- });
1317
- } else {
1318
- throw new AstroError(StaticClientAddressNotAvailable);
1319
- }
1146
+ return renderContext.clientAddress();
1147
+ },
1148
+ get currentLocale() {
1149
+ return renderContext.computeCurrentLocale();
1320
1150
  },
1151
+ generator,
1321
1152
  get locals() {
1322
1153
  return renderContext.locals;
1323
1154
  },
@@ -1329,52 +1160,122 @@ class RenderContext {
1329
1160
  renderContext.locals = val;
1330
1161
  Reflect.set(request, clientLocalsSymbol, val);
1331
1162
  }
1332
- }
1163
+ },
1164
+ params,
1165
+ get preferredLocale() {
1166
+ return renderContext.computePreferredLocale();
1167
+ },
1168
+ get preferredLocaleList() {
1169
+ return renderContext.computePreferredLocaleList();
1170
+ },
1171
+ props,
1172
+ redirect,
1173
+ request,
1174
+ site: pipeline.site,
1175
+ url
1333
1176
  };
1334
1177
  }
1335
1178
  async createResult(mod) {
1336
- const { cookies, locals, params, pathname, pipeline, request, routeData, status } = this;
1337
- const {
1338
- adapterName,
1339
- clientDirectives,
1340
- compressHTML,
1341
- i18n,
1342
- manifest,
1343
- logger,
1344
- renderers,
1345
- resolve,
1346
- site,
1347
- serverLike
1348
- } = pipeline;
1179
+ const { cookies, pathname, pipeline, routeData, status } = this;
1180
+ const { clientDirectives, inlinedScripts, compressHTML, manifest, renderers, resolve } = pipeline;
1349
1181
  const { links, scripts, styles } = await pipeline.headElements(routeData);
1350
1182
  const componentMetadata = await pipeline.componentMetadata(routeData) ?? manifest.componentMetadata;
1351
- const { defaultLocale, locales, strategy } = i18n ?? {};
1183
+ const headers = new Headers({ "Content-Type": "text/html" });
1352
1184
  const partial = Boolean(mod.partial);
1353
- return createResult({
1354
- adapterName,
1185
+ const response = {
1186
+ status,
1187
+ statusText: "OK",
1188
+ get headers() {
1189
+ return headers;
1190
+ },
1191
+ // Disallow `Astro.response.headers = new Headers`
1192
+ set headers(_) {
1193
+ throw new AstroError(AstroResponseHeadersReassigned);
1194
+ }
1195
+ };
1196
+ const result = {
1197
+ cancelled: false,
1355
1198
  clientDirectives,
1199
+ inlinedScripts,
1356
1200
  componentMetadata,
1357
1201
  compressHTML,
1358
1202
  cookies,
1359
- defaultLocale,
1360
- locales,
1361
- locals,
1362
- logger,
1203
+ /** This function returns the `Astro` faux-global */
1204
+ createAstro: (astroGlobal, props, slots) => this.createAstro(result, astroGlobal, props, slots),
1363
1205
  links,
1364
- params,
1365
1206
  partial,
1366
1207
  pathname,
1367
1208
  renderers,
1368
1209
  resolve,
1369
- request,
1370
- route: routeData.route,
1371
- strategy,
1372
- site,
1210
+ response,
1373
1211
  scripts,
1374
- ssr: serverLike,
1375
- status,
1376
- styles
1377
- });
1212
+ styles,
1213
+ _metadata: {
1214
+ hasHydrationScript: false,
1215
+ rendererSpecificHydrationScripts: /* @__PURE__ */ new Set(),
1216
+ hasRenderedHead: false,
1217
+ renderedScripts: /* @__PURE__ */ new Set(),
1218
+ hasDirectives: /* @__PURE__ */ new Set(),
1219
+ headInTree: false,
1220
+ extraHead: [],
1221
+ propagators: /* @__PURE__ */ new Set()
1222
+ }
1223
+ };
1224
+ return result;
1225
+ }
1226
+ createAstro(result, astroGlobalPartial, props, slotValues) {
1227
+ const renderContext = this;
1228
+ const { cookies, locals, params, pipeline, request, url } = this;
1229
+ const { response } = result;
1230
+ const redirect = (path, status = 302) => {
1231
+ if (request[responseSentSymbol$1]) {
1232
+ throw new AstroError({
1233
+ ...ResponseSentError
1234
+ });
1235
+ }
1236
+ return new Response(null, { status, headers: { Location: path } });
1237
+ };
1238
+ const slots = new Slots(result, slotValues, pipeline.logger);
1239
+ const astroGlobalCombined = {
1240
+ ...astroGlobalPartial,
1241
+ cookies,
1242
+ get clientAddress() {
1243
+ return renderContext.clientAddress();
1244
+ },
1245
+ get currentLocale() {
1246
+ return renderContext.computeCurrentLocale();
1247
+ },
1248
+ params,
1249
+ get preferredLocale() {
1250
+ return renderContext.computePreferredLocale();
1251
+ },
1252
+ get preferredLocaleList() {
1253
+ return renderContext.computePreferredLocaleList();
1254
+ },
1255
+ props,
1256
+ locals,
1257
+ redirect,
1258
+ request,
1259
+ response,
1260
+ slots,
1261
+ site: pipeline.site,
1262
+ url
1263
+ };
1264
+ return astroGlobalCombined;
1265
+ }
1266
+ clientAddress() {
1267
+ const { pipeline, request } = this;
1268
+ if (clientAddressSymbol$1 in request) {
1269
+ return Reflect.get(request, clientAddressSymbol$1);
1270
+ }
1271
+ if (pipeline.adapterName) {
1272
+ throw new AstroError({
1273
+ ...ClientAddressNotAvailable,
1274
+ message: ClientAddressNotAvailable.message(pipeline.adapterName)
1275
+ });
1276
+ } else {
1277
+ throw new AstroError(StaticClientAddressNotAvailable);
1278
+ }
1378
1279
  }
1379
1280
  /**
1380
1281
  * API Context may be created multiple times per request, i18n data needs to be computed only once.
@@ -1390,12 +1291,8 @@ class RenderContext {
1390
1291
  if (!i18n)
1391
1292
  return;
1392
1293
  const { defaultLocale, locales, strategy } = i18n;
1393
- return this.#currentLocale ??= computeCurrentLocale(
1394
- routeData.route,
1395
- locales,
1396
- strategy,
1397
- defaultLocale
1398
- );
1294
+ const fallbackTo = strategy === "pathname-prefix-other-locales" || strategy === "domains-prefix-other-locales" ? defaultLocale : void 0;
1295
+ return this.#currentLocale ??= computeCurrentLocale(routeData.route, locales) ?? computeCurrentLocale(url.pathname, locales) ?? fallbackTo;
1399
1296
  }
1400
1297
  #preferredLocale;
1401
1298
  computePreferredLocale() {
@@ -1419,9 +1316,22 @@ class RenderContext {
1419
1316
  }
1420
1317
  }
1421
1318
 
1319
+ function getAssetsPrefix(fileExtension, assetsPrefix) {
1320
+ if (!assetsPrefix)
1321
+ return "";
1322
+ if (typeof assetsPrefix === "string")
1323
+ return assetsPrefix;
1324
+ const dotLessFileExtension = fileExtension.slice(1);
1325
+ if (assetsPrefix[dotLessFileExtension]) {
1326
+ return assetsPrefix[dotLessFileExtension];
1327
+ }
1328
+ return assetsPrefix.fallback;
1329
+ }
1330
+
1422
1331
  function createAssetLink(href, base, assetsPrefix) {
1423
1332
  if (assetsPrefix) {
1424
- return joinPaths(assetsPrefix, slash(href));
1333
+ const pf = getAssetsPrefix(fileExtension(href), assetsPrefix);
1334
+ return joinPaths(pf, slash(href));
1425
1335
  } else if (base) {
1426
1336
  return prependForwardSlash$1(joinPaths(base, slash(href)));
1427
1337
  } else {
@@ -1469,6 +1379,24 @@ function createModuleScriptElementWithSrc(src, base, assetsPrefix) {
1469
1379
  };
1470
1380
  }
1471
1381
 
1382
+ function ensure404Route(manifest) {
1383
+ if (!manifest.routes.some((route) => route.route === "/404")) {
1384
+ manifest.routes.push({
1385
+ component: DEFAULT_404_COMPONENT,
1386
+ generate: () => "",
1387
+ params: [],
1388
+ pattern: /\/404/,
1389
+ prerender: false,
1390
+ segments: [[{ content: "404", dynamic: false, spread: false }]],
1391
+ type: "page",
1392
+ route: "/404",
1393
+ fallbackRoutes: [],
1394
+ isIndex: false
1395
+ });
1396
+ }
1397
+ return manifest;
1398
+ }
1399
+
1472
1400
  function matchRoute(pathname, manifest) {
1473
1401
  const decodedPathname = decodeURI(pathname);
1474
1402
  return manifest.routes.find((route) => {
@@ -1524,9 +1452,9 @@ class App {
1524
1452
  #renderOptionsDeprecationWarningShown = false;
1525
1453
  constructor(manifest, streaming = true) {
1526
1454
  this.#manifest = manifest;
1527
- this.#manifestData = {
1455
+ this.#manifestData = ensure404Route({
1528
1456
  routes: manifest.routes.map((route) => route.routeData)
1529
- };
1457
+ });
1530
1458
  this.#baseWithoutTrailingSlash = removeTrailingForwardSlash(this.#manifest.base);
1531
1459
  this.#pipeline = this.#createPipeline(streaming);
1532
1460
  this.#adapterLogger = new AstroIntegrationLogger(
@@ -1684,7 +1612,7 @@ class App {
1684
1612
  routeData = this.match(request);
1685
1613
  }
1686
1614
  if (!routeData) {
1687
- return this.#renderError(request, { status: 404 });
1615
+ return this.#renderError(request, { locals, status: 404 });
1688
1616
  }
1689
1617
  const pathname = this.#getPathnameFromRequest(request);
1690
1618
  const defaultStatus = this.#getDefaultStatusCode(routeData, pathname);
@@ -1702,10 +1630,11 @@ class App {
1702
1630
  response = await renderContext.render(await mod.page());
1703
1631
  } catch (err) {
1704
1632
  this.#logger.error(null, err.stack || err.message || String(err));
1705
- return this.#renderError(request, { status: 500 });
1633
+ return this.#renderError(request, { locals, status: 500 });
1706
1634
  }
1707
1635
  if (REROUTABLE_STATUS_CODES.includes(response.status) && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
1708
1636
  return this.#renderError(request, {
1637
+ locals,
1709
1638
  response,
1710
1639
  status: response.status
1711
1640
  });
@@ -1749,7 +1678,7 @@ class App {
1749
1678
  * If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro).
1750
1679
  * This also handles pre-rendered /404 or /500 routes
1751
1680
  */
1752
- async #renderError(request, { status, response: originalResponse, skipMiddleware = false }) {
1681
+ async #renderError(request, { locals, status, response: originalResponse, skipMiddleware = false }) {
1753
1682
  const errorRoutePath = `/${status}${this.#manifest.trailingSlash === "always" ? "/" : ""}`;
1754
1683
  const errorRouteData = matchRoute(errorRoutePath, this.#manifestData);
1755
1684
  const url = new URL(request.url);
@@ -1767,6 +1696,7 @@ class App {
1767
1696
  const mod = await this.#getModuleForRoute(errorRouteData);
1768
1697
  try {
1769
1698
  const renderContext = RenderContext.create({
1699
+ locals,
1770
1700
  pipeline: this.#pipeline,
1771
1701
  middleware: skipMiddleware ? (_, next) => next() : void 0,
1772
1702
  pathname: this.#getPathnameFromRequest(request),
@@ -1779,6 +1709,7 @@ class App {
1779
1709
  } catch {
1780
1710
  if (skipMiddleware === false) {
1781
1711
  return this.#renderError(request, {
1712
+ locals,
1782
1713
  status,
1783
1714
  response: originalResponse,
1784
1715
  skipMiddleware: true
@@ -1836,6 +1767,12 @@ class App {
1836
1767
  return 200;
1837
1768
  }
1838
1769
  async #getModuleForRoute(route) {
1770
+ if (route.component === DEFAULT_404_COMPONENT) {
1771
+ return {
1772
+ page: async () => ({ default: () => new Response(null, { status: 404 }) }),
1773
+ renderers: []
1774
+ };
1775
+ }
1839
1776
  if (route.type === "redirect") {
1840
1777
  return RedirectSinglePageBuiltModule;
1841
1778
  } else {
@@ -2022,15 +1959,32 @@ function asyncIterableToBodyProps(iterable) {
2022
1959
  }
2023
1960
 
2024
1961
  function createAppHandler(app) {
1962
+ const als = new AsyncLocalStorage();
1963
+ const logger = app.getAdapterLogger();
1964
+ process.on("unhandledRejection", (reason) => {
1965
+ const requestUrl = als.getStore();
1966
+ logger.error(`Unhandled rejection while rendering ${requestUrl}`);
1967
+ console.error(reason);
1968
+ });
2025
1969
  return async (req, res, next, locals) => {
2026
- const request = NodeApp.createRequest(req);
1970
+ let request;
1971
+ try {
1972
+ request = NodeApp.createRequest(req);
1973
+ } catch (err) {
1974
+ res.statusCode = 500;
1975
+ res.end("Internal Server Error");
1976
+ return;
1977
+ }
2027
1978
  const routeData = app.match(request);
2028
1979
  if (routeData) {
2029
- const response = await app.render(request, {
2030
- addCookieHeader: true,
2031
- locals,
2032
- routeData
2033
- });
1980
+ const response = await als.run(
1981
+ request.url,
1982
+ () => app.render(request, {
1983
+ addCookieHeader: true,
1984
+ locals,
1985
+ routeData
1986
+ })
1987
+ );
2034
1988
  await NodeApp.writeResponse(response, res);
2035
1989
  } else if (next) {
2036
1990
  return next();
@@ -2041,6 +1995,88 @@ function createAppHandler(app) {
2041
1995
  };
2042
1996
  }
2043
1997
 
1998
+ function createMiddleware(app) {
1999
+ const handler = createAppHandler(app);
2000
+ const logger = app.getAdapterLogger();
2001
+ return async function(...args) {
2002
+ const [req, res, next, locals] = args;
2003
+ if (req instanceof Error) {
2004
+ const error = req;
2005
+ if (next) {
2006
+ return next(error);
2007
+ } else {
2008
+ throw error;
2009
+ }
2010
+ }
2011
+ try {
2012
+ await handler(req, res, next, locals);
2013
+ } catch (err) {
2014
+ logger.error(`Could not render ${req.url}`);
2015
+ console.error(err);
2016
+ if (!res.headersSent) {
2017
+ res.writeHead(500, `Server error`);
2018
+ res.end();
2019
+ }
2020
+ }
2021
+ };
2022
+ }
2023
+
2024
+ async function logListeningOn(logger, server, options) {
2025
+ await new Promise((resolve) => server.once("listening", resolve));
2026
+ const protocol = server instanceof https.Server ? "https" : "http";
2027
+ const host = getResolvedHostForHttpServer(
2028
+ process.env.HOST !== void 0 && process.env.HOST !== "" ? process.env.HOST : options.host
2029
+ );
2030
+ const { port } = server.address();
2031
+ const address = getNetworkAddress(protocol, host, port);
2032
+ if (host === void 0) {
2033
+ logger.info(
2034
+ `Server listening on
2035
+ local: ${address.local[0]}
2036
+ network: ${address.network[0]}
2037
+ `
2038
+ );
2039
+ } else {
2040
+ logger.info(`Server listening on ${address.local[0]}`);
2041
+ }
2042
+ }
2043
+ function getResolvedHostForHttpServer(host) {
2044
+ if (host === false) {
2045
+ return "localhost";
2046
+ } else if (host === true) {
2047
+ return void 0;
2048
+ } else {
2049
+ return host;
2050
+ }
2051
+ }
2052
+ const wildcardHosts = /* @__PURE__ */ new Set(["0.0.0.0", "::", "0000:0000:0000:0000:0000:0000:0000:0000"]);
2053
+ function getNetworkAddress(protocol = "http", hostname, port, base) {
2054
+ const NetworkAddress = {
2055
+ local: [],
2056
+ network: []
2057
+ };
2058
+ Object.values(os.networkInterfaces()).flatMap((nInterface) => nInterface ?? []).filter(
2059
+ (detail) => detail && detail.address && (detail.family === "IPv4" || // @ts-expect-error Node 18.0 - 18.3 returns number
2060
+ detail.family === 4)
2061
+ ).forEach((detail) => {
2062
+ let host = detail.address.replace(
2063
+ "127.0.0.1",
2064
+ hostname === void 0 || wildcardHosts.has(hostname) ? "localhost" : hostname
2065
+ );
2066
+ if (host.includes(":")) {
2067
+ host = `[${host}]`;
2068
+ }
2069
+ const url = `${protocol}://${host}:${port}${base ? base : ""}`;
2070
+ if (detail.address.includes("127.0.0.1")) {
2071
+ NetworkAddress.local.push(url);
2072
+ } else {
2073
+ NetworkAddress.network.push(url);
2074
+ }
2075
+ });
2076
+ return NetworkAddress;
2077
+ }
2078
+
2079
+ const isSubresourceRegex = /.+\.[a-z]+$/i;
2044
2080
  function createStaticHandler(app, options) {
2045
2081
  const client = resolveClientDir(options);
2046
2082
  return (req, res, ssr) => {
@@ -2073,7 +2109,7 @@ function createStaticHandler(app, options) {
2073
2109
  }
2074
2110
  break;
2075
2111
  case "always":
2076
- if (!hasSlash) {
2112
+ if (!hasSlash && !urlPath.match(isSubresourceRegex)) {
2077
2113
  pathname = urlPath + "/" + (urlQuery ? "?" + urlQuery : "");
2078
2114
  res.statusCode = 301;
2079
2115
  res.setHeader("Location", pathname);
@@ -2127,65 +2163,15 @@ function appendForwardSlash(pth) {
2127
2163
  return pth.endsWith("/") ? pth : pth + "/";
2128
2164
  }
2129
2165
 
2130
- async function logListeningOn(logger, server, options) {
2131
- await new Promise((resolve) => server.once("listening", resolve));
2132
- const protocol = server instanceof https.Server ? "https" : "http";
2133
- const host = getResolvedHostForHttpServer(
2134
- process.env.HOST !== void 0 && process.env.HOST !== "" ? process.env.HOST : options.host
2135
- );
2136
- const { port } = server.address();
2137
- const address = getNetworkAddress(protocol, host, port);
2138
- if (host === void 0) {
2139
- logger.info(
2140
- `Server listening on
2141
- local: ${address.local[0]}
2142
- network: ${address.network[0]}
2143
- `
2144
- );
2145
- } else {
2146
- logger.info(`Server listening on ${address.local[0]}`);
2166
+ const hostOptions = (host) => {
2167
+ if (typeof host === "boolean") {
2168
+ return host ? "0.0.0.0" : "localhost";
2147
2169
  }
2148
- }
2149
- function getResolvedHostForHttpServer(host) {
2150
- if (host === false) {
2151
- return "localhost";
2152
- } else if (host === true) {
2153
- return void 0;
2154
- } else {
2155
- return host;
2156
- }
2157
- }
2158
- const wildcardHosts = /* @__PURE__ */ new Set(["0.0.0.0", "::", "0000:0000:0000:0000:0000:0000:0000:0000"]);
2159
- function getNetworkAddress(protocol = "http", hostname, port, base) {
2160
- const NetworkAddress = {
2161
- local: [],
2162
- network: []
2163
- };
2164
- Object.values(os.networkInterfaces()).flatMap((nInterface) => nInterface ?? []).filter(
2165
- (detail) => detail && detail.address && (detail.family === "IPv4" || // @ts-expect-error Node 18.0 - 18.3 returns number
2166
- detail.family === 4)
2167
- ).forEach((detail) => {
2168
- let host = detail.address.replace(
2169
- "127.0.0.1",
2170
- hostname === void 0 || wildcardHosts.has(hostname) ? "localhost" : hostname
2171
- );
2172
- if (host.includes(":")) {
2173
- host = `[${host}]`;
2174
- }
2175
- const url = `${protocol}://${host}:${port}${base ? base : ""}`;
2176
- if (detail.address.includes("127.0.0.1")) {
2177
- NetworkAddress.local.push(url);
2178
- } else {
2179
- NetworkAddress.network.push(url);
2180
- }
2181
- });
2182
- return NetworkAddress;
2183
- }
2184
-
2170
+ return host;
2171
+ };
2185
2172
  function standalone(app, options) {
2186
2173
  const port = process.env.PORT ? Number(process.env.PORT) : options.port ?? 8080;
2187
- const hostOptions = typeof options.host === "boolean" ? "localhost" : options.host;
2188
- const host = process.env.HOST ?? hostOptions;
2174
+ const host = process.env.HOST ?? hostOptions(options.host);
2189
2175
  const handler = createStandaloneHandler(app, options);
2190
2176
  const server = createServer(handler, host, port);
2191
2177
  server.server.listen(port, host);
@@ -2247,32 +2233,6 @@ function createServer(listener, host, port) {
2247
2233
  };
2248
2234
  }
2249
2235
 
2250
- function createMiddleware(app) {
2251
- const handler = createAppHandler(app);
2252
- const logger = app.getAdapterLogger();
2253
- return async function(...args) {
2254
- const [req, res, next, locals] = args;
2255
- if (req instanceof Error) {
2256
- const error = req;
2257
- if (next) {
2258
- return next(error);
2259
- } else {
2260
- throw error;
2261
- }
2262
- }
2263
- try {
2264
- await handler(req, res, next, locals);
2265
- } catch (err) {
2266
- logger.error(`Could not render ${req.url}`);
2267
- console.error(err);
2268
- if (!res.headersSent) {
2269
- res.writeHead(500, `Server error`);
2270
- res.end();
2271
- }
2272
- }
2273
- };
2274
- }
2275
-
2276
2236
  apply();
2277
2237
  function createExports(manifest, options) {
2278
2238
  const app = new NodeApp(manifest);
@@ -2297,21 +2257,23 @@ const serverEntrypointModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.de
2297
2257
  start
2298
2258
  }, Symbol.toStringTag, { value: 'Module' }));
2299
2259
 
2300
- const _page0 = () => import('./chunks/node_DavlI8UF.mjs');
2301
- const _page1 = () => import('./chunks/~fallback_DQ6yB81s.mjs');
2302
- const _page2 = () => import('./chunks/index_BOh755yP.mjs');
2303
- const _page3 = () => import('./chunks/account_B7sLjsXD.mjs');
2304
- const _page4 = () => import('./chunks/index_C2hkTn-w.mjs');
2305
- const _page5 = () => import('./chunks/_page__Ex4FhYrc.mjs');
2306
- const _page6 = () => import('./chunks/_.._CvgSOb3Z.mjs');
2260
+ const _page0 = () => import('./chunks/node_Khrf-0bH.mjs');
2261
+ const _page1 = () => import('./chunks/~fallback_xH9bJF7E.mjs');
2262
+ const _page2 = () => import('./chunks/404_jTV5wvby.mjs');
2263
+ const _page3 = () => import('./chunks/index_D1o9pXka.mjs');
2264
+ const _page4 = () => import('./chunks/account_BZOa6Kmc.mjs');
2265
+ const _page5 = () => import('./chunks/index_CZ6FSUEb.mjs');
2266
+ const _page6 = () => import('./chunks/_page__BKNX3RH7.mjs');
2267
+ const _page7 = () => import('./chunks/_.._k1NruPDv.mjs');
2307
2268
  const pageMap = new Map([
2308
- ["../../node_modules/.pnpm/astro@4.4.6_@types+node@18.19.18_typescript@5.2.2/node_modules/astro/dist/assets/endpoint/node.js", _page0],
2269
+ ["../../node_modules/.pnpm/astro@4.5.12_@types+node@18.19.28_typescript@5.4.3/node_modules/astro/dist/assets/endpoint/node.js", _page0],
2309
2270
  ["src/pages/~fallback.astro", _page1],
2310
- ["src/pages/admin/index.astro", _page2],
2311
- ["src/pages/app/account.astro", _page3],
2312
- ["src/pages/app/index.astro", _page4],
2313
- ["src/pages/blog/[page].astro", _page5],
2314
- ["src/pages/[...slug].astro", _page6]
2271
+ ["src/pages/404.astro", _page2],
2272
+ ["src/pages/admin/index.astro", _page3],
2273
+ ["src/pages/app/account.astro", _page4],
2274
+ ["src/pages/app/index.astro", _page5],
2275
+ ["src/pages/blog/[page].astro", _page6],
2276
+ ["src/pages/[...slug].astro", _page7]
2315
2277
  ]);
2316
2278
 
2317
2279
  const _manifest = Object.assign(manifest, {