astro 2.10.3 → 2.10.5

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.
@@ -10,7 +10,9 @@ declare module 'astro:content' {
10
10
 
11
11
  declare module 'astro:content' {
12
12
  export { z } from 'astro/zod';
13
- export type CollectionEntry<C extends keyof AnyEntryMap> = AnyEntryMap[C][keyof AnyEntryMap[C]];
13
+
14
+ type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
15
+ export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;
14
16
 
15
17
  // TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04
16
18
  /**
@@ -1186,6 +1186,27 @@ export interface AstroUserConfig {
1186
1186
  * ```
1187
1187
  */
1188
1188
  viewTransitions?: boolean;
1189
+ /**
1190
+ * @docs
1191
+ * @name experimental.optimizeHoistedScript
1192
+ * @type {boolean}
1193
+ * @default `false`
1194
+ * @version 2.10.4
1195
+ * @description
1196
+ * Prevents unused components' scripts from being included in a page unexpectedly.
1197
+ * The optimization is best-effort and may inversely miss including the used scripts. Make sure to double-check your built pages
1198
+ * before publishing.
1199
+ * Enable hoisted script analysis optimization by adding the experimental flag:
1200
+ *
1201
+ * ```js
1202
+ * {
1203
+ * experimental: {
1204
+ * optimizeHoistedScript: true,
1205
+ * },
1206
+ * }
1207
+ * ```
1208
+ */
1209
+ optimizeHoistedScript?: boolean;
1189
1210
  };
1190
1211
  /** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
1191
1212
  renderers?: never;
@@ -1653,10 +1674,13 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
1653
1674
  */
1654
1675
  locals: App.Locals;
1655
1676
  }
1656
- export interface EndpointOutput {
1677
+ export type EndpointOutput = {
1657
1678
  body: Body;
1658
- encoding?: BufferEncoding;
1659
- }
1679
+ encoding?: Exclude<BufferEncoding, 'binary'>;
1680
+ } | {
1681
+ body: Uint8Array;
1682
+ encoding: 'binary';
1683
+ };
1660
1684
  export type APIRoute<Props extends Record<string, any> = Record<string, any>> = (context: APIContext<Props>) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
1661
1685
  export interface EndpointHandler {
1662
1686
  [method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
@@ -162,7 +162,6 @@ class App {
162
162
  }
163
163
  return response.response;
164
164
  } else {
165
- const body = response.body;
166
165
  const headers = new Headers();
167
166
  const mimeType = mime.getType(url.pathname);
168
167
  if (mimeType) {
@@ -170,7 +169,7 @@ class App {
170
169
  } else {
171
170
  headers.set("Content-Type", "text/plain;charset=utf-8");
172
171
  }
173
- const bytes = this.#encoder.encode(body);
172
+ const bytes = response.encoding !== "binary" ? this.#encoder.encode(response.body) : response.body;
174
173
  headers.set("Content-Length", bytes.byteLength.toString());
175
174
  const newResponse = new Response(bytes, {
176
175
  status: 200,
@@ -14,7 +14,7 @@ import { pluginSSR, pluginSSRSplit } from "./plugin-ssr.js";
14
14
  function registerAllPlugins({ internals, options, register }) {
15
15
  register(pluginComponentEntry(internals));
16
16
  register(pluginAliasResolve(internals));
17
- register(pluginAnalyzer(internals));
17
+ register(pluginAnalyzer(options, internals));
18
18
  register(pluginInternals(internals));
19
19
  register(pluginRenderers(options));
20
20
  register(pluginMiddleware(options, internals));
@@ -1,5 +1,6 @@
1
1
  import type { Plugin as VitePlugin } from 'vite';
2
2
  import type { BuildInternals } from '../internal.js';
3
3
  import type { AstroBuildPlugin } from '../plugin.js';
4
- export declare function vitePluginAnalyzer(internals: BuildInternals): VitePlugin;
5
- export declare function pluginAnalyzer(internals: BuildInternals): AstroBuildPlugin;
4
+ import type { StaticBuildOptions } from '../types.js';
5
+ export declare function vitePluginAnalyzer(options: StaticBuildOptions, internals: BuildInternals): VitePlugin;
6
+ export declare function pluginAnalyzer(options: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
@@ -1,4 +1,3 @@
1
- import { walk } from "estree-walker";
2
1
  import { PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
3
2
  import { prependForwardSlash } from "../../../core/path.js";
4
3
  import { getTopLevelPages, moduleIsTopLevelPage, walkParentInfos } from "../graph.js";
@@ -19,15 +18,13 @@ async function doesParentImportChild(parentInfo, childInfo, childExportNames) {
19
18
  }
20
19
  const imports = [];
21
20
  const exports = [];
22
- walk(parentInfo.ast, {
23
- enter(node) {
24
- if (node.type === "ImportDeclaration") {
25
- imports.push(node);
26
- } else if (node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration") {
27
- exports.push(node);
28
- }
21
+ for (const node of parentInfo.ast.body) {
22
+ if (node.type === "ImportDeclaration") {
23
+ imports.push(node);
24
+ } else if (node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration") {
25
+ exports.push(node);
29
26
  }
30
- });
27
+ }
31
28
  const importNames = [];
32
29
  const exportNames = [];
33
30
  for (const node of imports) {
@@ -89,7 +86,7 @@ async function doesParentImportChild(parentInfo, childInfo, childExportNames) {
89
86
  }
90
87
  return exportNames;
91
88
  }
92
- function vitePluginAnalyzer(internals) {
89
+ function vitePluginAnalyzer(options, internals) {
93
90
  function hoistedScriptScanner() {
94
91
  const uniqueHoistedIds = /* @__PURE__ */ new Map();
95
92
  const pageScripts = /* @__PURE__ */ new Map();
@@ -108,20 +105,22 @@ function vitePluginAnalyzer(internals) {
108
105
  for (const [parentInfo, depth] of walkParentInfos(from, this, function until(importer) {
109
106
  return isPropagatedAsset(importer);
110
107
  })) {
111
- depthsToChildren.set(depth, parentInfo);
112
- if (depth > 0) {
113
- const childInfo = depthsToChildren.get(depth - 1);
114
- const childExportNames = depthsToExportNames.get(depth - 1);
115
- const doesImport = await doesParentImportChild.call(
116
- this,
117
- parentInfo,
118
- childInfo,
119
- childExportNames
120
- );
121
- if (doesImport === "no") {
122
- continue;
108
+ if (options.settings.config.experimental.optimizeHoistedScript) {
109
+ depthsToChildren.set(depth, parentInfo);
110
+ if (depth > 0) {
111
+ const childInfo = depthsToChildren.get(depth - 1);
112
+ const childExportNames = depthsToExportNames.get(depth - 1);
113
+ const doesImport = await doesParentImportChild.call(
114
+ this,
115
+ parentInfo,
116
+ childInfo,
117
+ childExportNames
118
+ );
119
+ if (doesImport === "no") {
120
+ continue;
121
+ }
122
+ depthsToExportNames.set(depth, doesImport);
123
123
  }
124
- depthsToExportNames.set(depth, doesImport);
125
124
  }
126
125
  if (isPropagatedAsset(parentInfo.id)) {
127
126
  for (const [nestedParentInfo] of walkParentInfos(from, this)) {
@@ -241,13 +240,13 @@ function vitePluginAnalyzer(internals) {
241
240
  }
242
241
  };
243
242
  }
244
- function pluginAnalyzer(internals) {
243
+ function pluginAnalyzer(options, internals) {
245
244
  return {
246
245
  build: "ssr",
247
246
  hooks: {
248
247
  "build:before": () => {
249
248
  return {
250
- vitePlugin: vitePluginAnalyzer(internals)
249
+ vitePlugin: vitePluginAnalyzer(options, internals)
251
250
  };
252
251
  }
253
252
  }
@@ -179,18 +179,23 @@ export declare const AstroConfigSchema: z.ZodObject<{
179
179
  experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
180
180
  assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
181
181
  viewTransitions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
182
+ optimizeHoistedScript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
182
183
  }, "passthrough", z.ZodTypeAny, {
183
184
  assets: boolean;
184
185
  viewTransitions: boolean;
186
+ optimizeHoistedScript: boolean;
185
187
  }, {
186
188
  assets?: boolean | undefined;
187
189
  viewTransitions?: boolean | undefined;
190
+ optimizeHoistedScript?: boolean | undefined;
188
191
  }>, {
189
192
  assets: boolean;
190
193
  viewTransitions: boolean;
194
+ optimizeHoistedScript: boolean;
191
195
  }, {
192
196
  assets?: boolean | undefined;
193
197
  viewTransitions?: boolean | undefined;
198
+ optimizeHoistedScript?: boolean | undefined;
194
199
  }>>>;
195
200
  legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
196
201
  }, "strip", z.ZodTypeAny, {
@@ -259,6 +264,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
259
264
  experimental: {
260
265
  assets: boolean;
261
266
  viewTransitions: boolean;
267
+ optimizeHoistedScript: boolean;
262
268
  };
263
269
  legacy: {};
264
270
  }, {
@@ -319,6 +325,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
319
325
  experimental?: {
320
326
  assets?: boolean | undefined;
321
327
  viewTransitions?: boolean | undefined;
328
+ optimizeHoistedScript?: boolean | undefined;
322
329
  } | undefined;
323
330
  legacy?: {} | undefined;
324
331
  }>;
@@ -435,18 +442,23 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
435
442
  experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
436
443
  assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
437
444
  viewTransitions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
445
+ optimizeHoistedScript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
438
446
  }, "passthrough", z.ZodTypeAny, {
439
447
  assets: boolean;
440
448
  viewTransitions: boolean;
449
+ optimizeHoistedScript: boolean;
441
450
  }, {
442
451
  assets?: boolean | undefined;
443
452
  viewTransitions?: boolean | undefined;
453
+ optimizeHoistedScript?: boolean | undefined;
444
454
  }>, {
445
455
  assets: boolean;
446
456
  viewTransitions: boolean;
457
+ optimizeHoistedScript: boolean;
447
458
  }, {
448
459
  assets?: boolean | undefined;
449
460
  viewTransitions?: boolean | undefined;
461
+ optimizeHoistedScript?: boolean | undefined;
450
462
  }>>>;
451
463
  legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
452
464
  root: z.ZodEffects<z.ZodDefault<z.ZodString>, import("url").URL, string | undefined>;
@@ -581,6 +593,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
581
593
  experimental: {
582
594
  assets: boolean;
583
595
  viewTransitions: boolean;
596
+ optimizeHoistedScript: boolean;
584
597
  };
585
598
  legacy: {};
586
599
  }, {
@@ -641,6 +654,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
641
654
  experimental?: {
642
655
  assets?: boolean | undefined;
643
656
  viewTransitions?: boolean | undefined;
657
+ optimizeHoistedScript?: boolean | undefined;
644
658
  } | undefined;
645
659
  legacy?: {} | undefined;
646
660
  }>, {
@@ -710,6 +724,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
710
724
  experimental: {
711
725
  assets: boolean;
712
726
  viewTransitions: boolean;
727
+ optimizeHoistedScript: boolean;
713
728
  };
714
729
  legacy: {};
715
730
  }, {
@@ -770,6 +785,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
770
785
  experimental?: {
771
786
  assets?: boolean | undefined;
772
787
  viewTransitions?: boolean | undefined;
788
+ optimizeHoistedScript?: boolean | undefined;
773
789
  } | undefined;
774
790
  legacy?: {} | undefined;
775
791
  }>;
@@ -39,7 +39,8 @@ const ASTRO_CONFIG_DEFAULTS = {
39
39
  redirects: {},
40
40
  experimental: {
41
41
  assets: false,
42
- viewTransitions: false
42
+ viewTransitions: false,
43
+ optimizeHoistedScript: false
43
44
  }
44
45
  };
45
46
  const AstroConfigSchema = z.object({
@@ -143,7 +144,8 @@ const AstroConfigSchema = z.object({
143
144
  vite: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.vite),
144
145
  experimental: z.object({
145
146
  assets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.assets),
146
- viewTransitions: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.viewTransitions)
147
+ viewTransitions: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.viewTransitions),
148
+ optimizeHoistedScript: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.optimizeHoistedScript)
147
149
  }).passthrough().refine(
148
150
  (d) => {
149
151
  const validKeys = Object.keys(ASTRO_CONFIG_DEFAULTS.experimental);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.10.3";
1
+ const ASTRO_VERSION = "2.10.5";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
23
23
  base: restart.container.settings.config.base
24
24
  })
25
25
  );
26
- const currentVersion = "2.10.3";
26
+ const currentVersion = "2.10.5";
27
27
  if (currentVersion.includes("-")) {
28
28
  warn(logging, null, msg.prerelease({ currentVersion }));
29
29
  }
@@ -1,13 +1,10 @@
1
- /// <reference types="node" />
2
1
  import type { APIContext, EndpointHandler, EndpointOutput, MiddlewareHandler, Params } from '../../@types/astro';
3
2
  import type { Environment, RenderContext } from '../render/index';
4
3
  import { AstroCookies } from '../cookies/index.js';
5
- export type EndpointCallResult = {
4
+ export type EndpointCallResult = (EndpointOutput & {
6
5
  type: 'simple';
7
- body: string;
8
- encoding?: BufferEncoding;
9
6
  cookies: AstroCookies;
10
- } | {
7
+ }) | {
11
8
  type: 'response';
12
9
  response: Response;
13
10
  };
@@ -104,9 +104,8 @@ async function callEndpoint(mod, env, ctx, onRequest) {
104
104
  }
105
105
  }
106
106
  return {
107
+ ...response,
107
108
  type: "simple",
108
- body: response.body,
109
- encoding: response.encoding,
110
109
  cookies: context.cookies
111
110
  };
112
111
  }
@@ -47,7 +47,7 @@ function serverStart({
47
47
  base,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "2.10.3";
50
+ const version = "2.10.5";
51
51
  const localPrefix = `${dim("\u2503")} Local `;
52
52
  const networkPrefix = `${dim("\u2503")} Network `;
53
53
  const emptyPrefix = " ".repeat(11);
@@ -233,7 +233,7 @@ function printHelp({
233
233
  message.push(
234
234
  linebreak(),
235
235
  ` ${bgGreen(black(` ${commandName} `))} ${green(
236
- `v${"2.10.3"}`
236
+ `v${"2.10.5"}`
237
237
  )} ${headline}`
238
238
  );
239
239
  }
@@ -3,10 +3,9 @@ const renderer = {
3
3
  serverEntrypoint: "astro/jsx/server.js",
4
4
  jsxImportSource: "astro",
5
5
  jsxTransformOptions: async () => {
6
- const {
7
- default: { default: jsx }
8
- // @ts-expect-error
9
- } = await import("@babel/plugin-transform-react-jsx");
6
+ var _a;
7
+ const plugin = await import("@babel/plugin-transform-react-jsx");
8
+ const jsx = ((_a = plugin.default) == null ? void 0 : _a.default) ?? plugin.default;
10
9
  const { default: astroJSX } = await import("./babel.js");
11
10
  return {
12
11
  plugins: [
@@ -1,24 +1,28 @@
1
1
  var _a;
2
2
  {
3
3
  const propTypes = {
4
- 0: (value) => value,
5
- 1: (value) => JSON.parse(value, reviver),
4
+ 0: (value) => reviveObject(value),
5
+ 1: (value) => reviveArray(value),
6
6
  2: (value) => new RegExp(value),
7
7
  3: (value) => new Date(value),
8
- 4: (value) => new Map(JSON.parse(value, reviver)),
9
- 5: (value) => new Set(JSON.parse(value, reviver)),
8
+ 4: (value) => new Map(reviveArray(value)),
9
+ 5: (value) => new Set(reviveArray(value)),
10
10
  6: (value) => BigInt(value),
11
11
  7: (value) => new URL(value),
12
- 8: (value) => new Uint8Array(JSON.parse(value)),
13
- 9: (value) => new Uint16Array(JSON.parse(value)),
14
- 10: (value) => new Uint32Array(JSON.parse(value))
12
+ 8: (value) => new Uint8Array(value),
13
+ 9: (value) => new Uint16Array(value),
14
+ 10: (value) => new Uint32Array(value)
15
15
  };
16
- const reviver = (propKey, raw) => {
17
- if (propKey === "" || !Array.isArray(raw))
18
- return raw;
16
+ const reviveTuple = (raw) => {
19
17
  const [type, value] = raw;
20
18
  return type in propTypes ? propTypes[type](value) : void 0;
21
19
  };
20
+ const reviveArray = (raw) => raw.map(reviveTuple);
21
+ const reviveObject = (raw) => {
22
+ if (typeof raw !== "object" || raw === null)
23
+ return raw;
24
+ return Object.fromEntries(Object.entries(raw).map(([key, value]) => [key, reviveTuple(value)]));
25
+ };
22
26
  if (!customElements.get("astro-island")) {
23
27
  customElements.define(
24
28
  "astro-island",
@@ -54,7 +58,7 @@ var _a;
54
58
  }
55
59
  let props;
56
60
  try {
57
- props = this.hasAttribute("props") ? JSON.parse(this.getAttribute("props"), reviver) : {};
61
+ props = this.hasAttribute("props") ? reviveObject(JSON.parse(this.getAttribute("props"))) : {};
58
62
  } catch (e) {
59
63
  let componentName = this.getAttribute("component-url") || "<unknown>";
60
64
  const componentExport = this.getAttribute("component-export");
@@ -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 d;{let p={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,r)=>{if(t===\"\"||!Array.isArray(r))return r;let[s,i]=r;return s in p?p[s](i):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var o;if(!this.hydrator||!this.isConnected)return;let r=(o=this.parentElement)==null?void 0:o.closest(\"astro-island[ssr]\");if(r){r.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let s=this.querySelectorAll(\"astro-slot\"),i={},c=this.querySelectorAll(\"template[data-astro-template]\");for(let e of c){let n=e.closest(this.tagName);n!=null&&n.isSameNode(this)&&(i[e.getAttribute(\"data-astro-template\")||\"default\"]=e.innerHTML,e.remove())}for(let e of s){let n=e.closest(this.tagName);n!=null&&n.isSameNode(this)&&(i[e.getAttribute(\"name\")||\"default\"]=e.innerHTML)}let l;try{l=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),a):{}}catch(e){let n=this.getAttribute(\"component-url\")||\"<unknown>\",h=this.getAttribute(\"component-export\");throw h&&(n+=` (export ${h})`),console.error(`[hydrate] Error parsing props for component ${n}`,this.getAttribute(\"props\"),e),e}await this.hydrator(this)(this.Component,l,i,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),this.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((r,s)=>{s.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let r=this.getAttribute(\"before-hydration-url\");r&&await import(r),this.start()}start(){let r=JSON.parse(this.getAttribute(\"opts\")),s=this.getAttribute(\"client\");if(Astro[s]===void 0){window.addEventListener(`astro:${s}`,()=>this.start(),{once:!0});return}Astro[s](async()=>{let i=this.getAttribute(\"renderer-url\"),[c,{default:l}]=await Promise.all([import(this.getAttribute(\"component-url\")),i?import(i):()=>()=>{}]),o=this.getAttribute(\"component-export\")||\"default\";if(!o.includes(\".\"))this.Component=c[o];else{this.Component=c;for(let e of o.split(\".\"))this.Component=this.Component[e]}return this.hydrator=l,this.hydrate},r,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=[\"props\"],d))}})();";
6
+ declare const _default: "(()=>{var d;{let p={0:t=>u(t),1:t=>l(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(l(t)),5:t=>new Set(l(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)},h=t=>{let[e,n]=t;return e in p?p[e](n):void 0},l=t=>t.map(h),u=t=>typeof t!=\"object\"||t===null?t:Object.fromEntries(Object.entries(t).map(([e,n])=>[e,h(n)]));customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var i;if(!this.hydrator||!this.isConnected)return;let e=(i=this.parentElement)==null?void 0:i.closest(\"astro-island[ssr]\");if(e){e.addEventListener(\"astro:hydrate\",this.hydrate,{once:!0});return}let n=this.querySelectorAll(\"astro-slot\"),o={},a=this.querySelectorAll(\"template[data-astro-template]\");for(let r of a){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(let r of n){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}let c;try{c=this.hasAttribute(\"props\")?u(JSON.parse(this.getAttribute(\"props\"))):{}}catch(r){let s=this.getAttribute(\"component-url\")||\"<unknown>\",y=this.getAttribute(\"component-export\");throw y&&(s+=` (export ${y})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute(\"props\"),r),r}await this.hydrator(this)(this.Component,c,o,{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,n)=>{n.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\")),n=this.getAttribute(\"client\");if(Astro[n]===void 0){window.addEventListener(`astro:${n}`,()=>this.start(),{once:!0});return}Astro[n](async()=>{let o=this.getAttribute(\"renderer-url\"),[a,{default:c}]=await Promise.all([import(this.getAttribute(\"component-url\")),o?import(o):()=>()=>{}]),i=this.getAttribute(\"component-export\")||\"default\";if(!i.includes(\".\"))this.Component=a[i];else{this.Component=a;for(let r of i.split(\".\"))this.Component=this.Component[r]}return this.hydrator=c,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=[\"props\"],d))}})();";
7
7
  export default _default;
@@ -1,4 +1,4 @@
1
- var astro_island_prebuilt_default = `(()=>{var d;{let p={0:t=>t,1:t=>JSON.parse(t,a),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,a)),5:t=>new Set(JSON.parse(t,a)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},a=(t,r)=>{if(t===""||!Array.isArray(r))return r;let[s,i]=r;return s in p?p[s](i):void 0};customElements.get("astro-island")||customElements.define("astro-island",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var o;if(!this.hydrator||!this.isConnected)return;let r=(o=this.parentElement)==null?void 0:o.closest("astro-island[ssr]");if(r){r.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let s=this.querySelectorAll("astro-slot"),i={},c=this.querySelectorAll("template[data-astro-template]");for(let e of c){let n=e.closest(this.tagName);n!=null&&n.isSameNode(this)&&(i[e.getAttribute("data-astro-template")||"default"]=e.innerHTML,e.remove())}for(let e of s){let n=e.closest(this.tagName);n!=null&&n.isSameNode(this)&&(i[e.getAttribute("name")||"default"]=e.innerHTML)}let l;try{l=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),a):{}}catch(e){let n=this.getAttribute("component-url")||"<unknown>",h=this.getAttribute("component-export");throw h&&(n+=\` (export \${h})\`),console.error(\`[hydrate] Error parsing props for component \${n}\`,this.getAttribute("props"),e),e}await this.hydrator(this)(this.Component,l,i,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((r,s)=>{s.disconnect(),setTimeout(()=>this.childrenConnectedCallback(),0)}).observe(this,{childList:!0})}async childrenConnectedCallback(){let r=this.getAttribute("before-hydration-url");r&&await import(r),this.start()}start(){let r=JSON.parse(this.getAttribute("opts")),s=this.getAttribute("client");if(Astro[s]===void 0){window.addEventListener(\`astro:\${s}\`,()=>this.start(),{once:!0});return}Astro[s](async()=>{let i=this.getAttribute("renderer-url"),[c,{default:l}]=await Promise.all([import(this.getAttribute("component-url")),i?import(i):()=>()=>{}]),o=this.getAttribute("component-export")||"default";if(!o.includes("."))this.Component=c[o];else{this.Component=c;for(let e of o.split("."))this.Component=this.Component[e]}return this.hydrator=l,this.hydrate},r,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
1
+ var astro_island_prebuilt_default = `(()=>{var d;{let p={0:t=>u(t),1:t=>l(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(l(t)),5:t=>new Set(l(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)},h=t=>{let[e,n]=t;return e in p?p[e](n):void 0},l=t=>t.map(h),u=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([e,n])=>[e,h(n)]));customElements.get("astro-island")||customElements.define("astro-island",(d=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=async()=>{var i;if(!this.hydrator||!this.isConnected)return;let e=(i=this.parentElement)==null?void 0:i.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let n=this.querySelectorAll("astro-slot"),o={},a=this.querySelectorAll("template[data-astro-template]");for(let r of a){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of n){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(o[r.getAttribute("name")||"default"]=r.innerHTML)}let c;try{c=this.hasAttribute("props")?u(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",y=this.getAttribute("component-export");throw y&&(s+=\` (export \${y})\`),console.error(\`[hydrate] Error parsing props for component \${s}\`,this.getAttribute("props"),r),r}await this.hydrator(this)(this.Component,c,o,{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,n)=>{n.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")),n=this.getAttribute("client");if(Astro[n]===void 0){window.addEventListener(\`astro:\${n}\`,()=>this.start(),{once:!0});return}Astro[n](async()=>{let o=this.getAttribute("renderer-url"),[a,{default:c}]=await Promise.all([import(this.getAttribute("component-url")),o?import(o):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(let r of i.split("."))this.Component=this.Component[r]}return this.hydrator=c,this.hydrate},e,this)}attributeChangedCallback(){this.hydrate()}},d.observedAttributes=["props"],d))}})();`;
2
2
  export {
3
3
  astro_island_prebuilt_default as default
4
4
  };
@@ -1,6 +1,7 @@
1
1
  const PROP_TYPE = {
2
2
  Value: 0,
3
3
  JSON: 1,
4
+ // Actually means Array
4
5
  RegExp: 2,
5
6
  Date: 3,
6
7
  Map: 4,
@@ -49,16 +50,10 @@ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */
49
50
  return [PROP_TYPE.RegExp, value.source];
50
51
  }
51
52
  case "[object Map]": {
52
- return [
53
- PROP_TYPE.Map,
54
- JSON.stringify(serializeArray(Array.from(value), metadata, parents))
55
- ];
53
+ return [PROP_TYPE.Map, serializeArray(Array.from(value), metadata, parents)];
56
54
  }
57
55
  case "[object Set]": {
58
- return [
59
- PROP_TYPE.Set,
60
- JSON.stringify(serializeArray(Array.from(value), metadata, parents))
61
- ];
56
+ return [PROP_TYPE.Set, serializeArray(Array.from(value), metadata, parents)];
62
57
  }
63
58
  case "[object BigInt]": {
64
59
  return [PROP_TYPE.BigInt, value.toString()];
@@ -67,16 +62,16 @@ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */
67
62
  return [PROP_TYPE.URL, value.toString()];
68
63
  }
69
64
  case "[object Array]": {
70
- return [PROP_TYPE.JSON, JSON.stringify(serializeArray(value, metadata, parents))];
65
+ return [PROP_TYPE.JSON, serializeArray(value, metadata, parents)];
71
66
  }
72
67
  case "[object Uint8Array]": {
73
- return [PROP_TYPE.Uint8Array, JSON.stringify(Array.from(value))];
68
+ return [PROP_TYPE.Uint8Array, Array.from(value)];
74
69
  }
75
70
  case "[object Uint16Array]": {
76
- return [PROP_TYPE.Uint16Array, JSON.stringify(Array.from(value))];
71
+ return [PROP_TYPE.Uint16Array, Array.from(value)];
77
72
  }
78
73
  case "[object Uint32Array]": {
79
- return [PROP_TYPE.Uint32Array, JSON.stringify(Array.from(value))];
74
+ return [PROP_TYPE.Uint32Array, Array.from(value)];
80
75
  }
81
76
  default: {
82
77
  if (value !== null && typeof value === "object") {
@@ -178,12 +178,15 @@ async function handleRoute({
178
178
  if (computedMimeType) {
179
179
  contentType = computedMimeType;
180
180
  }
181
- const response = new Response(Buffer.from(result.body, result.encoding), {
182
- status: 200,
183
- headers: {
184
- "Content-Type": `${contentType};charset=utf-8`
181
+ const response = new Response(
182
+ result.encoding !== "binary" ? Buffer.from(result.body, result.encoding) : result.body,
183
+ {
184
+ status: 200,
185
+ headers: {
186
+ "Content-Type": `${contentType};charset=utf-8`
187
+ }
185
188
  }
186
- });
189
+ );
187
190
  attachToResponse(response, result.cookies);
188
191
  await writeWebResponse(incomingResponse, response);
189
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.10.3",
3
+ "version": "2.10.5",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",