astro 5.6.1 → 5.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,11 @@
4
4
  *
5
5
  * If some functions don't need to be exposed, just import the file that contains the functions.
6
6
  */
7
- export { emitESMImage } from './node/emitAsset.js';
7
+ export {
8
+ /**
9
+ * @deprecated
10
+ */
11
+ emitESMImage, emitImageMetadata, } from './node/emitAsset.js';
8
12
  export { isESMImportedImage, isRemoteImage } from './imageKind.js';
9
13
  export { imageMetadata } from './metadata.js';
10
14
  export { getOrigQueryParams } from './queryParams.js';
@@ -1,4 +1,7 @@
1
- import { emitESMImage } from "./node/emitAsset.js";
1
+ import {
2
+ emitESMImage,
3
+ emitImageMetadata
4
+ } from "./node/emitAsset.js";
2
5
  import { isESMImportedImage, isRemoteImage } from "./imageKind.js";
3
6
  import { imageMetadata } from "./metadata.js";
4
7
  import { getOrigQueryParams } from "./queryParams.js";
@@ -14,6 +17,7 @@ import {
14
17
  } from "./remotePattern.js";
15
18
  export {
16
19
  emitESMImage,
20
+ emitImageMetadata,
17
21
  getOrigQueryParams,
18
22
  hashTransform,
19
23
  imageMetadata,
@@ -16,4 +16,12 @@ type ImageMetadataWithContents = ImageMetadata & {
16
16
  export declare function emitESMImage(id: string | undefined,
17
17
  /** @deprecated */
18
18
  _watchMode: boolean, experimentalSvgEnabled: boolean, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
19
+ /**
20
+ * Processes an image file and emits its metadata and optionally its contents. This function supports both build and development modes.
21
+ *
22
+ * @param {string | undefined} id - The identifier or path of the image file to process. If undefined, the function returns immediately.
23
+ * @param {FileEmitter | undefined} [fileEmitter] - Function for emitting files during the build process. May throw in certain scenarios.
24
+ * @return {Promise<ImageMetadataWithContents | undefined>} Resolves to metadata with optional image contents or `undefined` if processing fails.
25
+ */
26
+ export declare function emitImageMetadata(id: string | undefined, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
19
27
  export {};
@@ -24,9 +24,50 @@ async function emitESMImage(id, _watchMode, experimentalSvgEnabled, fileEmitter)
24
24
  writable: false,
25
25
  value: id
26
26
  });
27
- if (fileMetadata.format === "svg" && experimentalSvgEnabled) {
28
- emittedImage.contents = fileData;
27
+ let isBuild = typeof fileEmitter === "function";
28
+ if (isBuild) {
29
+ const pathname = decodeURI(url.pathname);
30
+ const filename = path.basename(pathname, path.extname(pathname) + `.${fileMetadata.format}`);
31
+ try {
32
+ const handle = fileEmitter({
33
+ name: filename,
34
+ source: await fs.readFile(url),
35
+ type: "asset"
36
+ });
37
+ emittedImage.src = `__ASTRO_ASSET_IMAGE__${handle}__`;
38
+ } catch {
39
+ isBuild = false;
40
+ }
41
+ }
42
+ if (!isBuild) {
43
+ url.searchParams.append("origWidth", fileMetadata.width.toString());
44
+ url.searchParams.append("origHeight", fileMetadata.height.toString());
45
+ url.searchParams.append("origFormat", fileMetadata.format);
46
+ emittedImage.src = `/@fs` + prependForwardSlash(fileURLToNormalizedPath(url));
47
+ }
48
+ return emittedImage;
49
+ }
50
+ async function emitImageMetadata(id, fileEmitter) {
51
+ if (!id) {
52
+ return void 0;
53
+ }
54
+ const url = pathToFileURL(id);
55
+ let fileData;
56
+ try {
57
+ fileData = await fs.readFile(url);
58
+ } catch {
59
+ return void 0;
29
60
  }
61
+ const fileMetadata = await imageMetadata(fileData, id);
62
+ const emittedImage = {
63
+ src: "",
64
+ ...fileMetadata
65
+ };
66
+ Object.defineProperty(emittedImage, "fsPath", {
67
+ enumerable: false,
68
+ writable: false,
69
+ value: id
70
+ });
30
71
  let isBuild = typeof fileEmitter === "function";
31
72
  if (isBuild) {
32
73
  const pathname = decodeURI(url.pathname);
@@ -54,5 +95,6 @@ function fileURLToNormalizedPath(filePath) {
54
95
  return slash(fileURLToPath(filePath) + filePath.search).replace(/\\/g, "/");
55
96
  }
56
97
  export {
57
- emitESMImage
98
+ emitESMImage,
99
+ emitImageMetadata
58
100
  };
@@ -1,5 +1,7 @@
1
+ import type * as fsMod from 'node:fs';
1
2
  import type * as vite from 'vite';
2
3
  import type { AstroSettings } from '../types/astro.js';
3
- export default function assets({ settings }: {
4
+ export default function assets({ fs, settings, }: {
5
+ fs: typeof fsMod;
4
6
  settings: AstroSettings;
5
7
  }): vite.Plugin[];
@@ -63,7 +63,10 @@ const addStaticImageFactory = (settings) => {
63
63
  }
64
64
  };
65
65
  };
66
- function assets({ settings }) {
66
+ function assets({
67
+ fs,
68
+ settings
69
+ }) {
67
70
  let resolvedConfig;
68
71
  let shouldEmitFile = false;
69
72
  let isBuild = false;
@@ -180,8 +183,8 @@ function assets({ settings }) {
180
183
  });
181
184
  }
182
185
  if (settings.config.experimental.svg && /\.svg$/.test(id)) {
183
- const { contents, ...metadata } = imageMetadata;
184
- return { code: makeSvgComponent(metadata, contents) };
186
+ const contents = await fs.promises.readFile(imageMetadata.fsPath, { encoding: "utf8" });
187
+ return { code: makeSvgComponent(imageMetadata, contents) };
185
188
  }
186
189
  if (options?.ssr) {
187
190
  return {
@@ -545,7 +545,9 @@ async function tryToInstallIntegrations({
545
545
  }).filter(Boolean).flat();
546
546
  const installCommand = resolveCommand(packageManager?.agent ?? "npm", "add", inheritedFlags);
547
547
  if (!installCommand) return 0 /* none */;
548
- const installSpecifiers = await convertIntegrationsToInstallSpecifiers(integrations);
548
+ const installSpecifiers = await convertIntegrationsToInstallSpecifiers(integrations).then(
549
+ (specifiers) => installCommand.command === "deno" ? specifiers.map((specifier) => `npm:${specifier}`) : specifiers
550
+ );
549
551
  const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(" ")} ${cyan(installSpecifiers.join(" "))}`;
550
552
  const message = `
551
553
  ${boxen(coloredOutput, {
@@ -43,6 +43,9 @@ async function installPackage(packageNames, options, logger) {
43
43
  });
44
44
  const installCommand = resolveCommand(packageManager?.agent ?? "npm", "add", []);
45
45
  if (!installCommand) return false;
46
+ if (installCommand.command === "deno") {
47
+ packageNames = packageNames.map((name) => `npm:${name}`);
48
+ }
46
49
  const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(" ")} ${cyan(packageNames.join(" "))}`;
47
50
  const message = `
48
51
  ${boxen(coloredOutput, {
@@ -153,7 +153,7 @@ ${contentConfig.error.message}`);
153
153
  logger.info("Content config changed");
154
154
  shouldClear = true;
155
155
  }
156
- if (previousAstroVersion && previousAstroVersion !== "5.6.1") {
156
+ if (previousAstroVersion && previousAstroVersion !== "5.6.2") {
157
157
  logger.info("Astro version changed");
158
158
  shouldClear = true;
159
159
  }
@@ -161,8 +161,8 @@ ${contentConfig.error.message}`);
161
161
  logger.info("Clearing content store");
162
162
  this.#store.clearAll();
163
163
  }
164
- if ("5.6.1") {
165
- await this.#store.metaStore().set("astro-version", "5.6.1");
164
+ if ("5.6.2") {
165
+ await this.#store.metaStore().set("astro-version", "5.6.2");
166
166
  }
167
167
  if (currentConfigDigest) {
168
168
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -106,8 +106,8 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
106
106
  refreshContextData?: Record<string, unknown> | undefined;
107
107
  }) => unknown;
108
108
  name: string;
109
- render?: ((args_0: any) => unknown) | undefined;
110
109
  schema?: any;
110
+ render?: ((args_0: any) => unknown) | undefined;
111
111
  }, {
112
112
  load: (args_0: {
113
113
  collection: string;
@@ -122,8 +122,8 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
122
122
  refreshContextData?: Record<string, unknown> | undefined;
123
123
  }) => unknown;
124
124
  name: string;
125
- render?: ((args_0: any) => unknown) | undefined;
126
125
  schema?: any;
126
+ render?: ((args_0: any) => unknown) | undefined;
127
127
  }>]>;
128
128
  /** deprecated */
129
129
  _legacy: z.ZodOptional<z.ZodBoolean>;
@@ -143,8 +143,8 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
143
143
  refreshContextData?: Record<string, unknown> | undefined;
144
144
  }) => unknown;
145
145
  name: string;
146
- render?: ((args_0: any) => unknown) | undefined;
147
146
  schema?: any;
147
+ render?: ((args_0: any) => unknown) | undefined;
148
148
  };
149
149
  schema?: any;
150
150
  _legacy?: boolean | undefined;
@@ -164,8 +164,8 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
164
164
  refreshContextData?: Record<string, unknown> | undefined;
165
165
  }) => unknown;
166
166
  name: string;
167
- render?: ((args_0: any) => unknown) | undefined;
168
167
  schema?: any;
168
+ render?: ((args_0: any) => unknown) | undefined;
169
169
  };
170
170
  schema?: any;
171
171
  _legacy?: boolean | undefined;
@@ -244,8 +244,8 @@ declare const contentConfigParser: z.ZodObject<{
244
244
  refreshContextData?: Record<string, unknown> | undefined;
245
245
  }) => unknown;
246
246
  name: string;
247
- render?: ((args_0: any) => unknown) | undefined;
248
247
  schema?: any;
248
+ render?: ((args_0: any) => unknown) | undefined;
249
249
  }, {
250
250
  load: (args_0: {
251
251
  collection: string;
@@ -260,8 +260,8 @@ declare const contentConfigParser: z.ZodObject<{
260
260
  refreshContextData?: Record<string, unknown> | undefined;
261
261
  }) => unknown;
262
262
  name: string;
263
- render?: ((args_0: any) => unknown) | undefined;
264
263
  schema?: any;
264
+ render?: ((args_0: any) => unknown) | undefined;
265
265
  }>]>;
266
266
  /** deprecated */
267
267
  _legacy: z.ZodOptional<z.ZodBoolean>;
@@ -281,8 +281,8 @@ declare const contentConfigParser: z.ZodObject<{
281
281
  refreshContextData?: Record<string, unknown> | undefined;
282
282
  }) => unknown;
283
283
  name: string;
284
- render?: ((args_0: any) => unknown) | undefined;
285
284
  schema?: any;
285
+ render?: ((args_0: any) => unknown) | undefined;
286
286
  };
287
287
  schema?: any;
288
288
  _legacy?: boolean | undefined;
@@ -302,8 +302,8 @@ declare const contentConfigParser: z.ZodObject<{
302
302
  refreshContextData?: Record<string, unknown> | undefined;
303
303
  }) => unknown;
304
304
  name: string;
305
- render?: ((args_0: any) => unknown) | undefined;
306
305
  schema?: any;
306
+ render?: ((args_0: any) => unknown) | undefined;
307
307
  };
308
308
  schema?: any;
309
309
  _legacy?: boolean | undefined;
@@ -331,8 +331,8 @@ declare const contentConfigParser: z.ZodObject<{
331
331
  refreshContextData?: Record<string, unknown> | undefined;
332
332
  }) => unknown;
333
333
  name: string;
334
- render?: ((args_0: any) => unknown) | undefined;
335
334
  schema?: any;
335
+ render?: ((args_0: any) => unknown) | undefined;
336
336
  };
337
337
  schema?: any;
338
338
  _legacy?: boolean | undefined;
@@ -360,8 +360,8 @@ declare const contentConfigParser: z.ZodObject<{
360
360
  refreshContextData?: Record<string, unknown> | undefined;
361
361
  }) => unknown;
362
362
  name: string;
363
- render?: ((args_0: any) => unknown) | undefined;
364
363
  schema?: any;
364
+ render?: ((args_0: any) => unknown) | undefined;
365
365
  };
366
366
  schema?: any;
367
367
  _legacy?: boolean | undefined;
@@ -41,9 +41,6 @@ function getNonPrerenderOnlyChunks(bundle, internals) {
41
41
  }
42
42
  nonPrerenderOnlyEntryChunks.add(chunk);
43
43
  }
44
- if (chunk.type === "chunk" && chunk.isDynamicEntry) {
45
- nonPrerenderOnlyEntryChunks.add(chunk);
46
- }
47
44
  }
48
45
  const nonPrerenderOnlyChunks = new Set(nonPrerenderOnlyEntryChunks);
49
46
  for (const chunk of nonPrerenderOnlyChunks) {
@@ -171,10 +171,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
171
171
  open: string | boolean;
172
172
  headers?: OutgoingHttpHeaders | undefined;
173
173
  }, {
174
- headers?: OutgoingHttpHeaders | undefined;
175
174
  host?: string | boolean | undefined;
176
175
  port?: number | undefined;
177
176
  allowedHosts?: true | string[] | undefined;
177
+ headers?: OutgoingHttpHeaders | undefined;
178
178
  open?: string | boolean | undefined;
179
179
  }>>, {
180
180
  host: string | boolean;
@@ -211,8 +211,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
211
211
  route: string;
212
212
  entrypoint?: string | undefined;
213
213
  }, {
214
- route?: string | undefined;
215
214
  entrypoint?: string | undefined;
215
+ route?: string | undefined;
216
216
  }>>;
217
217
  service: z.ZodDefault<z.ZodObject<{
218
218
  entrypoint: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodString]>>;
@@ -267,8 +267,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
267
267
  experimentalBreakpoints?: number[] | undefined;
268
268
  }, {
269
269
  endpoint?: {
270
- route?: string | undefined;
271
270
  entrypoint?: string | undefined;
271
+ route?: string | undefined;
272
272
  } | undefined;
273
273
  service?: {
274
274
  entrypoint?: string | undefined;
@@ -490,10 +490,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
490
490
  endsWith?: string | undefined;
491
491
  startsWith?: string | undefined;
492
492
  default?: string | undefined;
493
- url?: boolean | undefined;
494
493
  optional?: boolean | undefined;
495
494
  max?: number | undefined;
496
495
  min?: number | undefined;
496
+ url?: boolean | undefined;
497
497
  }, {
498
498
  type: "string";
499
499
  length?: number | undefined;
@@ -501,10 +501,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
501
501
  endsWith?: string | undefined;
502
502
  startsWith?: string | undefined;
503
503
  default?: string | undefined;
504
- url?: boolean | undefined;
505
504
  optional?: boolean | undefined;
506
505
  max?: number | undefined;
507
506
  min?: number | undefined;
507
+ url?: boolean | undefined;
508
508
  }>, z.ZodObject<{
509
509
  type: z.ZodLiteral<"number">;
510
510
  optional: z.ZodOptional<z.ZodBoolean>;
@@ -589,10 +589,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
589
589
  endsWith?: string | undefined;
590
590
  startsWith?: string | undefined;
591
591
  default?: string | undefined;
592
- url?: boolean | undefined;
593
592
  optional?: boolean | undefined;
594
593
  max?: number | undefined;
595
594
  min?: number | undefined;
595
+ url?: boolean | undefined;
596
596
  } | {
597
597
  type: "number";
598
598
  default?: number | undefined;
@@ -630,10 +630,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
630
630
  endsWith?: string | undefined;
631
631
  startsWith?: string | undefined;
632
632
  default?: string | undefined;
633
- url?: boolean | undefined;
634
633
  optional?: boolean | undefined;
635
634
  max?: number | undefined;
636
635
  min?: number | undefined;
636
+ url?: boolean | undefined;
637
637
  } | {
638
638
  type: "number";
639
639
  default?: number | undefined;
@@ -861,10 +861,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
861
861
  endsWith?: string | undefined;
862
862
  startsWith?: string | undefined;
863
863
  default?: string | undefined;
864
- url?: boolean | undefined;
865
864
  optional?: boolean | undefined;
866
865
  max?: number | undefined;
867
866
  min?: number | undefined;
867
+ url?: boolean | undefined;
868
868
  } | {
869
869
  type: "number";
870
870
  default?: number | undefined;
@@ -990,8 +990,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
990
990
  } | undefined;
991
991
  image?: {
992
992
  endpoint?: {
993
- route?: string | undefined;
994
993
  entrypoint?: string | undefined;
994
+ route?: string | undefined;
995
995
  } | undefined;
996
996
  service?: {
997
997
  entrypoint?: string | undefined;
@@ -1068,10 +1068,10 @@ export declare const AstroConfigSchema: z.ZodObject<{
1068
1068
  endsWith?: string | undefined;
1069
1069
  startsWith?: string | undefined;
1070
1070
  default?: string | undefined;
1071
- url?: boolean | undefined;
1072
1071
  optional?: boolean | undefined;
1073
1072
  max?: number | undefined;
1074
1073
  min?: number | undefined;
1074
+ url?: boolean | undefined;
1075
1075
  } | {
1076
1076
  type: "number";
1077
1077
  default?: number | undefined;
@@ -95,10 +95,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
95
95
  open: string | boolean;
96
96
  headers?: OutgoingHttpHeaders | undefined;
97
97
  }, {
98
- headers?: OutgoingHttpHeaders | undefined;
99
98
  host?: string | boolean | undefined;
100
99
  port?: number | undefined;
101
100
  allowedHosts?: true | string[] | undefined;
101
+ headers?: OutgoingHttpHeaders | undefined;
102
102
  open?: string | boolean | undefined;
103
103
  }>>, {
104
104
  host: string | boolean;
@@ -135,8 +135,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
135
135
  route: string;
136
136
  entrypoint?: string | undefined;
137
137
  }, {
138
- route?: string | undefined;
139
138
  entrypoint?: string | undefined;
139
+ route?: string | undefined;
140
140
  }>>;
141
141
  service: z.ZodDefault<z.ZodObject<{
142
142
  entrypoint: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodString]>>;
@@ -191,8 +191,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
191
191
  experimentalBreakpoints?: number[] | undefined;
192
192
  }, {
193
193
  endpoint?: {
194
- route?: string | undefined;
195
194
  entrypoint?: string | undefined;
195
+ route?: string | undefined;
196
196
  } | undefined;
197
197
  service?: {
198
198
  entrypoint?: string | undefined;
@@ -414,10 +414,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
414
414
  endsWith?: string | undefined;
415
415
  startsWith?: string | undefined;
416
416
  default?: string | undefined;
417
- url?: boolean | undefined;
418
417
  optional?: boolean | undefined;
419
418
  max?: number | undefined;
420
419
  min?: number | undefined;
420
+ url?: boolean | undefined;
421
421
  }, {
422
422
  type: "string";
423
423
  length?: number | undefined;
@@ -425,10 +425,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
425
425
  endsWith?: string | undefined;
426
426
  startsWith?: string | undefined;
427
427
  default?: string | undefined;
428
- url?: boolean | undefined;
429
428
  optional?: boolean | undefined;
430
429
  max?: number | undefined;
431
430
  min?: number | undefined;
431
+ url?: boolean | undefined;
432
432
  }>, z.ZodObject<{
433
433
  type: z.ZodLiteral<"number">;
434
434
  optional: z.ZodOptional<z.ZodBoolean>;
@@ -513,10 +513,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
513
513
  endsWith?: string | undefined;
514
514
  startsWith?: string | undefined;
515
515
  default?: string | undefined;
516
- url?: boolean | undefined;
517
516
  optional?: boolean | undefined;
518
517
  max?: number | undefined;
519
518
  min?: number | undefined;
519
+ url?: boolean | undefined;
520
520
  } | {
521
521
  type: "number";
522
522
  default?: number | undefined;
@@ -554,10 +554,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
554
554
  endsWith?: string | undefined;
555
555
  startsWith?: string | undefined;
556
556
  default?: string | undefined;
557
- url?: boolean | undefined;
558
557
  optional?: boolean | undefined;
559
558
  max?: number | undefined;
560
559
  min?: number | undefined;
560
+ url?: boolean | undefined;
561
561
  } | {
562
562
  type: "number";
563
563
  default?: number | undefined;
@@ -741,10 +741,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
741
741
  streaming: boolean;
742
742
  headers?: OutgoingHttpHeaders | undefined;
743
743
  }, {
744
- headers?: OutgoingHttpHeaders | undefined;
745
744
  host?: string | boolean | undefined;
746
745
  port?: number | undefined;
747
746
  allowedHosts?: true | string[] | undefined;
747
+ headers?: OutgoingHttpHeaders | undefined;
748
748
  open?: string | boolean | undefined;
749
749
  streaming?: boolean | undefined;
750
750
  }>>>, {
@@ -863,10 +863,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
863
863
  endsWith?: string | undefined;
864
864
  startsWith?: string | undefined;
865
865
  default?: string | undefined;
866
- url?: boolean | undefined;
867
866
  optional?: boolean | undefined;
868
867
  max?: number | undefined;
869
868
  min?: number | undefined;
869
+ url?: boolean | undefined;
870
870
  } | {
871
871
  type: "number";
872
872
  default?: number | undefined;
@@ -992,8 +992,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
992
992
  } | undefined;
993
993
  image?: {
994
994
  endpoint?: {
995
- route?: string | undefined;
996
995
  entrypoint?: string | undefined;
996
+ route?: string | undefined;
997
997
  } | undefined;
998
998
  service?: {
999
999
  entrypoint?: string | undefined;
@@ -1070,10 +1070,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1070
1070
  endsWith?: string | undefined;
1071
1071
  startsWith?: string | undefined;
1072
1072
  default?: string | undefined;
1073
- url?: boolean | undefined;
1074
1073
  optional?: boolean | undefined;
1075
1074
  max?: number | undefined;
1076
1075
  min?: number | undefined;
1076
+ url?: boolean | undefined;
1077
1077
  } | {
1078
1078
  type: "number";
1079
1079
  default?: number | undefined;
@@ -1215,10 +1215,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1215
1215
  endsWith?: string | undefined;
1216
1216
  startsWith?: string | undefined;
1217
1217
  default?: string | undefined;
1218
- url?: boolean | undefined;
1219
1218
  optional?: boolean | undefined;
1220
1219
  max?: number | undefined;
1221
1220
  min?: number | undefined;
1221
+ url?: boolean | undefined;
1222
1222
  } | {
1223
1223
  type: "number";
1224
1224
  default?: number | undefined;
@@ -1344,8 +1344,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1344
1344
  } | undefined;
1345
1345
  image?: {
1346
1346
  endpoint?: {
1347
- route?: string | undefined;
1348
1347
  entrypoint?: string | undefined;
1348
+ route?: string | undefined;
1349
1349
  } | undefined;
1350
1350
  service?: {
1351
1351
  entrypoint?: string | undefined;
@@ -1422,10 +1422,10 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1422
1422
  endsWith?: string | undefined;
1423
1423
  startsWith?: string | undefined;
1424
1424
  default?: string | undefined;
1425
- url?: boolean | undefined;
1426
1425
  optional?: boolean | undefined;
1427
1426
  max?: number | undefined;
1428
1427
  min?: number | undefined;
1428
+ url?: boolean | undefined;
1429
1429
  } | {
1430
1430
  type: "number";
1431
1431
  default?: number | undefined;
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.6.1";
1
+ const ASTRO_VERSION = "5.6.2";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -125,7 +125,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
125
125
  astroContentAssetPropagationPlugin({ settings }),
126
126
  vitePluginMiddleware({ settings }),
127
127
  vitePluginSSRManifest(),
128
- astroAssetsPlugin({ settings }),
128
+ astroAssetsPlugin({ fs, settings }),
129
129
  astroPrefetch({ settings }),
130
130
  astroTransitions({ settings }),
131
131
  astroDevToolbar({ settings, logger }),
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "5.6.1";
25
+ const currentVersion = "5.6.2";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "5.6.1";
41
+ const version = "5.6.2";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -282,7 +282,7 @@ function printHelp({
282
282
  message.push(
283
283
  linebreak(),
284
284
  ` ${bgGreen(black(` ${commandName} `))} ${green(
285
- `v${"5.6.1"}`
285
+ `v${"5.6.2"}`
286
286
  )} ${headline}`
287
287
  );
288
288
  }
@@ -357,6 +357,7 @@ class RenderContext {
357
357
  hasRenderedHead: false,
358
358
  renderedScripts: /* @__PURE__ */ new Set(),
359
359
  hasDirectives: /* @__PURE__ */ new Set(),
360
+ hasRenderedServerIslandRuntime: false,
360
361
  headInTree: false,
361
362
  extraHead: [],
362
363
  propagators: /* @__PURE__ */ new Set()
@@ -17,10 +17,10 @@ declare const StringSchema: z.ZodObject<{
17
17
  endsWith?: string | undefined;
18
18
  startsWith?: string | undefined;
19
19
  default?: string | undefined;
20
- url?: boolean | undefined;
21
20
  optional?: boolean | undefined;
22
21
  max?: number | undefined;
23
22
  min?: number | undefined;
23
+ url?: boolean | undefined;
24
24
  }, {
25
25
  type: "string";
26
26
  length?: number | undefined;
@@ -28,10 +28,10 @@ declare const StringSchema: z.ZodObject<{
28
28
  endsWith?: string | undefined;
29
29
  startsWith?: string | undefined;
30
30
  default?: string | undefined;
31
- url?: boolean | undefined;
32
31
  optional?: boolean | undefined;
33
32
  max?: number | undefined;
34
33
  min?: number | undefined;
34
+ url?: boolean | undefined;
35
35
  }>;
36
36
  export type StringSchema = z.infer<typeof StringSchema>;
37
37
  declare const NumberSchema: z.ZodObject<{
@@ -111,10 +111,10 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
111
111
  endsWith?: string | undefined;
112
112
  startsWith?: string | undefined;
113
113
  default?: string | undefined;
114
- url?: boolean | undefined;
115
114
  optional?: boolean | undefined;
116
115
  max?: number | undefined;
117
116
  min?: number | undefined;
117
+ url?: boolean | undefined;
118
118
  }, {
119
119
  type: "string";
120
120
  length?: number | undefined;
@@ -122,10 +122,10 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
122
122
  endsWith?: string | undefined;
123
123
  startsWith?: string | undefined;
124
124
  default?: string | undefined;
125
- url?: boolean | undefined;
126
125
  optional?: boolean | undefined;
127
126
  max?: number | undefined;
128
127
  min?: number | undefined;
128
+ url?: boolean | undefined;
129
129
  }>, z.ZodObject<{
130
130
  type: z.ZodLiteral<"number">;
131
131
  optional: z.ZodOptional<z.ZodBoolean>;
@@ -283,10 +283,10 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
283
283
  endsWith?: string | undefined;
284
284
  startsWith?: string | undefined;
285
285
  default?: string | undefined;
286
- url?: boolean | undefined;
287
286
  optional?: boolean | undefined;
288
287
  max?: number | undefined;
289
288
  min?: number | undefined;
289
+ url?: boolean | undefined;
290
290
  }, {
291
291
  type: "string";
292
292
  length?: number | undefined;
@@ -294,10 +294,10 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
294
294
  endsWith?: string | undefined;
295
295
  startsWith?: string | undefined;
296
296
  default?: string | undefined;
297
- url?: boolean | undefined;
298
297
  optional?: boolean | undefined;
299
298
  max?: number | undefined;
300
299
  min?: number | undefined;
300
+ url?: boolean | undefined;
301
301
  }>, z.ZodObject<{
302
302
  type: z.ZodLiteral<"number">;
303
303
  optional: z.ZodOptional<z.ZodBoolean>;
@@ -6,6 +6,7 @@ import {
6
6
  } from "../scripts.js";
7
7
  import { renderAllHeadContent } from "./head.js";
8
8
  import { isRenderInstruction } from "./instruction.js";
9
+ import { renderServerIslandRuntime } from "./server-islands.js";
9
10
  import { isSlotString } from "./slot.js";
10
11
  const Fragment = Symbol.for("astro:fragment");
11
12
  const Renderer = Symbol.for("astro:renderer");
@@ -48,6 +49,13 @@ function stringifyChunk(result, chunk) {
48
49
  }
49
50
  return "";
50
51
  }
52
+ case "server-island-runtime": {
53
+ if (result._metadata.hasRenderedServerIslandRuntime) {
54
+ return "";
55
+ }
56
+ result._metadata.hasRenderedServerIslandRuntime = true;
57
+ return renderServerIslandRuntime();
58
+ }
51
59
  default: {
52
60
  throw new Error(`Unknown chunk type: ${chunk.type}`);
53
61
  }
@@ -18,9 +18,9 @@ export type RendererHydrationScriptInstruction = {
18
18
  export type MaybeRenderHeadInstruction = {
19
19
  type: 'maybe-head';
20
20
  };
21
- export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction | MaybeRenderHeadInstruction | RendererHydrationScriptInstruction;
22
- export declare function createRenderInstruction(instruction: RenderDirectiveInstruction): RenderDirectiveInstruction;
23
- export declare function createRenderInstruction(instruction: RendererHydrationScriptInstruction): RendererHydrationScriptInstruction;
24
- export declare function createRenderInstruction(instruction: RenderHeadInstruction): RenderHeadInstruction;
25
- export declare function createRenderInstruction(instruction: MaybeRenderHeadInstruction): MaybeRenderHeadInstruction;
21
+ export type ServerIslandRuntimeInstruction = {
22
+ type: 'server-island-runtime';
23
+ };
24
+ export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction | MaybeRenderHeadInstruction | RendererHydrationScriptInstruction | ServerIslandRuntimeInstruction;
25
+ export declare function createRenderInstruction<T extends RenderInstruction>(instruction: T): T;
26
26
  export declare function isRenderInstruction(chunk: any): chunk is RenderInstruction;
@@ -3,3 +3,4 @@ import type { RenderInstance } from './common.js';
3
3
  import { type ComponentSlots } from './slot.js';
4
4
  export declare function containsServerDirective(props: Record<string | number, any>): boolean;
5
5
  export declare function renderServerIsland(result: SSRResult, _displayName: string, props: Record<string | number, any>, slots: ComponentSlots): RenderInstance;
6
+ export declare const renderServerIslandRuntime: () => any;
@@ -1,5 +1,7 @@
1
1
  import { encryptString } from "../../../core/encryption.js";
2
+ import { markHTMLString } from "../escape.js";
2
3
  import { renderChild } from "./any.js";
4
+ import { createRenderInstruction } from "./instruction.js";
3
5
  import { renderSlotToString } from "./slot.js";
4
6
  const internalProps = /* @__PURE__ */ new Set([
5
7
  "server:component-path",
@@ -43,6 +45,7 @@ function renderServerIsland(result, _displayName, props, slots) {
43
45
  delete props[key2];
44
46
  }
45
47
  }
48
+ destination.write(createRenderInstruction({ type: "server-island-runtime" }));
46
49
  destination.write("<!--[if astro]>server-island-start<![endif]-->");
47
50
  const renderedSlots = {};
48
51
  for (const name in slots) {
@@ -70,13 +73,9 @@ function renderServerIsland(result, _displayName, props, slots) {
70
73
  `<link rel="preload" as="fetch" href="${serverIslandUrl}" crossorigin="anonymous">`
71
74
  );
72
75
  }
73
- destination.write(`<script async type="module" data-astro-rerun data-island-id="${hostId}">
74
- let script = document.querySelector('script[data-island-id="${hostId}"]');
75
-
76
- ${useGETRequest ? (
76
+ destination.write(`<script type="module" data-astro-rerun data-island-id="${hostId}">${useGETRequest ? (
77
77
  // GET request
78
- `let response = await fetch('${serverIslandUrl}');
79
- `
78
+ `let response = await fetch('${serverIslandUrl}');`
80
79
  ) : (
81
80
  // POST request
82
81
  `let data = {
@@ -84,38 +83,37 @@ ${useGETRequest ? (
84
83
  encryptedProps: ${safeJsonStringify(propsEncrypted)},
85
84
  slots: ${safeJsonStringify(renderedSlots)},
86
85
  };
87
-
88
86
  let response = await fetch('${serverIslandUrl}', {
89
87
  method: 'POST',
90
88
  body: JSON.stringify(data),
91
- });
92
- `
89
+ });`
93
90
  )}
94
- if (script) {
95
- if(
96
- response.status === 200
97
- && response.headers.has('content-type')
98
- && response.headers.get('content-type').split(";")[0].trim() === 'text/html') {
99
- let html = await response.text();
100
-
101
- // Swap!
102
- while(script.previousSibling &&
103
- script.previousSibling.nodeType !== 8 &&
104
- script.previousSibling.data !== '[if astro]>server-island-start<![endif]') {
105
- script.previousSibling.remove();
106
- }
107
- script.previousSibling?.remove();
108
-
109
- let frag = document.createRange().createContextualFragment(html);
110
- script.before(frag);
111
- }
112
- script.remove(); // Prior to v5.4.2, this was the trick to force rerun of scripts. Keeping it to minimize change to the existing behavior.
113
- }
114
- </script>`);
91
+ replaceServerIsland('${hostId}', response);</script>`);
115
92
  }
116
93
  };
117
94
  }
95
+ const renderServerIslandRuntime = () => markHTMLString(
96
+ `
97
+ <script>
98
+ async function replaceServerIsland(id, r) {
99
+ let s = document.querySelector(\`script[data-island-id="\${id}"]\`);
100
+ // If there's no matching script, or the request fails then return
101
+ if (!s || r.status !== 200 || r.headers.get('content-type')?.split(';')[0].trim() !== 'text/html') return;
102
+ // Load the HTML before modifying the DOM in case of errors
103
+ let html = await r.text();
104
+ // Remove any placeholder content before the island script
105
+ while (s.previousSibling && s.previousSibling.nodeType !== 8 && s.previousSibling.data !== '[if astro]>server-island-start<![endif]')
106
+ s.previousSibling.remove();
107
+ s.previousSibling?.remove();
108
+ // Insert the new HTML
109
+ s.before(document.createRange().createContextualFragment(html));
110
+ // Remove the script. Prior to v5.4.2, this was the trick to force rerun of scripts. Keeping it to minimize change to the existing behavior.
111
+ s.remove();
112
+ }
113
+ </script>`.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("//")).join(" ")
114
+ );
118
115
  export {
119
116
  containsServerDirective,
120
- renderServerIsland
117
+ renderServerIsland,
118
+ renderServerIslandRuntime
121
119
  };
@@ -5,7 +5,7 @@ export type SavedFocus = {
5
5
  };
6
6
  export declare function detectScriptExecuted(script: HTMLScriptElement): boolean;
7
7
  export declare function deselectScripts(doc: Document): void;
8
- export declare function swapRootAttributes(doc: Document): void;
8
+ export declare function swapRootAttributes(newDoc: Document): void;
9
9
  export declare function swapHeadElements(doc: Document): void;
10
10
  export declare function swapBodyElement(newElement: Element, oldElement: Element): void;
11
11
  export declare const saveFocus: () => (() => void);
@@ -1,4 +1,5 @@
1
1
  const PERSIST_ATTR = "data-astro-transition-persist";
2
+ const NON_OVERRIDABLE_ASTRO_ATTRS = ["data-astro-transition", "data-astro-transition-fallback"];
2
3
  const scriptsAlreadyRan = /* @__PURE__ */ new Set();
3
4
  function detectScriptExecuted(script) {
4
5
  const key = script.src ? new URL(script.src, location.href).href : script.textContent;
@@ -17,13 +18,13 @@ function deselectScripts(doc) {
17
18
  }
18
19
  }
19
20
  }
20
- function swapRootAttributes(doc) {
21
- const html = document.documentElement;
22
- const astroAttributes = [...html.attributes].filter(
23
- ({ name }) => (html.removeAttribute(name), name.startsWith("data-astro-"))
21
+ function swapRootAttributes(newDoc) {
22
+ const currentRoot = document.documentElement;
23
+ const nonOverridableAstroAttributes = [...currentRoot.attributes].filter(
24
+ ({ name }) => (currentRoot.removeAttribute(name), NON_OVERRIDABLE_ASTRO_ATTRS.includes(name))
24
25
  );
25
- [...doc.documentElement.attributes, ...astroAttributes].forEach(
26
- ({ name, value }) => html.setAttribute(name, value)
26
+ [...newDoc.documentElement.attributes, ...nonOverridableAstroAttributes].forEach(
27
+ ({ name, value }) => currentRoot.setAttribute(name, value)
27
28
  );
28
29
  }
29
30
  function swapHeadElements(doc) {
@@ -258,6 +258,7 @@ export interface SSRMetadata {
258
258
  renderedScripts: Set<string>;
259
259
  hasDirectives: Set<string>;
260
260
  hasRenderedHead: boolean;
261
+ hasRenderedServerIslandRuntime: boolean;
261
262
  headInTree: boolean;
262
263
  extraHead: string[];
263
264
  propagators: Set<AstroComponentInstance>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.6.1",
3
+ "version": "5.6.2",
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",
@@ -149,7 +149,7 @@
149
149
  "unist-util-visit": "^5.0.0",
150
150
  "unstorage": "^1.15.0",
151
151
  "vfile": "^6.0.3",
152
- "vite": "^6.2.4",
152
+ "vite": "^6.2.6",
153
153
  "vitefu": "^1.0.6",
154
154
  "xxhash-wasm": "^1.1.0",
155
155
  "yargs-parser": "^21.1.1",
@@ -157,9 +157,9 @@
157
157
  "zod": "^3.24.2",
158
158
  "zod-to-json-schema": "^3.24.5",
159
159
  "zod-to-ts": "^1.2.0",
160
+ "@astrojs/internal-helpers": "0.6.1",
160
161
  "@astrojs/markdown-remark": "6.3.1",
161
- "@astrojs/telemetry": "3.2.0",
162
- "@astrojs/internal-helpers": "0.6.1"
162
+ "@astrojs/telemetry": "3.2.0"
163
163
  },
164
164
  "optionalDependencies": {
165
165
  "sharp": "^0.33.3"