cloudcommerce 0.16.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/package.json +6 -6
- package/packages/api/package.json +1 -1
- package/packages/apps/affilate-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/infinitepay/package.json +1 -1
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/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/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 +2 -2
- package/packages/config/package.json +1 -1
- package/packages/emails/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/modules/tests/modules.test.mjs +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/lib/firebase/serve-storefront.js +86 -1
- package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
- package/packages/ssr/package.json +3 -3
- package/packages/ssr/src/firebase/serve-storefront.ts +95 -1
- package/packages/storefront/dist/client/_astro/Carousel.f39be3c0.js +1 -0
- package/packages/storefront/dist/client/_astro/HeroSlider.3d4a1d1c.js +1 -0
- package/packages/storefront/dist/client/_astro/PitchBar.c53e6d0b.js +1 -0
- package/packages/storefront/dist/client/_astro/Prices.de6df3cb.js +1 -0
- package/packages/storefront/dist/client/_astro/ProductShelf.f013b3ee.js +1 -0
- package/packages/storefront/dist/client/_astro/ShopHeader.c0ba5061.js +4 -0
- package/packages/storefront/dist/client/_astro/{_...slug_.ab554647.css → _...slug_.45bc69ca.css} +1 -1
- package/packages/storefront/dist/client/_astro/{_plugin-vue_export-helper.8870d8dc.js → _plugin-vue_export-helper.d3aaeb0d.js} +1 -1
- package/packages/storefront/dist/client/_astro/client.2d950540.js +1 -0
- package/packages/storefront/dist/client/_astro/{firebase-app.5325b6d5.js → firebase-app.84207480.js} +3 -3
- package/packages/storefront/dist/client/_astro/{format-money.3868f219.js → format-money.3b884fcb.js} +1 -1
- package/packages/storefront/dist/client/_astro/{hoisted.6aebc438.js → hoisted.9d9d7ac4.js} +1 -1
- package/packages/storefront/dist/client/_astro/img.517fec8e.js +1 -0
- package/packages/storefront/dist/client/_astro/index.33347cbd.js +1 -0
- package/packages/storefront/dist/client/_astro/{modules-info.c65d970c.js → modules-info.ad27b027.js} +1 -1
- package/packages/storefront/dist/client/_astro/preload-helper.cf010ec4.js +1 -0
- package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.00b967e0.js +1 -0
- package/packages/storefront/dist/client/sw.js +1 -1
- package/packages/storefront/dist/server/chunks/{_...5993f704.mjs → _...06f412d0.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{account@_@astro.f35b9c8d.mjs → account@_@astro.d58b2d34.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{astro.c449fda8.mjs → astro.2df8d1c5.mjs} +284 -292
- package/packages/storefront/dist/server/chunks/{endpoint@_@js.c74a899a.mjs → endpoint@_@js.ce919661.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{fallback@_@astro.50cbf3a3.mjs → fallback@_@astro.6c7c4acd.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{index@_@astro.a9e6a560.mjs → index@_@astro.8e359cb4.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{index@_@astro.2a31c91e.mjs → index@_@astro.f7e2409d.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/pages/{_...slug_.astro.116acf2f.mjs → _...slug_.astro.f0a57b8d.mjs} +51 -31
- package/packages/storefront/dist/server/chunks/pages/{account.astro.7074390b.mjs → account.astro.f630663e.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{endpoint.js.7cc60df6.mjs → endpoint.js.1d889b2f.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{fallback.astro.c8d2f06a.mjs → fallback.astro.42f81a9a.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/pages/{index.astro.bf79b1d4.mjs → index.astro.533679e1.mjs} +97 -23
- package/packages/storefront/dist/server/entry.mjs +9 -9
- package/packages/storefront/dist/server/renderers.mjs +2 -2
- package/packages/storefront/package.json +5 -5
- package/packages/storefront/src/lib/components/Carousel.vue +34 -14
- package/packages/storefront/src/lib/components/CarouselControl.vue +7 -7
- package/packages/storefront/src/lib/components/_injection-keys.ts +1 -1
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/_astro/Carousel.93c2309b.js +0 -1
- package/packages/storefront/dist/client/_astro/HeroSlider.c5b673b3.js +0 -1
- package/packages/storefront/dist/client/_astro/PitchBar.d0e3362e.js +0 -1
- package/packages/storefront/dist/client/_astro/Prices.51598206.js +0 -1
- package/packages/storefront/dist/client/_astro/Prices.5186c09f.js +0 -1
- package/packages/storefront/dist/client/_astro/ProductShelf.d90bfc6e.js +0 -1
- package/packages/storefront/dist/client/_astro/ShopHeader.e88dedbc.js +0 -4
- package/packages/storefront/dist/client/_astro/client.06720904.js +0 -1
- package/packages/storefront/dist/client/_astro/img.2ae78c70.js +0 -1
- package/packages/storefront/dist/client/_astro/index.3de006ba.js +0 -1
- package/packages/storefront/dist/client/_astro/preload-helper.101896b7.js +0 -1
- package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.7a95af90.js +0 -1
|
@@ -1145,10 +1145,10 @@ function createComponent(arg1, moduleId) {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
|
-
const ASTRO_VERSION = "2.
|
|
1148
|
+
const ASTRO_VERSION = "2.8.0";
|
|
1149
1149
|
|
|
1150
1150
|
function createAstroGlobFn() {
|
|
1151
|
-
const globHandler = (importMetaGlobResult
|
|
1151
|
+
const globHandler = (importMetaGlobResult) => {
|
|
1152
1152
|
if (typeof importMetaGlobResult === "string") {
|
|
1153
1153
|
throw new AstroError({
|
|
1154
1154
|
...AstroErrorData.AstroGlobUsedOutside,
|
|
@@ -1188,7 +1188,7 @@ function getHandlerFromModule(mod, method) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
async function renderEndpoint(mod, context, ssr) {
|
|
1190
1190
|
var _a;
|
|
1191
|
-
const { request, params
|
|
1191
|
+
const { request, params } = context;
|
|
1192
1192
|
const chosenMethod = (_a = request.method) == null ? void 0 : _a.toLowerCase();
|
|
1193
1193
|
const handler = getHandlerFromModule(mod, chosenMethod);
|
|
1194
1194
|
if (!ssr && ssr === false && chosenMethod && chosenMethod !== "get") {
|
|
@@ -1342,7 +1342,7 @@ function unescapeHTML(str) {
|
|
|
1342
1342
|
return markHTMLString(str);
|
|
1343
1343
|
}
|
|
1344
1344
|
|
|
1345
|
-
var astro_island_prebuilt_default = `(()=>{var d;{let h={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,e)=>{if(t===""||!Array.isArray(e))return e;let[
|
|
1345
|
+
var astro_island_prebuilt_default = `(()=>{var d;{let h={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,e)=>{if(t===""||!Array.isArray(e))return e;let[r,n]=e;return r in h?h[r](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var o;if(!this.hydrator||!this.isConnected)return;let e=(o=this.parentElement)==null?void 0:o.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let r=this.querySelectorAll("astro-slot"),n={},c=this.querySelectorAll("template[data-astro-template]");for(let s of c){let i=s.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[s.getAttribute("data-astro-template")||"default"]=s.innerHTML,s.remove())}for(let s of r){let i=s.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[s.getAttribute("name")||"default"]=s.innerHTML)}let l=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),a):{};await this.hydrator(this)(this.Component,l,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((e,r)=>{r.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}start(){let e=JSON.parse(this.getAttribute("opts")),r=this.getAttribute("client");if(Astro[r]===void 0){window.addEventListener(\`astro:\${r}\`,()=>this.start(),{once:!0});return}Astro[r](async()=>{let n=this.getAttribute("renderer-url"),[c,{default:l}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),o=this.getAttribute("component-export")||"default";if(!o.includes("."))this.Component=c[o];else{this.Component=c;for(let s of o.split("."))this.Component=this.Component[s]}return this.hydrator=l,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
|
|
1346
1346
|
|
|
1347
1347
|
const ISLAND_STYLES = `<style>astro-island,astro-slot,astro-static-slot{display:contents}</style>`;
|
|
1348
1348
|
function determineIfNeedsHydrationScript(result) {
|
|
@@ -1359,7 +1359,7 @@ function determinesIfNeedsDirectiveScript(result, directive) {
|
|
|
1359
1359
|
return true;
|
|
1360
1360
|
}
|
|
1361
1361
|
function getDirectiveScriptText(result, directive) {
|
|
1362
|
-
const clientDirectives = result.
|
|
1362
|
+
const clientDirectives = result.clientDirectives;
|
|
1363
1363
|
const clientDirective = clientDirectives.get(directive);
|
|
1364
1364
|
if (!clientDirective) {
|
|
1365
1365
|
throw new Error(`Unknown directive: ${directive}`);
|
|
@@ -1482,11 +1482,19 @@ function renderElement$1(name, { props: _props, children = "" }, shouldEscape =
|
|
|
1482
1482
|
}
|
|
1483
1483
|
return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
|
|
1484
1484
|
}
|
|
1485
|
+
const iteratorQueue = [];
|
|
1486
|
+
function queueIteratorBuffers(iterators) {
|
|
1487
|
+
if (iteratorQueue.length === 0) {
|
|
1488
|
+
setTimeout(() => {
|
|
1489
|
+
iteratorQueue.forEach((its) => its.forEach((it) => !it.isStarted() && it.buffer()));
|
|
1490
|
+
iteratorQueue.length = 0;
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
iteratorQueue.push(iterators);
|
|
1494
|
+
}
|
|
1485
1495
|
function bufferIterators(iterators) {
|
|
1486
1496
|
const eagerIterators = iterators.map((it) => new EagerAsyncIterableIterator(it));
|
|
1487
|
-
|
|
1488
|
-
eagerIterators.forEach((it) => !it.isStarted() && it.buffer());
|
|
1489
|
-
});
|
|
1497
|
+
queueIteratorBuffers(eagerIterators);
|
|
1490
1498
|
return eagerIterators;
|
|
1491
1499
|
}
|
|
1492
1500
|
class EagerAsyncIterableIterator {
|
|
@@ -1585,26 +1593,23 @@ function renderAllHeadContent(result) {
|
|
|
1585
1593
|
(style) => style.props.rel === "stylesheet" ? renderElement$1("link", style) : renderElement$1("style", style)
|
|
1586
1594
|
);
|
|
1587
1595
|
result.styles.clear();
|
|
1588
|
-
const scripts = Array.from(result.scripts).filter(uniqueElements).map((script
|
|
1596
|
+
const scripts = Array.from(result.scripts).filter(uniqueElements).map((script) => {
|
|
1589
1597
|
return renderElement$1("script", script, false);
|
|
1590
1598
|
});
|
|
1591
1599
|
const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement$1("link", link, false));
|
|
1592
1600
|
let content = links.join("\n") + styles.join("\n") + scripts.join("\n");
|
|
1593
|
-
if (result.extraHead.length > 0) {
|
|
1594
|
-
for (const part of result.extraHead) {
|
|
1601
|
+
if (result._metadata.extraHead.length > 0) {
|
|
1602
|
+
for (const part of result._metadata.extraHead) {
|
|
1595
1603
|
content += part;
|
|
1596
1604
|
}
|
|
1597
1605
|
}
|
|
1598
1606
|
return markHTMLString(content);
|
|
1599
1607
|
}
|
|
1600
|
-
function* renderHead(
|
|
1601
|
-
yield { type: "head"
|
|
1608
|
+
function* renderHead() {
|
|
1609
|
+
yield { type: "head" };
|
|
1602
1610
|
}
|
|
1603
|
-
function* maybeRenderHead(
|
|
1604
|
-
|
|
1605
|
-
return;
|
|
1606
|
-
}
|
|
1607
|
-
yield { type: "maybe-head", result, scope: result.scope };
|
|
1611
|
+
function* maybeRenderHead() {
|
|
1612
|
+
yield { type: "maybe-head" };
|
|
1608
1613
|
}
|
|
1609
1614
|
|
|
1610
1615
|
const headAndContentSym = Symbol.for("astro.headAndContent");
|
|
@@ -1741,8 +1746,8 @@ function validateComponentProps(props, displayName) {
|
|
|
1741
1746
|
function createAstroComponentInstance(result, displayName, factory, props, slots = {}) {
|
|
1742
1747
|
validateComponentProps(props, displayName);
|
|
1743
1748
|
const instance = new AstroComponentInstance(result, props, slots, factory);
|
|
1744
|
-
if (isAPropagatingComponent(result, factory) && !result.propagators.has(factory)) {
|
|
1745
|
-
result.propagators.set(factory, instance);
|
|
1749
|
+
if (isAPropagatingComponent(result, factory) && !result._metadata.propagators.has(factory)) {
|
|
1750
|
+
result._metadata.propagators.set(factory, instance);
|
|
1746
1751
|
}
|
|
1747
1752
|
return instance;
|
|
1748
1753
|
}
|
|
@@ -1971,7 +1976,7 @@ async function renderJSXVNode(result, vnode, skip) {
|
|
|
1971
1976
|
if (isVNode(vnode)) {
|
|
1972
1977
|
switch (true) {
|
|
1973
1978
|
case !vnode.type: {
|
|
1974
|
-
throw new Error(`Unable to render ${result.
|
|
1979
|
+
throw new Error(`Unable to render ${result.pathname} because it contains an undefined Component!
|
|
1975
1980
|
Did you forget to import the component or is it possible there is a typo?`);
|
|
1976
1981
|
}
|
|
1977
1982
|
case vnode.type === Symbol.for("astro:fragment"):
|
|
@@ -2023,7 +2028,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
2023
2028
|
try {
|
|
2024
2029
|
const output2 = await vnode.type(vnode.props ?? {});
|
|
2025
2030
|
let renderResult;
|
|
2026
|
-
if (output2
|
|
2031
|
+
if (output2 == null ? void 0 : output2[AstroJSX]) {
|
|
2027
2032
|
renderResult = await renderJSXVNode(result, output2, skip);
|
|
2028
2033
|
return renderResult;
|
|
2029
2034
|
} else if (!output2) {
|
|
@@ -2457,7 +2462,7 @@ async function renderFrameworkComponent(result, displayName, Component, _props,
|
|
|
2457
2462
|
Did you forget to import the component or is it possible there is a typo?`
|
|
2458
2463
|
);
|
|
2459
2464
|
}
|
|
2460
|
-
const { renderers, clientDirectives } = result
|
|
2465
|
+
const { renderers, clientDirectives } = result;
|
|
2461
2466
|
const metadata = {
|
|
2462
2467
|
astroStaticSlot: true,
|
|
2463
2468
|
displayName
|
|
@@ -2775,7 +2780,7 @@ const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
|
|
|
2775
2780
|
function nonAstroPageNeedsHeadInjection(pageComponent) {
|
|
2776
2781
|
return needsHeadRenderingSymbol in pageComponent && !!pageComponent[needsHeadRenderingSymbol];
|
|
2777
2782
|
}
|
|
2778
|
-
async function iterableToHTMLBytes(result, iterable,
|
|
2783
|
+
async function iterableToHTMLBytes(result, iterable, onDocTypeInjection) {
|
|
2779
2784
|
const parts = new HTMLParts();
|
|
2780
2785
|
let i = 0;
|
|
2781
2786
|
for await (const chunk of iterable) {
|
|
@@ -2783,7 +2788,7 @@ async function iterableToHTMLBytes(result, iterable, isCompressHTML, onDocTypeIn
|
|
|
2783
2788
|
if (i === 0) {
|
|
2784
2789
|
i++;
|
|
2785
2790
|
if (!/<!doctype html/i.test(String(chunk))) {
|
|
2786
|
-
parts.append(`${
|
|
2791
|
+
parts.append(`${result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n"}`, result);
|
|
2787
2792
|
if (onDocTypeInjection) {
|
|
2788
2793
|
await onDocTypeInjection(parts);
|
|
2789
2794
|
}
|
|
@@ -2795,7 +2800,7 @@ async function iterableToHTMLBytes(result, iterable, isCompressHTML, onDocTypeIn
|
|
|
2795
2800
|
return parts.toArrayBuffer();
|
|
2796
2801
|
}
|
|
2797
2802
|
async function bufferHeadContent(result) {
|
|
2798
|
-
const iterator = result.propagators.values();
|
|
2803
|
+
const iterator = result._metadata.propagators.values();
|
|
2799
2804
|
while (true) {
|
|
2800
2805
|
const { value, done } = iterator.next();
|
|
2801
2806
|
if (done) {
|
|
@@ -2803,11 +2808,11 @@ async function bufferHeadContent(result) {
|
|
|
2803
2808
|
}
|
|
2804
2809
|
const returnValue = await value.init(result);
|
|
2805
2810
|
if (isHeadAndContent(returnValue)) {
|
|
2806
|
-
result.extraHead.push(returnValue.head);
|
|
2811
|
+
result._metadata.extraHead.push(returnValue.head);
|
|
2807
2812
|
}
|
|
2808
2813
|
}
|
|
2809
2814
|
}
|
|
2810
|
-
async function renderPage$1(result, componentFactory, props, children, streaming,
|
|
2815
|
+
async function renderPage$1(result, componentFactory, props, children, streaming, route) {
|
|
2811
2816
|
var _a, _b;
|
|
2812
2817
|
if (!isAstroComponentFactory(componentFactory)) {
|
|
2813
2818
|
result._metadata.headInTree = ((_a = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _a.containsHead) ?? false;
|
|
@@ -2817,7 +2822,7 @@ async function renderPage$1(result, componentFactory, props, children, streaming
|
|
|
2817
2822
|
try {
|
|
2818
2823
|
if (nonAstroPageNeedsHeadInjection(componentFactory)) {
|
|
2819
2824
|
const parts = new HTMLParts();
|
|
2820
|
-
for await (const chunk of maybeRenderHead(
|
|
2825
|
+
for await (const chunk of maybeRenderHead()) {
|
|
2821
2826
|
parts.append(chunk, result);
|
|
2822
2827
|
}
|
|
2823
2828
|
head = parts.toString();
|
|
@@ -2842,7 +2847,7 @@ async function renderPage$1(result, componentFactory, props, children, streaming
|
|
|
2842
2847
|
}
|
|
2843
2848
|
throw e;
|
|
2844
2849
|
}
|
|
2845
|
-
const bytes = await iterableToHTMLBytes(result, output,
|
|
2850
|
+
const bytes = await iterableToHTMLBytes(result, output, async (parts) => {
|
|
2846
2851
|
parts.append(head, result);
|
|
2847
2852
|
});
|
|
2848
2853
|
return new Response(bytes, {
|
|
@@ -2874,7 +2879,7 @@ async function renderPage$1(result, componentFactory, props, children, streaming
|
|
|
2874
2879
|
if (!/<!doctype html/i.test(String(chunk))) {
|
|
2875
2880
|
controller.enqueue(
|
|
2876
2881
|
encoder.encode(
|
|
2877
|
-
`${
|
|
2882
|
+
`${result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n"}`
|
|
2878
2883
|
)
|
|
2879
2884
|
);
|
|
2880
2885
|
}
|
|
@@ -2903,7 +2908,7 @@ async function renderPage$1(result, componentFactory, props, children, streaming
|
|
|
2903
2908
|
}
|
|
2904
2909
|
});
|
|
2905
2910
|
} else {
|
|
2906
|
-
body = await iterableToHTMLBytes(result, iterable
|
|
2911
|
+
body = await iterableToHTMLBytes(result, iterable);
|
|
2907
2912
|
headers.set("Content-Length", body.byteLength.toString());
|
|
2908
2913
|
}
|
|
2909
2914
|
let response = createResponse(body, { ...init, headers });
|
|
@@ -3184,7 +3189,8 @@ class AstroCookies {
|
|
|
3184
3189
|
* @returns An object containing the cookie value as well as convenience methods for converting its value.
|
|
3185
3190
|
*/
|
|
3186
3191
|
get(key) {
|
|
3187
|
-
|
|
3192
|
+
var _a;
|
|
3193
|
+
if ((_a = this.#outgoing) == null ? void 0 : _a.has(key)) {
|
|
3188
3194
|
let [serializedValue, , isSetValue] = this.#outgoing.get(key);
|
|
3189
3195
|
if (isSetValue) {
|
|
3190
3196
|
return new AstroCookie(serializedValue);
|
|
@@ -3203,7 +3209,8 @@ class AstroCookies {
|
|
|
3203
3209
|
* @returns
|
|
3204
3210
|
*/
|
|
3205
3211
|
has(key) {
|
|
3206
|
-
|
|
3212
|
+
var _a;
|
|
3213
|
+
if ((_a = this.#outgoing) == null ? void 0 : _a.has(key)) {
|
|
3207
3214
|
let [, , isSetValue] = this.#outgoing.get(key);
|
|
3208
3215
|
return isSetValue;
|
|
3209
3216
|
}
|
|
@@ -3350,8 +3357,6 @@ if (typeof process !== "undefined") {
|
|
|
3350
3357
|
}
|
|
3351
3358
|
|
|
3352
3359
|
async function callMiddleware(logging, onRequest, apiContext, responseFunction) {
|
|
3353
|
-
new Promise((resolve) => {
|
|
3354
|
-
});
|
|
3355
3360
|
let nextCalled = false;
|
|
3356
3361
|
let responseFunctionPromise = void 0;
|
|
3357
3362
|
const next = async () => {
|
|
@@ -3449,7 +3454,7 @@ function createAPIContext({
|
|
|
3449
3454
|
});
|
|
3450
3455
|
return context;
|
|
3451
3456
|
}
|
|
3452
|
-
async function callEndpoint(mod, env, ctx,
|
|
3457
|
+
async function callEndpoint(mod, env, ctx, onRequest) {
|
|
3453
3458
|
var _a;
|
|
3454
3459
|
const context = createAPIContext({
|
|
3455
3460
|
request: ctx.request,
|
|
@@ -3481,14 +3486,14 @@ async function callEndpoint(mod, env, ctx, logging, onRequest) {
|
|
|
3481
3486
|
if (env.ssr && !((_a = ctx.route) == null ? void 0 : _a.prerender)) {
|
|
3482
3487
|
if (response.hasOwnProperty("headers")) {
|
|
3483
3488
|
warn(
|
|
3484
|
-
logging,
|
|
3489
|
+
env.logging,
|
|
3485
3490
|
"ssr",
|
|
3486
3491
|
"Setting headers is not supported when returning an object. Please return an instance of Response. See https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes for more information."
|
|
3487
3492
|
);
|
|
3488
3493
|
}
|
|
3489
3494
|
if (response.encoding) {
|
|
3490
3495
|
warn(
|
|
3491
|
-
logging,
|
|
3496
|
+
env.logging,
|
|
3492
3497
|
"ssr",
|
|
3493
3498
|
"`encoding` is ignored in SSR. To return a charset other than UTF-8, please return an instance of Response. See https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes for more information."
|
|
3494
3499
|
);
|
|
@@ -3682,6 +3687,230 @@ function stringifyParams(params, routeComponent) {
|
|
|
3682
3687
|
return JSON.stringify(validatedParams, Object.keys(params).sort());
|
|
3683
3688
|
}
|
|
3684
3689
|
|
|
3690
|
+
function generatePaginateFunction(routeMatch) {
|
|
3691
|
+
return function paginateUtility(data, args = {}) {
|
|
3692
|
+
let { pageSize: _pageSize, params: _params, props: _props } = args;
|
|
3693
|
+
const pageSize = _pageSize || 10;
|
|
3694
|
+
const paramName = "page";
|
|
3695
|
+
const additionalParams = _params || {};
|
|
3696
|
+
const additionalProps = _props || {};
|
|
3697
|
+
let includesFirstPageNumber;
|
|
3698
|
+
if (routeMatch.params.includes(`...${paramName}`)) {
|
|
3699
|
+
includesFirstPageNumber = false;
|
|
3700
|
+
} else if (routeMatch.params.includes(`${paramName}`)) {
|
|
3701
|
+
includesFirstPageNumber = true;
|
|
3702
|
+
} else {
|
|
3703
|
+
throw new AstroError({
|
|
3704
|
+
...AstroErrorData.PageNumberParamNotFound,
|
|
3705
|
+
message: AstroErrorData.PageNumberParamNotFound.message(paramName)
|
|
3706
|
+
});
|
|
3707
|
+
}
|
|
3708
|
+
const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
|
|
3709
|
+
const result = [...Array(lastPage).keys()].map((num) => {
|
|
3710
|
+
const pageNum = num + 1;
|
|
3711
|
+
const start = pageSize === Infinity ? 0 : (pageNum - 1) * pageSize;
|
|
3712
|
+
const end = Math.min(start + pageSize, data.length);
|
|
3713
|
+
const params = {
|
|
3714
|
+
...additionalParams,
|
|
3715
|
+
[paramName]: includesFirstPageNumber || pageNum > 1 ? String(pageNum) : void 0
|
|
3716
|
+
};
|
|
3717
|
+
const current = correctIndexRoute(routeMatch.generate({ ...params }));
|
|
3718
|
+
const next = pageNum === lastPage ? void 0 : correctIndexRoute(routeMatch.generate({ ...params, page: String(pageNum + 1) }));
|
|
3719
|
+
const prev = pageNum === 1 ? void 0 : correctIndexRoute(
|
|
3720
|
+
routeMatch.generate({
|
|
3721
|
+
...params,
|
|
3722
|
+
page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
|
|
3723
|
+
})
|
|
3724
|
+
);
|
|
3725
|
+
return {
|
|
3726
|
+
params,
|
|
3727
|
+
props: {
|
|
3728
|
+
...additionalProps,
|
|
3729
|
+
page: {
|
|
3730
|
+
data: data.slice(start, end),
|
|
3731
|
+
start,
|
|
3732
|
+
end: end - 1,
|
|
3733
|
+
size: pageSize,
|
|
3734
|
+
total: data.length,
|
|
3735
|
+
currentPage: pageNum,
|
|
3736
|
+
lastPage,
|
|
3737
|
+
url: { current, next, prev }
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
};
|
|
3741
|
+
});
|
|
3742
|
+
return result;
|
|
3743
|
+
};
|
|
3744
|
+
}
|
|
3745
|
+
function correctIndexRoute(route) {
|
|
3746
|
+
if (route === "") {
|
|
3747
|
+
return "/";
|
|
3748
|
+
}
|
|
3749
|
+
return route;
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3752
|
+
async function callGetStaticPaths({
|
|
3753
|
+
mod,
|
|
3754
|
+
route,
|
|
3755
|
+
routeCache,
|
|
3756
|
+
isValidate,
|
|
3757
|
+
logging,
|
|
3758
|
+
ssr
|
|
3759
|
+
}) {
|
|
3760
|
+
const cached = routeCache.get(route);
|
|
3761
|
+
if (cached == null ? void 0 : cached.staticPaths)
|
|
3762
|
+
return cached.staticPaths;
|
|
3763
|
+
validateDynamicRouteModule(mod, { ssr, logging, route });
|
|
3764
|
+
if (ssr && !route.prerender) {
|
|
3765
|
+
const entry = Object.assign([], { keyed: /* @__PURE__ */ new Map() });
|
|
3766
|
+
routeCache.set(route, { ...cached, staticPaths: entry });
|
|
3767
|
+
return entry;
|
|
3768
|
+
}
|
|
3769
|
+
if (!mod.getStaticPaths) {
|
|
3770
|
+
throw new Error("Unexpected Error.");
|
|
3771
|
+
}
|
|
3772
|
+
let staticPaths = [];
|
|
3773
|
+
staticPaths = await mod.getStaticPaths({
|
|
3774
|
+
paginate: generatePaginateFunction(route),
|
|
3775
|
+
rss() {
|
|
3776
|
+
throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
|
|
3777
|
+
}
|
|
3778
|
+
});
|
|
3779
|
+
if (Array.isArray(staticPaths)) {
|
|
3780
|
+
staticPaths = staticPaths.flat();
|
|
3781
|
+
}
|
|
3782
|
+
if (isValidate) {
|
|
3783
|
+
validateGetStaticPathsResult(staticPaths, logging, route);
|
|
3784
|
+
}
|
|
3785
|
+
const keyedStaticPaths = staticPaths;
|
|
3786
|
+
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
|
|
3787
|
+
for (const sp of keyedStaticPaths) {
|
|
3788
|
+
const paramsKey = stringifyParams(sp.params, route.component);
|
|
3789
|
+
keyedStaticPaths.keyed.set(paramsKey, sp);
|
|
3790
|
+
}
|
|
3791
|
+
routeCache.set(route, { ...cached, staticPaths: keyedStaticPaths });
|
|
3792
|
+
return keyedStaticPaths;
|
|
3793
|
+
}
|
|
3794
|
+
class RouteCache {
|
|
3795
|
+
constructor(logging, mode = "production") {
|
|
3796
|
+
this.cache = {};
|
|
3797
|
+
this.logging = logging;
|
|
3798
|
+
this.mode = mode;
|
|
3799
|
+
}
|
|
3800
|
+
/** Clear the cache. */
|
|
3801
|
+
clearAll() {
|
|
3802
|
+
this.cache = {};
|
|
3803
|
+
}
|
|
3804
|
+
set(route, entry) {
|
|
3805
|
+
var _a;
|
|
3806
|
+
if (this.mode === "production" && ((_a = this.cache[route.component]) == null ? void 0 : _a.staticPaths)) {
|
|
3807
|
+
warn(
|
|
3808
|
+
this.logging,
|
|
3809
|
+
"routeCache",
|
|
3810
|
+
`Internal Warning: route cache overwritten. (${route.component})`
|
|
3811
|
+
);
|
|
3812
|
+
}
|
|
3813
|
+
this.cache[route.component] = entry;
|
|
3814
|
+
}
|
|
3815
|
+
get(route) {
|
|
3816
|
+
return this.cache[route.component];
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
function findPathItemByKey(staticPaths, params, route) {
|
|
3820
|
+
const paramsKey = stringifyParams(params, route.component);
|
|
3821
|
+
const matchedStaticPath = staticPaths.keyed.get(paramsKey);
|
|
3822
|
+
if (matchedStaticPath) {
|
|
3823
|
+
return matchedStaticPath;
|
|
3824
|
+
}
|
|
3825
|
+
debug("findPathItemByKey", `Unexpected cache miss looking for ${paramsKey}`);
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
async function getParamsAndProps(opts) {
|
|
3829
|
+
const { logging, mod, route, routeCache, pathname, ssr } = opts;
|
|
3830
|
+
if (!route || route.pathname) {
|
|
3831
|
+
return [{}, {}];
|
|
3832
|
+
}
|
|
3833
|
+
const params = getRouteParams(route, pathname) ?? {};
|
|
3834
|
+
validatePrerenderEndpointCollision(route, mod, params);
|
|
3835
|
+
const staticPaths = await callGetStaticPaths({
|
|
3836
|
+
mod,
|
|
3837
|
+
route,
|
|
3838
|
+
routeCache,
|
|
3839
|
+
isValidate: true,
|
|
3840
|
+
logging,
|
|
3841
|
+
ssr
|
|
3842
|
+
});
|
|
3843
|
+
const matchedStaticPath = findPathItemByKey(staticPaths, params, route);
|
|
3844
|
+
if (!matchedStaticPath && (ssr ? route.prerender : true)) {
|
|
3845
|
+
throw new AstroError({
|
|
3846
|
+
...AstroErrorData.NoMatchingStaticPathFound,
|
|
3847
|
+
message: AstroErrorData.NoMatchingStaticPathFound.message(pathname),
|
|
3848
|
+
hint: AstroErrorData.NoMatchingStaticPathFound.hint([route.component])
|
|
3849
|
+
});
|
|
3850
|
+
}
|
|
3851
|
+
const props = (matchedStaticPath == null ? void 0 : matchedStaticPath.props) ? { ...matchedStaticPath.props } : {};
|
|
3852
|
+
return [params, props];
|
|
3853
|
+
}
|
|
3854
|
+
function getRouteParams(route, pathname) {
|
|
3855
|
+
if (route.params.length) {
|
|
3856
|
+
const paramsMatch = route.pattern.exec(decodeURIComponent(pathname));
|
|
3857
|
+
if (paramsMatch) {
|
|
3858
|
+
return getParams(route.params)(paramsMatch);
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
}
|
|
3862
|
+
function validatePrerenderEndpointCollision(route, mod, params) {
|
|
3863
|
+
if (route.type === "endpoint" && mod.getStaticPaths) {
|
|
3864
|
+
const lastSegment = route.segments[route.segments.length - 1];
|
|
3865
|
+
const paramValues = Object.values(params);
|
|
3866
|
+
const lastParam = paramValues[paramValues.length - 1];
|
|
3867
|
+
if (lastSegment.length === 1 && lastSegment[0].dynamic && lastParam === void 0) {
|
|
3868
|
+
throw new AstroError({
|
|
3869
|
+
...AstroErrorData.PrerenderDynamicEndpointPathCollide,
|
|
3870
|
+
message: AstroErrorData.PrerenderDynamicEndpointPathCollide.message(route.route),
|
|
3871
|
+
hint: AstroErrorData.PrerenderDynamicEndpointPathCollide.hint(route.component),
|
|
3872
|
+
location: {
|
|
3873
|
+
file: route.component
|
|
3874
|
+
}
|
|
3875
|
+
});
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
const clientLocalsSymbol$1 = Symbol.for("astro.locals");
|
|
3881
|
+
async function createRenderContext(options) {
|
|
3882
|
+
const request = options.request;
|
|
3883
|
+
const pathname = options.pathname ?? new URL(request.url).pathname;
|
|
3884
|
+
const [params, props] = await getParamsAndProps({
|
|
3885
|
+
mod: options.mod,
|
|
3886
|
+
route: options.route,
|
|
3887
|
+
routeCache: options.env.routeCache,
|
|
3888
|
+
pathname,
|
|
3889
|
+
logging: options.env.logging,
|
|
3890
|
+
ssr: options.env.ssr
|
|
3891
|
+
});
|
|
3892
|
+
const context = {
|
|
3893
|
+
...options,
|
|
3894
|
+
pathname,
|
|
3895
|
+
params,
|
|
3896
|
+
props
|
|
3897
|
+
};
|
|
3898
|
+
Object.defineProperty(context, "locals", {
|
|
3899
|
+
enumerable: true,
|
|
3900
|
+
get() {
|
|
3901
|
+
return Reflect.get(request, clientLocalsSymbol$1);
|
|
3902
|
+
},
|
|
3903
|
+
set(val) {
|
|
3904
|
+
if (typeof val !== "object") {
|
|
3905
|
+
throw new AstroError(AstroErrorData.LocalsNotAnObject);
|
|
3906
|
+
} else {
|
|
3907
|
+
Reflect.set(request, clientLocalsSymbol$1, val);
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
});
|
|
3911
|
+
return context;
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3685
3914
|
const clientAddressSymbol$1 = Symbol.for("astro.clientAddress");
|
|
3686
3915
|
const responseSentSymbol$1 = Symbol.for("astro.responseSent");
|
|
3687
3916
|
function getFunctionExpression(slot) {
|
|
@@ -3755,7 +3984,7 @@ class Slots {
|
|
|
3755
3984
|
}
|
|
3756
3985
|
let renderMarkdown = null;
|
|
3757
3986
|
function createResult(args) {
|
|
3758
|
-
const { markdown, params,
|
|
3987
|
+
const { markdown, params, request, resolve, locals } = args;
|
|
3759
3988
|
const url = new URL(request.url);
|
|
3760
3989
|
const headers = new Headers();
|
|
3761
3990
|
headers.set("Content-Type", "text/html");
|
|
@@ -3770,15 +3999,15 @@ function createResult(args) {
|
|
|
3770
3999
|
writable: false
|
|
3771
4000
|
});
|
|
3772
4001
|
let cookies = args.cookies;
|
|
3773
|
-
let componentMetadata = args.componentMetadata ?? /* @__PURE__ */ new Map();
|
|
3774
4002
|
const result = {
|
|
3775
4003
|
styles: args.styles ?? /* @__PURE__ */ new Set(),
|
|
3776
4004
|
scripts: args.scripts ?? /* @__PURE__ */ new Set(),
|
|
3777
4005
|
links: args.links ?? /* @__PURE__ */ new Set(),
|
|
3778
|
-
componentMetadata,
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
4006
|
+
componentMetadata: args.componentMetadata ?? /* @__PURE__ */ new Map(),
|
|
4007
|
+
renderers: args.renderers,
|
|
4008
|
+
clientDirectives: args.clientDirectives,
|
|
4009
|
+
compressHTML: args.compressHTML,
|
|
4010
|
+
pathname: args.pathname,
|
|
3782
4011
|
cookies,
|
|
3783
4012
|
/** This function returns the `Astro` faux-global */
|
|
3784
4013
|
createAstro(astroGlobal, props, slots) {
|
|
@@ -3849,212 +4078,20 @@ function createResult(args) {
|
|
|
3849
4078
|
return Astro;
|
|
3850
4079
|
},
|
|
3851
4080
|
resolve,
|
|
4081
|
+
response,
|
|
3852
4082
|
_metadata: {
|
|
3853
|
-
renderers,
|
|
3854
|
-
pathname,
|
|
3855
4083
|
hasHydrationScript: false,
|
|
3856
4084
|
hasRenderedHead: false,
|
|
3857
4085
|
hasDirectives: /* @__PURE__ */ new Set(),
|
|
3858
4086
|
headInTree: false,
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
response
|
|
3862
|
-
};
|
|
3863
|
-
return result;
|
|
3864
|
-
}
|
|
3865
|
-
|
|
3866
|
-
function generatePaginateFunction(routeMatch) {
|
|
3867
|
-
return function paginateUtility(data, args = {}) {
|
|
3868
|
-
let { pageSize: _pageSize, params: _params, props: _props } = args;
|
|
3869
|
-
const pageSize = _pageSize || 10;
|
|
3870
|
-
const paramName = "page";
|
|
3871
|
-
const additionalParams = _params || {};
|
|
3872
|
-
const additionalProps = _props || {};
|
|
3873
|
-
let includesFirstPageNumber;
|
|
3874
|
-
if (routeMatch.params.includes(`...${paramName}`)) {
|
|
3875
|
-
includesFirstPageNumber = false;
|
|
3876
|
-
} else if (routeMatch.params.includes(`${paramName}`)) {
|
|
3877
|
-
includesFirstPageNumber = true;
|
|
3878
|
-
} else {
|
|
3879
|
-
throw new AstroError({
|
|
3880
|
-
...AstroErrorData.PageNumberParamNotFound,
|
|
3881
|
-
message: AstroErrorData.PageNumberParamNotFound.message(paramName)
|
|
3882
|
-
});
|
|
4087
|
+
extraHead: [],
|
|
4088
|
+
propagators: /* @__PURE__ */ new Map()
|
|
3883
4089
|
}
|
|
3884
|
-
const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
|
|
3885
|
-
const result = [...Array(lastPage).keys()].map((num) => {
|
|
3886
|
-
const pageNum = num + 1;
|
|
3887
|
-
const start = pageSize === Infinity ? 0 : (pageNum - 1) * pageSize;
|
|
3888
|
-
const end = Math.min(start + pageSize, data.length);
|
|
3889
|
-
const params = {
|
|
3890
|
-
...additionalParams,
|
|
3891
|
-
[paramName]: includesFirstPageNumber || pageNum > 1 ? String(pageNum) : void 0
|
|
3892
|
-
};
|
|
3893
|
-
const current = correctIndexRoute(routeMatch.generate({ ...params }));
|
|
3894
|
-
const next = pageNum === lastPage ? void 0 : correctIndexRoute(routeMatch.generate({ ...params, page: String(pageNum + 1) }));
|
|
3895
|
-
const prev = pageNum === 1 ? void 0 : correctIndexRoute(
|
|
3896
|
-
routeMatch.generate({
|
|
3897
|
-
...params,
|
|
3898
|
-
page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
|
|
3899
|
-
})
|
|
3900
|
-
);
|
|
3901
|
-
return {
|
|
3902
|
-
params,
|
|
3903
|
-
props: {
|
|
3904
|
-
...additionalProps,
|
|
3905
|
-
page: {
|
|
3906
|
-
data: data.slice(start, end),
|
|
3907
|
-
start,
|
|
3908
|
-
end: end - 1,
|
|
3909
|
-
size: pageSize,
|
|
3910
|
-
total: data.length,
|
|
3911
|
-
currentPage: pageNum,
|
|
3912
|
-
lastPage,
|
|
3913
|
-
url: { current, next, prev }
|
|
3914
|
-
}
|
|
3915
|
-
}
|
|
3916
|
-
};
|
|
3917
|
-
});
|
|
3918
|
-
return result;
|
|
3919
4090
|
};
|
|
3920
|
-
|
|
3921
|
-
function correctIndexRoute(route) {
|
|
3922
|
-
if (route === "") {
|
|
3923
|
-
return "/";
|
|
3924
|
-
}
|
|
3925
|
-
return route;
|
|
3926
|
-
}
|
|
3927
|
-
|
|
3928
|
-
async function callGetStaticPaths({
|
|
3929
|
-
isValidate,
|
|
3930
|
-
logging,
|
|
3931
|
-
mod,
|
|
3932
|
-
route,
|
|
3933
|
-
ssr
|
|
3934
|
-
}) {
|
|
3935
|
-
validateDynamicRouteModule(mod, { ssr, logging, route });
|
|
3936
|
-
if (ssr && !route.prerender) {
|
|
3937
|
-
return { staticPaths: Object.assign([], { keyed: /* @__PURE__ */ new Map() }) };
|
|
3938
|
-
}
|
|
3939
|
-
if (!mod.getStaticPaths) {
|
|
3940
|
-
throw new Error("Unexpected Error.");
|
|
3941
|
-
}
|
|
3942
|
-
let staticPaths = [];
|
|
3943
|
-
staticPaths = await mod.getStaticPaths({
|
|
3944
|
-
paginate: generatePaginateFunction(route),
|
|
3945
|
-
rss() {
|
|
3946
|
-
throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
|
|
3947
|
-
}
|
|
3948
|
-
});
|
|
3949
|
-
if (Array.isArray(staticPaths)) {
|
|
3950
|
-
staticPaths = staticPaths.flat();
|
|
3951
|
-
}
|
|
3952
|
-
if (isValidate) {
|
|
3953
|
-
validateGetStaticPathsResult(staticPaths, logging, route);
|
|
3954
|
-
}
|
|
3955
|
-
const keyedStaticPaths = staticPaths;
|
|
3956
|
-
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
|
|
3957
|
-
for (const sp of keyedStaticPaths) {
|
|
3958
|
-
const paramsKey = stringifyParams(sp.params, route.component);
|
|
3959
|
-
keyedStaticPaths.keyed.set(paramsKey, sp);
|
|
3960
|
-
}
|
|
3961
|
-
return {
|
|
3962
|
-
staticPaths: keyedStaticPaths
|
|
3963
|
-
};
|
|
3964
|
-
}
|
|
3965
|
-
class RouteCache {
|
|
3966
|
-
constructor(logging, mode = "production") {
|
|
3967
|
-
this.cache = {};
|
|
3968
|
-
this.logging = logging;
|
|
3969
|
-
this.mode = mode;
|
|
3970
|
-
}
|
|
3971
|
-
/** Clear the cache. */
|
|
3972
|
-
clearAll() {
|
|
3973
|
-
this.cache = {};
|
|
3974
|
-
}
|
|
3975
|
-
set(route, entry) {
|
|
3976
|
-
if (this.mode === "production" && this.cache[route.component]) {
|
|
3977
|
-
warn(
|
|
3978
|
-
this.logging,
|
|
3979
|
-
"routeCache",
|
|
3980
|
-
`Internal Warning: route cache overwritten. (${route.component})`
|
|
3981
|
-
);
|
|
3982
|
-
}
|
|
3983
|
-
this.cache[route.component] = entry;
|
|
3984
|
-
}
|
|
3985
|
-
get(route) {
|
|
3986
|
-
return this.cache[route.component];
|
|
3987
|
-
}
|
|
3988
|
-
}
|
|
3989
|
-
function findPathItemByKey(staticPaths, params, route) {
|
|
3990
|
-
const paramsKey = stringifyParams(params, route.component);
|
|
3991
|
-
const matchedStaticPath = staticPaths.keyed.get(paramsKey);
|
|
3992
|
-
if (matchedStaticPath) {
|
|
3993
|
-
return matchedStaticPath;
|
|
3994
|
-
}
|
|
3995
|
-
debug("findPathItemByKey", `Unexpected cache miss looking for ${paramsKey}`);
|
|
4091
|
+
return result;
|
|
3996
4092
|
}
|
|
3997
4093
|
|
|
3998
|
-
async function
|
|
3999
|
-
var _a, _b;
|
|
4000
|
-
let paramsAndPropsResp = await getParamsAndProps(options);
|
|
4001
|
-
if (paramsAndPropsResp === 0 /* NoMatchingStaticPath */) {
|
|
4002
|
-
throw new AstroError({
|
|
4003
|
-
...AstroErrorData.NoMatchingStaticPathFound,
|
|
4004
|
-
message: AstroErrorData.NoMatchingStaticPathFound.message(options.pathname),
|
|
4005
|
-
hint: ((_a = options.route) == null ? void 0 : _a.component) ? AstroErrorData.NoMatchingStaticPathFound.hint([(_b = options.route) == null ? void 0 : _b.component]) : ""
|
|
4006
|
-
});
|
|
4007
|
-
}
|
|
4008
|
-
return paramsAndPropsResp;
|
|
4009
|
-
}
|
|
4010
|
-
async function getParamsAndProps(opts) {
|
|
4011
|
-
const { logging, mod, route, routeCache, pathname, ssr } = opts;
|
|
4012
|
-
let params = {};
|
|
4013
|
-
let pageProps;
|
|
4014
|
-
if (route && !route.pathname) {
|
|
4015
|
-
if (route.params.length) {
|
|
4016
|
-
const paramsMatch = route.pattern.exec(decodeURIComponent(pathname));
|
|
4017
|
-
if (paramsMatch) {
|
|
4018
|
-
params = getParams(route.params)(paramsMatch);
|
|
4019
|
-
if (route.type === "endpoint" && mod.getStaticPaths) {
|
|
4020
|
-
const lastSegment = route.segments[route.segments.length - 1];
|
|
4021
|
-
const paramValues = Object.values(params);
|
|
4022
|
-
const lastParam = paramValues[paramValues.length - 1];
|
|
4023
|
-
if (lastSegment.length === 1 && lastSegment[0].dynamic && lastParam === void 0) {
|
|
4024
|
-
throw new AstroError({
|
|
4025
|
-
...AstroErrorData.PrerenderDynamicEndpointPathCollide,
|
|
4026
|
-
message: AstroErrorData.PrerenderDynamicEndpointPathCollide.message(route.route),
|
|
4027
|
-
hint: AstroErrorData.PrerenderDynamicEndpointPathCollide.hint(route.component),
|
|
4028
|
-
location: {
|
|
4029
|
-
file: route.component
|
|
4030
|
-
}
|
|
4031
|
-
});
|
|
4032
|
-
}
|
|
4033
|
-
}
|
|
4034
|
-
}
|
|
4035
|
-
}
|
|
4036
|
-
let routeCacheEntry = routeCache.get(route);
|
|
4037
|
-
if (!routeCacheEntry) {
|
|
4038
|
-
routeCacheEntry = await callGetStaticPaths({ mod, route, isValidate: true, logging, ssr });
|
|
4039
|
-
routeCache.set(route, routeCacheEntry);
|
|
4040
|
-
}
|
|
4041
|
-
const matchedStaticPath = findPathItemByKey(routeCacheEntry.staticPaths, params, route);
|
|
4042
|
-
if (!matchedStaticPath && (ssr ? route.prerender : true)) {
|
|
4043
|
-
return 0 /* NoMatchingStaticPath */;
|
|
4044
|
-
}
|
|
4045
|
-
pageProps = (matchedStaticPath == null ? void 0 : matchedStaticPath.props) ? { ...matchedStaticPath.props } : {};
|
|
4046
|
-
} else {
|
|
4047
|
-
pageProps = {};
|
|
4048
|
-
}
|
|
4049
|
-
return [params, pageProps];
|
|
4050
|
-
}
|
|
4051
|
-
async function renderPage({
|
|
4052
|
-
mod,
|
|
4053
|
-
renderContext,
|
|
4054
|
-
env,
|
|
4055
|
-
cookies,
|
|
4056
|
-
isCompressHTML = false
|
|
4057
|
-
}) {
|
|
4094
|
+
async function renderPage({ mod, renderContext, env, cookies }) {
|
|
4058
4095
|
if (routeIsRedirect(renderContext.route)) {
|
|
4059
4096
|
return new Response(null, {
|
|
4060
4097
|
status: redirectRouteStatus(renderContext.route, renderContext.request.method),
|
|
@@ -4072,15 +4109,13 @@ async function renderPage({
|
|
|
4072
4109
|
styles: renderContext.styles,
|
|
4073
4110
|
logging: env.logging,
|
|
4074
4111
|
markdown: env.markdown,
|
|
4075
|
-
mode: env.mode,
|
|
4076
|
-
origin: renderContext.origin,
|
|
4077
4112
|
params: renderContext.params,
|
|
4078
|
-
props: renderContext.props,
|
|
4079
4113
|
pathname: renderContext.pathname,
|
|
4080
4114
|
componentMetadata: renderContext.componentMetadata,
|
|
4081
4115
|
resolve: env.resolve,
|
|
4082
4116
|
renderers: env.renderers,
|
|
4083
4117
|
clientDirectives: env.clientDirectives,
|
|
4118
|
+
compressHTML: env.compressHTML,
|
|
4084
4119
|
request: renderContext.request,
|
|
4085
4120
|
site: env.site,
|
|
4086
4121
|
scripts: renderContext.scripts,
|
|
@@ -4098,7 +4133,6 @@ async function renderPage({
|
|
|
4098
4133
|
renderContext.props,
|
|
4099
4134
|
null,
|
|
4100
4135
|
env.streaming,
|
|
4101
|
-
isCompressHTML,
|
|
4102
4136
|
renderContext.route
|
|
4103
4137
|
);
|
|
4104
4138
|
if (result.cookies) {
|
|
@@ -4107,44 +4141,6 @@ async function renderPage({
|
|
|
4107
4141
|
return response;
|
|
4108
4142
|
}
|
|
4109
4143
|
|
|
4110
|
-
const clientLocalsSymbol$1 = Symbol.for("astro.locals");
|
|
4111
|
-
async function createRenderContext(options) {
|
|
4112
|
-
const request = options.request;
|
|
4113
|
-
const url = new URL(request.url);
|
|
4114
|
-
const origin = options.origin ?? url.origin;
|
|
4115
|
-
const pathname = options.pathname ?? url.pathname;
|
|
4116
|
-
const [params, props] = await getParamsAndPropsOrThrow({
|
|
4117
|
-
mod: options.mod,
|
|
4118
|
-
route: options.route,
|
|
4119
|
-
routeCache: options.env.routeCache,
|
|
4120
|
-
pathname,
|
|
4121
|
-
logging: options.env.logging,
|
|
4122
|
-
ssr: options.env.ssr
|
|
4123
|
-
});
|
|
4124
|
-
let context = {
|
|
4125
|
-
...options,
|
|
4126
|
-
origin,
|
|
4127
|
-
pathname,
|
|
4128
|
-
url,
|
|
4129
|
-
params,
|
|
4130
|
-
props
|
|
4131
|
-
};
|
|
4132
|
-
Object.defineProperty(context, "locals", {
|
|
4133
|
-
enumerable: true,
|
|
4134
|
-
get() {
|
|
4135
|
-
return Reflect.get(request, clientLocalsSymbol$1);
|
|
4136
|
-
},
|
|
4137
|
-
set(val) {
|
|
4138
|
-
if (typeof val !== "object") {
|
|
4139
|
-
throw new AstroError(AstroErrorData.LocalsNotAnObject);
|
|
4140
|
-
} else {
|
|
4141
|
-
Reflect.set(request, clientLocalsSymbol$1, val);
|
|
4142
|
-
}
|
|
4143
|
-
}
|
|
4144
|
-
});
|
|
4145
|
-
return context;
|
|
4146
|
-
}
|
|
4147
|
-
|
|
4148
4144
|
function createEnvironment(options) {
|
|
4149
4145
|
return options;
|
|
4150
4146
|
}
|
|
@@ -4230,6 +4226,7 @@ class App {
|
|
|
4230
4226
|
logging: this.#logging,
|
|
4231
4227
|
markdown: manifest.markdown,
|
|
4232
4228
|
mode: "production",
|
|
4229
|
+
compressHTML: manifest.compressHTML,
|
|
4233
4230
|
renderers: manifest.renderers,
|
|
4234
4231
|
clientDirectives: manifest.clientDirectives,
|
|
4235
4232
|
async resolve(specifier) {
|
|
@@ -4356,7 +4353,6 @@ class App {
|
|
|
4356
4353
|
const url = new URL(request.url);
|
|
4357
4354
|
const pathname = prependForwardSlash(this.removeBase(url.pathname));
|
|
4358
4355
|
const info = this.#routeDataToRouteInfo.get(routeData);
|
|
4359
|
-
const isCompressHTML = this.#manifest.compressHTML ?? false;
|
|
4360
4356
|
const links = /* @__PURE__ */ new Set();
|
|
4361
4357
|
const styles = createStylesheetElementSet(info.styles);
|
|
4362
4358
|
let scripts = /* @__PURE__ */ new Set();
|
|
@@ -4376,7 +4372,6 @@ class App {
|
|
|
4376
4372
|
const mod = await page.page();
|
|
4377
4373
|
const renderContext = await createRenderContext({
|
|
4378
4374
|
request,
|
|
4379
|
-
origin: url.origin,
|
|
4380
4375
|
pathname,
|
|
4381
4376
|
componentMetadata: this.#manifest.componentMetadata,
|
|
4382
4377
|
scripts,
|
|
@@ -4405,8 +4400,7 @@ class App {
|
|
|
4405
4400
|
mod,
|
|
4406
4401
|
renderContext,
|
|
4407
4402
|
env: this.#env,
|
|
4408
|
-
cookies: apiContext.cookies
|
|
4409
|
-
isCompressHTML
|
|
4403
|
+
cookies: apiContext.cookies
|
|
4410
4404
|
});
|
|
4411
4405
|
}
|
|
4412
4406
|
);
|
|
@@ -4415,8 +4409,7 @@ class App {
|
|
|
4415
4409
|
mod,
|
|
4416
4410
|
renderContext,
|
|
4417
4411
|
env: this.#env,
|
|
4418
|
-
cookies: apiContext.cookies
|
|
4419
|
-
isCompressHTML
|
|
4412
|
+
cookies: apiContext.cookies
|
|
4420
4413
|
});
|
|
4421
4414
|
}
|
|
4422
4415
|
Reflect.set(request, responseSentSymbol, true);
|
|
@@ -4436,14 +4429,13 @@ class App {
|
|
|
4436
4429
|
const handler = mod;
|
|
4437
4430
|
const ctx = await createRenderContext({
|
|
4438
4431
|
request,
|
|
4439
|
-
origin: url.origin,
|
|
4440
4432
|
pathname,
|
|
4441
4433
|
route: routeData,
|
|
4442
4434
|
status,
|
|
4443
4435
|
env: this.#env,
|
|
4444
4436
|
mod: handler
|
|
4445
4437
|
});
|
|
4446
|
-
const result = await callEndpoint(handler, this.#env, ctx,
|
|
4438
|
+
const result = await callEndpoint(handler, this.#env, ctx, page.onRequest);
|
|
4447
4439
|
if (result.type === "response") {
|
|
4448
4440
|
if (result.response.headers.get("X-Astro-Response") === "Not-Found") {
|
|
4449
4441
|
const fourOhFourRequest = new Request(new URL("/404", request.url));
|