astro 5.0.0-beta.9 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,3 @@
4
4
  export { default as Code } from './Code.astro';
5
5
  // @ts-ignore
6
6
  export { default as Debug } from './Debug.astro';
7
- // @ts-ignore
8
- export { default as Welcome } from './Welcome.astro';
@@ -5,7 +5,7 @@ const VIRTUAL_INTERNAL_MODULE_ID = "astro:internal-actions";
5
5
  const RESOLVED_VIRTUAL_INTERNAL_MODULE_ID = "\0astro:internal-actions";
6
6
  const NOOP_ACTIONS = "\0noop-actions";
7
7
  const ACTION_QUERY_PARAMS = {
8
- actionName: "_astroAction",
8
+ actionName: "_action",
9
9
  actionPayload: "_astroActionPayload"
10
10
  };
11
11
  const ACTION_RPC_ROUTE_PATTERN = "/_actions/[...path]";
@@ -27,7 +27,7 @@ function astroIntegrationActionsRouteHandler({
27
27
  throw error;
28
28
  }
29
29
  const stringifiedActionsImport = JSON.stringify(
30
- viteID(new URL("./actions", params.config.srcDir))
30
+ viteID(new URL("./actions/index.ts", params.config.srcDir))
31
31
  );
32
32
  settings.injectedTypes.push({
33
33
  filename: ACTIONS_TYPES_FILE,
@@ -5,11 +5,11 @@ import {
5
5
  import { resolveInjectedRoute } from "../../core/routing/manifest/create.js";
6
6
  import { getPattern } from "../../core/routing/manifest/pattern.js";
7
7
  function injectImageEndpoint(settings, manifest, mode, cwd) {
8
- manifest.routes.push(getImageEndpointData(settings, mode, cwd));
8
+ manifest.routes.unshift(getImageEndpointData(settings, mode, cwd));
9
9
  }
10
10
  function ensureImageEndpointRoute(settings, manifest, mode, cwd) {
11
- if (!manifest.routes.some((route) => route.route === "/_image")) {
12
- manifest.routes.push(getImageEndpointData(settings, mode, cwd));
11
+ if (!manifest.routes.some((route) => route.route === settings.config.image.endpoint.route)) {
12
+ manifest.routes.unshift(getImageEndpointData(settings, mode, cwd));
13
13
  }
14
14
  }
15
15
  function getImageEndpointData(settings, mode, cwd) {
@@ -4,20 +4,11 @@ import {
4
4
  spreadAttributes,
5
5
  unescapeHTML
6
6
  } from "../runtime/server/index.js";
7
- const ids = /* @__PURE__ */ new WeakMap();
8
- let counter = 0;
7
+ const countersByPage = /* @__PURE__ */ new WeakMap();
9
8
  function createSvgComponent({ meta, attributes, children }) {
10
- const rendered = /* @__PURE__ */ new WeakSet();
9
+ const renderedIds = /* @__PURE__ */ new WeakMap();
11
10
  const Component = createComponent((result, props) => {
12
- let id;
13
- if (ids.has(result)) {
14
- id = ids.get(result);
15
- } else {
16
- counter += 1;
17
- ids.set(result, counter);
18
- id = counter;
19
- }
20
- id = `a:${id}`;
11
+ let counter = countersByPage.get(result) ?? 0;
21
12
  const {
22
13
  title: titleProp,
23
14
  viewBox,
@@ -27,9 +18,12 @@ function createSvgComponent({ meta, attributes, children }) {
27
18
  const title = titleProp ? unescapeHTML(`<title>${titleProp}</title>`) : "";
28
19
  if (mode === "sprite") {
29
20
  let symbol = "";
30
- if (!rendered.has(result.response)) {
21
+ let id = renderedIds.get(result);
22
+ if (!id) {
23
+ countersByPage.set(result, ++counter);
24
+ id = `a:${counter}`;
31
25
  symbol = unescapeHTML(`<symbol${spreadAttributes({ viewBox, id })}>${children}</symbol>`);
32
- rendered.add(result.response);
26
+ renderedIds.set(result, id);
33
27
  }
34
28
  return render`<svg${spreadAttributes(normalizedProps)}>${title}${symbol}<use href="#${id}" /></svg>`;
35
29
  }
@@ -2,7 +2,13 @@ import { parse, renderSync } from "ultrahtml";
2
2
  import { dropAttributes } from "../runtime.js";
3
3
  function parseSvg(contents) {
4
4
  const root = parse(contents);
5
- const [{ attributes, children }] = root.children;
5
+ const svgNode = root.children.find(
6
+ ({ name, type }) => type === 1 && name === "svg"
7
+ );
8
+ if (!svgNode) {
9
+ throw new Error("SVG file does not contain an <svg> element");
10
+ }
11
+ const { attributes, children } = svgNode;
6
12
  const body = renderSync({ ...root, children });
7
13
  return { attributes, body };
8
14
  }
@@ -68,7 +68,7 @@ const JPG = {
68
68
  while (input.length) {
69
69
  const i = readUInt16BE(input, 0);
70
70
  if (input[i] !== 255) {
71
- input = input.slice(1);
71
+ input = input.slice(i);
72
72
  continue;
73
73
  }
74
74
  if (isEXIF(input)) {
@@ -114,7 +114,7 @@ class ContentLayer {
114
114
  logger.info("Content config changed");
115
115
  shouldClear = true;
116
116
  }
117
- if (previousAstroVersion !== "5.0.0-beta.9") {
117
+ if (previousAstroVersion !== "5.0.0") {
118
118
  logger.info("Astro version changed");
119
119
  shouldClear = true;
120
120
  }
@@ -122,8 +122,8 @@ class ContentLayer {
122
122
  logger.info("Clearing content store");
123
123
  this.#store.clearAll();
124
124
  }
125
- if ("5.0.0-beta.9") {
126
- await this.#store.metaStore().set("astro-version", "5.0.0-beta.9");
125
+ if ("5.0.0") {
126
+ await this.#store.metaStore().set("astro-version", "5.0.0");
127
127
  }
128
128
  if (currentConfigDigest) {
129
129
  await this.#store.metaStore().set("config-digest", currentConfigDigest);
@@ -292,14 +292,14 @@ function getRelativeEntryPath(entry, collection, contentDir) {
292
292
  function getEntryType(entryPath, paths, contentFileExts, dataFileExts) {
293
293
  const { ext } = path.parse(entryPath);
294
294
  const fileUrl = pathToFileURL(entryPath);
295
- if (hasUnderscoreBelowContentDirectoryPath(fileUrl, paths.contentDir)) {
295
+ if (fileUrl.href === paths.config.url.href) {
296
+ return "config";
297
+ } else if (hasUnderscoreBelowContentDirectoryPath(fileUrl, paths.contentDir)) {
296
298
  return "ignored";
297
299
  } else if (contentFileExts.includes(ext)) {
298
300
  return "content";
299
301
  } else if (dataFileExts.includes(ext)) {
300
302
  return "data";
301
- } else if (fileUrl.href === paths.config.url.href) {
302
- return "config";
303
303
  } else {
304
304
  return "ignored";
305
305
  }
@@ -10,20 +10,38 @@ function createOriginCheckMiddleware() {
10
10
  if (isPrerendered) {
11
11
  return next();
12
12
  }
13
- const contentType = request.headers.get("content-type");
14
- if (contentType) {
15
- if (FORM_CONTENT_TYPES.includes(contentType.toLowerCase())) {
16
- const forbidden = (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request.headers.get("origin") !== url.origin;
17
- if (forbidden) {
18
- return new Response(`Cross-site ${request.method} form submissions are forbidden`, {
19
- status: 403
20
- });
21
- }
13
+ if (request.method === "GET") {
14
+ return next();
15
+ }
16
+ const sameOrigin = (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request.headers.get("origin") === url.origin;
17
+ const hasContentType = request.headers.has("content-type");
18
+ if (hasContentType) {
19
+ const formLikeHeader = hasFormLikeHeader(request.headers.get("content-type"));
20
+ if (formLikeHeader && !sameOrigin) {
21
+ return new Response(`Cross-site ${request.method} form submissions are forbidden`, {
22
+ status: 403
23
+ });
24
+ }
25
+ } else {
26
+ if (!sameOrigin) {
27
+ return new Response(`Cross-site ${request.method} form submissions are forbidden`, {
28
+ status: 403
29
+ });
22
30
  }
23
31
  }
24
32
  return next();
25
33
  });
26
34
  }
35
+ function hasFormLikeHeader(contentType) {
36
+ if (contentType) {
37
+ for (const FORM_CONTENT_TYPE of FORM_CONTENT_TYPES) {
38
+ if (contentType.toLowerCase().includes(FORM_CONTENT_TYPE)) {
39
+ return true;
40
+ }
41
+ }
42
+ }
43
+ return false;
44
+ }
27
45
  export {
28
46
  createOriginCheckMiddleware
29
47
  };
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.0.0-beta.9";
1
+ const ASTRO_VERSION = "5.0.0";
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";
@@ -175,7 +175,6 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
175
175
  replacement: "astro/components"
176
176
  }
177
177
  ],
178
- conditions: ["astro"],
179
178
  // Astro imports in third-party packages should use the same version as root
180
179
  dedupe: ["astro"]
181
180
  },
@@ -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.0.0-beta.9";
25
+ const currentVersion = "5.0.0";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -42,7 +42,7 @@ export declare const ClientAddressNotAvailable: {
42
42
  /**
43
43
  * @docs
44
44
  * @see
45
- * - [Opting-in to pre-rendering](https://docs.astro.build/en/guides/server-side-rendering/#opting-in-to-pre-rendering-in-server-mode)
45
+ * - [On-demand rendering](https://docs.astro.build/en/guides/on-demand-rendering/)
46
46
  * - [Astro.clientAddress](https://docs.astro.build/en/reference/api-reference/#astroclientaddress)
47
47
  * @description
48
48
  * The `Astro.clientAddress` property cannot be used inside prerendered routes.
@@ -55,10 +55,10 @@ export declare const PrerenderClientAddressNotAvailable: {
55
55
  /**
56
56
  * @docs
57
57
  * @see
58
- * - [Enabling SSR in Your Project](https://docs.astro.build/en/guides/server-side-rendering/)
58
+ * - [Enabling SSR in Your Project](https://docs.astro.build/en/guides/on-demand-rendering/)
59
59
  * - [Astro.clientAddress](https://docs.astro.build/en/reference/api-reference/#astroclientaddress)
60
60
  * @description
61
- * The `Astro.clientAddress` property is only available when [Server-side rendering](https://docs.astro.build/en/guides/server-side-rendering/) is enabled.
61
+ * The `Astro.clientAddress` property is only available when [Server-side rendering](https://docs.astro.build/en/guides/on-demand-rendering/) is enabled.
62
62
  *
63
63
  * To get the user's IP address in static mode, different APIs such as [Ipify](https://www.ipify.org/) can be used in a [Client-side script](https://docs.astro.build/en/guides/client-side-scripts/) or it may be possible to get the user's IP using a serverless function hosted on your hosting provider.
64
64
  */
@@ -85,7 +85,7 @@ export declare const NoMatchingStaticPathFound: {
85
85
  * @docs
86
86
  * @message Route returned a `RETURNED_VALUE`. Only a Response can be returned from Astro files.
87
87
  * @see
88
- * - [Response](https://docs.astro.build/en/guides/server-side-rendering/#response)
88
+ * - [Response](https://docs.astro.build/en/guides/on-demand-rendering/#response)
89
89
  * @description
90
90
  * Only instances of [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned inside Astro files.
91
91
  * ```astro title="pages/login.astro"
@@ -314,7 +314,7 @@ export declare const GetStaticPathsInvalidRouteParam: {
314
314
  * @see
315
315
  * - [Dynamic Routes](https://docs.astro.build/en/guides/routing/#dynamic-routes)
316
316
  * - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
317
- * - [Server-side Rendering](https://docs.astro.build/en/guides/server-side-rendering/)
317
+ * - [Server-side Rendering](https://docs.astro.build/en/guides/on-demand-rendering/)
318
318
  * @description
319
319
  * In [Static Mode](https://docs.astro.build/en/guides/routing/#static-ssg-mode), all routes must be determined at build time. As such, dynamic routes must `export` a `getStaticPaths` function returning the different paths to generate.
320
320
  */
@@ -339,7 +339,7 @@ export declare const ReservedSlotName: {
339
339
  /**
340
340
  * @docs
341
341
  * @see
342
- * - [Server-side Rendering](https://docs.astro.build/en/guides/server-side-rendering/)
342
+ * - [Server-side Rendering](https://docs.astro.build/en/guides/on-demand-rendering/)
343
343
  * @description
344
344
  * To use server-side rendering, an adapter needs to be installed so Astro knows how to generate the proper output for your targeted deployment platform.
345
345
  */
@@ -352,7 +352,7 @@ export declare const NoAdapterInstalled: {
352
352
  /**
353
353
  * @docs
354
354
  * @see
355
- * - [Server-side Rendering](https://docs.astro.build/en/guides/server-side-rendering/)
355
+ * - [Server-side Rendering](https://docs.astro.build/en/guides/on-demand-rendering/)
356
356
  * @description
357
357
  * The currently configured adapter does not support server-side rendering, which is required for the current project setup.
358
358
  *
@@ -17,7 +17,7 @@ const StaticClientAddressNotAvailable = {
17
17
  name: "StaticClientAddressNotAvailable",
18
18
  title: "`Astro.clientAddress` is not available in prerendered pages.",
19
19
  message: "`Astro.clientAddress` is only available on pages that are server-rendered.",
20
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information on how to enable SSR."
20
+ hint: "See https://docs.astro.build/en/guides/on-demand-rendering/ for more information on how to enable SSR."
21
21
  };
22
22
  const NoMatchingStaticPathFound = {
23
23
  name: "NoMatchingStaticPathFound",
@@ -29,7 +29,7 @@ const OnlyResponseCanBeReturned = {
29
29
  name: "OnlyResponseCanBeReturned",
30
30
  title: "Invalid type returned by Astro page.",
31
31
  message: (route, returnedValue) => `Route \`${route ? route : ""}\` returned a \`${returnedValue}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,
32
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
32
+ hint: "See https://docs.astro.build/en/guides/on-demand-rendering/#response for more information."
33
33
  };
34
34
  const MissingMediaQueryDirective = {
35
35
  name: "MissingMediaQueryDirective",
@@ -106,7 +106,7 @@ const NoAdapterInstalled = {
106
106
  name: "NoAdapterInstalled",
107
107
  title: "Cannot use Server-side Rendering without an adapter.",
108
108
  message: `Cannot use server-rendered pages without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
109
- hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information."
109
+ hint: "See https://docs.astro.build/en/guides/on-demand-rendering/ for more information."
110
110
  };
111
111
  const AdapterSupportOutputMismatch = {
112
112
  name: "AdapterSupportOutputMismatch",
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "5.0.0-beta.9";
41
+ const version = "5.0.0";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -274,7 +274,7 @@ function printHelp({
274
274
  message.push(
275
275
  linebreak(),
276
276
  ` ${bgGreen(black(` ${commandName} `))} ${green(
277
- `v${"5.0.0-beta.9"}`
277
+ `v${"5.0.0"}`
278
278
  )} ${headline}`
279
279
  );
280
280
  }
@@ -1,7 +1,8 @@
1
1
  import { NOOP_MIDDLEWARE_HEADER } from "../constants.js";
2
- const NOOP_MIDDLEWARE_FN = (ctx, next) => {
3
- ctx.request.headers.set(NOOP_MIDDLEWARE_HEADER, "true");
4
- return next();
2
+ const NOOP_MIDDLEWARE_FN = async (_ctx, next) => {
3
+ const response = await next();
4
+ response.headers.set(NOOP_MIDDLEWARE_HEADER, "true");
5
+ return response;
5
6
  };
6
7
  export {
7
8
  NOOP_MIDDLEWARE_FN
@@ -28,8 +28,8 @@ function createRequest({
28
28
  body: isPrerendered ? null : body
29
29
  });
30
30
  if (isPrerendered) {
31
- const _headers = request.headers;
32
- const headersDesc = Object.getOwnPropertyDescriptor(request, "headers") || {};
31
+ let _headers = request.headers;
32
+ const { value, writable, ...headersDesc } = Object.getOwnPropertyDescriptor(request, "headers") || {};
33
33
  Object.defineProperty(request, "headers", {
34
34
  ...headersDesc,
35
35
  get() {
@@ -38,6 +38,9 @@ function createRequest({
38
38
  `\`Astro.request.headers\` is not available on prerendered pages. If you need access to request headers, make sure that the page is server rendered using \`export const prerender = false;\` or by setting \`output\` to \`"server"\` in your Astro config to make all your pages server rendered.`
39
39
  );
40
40
  return _headers;
41
+ },
42
+ set(newHeaders) {
43
+ _headers = newHeaders;
41
44
  }
42
45
  });
43
46
  } else if (clientAddress) {
@@ -2,6 +2,7 @@ import {
2
2
  renderComponent,
3
3
  renderTemplate
4
4
  } from "../../runtime/server/index.js";
5
+ import { isAstroComponentFactory } from "../../runtime/server/render/astro/factory.js";
5
6
  import { createSlotValueFromString } from "../../runtime/server/render/slot.js";
6
7
  import { decryptString } from "../encryption.js";
7
8
  import { getPattern } from "../routing/manifest/pattern.js";
@@ -98,11 +99,19 @@ function createEndpoint(manifest) {
98
99
  const propString = await decryptString(key, encryptedProps);
99
100
  const props = JSON.parse(propString);
100
101
  const componentModule = await imp();
101
- const Component = componentModule[data.componentExport];
102
+ let Component = componentModule[data.componentExport];
102
103
  const slots = {};
103
104
  for (const prop in data.slots) {
104
105
  slots[prop] = createSlotValueFromString(data.slots[prop]);
105
106
  }
107
+ if (isAstroComponentFactory(Component)) {
108
+ const ServerIsland = Component;
109
+ Component = function(...args) {
110
+ return ServerIsland.apply(this, args);
111
+ };
112
+ Object.assign(Component, ServerIsland);
113
+ Component.propagation = "self";
114
+ }
106
115
  return renderTemplate`${renderComponent(result, "Component", Component, props, slots)}`;
107
116
  };
108
117
  page.isAstroComponentFactory = true;
@@ -99,11 +99,15 @@ async function syncInternal({
99
99
  });
100
100
  await contentLayer.sync();
101
101
  settings.timer.end("Sync content layer");
102
- } else if (fs.existsSync(fileURLToPath(getContentPaths(settings.config, fs).contentDir))) {
103
- settings.injectedTypes.push({
104
- filename: CONTENT_TYPES_FILE,
105
- content: ""
106
- });
102
+ } else {
103
+ const paths = getContentPaths(settings.config, fs);
104
+ if (paths.config.exists || // Legacy collections don't require a config file
105
+ settings.config.legacy?.collections && fs.existsSync(paths.contentDir)) {
106
+ settings.injectedTypes.push({
107
+ filename: CONTENT_TYPES_FILE,
108
+ content: ""
109
+ });
110
+ }
107
111
  }
108
112
  syncAstroEnv(settings);
109
113
  writeInjectedTypes(settings, fs);
@@ -1,4 +1,4 @@
1
- import { ROUTE_TYPE_HEADER } from "../core/constants.js";
1
+ import { REROUTE_DIRECTIVE_HEADER, ROUTE_TYPE_HEADER } from "../core/constants.js";
2
2
  import {
3
3
  normalizeTheLocale,
4
4
  notFound,
@@ -48,6 +48,10 @@ function createI18nMiddleware(i18n, base, trailingSlash, format) {
48
48
  return async (context, next) => {
49
49
  const response = await next();
50
50
  const type = response.headers.get(ROUTE_TYPE_HEADER);
51
+ const isReroute = response.headers.get(REROUTE_DIRECTIVE_HEADER);
52
+ if (isReroute === "no" && typeof i18n.fallback === "undefined") {
53
+ return response;
54
+ }
51
55
  if (type !== "page" && type !== "fallback") {
52
56
  return response;
53
57
  }
@@ -248,7 +248,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
248
248
  *
249
249
  * Deploy to your favorite server, serverless, or edge host with build adapters. Import one of our first-party adapters for [Netlify](https://docs.astro.build/en/guides/deploy/netlify/#adapter-for-ssr), [Vercel](https://docs.astro.build/en/guides/deploy/vercel/#adapter-for-ssr), and more to engage Astro SSR.
250
250
  *
251
- * [See our Server-side Rendering guide](https://docs.astro.build/en/guides/server-side-rendering/) for more on SSR, and [our deployment guides](https://docs.astro.build/en/guides/deploy/) for a complete list of hosts.
251
+ * [See our On-demand Rendering guide](https://docs.astro.build/en/guides/on-demand-rendering/) for more on SSR, and [our deployment guides](https://docs.astro.build/en/guides/deploy/) for a complete list of hosts.
252
252
  *
253
253
  * ```js
254
254
  * import netlify from '@astrojs/netlify';
@@ -1585,7 +1585,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1585
1585
  validateSecrets?: boolean;
1586
1586
  };
1587
1587
  /**
1588
- * @docs
1588
+ *
1589
1589
  * @kind heading
1590
1590
  * @name Legacy Flags
1591
1591
  * @description
@@ -1595,7 +1595,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1595
1595
  */
1596
1596
  legacy?: {
1597
1597
  /**
1598
- * @docs
1598
+ *
1599
1599
  * @name legacy.collections
1600
1600
  * @type {boolean}
1601
1601
  * @default `false`
@@ -1632,12 +1632,11 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1632
1632
  * export const collections = { blog };
1633
1633
  * ```
1634
1634
  *
1635
-
1636
1635
  */
1637
1636
  collections?: boolean;
1638
1637
  };
1639
1638
  /**
1640
- * @docs
1639
+ *
1641
1640
  * @kind heading
1642
1641
  * @name Experimental Flags
1643
1642
  * @description
@@ -1646,7 +1645,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1646
1645
  */
1647
1646
  experimental?: {
1648
1647
  /**
1649
- * @docs
1648
+ *
1650
1649
  * @name experimental.clientPrerender
1651
1650
  * @type {boolean}
1652
1651
  * @default `false`
@@ -1681,7 +1680,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1681
1680
  */
1682
1681
  clientPrerender?: boolean;
1683
1682
  /**
1684
- * @docs
1683
+ *
1685
1684
  * @name experimental.contentIntellisense
1686
1685
  * @type {boolean}
1687
1686
  * @default `false`
@@ -1704,7 +1703,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1704
1703
  */
1705
1704
  contentIntellisense?: boolean;
1706
1705
  /**
1707
- * @docs
1706
+ *
1708
1707
  * @name experimental.responsiveImages
1709
1708
  * @type {boolean}
1710
1709
  * @default `undefined`
@@ -1820,7 +1819,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1820
1819
  */
1821
1820
  responsiveImages?: boolean;
1822
1821
  /**
1823
- * @docs
1822
+ *
1824
1823
  * @name experimental.svg
1825
1824
  * @type {boolean|object}
1826
1825
  * @default `undefined`
@@ -1855,7 +1854,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1855
1854
  */
1856
1855
  svg?: {
1857
1856
  /**
1858
- * @docs
1857
+ *
1859
1858
  * @name experimental.svg.mode
1860
1859
  * @type {string}
1861
1860
  * @default 'inline'
@@ -1,4 +1,4 @@
1
- import { normalizePath } from "vite";
1
+ import { defaultClientConditions, defaultServerConditions, normalizePath } from "vite";
2
2
  import { hasSpecialQueries, normalizeFilename } from "../vite-plugin-utils/index.js";
3
3
  import { compileAstro } from "./compile.js";
4
4
  import { handleHotUpdate } from "./hmr.js";
@@ -17,6 +17,17 @@ function astro({ settings, logger }) {
17
17
  name: "astro:build",
18
18
  enforce: "pre",
19
19
  // run transforms before other plugins can
20
+ async configEnvironment(name, viteConfig, opts) {
21
+ viteConfig.resolve ??= {};
22
+ if (viteConfig.resolve.conditions == null) {
23
+ if (viteConfig.consumer === "client" || name === "client" || opts.isSsrTargetWebworker) {
24
+ viteConfig.resolve.conditions = [...defaultClientConditions];
25
+ } else {
26
+ viteConfig.resolve.conditions = [...defaultServerConditions];
27
+ }
28
+ }
29
+ viteConfig.resolve.conditions.push("astro");
30
+ },
20
31
  configResolved(viteConfig) {
21
32
  compile = (code, filename) => {
22
33
  return compileAstro({
@@ -3,7 +3,7 @@ import { IncomingMessage } from "node:http";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { normalizePath } from "vite";
5
5
  import { warnMissingAdapter } from "../core/dev/adapter-validation.js";
6
- import { createKey } from "../core/encryption.js";
6
+ import { createKey, getEnvironmentKey, hasEnvironmentKey } from "../core/encryption.js";
7
7
  import { getViteErrorPayload } from "../core/errors/dev/index.js";
8
8
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
9
9
  import { patchOverlay } from "../core/errors/overlay.js";
@@ -151,7 +151,7 @@ function createDevelopmentManifest(settings) {
151
151
  i18n: i18nManifest,
152
152
  checkOrigin: (settings.config.security?.checkOrigin && settings.buildOutput === "server") ?? false,
153
153
  envGetSecretEnabled: false,
154
- key: createKey(),
154
+ key: hasEnvironmentKey() ? getEnvironmentKey() : createKey(),
155
155
  middleware() {
156
156
  return {
157
157
  onRequest: NOOP_MIDDLEWARE_FN
@@ -42,7 +42,6 @@ async function handleRequest({
42
42
  url,
43
43
  pathname: resolvedPathname,
44
44
  body,
45
- origin,
46
45
  pipeline,
47
46
  manifestData,
48
47
  incomingRequest,
@@ -16,11 +16,10 @@ type HandleRoute = {
16
16
  url: URL;
17
17
  pathname: string;
18
18
  body: ArrayBuffer | undefined;
19
- origin: string;
20
19
  manifestData: ManifestData;
21
20
  incomingRequest: http.IncomingMessage;
22
21
  incomingResponse: http.ServerResponse;
23
22
  pipeline: DevPipeline;
24
23
  };
25
- export declare function handleRoute({ matchedRoute, url, pathname, body, origin, pipeline, manifestData, incomingRequest, incomingResponse, }: HandleRoute): Promise<void>;
24
+ export declare function handleRoute({ matchedRoute, url, pathname, body, pipeline, manifestData, incomingRequest, incomingResponse, }: HandleRoute): Promise<void>;
26
25
  export {};
@@ -90,7 +90,6 @@ async function handleRoute({
90
90
  url,
91
91
  pathname,
92
92
  body,
93
- origin,
94
93
  pipeline,
95
94
  manifestData,
96
95
  incomingRequest,
@@ -104,11 +103,9 @@ async function handleRoute({
104
103
  let request;
105
104
  let renderContext;
106
105
  let mod = void 0;
107
- let options = void 0;
108
106
  let route;
109
107
  const middleware = (await loadMiddleware(loader)).onRequest;
110
108
  const locals = Reflect.get(incomingRequest, clientLocalsSymbol);
111
- const filePath = matchedRoute.filePath;
112
109
  const { preloadedComponent } = matchedRoute;
113
110
  route = matchedRoute.route;
114
111
  request = createRequest({
@@ -123,14 +120,6 @@ async function handleRoute({
123
120
  for (const [name, value] of Object.entries(config.server.headers ?? {})) {
124
121
  if (value) incomingResponse.setHeader(name, value);
125
122
  }
126
- options = {
127
- pipeline,
128
- filePath,
129
- preload: preloadedComponent,
130
- pathname,
131
- request,
132
- route
133
- };
134
123
  mod = preloadedComponent;
135
124
  renderContext = await RenderContext.create({
136
125
  locals,
@@ -184,18 +173,17 @@ async function handleRoute({
184
173
  }
185
174
  if (statusCode === 404 && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
186
175
  const fourOhFourRoute = await matchRoute("/404", manifestData, pipeline);
187
- if (options && options.route !== fourOhFourRoute?.route)
188
- return handleRoute({
189
- ...options,
190
- matchedRoute: fourOhFourRoute,
191
- url: new URL(pathname, url),
192
- body,
193
- origin,
176
+ if (fourOhFourRoute) {
177
+ renderContext = await RenderContext.create({
178
+ locals,
194
179
  pipeline,
195
- manifestData,
196
- incomingRequest,
197
- incomingResponse
180
+ pathname,
181
+ middleware: isDefaultPrerendered404(fourOhFourRoute.route) ? void 0 : middleware,
182
+ request,
183
+ routeData: fourOhFourRoute.route
198
184
  });
185
+ response = await renderContext.render(fourOhFourRoute.preloadedComponent);
186
+ }
199
187
  }
200
188
  if (isReroute) {
201
189
  response.headers.delete(REROUTE_DIRECTIVE_HEADER);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.0.0-beta.9",
3
+ "version": "5.0.0",
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",
@@ -111,7 +111,7 @@
111
111
  "aria-query": "^5.3.2",
112
112
  "axobject-query": "^4.1.0",
113
113
  "boxen": "8.0.1",
114
- "ci-info": "^4.0.0",
114
+ "ci-info": "^4.1.0",
115
115
  "clsx": "^2.1.1",
116
116
  "common-ancestor-path": "^1.0.1",
117
117
  "cookie": "^0.7.2",
@@ -132,7 +132,7 @@
132
132
  "http-cache-semantics": "^4.1.1",
133
133
  "js-yaml": "^4.1.0",
134
134
  "kleur": "^4.1.5",
135
- "magic-string": "^0.30.12",
135
+ "magic-string": "^0.30.14",
136
136
  "magicast": "^0.3.5",
137
137
  "micromatch": "^4.0.8",
138
138
  "mrmime": "^2.0.0",
@@ -143,37 +143,37 @@
143
143
  "prompts": "^2.4.2",
144
144
  "rehype": "^13.0.2",
145
145
  "semver": "^7.6.3",
146
- "shiki": "^1.22.2",
146
+ "shiki": "^1.23.1",
147
147
  "tinyexec": "^0.3.1",
148
148
  "tsconfck": "^3.1.4",
149
149
  "ultrahtml": "^1.5.3",
150
150
  "unist-util-visit": "^5.0.0",
151
151
  "vfile": "^6.0.3",
152
- "vite": "6.0.0-beta.6",
153
- "vitefu": "^1.0.3",
152
+ "vite": "^6.0.1",
153
+ "vitefu": "^1.0.4",
154
154
  "which-pm": "^3.0.0",
155
- "xxhash-wasm": "^1.0.2",
155
+ "xxhash-wasm": "^1.1.0",
156
156
  "yargs-parser": "^21.1.1",
157
157
  "yocto-spinner": "^0.1.0",
158
158
  "zod": "^3.23.8",
159
159
  "zod-to-json-schema": "^3.23.5",
160
160
  "zod-to-ts": "^1.2.0",
161
- "@astrojs/internal-helpers": "0.4.1",
162
- "@astrojs/markdown-remark": "6.0.0-beta.2",
163
- "@astrojs/telemetry": "3.1.0"
161
+ "@astrojs/internal-helpers": "0.4.2",
162
+ "@astrojs/markdown-remark": "6.0.0",
163
+ "@astrojs/telemetry": "3.2.0"
164
164
  },
165
165
  "optionalDependencies": {
166
166
  "sharp": "^0.33.3"
167
167
  },
168
168
  "devDependencies": {
169
169
  "@astrojs/check": "^0.9.4",
170
- "@playwright/test": "^1.48.2",
170
+ "@playwright/test": "^1.49.0",
171
171
  "@types/aria-query": "^5.0.4",
172
172
  "@types/common-ancestor-path": "^1.0.2",
173
173
  "@types/cssesc": "^3.0.2",
174
174
  "@types/debug": "^4.1.12",
175
175
  "@types/diff": "^5.2.3",
176
- "@types/dlv": "^1.1.4",
176
+ "@types/dlv": "^1.1.5",
177
177
  "@types/hast": "^3.0.4",
178
178
  "@types/html-escaper": "^3.0.2",
179
179
  "@types/http-cache-semantics": "^4.0.4",
@@ -195,15 +195,15 @@
195
195
  "rehype-slug": "^6.0.0",
196
196
  "rehype-toc": "^3.0.2",
197
197
  "remark-code-titles": "^0.1.2",
198
- "rollup": "^4.24.4",
199
- "sass": "^1.80.6",
200
- "undici": "^6.20.1",
198
+ "rollup": "^4.27.4",
199
+ "sass": "^1.81.0",
200
+ "undici": "^6.21.0",
201
201
  "unified": "^11.0.5",
202
- "vitest": "^2.1.1",
202
+ "vitest": "^2.1.6",
203
203
  "astro-scripts": "0.0.14"
204
204
  },
205
205
  "engines": {
206
- "node": "^18.17.1 || ^20.3.0 || >=21.0.0",
206
+ "node": "^18.17.1 || ^20.3.0 || >=22.0.0",
207
207
  "npm": ">=9.6.5",
208
208
  "pnpm": ">=7.1.0"
209
209
  },
@@ -1,172 +0,0 @@
1
- ---
2
- interface Props {
3
- title?: string;
4
- }
5
-
6
- const cards = [
7
- {
8
- href: 'https://docs.astro.build/',
9
- title: 'Documentation',
10
- body: 'Learn how Astro works and explore the official API docs.',
11
- },
12
- {
13
- href: 'https://astro.build/integrations/',
14
- title: 'Integrations',
15
- body: 'Supercharge your project with new frameworks and libraries.',
16
- },
17
- {
18
- href: 'https://astro.build/themes/',
19
- title: 'Themes',
20
- body: 'Explore a galaxy of community-built starter themes.',
21
- },
22
- {
23
- href: 'https://astro.build/chat/',
24
- title: 'Community',
25
- body: 'Come say hi to our amazing Discord community. ❤️',
26
- },
27
- ];
28
-
29
- const { title = 'Welcome to Astro' } = Astro.props;
30
- ---
31
-
32
- <main>
33
- <svg
34
- class="astro-a"
35
- width="495"
36
- height="623"
37
- viewBox="0 0 495 623"
38
- fill="none"
39
- xmlns="http://www.w3.org/2000/svg"
40
- aria-hidden="true"
41
- >
42
- <path
43
- fill-rule="evenodd"
44
- clip-rule="evenodd"
45
- d="M167.19 364.254C83.4786 364.254 0 404.819 0 404.819C0 404.819 141.781 19.4876 142.087 18.7291C146.434 7.33701 153.027 0 162.289 0H332.441C341.703 0 348.574 7.33701 352.643 18.7291C352.92 19.5022 494.716 404.819 494.716 404.819C494.716 404.819 426.67 364.254 327.525 364.254L264.41 169.408C262.047 159.985 255.147 153.581 247.358 153.581C239.569 153.581 232.669 159.985 230.306 169.408L167.19 364.254ZM160.869 530.172C160.877 530.18 160.885 530.187 160.894 530.195L160.867 530.181C160.868 530.178 160.868 530.175 160.869 530.172ZM136.218 411.348C124.476 450.467 132.698 504.458 160.869 530.172C160.997 529.696 161.125 529.242 161.248 528.804C161.502 527.907 161.737 527.073 161.917 526.233C165.446 509.895 178.754 499.52 195.577 500.01C211.969 500.487 220.67 508.765 223.202 527.254C224.141 534.12 224.23 541.131 224.319 548.105C224.328 548.834 224.337 549.563 224.347 550.291C224.563 566.098 228.657 580.707 237.264 593.914C245.413 606.426 256.108 615.943 270.749 622.478C270.593 621.952 270.463 621.508 270.35 621.126C270.045 620.086 269.872 619.499 269.685 618.911C258.909 585.935 266.668 563.266 295.344 543.933C298.254 541.971 301.187 540.041 304.12 538.112C310.591 533.854 317.059 529.599 323.279 525.007C345.88 508.329 360.09 486.327 363.431 457.844C364.805 446.148 363.781 434.657 359.848 423.275C358.176 424.287 356.587 425.295 355.042 426.275C351.744 428.366 348.647 430.33 345.382 431.934C303.466 452.507 259.152 455.053 214.03 448.245C184.802 443.834 156.584 436.019 136.218 411.348Z"
46
- fill="url(#paint0_linear_1805_24383)"></path>
47
- <defs>
48
- <linearGradient
49
- id="paint0_linear_1805_24383"
50
- x1="247.358"
51
- y1="0"
52
- x2="247.358"
53
- y2="622.479"
54
- gradientUnits="userSpaceOnUse"
55
- >
56
- <stop stop-opacity="0.9"></stop>
57
- <stop offset="1" stop-opacity="0.2"></stop>
58
- </linearGradient>
59
- </defs>
60
- </svg>
61
- <h1>{title}</h1>
62
- <p class="instructions">
63
- To get started, open the directory <code>src/pages</code> in your project.<br />
64
- <strong>Code Challenge:</strong> Tweak the "Welcome to Astro" message above.
65
- </p>
66
- <ul role="list" class="link-card-grid">
67
- {
68
- cards.map((card) => (
69
- <li class="link-card">
70
- <a href={card.href}>
71
- <h2>
72
- {card.title}
73
- <span>&rarr;</span>
74
- </h2>
75
- <p>{card.body}</p>
76
- </a>
77
- </li>
78
- ))
79
- }
80
- </ul>
81
- </main>
82
-
83
- <style>
84
- main {
85
- margin: auto;
86
- padding: 1rem;
87
- width: 800px;
88
- max-width: calc(100% - 2rem);
89
- color: white;
90
- font-size: 20px;
91
- line-height: 1.6;
92
- }
93
- .astro-a {
94
- position: absolute;
95
- top: -32px;
96
- left: 50%;
97
- transform: translatex(-50%);
98
- width: 220px;
99
- height: auto;
100
- z-index: -1;
101
- }
102
- h1 {
103
- font-size: 4rem;
104
- font-weight: 700;
105
- line-height: 1;
106
- text-align: center;
107
- margin-bottom: 1em;
108
- }
109
- .instructions {
110
- margin-bottom: 2rem;
111
- border: 1px solid rgba(var(--accent-light), 25%);
112
- background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%));
113
- padding: 1.5rem;
114
- border-radius: 8px;
115
- }
116
- .instructions code {
117
- font-size: 0.8em;
118
- font-weight: bold;
119
- background: rgba(var(--accent-light), 12%);
120
- color: rgb(var(--accent-light));
121
- border-radius: 4px;
122
- padding: 0.3em 0.4em;
123
- }
124
- .instructions strong {
125
- color: rgb(var(--accent-light));
126
- }
127
- .link-card-grid {
128
- display: grid;
129
- grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
130
- gap: 2rem;
131
- padding: 0;
132
- }
133
-
134
- .link-card {
135
- list-style: none;
136
- display: flex;
137
- padding: 1px;
138
- background-color: #23262d;
139
- background-image: none;
140
- background-size: 400%;
141
- border-radius: 7px;
142
- background-position: 100%;
143
- transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
144
- box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
145
- }
146
- .link-card > a {
147
- width: 100%;
148
- text-decoration: none;
149
- line-height: 1.4;
150
- padding: calc(1.5rem - 1px);
151
- border-radius: 8px;
152
- color: white;
153
- background-color: #23262d;
154
- opacity: 0.8;
155
- }
156
- h2 {
157
- margin: 0;
158
- font-size: 1.25rem;
159
- transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
160
- }
161
- p {
162
- margin-top: 0.5rem;
163
- margin-bottom: 0;
164
- }
165
- .link-card:is(:hover, :focus-within) {
166
- background-position: 0;
167
- background-image: var(--accent-gradient);
168
- }
169
- .link-card:is(:hover, :focus-within) h2 {
170
- color: rgb(var(--accent-light));
171
- }
172
- </style>