cloudcommerce 2.6.4 → 2.7.3
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.
- package/.github/workflows/test-apps.yml +2 -2
- package/CHANGELOG.md +30 -0
- package/action.yml +2 -2
- package/{commitlint.config.cjs → commitlint.config.mjs} +2 -2
- package/ecomplus-stores/barradoce/.gitpod.yml +1 -1
- package/ecomplus-stores/barradoce/.idx/dev.nix +5 -4
- package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
- package/ecomplus-stores/barradoce/functions/ssr/content/pages/home.json +106 -8
- package/ecomplus-stores/barradoce/functions/ssr/content/pages/products.json +3 -0
- package/ecomplus-stores/barradoce/functions/ssr/content/types.d.ts +1 -1
- package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
- package/ecomplus-stores/barradoce/functions/ssr/src/components/BuyerReviews.vue +83 -0
- package/ecomplus-stores/barradoce/functions/ssr/src/components/CheckoutPage.vue +6 -6
- package/ecomplus-stores/barradoce/functions/ssr/src/components/FooterStamps.vue +4 -4
- package/ecomplus-stores/barradoce/functions/ssr/src/components/ProductDetails.vue +36 -5
- package/ecomplus-stores/barradoce/functions/ssr/src/components/ProductShelf.vue +8 -7
- package/ecomplus-stores/barradoce/functions/ssr/src/components/ShippingCalculator.vue +1 -1
- package/ecomplus-stores/barradoce/functions/ssr/src/main/content/Sections.astro +4 -0
- package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/barradoce/package.json +2 -2
- package/package.json +5 -5
- package/packages/api/package.json +1 -1
- package/packages/apps/affiliate-program/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +1 -1
- package/packages/apps/fb-conversions/package.json +1 -1
- package/packages/apps/flash-courier/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/galaxpay/package.json +1 -1
- package/packages/apps/google-analytics/package.json +1 -1
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/mandae/package.json +1 -1
- package/packages/apps/melhor-envio/package.json +1 -1
- package/packages/apps/mercadopago/package.json +1 -1
- package/packages/apps/pagarme/package.json +1 -1
- package/packages/apps/pagarme-v5/package.json +1 -1
- package/packages/apps/paghiper/package.json +1 -1
- package/packages/apps/pix/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/apps/webhooks/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +2 -2
- package/packages/eslint/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/feeds/package.json +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/lib/lib/cron-ssr-save-views.js +7 -85
- package/packages/ssr/lib/lib/cron-ssr-save-views.js.map +1 -1
- package/packages/ssr/package.json +3 -3
- package/packages/ssr/src/lib/cron-ssr-save-views.ts +7 -91
- package/packages/storefront/dist/client/_astro/{AccountPage.B4WZaOzX.js → AccountPage.Cq0jrJE5.js} +1 -1
- package/packages/storefront/dist/client/_astro/{CartSidebar.DAGdpIcU.js → CartSidebar.DkX2BE1w.js} +1 -1
- package/packages/storefront/dist/client/_astro/{HeroSlider.Dq_9kcdU.js → HeroSlider.CZujn8cU.js} +1 -1
- package/packages/storefront/dist/client/_astro/{PitchBar.BwLlIs6F.js → PitchBar.DhcSEQPV.js} +1 -1
- package/packages/storefront/dist/client/_astro/{Prices.BgHTq5id.js → Prices.D1uItqV5.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ProductDetails.CnYNdPl5.js → ProductDetails.DDNMc2oj.js} +1 -1
- package/packages/storefront/dist/client/_astro/ProductShelf.BwRDTU-V.js +1 -0
- package/packages/storefront/dist/client/_astro/{SearchModal.DcmvABes.js → SearchModal.DgrtGsIu.js} +1 -1
- package/packages/storefront/dist/client/_astro/{SearchShowcase.C9GWwOnF.js → SearchShowcase.DggdcmcI.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ShippingCalculator.DE01D7dt.js → ShippingCalculator.B5JIh5xw.js} +1 -1
- package/packages/storefront/dist/client/_astro/{ShopHeader.Cf4t6O6z.js → ShopHeader.CIsQLhMR.js} +2 -2
- package/packages/storefront/dist/client/_astro/{_plugin-vue_export-helper.CBemkWnU.js → _plugin-vue_export-helper.3R8ooc_r.js} +3 -3
- package/packages/storefront/dist/client/_astro/{_slug_.DX_OkMX7.css → _slug_.CnXAH2gj.css} +1 -1
- package/packages/storefront/dist/client/_astro/client.mwowSQrH.js +1 -0
- package/packages/storefront/dist/client/_astro/{customer-session.CNe1heRH.js → customer-session.BAjMMoBA.js} +1 -1
- package/packages/storefront/dist/client/_astro/{format-money.DINpWB0x.js → format-money.vLicYTv9.js} +1 -1
- package/packages/storefront/dist/client/_astro/{grid-title.D4m7-g3h.js → grid-title.CxNZApGL.js} +1 -1
- package/packages/storefront/dist/client/_astro/{hoisted.EBqhuD5o.js → hoisted.B8Lw6O9a.js} +1 -1
- package/packages/storefront/dist/client/_astro/{hoisted.B2rH1xwX.js → hoisted.D4m7OTKi.js} +1 -1
- package/packages/storefront/dist/client/_astro/{hoisted.ut_nNM_H.js → hoisted.DSAg3dYh.js} +1 -1
- package/packages/storefront/dist/client/_astro/hoisted.D_dlmSy5.js +1 -0
- package/packages/storefront/dist/client/_astro/{i18n.B3skIOFg.js → i18n.BE5r_SIU.js} +1 -1
- package/packages/storefront/dist/client/_astro/{img.D5a6GzeE.js → img.CB-F9VLo.js} +1 -1
- package/packages/storefront/dist/client/_astro/{index.DBfgCyd-.js → index.BAyyMfaO.js} +1 -1
- package/packages/storefront/dist/client/_astro/{index.CFw6O-Kt.js → index.CTTHpJlV.js} +1 -1
- package/packages/storefront/dist/client/_astro/{modules-info.BHKiT6oA.js → modules-info.C6KJuGeB.js} +1 -1
- package/packages/storefront/dist/client/_astro/name.CIPngEFN.js +1 -0
- package/packages/storefront/dist/client/_astro/sf-utils.xmJHVMAX.js +13 -0
- package/packages/storefront/dist/client/_astro/{shopping-cart.D-w8Z-4p.js → shopping-cart.DGvCZWRZ.js} +1 -1
- package/packages/storefront/dist/client/_astro/{use-analytics.CQDdNgwF.js → use-analytics.BWhF_fCv.js} +1 -1
- package/packages/storefront/dist/client/_astro/{use-cms-preview.4Hq7LCmA.js → use-cms-preview.CPGTKut8.js} +1 -1
- package/packages/storefront/dist/client/_astro/{use-product-card.CQRlRsNX.js → use-product-card.C-RbCwna.js} +1 -1
- package/packages/storefront/dist/client/_astro/{use-text-value.UjCYLWjm.js → use-text-value.D4Rw7N4D.js} +1 -1
- package/packages/storefront/dist/server/chunks/{CartSidebar_BmwcZuxv.mjs → CartSidebar_lUckG0fs.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{SearchModal_BvEnUvAx.mjs → SearchModal_B2f22Mff.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{_.._DORZHe_Z.mjs → _.._CvgSOb3Z.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{_page__DU3kNewy.mjs → _page__Ex4FhYrc.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{account_CaTloREf.mjs → account_B7sLjsXD.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/astro/{assets-service_B77Hm2ue.mjs → assets-service_BOyOfKDQ.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{astro_ISB6VLqs.mjs → astro_B5LBy7PI.mjs} +8 -4
- package/packages/storefront/dist/server/chunks/{index_BTDpenpc.mjs → index_BOh755yP.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{index_D0q4ab_n.mjs → index_C2hkTn-w.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/{node_C7sdLKL4.mjs → node_DavlI8UF.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{__B4CsSrck.mjs → __RXg_hYeF.mjs} +57 -18
- package/packages/storefront/dist/server/chunks/pages/{_page__sb5Idhgp.mjs → _page__Dyte93f2.mjs} +2 -2
- package/packages/storefront/dist/server/chunks/pages/{account_iWjHfkwu.mjs → account_C66y6_Y9.mjs} +2 -2
- package/packages/storefront/dist/server/chunks/pages/{index_BZlpKBRL.mjs → index_EO1hhrt8.mjs} +2 -2
- package/packages/storefront/dist/server/chunks/pages/{node_GFu-CQ19.mjs → node_hc25rqYt.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/pages/{~fallback_C07rzeay.mjs → ~fallback_-K3esUV3.mjs} +2 -2
- package/packages/storefront/dist/server/chunks/{~fallback_YpJa9BIL.mjs → ~fallback_DQ6yB81s.mjs} +1 -1
- package/packages/storefront/dist/server/entry.mjs +625 -601
- package/packages/storefront/dist/server/{manifest_KFjAaJaC.mjs → manifest_bZVxjk3o.mjs} +3 -3
- package/packages/storefront/dist/server/renderers.mjs +1 -1
- package/packages/storefront/package.json +3 -3
- package/packages/storefront/src/lib/components/Carousel.vue +6 -0
- package/packages/storefront/src/lib/composables/use-product-shelf.ts +23 -4
- package/packages/storefront/src/lib/layouts/use-page-main.ts +6 -7
- package/packages/test-base/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/_astro/ProductShelf.kfADQTUO.js +0 -1
- package/packages/storefront/dist/client/_astro/client.CdXC84C5.js +0 -1
- package/packages/storefront/dist/client/_astro/hoisted.DBPXHTEb.js +0 -1
- package/packages/storefront/dist/client/_astro/name.BZA9xqh-.js +0 -1
- package/packages/storefront/dist/client/_astro/sf-utils.Cigv01cN.js +0 -13
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { renderers } from './renderers.mjs';
|
|
2
|
-
import { l as levels, g as getEventPrefix, L as Logger, A as AstroIntegrationLogger, manifest } from './
|
|
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';
|
|
3
5
|
import { serialize, parse } from 'cookie';
|
|
4
|
-
import { A as AstroError, R as ResponseSentError, G as GetStaticPathsRequired, p as InvalidGetStaticPathsReturn, q as InvalidGetStaticPathsEntry, t as GetStaticPathsExpectedParams, v as GetStaticPathsInvalidRouteParam, P as PageNumberParamNotFound, w as ROUTE_TYPE_HEADER, x as MiddlewareNoDataOrNextCalled, y as MiddlewareNotAResponse, 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_ISB6VLqs.mjs';
|
|
5
|
-
import { joinPaths, slash, prependForwardSlash as prependForwardSlash$1, trimSlashes, appendForwardSlash as appendForwardSlash$1, removeTrailingForwardSlash, collapseDuplicateSlashes } from '@astrojs/internal-helpers/path';
|
|
6
|
-
import 'kleur/colors';
|
|
7
6
|
import 'clsx';
|
|
7
|
+
import 'kleur/colors';
|
|
8
8
|
import http from 'node:http';
|
|
9
9
|
import https$1 from 'https';
|
|
10
10
|
import fs from 'node:fs';
|
|
@@ -18,6 +18,60 @@ import buffer from 'node:buffer';
|
|
|
18
18
|
import crypto from 'node:crypto';
|
|
19
19
|
import { onRequest } from './_noop-middleware.mjs';
|
|
20
20
|
|
|
21
|
+
function shouldAppendForwardSlash(trailingSlash, buildFormat) {
|
|
22
|
+
switch (trailingSlash) {
|
|
23
|
+
case "always":
|
|
24
|
+
return true;
|
|
25
|
+
case "never":
|
|
26
|
+
return false;
|
|
27
|
+
case "ignore": {
|
|
28
|
+
switch (buildFormat) {
|
|
29
|
+
case "directory":
|
|
30
|
+
return true;
|
|
31
|
+
case "preserve":
|
|
32
|
+
case "file":
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getPathByLocale(locale, locales) {
|
|
40
|
+
for (const loopLocale of locales) {
|
|
41
|
+
if (typeof loopLocale === "string") {
|
|
42
|
+
if (loopLocale === locale) {
|
|
43
|
+
return loopLocale;
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
for (const code of loopLocale.codes) {
|
|
47
|
+
if (code === locale) {
|
|
48
|
+
return loopLocale.path;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw new Unreachable();
|
|
54
|
+
}
|
|
55
|
+
function normalizeTheLocale(locale) {
|
|
56
|
+
return locale.replaceAll("_", "-").toLowerCase();
|
|
57
|
+
}
|
|
58
|
+
function toCodes(locales) {
|
|
59
|
+
return locales.map((loopLocale) => {
|
|
60
|
+
if (typeof loopLocale === "string") {
|
|
61
|
+
return loopLocale;
|
|
62
|
+
} else {
|
|
63
|
+
return loopLocale.codes[0];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
class Unreachable extends Error {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(
|
|
70
|
+
"Astro encountered an unexpected line of code.\nIn most cases, this is not your fault, but a bug in astro code.\nIf there isn't one already, please create an issue.\nhttps://astro.build/issues"
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
21
75
|
const DELETED_EXPIRATION = /* @__PURE__ */ new Date(0);
|
|
22
76
|
const DELETED_VALUE = "deleted";
|
|
23
77
|
const responseSentSymbol = Symbol.for("astro.responseSent");
|
|
@@ -288,328 +342,204 @@ function redirectRouteGenerate(renderContext) {
|
|
|
288
342
|
return redirect.destination;
|
|
289
343
|
}
|
|
290
344
|
|
|
291
|
-
function
|
|
292
|
-
if (
|
|
293
|
-
return
|
|
294
|
-
} else if (base) {
|
|
295
|
-
return prependForwardSlash$1(joinPaths(base, slash(href)));
|
|
296
|
-
} else {
|
|
297
|
-
return href;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function createStylesheetElement(stylesheet, base, assetsPrefix) {
|
|
301
|
-
if (stylesheet.type === "inline") {
|
|
302
|
-
return {
|
|
303
|
-
props: {},
|
|
304
|
-
children: stylesheet.content
|
|
305
|
-
};
|
|
306
|
-
} else {
|
|
307
|
-
return {
|
|
308
|
-
props: {
|
|
309
|
-
rel: "stylesheet",
|
|
310
|
-
href: createAssetLink(stylesheet.src, base, assetsPrefix)
|
|
311
|
-
},
|
|
312
|
-
children: ""
|
|
313
|
-
};
|
|
345
|
+
function parseLocale(header) {
|
|
346
|
+
if (header === "*") {
|
|
347
|
+
return [{ locale: header, qualityValue: void 0 }];
|
|
314
348
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
+
}
|
|
329
377
|
}
|
|
378
|
+
return result;
|
|
330
379
|
}
|
|
331
|
-
function
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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;
|
|
345
396
|
});
|
|
346
397
|
}
|
|
347
|
-
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
+
}
|
|
356
417
|
}
|
|
357
|
-
}
|
|
418
|
+
}
|
|
358
419
|
}
|
|
420
|
+
return result;
|
|
359
421
|
}
|
|
360
|
-
function
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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
|
+
}
|
|
369
452
|
}
|
|
453
|
+
return result;
|
|
370
454
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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
|
+
}
|
|
378
474
|
}
|
|
379
|
-
}
|
|
475
|
+
}
|
|
380
476
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
message: InvalidGetStaticPathsEntry.message(
|
|
386
|
-
Array.isArray(pathObject) ? "array" : typeof pathObject
|
|
387
|
-
)
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
if (pathObject.params === void 0 || pathObject.params === null || pathObject.params && Object.keys(pathObject.params).length === 0) {
|
|
391
|
-
throw new AstroError({
|
|
392
|
-
...GetStaticPathsExpectedParams,
|
|
393
|
-
location: {
|
|
394
|
-
file: route.component
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
for (const [key, val] of Object.entries(pathObject.params)) {
|
|
399
|
-
if (!(typeof val === "undefined" || typeof val === "string" || typeof val === "number")) {
|
|
400
|
-
logger.warn(
|
|
401
|
-
"router",
|
|
402
|
-
`getStaticPaths() returned an invalid path param: "${key}". A string, number or undefined value was expected, but got \`${JSON.stringify(
|
|
403
|
-
val
|
|
404
|
-
)}\`.`
|
|
405
|
-
);
|
|
406
|
-
}
|
|
407
|
-
if (typeof val === "string" && val === "") {
|
|
408
|
-
logger.warn(
|
|
409
|
-
"router",
|
|
410
|
-
`getStaticPaths() returned an invalid path param: "${key}". \`undefined\` expected for an optional param, but got empty string.`
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
function stringifyParams(params, route) {
|
|
418
|
-
const validatedParams = Object.entries(params).reduce((acc, next) => {
|
|
419
|
-
validateGetStaticPathsParameter(next, route.component);
|
|
420
|
-
const [key, value] = next;
|
|
421
|
-
if (value !== void 0) {
|
|
422
|
-
acc[key] = typeof value === "string" ? trimSlashes(value) : value.toString();
|
|
423
|
-
}
|
|
424
|
-
return acc;
|
|
425
|
-
}, {});
|
|
426
|
-
return JSON.stringify(route.generate(validatedParams));
|
|
477
|
+
if (routingStrategy === "pathname-prefix-other-locales" || routingStrategy === "domains-prefix-other-locales") {
|
|
478
|
+
return defaultLocale;
|
|
479
|
+
}
|
|
480
|
+
return void 0;
|
|
427
481
|
}
|
|
428
482
|
|
|
429
|
-
function
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
483
|
+
async function callMiddleware(onRequest, apiContext, responseFunction) {
|
|
484
|
+
let nextCalled = false;
|
|
485
|
+
let responseFunctionPromise = void 0;
|
|
486
|
+
const next = async () => {
|
|
487
|
+
nextCalled = true;
|
|
488
|
+
responseFunctionPromise = responseFunction();
|
|
489
|
+
return responseFunctionPromise;
|
|
490
|
+
};
|
|
491
|
+
let middlewarePromise = onRequest(apiContext, next);
|
|
492
|
+
return await Promise.resolve(middlewarePromise).then(async (value) => {
|
|
493
|
+
if (nextCalled) {
|
|
494
|
+
if (typeof value !== "undefined") {
|
|
495
|
+
if (value instanceof Response === false) {
|
|
496
|
+
throw new AstroError(MiddlewareNotAResponse);
|
|
497
|
+
}
|
|
498
|
+
return value;
|
|
499
|
+
} else {
|
|
500
|
+
if (responseFunctionPromise) {
|
|
501
|
+
return responseFunctionPromise;
|
|
502
|
+
} else {
|
|
503
|
+
throw new AstroError(MiddlewareNotAResponse);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
} else if (typeof value === "undefined") {
|
|
507
|
+
throw new AstroError(MiddlewareNoDataOrNextCalled);
|
|
508
|
+
} else if (value instanceof Response === false) {
|
|
509
|
+
throw new AstroError(MiddlewareNotAResponse);
|
|
441
510
|
} else {
|
|
442
|
-
|
|
443
|
-
...PageNumberParamNotFound,
|
|
444
|
-
message: PageNumberParamNotFound.message(paramName)
|
|
445
|
-
});
|
|
511
|
+
return value;
|
|
446
512
|
}
|
|
447
|
-
const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
|
|
448
|
-
const result = [...Array(lastPage).keys()].map((num) => {
|
|
449
|
-
const pageNum = num + 1;
|
|
450
|
-
const start = pageSize === Infinity ? 0 : (pageNum - 1) * pageSize;
|
|
451
|
-
const end = Math.min(start + pageSize, data.length);
|
|
452
|
-
const params = {
|
|
453
|
-
...additionalParams,
|
|
454
|
-
[paramName]: includesFirstPageNumber || pageNum > 1 ? String(pageNum) : void 0
|
|
455
|
-
};
|
|
456
|
-
const current = correctIndexRoute(routeMatch.generate({ ...params }));
|
|
457
|
-
const next = pageNum === lastPage ? void 0 : correctIndexRoute(routeMatch.generate({ ...params, page: String(pageNum + 1) }));
|
|
458
|
-
const prev = pageNum === 1 ? void 0 : correctIndexRoute(
|
|
459
|
-
routeMatch.generate({
|
|
460
|
-
...params,
|
|
461
|
-
page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
|
|
462
|
-
})
|
|
463
|
-
);
|
|
464
|
-
return {
|
|
465
|
-
params,
|
|
466
|
-
props: {
|
|
467
|
-
...additionalProps,
|
|
468
|
-
page: {
|
|
469
|
-
data: data.slice(start, end),
|
|
470
|
-
start,
|
|
471
|
-
end: end - 1,
|
|
472
|
-
size: pageSize,
|
|
473
|
-
total: data.length,
|
|
474
|
-
currentPage: pageNum,
|
|
475
|
-
lastPage,
|
|
476
|
-
url: { current, next, prev }
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
});
|
|
481
|
-
return result;
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
function correctIndexRoute(route) {
|
|
485
|
-
if (route === "") {
|
|
486
|
-
return "/";
|
|
487
|
-
}
|
|
488
|
-
return route;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
async function callGetStaticPaths({
|
|
492
|
-
mod,
|
|
493
|
-
route,
|
|
494
|
-
routeCache,
|
|
495
|
-
logger,
|
|
496
|
-
ssr
|
|
497
|
-
}) {
|
|
498
|
-
const cached = routeCache.get(route);
|
|
499
|
-
if (!mod) {
|
|
500
|
-
throw new Error("This is an error caused by Astro and not your code. Please file an issue.");
|
|
501
|
-
}
|
|
502
|
-
if (cached?.staticPaths) {
|
|
503
|
-
return cached.staticPaths;
|
|
504
|
-
}
|
|
505
|
-
validateDynamicRouteModule(mod, { ssr, route });
|
|
506
|
-
if (ssr && !route.prerender) {
|
|
507
|
-
const entry = Object.assign([], { keyed: /* @__PURE__ */ new Map() });
|
|
508
|
-
routeCache.set(route, { ...cached, staticPaths: entry });
|
|
509
|
-
return entry;
|
|
510
|
-
}
|
|
511
|
-
let staticPaths = [];
|
|
512
|
-
if (!mod.getStaticPaths) {
|
|
513
|
-
throw new Error("Unexpected Error.");
|
|
514
|
-
}
|
|
515
|
-
staticPaths = await mod.getStaticPaths({
|
|
516
|
-
// Q: Why the cast?
|
|
517
|
-
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
|
|
518
|
-
paginate: generatePaginateFunction(route)
|
|
519
513
|
});
|
|
520
|
-
validateGetStaticPathsResult(staticPaths, logger, route);
|
|
521
|
-
const keyedStaticPaths = staticPaths;
|
|
522
|
-
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
|
|
523
|
-
for (const sp of keyedStaticPaths) {
|
|
524
|
-
const paramsKey = stringifyParams(sp.params, route);
|
|
525
|
-
keyedStaticPaths.keyed.set(paramsKey, sp);
|
|
526
|
-
}
|
|
527
|
-
routeCache.set(route, { ...cached, staticPaths: keyedStaticPaths });
|
|
528
|
-
return keyedStaticPaths;
|
|
529
|
-
}
|
|
530
|
-
class RouteCache {
|
|
531
|
-
logger;
|
|
532
|
-
cache = {};
|
|
533
|
-
mode;
|
|
534
|
-
constructor(logger, mode = "production") {
|
|
535
|
-
this.logger = logger;
|
|
536
|
-
this.mode = mode;
|
|
537
|
-
}
|
|
538
|
-
/** Clear the cache. */
|
|
539
|
-
clearAll() {
|
|
540
|
-
this.cache = {};
|
|
541
|
-
}
|
|
542
|
-
set(route, entry) {
|
|
543
|
-
if (this.mode === "production" && this.cache[route.component]?.staticPaths) {
|
|
544
|
-
this.logger.warn(null, `Internal Warning: route cache overwritten. (${route.component})`);
|
|
545
|
-
}
|
|
546
|
-
this.cache[route.component] = entry;
|
|
547
|
-
}
|
|
548
|
-
get(route) {
|
|
549
|
-
return this.cache[route.component];
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
function findPathItemByKey(staticPaths, params, route, logger) {
|
|
553
|
-
const paramsKey = stringifyParams(params, route);
|
|
554
|
-
const matchedStaticPath = staticPaths.keyed.get(paramsKey);
|
|
555
|
-
if (matchedStaticPath) {
|
|
556
|
-
return matchedStaticPath;
|
|
557
|
-
}
|
|
558
|
-
logger.debug("router", `findPathItemByKey() - Unexpected cache miss looking for ${paramsKey}`);
|
|
559
514
|
}
|
|
560
515
|
|
|
561
|
-
function
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
return
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
case "directory":
|
|
570
|
-
return true;
|
|
571
|
-
case "preserve":
|
|
572
|
-
case "file":
|
|
573
|
-
return false;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
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;
|
|
576
524
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
function
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
for (const code of loopLocale.codes) {
|
|
587
|
-
if (code === locale) {
|
|
588
|
-
return loopLocale.path;
|
|
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();
|
|
589
534
|
}
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
}
|
|
593
|
-
throw new Unreachable();
|
|
594
|
-
}
|
|
595
|
-
function normalizeTheLocale(locale) {
|
|
596
|
-
return locale.replaceAll("_", "-").toLowerCase();
|
|
597
|
-
}
|
|
598
|
-
function toCodes(locales) {
|
|
599
|
-
return locales.map((loopLocale) => {
|
|
600
|
-
if (typeof loopLocale === "string") {
|
|
601
|
-
return loopLocale;
|
|
602
|
-
} else {
|
|
603
|
-
return loopLocale.codes[0];
|
|
535
|
+
});
|
|
536
|
+
return result;
|
|
604
537
|
}
|
|
605
538
|
});
|
|
606
539
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
"Astro encountered an unexpected line of code.\nIn most cases, this is not your fault, but a bug in astro code.\nIf there isn't one already, please create an issue.\nhttps://astro.build/issues"
|
|
611
|
-
);
|
|
612
|
-
}
|
|
540
|
+
|
|
541
|
+
function defineMiddleware(fn) {
|
|
542
|
+
return fn;
|
|
613
543
|
}
|
|
614
544
|
|
|
615
545
|
function pathnameHasLocale(pathname, locales) {
|
|
@@ -726,306 +656,288 @@ function createI18nMiddleware(i18n, base, trailingSlash, buildFormat) {
|
|
|
726
656
|
const result = prefixAlways(url, response, context);
|
|
727
657
|
if (result) {
|
|
728
658
|
return result;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
break;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
if (response.status >= 300 && fallback) {
|
|
735
|
-
const fallbackKeys = i18n.fallback ? Object.keys(i18n.fallback) : [];
|
|
736
|
-
const segments = url.pathname.split("/");
|
|
737
|
-
const urlLocale = segments.find((segment) => {
|
|
738
|
-
for (const locale of locales) {
|
|
739
|
-
if (typeof locale === "string") {
|
|
740
|
-
if (locale === segment) {
|
|
741
|
-
return true;
|
|
742
|
-
}
|
|
743
|
-
} else if (locale.path === segment) {
|
|
744
|
-
return true;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
return false;
|
|
748
|
-
});
|
|
749
|
-
if (urlLocale && fallbackKeys.includes(urlLocale)) {
|
|
750
|
-
const fallbackLocale = fallback[urlLocale];
|
|
751
|
-
const pathFallbackLocale = getPathByLocale(fallbackLocale, locales);
|
|
752
|
-
let newPathname;
|
|
753
|
-
if (pathFallbackLocale === defaultLocale && strategy === "pathname-prefix-other-locales") {
|
|
754
|
-
newPathname = url.pathname.replace(`/${urlLocale}`, ``);
|
|
755
|
-
} else {
|
|
756
|
-
newPathname = url.pathname.replace(`/${urlLocale}`, `/${pathFallbackLocale}`);
|
|
757
|
-
}
|
|
758
|
-
return context.redirect(newPathname);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
return response;
|
|
762
|
-
};
|
|
763
|
-
}
|
|
764
|
-
function localeHasntDomain(i18n, currentLocale) {
|
|
765
|
-
for (const domainLocale of Object.values(i18n.domainLookupTable)) {
|
|
766
|
-
if (domainLocale === currentLocale) {
|
|
767
|
-
return false;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
return true;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
class Pipeline {
|
|
774
|
-
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) {
|
|
775
|
-
this.logger = logger;
|
|
776
|
-
this.manifest = manifest;
|
|
777
|
-
this.mode = mode;
|
|
778
|
-
this.renderers = renderers;
|
|
779
|
-
this.resolve = resolve;
|
|
780
|
-
this.serverLike = serverLike;
|
|
781
|
-
this.streaming = streaming;
|
|
782
|
-
this.adapterName = adapterName;
|
|
783
|
-
this.clientDirectives = clientDirectives;
|
|
784
|
-
this.compressHTML = compressHTML;
|
|
785
|
-
this.i18n = i18n;
|
|
786
|
-
this.middleware = middleware;
|
|
787
|
-
this.routeCache = routeCache;
|
|
788
|
-
this.site = site;
|
|
789
|
-
this.internalMiddleware = [
|
|
790
|
-
createI18nMiddleware(i18n, manifest.base, manifest.trailingSlash, manifest.buildFormat)
|
|
791
|
-
];
|
|
792
|
-
}
|
|
793
|
-
internalMiddleware;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
class AppPipeline extends Pipeline {
|
|
797
|
-
static create({
|
|
798
|
-
logger,
|
|
799
|
-
manifest,
|
|
800
|
-
mode,
|
|
801
|
-
renderers,
|
|
802
|
-
resolve,
|
|
803
|
-
serverLike,
|
|
804
|
-
streaming
|
|
805
|
-
}) {
|
|
806
|
-
return new AppPipeline(logger, manifest, mode, renderers, resolve, serverLike, streaming);
|
|
807
|
-
}
|
|
808
|
-
headElements(routeData) {
|
|
809
|
-
const routeInfo = this.manifest.routes.find((route) => route.routeData === routeData);
|
|
810
|
-
const links = /* @__PURE__ */ new Set();
|
|
811
|
-
const scripts = /* @__PURE__ */ new Set();
|
|
812
|
-
const styles = createStylesheetElementSet(routeInfo?.styles ?? []);
|
|
813
|
-
for (const script of routeInfo?.scripts ?? []) {
|
|
814
|
-
if ("stage" in script) {
|
|
815
|
-
if (script.stage === "head-inline") {
|
|
816
|
-
scripts.add({
|
|
817
|
-
props: {},
|
|
818
|
-
children: script.children
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
} else {
|
|
822
|
-
scripts.add(createModuleScriptElement(script));
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
return { links, styles, scripts };
|
|
826
|
-
}
|
|
827
|
-
componentMetadata() {
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
async function callMiddleware(onRequest, apiContext, responseFunction) {
|
|
832
|
-
let nextCalled = false;
|
|
833
|
-
let responseFunctionPromise = void 0;
|
|
834
|
-
const next = async () => {
|
|
835
|
-
nextCalled = true;
|
|
836
|
-
responseFunctionPromise = responseFunction();
|
|
837
|
-
return responseFunctionPromise;
|
|
838
|
-
};
|
|
839
|
-
let middlewarePromise = onRequest(apiContext, next);
|
|
840
|
-
return await Promise.resolve(middlewarePromise).then(async (value) => {
|
|
841
|
-
if (nextCalled) {
|
|
842
|
-
if (typeof value !== "undefined") {
|
|
843
|
-
if (value instanceof Response === false) {
|
|
844
|
-
throw new AstroError(MiddlewareNotAResponse);
|
|
659
|
+
}
|
|
845
660
|
}
|
|
846
|
-
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (response.status >= 300 && fallback) {
|
|
665
|
+
const fallbackKeys = i18n.fallback ? Object.keys(i18n.fallback) : [];
|
|
666
|
+
const segments = url.pathname.split("/");
|
|
667
|
+
const urlLocale = segments.find((segment) => {
|
|
668
|
+
for (const locale of locales) {
|
|
669
|
+
if (typeof locale === "string") {
|
|
670
|
+
if (locale === segment) {
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
} else if (locale.path === segment) {
|
|
674
|
+
return true;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return false;
|
|
678
|
+
});
|
|
679
|
+
if (urlLocale && fallbackKeys.includes(urlLocale)) {
|
|
680
|
+
const fallbackLocale = fallback[urlLocale];
|
|
681
|
+
const pathFallbackLocale = getPathByLocale(fallbackLocale, locales);
|
|
682
|
+
let newPathname;
|
|
683
|
+
if (pathFallbackLocale === defaultLocale && strategy === "pathname-prefix-other-locales") {
|
|
684
|
+
newPathname = url.pathname.replace(`/${urlLocale}`, ``);
|
|
850
685
|
} else {
|
|
851
|
-
|
|
686
|
+
newPathname = url.pathname.replace(`/${urlLocale}`, `/${pathFallbackLocale}`);
|
|
852
687
|
}
|
|
688
|
+
return context.redirect(newPathname);
|
|
853
689
|
}
|
|
854
|
-
} else if (typeof value === "undefined") {
|
|
855
|
-
throw new AstroError(MiddlewareNoDataOrNextCalled);
|
|
856
|
-
} else if (value instanceof Response === false) {
|
|
857
|
-
throw new AstroError(MiddlewareNotAResponse);
|
|
858
|
-
} else {
|
|
859
|
-
return value;
|
|
860
690
|
}
|
|
861
|
-
|
|
691
|
+
return response;
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
function localeHasntDomain(i18n, currentLocale) {
|
|
695
|
+
for (const domainLocale of Object.values(i18n.domainLookupTable)) {
|
|
696
|
+
if (domainLocale === currentLocale) {
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return true;
|
|
862
701
|
}
|
|
863
702
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
703
|
+
const VALID_PARAM_TYPES = ["string", "number", "undefined"];
|
|
704
|
+
function validateGetStaticPathsParameter([key, value], route) {
|
|
705
|
+
if (!VALID_PARAM_TYPES.includes(typeof value)) {
|
|
706
|
+
throw new AstroError({
|
|
707
|
+
...GetStaticPathsInvalidRouteParam,
|
|
708
|
+
message: GetStaticPathsInvalidRouteParam.message(key, value, typeof value),
|
|
709
|
+
location: {
|
|
710
|
+
file: route
|
|
711
|
+
}
|
|
870
712
|
});
|
|
871
|
-
return handler;
|
|
872
713
|
}
|
|
873
|
-
return defineMiddleware((context, next) => {
|
|
874
|
-
return applyHandle(0, context);
|
|
875
|
-
function applyHandle(i, handleContext) {
|
|
876
|
-
const handle = filtered[i];
|
|
877
|
-
const result = handle(handleContext, async () => {
|
|
878
|
-
if (i < length - 1) {
|
|
879
|
-
return applyHandle(i + 1, handleContext);
|
|
880
|
-
} else {
|
|
881
|
-
return next();
|
|
882
|
-
}
|
|
883
|
-
});
|
|
884
|
-
return result;
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
714
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
715
|
+
function validateDynamicRouteModule(mod, {
|
|
716
|
+
ssr,
|
|
717
|
+
route
|
|
718
|
+
}) {
|
|
719
|
+
if ((!ssr || route.prerender) && !mod.getStaticPaths) {
|
|
720
|
+
throw new AstroError({
|
|
721
|
+
...GetStaticPathsRequired,
|
|
722
|
+
location: { file: route.component }
|
|
723
|
+
});
|
|
892
724
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
}
|
|
902
|
-
if (qualityValue && qualityValue.startsWith("q=")) {
|
|
903
|
-
const qualityValueAsFloat = Number.parseFloat(qualityValue.slice("q=".length));
|
|
904
|
-
if (Number.isNaN(qualityValueAsFloat) || qualityValueAsFloat > 1) {
|
|
905
|
-
result.push({
|
|
906
|
-
locale: localeName,
|
|
907
|
-
qualityValue: void 0
|
|
908
|
-
});
|
|
909
|
-
} else {
|
|
910
|
-
result.push({
|
|
911
|
-
locale: localeName,
|
|
912
|
-
qualityValue: qualityValueAsFloat
|
|
913
|
-
});
|
|
725
|
+
}
|
|
726
|
+
function validateGetStaticPathsResult(result, logger, route) {
|
|
727
|
+
if (!Array.isArray(result)) {
|
|
728
|
+
throw new AstroError({
|
|
729
|
+
...InvalidGetStaticPathsReturn,
|
|
730
|
+
message: InvalidGetStaticPathsReturn.message(typeof result),
|
|
731
|
+
location: {
|
|
732
|
+
file: route.component
|
|
914
733
|
}
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
result.forEach((pathObject) => {
|
|
737
|
+
if (typeof pathObject === "object" && Array.isArray(pathObject) || pathObject === null) {
|
|
738
|
+
throw new AstroError({
|
|
739
|
+
...InvalidGetStaticPathsEntry,
|
|
740
|
+
message: InvalidGetStaticPathsEntry.message(
|
|
741
|
+
Array.isArray(pathObject) ? "array" : typeof pathObject
|
|
742
|
+
)
|
|
919
743
|
});
|
|
920
744
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
return normalizedLocales.includes(normalizeTheLocale(browserLocale.locale));
|
|
745
|
+
if (pathObject.params === void 0 || pathObject.params === null || pathObject.params && Object.keys(pathObject.params).length === 0) {
|
|
746
|
+
throw new AstroError({
|
|
747
|
+
...GetStaticPathsExpectedParams,
|
|
748
|
+
location: {
|
|
749
|
+
file: route.component
|
|
750
|
+
}
|
|
751
|
+
});
|
|
929
752
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
753
|
+
for (const [key, val] of Object.entries(pathObject.params)) {
|
|
754
|
+
if (!(typeof val === "undefined" || typeof val === "string" || typeof val === "number")) {
|
|
755
|
+
logger.warn(
|
|
756
|
+
"router",
|
|
757
|
+
`getStaticPaths() returned an invalid path param: "${key}". A string, number or undefined value was expected, but got \`${JSON.stringify(
|
|
758
|
+
val
|
|
759
|
+
)}\`.`
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
if (typeof val === "string" && val === "") {
|
|
763
|
+
logger.warn(
|
|
764
|
+
"router",
|
|
765
|
+
`getStaticPaths() returned an invalid path param: "${key}". \`undefined\` expected for an optional param, but got empty string.`
|
|
766
|
+
);
|
|
937
767
|
}
|
|
938
768
|
}
|
|
939
|
-
return 0;
|
|
940
769
|
});
|
|
941
770
|
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
for (const currentLocale of locales) {
|
|
950
|
-
if (typeof currentLocale === "string") {
|
|
951
|
-
if (normalizeTheLocale(currentLocale) === normalizeTheLocale(firstResult.locale)) {
|
|
952
|
-
result = currentLocale;
|
|
953
|
-
}
|
|
954
|
-
} else {
|
|
955
|
-
for (const currentCode of currentLocale.codes) {
|
|
956
|
-
if (normalizeTheLocale(currentCode) === normalizeTheLocale(firstResult.locale)) {
|
|
957
|
-
result = currentLocale.path;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
771
|
+
|
|
772
|
+
function stringifyParams(params, route) {
|
|
773
|
+
const validatedParams = Object.entries(params).reduce((acc, next) => {
|
|
774
|
+
validateGetStaticPathsParameter(next, route.component);
|
|
775
|
+
const [key, value] = next;
|
|
776
|
+
if (value !== void 0) {
|
|
777
|
+
acc[key] = typeof value === "string" ? trimSlashes(value) : value.toString();
|
|
962
778
|
}
|
|
963
|
-
|
|
964
|
-
|
|
779
|
+
return acc;
|
|
780
|
+
}, {});
|
|
781
|
+
return JSON.stringify(route.generate(validatedParams));
|
|
965
782
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
783
|
+
|
|
784
|
+
function generatePaginateFunction(routeMatch) {
|
|
785
|
+
return function paginateUtility(data, args = {}) {
|
|
786
|
+
let { pageSize: _pageSize, params: _params, props: _props } = args;
|
|
787
|
+
const pageSize = _pageSize || 10;
|
|
788
|
+
const paramName = "page";
|
|
789
|
+
const additionalParams = _params || {};
|
|
790
|
+
const additionalProps = _props || {};
|
|
791
|
+
let includesFirstPageNumber;
|
|
792
|
+
if (routeMatch.params.includes(`...${paramName}`)) {
|
|
793
|
+
includesFirstPageNumber = false;
|
|
794
|
+
} else if (routeMatch.params.includes(`${paramName}`)) {
|
|
795
|
+
includesFirstPageNumber = true;
|
|
796
|
+
} else {
|
|
797
|
+
throw new AstroError({
|
|
798
|
+
...PageNumberParamNotFound,
|
|
799
|
+
message: PageNumberParamNotFound.message(paramName)
|
|
978
800
|
});
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
801
|
+
}
|
|
802
|
+
const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
|
|
803
|
+
const result = [...Array(lastPage).keys()].map((num) => {
|
|
804
|
+
const pageNum = num + 1;
|
|
805
|
+
const start = pageSize === Infinity ? 0 : (pageNum - 1) * pageSize;
|
|
806
|
+
const end = Math.min(start + pageSize, data.length);
|
|
807
|
+
const params = {
|
|
808
|
+
...additionalParams,
|
|
809
|
+
[paramName]: includesFirstPageNumber || pageNum > 1 ? String(pageNum) : void 0
|
|
810
|
+
};
|
|
811
|
+
const current = correctIndexRoute(routeMatch.generate({ ...params }));
|
|
812
|
+
const next = pageNum === lastPage ? void 0 : correctIndexRoute(routeMatch.generate({ ...params, page: String(pageNum + 1) }));
|
|
813
|
+
const prev = pageNum === 1 ? void 0 : correctIndexRoute(
|
|
814
|
+
routeMatch.generate({
|
|
815
|
+
...params,
|
|
816
|
+
page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
|
|
817
|
+
})
|
|
818
|
+
);
|
|
819
|
+
return {
|
|
820
|
+
params,
|
|
821
|
+
props: {
|
|
822
|
+
...additionalProps,
|
|
823
|
+
page: {
|
|
824
|
+
data: data.slice(start, end),
|
|
825
|
+
start,
|
|
826
|
+
end: end - 1,
|
|
827
|
+
size: pageSize,
|
|
828
|
+
total: data.length,
|
|
829
|
+
currentPage: pageNum,
|
|
830
|
+
lastPage,
|
|
831
|
+
url: { current, next, prev }
|
|
992
832
|
}
|
|
993
833
|
}
|
|
994
|
-
}
|
|
995
|
-
}
|
|
834
|
+
};
|
|
835
|
+
});
|
|
836
|
+
return result;
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
function correctIndexRoute(route) {
|
|
840
|
+
if (route === "") {
|
|
841
|
+
return "/";
|
|
996
842
|
}
|
|
997
|
-
return
|
|
843
|
+
return route;
|
|
998
844
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
845
|
+
|
|
846
|
+
async function callGetStaticPaths({
|
|
847
|
+
mod,
|
|
848
|
+
route,
|
|
849
|
+
routeCache,
|
|
850
|
+
logger,
|
|
851
|
+
ssr
|
|
852
|
+
}) {
|
|
853
|
+
const cached = routeCache.get(route);
|
|
854
|
+
if (!mod) {
|
|
855
|
+
throw new Error("This is an error caused by Astro and not your code. Please file an issue.");
|
|
856
|
+
}
|
|
857
|
+
if (cached?.staticPaths) {
|
|
858
|
+
return cached.staticPaths;
|
|
859
|
+
}
|
|
860
|
+
validateDynamicRouteModule(mod, { ssr, route });
|
|
861
|
+
if (ssr && !route.prerender) {
|
|
862
|
+
const entry = Object.assign([], { keyed: /* @__PURE__ */ new Map() });
|
|
863
|
+
routeCache.set(route, { ...cached, staticPaths: entry });
|
|
864
|
+
return entry;
|
|
865
|
+
}
|
|
866
|
+
let staticPaths = [];
|
|
867
|
+
if (!mod.getStaticPaths) {
|
|
868
|
+
throw new Error("Unexpected Error.");
|
|
869
|
+
}
|
|
870
|
+
staticPaths = await mod.getStaticPaths({
|
|
871
|
+
// Q: Why the cast?
|
|
872
|
+
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
|
|
873
|
+
paginate: generatePaginateFunction(route)
|
|
874
|
+
});
|
|
875
|
+
validateGetStaticPathsResult(staticPaths, logger, route);
|
|
876
|
+
const keyedStaticPaths = staticPaths;
|
|
877
|
+
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
|
|
878
|
+
for (const sp of keyedStaticPaths) {
|
|
879
|
+
const paramsKey = stringifyParams(sp.params, route);
|
|
880
|
+
keyedStaticPaths.keyed.set(paramsKey, sp);
|
|
881
|
+
}
|
|
882
|
+
routeCache.set(route, { ...cached, staticPaths: keyedStaticPaths });
|
|
883
|
+
return keyedStaticPaths;
|
|
884
|
+
}
|
|
885
|
+
class RouteCache {
|
|
886
|
+
logger;
|
|
887
|
+
cache = {};
|
|
888
|
+
mode;
|
|
889
|
+
constructor(logger, mode = "production") {
|
|
890
|
+
this.logger = logger;
|
|
891
|
+
this.mode = mode;
|
|
892
|
+
}
|
|
893
|
+
/** Clear the cache. */
|
|
894
|
+
clearAll() {
|
|
895
|
+
this.cache = {};
|
|
896
|
+
}
|
|
897
|
+
set(route, entry) {
|
|
898
|
+
const key = this.key(route);
|
|
899
|
+
if (this.mode === "production" && this.cache[key]?.staticPaths) {
|
|
900
|
+
this.logger.warn(null, `Internal Warning: route cache overwritten. (${key})`);
|
|
1019
901
|
}
|
|
902
|
+
this.cache[key] = entry;
|
|
1020
903
|
}
|
|
1021
|
-
|
|
1022
|
-
return
|
|
904
|
+
get(route) {
|
|
905
|
+
return this.cache[this.key(route)];
|
|
1023
906
|
}
|
|
1024
|
-
|
|
907
|
+
key(route) {
|
|
908
|
+
return `${route.route}_${route.component}`;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
function findPathItemByKey(staticPaths, params, route, logger) {
|
|
912
|
+
const paramsKey = stringifyParams(params, route);
|
|
913
|
+
const matchedStaticPath = staticPaths.keyed.get(paramsKey);
|
|
914
|
+
if (matchedStaticPath) {
|
|
915
|
+
return matchedStaticPath;
|
|
916
|
+
}
|
|
917
|
+
logger.debug("router", `findPathItemByKey() - Unexpected cache miss looking for ${paramsKey}`);
|
|
1025
918
|
}
|
|
1026
919
|
|
|
1027
|
-
|
|
1028
|
-
|
|
920
|
+
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) {
|
|
922
|
+
this.logger = logger;
|
|
923
|
+
this.manifest = manifest;
|
|
924
|
+
this.mode = mode;
|
|
925
|
+
this.renderers = renderers;
|
|
926
|
+
this.resolve = resolve;
|
|
927
|
+
this.serverLike = serverLike;
|
|
928
|
+
this.streaming = streaming;
|
|
929
|
+
this.adapterName = adapterName;
|
|
930
|
+
this.clientDirectives = clientDirectives;
|
|
931
|
+
this.compressHTML = compressHTML;
|
|
932
|
+
this.i18n = i18n;
|
|
933
|
+
this.middleware = middleware;
|
|
934
|
+
this.routeCache = routeCache;
|
|
935
|
+
this.site = site;
|
|
936
|
+
this.internalMiddleware = [
|
|
937
|
+
createI18nMiddleware(i18n, manifest.base, manifest.trailingSlash, manifest.buildFormat)
|
|
938
|
+
];
|
|
939
|
+
}
|
|
940
|
+
internalMiddleware;
|
|
1029
941
|
}
|
|
1030
942
|
|
|
1031
943
|
async function getProps(opts) {
|
|
@@ -1145,7 +1057,7 @@ class Slots {
|
|
|
1145
1057
|
if (expression) {
|
|
1146
1058
|
const slot = async () => typeof expression === "function" ? expression(...args) : expression;
|
|
1147
1059
|
return await renderSlotToString(result, slot).then((res) => {
|
|
1148
|
-
return res
|
|
1060
|
+
return res;
|
|
1149
1061
|
});
|
|
1150
1062
|
}
|
|
1151
1063
|
if (typeof component === "function") {
|
|
@@ -1292,7 +1204,7 @@ function createResult(args) {
|
|
|
1292
1204
|
}
|
|
1293
1205
|
|
|
1294
1206
|
class RenderContext {
|
|
1295
|
-
constructor(pipeline, locals, middleware, pathname, request, routeData, status, cookies = new AstroCookies(request), params = getParams(routeData, pathname)) {
|
|
1207
|
+
constructor(pipeline, locals, middleware, pathname, request, routeData, status, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url)) {
|
|
1296
1208
|
this.pipeline = pipeline;
|
|
1297
1209
|
this.locals = locals;
|
|
1298
1210
|
this.middleware = middleware;
|
|
@@ -1302,6 +1214,7 @@ class RenderContext {
|
|
|
1302
1214
|
this.status = status;
|
|
1303
1215
|
this.cookies = cookies;
|
|
1304
1216
|
this.params = params;
|
|
1217
|
+
this.url = url;
|
|
1305
1218
|
}
|
|
1306
1219
|
static create({
|
|
1307
1220
|
locals = {},
|
|
@@ -1370,19 +1283,23 @@ class RenderContext {
|
|
|
1370
1283
|
}
|
|
1371
1284
|
createAPIContext(props) {
|
|
1372
1285
|
const renderContext = this;
|
|
1373
|
-
const { cookies,
|
|
1374
|
-
const { currentLocale, preferredLocale, preferredLocaleList } = i18nData;
|
|
1286
|
+
const { cookies, params, pipeline, request, url } = this;
|
|
1375
1287
|
const generator = `Astro v${ASTRO_VERSION}`;
|
|
1376
1288
|
const redirect = (path, status = 302) => new Response(null, { status, headers: { Location: path } });
|
|
1377
1289
|
const site = pipeline.site ? new URL(pipeline.site) : void 0;
|
|
1378
|
-
const url = new URL(request.url);
|
|
1379
1290
|
return {
|
|
1380
1291
|
cookies,
|
|
1381
|
-
currentLocale
|
|
1292
|
+
get currentLocale() {
|
|
1293
|
+
return renderContext.computeCurrentLocale();
|
|
1294
|
+
},
|
|
1382
1295
|
generator,
|
|
1383
1296
|
params,
|
|
1384
|
-
preferredLocale
|
|
1385
|
-
|
|
1297
|
+
get preferredLocale() {
|
|
1298
|
+
return renderContext.computePreferredLocale();
|
|
1299
|
+
},
|
|
1300
|
+
get preferredLocaleList() {
|
|
1301
|
+
return renderContext.computePreferredLocaleList();
|
|
1302
|
+
},
|
|
1386
1303
|
props,
|
|
1387
1304
|
redirect,
|
|
1388
1305
|
request,
|
|
@@ -1463,29 +1380,136 @@ class RenderContext {
|
|
|
1463
1380
|
* API Context may be created multiple times per request, i18n data needs to be computed only once.
|
|
1464
1381
|
* So, it is computed and saved here on creation of the first APIContext and reused for later ones.
|
|
1465
1382
|
*/
|
|
1466
|
-
#
|
|
1467
|
-
|
|
1468
|
-
if (this.#i18nData)
|
|
1469
|
-
return this.#i18nData;
|
|
1383
|
+
#currentLocale;
|
|
1384
|
+
computeCurrentLocale() {
|
|
1470
1385
|
const {
|
|
1386
|
+
url,
|
|
1471
1387
|
pipeline: { i18n },
|
|
1472
|
-
request,
|
|
1473
1388
|
routeData
|
|
1474
1389
|
} = this;
|
|
1475
1390
|
if (!i18n)
|
|
1476
|
-
return
|
|
1477
|
-
currentLocale: void 0,
|
|
1478
|
-
preferredLocale: void 0,
|
|
1479
|
-
preferredLocaleList: void 0
|
|
1480
|
-
};
|
|
1391
|
+
return;
|
|
1481
1392
|
const { defaultLocale, locales, strategy } = i18n;
|
|
1482
|
-
return this.#
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1393
|
+
return this.#currentLocale ??= computeCurrentLocale(
|
|
1394
|
+
routeData.route,
|
|
1395
|
+
locales,
|
|
1396
|
+
strategy,
|
|
1397
|
+
defaultLocale
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
#preferredLocale;
|
|
1401
|
+
computePreferredLocale() {
|
|
1402
|
+
const {
|
|
1403
|
+
pipeline: { i18n },
|
|
1404
|
+
request
|
|
1405
|
+
} = this;
|
|
1406
|
+
if (!i18n)
|
|
1407
|
+
return;
|
|
1408
|
+
return this.#preferredLocale ??= computePreferredLocale(request, i18n.locales);
|
|
1409
|
+
}
|
|
1410
|
+
#preferredLocaleList;
|
|
1411
|
+
computePreferredLocaleList() {
|
|
1412
|
+
const {
|
|
1413
|
+
pipeline: { i18n },
|
|
1414
|
+
request
|
|
1415
|
+
} = this;
|
|
1416
|
+
if (!i18n)
|
|
1417
|
+
return;
|
|
1418
|
+
return this.#preferredLocaleList ??= computePreferredLocaleList(request, i18n.locales);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
function createAssetLink(href, base, assetsPrefix) {
|
|
1423
|
+
if (assetsPrefix) {
|
|
1424
|
+
return joinPaths(assetsPrefix, slash(href));
|
|
1425
|
+
} else if (base) {
|
|
1426
|
+
return prependForwardSlash$1(joinPaths(base, slash(href)));
|
|
1427
|
+
} else {
|
|
1428
|
+
return href;
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
function createStylesheetElement(stylesheet, base, assetsPrefix) {
|
|
1432
|
+
if (stylesheet.type === "inline") {
|
|
1433
|
+
return {
|
|
1434
|
+
props: {},
|
|
1435
|
+
children: stylesheet.content
|
|
1436
|
+
};
|
|
1437
|
+
} else {
|
|
1438
|
+
return {
|
|
1439
|
+
props: {
|
|
1440
|
+
rel: "stylesheet",
|
|
1441
|
+
href: createAssetLink(stylesheet.src, base, assetsPrefix)
|
|
1442
|
+
},
|
|
1443
|
+
children: ""
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
function createStylesheetElementSet(stylesheets, base, assetsPrefix) {
|
|
1448
|
+
return new Set(stylesheets.map((s) => createStylesheetElement(s, base, assetsPrefix)));
|
|
1449
|
+
}
|
|
1450
|
+
function createModuleScriptElement(script, base, assetsPrefix) {
|
|
1451
|
+
if (script.type === "external") {
|
|
1452
|
+
return createModuleScriptElementWithSrc(script.value, base, assetsPrefix);
|
|
1453
|
+
} else {
|
|
1454
|
+
return {
|
|
1455
|
+
props: {
|
|
1456
|
+
type: "module"
|
|
1457
|
+
},
|
|
1458
|
+
children: script.value
|
|
1486
1459
|
};
|
|
1487
1460
|
}
|
|
1488
1461
|
}
|
|
1462
|
+
function createModuleScriptElementWithSrc(src, base, assetsPrefix) {
|
|
1463
|
+
return {
|
|
1464
|
+
props: {
|
|
1465
|
+
type: "module",
|
|
1466
|
+
src: createAssetLink(src, base, assetsPrefix)
|
|
1467
|
+
},
|
|
1468
|
+
children: ""
|
|
1469
|
+
};
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
function matchRoute(pathname, manifest) {
|
|
1473
|
+
const decodedPathname = decodeURI(pathname);
|
|
1474
|
+
return manifest.routes.find((route) => {
|
|
1475
|
+
return route.pattern.test(decodedPathname) || route.fallbackRoutes.some((fallbackRoute) => fallbackRoute.pattern.test(decodedPathname));
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
class AppPipeline extends Pipeline {
|
|
1480
|
+
static create({
|
|
1481
|
+
logger,
|
|
1482
|
+
manifest,
|
|
1483
|
+
mode,
|
|
1484
|
+
renderers,
|
|
1485
|
+
resolve,
|
|
1486
|
+
serverLike,
|
|
1487
|
+
streaming
|
|
1488
|
+
}) {
|
|
1489
|
+
return new AppPipeline(logger, manifest, mode, renderers, resolve, serverLike, streaming);
|
|
1490
|
+
}
|
|
1491
|
+
headElements(routeData) {
|
|
1492
|
+
const routeInfo = this.manifest.routes.find((route) => route.routeData === routeData);
|
|
1493
|
+
const links = /* @__PURE__ */ new Set();
|
|
1494
|
+
const scripts = /* @__PURE__ */ new Set();
|
|
1495
|
+
const styles = createStylesheetElementSet(routeInfo?.styles ?? []);
|
|
1496
|
+
for (const script of routeInfo?.scripts ?? []) {
|
|
1497
|
+
if ("stage" in script) {
|
|
1498
|
+
if (script.stage === "head-inline") {
|
|
1499
|
+
scripts.add({
|
|
1500
|
+
props: {},
|
|
1501
|
+
children: script.children
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
} else {
|
|
1505
|
+
scripts.add(createModuleScriptElement(script));
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
return { links, styles, scripts };
|
|
1509
|
+
}
|
|
1510
|
+
componentMetadata() {
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1489
1513
|
|
|
1490
1514
|
class App {
|
|
1491
1515
|
#manifest;
|
|
@@ -2273,15 +2297,15 @@ const serverEntrypointModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.de
|
|
|
2273
2297
|
start
|
|
2274
2298
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
2275
2299
|
|
|
2276
|
-
const _page0 = () => import('./chunks/
|
|
2277
|
-
const _page1 = () => import('./chunks/~
|
|
2278
|
-
const _page2 = () => import('./chunks/
|
|
2279
|
-
const _page3 = () => import('./chunks/
|
|
2280
|
-
const _page4 = () => import('./chunks/
|
|
2281
|
-
const _page5 = () => import('./chunks/
|
|
2282
|
-
const _page6 = () => import('./chunks/_..
|
|
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');
|
|
2283
2307
|
const pageMap = new Map([
|
|
2284
|
-
["../../node_modules/.pnpm/astro@4.4.
|
|
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],
|
|
2285
2309
|
["src/pages/~fallback.astro", _page1],
|
|
2286
2310
|
["src/pages/admin/index.astro", _page2],
|
|
2287
2311
|
["src/pages/app/account.astro", _page3],
|