astro 4.1.1 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/components/ViewTransitions.astro +6 -1
  2. package/dist/@types/astro.d.ts +26 -25
  3. package/dist/assets/internal.js +3 -2
  4. package/dist/assets/services/noop.js +1 -4
  5. package/dist/assets/types.d.ts +1 -1
  6. package/dist/assets/utils/emitAsset.js +1 -1
  7. package/dist/assets/utils/proxy.d.ts +2 -1
  8. package/dist/assets/utils/proxy.js +5 -1
  9. package/dist/assets/vite-plugin-assets.js +21 -14
  10. package/dist/content/runtime-assets.d.ts +1 -1
  11. package/dist/content/runtime-assets.js +1 -1
  12. package/dist/content/vite-plugin-content-imports.js +5 -5
  13. package/dist/core/config/vite-load.js +1 -1
  14. package/dist/core/constants.js +1 -1
  15. package/dist/core/cookies/cookies.d.ts +5 -0
  16. package/dist/core/cookies/cookies.js +17 -0
  17. package/dist/core/cookies/response.d.ts +1 -1
  18. package/dist/core/cookies/response.js +2 -1
  19. package/dist/core/create-vite.js +9 -4
  20. package/dist/core/dev/dev.js +1 -1
  21. package/dist/core/errors/dev/utils.js +1 -1
  22. package/dist/core/errors/errors-data.d.ts +43 -25
  23. package/dist/core/errors/errors-data.js +32 -33
  24. package/dist/core/messages.js +2 -2
  25. package/dist/core/redirects/helpers.js +2 -2
  26. package/dist/core/routing/manifest/create.js +22 -1
  27. package/dist/core/sync/index.js +1 -1
  28. package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/astro.js +3 -3
  29. package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/audit/index.js +4 -4
  30. package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/settings.js +7 -7
  31. package/dist/runtime/client/dev-toolbar/apps/utils/highlight.d.ts +8 -0
  32. package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/window.d.ts +1 -1
  33. package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/xray.js +5 -5
  34. package/dist/runtime/client/{dev-overlay → dev-toolbar}/entrypoint.js +64 -68
  35. package/dist/runtime/client/{dev-overlay → dev-toolbar}/settings.d.ts +2 -2
  36. package/dist/runtime/client/{dev-overlay → dev-toolbar}/settings.js +10 -5
  37. package/dist/runtime/client/dev-toolbar/toolbar.d.ts +45 -0
  38. package/dist/runtime/client/{dev-overlay/overlay.js → dev-toolbar/toolbar.js} +99 -103
  39. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/badge.d.ts +1 -1
  40. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/badge.js +2 -2
  41. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/button.d.ts +1 -1
  42. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/button.js +3 -2
  43. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/card.d.ts +1 -1
  44. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/card.js +2 -2
  45. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/highlight.d.ts +1 -1
  46. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/highlight.js +2 -2
  47. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/icon.d.ts +1 -1
  48. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/icon.js +2 -2
  49. package/dist/runtime/client/dev-toolbar/ui-library/index.d.ts +8 -0
  50. package/dist/runtime/client/dev-toolbar/ui-library/index.js +18 -0
  51. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/toggle.d.ts +1 -1
  52. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/toggle.js +2 -2
  53. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/tooltip.d.ts +3 -3
  54. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/tooltip.js +2 -2
  55. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/window.d.ts +1 -1
  56. package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/window.js +3 -3
  57. package/dist/transitions/router.js +4 -1
  58. package/dist/vite-plugin-astro/index.js +12 -2
  59. package/dist/vite-plugin-astro-server/route.js +7 -4
  60. package/dist/vite-plugin-config-alias/index.js +3 -0
  61. package/dist/{vite-plugin-dev-overlay/vite-plugin-dev-overlay.d.ts → vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.d.ts} +1 -1
  62. package/dist/{vite-plugin-dev-overlay/vite-plugin-dev-overlay.js → vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.js} +5 -5
  63. package/dist/vite-plugin-env/index.d.ts +1 -1
  64. package/dist/vite-plugin-env/index.js +81 -43
  65. package/dist/vite-plugin-markdown/index.js +3 -3
  66. package/dist/vite-plugin-utils/index.d.ts +0 -6
  67. package/dist/vite-plugin-utils/index.js +0 -4
  68. package/package.json +2 -2
  69. package/dist/runtime/client/dev-overlay/overlay.d.ts +0 -45
  70. package/dist/runtime/client/dev-overlay/plugins/utils/highlight.d.ts +0 -8
  71. package/dist/runtime/client/dev-overlay/ui-library/index.d.ts +0 -8
  72. package/dist/runtime/client/dev-overlay/ui-library/index.js +0 -18
  73. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/astro.d.ts +0 -0
  74. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/audit/a11y.d.ts +0 -0
  75. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/audit/a11y.js +0 -0
  76. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/audit/index.d.ts +0 -0
  77. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/settings.d.ts +0 -0
  78. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/highlight.js +0 -0
  79. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/icons.d.ts +0 -0
  80. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/icons.js +0 -0
  81. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/window.js +0 -0
  82. /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/xray.d.ts +0 -0
  83. /package/dist/runtime/client/{dev-overlay → dev-toolbar}/entrypoint.d.ts +0 -0
  84. /package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/icons.d.ts +0 -0
  85. /package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/icons.js +0 -0
@@ -53,6 +53,9 @@ const { fallback = 'animate' } = Astro.props;
53
53
  if (supportsViewTransitions || getFallback() !== 'none') {
54
54
  document.addEventListener('click', (ev) => {
55
55
  let link = ev.target;
56
+ if (ev.composed) {
57
+ link = ev.composedPath()[0];
58
+ }
56
59
  if (link instanceof Element) {
57
60
  link = link.closest('a, area');
58
61
  }
@@ -106,7 +109,9 @@ const { fallback = 'animate' } = Astro.props;
106
109
 
107
110
  // the "dialog" method is a special keyword used within <dialog> elements
108
111
  // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-method
109
- if (method === 'dialog') {
112
+ if (method === 'dialog' || location.origin !== new URL(action, location.href).origin) {
113
+ // No page transitions in these cases,
114
+ // Let the browser standard action handle this
110
115
  return;
111
116
  }
112
117
 
@@ -15,9 +15,9 @@ import type { TSConfig } from '../core/config/tsconfig.js';
15
15
  import type { AstroCookies } from '../core/cookies/index.js';
16
16
  import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core.js';
17
17
  import type { AstroPreferences } from '../preferences/index.js';
18
- import type { AstroDevOverlay, DevOverlayCanvas } from '../runtime/client/dev-overlay/overlay.js';
19
- import type { Icon } from '../runtime/client/dev-overlay/ui-library/icons.js';
20
- import type { DevOverlayBadge, DevOverlayButton, DevOverlayCard, DevOverlayHighlight, DevOverlayIcon, DevOverlayToggle, DevOverlayTooltip, DevOverlayWindow } from '../runtime/client/dev-overlay/ui-library/index.js';
18
+ import type { AstroDevToolbar, DevToolbarCanvas } from '../runtime/client/dev-toolbar/toolbar.js';
19
+ import type { Icon } from '../runtime/client/dev-toolbar/ui-library/icons.js';
20
+ import type { DevToolbarBadge, DevToolbarButton, DevToolbarCard, DevToolbarHighlight, DevToolbarIcon, DevToolbarToggle, DevToolbarTooltip, DevToolbarWindow } from '../runtime/client/dev-toolbar/ui-library/index.js';
21
21
  import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server/index.js';
22
22
  import type { DeepPartial, OmitIndexSignature, Simplify } from '../type-utils.js';
23
23
  import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
@@ -2082,6 +2082,7 @@ export interface AstroIntegration {
2082
2082
  addClientDirective: (directive: ClientDirectiveConfig) => void;
2083
2083
  /**
2084
2084
  * @deprecated Use `addDevToolbarApp` instead.
2085
+ * TODO: Fully remove in Astro 5.0
2085
2086
  */
2086
2087
  addDevOverlayPlugin: (entrypoint: string) => void;
2087
2088
  addDevToolbarApp: (entrypoint: string) => void;
@@ -2302,8 +2303,8 @@ export interface DevToolbarApp {
2302
2303
  beforeTogglingOff?(canvas: ShadowRoot): boolean | Promise<boolean>;
2303
2304
  }
2304
2305
  export type DevOverlayPlugin = DevToolbarApp;
2305
- export type DevOverlayMetadata = Window & typeof globalThis & {
2306
- __astro_dev_overlay__: {
2306
+ export type DevToolbarMetadata = Window & typeof globalThis & {
2307
+ __astro_dev_toolbar__: {
2307
2308
  root: string;
2308
2309
  version: string;
2309
2310
  debugInfo: string;
@@ -2311,25 +2312,25 @@ export type DevOverlayMetadata = Window & typeof globalThis & {
2311
2312
  };
2312
2313
  declare global {
2313
2314
  interface HTMLElementTagNameMap {
2314
- 'astro-dev-toolbar': AstroDevOverlay;
2315
- 'astro-dev-toolbar-window': DevOverlayWindow;
2316
- 'astro-dev-toolbar-plugin-canvas': DevOverlayCanvas;
2317
- 'astro-dev-toolbar-tooltip': DevOverlayTooltip;
2318
- 'astro-dev-toolbar-highlight': DevOverlayHighlight;
2319
- 'astro-dev-toolbar-toggle': DevOverlayToggle;
2320
- 'astro-dev-toolbar-badge': DevOverlayBadge;
2321
- 'astro-dev-toolbar-button': DevOverlayButton;
2322
- 'astro-dev-toolbar-icon': DevOverlayIcon;
2323
- 'astro-dev-toolbar-card': DevOverlayCard;
2324
- 'astro-dev-overlay': AstroDevOverlay;
2325
- 'astro-dev-overlay-window': DevOverlayWindow;
2326
- 'astro-dev-overlay-plugin-canvas': DevOverlayCanvas;
2327
- 'astro-dev-overlay-tooltip': DevOverlayTooltip;
2328
- 'astro-dev-overlay-highlight': DevOverlayHighlight;
2329
- 'astro-dev-overlay-toggle': DevOverlayToggle;
2330
- 'astro-dev-overlay-badge': DevOverlayBadge;
2331
- 'astro-dev-overlay-button': DevOverlayButton;
2332
- 'astro-dev-overlay-icon': DevOverlayIcon;
2333
- 'astro-dev-overlay-card': DevOverlayCard;
2315
+ 'astro-dev-toolbar': AstroDevToolbar;
2316
+ 'astro-dev-toolbar-window': DevToolbarWindow;
2317
+ 'astro-dev-toolbar-app-canvas': DevToolbarCanvas;
2318
+ 'astro-dev-toolbar-tooltip': DevToolbarTooltip;
2319
+ 'astro-dev-toolbar-highlight': DevToolbarHighlight;
2320
+ 'astro-dev-toolbar-toggle': DevToolbarToggle;
2321
+ 'astro-dev-toolbar-badge': DevToolbarBadge;
2322
+ 'astro-dev-toolbar-button': DevToolbarButton;
2323
+ 'astro-dev-toolbar-icon': DevToolbarIcon;
2324
+ 'astro-dev-toolbar-card': DevToolbarCard;
2325
+ 'astro-dev-overlay': AstroDevToolbar;
2326
+ 'astro-dev-overlay-window': DevToolbarWindow;
2327
+ 'astro-dev-overlay-plugin-canvas': DevToolbarCanvas;
2328
+ 'astro-dev-overlay-tooltip': DevToolbarTooltip;
2329
+ 'astro-dev-overlay-highlight': DevToolbarHighlight;
2330
+ 'astro-dev-overlay-toggle': DevToolbarToggle;
2331
+ 'astro-dev-overlay-badge': DevToolbarBadge;
2332
+ 'astro-dev-overlay-button': DevToolbarButton;
2333
+ 'astro-dev-overlay-icon': DevToolbarIcon;
2334
+ 'astro-dev-overlay-card': DevToolbarCard;
2334
2335
  }
2335
2336
  }
@@ -41,6 +41,7 @@ async function getImage(options, imageConfig) {
41
41
  ...options,
42
42
  src: typeof options.src === "object" && "then" in options.src ? (await options.src).default ?? await options.src : options.src
43
43
  };
44
+ const originalPath = isESMImportedImage(resolvedOptions.src) ? resolvedOptions.src.fsPath : resolvedOptions.src;
44
45
  const clonedSrc = isESMImportedImage(resolvedOptions.src) ? (
45
46
  // @ts-expect-error - clone is a private, hidden prop
46
47
  resolvedOptions.src.clone ?? resolvedOptions.src
@@ -59,10 +60,10 @@ async function getImage(options, imageConfig) {
59
60
  );
60
61
  if (isLocalService(service) && globalThis.astroAsset.addStaticImage && !(isRemoteImage(validatedOptions.src) && imageURL === validatedOptions.src)) {
61
62
  const propsToHash = service.propertiesToHash ?? DEFAULT_HASH_PROPS;
62
- imageURL = globalThis.astroAsset.addStaticImage(validatedOptions, propsToHash);
63
+ imageURL = globalThis.astroAsset.addStaticImage(validatedOptions, propsToHash, originalPath);
63
64
  srcSets = srcSetTransforms.map((srcSet) => ({
64
65
  transform: srcSet.transform,
65
- url: globalThis.astroAsset.addStaticImage(srcSet.transform, propsToHash),
66
+ url: globalThis.astroAsset.addStaticImage(srcSet.transform, propsToHash, originalPath),
66
67
  descriptor: srcSet.descriptor,
67
68
  attributes: srcSet.attributes
68
69
  }));
@@ -1,10 +1,7 @@
1
1
  import { baseService } from "./service.js";
2
2
  const noopService = {
3
+ ...baseService,
3
4
  propertiesToHash: ["src"],
4
- validateOptions: baseService.validateOptions,
5
- getURL: baseService.getURL,
6
- parseURL: baseService.parseURL,
7
- getHTMLAttributes: baseService.getHTMLAttributes,
8
5
  async transform(inputBuffer, transformOptions) {
9
6
  return {
10
7
  data: inputBuffer,
@@ -15,7 +15,7 @@ export type AssetsGlobalStaticImagesList = Map<string, {
15
15
  declare global {
16
16
  var astroAsset: {
17
17
  imageService?: ImageService;
18
- addStaticImage?: ((options: ImageTransform, hashProperties: string[]) => string) | undefined;
18
+ addStaticImage?: ((options: ImageTransform, hashProperties: string[], fsPath: string) => string) | undefined;
19
19
  staticImages?: AssetsGlobalStaticImagesList;
20
20
  referencedImages?: Set<string>;
21
21
  };
@@ -22,7 +22,7 @@ async function emitESMImage(id, watchMode, fileEmitter) {
22
22
  Object.defineProperty(emittedImage, "fsPath", {
23
23
  enumerable: false,
24
24
  writable: false,
25
- value: url
25
+ value: id
26
26
  });
27
27
  if (!watchMode) {
28
28
  const pathname = decodeURI(url.pathname);
@@ -1 +1,2 @@
1
- export declare function getProxyCode(options: Record<string, any>, isSSR: boolean): string;
1
+ import type { ImageMetadata } from '../types.js';
2
+ export declare function getProxyCode(options: ImageMetadata, isSSR: boolean): string;
@@ -1,11 +1,15 @@
1
1
  function getProxyCode(options, isSSR) {
2
+ const stringifiedFSPath = JSON.stringify(options.fsPath);
2
3
  return `
3
4
  new Proxy(${JSON.stringify(options)}, {
4
5
  get(target, name, receiver) {
5
6
  if (name === 'clone') {
6
7
  return structuredClone(target);
7
8
  }
8
- ${!isSSR ? "globalThis.astroAsset.referencedImages.add(target.fsPath);" : ""}
9
+ if (name === 'fsPath') {
10
+ return ${stringifiedFSPath};
11
+ }
12
+ ${!isSSR ? `globalThis.astroAsset.referencedImages.add(${stringifiedFSPath});` : ""}
9
13
  return target[name];
10
14
  }
11
15
  })
@@ -15,7 +15,8 @@ import { isESMImportedImage } from "./utils/imageKind.js";
15
15
  import { getProxyCode } from "./utils/proxy.js";
16
16
  import { hashTransform, propsToFilename } from "./utils/transformToPath.js";
17
17
  const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
18
- const assetRegex = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})$`, "i");
18
+ const assetRegex = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})`, "i");
19
+ const assetRegexEnds = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})$`, "i");
19
20
  function assets({
20
21
  settings,
21
22
  mode
@@ -67,12 +68,11 @@ function assets({
67
68
  if (mode != "build") {
68
69
  return;
69
70
  }
70
- globalThis.astroAsset.addStaticImage = (options, hashProperties) => {
71
+ globalThis.astroAsset.addStaticImage = (options, hashProperties, originalPath) => {
71
72
  if (!globalThis.astroAsset.staticImages) {
72
73
  globalThis.astroAsset.staticImages = /* @__PURE__ */ new Map();
73
74
  }
74
75
  const finalOriginalImagePath = (isESMImportedImage(options.src) ? options.src.src : options.src).replace(settings.config.build.assetsPrefix || "", "");
75
- const originalSrcPath = isESMImportedImage(options.src) ? options.src.fsPath : options.src;
76
76
  const hash = hashTransform(
77
77
  options,
78
78
  settings.config.image.service.entrypoint,
@@ -89,7 +89,7 @@ function assets({
89
89
  );
90
90
  if (!transformsForPath) {
91
91
  globalThis.astroAsset.staticImages.set(finalOriginalImagePath, {
92
- originalSrcPath,
92
+ originalSrcPath: originalPath,
93
93
  transforms: /* @__PURE__ */ new Map()
94
94
  });
95
95
  transformsForPath = globalThis.astroAsset.staticImages.get(finalOriginalImagePath);
@@ -137,24 +137,31 @@ function assets({
137
137
  resolvedConfig = viteConfig;
138
138
  },
139
139
  async load(id, options) {
140
- if (id !== removeQueryString(id)) {
141
- return;
142
- }
143
140
  if (assetRegex.test(id)) {
144
- const meta = await emitESMImage(id, this.meta.watchMode, this.emitFile);
145
- if (!meta) {
141
+ if (!globalThis.astroAsset.referencedImages)
142
+ globalThis.astroAsset.referencedImages = /* @__PURE__ */ new Set();
143
+ if (id !== removeQueryString(id)) {
144
+ globalThis.astroAsset.referencedImages.add(removeQueryString(id));
145
+ return;
146
+ }
147
+ if (!assetRegexEnds.test(id)) {
148
+ return;
149
+ }
150
+ const imageMetadata = await emitESMImage(id, this.meta.watchMode, this.emitFile);
151
+ if (!imageMetadata) {
146
152
  throw new AstroError({
147
153
  ...AstroErrorData.ImageNotFound,
148
154
  message: AstroErrorData.ImageNotFound.message(id)
149
155
  });
150
156
  }
151
157
  if (options?.ssr) {
152
- return `export default ${getProxyCode(meta, isServerLikeOutput(settings.config))}`;
158
+ return `export default ${getProxyCode(
159
+ imageMetadata,
160
+ isServerLikeOutput(settings.config)
161
+ )}`;
153
162
  } else {
154
- if (!globalThis.astroAsset.referencedImages)
155
- globalThis.astroAsset.referencedImages = /* @__PURE__ */ new Set();
156
- globalThis.astroAsset.referencedImages.add(meta.fsPath);
157
- return `export default ${JSON.stringify(meta)}`;
163
+ globalThis.astroAsset.referencedImages.add(imageMetadata.fsPath);
164
+ return `export default ${JSON.stringify(imageMetadata)}`;
158
165
  }
159
166
  }
160
167
  }
@@ -1,7 +1,7 @@
1
1
  import type { PluginContext } from 'rollup';
2
2
  import { z } from 'zod';
3
3
  export declare function createImage(pluginContext: PluginContext, entryFilePath: string): () => z.ZodEffects<z.ZodString, z.ZodNever | {
4
- ASTRO_ASSET: boolean;
4
+ ASTRO_ASSET: string;
5
5
  src: string;
6
6
  width: number;
7
7
  height: number;
@@ -17,7 +17,7 @@ function createImage(pluginContext, entryFilePath) {
17
17
  });
18
18
  return z.never();
19
19
  }
20
- return { ...metadata, ASTRO_ASSET: true };
20
+ return { ...metadata, ASTRO_ASSET: metadata.fsPath };
21
21
  });
22
22
  };
23
23
  }
@@ -5,7 +5,6 @@ import { getProxyCode } from "../assets/utils/proxy.js";
5
5
  import { AstroError } from "../core/errors/errors.js";
6
6
  import { AstroErrorData } from "../core/errors/index.js";
7
7
  import { isServerLikeOutput } from "../prerender/utils.js";
8
- import { escapeViteEnvReferences } from "../vite-plugin-utils/index.js";
9
8
  import { CONTENT_FLAG, DATA_FLAG } from "./consts.js";
10
9
  import {
11
10
  getContentEntryExts,
@@ -59,7 +58,7 @@ function astroContentImportPlugin({
59
58
  fs,
60
59
  pluginContext: this
61
60
  });
62
- const code = escapeViteEnvReferences(`
61
+ const code = `
63
62
  export const id = ${JSON.stringify(id)};
64
63
  export const collection = ${JSON.stringify(collection)};
65
64
  export const data = ${stringifyEntryData(data, isServerLikeOutput(settings.config))};
@@ -68,7 +67,7 @@ export const _internal = {
68
67
  filePath: ${JSON.stringify(_internal.filePath)},
69
68
  rawData: ${JSON.stringify(_internal.rawData)},
70
69
  };
71
- `);
70
+ `;
72
71
  return code;
73
72
  } else if (hasContentFlag(viteId, CONTENT_FLAG)) {
74
73
  const fileId = viteId.split("?")[0];
@@ -80,7 +79,7 @@ export const _internal = {
80
79
  fs,
81
80
  pluginContext: this
82
81
  });
83
- const code = escapeViteEnvReferences(`
82
+ const code = `
84
83
  export const id = ${JSON.stringify(id)};
85
84
  export const collection = ${JSON.stringify(collection)};
86
85
  export const slug = ${JSON.stringify(slug)};
@@ -90,7 +89,7 @@ export const _internal = {
90
89
  type: 'content',
91
90
  filePath: ${JSON.stringify(_internal.filePath)},
92
91
  rawData: ${JSON.stringify(_internal.rawData)},
93
- };`);
92
+ };`;
94
93
  return { code, map: { mappings: "" } };
95
94
  }
96
95
  },
@@ -269,6 +268,7 @@ function stringifyEntryData(data, isSSR) {
269
268
  }
270
269
  if (typeof value === "object" && "ASTRO_ASSET" in value) {
271
270
  const { ASTRO_ASSET, ...asset } = value;
271
+ asset.fsPath = ASTRO_ASSET;
272
272
  return getProxyCode(asset, isSSR);
273
273
  }
274
274
  });
@@ -4,7 +4,7 @@ import loadFallbackPlugin from "../../vite-plugin-load-fallback/index.js";
4
4
  import { debug } from "../logger/core.js";
5
5
  async function createViteServer(root, fs) {
6
6
  const viteServer = await createServer({
7
- server: { middlewareMode: true, hmr: false, watch: { ignored: ["**"] } },
7
+ server: { middlewareMode: true, hmr: false, watch: null },
8
8
  optimizeDeps: { disabled: true },
9
9
  clearScreen: false,
10
10
  appType: "custom",
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.1.1";
1
+ const ASTRO_VERSION = "4.1.3";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -73,5 +73,10 @@ declare class AstroCookies implements AstroCookiesInterface {
73
73
  * @returns
74
74
  */
75
75
  headers(): Generator<string, void, unknown>;
76
+ /**
77
+ * Behaves the same as AstroCookies.prototype.headers(),
78
+ * but allows a warning when cookies are set after the instance is consumed.
79
+ */
80
+ static consume(cookies: AstroCookies): Generator<string, void, unknown>;
76
81
  }
77
82
  export { AstroCookies };
@@ -28,10 +28,12 @@ class AstroCookies {
28
28
  #request;
29
29
  #requestValues;
30
30
  #outgoing;
31
+ #consumed;
31
32
  constructor(request) {
32
33
  this.#request = request;
33
34
  this.#requestValues = null;
34
35
  this.#outgoing = null;
36
+ this.#consumed = false;
35
37
  }
36
38
  /**
37
39
  * Astro.cookies.delete(key) is used to delete a cookie. Using this method will result
@@ -101,6 +103,13 @@ class AstroCookies {
101
103
  * @param options Options for the cookie, such as the path and security settings.
102
104
  */
103
105
  set(key, value, options) {
106
+ if (this.#consumed) {
107
+ const warning = new Error(
108
+ "Astro.cookies.set() was called after the cookies had already been sent to the browser.\nThis may have happened if this method was called in an imported component.\nPlease make sure that Astro.cookies.set() is only called in the frontmatter of the main page."
109
+ );
110
+ warning.name = "Warning";
111
+ console.warn(warning);
112
+ }
104
113
  let serializedValue;
105
114
  if (typeof value === "string") {
106
115
  serializedValue = value;
@@ -140,6 +149,14 @@ class AstroCookies {
140
149
  yield value[1];
141
150
  }
142
151
  }
152
+ /**
153
+ * Behaves the same as AstroCookies.prototype.headers(),
154
+ * but allows a warning when cookies are set after the instance is consumed.
155
+ */
156
+ static consume(cookies) {
157
+ cookies.#consumed = true;
158
+ return cookies.headers();
159
+ }
143
160
  #ensureParsed(options = void 0) {
144
161
  if (!this.#requestValues) {
145
162
  this.#parse(options);
@@ -1,4 +1,4 @@
1
- import type { AstroCookies } from './cookies.js';
1
+ import { AstroCookies } from './cookies.js';
2
2
  export declare function attachCookiesToResponse(response: Response, cookies: AstroCookies): void;
3
3
  export declare function responseHasCookies(response: Response): boolean;
4
4
  export declare function getSetCookiesFromResponse(response: Response): Generator<string, string[]>;
@@ -1,3 +1,4 @@
1
+ import { AstroCookies } from "./cookies.js";
1
2
  const astroCookiesSymbol = Symbol.for("astro.cookies");
2
3
  function attachCookiesToResponse(response, cookies) {
3
4
  Reflect.set(response, astroCookiesSymbol, cookies);
@@ -18,7 +19,7 @@ function* getSetCookiesFromResponse(response) {
18
19
  if (!cookies) {
19
20
  return [];
20
21
  }
21
- for (const headerValue of cookies.headers()) {
22
+ for (const headerValue of AstroCookies.consume(cookies)) {
22
23
  yield headerValue;
23
24
  }
24
25
  return [];
@@ -15,8 +15,9 @@ import astroPostprocessVitePlugin from "../vite-plugin-astro-postprocess/index.j
15
15
  import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
16
16
  import astroVitePlugin from "../vite-plugin-astro/index.js";
17
17
  import configAliasVitePlugin from "../vite-plugin-config-alias/index.js";
18
- import astroDevOverlay from "../vite-plugin-dev-overlay/vite-plugin-dev-overlay.js";
18
+ import astroDevToolbar from "../vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.js";
19
19
  import envVitePlugin from "../vite-plugin-env/index.js";
20
+ import vitePluginFileURL from "../vite-plugin-fileurl/index.js";
20
21
  import astroHeadPlugin from "../vite-plugin-head/index.js";
21
22
  import htmlVitePlugin from "../vite-plugin-html/index.js";
22
23
  import { astroInjectEnvTsPlugin } from "../vite-plugin-inject-env-ts/index.js";
@@ -31,7 +32,6 @@ import { vitePluginSSRManifest } from "../vite-plugin-ssr-manifest/index.js";
31
32
  import { createViteLogger } from "./logger/vite.js";
32
33
  import { vitePluginMiddleware } from "./middleware/vite-plugin.js";
33
34
  import { joinPaths } from "./path.js";
34
- import vitePluginFileURL from "../vite-plugin-fileurl/index.js";
35
35
  const ALWAYS_NOEXTERNAL = [
36
36
  // This is only because Vite's native ESM doesn't resolve "exports" correctly.
37
37
  "astro",
@@ -113,7 +113,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
113
113
  astroAssetsPlugin({ settings, logger, mode }),
114
114
  astroPrefetch({ settings }),
115
115
  astroTransitions({ settings }),
116
- astroDevOverlay({ settings, logger }),
116
+ astroDevToolbar({ settings, logger }),
117
117
  vitePluginFileURL({}),
118
118
  !!settings.config.i18n && astroInternationalization({ settings })
119
119
  ],
@@ -121,7 +121,9 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
121
121
  root: fileURLToPath(settings.config.root),
122
122
  envPrefix: settings.config.vite?.envPrefix ?? "PUBLIC_",
123
123
  define: {
124
- "import.meta.env.SITE": settings.config.site ? JSON.stringify(settings.config.site) : "undefined"
124
+ "import.meta.env.SITE": stringifyForDefine(settings.config.site),
125
+ "import.meta.env.BASE_URL": stringifyForDefine(settings.config.base),
126
+ "import.meta.env.ASSETS_PREFIX": stringifyForDefine(settings.config.build.assetsPrefix)
125
127
  },
126
128
  server: {
127
129
  hmr: process.env.NODE_ENV === "test" || process.env.NODE_ENV === "production" ? false : void 0,
@@ -245,6 +247,9 @@ function isCommonNotAstro(dep) {
245
247
  // check prefix omitting @scope/
246
248
  );
247
249
  }
250
+ function stringifyForDefine(value) {
251
+ return typeof value === "string" ? JSON.stringify(value) : "undefined";
252
+ }
248
253
  export {
249
254
  createVite
250
255
  };
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
23
23
  base: restart.container.settings.config.base
24
24
  })
25
25
  );
26
- const currentVersion = "4.1.1";
26
+ const currentVersion = "4.1.3";
27
27
  if (currentVersion.includes("-")) {
28
28
  logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
29
29
  }
@@ -133,7 +133,7 @@ function cleanErrorStack(stack) {
133
133
  return stack.split(/\n/g).map((l) => l.replace(/\/@fs\//g, "/")).join("\n");
134
134
  }
135
135
  function getDocsForError(err) {
136
- if (err.name in AstroErrorData) {
136
+ if (err.name !== "UnknownError" && err.name in AstroErrorData) {
137
137
  return `https://docs.astro.build/en/reference/errors/${getKebabErrorName(err.name)}/`;
138
138
  }
139
139
  return void 0;
@@ -389,7 +389,7 @@ export declare const NoMatchingImport: {
389
389
  export declare const InvalidPrerenderExport: {
390
390
  name: string;
391
391
  title: string;
392
- message: (prefix: string, suffix: string, isHydridOuput: boolean) => string;
392
+ message(prefix: string, suffix: string, isHydridOuput: boolean): string;
393
393
  hint: string;
394
394
  };
395
395
  /**
@@ -883,6 +883,43 @@ export declare const FailedToFindPageMapSSR: {
883
883
  title: string;
884
884
  message: string;
885
885
  };
886
+ /**
887
+ * @docs
888
+ * @description
889
+ * Astro can't find the requested locale. All supported locales must be configured in [i18n.locales](/en/reference/configuration-reference/#i18nlocales) and have corresponding directories within `src/pages/`.
890
+ */
891
+ export declare const MissingLocale: {
892
+ name: string;
893
+ title: string;
894
+ message: (locale: string) => string;
895
+ };
896
+ export declare const MissingIndexForInternationalization: {
897
+ name: string;
898
+ title: string;
899
+ message: (src: string) => string;
900
+ };
901
+ /**
902
+ * @docs
903
+ * @description
904
+ * Astro could not find an associated file with content while trying to render the route. This is an Astro error and not a user error. If restarting the dev server does not fix the problem, please file an issue.
905
+ */
906
+ export declare const CantRenderPage: {
907
+ name: string;
908
+ title: string;
909
+ message: string;
910
+ hint: string;
911
+ };
912
+ /**
913
+ * @docs
914
+ * @description
915
+ * Astro could not find any code to handle a rejected `Promise`. Make sure all your promises have an `await` or `.catch()` handler.
916
+ */
917
+ export declare const UnhandledRejection: {
918
+ name: string;
919
+ title: string;
920
+ message: (stack: string) => string;
921
+ hint: string;
922
+ };
886
923
  /**
887
924
  * @docs
888
925
  * @kind heading
@@ -1068,7 +1105,7 @@ export declare const UnknownContentCollectionError: {
1068
1105
  export declare const InvalidContentEntryFrontmatterError: {
1069
1106
  name: string;
1070
1107
  title: string;
1071
- message: (collection: string, entryId: string, error: ZodError) => string;
1108
+ message(collection: string, entryId: string, error: ZodError): string;
1072
1109
  hint: string;
1073
1110
  };
1074
1111
  /**
@@ -1082,7 +1119,7 @@ export declare const InvalidContentEntryFrontmatterError: {
1082
1119
  export declare const InvalidContentEntrySlugError: {
1083
1120
  name: string;
1084
1121
  title: string;
1085
- message: (collection: string, entryId: string) => string;
1122
+ message(collection: string, entryId: string): string;
1086
1123
  hint: string;
1087
1124
  };
1088
1125
  /**
@@ -1113,7 +1150,6 @@ export declare const CollectionDoesNotExistError: {
1113
1150
  };
1114
1151
  /**
1115
1152
  * @docs
1116
- * @message `COLLECTION_NAME` contains a mix of content and data entries. All entries must be of the same type.
1117
1153
  * @see
1118
1154
  * - [Defining content collections](https://docs.astro.build/en/guides/content-collections/#defining-collections)
1119
1155
  * @description
@@ -1122,12 +1158,11 @@ export declare const CollectionDoesNotExistError: {
1122
1158
  export declare const MixedContentDataCollectionError: {
1123
1159
  name: string;
1124
1160
  title: string;
1125
- message: (collection: string) => string;
1161
+ message: (collectionName: string) => string;
1126
1162
  hint: string;
1127
1163
  };
1128
1164
  /**
1129
1165
  * @docs
1130
- * @message `COLLECTION_NAME` contains entries of type `ACTUAL_TYPE`, but is configured as a `EXPECTED_TYPE` collection.
1131
1166
  * @see
1132
1167
  * - [Defining content collections](https://docs.astro.build/en/guides/content-collections/#defining-collections)
1133
1168
  * @description
@@ -1147,7 +1182,7 @@ export declare const ContentCollectionTypeMismatchError: {
1147
1182
  export declare const DataCollectionEntryParseError: {
1148
1183
  name: string;
1149
1184
  title: string;
1150
- message: (entryId: string, errorMessage: string) => string;
1185
+ message(entryId: string, errorMessage: string): string;
1151
1186
  hint: string;
1152
1187
  };
1153
1188
  /**
@@ -1159,7 +1194,7 @@ export declare const DataCollectionEntryParseError: {
1159
1194
  export declare const DuplicateContentEntrySlugError: {
1160
1195
  name: string;
1161
1196
  title: string;
1162
- message: (collection: string, slug: string, preExisting: string, alsoFound: string) => string;
1197
+ message(collection: string, slug: string, preExisting: string, alsoFound: string): string;
1163
1198
  };
1164
1199
  /**
1165
1200
  * @docs
@@ -1174,24 +1209,7 @@ export declare const UnsupportedConfigTransformError: {
1174
1209
  message: (parseError: string) => string;
1175
1210
  hint: string;
1176
1211
  };
1177
- export declare const MissingLocale: {
1178
- name: string;
1179
- title: string;
1180
- message: (locale: string) => string;
1181
- };
1182
- export declare const CantRenderPage: {
1183
- name: string;
1184
- title: string;
1185
- message: string;
1186
- hint: string;
1187
- };
1188
1212
  export declare const UnknownError: {
1189
1213
  name: string;
1190
1214
  title: string;
1191
1215
  };
1192
- export declare const UnhandledRejection: {
1193
- name: string;
1194
- title: string;
1195
- message: (stack: string) => string;
1196
- hint: string;
1197
- };