astro 6.2.2 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/actions/handler.d.ts +32 -0
  2. package/dist/actions/handler.js +45 -0
  3. package/dist/actions/runtime/server.js +1 -1
  4. package/dist/assets/build/generate.js +1 -1
  5. package/dist/assets/build/remote.d.ts +3 -2
  6. package/dist/assets/build/remote.js +16 -9
  7. package/dist/assets/endpoint/generic.js +4 -7
  8. package/dist/assets/endpoint/shared.js +7 -2
  9. package/dist/assets/index.d.ts +1 -0
  10. package/dist/assets/index.js +2 -0
  11. package/dist/assets/services/sharp.js +7 -0
  12. package/dist/assets/utils/index.d.ts +1 -0
  13. package/dist/assets/utils/index.js +2 -0
  14. package/dist/assets/utils/redirectValidation.d.ts +48 -0
  15. package/dist/assets/utils/redirectValidation.js +48 -0
  16. package/dist/assets/utils/remoteProbe.js +25 -2
  17. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  18. package/dist/container/index.js +18 -14
  19. package/dist/content/content-layer.js +3 -4
  20. package/dist/content/server-listeners.js +0 -4
  21. package/dist/content/vite-plugin-content-virtual-mod.js +9 -1
  22. package/dist/core/app/base.d.ts +33 -15
  23. package/dist/core/app/base.js +120 -324
  24. package/dist/core/app/dev/app.d.ts +3 -2
  25. package/dist/core/app/dev/app.js +4 -60
  26. package/dist/core/app/entrypoints/virtual/dev.js +2 -0
  27. package/dist/core/app/entrypoints/virtual/prod.js +4 -1
  28. package/dist/core/app/prepare-response.d.ts +11 -0
  29. package/dist/core/app/prepare-response.js +18 -0
  30. package/dist/core/app/render-options.d.ts +11 -0
  31. package/dist/core/app/render-options.js +11 -0
  32. package/dist/core/base-pipeline.d.ts +38 -1
  33. package/dist/core/base-pipeline.js +50 -7
  34. package/dist/core/build/app.d.ts +3 -4
  35. package/dist/core/build/app.js +3 -17
  36. package/dist/core/cache/handler.d.ts +29 -0
  37. package/dist/core/cache/handler.js +81 -0
  38. package/dist/core/config/schemas/base.d.ts +4 -0
  39. package/dist/core/config/schemas/base.js +4 -0
  40. package/dist/core/config/schemas/relative.d.ts +6 -0
  41. package/dist/core/constants.d.ts +27 -1
  42. package/dist/core/constants.js +14 -1
  43. package/dist/core/cookies/cookies.d.ts +7 -2
  44. package/dist/core/cookies/cookies.js +11 -4
  45. package/dist/core/cookies/response.d.ts +1 -1
  46. package/dist/core/cookies/response.js +1 -2
  47. package/dist/core/create-vite.js +15 -0
  48. package/dist/core/csp/runtime.js +6 -4
  49. package/dist/core/dev/dev.js +1 -1
  50. package/dist/core/errors/build-handler.d.ts +17 -0
  51. package/dist/core/errors/build-handler.js +22 -0
  52. package/dist/core/errors/default-handler.d.ts +14 -0
  53. package/dist/core/errors/default-handler.js +144 -0
  54. package/dist/core/errors/dev-handler.d.ts +21 -0
  55. package/dist/core/errors/dev-handler.js +82 -0
  56. package/dist/core/errors/handler.d.ts +9 -0
  57. package/dist/core/errors/handler.js +0 -0
  58. package/dist/core/fetch/default-handler.d.ts +17 -0
  59. package/dist/core/fetch/default-handler.js +45 -0
  60. package/dist/core/fetch/fetch-state.d.ts +244 -0
  61. package/dist/core/fetch/fetch-state.js +779 -0
  62. package/dist/core/fetch/index.d.ts +61 -0
  63. package/dist/core/fetch/index.js +121 -0
  64. package/dist/core/fetch/types.d.ts +6 -0
  65. package/dist/core/fetch/types.js +0 -0
  66. package/dist/core/fetch/vite-plugin.d.ts +5 -0
  67. package/dist/core/fetch/vite-plugin.js +69 -0
  68. package/dist/core/hono/index.d.ts +21 -0
  69. package/dist/core/hono/index.js +98 -0
  70. package/dist/core/i18n/handler.d.ts +18 -0
  71. package/dist/core/i18n/handler.js +119 -0
  72. package/dist/core/logger/core.d.ts +8 -0
  73. package/dist/core/logger/core.js +16 -0
  74. package/dist/core/messages/runtime.js +1 -1
  75. package/dist/core/middleware/astro-middleware.d.ts +27 -0
  76. package/dist/core/middleware/astro-middleware.js +53 -0
  77. package/dist/core/pages/handler.d.ts +20 -0
  78. package/dist/core/pages/handler.js +74 -0
  79. package/dist/core/redirects/render.d.ts +2 -2
  80. package/dist/core/redirects/render.js +7 -8
  81. package/dist/core/rewrites/handler.d.ts +37 -0
  82. package/dist/core/rewrites/handler.js +67 -0
  83. package/dist/core/routing/3xx.js +8 -4
  84. package/dist/core/routing/handler.d.ts +17 -0
  85. package/dist/core/routing/handler.js +172 -0
  86. package/dist/core/routing/match.d.ts +0 -7
  87. package/dist/core/routing/match.js +0 -5
  88. package/dist/core/routing/trailing-slash-handler.d.ts +18 -0
  89. package/dist/core/routing/trailing-slash-handler.js +67 -0
  90. package/dist/core/session/drivers.d.ts +1 -1
  91. package/dist/core/session/handler.d.ts +11 -0
  92. package/dist/core/session/handler.js +33 -0
  93. package/dist/core/util/normalized-url.d.ts +10 -0
  94. package/dist/core/util/normalized-url.js +21 -0
  95. package/dist/i18n/middleware.d.ts +10 -0
  96. package/dist/i18n/middleware.js +4 -88
  97. package/dist/i18n/utils.js +2 -2
  98. package/dist/runtime/server/astro-island.js +57 -20
  99. package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
  100. package/dist/runtime/server/astro-island.prebuilt-dev.js +1 -1
  101. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  102. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  103. package/dist/runtime/server/render/server-islands.js +2 -1
  104. package/dist/types/public/config.d.ts +46 -12
  105. package/dist/types/public/internal.d.ts +1 -1
  106. package/dist/vite-plugin-app/app.d.ts +4 -5
  107. package/dist/vite-plugin-app/app.js +20 -65
  108. package/package.json +11 -5
  109. package/dist/core/render-context.d.ts +0 -77
  110. package/dist/core/render-context.js +0 -826
@@ -1,95 +1,11 @@
1
- import { appendForwardSlash } from "@astrojs/internal-helpers/path";
2
- import { shouldAppendForwardSlash } from "../core/build/util.js";
3
- import { REROUTE_DIRECTIVE_HEADER, ROUTE_TYPE_HEADER } from "../core/constants.js";
4
- import { computeFallbackRoute } from "./fallback.js";
5
- import { I18nRouter } from "./router.js";
1
+ import { getFetchStateFromAPIContext } from "../core/fetch/fetch-state.js";
2
+ import { I18n } from "../core/i18n/handler.js";
6
3
  function createI18nMiddleware(i18n, base, trailingSlash, format) {
7
4
  if (!i18n) return (_, next) => next();
8
- const i18nRouter = new I18nRouter({
9
- strategy: i18n.strategy,
10
- defaultLocale: i18n.defaultLocale,
11
- locales: i18n.locales,
12
- base,
13
- domains: i18n.domainLookupTable ? Object.keys(i18n.domainLookupTable).reduce(
14
- (acc, domain) => {
15
- const locale = i18n.domainLookupTable[domain];
16
- if (!acc[domain]) {
17
- acc[domain] = [];
18
- }
19
- acc[domain].push(locale);
20
- return acc;
21
- },
22
- {}
23
- ) : void 0
24
- });
5
+ const handler = new I18n(i18n, base, trailingSlash, format);
25
6
  return async (context, next) => {
26
7
  const response = await next();
27
- const typeHeader = response.headers.get(ROUTE_TYPE_HEADER);
28
- const isReroute = response.headers.get(REROUTE_DIRECTIVE_HEADER);
29
- if (isReroute === "no" && typeof i18n.fallback === "undefined") {
30
- return response;
31
- }
32
- if (typeHeader !== "page" && typeHeader !== "fallback") {
33
- return response;
34
- }
35
- const routerContext = {
36
- currentLocale: context.currentLocale,
37
- currentDomain: context.url.hostname,
38
- routeType: typeHeader,
39
- isReroute: isReroute === "yes"
40
- };
41
- const routeDecision = i18nRouter.match(context.url.pathname, routerContext);
42
- switch (routeDecision.type) {
43
- case "redirect": {
44
- let location = routeDecision.location;
45
- if (shouldAppendForwardSlash(trailingSlash, format)) {
46
- location = appendForwardSlash(location);
47
- }
48
- return context.redirect(location, routeDecision.status);
49
- }
50
- case "notFound": {
51
- if (context.isPrerendered) {
52
- const prerenderedRes = new Response(response.body, {
53
- status: 404,
54
- headers: response.headers
55
- });
56
- prerenderedRes.headers.set(REROUTE_DIRECTIVE_HEADER, "no");
57
- if (routeDecision.location) {
58
- prerenderedRes.headers.set("Location", routeDecision.location);
59
- }
60
- return prerenderedRes;
61
- }
62
- const headers = new Headers();
63
- if (routeDecision.location) {
64
- headers.set("Location", routeDecision.location);
65
- }
66
- return new Response(null, { status: 404, headers });
67
- }
68
- case "continue":
69
- break;
70
- }
71
- if (i18n.fallback && i18n.fallbackType) {
72
- const fallbackDecision = computeFallbackRoute({
73
- pathname: context.url.pathname,
74
- responseStatus: typeHeader === "fallback" ? 404 : response.status,
75
- currentLocale: context.currentLocale,
76
- fallback: i18n.fallback,
77
- fallbackType: i18n.fallbackType,
78
- locales: i18n.locales,
79
- defaultLocale: i18n.defaultLocale,
80
- strategy: i18n.strategy,
81
- base
82
- });
83
- switch (fallbackDecision.type) {
84
- case "redirect":
85
- return context.redirect(fallbackDecision.pathname + context.url.search);
86
- case "rewrite":
87
- return await context.rewrite(fallbackDecision.pathname + context.url.search);
88
- case "none":
89
- break;
90
- }
91
- }
92
- return response;
8
+ return handler.finalize(getFetchStateFromAPIContext(context), response);
93
9
  };
94
10
  }
95
11
  export {
@@ -55,7 +55,7 @@ function computePreferredLocale(request, locales) {
55
55
  const browserLocaleList = sortAndFilterLocales(parseLocale(acceptHeader), locales);
56
56
  const firstResult = browserLocaleList.at(0);
57
57
  if (firstResult && firstResult.locale !== "*") {
58
- for (const currentLocale of locales) {
58
+ outer: for (const currentLocale of locales) {
59
59
  if (typeof currentLocale === "string") {
60
60
  if (normalizeTheLocale(currentLocale) === normalizeTheLocale(firstResult.locale)) {
61
61
  result = currentLocale;
@@ -65,7 +65,7 @@ function computePreferredLocale(request, locales) {
65
65
  for (const currentCode of currentLocale.codes) {
66
66
  if (normalizeTheLocale(currentCode) === normalizeTheLocale(firstResult.locale)) {
67
67
  result = currentCode;
68
- break;
68
+ break outer;
69
69
  }
70
70
  }
71
71
  }
@@ -59,6 +59,37 @@ const FORBIDDEN_COMPONENT_EXPORT_KEYS = /* @__PURE__ */ new Set(["__proto__", "c
59
59
  }
60
60
  this.start();
61
61
  }
62
+ getRetryImportUrl(url) {
63
+ const parsed = new URL(url, document.baseURI);
64
+ const retryToken = `astro-retry=${Date.now()}`;
65
+ const currentHash = parsed.hash.replace(/^#/, "");
66
+ parsed.hash = currentHash ? `${currentHash}&${retryToken}` : retryToken;
67
+ return parsed.toString();
68
+ }
69
+ async importWithRetry(url) {
70
+ try {
71
+ return await import(url);
72
+ } catch {
73
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
74
+ return import(this.getRetryImportUrl(url));
75
+ }
76
+ }
77
+ handleHydrationError(error) {
78
+ const componentUrl = this.getAttribute("component-url");
79
+ const event = new CustomEvent("astro:hydration-error", {
80
+ cancelable: true,
81
+ bubbles: true,
82
+ composed: true,
83
+ detail: {
84
+ error,
85
+ componentUrl
86
+ }
87
+ });
88
+ const shouldLogError = this.dispatchEvent(event);
89
+ if (shouldLogError) {
90
+ console.error(`[astro-island] Error hydrating ${componentUrl}`, error);
91
+ }
92
+ }
62
93
  async start() {
63
94
  const opts = JSON.parse(this.getAttribute("opts"));
64
95
  const directive = this.getAttribute("client");
@@ -70,34 +101,40 @@ const FORBIDDEN_COMPONENT_EXPORT_KEYS = /* @__PURE__ */ new Set(["__proto__", "c
70
101
  await Astro[directive](
71
102
  async () => {
72
103
  const rendererUrl = this.getAttribute("renderer-url");
73
- const [componentModule, { default: hydrator }] = await Promise.all([
74
- import(this.getAttribute("component-url")),
75
- rendererUrl ? import(rendererUrl) : () => () => {
76
- }
77
- ]);
78
- const componentExport = this.getAttribute("component-export") || "default";
79
- if (!componentExport.includes(".")) {
80
- if (FORBIDDEN_COMPONENT_EXPORT_KEYS.has(componentExport)) {
81
- throw new Error(`Invalid component export path: ${componentExport}`);
82
- }
83
- this.Component = componentModule[componentExport];
84
- } else {
85
- this.Component = componentModule;
86
- for (const part of componentExport.split(".")) {
87
- if (FORBIDDEN_COMPONENT_EXPORT_KEYS.has(part) || !this.Component || typeof this.Component !== "object" && typeof this.Component !== "function" || !Object.hasOwn(this.Component, part)) {
104
+ try {
105
+ const [componentModule, { default: hydrator }] = await Promise.all([
106
+ this.importWithRetry(this.getAttribute("component-url")),
107
+ rendererUrl ? this.importWithRetry(rendererUrl) : Promise.resolve({ default: () => () => {
108
+ } })
109
+ ]);
110
+ const componentExport = this.getAttribute("component-export") || "default";
111
+ if (!componentExport.includes(".")) {
112
+ if (FORBIDDEN_COMPONENT_EXPORT_KEYS.has(componentExport)) {
88
113
  throw new Error(`Invalid component export path: ${componentExport}`);
89
114
  }
90
- this.Component = this.Component[part];
115
+ this.Component = componentModule[componentExport];
116
+ } else {
117
+ this.Component = componentModule;
118
+ for (const part of componentExport.split(".")) {
119
+ if (FORBIDDEN_COMPONENT_EXPORT_KEYS.has(part) || !this.Component || typeof this.Component !== "object" && typeof this.Component !== "function" || !Object.hasOwn(this.Component, part)) {
120
+ throw new Error(`Invalid component export path: ${componentExport}`);
121
+ }
122
+ this.Component = this.Component[part];
123
+ }
91
124
  }
125
+ this.hydrator = hydrator;
126
+ return this.hydrate;
127
+ } catch (error) {
128
+ this.handleHydrationError(error);
129
+ return () => {
130
+ };
92
131
  }
93
- this.hydrator = hydrator;
94
- return this.hydrate;
95
132
  },
96
133
  opts,
97
134
  this
98
135
  );
99
- } catch (e) {
100
- console.error("[astro-island] Error hydrating %s", this.getAttribute("component-url"), e);
136
+ } catch (error) {
137
+ this.handleHydrationError(error);
101
138
  }
102
139
  }
103
140
  hydrate = async () => {
@@ -3,5 +3,5 @@
3
3
  * Do not edit this directly, but instead edit that file and rerun the prebuild
4
4
  * to generate this file.
5
5
  */
6
- declare const _default: "(()=>{var A=Object.defineProperty;var C=(a,r,c)=>r in a?A(a,r,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[r]=c;var l=(a,r,c)=>C(a,typeof r!=\"symbol\"?r+\"\":r,c);var E=new Set([\"__proto__\",\"constructor\",\"prototype\"]);{let a={0:t=>y(t),1:t=>c(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(c(t)),5:t=>new Set(c(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},r=t=>{let[p,e]=t;return p in a?a[p](e):void 0},c=t=>t.map(r),y=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([p,e])=>[p,r(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,\"Component\");l(this,\"hydrator\");l(this,\"hydrate\",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let d=this.querySelectorAll(\"astro-slot\"),n={},u=this.querySelectorAll(\"template[data-astro-template]\");for(let o of u){let i=o.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[o.getAttribute(\"data-astro-template\")||\"default\"]=o.innerHTML,o.remove())}for(let o of d){let i=o.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[o.getAttribute(\"name\")||\"default\"]=o.innerHTML)}let m;try{m=this.hasAttribute(\"props\")?y(JSON.parse(this.getAttribute(\"props\"))):{}}catch(o){let i=this.getAttribute(\"component-url\")||\"<unknown>\",v=this.getAttribute(\"component-export\");throw v&&(i+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${i}`,this.getAttribute(\"props\"),o),o}let s,h=this.hydrator(this);s=performance.now(),await h(this.Component,m,n,{client:this.getAttribute(\"client\")}),s&&this.setAttribute(\"client-render-time\",(performance.now()-s).toString()),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))});l(this,\"unmount\",()=>{this.isConnected||this.dispatchEvent(new CustomEvent(\"astro:unmount\"))})}disconnectedCallback(){document.removeEventListener(\"astro:after-swap\",this.unmount),document.addEventListener(\"astro:after-swap\",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute(\"await-children\")||document.readyState===\"interactive\"||document.readyState===\"complete\")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener(\"DOMContentLoaded\",e),d.disconnect(),this.childrenConnectedCallback()},d=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue===\"astro:end\"&&(this.lastChild.remove(),e())});d.observe(this,{childList:!0}),document.addEventListener(\"DOMContentLoaded\",e)}}async childrenConnectedCallback(){let e=this.getAttribute(\"before-hydration-url\");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute(\"opts\")),d=this.getAttribute(\"client\");if(Astro[d]===void 0){window.addEventListener(`astro:${d}`,()=>this.start(),{once:!0});return}try{await Astro[d](async()=>{let n=this.getAttribute(\"renderer-url\"),[u,{default:m}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),s=this.getAttribute(\"component-export\")||\"default\";if(s.includes(\".\")){this.Component=u;for(let h of s.split(\".\")){if(E.has(h)||!this.Component||typeof this.Component!=\"object\"&&typeof this.Component!=\"function\"||!Object.hasOwn(this.Component,h))throw new Error(`Invalid component export path: ${s}`);this.Component=this.Component[h]}}else{if(E.has(s))throw new Error(`Invalid component export path: ${s}`);this.Component=u[s]}return this.hydrator=m,this.hydrate},e,this)}catch(n){console.error(\"[astro-island] Error hydrating %s\",this.getAttribute(\"component-url\"),n)}}attributeChangedCallback(){this.hydrate()}}l(f,\"observedAttributes\",[\"props\"]),customElements.get(\"astro-island\")||customElements.define(\"astro-island\",f)}})();";
6
+ declare const _default: "(()=>{var g=Object.defineProperty;var w=(d,s,h)=>s in d?g(d,s,{enumerable:!0,configurable:!0,writable:!0,value:h}):d[s]=h;var l=(d,s,h)=>w(d,typeof s!=\"symbol\"?s+\"\":s,h);var E=new Set([\"__proto__\",\"constructor\",\"prototype\"]);{let d={0:t=>y(t),1:t=>h(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(h(t)),5:t=>new Set(h(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},s=t=>{let[p,e]=t;return p in d?d[p](e):void 0},h=t=>t.map(s),y=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([p,e])=>[p,s(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,\"Component\");l(this,\"hydrator\");l(this,\"hydrate\",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let n=this.querySelectorAll(\"astro-slot\"),r={},i=this.querySelectorAll(\"template[data-astro-template]\");for(let o of i){let c=o.closest(this.tagName);c!=null&&c.isSameNode(this)&&(r[o.getAttribute(\"data-astro-template\")||\"default\"]=o.innerHTML,o.remove())}for(let o of n){let c=o.closest(this.tagName);c!=null&&c.isSameNode(this)&&(r[o.getAttribute(\"name\")||\"default\"]=o.innerHTML)}let m;try{m=this.hasAttribute(\"props\")?y(JSON.parse(this.getAttribute(\"props\"))):{}}catch(o){let c=this.getAttribute(\"component-url\")||\"<unknown>\",v=this.getAttribute(\"component-export\");throw v&&(c+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${c}`,this.getAttribute(\"props\"),o),o}let a,u=this.hydrator(this);a=performance.now(),await u(this.Component,m,r,{client:this.getAttribute(\"client\")}),a&&this.setAttribute(\"client-render-time\",(performance.now()-a).toString()),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))});l(this,\"unmount\",()=>{this.isConnected||this.dispatchEvent(new CustomEvent(\"astro:unmount\"))})}disconnectedCallback(){document.removeEventListener(\"astro:after-swap\",this.unmount),document.addEventListener(\"astro:after-swap\",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute(\"await-children\")||document.readyState===\"interactive\"||document.readyState===\"complete\")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener(\"DOMContentLoaded\",e),n.disconnect(),this.childrenConnectedCallback()},n=new MutationObserver(()=>{var r;((r=this.lastChild)==null?void 0:r.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue===\"astro:end\"&&(this.lastChild.remove(),e())});n.observe(this,{childList:!0}),document.addEventListener(\"DOMContentLoaded\",e)}}async childrenConnectedCallback(){let e=this.getAttribute(\"before-hydration-url\");e&&await import(e),this.start()}getRetryImportUrl(e){let n=new URL(e,document.baseURI),r=`astro-retry=${Date.now()}`,i=n.hash.replace(/^#/,\"\");return n.hash=i?`${i}&${r}`:r,n.toString()}async importWithRetry(e){try{return await import(e)}catch(n){return await new Promise(r=>setTimeout(r,1e3)),import(this.getRetryImportUrl(e))}}handleHydrationError(e){let n=this.getAttribute(\"component-url\"),r=new CustomEvent(\"astro:hydration-error\",{cancelable:!0,bubbles:!0,composed:!0,detail:{error:e,componentUrl:n}});this.dispatchEvent(r)&&console.error(`[astro-island] Error hydrating ${n}`,e)}async start(){let e=JSON.parse(this.getAttribute(\"opts\")),n=this.getAttribute(\"client\");if(Astro[n]===void 0){window.addEventListener(`astro:${n}`,()=>this.start(),{once:!0});return}try{await Astro[n](async()=>{let r=this.getAttribute(\"renderer-url\");try{let[i,{default:m}]=await Promise.all([this.importWithRetry(this.getAttribute(\"component-url\")),r?this.importWithRetry(r):Promise.resolve({default:()=>()=>{}})]),a=this.getAttribute(\"component-export\")||\"default\";if(a.includes(\".\")){this.Component=i;for(let u of a.split(\".\")){if(E.has(u)||!this.Component||typeof this.Component!=\"object\"&&typeof this.Component!=\"function\"||!Object.hasOwn(this.Component,u))throw new Error(`Invalid component export path: ${a}`);this.Component=this.Component[u]}}else{if(E.has(a))throw new Error(`Invalid component export path: ${a}`);this.Component=i[a]}return this.hydrator=m,this.hydrate}catch(i){return this.handleHydrationError(i),()=>{}}},e,this)}catch(r){this.handleHydrationError(r)}}attributeChangedCallback(){this.hydrate()}}l(f,\"observedAttributes\",[\"props\"]),customElements.get(\"astro-island\")||customElements.define(\"astro-island\",f)}})();";
7
7
  export default _default;
@@ -1,4 +1,4 @@
1
- var astro_island_prebuilt_dev_default = `(()=>{var A=Object.defineProperty;var C=(a,r,c)=>r in a?A(a,r,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[r]=c;var l=(a,r,c)=>C(a,typeof r!="symbol"?r+"":r,c);var E=new Set(["__proto__","constructor","prototype"]);{let a={0:t=>y(t),1:t=>c(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(c(t)),5:t=>new Set(c(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},r=t=>{let[p,e]=t;return p in a?a[p](e):void 0},c=t=>t.map(r),y=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([p,e])=>[p,r(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,"Component");l(this,"hydrator");l(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let d=this.querySelectorAll("astro-slot"),n={},u=this.querySelectorAll("template[data-astro-template]");for(let o of u){let i=o.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[o.getAttribute("data-astro-template")||"default"]=o.innerHTML,o.remove())}for(let o of d){let i=o.closest(this.tagName);i!=null&&i.isSameNode(this)&&(n[o.getAttribute("name")||"default"]=o.innerHTML)}let m;try{m=this.hasAttribute("props")?y(JSON.parse(this.getAttribute("props"))):{}}catch(o){let i=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(i+=\` (export \${v})\`),console.error(\`[hydrate] Error parsing props for component \${i}\`,this.getAttribute("props"),o),o}let s,h=this.hydrator(this);s=performance.now(),await h(this.Component,m,n,{client:this.getAttribute("client")}),s&&this.setAttribute("client-render-time",(performance.now()-s).toString()),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});l(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),d.disconnect(),this.childrenConnectedCallback()},d=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});d.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),d=this.getAttribute("client");if(Astro[d]===void 0){window.addEventListener(\`astro:\${d}\`,()=>this.start(),{once:!0});return}try{await Astro[d](async()=>{let n=this.getAttribute("renderer-url"),[u,{default:m}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),s=this.getAttribute("component-export")||"default";if(s.includes(".")){this.Component=u;for(let h of s.split(".")){if(E.has(h)||!this.Component||typeof this.Component!="object"&&typeof this.Component!="function"||!Object.hasOwn(this.Component,h))throw new Error(\`Invalid component export path: \${s}\`);this.Component=this.Component[h]}}else{if(E.has(s))throw new Error(\`Invalid component export path: \${s}\`);this.Component=u[s]}return this.hydrator=m,this.hydrate},e,this)}catch(n){console.error("[astro-island] Error hydrating %s",this.getAttribute("component-url"),n)}}attributeChangedCallback(){this.hydrate()}}l(f,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",f)}})();`;
1
+ var astro_island_prebuilt_dev_default = `(()=>{var g=Object.defineProperty;var w=(d,s,h)=>s in d?g(d,s,{enumerable:!0,configurable:!0,writable:!0,value:h}):d[s]=h;var l=(d,s,h)=>w(d,typeof s!="symbol"?s+"":s,h);var E=new Set(["__proto__","constructor","prototype"]);{let d={0:t=>y(t),1:t=>h(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(h(t)),5:t=>new Set(h(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},s=t=>{let[p,e]=t;return p in d?d[p](e):void 0},h=t=>t.map(s),y=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([p,e])=>[p,s(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,"Component");l(this,"hydrator");l(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let n=this.querySelectorAll("astro-slot"),r={},i=this.querySelectorAll("template[data-astro-template]");for(let o of i){let c=o.closest(this.tagName);c!=null&&c.isSameNode(this)&&(r[o.getAttribute("data-astro-template")||"default"]=o.innerHTML,o.remove())}for(let o of n){let c=o.closest(this.tagName);c!=null&&c.isSameNode(this)&&(r[o.getAttribute("name")||"default"]=o.innerHTML)}let m;try{m=this.hasAttribute("props")?y(JSON.parse(this.getAttribute("props"))):{}}catch(o){let c=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(c+=\` (export \${v})\`),console.error(\`[hydrate] Error parsing props for component \${c}\`,this.getAttribute("props"),o),o}let a,u=this.hydrator(this);a=performance.now(),await u(this.Component,m,r,{client:this.getAttribute("client")}),a&&this.setAttribute("client-render-time",(performance.now()-a).toString()),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});l(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),n.disconnect(),this.childrenConnectedCallback()},n=new MutationObserver(()=>{var r;((r=this.lastChild)==null?void 0:r.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});n.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}getRetryImportUrl(e){let n=new URL(e,document.baseURI),r=\`astro-retry=\${Date.now()}\`,i=n.hash.replace(/^#/,"");return n.hash=i?\`\${i}&\${r}\`:r,n.toString()}async importWithRetry(e){try{return await import(e)}catch(n){return await new Promise(r=>setTimeout(r,1e3)),import(this.getRetryImportUrl(e))}}handleHydrationError(e){let n=this.getAttribute("component-url"),r=new CustomEvent("astro:hydration-error",{cancelable:!0,bubbles:!0,composed:!0,detail:{error:e,componentUrl:n}});this.dispatchEvent(r)&&console.error(\`[astro-island] Error hydrating \${n}\`,e)}async start(){let e=JSON.parse(this.getAttribute("opts")),n=this.getAttribute("client");if(Astro[n]===void 0){window.addEventListener(\`astro:\${n}\`,()=>this.start(),{once:!0});return}try{await Astro[n](async()=>{let r=this.getAttribute("renderer-url");try{let[i,{default:m}]=await Promise.all([this.importWithRetry(this.getAttribute("component-url")),r?this.importWithRetry(r):Promise.resolve({default:()=>()=>{}})]),a=this.getAttribute("component-export")||"default";if(a.includes(".")){this.Component=i;for(let u of a.split(".")){if(E.has(u)||!this.Component||typeof this.Component!="object"&&typeof this.Component!="function"||!Object.hasOwn(this.Component,u))throw new Error(\`Invalid component export path: \${a}\`);this.Component=this.Component[u]}}else{if(E.has(a))throw new Error(\`Invalid component export path: \${a}\`);this.Component=i[a]}return this.hydrator=m,this.hydrate}catch(i){return this.handleHydrationError(i),()=>{}}},e,this)}catch(r){this.handleHydrationError(r)}}attributeChangedCallback(){this.hydrate()}}l(f,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",f)}})();`;
2
2
  export {
3
3
  astro_island_prebuilt_dev_default as default
4
4
  };
@@ -3,5 +3,5 @@
3
3
  * Do not edit this directly, but instead edit that file and rerun the prebuild
4
4
  * to generate this file.
5
5
  */
6
- declare const _default: "(()=>{var A=Object.defineProperty;var C=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var l=(i,o,a)=>C(i,typeof o!=\"symbol\"?o+\"\":o,a);var E=new Set([\"__proto__\",\"constructor\",\"prototype\"]);{let i={0:t=>y(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},o=t=>{let[h,e]=t;return h in i?i[h](e):void 0},a=t=>t.map(o),y=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([h,e])=>[h,o(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,\"Component\");l(this,\"hydrator\");l(this,\"hydrate\",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let c=this.querySelectorAll(\"astro-slot\"),n={},p=this.querySelectorAll(\"template[data-astro-template]\");for(let r of p){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}let u;try{u=this.hasAttribute(\"props\")?y(JSON.parse(this.getAttribute(\"props\"))):{}}catch(r){let s=this.getAttribute(\"component-url\")||\"<unknown>\",v=this.getAttribute(\"component-export\");throw v&&(s+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute(\"props\"),r),r}let d;await this.hydrator(this)(this.Component,u,n,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))});l(this,\"unmount\",()=>{this.isConnected||this.dispatchEvent(new CustomEvent(\"astro:unmount\"))})}disconnectedCallback(){document.removeEventListener(\"astro:after-swap\",this.unmount),document.addEventListener(\"astro:after-swap\",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute(\"await-children\")||document.readyState===\"interactive\"||document.readyState===\"complete\")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener(\"DOMContentLoaded\",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue===\"astro:end\"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener(\"DOMContentLoaded\",e)}}async childrenConnectedCallback(){let e=this.getAttribute(\"before-hydration-url\");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute(\"opts\")),c=this.getAttribute(\"client\");if(Astro[c]===void 0){window.addEventListener(`astro:${c}`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute(\"renderer-url\"),[p,{default:u}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),d=this.getAttribute(\"component-export\")||\"default\";if(d.includes(\".\")){this.Component=p;for(let m of d.split(\".\")){if(E.has(m)||!this.Component||typeof this.Component!=\"object\"&&typeof this.Component!=\"function\"||!Object.hasOwn(this.Component,m))throw new Error(`Invalid component export path: ${d}`);this.Component=this.Component[m]}}else{if(E.has(d))throw new Error(`Invalid component export path: ${d}`);this.Component=p[d]}return this.hydrator=u,this.hydrate},e,this)}catch(n){console.error(\"[astro-island] Error hydrating %s\",this.getAttribute(\"component-url\"),n)}}attributeChangedCallback(){this.hydrate()}}l(f,\"observedAttributes\",[\"props\"]),customElements.get(\"astro-island\")||customElements.define(\"astro-island\",f)}})();";
6
+ declare const _default: "(()=>{var g=Object.defineProperty;var w=(c,s,d)=>s in c?g(c,s,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[s]=d;var l=(c,s,d)=>w(c,typeof s!=\"symbol\"?s+\"\":s,d);var E=new Set([\"__proto__\",\"constructor\",\"prototype\"]);{let c={0:t=>y(t),1:t=>d(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(d(t)),5:t=>new Set(d(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},s=t=>{let[p,e]=t;return p in c?c[p](e):void 0},d=t=>t.map(s),y=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([p,e])=>[p,s(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,\"Component\");l(this,\"hydrator\");l(this,\"hydrate\",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let n=this.querySelectorAll(\"astro-slot\"),r={},i=this.querySelectorAll(\"template[data-astro-template]\");for(let o of i){let a=o.closest(this.tagName);a!=null&&a.isSameNode(this)&&(r[o.getAttribute(\"data-astro-template\")||\"default\"]=o.innerHTML,o.remove())}for(let o of n){let a=o.closest(this.tagName);a!=null&&a.isSameNode(this)&&(r[o.getAttribute(\"name\")||\"default\"]=o.innerHTML)}let u;try{u=this.hasAttribute(\"props\")?y(JSON.parse(this.getAttribute(\"props\"))):{}}catch(o){let a=this.getAttribute(\"component-url\")||\"<unknown>\",v=this.getAttribute(\"component-export\");throw v&&(a+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${a}`,this.getAttribute(\"props\"),o),o}let h;await this.hydrator(this)(this.Component,u,r,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))});l(this,\"unmount\",()=>{this.isConnected||this.dispatchEvent(new CustomEvent(\"astro:unmount\"))})}disconnectedCallback(){document.removeEventListener(\"astro:after-swap\",this.unmount),document.addEventListener(\"astro:after-swap\",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute(\"await-children\")||document.readyState===\"interactive\"||document.readyState===\"complete\")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener(\"DOMContentLoaded\",e),n.disconnect(),this.childrenConnectedCallback()},n=new MutationObserver(()=>{var r;((r=this.lastChild)==null?void 0:r.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue===\"astro:end\"&&(this.lastChild.remove(),e())});n.observe(this,{childList:!0}),document.addEventListener(\"DOMContentLoaded\",e)}}async childrenConnectedCallback(){let e=this.getAttribute(\"before-hydration-url\");e&&await import(e),this.start()}getRetryImportUrl(e){let n=new URL(e,document.baseURI),r=`astro-retry=${Date.now()}`,i=n.hash.replace(/^#/,\"\");return n.hash=i?`${i}&${r}`:r,n.toString()}async importWithRetry(e){try{return await import(e)}catch(n){return await new Promise(r=>setTimeout(r,1e3)),import(this.getRetryImportUrl(e))}}handleHydrationError(e){let n=this.getAttribute(\"component-url\"),r=new CustomEvent(\"astro:hydration-error\",{cancelable:!0,bubbles:!0,composed:!0,detail:{error:e,componentUrl:n}});this.dispatchEvent(r)&&console.error(`[astro-island] Error hydrating ${n}`,e)}async start(){let e=JSON.parse(this.getAttribute(\"opts\")),n=this.getAttribute(\"client\");if(Astro[n]===void 0){window.addEventListener(`astro:${n}`,()=>this.start(),{once:!0});return}try{await Astro[n](async()=>{let r=this.getAttribute(\"renderer-url\");try{let[i,{default:u}]=await Promise.all([this.importWithRetry(this.getAttribute(\"component-url\")),r?this.importWithRetry(r):Promise.resolve({default:()=>()=>{}})]),h=this.getAttribute(\"component-export\")||\"default\";if(h.includes(\".\")){this.Component=i;for(let m of h.split(\".\")){if(E.has(m)||!this.Component||typeof this.Component!=\"object\"&&typeof this.Component!=\"function\"||!Object.hasOwn(this.Component,m))throw new Error(`Invalid component export path: ${h}`);this.Component=this.Component[m]}}else{if(E.has(h))throw new Error(`Invalid component export path: ${h}`);this.Component=i[h]}return this.hydrator=u,this.hydrate}catch(i){return this.handleHydrationError(i),()=>{}}},e,this)}catch(r){this.handleHydrationError(r)}}attributeChangedCallback(){this.hydrate()}}l(f,\"observedAttributes\",[\"props\"]),customElements.get(\"astro-island\")||customElements.define(\"astro-island\",f)}})();";
7
7
  export default _default;
@@ -1,4 +1,4 @@
1
- var astro_island_prebuilt_default = `(()=>{var A=Object.defineProperty;var C=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var l=(i,o,a)=>C(i,typeof o!="symbol"?o+"":o,a);var E=new Set(["__proto__","constructor","prototype"]);{let i={0:t=>y(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},o=t=>{let[h,e]=t;return h in i?i[h](e):void 0},a=t=>t.map(o),y=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([h,e])=>[h,o(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,"Component");l(this,"hydrator");l(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},p=this.querySelectorAll("template[data-astro-template]");for(let r of p){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let u;try{u=this.hasAttribute("props")?y(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=\` (export \${v})\`),console.error(\`[hydrate] Error parsing props for component \${s}\`,this.getAttribute("props"),r),r}let d;await this.hydrator(this)(this.Component,u,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});l(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(\`astro:\${c}\`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[p,{default:u}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),d=this.getAttribute("component-export")||"default";if(d.includes(".")){this.Component=p;for(let m of d.split(".")){if(E.has(m)||!this.Component||typeof this.Component!="object"&&typeof this.Component!="function"||!Object.hasOwn(this.Component,m))throw new Error(\`Invalid component export path: \${d}\`);this.Component=this.Component[m]}}else{if(E.has(d))throw new Error(\`Invalid component export path: \${d}\`);this.Component=p[d]}return this.hydrator=u,this.hydrate},e,this)}catch(n){console.error("[astro-island] Error hydrating %s",this.getAttribute("component-url"),n)}}attributeChangedCallback(){this.hydrate()}}l(f,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",f)}})();`;
1
+ var astro_island_prebuilt_default = `(()=>{var g=Object.defineProperty;var w=(c,s,d)=>s in c?g(c,s,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[s]=d;var l=(c,s,d)=>w(c,typeof s!="symbol"?s+"":s,d);var E=new Set(["__proto__","constructor","prototype"]);{let c={0:t=>y(t),1:t=>d(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(d(t)),5:t=>new Set(d(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},s=t=>{let[p,e]=t;return p in c?c[p](e):void 0},d=t=>t.map(s),y=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([p,e])=>[p,s(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,"Component");l(this,"hydrator");l(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let n=this.querySelectorAll("astro-slot"),r={},i=this.querySelectorAll("template[data-astro-template]");for(let o of i){let a=o.closest(this.tagName);a!=null&&a.isSameNode(this)&&(r[o.getAttribute("data-astro-template")||"default"]=o.innerHTML,o.remove())}for(let o of n){let a=o.closest(this.tagName);a!=null&&a.isSameNode(this)&&(r[o.getAttribute("name")||"default"]=o.innerHTML)}let u;try{u=this.hasAttribute("props")?y(JSON.parse(this.getAttribute("props"))):{}}catch(o){let a=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(a+=\` (export \${v})\`),console.error(\`[hydrate] Error parsing props for component \${a}\`,this.getAttribute("props"),o),o}let h;await this.hydrator(this)(this.Component,u,r,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});l(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),n.disconnect(),this.childrenConnectedCallback()},n=new MutationObserver(()=>{var r;((r=this.lastChild)==null?void 0:r.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});n.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}getRetryImportUrl(e){let n=new URL(e,document.baseURI),r=\`astro-retry=\${Date.now()}\`,i=n.hash.replace(/^#/,"");return n.hash=i?\`\${i}&\${r}\`:r,n.toString()}async importWithRetry(e){try{return await import(e)}catch(n){return await new Promise(r=>setTimeout(r,1e3)),import(this.getRetryImportUrl(e))}}handleHydrationError(e){let n=this.getAttribute("component-url"),r=new CustomEvent("astro:hydration-error",{cancelable:!0,bubbles:!0,composed:!0,detail:{error:e,componentUrl:n}});this.dispatchEvent(r)&&console.error(\`[astro-island] Error hydrating \${n}\`,e)}async start(){let e=JSON.parse(this.getAttribute("opts")),n=this.getAttribute("client");if(Astro[n]===void 0){window.addEventListener(\`astro:\${n}\`,()=>this.start(),{once:!0});return}try{await Astro[n](async()=>{let r=this.getAttribute("renderer-url");try{let[i,{default:u}]=await Promise.all([this.importWithRetry(this.getAttribute("component-url")),r?this.importWithRetry(r):Promise.resolve({default:()=>()=>{}})]),h=this.getAttribute("component-export")||"default";if(h.includes(".")){this.Component=i;for(let m of h.split(".")){if(E.has(m)||!this.Component||typeof this.Component!="object"&&typeof this.Component!="function"||!Object.hasOwn(this.Component,m))throw new Error(\`Invalid component export path: \${h}\`);this.Component=this.Component[m]}}else{if(E.has(h))throw new Error(\`Invalid component export path: \${h}\`);this.Component=i[h]}return this.hydrator=u,this.hydrate}catch(i){return this.handleHydrationError(i),()=>{}}},e,this)}catch(r){this.handleHydrationError(r)}}attributeChangedCallback(){this.hydrate()}}l(f,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",f)}})();`;
2
2
  export {
3
3
  astro_island_prebuilt_default as default
4
4
  };
@@ -100,7 +100,8 @@ class ServerIslandComponent {
100
100
  }
101
101
  const componentPath = this.getComponentPath();
102
102
  const componentExport = this.getComponentExport();
103
- let componentId = this.result.serverIslandNameMap.get(componentPath);
103
+ const serverIslandNameMap = await this.result.getServerIslandNameMap();
104
+ let componentId = serverIslandNameMap.get(componentPath);
104
105
  if (!componentId) {
105
106
  throw new Error(`Could not find server component name ${componentPath}`);
106
107
  }
@@ -1328,23 +1328,25 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1328
1328
  * @description
1329
1329
  *
1330
1330
  * Configures session storage for your Astro project. This is used to store session data in a persistent way, so that it can be accessed across different requests.
1331
- * Some adapters may provide a default session driver, but you can override it with your own configuration.
1332
1331
  *
1333
- * See [the sessions guide](https://docs.astro.build/en/guides/sessions/) for more information.
1332
+ * Some adapters may provide a default session driver, but you can override it with your own configuration:
1334
1333
  *
1335
1334
  * ```js title="astro.config.mjs"
1336
- * {
1337
- * session: {
1338
- * // The name of the Unstorage driver
1339
- * driver: 'redis',
1340
- * // The required options depend on the driver
1341
- * options: {
1342
- * url: process.env.REDIS_URL,
1343
- * },
1344
- * ttl: 3600, // 1 hour
1345
- * }
1335
+ * import { defineConfig, sessionDrivers } from 'astro/config';
1336
+ *
1337
+ * export default defineConfig({
1338
+ * session: {
1339
+ * driver: sessionDrivers.redis({
1340
+ * // The options are driver-dependent and some may be required.
1341
+ * url: process.env.REDIS_URL
1342
+ * }),
1346
1343
  * }
1344
+ * });
1347
1345
  * ```
1346
+ *
1347
+ * Session drivers are configured at build time. This means environment variables used in the driver configuration are inlined. You must create your own driver entrypoint to [override the configuration at runtime](https://docs.astro.build/en/guides/sessions/#overriding-the-configuration-at-runtime).
1348
+ *
1349
+ * See [the sessions guide](https://docs.astro.build/en/guides/sessions/) for more information.
1348
1350
  */
1349
1351
  session?: SessionConfig<TDriver>;
1350
1352
  /**
@@ -1626,6 +1628,19 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1626
1628
  * ```
1627
1629
  */
1628
1630
  service?: ImageServiceConfig;
1631
+ /**
1632
+ * @docs
1633
+ * @name image.dangerouslyProcessSVG
1634
+ * @type {boolean}
1635
+ * @default `false`
1636
+ * @version 6.3.0
1637
+ * @description
1638
+ *
1639
+ * Allows SVG source images to be processed by the image optimization pipeline.
1640
+ *
1641
+ * This is disabled by default as specifically formed SVGs can be prohibitively expensive to process and used by malicious actors to execute denial of service attacks. Only enable this option if you trust the source of your SVG images and understand the risks of processing them.
1642
+ */
1643
+ dangerouslyProcessSVG?: boolean;
1629
1644
  /**
1630
1645
  * @docs
1631
1646
  * @name image.service.config.limitInputPixels
@@ -1766,6 +1781,8 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1766
1781
  * `pathname` patterns:
1767
1782
  * - End with `/**` to allow all sub-routes (like `startsWith`).
1768
1783
  * - End with `/*` to allow only one level of sub-route.
1784
+ *
1785
+ * HTTP redirects are also followed when an image URL matches a remote pattern. The final destination URL must be among the allowed remote patterns to be loaded.
1769
1786
 
1770
1787
  */
1771
1788
  remotePatterns?: Partial<RemotePattern>[];
@@ -2628,6 +2645,23 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2628
2645
  * These flags are not guaranteed to be stable.
2629
2646
  */
2630
2647
  experimental?: {
2648
+ /**
2649
+ * @name experimental.advancedRouting
2650
+ * @type {boolean}
2651
+ * @default `false`
2652
+ * @description
2653
+ * Enables `src/app.ts` as an advanced routing entrypoint, allowing you to
2654
+ * compose Astro's request pipeline with the Web Fetch standard or your own Hono middleware.
2655
+ *
2656
+ * ```js
2657
+ * export default defineConfig({
2658
+ * experimental: {
2659
+ * advancedRouting: true,
2660
+ * },
2661
+ * });
2662
+ * ```
2663
+ */
2664
+ advancedRouting?: boolean;
2631
2665
  /**
2632
2666
  *
2633
2667
  * @name experimental.clientPrerender
@@ -207,7 +207,7 @@ export interface SSRResult {
207
207
  */
208
208
  pathname: string;
209
209
  cookies: AstroCookies | undefined;
210
- serverIslandNameMap: Map<string, string>;
210
+ getServerIslandNameMap: () => Promise<Map<string, string>>;
211
211
  trailingSlash: AstroConfig['trailingSlash'];
212
212
  key: Promise<CryptoKey>;
213
213
  _metadata: SSRMetadata;
@@ -1,18 +1,18 @@
1
1
  import type http from 'node:http';
2
- import { BaseApp, type RenderErrorOptions } from '../core/app/entrypoints/index.js';
2
+ import { BaseApp } from '../core/app/entrypoints/index.js';
3
+ import type { ErrorHandler } from '../core/errors/handler.js';
3
4
  import type { AstroLogger } from '../core/logger/core.js';
4
5
  import type { ModuleLoader } from '../core/module-loader/index.js';
5
- import type { CreateRenderContext, RenderContext } from '../core/render-context.js';
6
6
  import type { AstroSettings, RoutesList } from '../types/astro.js';
7
7
  import type { RouteData, SSRManifest } from '../types/public/index.js';
8
8
  import type { DevServerController } from '../vite-plugin-astro-server/controller.js';
9
9
  import { RunnablePipeline } from './pipeline.js';
10
10
  import type { DevMatch, LogRequestPayload } from '../core/app/base.js';
11
11
  export declare class AstroServerApp extends BaseApp<RunnablePipeline> {
12
+ #private;
12
13
  settings: AstroSettings;
13
14
  loader: ModuleLoader;
14
15
  manifestData: RoutesList;
15
- currentRenderContext: RenderContext | undefined;
16
16
  constructor(manifest: SSRManifest, streaming: boolean | undefined, logger: AstroLogger, manifestData: RoutesList, loader: ModuleLoader, settings: AstroSettings, getDebugInfo: () => Promise<string>);
17
17
  isDev(): boolean;
18
18
  /**
@@ -33,10 +33,9 @@ export declare class AstroServerApp extends BaseApp<RunnablePipeline> {
33
33
  devMatch(pathname: string): Promise<DevMatch | undefined>;
34
34
  static create(manifest: SSRManifest, routesList: RoutesList, logger: AstroLogger, loader: ModuleLoader, settings: AstroSettings, getDebugInfo: () => Promise<string>): Promise<AstroServerApp>;
35
35
  createPipeline(_streaming: boolean, manifest: SSRManifest, settings: AstroSettings, logger: AstroLogger, loader: ModuleLoader, manifestData: RoutesList, getDebugInfo: () => Promise<string>): RunnablePipeline;
36
- createRenderContext(payload: CreateRenderContext): Promise<RenderContext>;
37
36
  handleRequest({ controller, incomingRequest, incomingResponse, isHttps, }: HandleRequest): Promise<void>;
38
37
  match(request: Request, _allowPrerenderedRoutes: boolean): RouteData | undefined;
39
- renderError(request: Request, { skipMiddleware, error, status, response: _response, ...resolvedRenderOptions }: RenderErrorOptions): Promise<Response>;
38
+ protected createErrorHandler(): ErrorHandler;
40
39
  logRequest({ pathname, method, statusCode, isRewrite, reqTime }: LogRequestPayload): void;
41
40
  }
42
41
  type HandleRequest = {
@@ -3,17 +3,13 @@ import { BaseApp } from "../core/app/entrypoints/index.js";
3
3
  import { getFirstForwardedValue, validateForwardedHeaders } from "../core/app/validate-headers.js";
4
4
  import { shouldAppendForwardSlash } from "../core/build/util.js";
5
5
  import { clientLocalsSymbol } from "../core/constants.js";
6
- import {
7
- MiddlewareNoDataOrNextCalled,
8
- MiddlewareNotAResponse
9
- } from "../core/errors/errors-data.js";
10
- import { createSafeError, isAstroError } from "../core/errors/index.js";
6
+ import { createSafeError } from "../core/errors/index.js";
7
+ import { DevErrorHandler } from "../core/errors/dev-handler.js";
11
8
  import { createRequest } from "../core/request.js";
12
9
  import { recordServerError } from "../vite-plugin-astro-server/error.js";
13
10
  import { runWithErrorHandling } from "../vite-plugin-astro-server/index.js";
14
11
  import { handle500Response, writeSSRResult } from "../vite-plugin-astro-server/response.js";
15
12
  import { RunnablePipeline } from "./pipeline.js";
16
- import { getCustom404Route, getCustom500Route } from "../core/routing/helpers.js";
17
13
  import { ensure404Route } from "../core/routing/astro-designed-error-pages.js";
18
14
  import { matchRoute } from "../core/routing/dev.js";
19
15
  import { req } from "../core/messages/runtime.js";
@@ -21,13 +17,27 @@ class AstroServerApp extends BaseApp {
21
17
  settings;
22
18
  loader;
23
19
  manifestData;
24
- currentRenderContext = void 0;
25
20
  constructor(manifest, streaming = true, logger, manifestData, loader, settings, getDebugInfo) {
26
21
  super(manifest, streaming, settings, logger, loader, manifestData, getDebugInfo);
27
22
  this.settings = settings;
28
23
  this.loader = loader;
29
24
  this.manifestData = manifestData;
30
25
  }
26
+ /**
27
+ * Loads the user's `src/app.ts` (via `virtual:astro:fetchable`) and
28
+ * sets it as the fetch handler. Called on every request so that HMR
29
+ * invalidation of the virtual module is picked up automatically.
30
+ * Vite caches the module internally so repeated calls are cheap.
31
+ */
32
+ async #loadFetchHandler() {
33
+ try {
34
+ const mod = await this.loader.import("virtual:astro:fetchable");
35
+ if (mod?.default) {
36
+ this.setFetchHandler(mod.default);
37
+ }
38
+ } catch {
39
+ }
40
+ }
31
41
  isDev() {
32
42
  return true;
33
43
  }
@@ -82,10 +92,6 @@ class AstroServerApp extends BaseApp {
82
92
  });
83
93
  return pipeline;
84
94
  }
85
- async createRenderContext(payload) {
86
- this.currentRenderContext = await super.createRenderContext(payload);
87
- return this.currentRenderContext;
88
- }
89
95
  async handleRequest({
90
96
  controller,
91
97
  incomingRequest,
@@ -124,6 +130,7 @@ class AstroServerApp extends BaseApp {
124
130
  body = Buffer.concat(bytes);
125
131
  }
126
132
  const self = this;
133
+ await self.#loadFetchHandler();
127
134
  await runWithErrorHandling({
128
135
  controller,
129
136
  pathname,
@@ -171,60 +178,8 @@ class AstroServerApp extends BaseApp {
171
178
  match(request, _allowPrerenderedRoutes) {
172
179
  return super.match(request, true);
173
180
  }
174
- async renderError(request, {
175
- skipMiddleware = false,
176
- error,
177
- status,
178
- response: _response,
179
- ...resolvedRenderOptions
180
- }) {
181
- if (isAstroError(error) && [MiddlewareNoDataOrNextCalled.name, MiddlewareNotAResponse.name].includes(error.name)) {
182
- throw error;
183
- }
184
- const renderRoute = async (routeData) => {
185
- try {
186
- const preloadedComponent = await this.pipeline.getComponentByRoute(routeData);
187
- const renderContext = await this.createRenderContext({
188
- locals: resolvedRenderOptions.locals,
189
- pipeline: this.pipeline,
190
- pathname: this.getPathnameFromRequest(request),
191
- skipMiddleware,
192
- request,
193
- routeData,
194
- clientAddress: resolvedRenderOptions.clientAddress,
195
- status,
196
- shouldInjectCspMetaTags: !!this.manifest.csp
197
- });
198
- renderContext.props.error = error;
199
- const response = await renderContext.render(preloadedComponent);
200
- if (error) {
201
- this.logger.error("router", error.stack || error.message);
202
- }
203
- return response;
204
- } catch (_err) {
205
- if (skipMiddleware === false) {
206
- return this.renderError(request, {
207
- ...resolvedRenderOptions,
208
- status: 500,
209
- skipMiddleware: true,
210
- error: _err
211
- });
212
- }
213
- throw _err;
214
- }
215
- };
216
- if (status === 404) {
217
- const custom404 = getCustom404Route(this.manifestData);
218
- if (custom404) {
219
- return renderRoute(custom404);
220
- }
221
- }
222
- const custom500 = getCustom500Route(this.manifestData);
223
- if (!custom500) {
224
- throw error;
225
- } else {
226
- return renderRoute(custom500);
227
- }
181
+ createErrorHandler() {
182
+ return new DevErrorHandler(this, { shouldInjectCspMetaTags: true });
228
183
  }
229
184
  logRequest({ pathname, method, statusCode, isRewrite, reqTime }) {
230
185
  if (pathname === "/favicon.ico") {