astro 5.5.5 → 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.
Files changed (43) hide show
  1. package/client.d.ts +1 -16
  2. package/dist/actions/runtime/utils.d.ts +8 -2
  3. package/dist/assets/runtime.js +5 -29
  4. package/dist/assets/utils/svg.d.ts +1 -4
  5. package/dist/assets/utils/svg.js +2 -2
  6. package/dist/assets/vite-plugin-assets.js +1 -3
  7. package/dist/cli/add/index.js +1 -1
  8. package/dist/container/index.js +1 -1
  9. package/dist/content/content-layer.js +3 -3
  10. package/dist/core/app/index.d.ts +15 -0
  11. package/dist/core/app/index.js +27 -7
  12. package/dist/core/build/index.js +2 -2
  13. package/dist/core/config/index.d.ts +1 -1
  14. package/dist/core/config/schemas/base.d.ts +1110 -0
  15. package/dist/core/config/{schema.js → schemas/base.js} +8 -254
  16. package/dist/core/config/schemas/index.d.ts +3 -0
  17. package/dist/core/config/schemas/index.js +9 -0
  18. package/dist/core/config/schemas/refined.d.ts +3 -0
  19. package/dist/core/config/schemas/refined.js +148 -0
  20. package/dist/core/config/schemas/relative.d.ts +1462 -0
  21. package/dist/core/config/schemas/relative.js +93 -0
  22. package/dist/core/config/validate.d.ts +6 -0
  23. package/dist/core/config/validate.js +9 -3
  24. package/dist/core/constants.js +1 -1
  25. package/dist/core/dev/dev.js +1 -1
  26. package/dist/core/errors/errors-data.d.ts +1 -1
  27. package/dist/core/errors/errors-data.js +1 -1
  28. package/dist/core/messages.js +2 -2
  29. package/dist/core/render-context.js +5 -2
  30. package/dist/core/session.d.ts +8 -0
  31. package/dist/core/session.js +13 -0
  32. package/dist/events/session.js +1 -1
  33. package/dist/i18n/index.d.ts +1 -0
  34. package/dist/i18n/index.js +12 -0
  35. package/dist/i18n/utils.js +7 -11
  36. package/dist/integrations/hooks.d.ts +4 -4
  37. package/dist/integrations/hooks.js +273 -280
  38. package/dist/prefetch/index.d.ts +8 -0
  39. package/dist/prefetch/index.js +6 -4
  40. package/dist/types/public/config.d.ts +3 -25
  41. package/dist/types/public/context.d.ts +1 -1
  42. package/package.json +11 -11
  43. package/dist/core/config/schema.d.ts +0 -3402
@@ -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}
@@ -229,7 +229,7 @@ export interface AstroGlobalPartial {
229
229
  */
230
230
  generator: string;
231
231
  }
232
- interface AstroSharedContext<Props extends Record<string, any> = Record<string, any>, RouteParams extends Record<string, string | undefined> = Record<string, string | undefined>> {
232
+ export interface AstroSharedContext<Props extends Record<string, any> = Record<string, any>, RouteParams extends Record<string, string | undefined> = Record<string, string | undefined>> {
233
233
  /**
234
234
  * The address (usually IP address) of the user.
235
235
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.5.5",
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",
@@ -136,12 +136,12 @@
136
136
  "neotraverse": "^0.6.18",
137
137
  "p-limit": "^6.2.0",
138
138
  "p-queue": "^8.1.0",
139
- "package-manager-detector": "^1.0.0",
139
+ "package-manager-detector": "^1.1.0",
140
140
  "picomatch": "^4.0.2",
141
141
  "prompts": "^2.4.2",
142
142
  "rehype": "^13.0.2",
143
143
  "semver": "^7.7.1",
144
- "shiki": "^3.0.0",
144
+ "shiki": "^3.2.1",
145
145
  "tinyexec": "^0.3.2",
146
146
  "tinyglobby": "^0.2.12",
147
147
  "tsconfck": "^3.1.5",
@@ -149,13 +149,13 @@
149
149
  "unist-util-visit": "^5.0.0",
150
150
  "unstorage": "^1.15.0",
151
151
  "vfile": "^6.0.3",
152
- "vite": "^6.2.3",
152
+ "vite": "^6.2.4",
153
153
  "vitefu": "^1.0.6",
154
154
  "xxhash-wasm": "^1.1.0",
155
155
  "yargs-parser": "^21.1.1",
156
156
  "yocto-spinner": "^0.2.1",
157
157
  "zod": "^3.24.2",
158
- "zod-to-json-schema": "^3.24.3",
158
+ "zod-to-json-schema": "^3.24.5",
159
159
  "zod-to-ts": "^1.2.0",
160
160
  "@astrojs/internal-helpers": "0.6.1",
161
161
  "@astrojs/markdown-remark": "6.3.1",
@@ -166,7 +166,7 @@
166
166
  },
167
167
  "devDependencies": {
168
168
  "@astrojs/check": "^0.9.4",
169
- "@playwright/test": "^1.51.0",
169
+ "@playwright/test": "^1.51.1",
170
170
  "@types/aria-query": "^5.0.4",
171
171
  "@types/common-ancestor-path": "^1.0.2",
172
172
  "@types/cssesc": "^3.0.2",
@@ -179,7 +179,7 @@
179
179
  "@types/js-yaml": "^4.0.9",
180
180
  "@types/picomatch": "^3.0.2",
181
181
  "@types/prompts": "^2.4.9",
182
- "@types/semver": "^7.5.8",
182
+ "@types/semver": "^7.7.0",
183
183
  "@types/yargs-parser": "^21.0.3",
184
184
  "cheerio": "1.0.0",
185
185
  "eol": "^0.10.0",
@@ -194,11 +194,11 @@
194
194
  "rehype-slug": "^6.0.0",
195
195
  "rehype-toc": "^3.0.2",
196
196
  "remark-code-titles": "^0.1.2",
197
- "rollup": "^4.35.0",
198
- "sass": "^1.85.1",
199
- "undici": "^7.4.0",
197
+ "rollup": "^4.37.0",
198
+ "sass": "^1.86.0",
199
+ "undici": "^7.5.0",
200
200
  "unified": "^11.0.5",
201
- "vitest": "^3.0.8",
201
+ "vitest": "^3.0.9",
202
202
  "astro-scripts": "0.0.14"
203
203
  },
204
204
  "engines": {