astro 5.5.6 → 5.6.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.
@@ -23,6 +23,14 @@ export interface PrefetchOptions {
23
23
  * Should prefetch even on data saver mode or slow connection. (default `false`)
24
24
  */
25
25
  ignoreSlowConnection?: boolean;
26
+ /**
27
+ * A string providing a hint to the browser as to how eagerly it should prefetch/prerender link targets in order to balance performance advantages against resource overheads. (default `immediate`)
28
+ * Only works if `clientPrerender` is enabled and browser supports Speculation Rules API.
29
+ * The browser takes this hint into consideration along with its own heuristics, so it may select a link that the author has hinted as less eager than another, if the less eager candidate is considered a better choice.
30
+ *
31
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/speculationrules#eagerness
32
+ */
33
+ eagerness?: 'immediate' | 'eager' | 'moderate' | 'conservative';
26
34
  }
27
35
  /**
28
36
  * Prefetch a URL so it's cached when the user navigates to it.
@@ -125,7 +125,7 @@ function prefetch(url, opts) {
125
125
  prefetchedUrls.add(url);
126
126
  if (clientPrerender && HTMLScriptElement.supports?.("speculationrules")) {
127
127
  debug?.(`[astro] Prefetching ${url} with <script type="speculationrules">`);
128
- appendSpeculationRules(url);
128
+ appendSpeculationRules(url, opts?.eagerness ?? "immediate");
129
129
  } else if (document.createElement("link").relList?.supports?.("prefetch") && opts?.with !== "fetch") {
130
130
  debug?.(`[astro] Prefetching ${url} with <link rel="prefetch">`);
131
131
  const link = document.createElement("link");
@@ -182,14 +182,15 @@ function onPageLoad(cb) {
182
182
  cb();
183
183
  });
184
184
  }
185
- function appendSpeculationRules(url) {
185
+ function appendSpeculationRules(url, eagerness) {
186
186
  const script = document.createElement("script");
187
187
  script.type = "speculationrules";
188
188
  script.textContent = JSON.stringify({
189
189
  prerender: [
190
190
  {
191
191
  source: "list",
192
- urls: [url]
192
+ urls: [url],
193
+ eagerness
193
194
  }
194
195
  ],
195
196
  // Currently, adding `prefetch` is required to fallback if `prerender` fails.
@@ -198,7 +199,8 @@ function appendSpeculationRules(url) {
198
199
  prefetch: [
199
200
  {
200
201
  source: "list",
201
- urls: [url]
202
+ urls: [url],
203
+ eagerness
202
204
  }
203
205
  ]
204
206
  });
@@ -4,9 +4,8 @@ import type { RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig, SyntaxHig
4
4
  import type { BuiltinDriverName, BuiltinDriverOptions, Driver, Storage } from 'unstorage';
5
5
  import type { UserConfig as OriginalViteUserConfig, SSROptions as ViteSSROptions } from 'vite';
6
6
  import type { ImageFit, ImageLayout } from '../../assets/types.js';
7
- import type { SvgRenderMode } from '../../assets/utils/svg.js';
8
7
  import type { AssetsPrefix } from '../../core/app/types.js';
9
- import type { AstroConfigType } from '../../core/config/schema.js';
8
+ import type { AstroConfigType } from '../../core/config/schemas/index.js';
10
9
  import type { REDIRECT_STATUS_CODES } from '../../core/constants.js';
11
10
  import type { AstroCookieSetOptions } from '../../core/cookies/cookies.js';
12
11
  import type { LoggerLevel } from '../../core/logger/core.js';
@@ -1978,7 +1977,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1978
1977
  /**
1979
1978
  *
1980
1979
  * @name experimental.svg
1981
- * @type {boolean|object}
1980
+ * @type {boolean}
1982
1981
  * @default `undefined`
1983
1982
  * @version 5.x
1984
1983
  * @description
@@ -2009,28 +2008,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
2009
2008
  * For a complete overview, and to give feedback on this experimental API,
2010
2009
  * see the [Feature RFC](https://github.com/withastro/roadmap/pull/1035).
2011
2010
  */
2012
- svg?: boolean | {
2013
- /**
2014
- *
2015
- * @name experimental.svg.mode
2016
- * @type {string}
2017
- * @default 'inline'
2018
- *
2019
- * The default technique for handling imported SVG files. Astro will inline the SVG content into your HTML output if not specified.
2020
- *
2021
- * - `inline`: Astro will inline the SVG content into your HTML output.
2022
- * - `sprite`: Astro will generate a sprite sheet with all imported SVG files.
2023
- *
2024
- * ```astro
2025
- * ---
2026
- * import Logo from './path/to/svg/file.svg';
2027
- * ---
2028
- *
2029
- * <Logo size={24} mode="sprite" />
2030
- * ```
2031
- */
2032
- mode: SvgRenderMode;
2033
- };
2011
+ svg?: boolean;
2034
2012
  /**
2035
2013
  * @name experimental.serializeConfig
2036
2014
  * @type {boolean}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.5.6",
3
+ "version": "5.6.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",