astro 5.6.1 → 5.7.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 (94) hide show
  1. package/client.d.ts +3 -0
  2. package/components/Font.astro +32 -0
  3. package/dist/actions/plugins.js +2 -2
  4. package/dist/assets/fonts/config.d.ts +378 -0
  5. package/dist/assets/fonts/config.js +157 -0
  6. package/dist/assets/fonts/constants.d.ts +15 -0
  7. package/dist/assets/fonts/constants.js +41 -0
  8. package/dist/assets/fonts/load.d.ts +20 -0
  9. package/dist/assets/fonts/load.js +133 -0
  10. package/dist/assets/fonts/metrics.d.ts +10 -0
  11. package/dist/assets/fonts/metrics.js +84 -0
  12. package/dist/assets/fonts/providers/entrypoints/adobe.d.ts +2 -0
  13. package/dist/assets/fonts/providers/entrypoints/adobe.js +5 -0
  14. package/dist/assets/fonts/providers/entrypoints/bunny.d.ts +1 -0
  15. package/dist/assets/fonts/providers/entrypoints/bunny.js +5 -0
  16. package/dist/assets/fonts/providers/entrypoints/fontshare.d.ts +1 -0
  17. package/dist/assets/fonts/providers/entrypoints/fontshare.js +5 -0
  18. package/dist/assets/fonts/providers/entrypoints/fontsource.d.ts +1 -0
  19. package/dist/assets/fonts/providers/entrypoints/fontsource.js +5 -0
  20. package/dist/assets/fonts/providers/entrypoints/google.d.ts +2 -0
  21. package/dist/assets/fonts/providers/entrypoints/google.js +5 -0
  22. package/dist/assets/fonts/providers/index.d.ts +48 -0
  23. package/dist/assets/fonts/providers/index.js +40 -0
  24. package/dist/assets/fonts/providers/local.d.ts +10 -0
  25. package/dist/assets/fonts/providers/local.js +30 -0
  26. package/dist/assets/fonts/providers/utils.d.ts +9 -0
  27. package/dist/assets/fonts/providers/utils.js +37 -0
  28. package/dist/assets/fonts/sync.d.ts +2 -0
  29. package/dist/assets/fonts/sync.js +17 -0
  30. package/dist/assets/fonts/types.d.ts +45 -0
  31. package/dist/assets/fonts/types.js +0 -0
  32. package/dist/assets/fonts/utils.d.ts +95 -0
  33. package/dist/assets/fonts/utils.js +215 -0
  34. package/dist/assets/fonts/vite-plugin-fonts.d.ts +10 -0
  35. package/dist/assets/fonts/vite-plugin-fonts.js +217 -0
  36. package/dist/assets/utils/index.d.ts +5 -1
  37. package/dist/assets/utils/index.js +5 -1
  38. package/dist/assets/utils/node/emitAsset.d.ts +12 -2
  39. package/dist/assets/utils/node/emitAsset.js +46 -4
  40. package/dist/assets/utils/vendor/image-size/types/index.d.ts +2 -2
  41. package/dist/assets/vite-plugin-assets.d.ts +9 -2
  42. package/dist/assets/vite-plugin-assets.js +9 -6
  43. package/dist/cli/add/index.js +3 -1
  44. package/dist/cli/install-package.js +3 -0
  45. package/dist/config/entrypoint.d.ts +2 -0
  46. package/dist/config/entrypoint.js +3 -0
  47. package/dist/config/index.d.ts +2 -1
  48. package/dist/content/content-layer.js +5 -4
  49. package/dist/content/runtime-assets.js +1 -0
  50. package/dist/content/utils.d.ts +10 -10
  51. package/dist/content/vite-plugin-content-imports.js +4 -2
  52. package/dist/core/build/generate.js +2 -2
  53. package/dist/core/build/pipeline.js +2 -2
  54. package/dist/core/build/plugins/plugin-prerender.js +0 -3
  55. package/dist/core/build/static-build.js +2 -2
  56. package/dist/core/config/schemas/base.d.ts +446 -49
  57. package/dist/core/config/schemas/base.js +3 -7
  58. package/dist/core/config/schemas/refined.js +12 -0
  59. package/dist/core/config/schemas/relative.d.ts +581 -77
  60. package/dist/core/config/schemas/relative.js +1 -2
  61. package/dist/core/constants.js +1 -1
  62. package/dist/core/create-vite.js +2 -2
  63. package/dist/core/dev/dev.js +1 -1
  64. package/dist/core/errors/errors-data.d.ts +82 -26
  65. package/dist/core/errors/errors-data.js +45 -16
  66. package/dist/core/logger/core.d.ts +1 -1
  67. package/dist/core/messages.js +2 -2
  68. package/dist/core/middleware/vite-plugin.js +2 -2
  69. package/dist/core/render-context.js +39 -5
  70. package/dist/core/routing/rewrite.js +14 -5
  71. package/dist/core/session.d.ts +2 -4
  72. package/dist/core/session.js +4 -29
  73. package/dist/core/sync/index.js +2 -0
  74. package/dist/env/schema.d.ts +6 -6
  75. package/dist/integrations/hooks.js +2 -3
  76. package/dist/manifest/virtual-module.d.ts +1 -5
  77. package/dist/manifest/virtual-module.js +1 -18
  78. package/dist/prerender/utils.d.ts +5 -1
  79. package/dist/prerender/utils.js +8 -8
  80. package/dist/runtime/client/dev-toolbar/apps/audit/annotations.d.ts +6 -0
  81. package/dist/runtime/client/dev-toolbar/apps/audit/annotations.js +27 -0
  82. package/dist/runtime/client/dev-toolbar/apps/audit/index.js +10 -4
  83. package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.js +2 -2
  84. package/dist/runtime/server/render/common.js +8 -0
  85. package/dist/runtime/server/render/instruction.d.ts +5 -5
  86. package/dist/runtime/server/render/server-islands.d.ts +1 -0
  87. package/dist/runtime/server/render/server-islands.js +29 -31
  88. package/dist/transitions/swap-functions.d.ts +1 -1
  89. package/dist/transitions/swap-functions.js +7 -6
  90. package/dist/types/public/config.d.ts +155 -98
  91. package/dist/types/public/internal.d.ts +1 -0
  92. package/dist/vite-plugin-astro-server/plugin.js +1 -1
  93. package/package.json +9 -5
  94. package/types/fonts.d.ts +4 -0
@@ -3,6 +3,7 @@ import type { RemotePattern } from '@astrojs/internal-helpers/remote';
3
3
  import type { RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig, SyntaxHighlightConfigType } from '@astrojs/markdown-remark';
4
4
  import type { BuiltinDriverName, BuiltinDriverOptions, Driver, Storage } from 'unstorage';
5
5
  import type { UserConfig as OriginalViteUserConfig, SSROptions as ViteSSROptions } from 'vite';
6
+ import type { AstroFontProvider, FontFamily } from '../../assets/fonts/types.js';
6
7
  import type { ImageFit, ImageLayout } from '../../assets/types.js';
7
8
  import type { AssetsPrefix } from '../../core/app/types.js';
8
9
  import type { AstroConfigType } from '../../core/config/schemas/index.js';
@@ -15,6 +16,7 @@ export type Locales = (string | {
15
16
  codes: [string, ...string[]];
16
17
  path: string;
17
18
  })[];
19
+ export type { AstroFontProvider as FontProvider };
18
20
  type NormalizeLocales<T extends Locales> = {
19
21
  [K in keyof T]: T[K] extends string ? T[K] : T[K] extends {
20
22
  codes: Array<string>;
@@ -142,7 +144,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
142
144
  * Docs: https://docs.astro.build/reference/configuration-reference/
143
145
  *
144
146
  * Generics do not follow semver and may change at any time.
145
- */ export interface AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never> {
147
+ */ export interface AstroUserConfig<TLocales extends Locales = never, TSession extends SessionDriverName = never, TFontFamilies extends FontFamily[] = never> {
146
148
  /**
147
149
  * @docs
148
150
  * @kind heading
@@ -251,7 +253,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
251
253
  * '/news': {
252
254
  * status: 302,
253
255
  * destination: 'https://example.com/news'
254
- * },
256
+ * },
255
257
  * // '/product1/', '/product1' // Note, this is not supported
256
258
  * }
257
259
  * })
@@ -516,35 +518,6 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
516
518
  */
517
519
  checkOrigin?: boolean;
518
520
  };
519
- /**
520
- * @docs
521
- * @name session
522
- * @type {SessionConfig}
523
- * @version 5.3.0
524
- * @description
525
- *
526
- * Configures experimental session support by specifying a storage `driver` as well as any associated `options`.
527
- * You must enable the `experimental.session` flag to use this feature.
528
- * Some adapters may provide a default session driver, but you can override it with your own configuration.
529
- *
530
- * You can specify [any driver from Unstorage](https://unstorage.unjs.io/drivers) or provide a custom config which will override your adapter's default.
531
- *
532
- * See [the experimental session guide](https://docs.astro.build/en/reference/experimental-flags/sessions/) for more information.
533
- *
534
- * ```js title="astro.config.mjs"
535
- * {
536
- * session: {
537
- * // Required: the name of the Unstorage driver
538
- * driver: 'redis',
539
- * // The required options depend on the driver
540
- * options: {
541
- * url: process.env.REDIS_URL,
542
- * },
543
- * }
544
- * }
545
- * ```
546
- */
547
- session?: SessionConfig<TSession>;
548
521
  /**
549
522
  * @docs
550
523
  * @name vite
@@ -893,6 +866,146 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
893
866
  server?: ServerConfig | ((options: {
894
867
  command: 'dev' | 'preview';
895
868
  }) => ServerConfig);
869
+ /**
870
+ * @docs
871
+ * @kind heading
872
+ * @version 5.7.0
873
+ * @name Session Options
874
+ * @description
875
+ *
876
+ * Configures session storage for your Astro project. This is used to store session data in a persistent way, so that it can be accessed across different requests.
877
+ * Some adapters may provide a default session driver, but you can override it with your own configuration.
878
+ *
879
+ * See [the sessions guide](https://docs.astro.build/en/guides/sessions/) for more information.
880
+ *
881
+ * ```js title="astro.config.mjs"
882
+ * {
883
+ * session: {
884
+ * // The name of the Unstorage driver
885
+ * driver: 'redis',
886
+ * // The required options depend on the driver
887
+ * options: {
888
+ * url: process.env.REDIS_URL,
889
+ * },
890
+ * ttl: 3600, // 1 hour
891
+ * }
892
+ * }
893
+ * ```
894
+ */
895
+ session?: SessionConfig<TSession>;
896
+ /**
897
+ * @docs
898
+ * @name session.driver
899
+ * @type {string | undefined}
900
+ * @version 5.7.0
901
+ * @description
902
+ *
903
+ * The Unstorage driver to use for session storage. The [Node](https://docs.astro.build/en/guides/integrations-guide/node/#sessions),
904
+ * [Cloudflare](https://docs.astro.build/en/guides/integrations-guide/cloudflare/#sessions), and
905
+ * [Netlify](/en/guides/integrations-guide/netlify/#sessions) adapters automatically configure a default driver for you,
906
+ * but you can specify your own if you would prefer or if you are using an adapter that does not provide one.
907
+ *
908
+ * The value is the "Driver name" from the [Unstorage driver documentation](https://unstorage.unjs.io/drivers).
909
+ *
910
+ * ```js title="astro.config.mjs" ins={4}
911
+ * {
912
+ * adapter: vercel(),
913
+ * session: {
914
+ * driver: "redis",
915
+ * },
916
+ * }
917
+ * ```
918
+ * :::note
919
+ * Some drivers may need extra packages to be installed. Some drivers may also require environment variables or credentials to be set. See the [Unstorage documentation](https://unstorage.unjs.io/drivers) for more information.
920
+ * :::
921
+ *
922
+ */
923
+ /**
924
+ * @docs
925
+ * @name session.options
926
+ * @type {Record<string, unknown> | undefined}
927
+ * @version 5.7.0
928
+ * @default `{}`
929
+ * @description
930
+ *
931
+ * The driver-specific options to use for session storage. The options depend on the driver you are using. See the [Unstorage documentation](https://unstorage.unjs.io/drivers)
932
+ * for more information on the options available for each driver.
933
+ *
934
+ * ```js title="astro.config.mjs" ins={4-6}
935
+ * {
936
+ * session: {
937
+ * driver: "redis",
938
+ * options: {
939
+ * url: process.env.REDIS_URL
940
+ * },
941
+ * }
942
+ * }
943
+ * ```
944
+ */
945
+ /**
946
+ * @docs
947
+ * @name session.cookie
948
+ * @type {string | AstroCookieSetOptions | undefined}
949
+ * @version 5.7.0
950
+ * @default `{ name: "astro-session", sameSite: "lax", httpOnly: true, secure: true }`
951
+ * @description
952
+ *
953
+ * The session cookie configuration. If set to a string, it will be used as the cookie name.
954
+ * Alternatively, you can pass an object with additional options. These will be merged with the defaults.
955
+ *
956
+ * ```js title="astro.config.mjs" ins={3-4}
957
+ * {
958
+ * session: {
959
+ * // If set to a string, it will be used as the cookie name.
960
+ * cookie: "my-session-cookie",
961
+ * }
962
+ * }
963
+ *
964
+ * ```
965
+ *
966
+ * ```js title="astro.config.mjs" ins={4-8}
967
+ * {
968
+ * session: {
969
+ * // If set to an object, it will be used as the cookie options.
970
+ * cookie: {
971
+ * name: "my-session-cookie",
972
+ * sameSite: "lax",
973
+ * secure: true,
974
+ * }
975
+ * }
976
+ * }
977
+ * ```
978
+ */
979
+ /**
980
+ * @docs
981
+ * @name session.ttl
982
+ * @version 5.7.0
983
+ * @type {number | undefined}
984
+ * @default {Infinity}
985
+ * @description
986
+ *
987
+ * An optional default time-to-live expiration period for session values, in seconds.
988
+ *
989
+ * By default, session values persist until they are deleted or the session is destroyed, and do not automatically expire because a particular amount of time has passed.
990
+ * Set `session.ttl` to add a default expiration period for your session values. Passing a `ttl` option to [`session.set()`](https://docs.astro.build/en/reference/api-reference/#set) will override the global default
991
+ * for that individual entry.
992
+ *
993
+ * ```js title="astro.config.mjs" ins={3-4}
994
+ * {
995
+ * session: {
996
+ * // Set a default expiration period of 1 hour (3600 seconds)
997
+ * ttl: 3600,
998
+ * }
999
+ * }
1000
+ * ```
1001
+ * :::note
1002
+ * Setting a value for `ttl` does not automatically delete the value from storage after the time limit has passed.
1003
+ *
1004
+ * Values from storage will only be deleted when there is an attempt to access them after the `ttl` period has expired. At this time, the session value will be undefined and only then will the value be deleted.
1005
+ *
1006
+ * Individual drivers may also support a `ttl` option that will automatically delete sessions after the specified time. See your chosen driver's documentation for more information.
1007
+ * :::
1008
+ */
896
1009
  /**
897
1010
  * @docs
898
1011
  * @kind heading
@@ -1844,7 +1957,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1844
1957
  *
1845
1958
  * ```js title=astro.config.mjs
1846
1959
  * {
1847
- * experimental: {
1960
+ * experimental: {
1848
1961
  * responsiveImages: true,
1849
1962
  * },
1850
1963
  * }
@@ -1950,77 +2063,22 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
1950
2063
  responsiveImages?: boolean;
1951
2064
  /**
1952
2065
  *
1953
- * @name experimental.session
1954
- * @type {boolean}
1955
- * @default `false`
1956
- * @version 5.0.0
1957
- * @description
1958
- *
1959
- * Enables support for sessions in Astro. Sessions are used to store user data across requests, such as user authentication state.
1960
- *
1961
- * When enabled you can access the `Astro.session` object to read and write data that persists across requests. You can configure the session driver using the [`session` option](#session), or use the default provided by your adapter.
1962
- *
1963
- * ```astro title=src/components/CartButton.astro
1964
- * ---
1965
- * export const prerender = false; // Not needed in 'server' mode
1966
- * const cart = await Astro.session.get('cart');
1967
- * ---
1968
- *
1969
- * <a href="/checkout">🛒 {cart?.length ?? 0} items</a>
1970
- *
1971
- * ```
1972
- *
1973
- * For more details, see [the experimental session guide](https://docs.astro.build/en/reference/experimental-flags/sessions/).
1974
- *
1975
- */
1976
- session?: boolean;
1977
- /**
1978
- *
1979
- * @name experimental.svg
1980
- * @type {boolean}
1981
- * @default `undefined`
1982
- * @version 5.x
2066
+ * @name experimental.fonts
2067
+ * @type {FontFamily[]}
2068
+ * @version 5.7
1983
2069
  * @description
1984
2070
  *
1985
- * This feature allows you to import SVG files directly into your Astro project. By default, Astro will inline the SVG content into your HTML output.
1986
- *
1987
- * To enable this feature, set `experimental.svg` to `true` in your Astro config:
1988
- *
1989
- * ```js
1990
- * {
1991
- * experimental: {
1992
- * svg: true,
1993
- * },
1994
- * }
1995
- * ```
1996
- *
1997
- * To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component.
1998
- * Astro also provides a `size` attribute to set equal `height` and `width` properties:
2071
+ * This experimental feature allows you to use fonts from your filesystem and various providers
2072
+ * (eg. Google, Fontsource, Bunny...) through a unified, fully customizable and type-safe API.
1999
2073
  *
2000
- * ```astro
2001
- * ---
2002
- * import Logo from './path/to/svg/file.svg';
2003
- * ---
2004
- *
2005
- * <Logo size={24} />
2006
- * ```
2074
+ * Web fonts can impact page performance at both load time and rendering time. This feature provides
2075
+ * automatic [optimization](https://web.dev/learn/performance/optimize-web-fonts) by creating
2076
+ * preload links and optimized fallbacks. This API includes opinionated defaults to keep your sites lightweight and performant (e.g. minimal font files downloaded) while allowing for extensive customization so you can opt in to greater control.
2007
2077
  *
2008
2078
  * For a complete overview, and to give feedback on this experimental API,
2009
- * see the [Feature RFC](https://github.com/withastro/roadmap/pull/1035).
2010
- */
2011
- svg?: boolean;
2012
- /**
2013
- * @name experimental.serializeConfig
2014
- * @type {boolean}
2015
- * @default `false`
2016
- * @version 5.x
2017
- * @description
2018
- *
2019
- * Enables the use of the experimental virtual modules `astro:config/server` and `astro:config/client`.
2020
- *
2021
- * These two virtual modules contain a serializable subset of the Astro configuration.
2079
+ * see the [Fonts RFC](https://github.com/withastro/roadmap/pull/1039).
2022
2080
  */
2023
- serializeConfig?: boolean;
2081
+ fonts?: [TFontFamilies] extends [never] ? FontFamily[] : TFontFamilies;
2024
2082
  /**
2025
2083
  * @name experimental.headingIdCompat
2026
2084
  * @type {boolean}
@@ -2133,4 +2191,3 @@ declare global {
2133
2191
  type Database = Record<string, any>;
2134
2192
  }
2135
2193
  }
2136
- export {};
@@ -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>;
@@ -163,7 +163,7 @@ function createDevelopmentManifest(settings) {
163
163
  onRequest: NOOP_MIDDLEWARE_FN
164
164
  };
165
165
  },
166
- sessionConfig: settings.config.experimental.session ? settings.config.session : void 0
166
+ sessionConfig: settings.config.session
167
167
  };
168
168
  }
169
169
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.6.1",
3
+ "version": "5.7.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",
@@ -65,6 +65,7 @@
65
65
  "./assets/endpoint/*": "./dist/assets/endpoint/*.js",
66
66
  "./assets/services/sharp": "./dist/assets/services/sharp.js",
67
67
  "./assets/services/noop": "./dist/assets/services/noop.js",
68
+ "./assets/fonts/providers/*": "./dist/assets/fonts/providers/entrypoints/*.js",
68
69
  "./loaders": "./dist/content/loaders/index.js",
69
70
  "./content/runtime": "./dist/content/runtime.js",
70
71
  "./content/runtime-assets": "./dist/content/runtime-assets.js",
@@ -104,6 +105,8 @@
104
105
  ],
105
106
  "dependencies": {
106
107
  "@astrojs/compiler": "^2.11.0",
108
+ "@capsizecss/metrics": "^3.5.0",
109
+ "@capsizecss/unpack": "^2.4.0",
107
110
  "@oslojs/encoding": "^1.1.0",
108
111
  "@rollup/pluginutils": "^5.1.4",
109
112
  "acorn": "^8.14.1",
@@ -146,10 +149,11 @@
146
149
  "tinyglobby": "^0.2.12",
147
150
  "tsconfck": "^3.1.5",
148
151
  "ultrahtml": "^1.6.0",
152
+ "unifont": "^0.1.7",
149
153
  "unist-util-visit": "^5.0.0",
150
154
  "unstorage": "^1.15.0",
151
155
  "vfile": "^6.0.3",
152
- "vite": "^6.2.4",
156
+ "vite": "^6.2.6",
153
157
  "vitefu": "^1.0.6",
154
158
  "xxhash-wasm": "^1.1.0",
155
159
  "yargs-parser": "^21.1.1",
@@ -157,9 +161,9 @@
157
161
  "zod": "^3.24.2",
158
162
  "zod-to-json-schema": "^3.24.5",
159
163
  "zod-to-ts": "^1.2.0",
164
+ "@astrojs/internal-helpers": "0.6.1",
160
165
  "@astrojs/markdown-remark": "6.3.1",
161
- "@astrojs/telemetry": "3.2.0",
162
- "@astrojs/internal-helpers": "0.6.1"
166
+ "@astrojs/telemetry": "3.2.0"
163
167
  },
164
168
  "optionalDependencies": {
165
169
  "sharp": "^0.33.3"
@@ -224,7 +228,7 @@
224
228
  "test:e2e:match": "playwright test -g",
225
229
  "test:e2e:chrome": "playwright test",
226
230
  "test:e2e:firefox": "playwright test --config playwright.firefox.config.js",
227
- "test:types": "tsc --project tsconfig.tests.json",
231
+ "test:types": "tsc --project test/types/tsconfig.json",
228
232
  "test:unit": "astro-scripts test \"test/units/**/*.test.js\" --teardown ./test/units/teardown.js",
229
233
  "test:integration": "astro-scripts test \"test/*.test.js\""
230
234
  }
@@ -0,0 +1,4 @@
1
+ declare module 'astro:assets' {
2
+ /** @internal Run `astro dev` or `astro sync` to generate high fidelity types */
3
+ export type FontFamily = string;
4
+ }