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
@@ -50,9 +50,8 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
50
50
  (val) => {
51
51
  if (typeof val === "function") {
52
52
  return val({ command: cmd === "dev" ? "dev" : "preview" });
53
- } else {
54
- return val;
55
53
  }
54
+ return val;
56
55
  },
57
56
  // validate
58
57
  z.object({
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.6.1";
1
+ const ASTRO_VERSION = "5.7.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";
@@ -102,7 +102,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
102
102
  exclude: ["astro", "node-fetch"]
103
103
  },
104
104
  plugins: [
105
- astroVirtualManifestPlugin({ settings, logger, manifest }),
105
+ astroVirtualManifestPlugin({ manifest }),
106
106
  configAliasVitePlugin({ settings }),
107
107
  astroLoadFallbackPlugin({ fs, root: settings.config.root }),
108
108
  astroVitePlugin({ settings, logger }),
@@ -125,7 +125,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
125
125
  astroContentAssetPropagationPlugin({ settings }),
126
126
  vitePluginMiddleware({ settings }),
127
127
  vitePluginSSRManifest(),
128
- astroAssetsPlugin({ settings }),
128
+ astroAssetsPlugin({ fs, settings, sync, logger }),
129
129
  astroPrefetch({ settings }),
130
130
  astroTransitions({ settings }),
131
131
  astroDevToolbar({ settings, logger }),
@@ -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.6.1";
25
+ const currentVersion = "5.7.0";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -10,16 +10,6 @@ export interface ErrorData {
10
10
  * @kind heading
11
11
  * @name Astro Errors
12
12
  */
13
- /**
14
- * @docs
15
- * @description
16
- * Cannot use the module `astro:config` without enabling the experimental feature.
17
- */
18
- export declare const CantUseAstroConfigModuleError: {
19
- name: string;
20
- title: string;
21
- message: (moduleName: any) => string;
22
- };
23
13
  /**
24
14
  * @docs
25
15
  * @message
@@ -1163,6 +1153,69 @@ export declare const UnknownFilesystemError: {
1163
1153
  title: string;
1164
1154
  hint: string;
1165
1155
  };
1156
+ /**
1157
+ * @docs
1158
+ * @description
1159
+ * Cannot extract the font type from the given URL.
1160
+ * @message
1161
+ * An error occured while trying to extract the font type from the given URL.
1162
+ */
1163
+ export declare const CannotExtractFontType: {
1164
+ name: string;
1165
+ title: string;
1166
+ message: (url: string) => string;
1167
+ hint: string;
1168
+ };
1169
+ /**
1170
+ * @docs
1171
+ * @description
1172
+ * Cannot fetch the given font file
1173
+ * @message
1174
+ * An error occured while fetching font file from the given URL.
1175
+ */
1176
+ export declare const CannotFetchFontFile: {
1177
+ name: string;
1178
+ title: string;
1179
+ message: (url: string) => string;
1180
+ hint: string;
1181
+ };
1182
+ /**
1183
+ * @docs
1184
+ * @description
1185
+ * Cannot load font provider
1186
+ * @message
1187
+ * Astro is unable to load the given font provider. Open an issue on the corresponding provider's repository.
1188
+ */
1189
+ export declare const CannotLoadFontProvider: {
1190
+ name: string;
1191
+ title: string;
1192
+ message: (entrypoint: string) => string;
1193
+ hint: string;
1194
+ };
1195
+ /**
1196
+ * @docs
1197
+ * @description
1198
+ * Font component is used but experimental fonts have not been registered in the config.
1199
+ */
1200
+ export declare const ExperimentalFontsNotEnabled: {
1201
+ name: string;
1202
+ title: string;
1203
+ message: string;
1204
+ hint: string;
1205
+ };
1206
+ /**
1207
+ * @docs
1208
+ * @description
1209
+ * Font family not found
1210
+ * @message
1211
+ * No data was found for the family passed to the Font component.
1212
+ */
1213
+ export declare const FontFamilyNotFound: {
1214
+ name: string;
1215
+ title: string;
1216
+ message: (family: string) => string;
1217
+ hint: string;
1218
+ };
1166
1219
  /**
1167
1220
  * @docs
1168
1221
  * @kind heading
@@ -1611,26 +1664,27 @@ export declare const ActionsCantBeLoaded: {
1611
1664
  */
1612
1665
  /**
1613
1666
  * @docs
1667
+ * @message Error when initializing session storage with driver `DRIVER`. `ERROR`
1614
1668
  * @see
1615
- * - [Server output adapter feature](https://docs.astro.build/en/reference/adapter-reference/#building-an-adapter)
1669
+ * - [Sessions](https://docs.astro.build/en/guides/sessions/)
1616
1670
  * @description
1617
- * Your adapter must support server output to use sessions.
1671
+ * Thrown when the session storage could not be initialized.
1618
1672
  */
1619
- export declare const SessionWithoutSupportedAdapterOutputError: {
1673
+ export declare const SessionStorageInitError: {
1620
1674
  name: string;
1621
1675
  title: string;
1622
- message: string;
1676
+ message: (error: string, driver?: string) => string;
1623
1677
  hint: string;
1624
1678
  };
1625
1679
  /**
1626
1680
  * @docs
1627
- * @message Error when initializing session storage with driver `DRIVER`. `ERROR`
1681
+ * @message Error when saving session data with driver `DRIVER`. `ERROR`
1628
1682
  * @see
1629
- * - [experimental.session](https://docs.astro.build/en/reference/experimental-flags/sessions/)
1683
+ * - [Sessions](https://docs.astro.build/en/guides/sessions/)
1630
1684
  * @description
1631
- * Thrown when the session storage could not be initialized.
1685
+ * Thrown when the session data could not be saved.
1632
1686
  */
1633
- export declare const SessionStorageInitError: {
1687
+ export declare const SessionStorageSaveError: {
1634
1688
  name: string;
1635
1689
  title: string;
1636
1690
  message: (error: string, driver?: string) => string;
@@ -1638,23 +1692,24 @@ export declare const SessionStorageInitError: {
1638
1692
  };
1639
1693
  /**
1640
1694
  * @docs
1641
- * @message Error when saving session data with driver `DRIVER`. `ERROR`
1642
1695
  * @see
1643
- * - [experimental.session](https://docs.astro.build/en/reference/experimental-flags/sessions/)
1696
+ * - [Sessions](https://docs.astro.build/en/guides/sessions/)
1697
+ * @deprecated This error was removed in Astro 5.7, when the Sessions feature stopped being experimental.
1644
1698
  * @description
1645
- * Thrown when the session data could not be saved.
1699
+ * Your adapter must support server output to use sessions.
1646
1700
  */
1647
- export declare const SessionStorageSaveError: {
1701
+ export declare const SessionWithoutSupportedAdapterOutputError: {
1648
1702
  name: string;
1649
1703
  title: string;
1650
- message: (error: string, driver?: string) => string;
1704
+ message: string;
1651
1705
  hint: string;
1652
1706
  };
1653
1707
  /**
1654
1708
  * @docs
1655
- * @message The `experimental.session` flag was set to `true`, but no storage was configured. Either configure the storage manually or use an adapter that provides session storage
1709
+ * @message The `experimental.session` flag was set to `true`, but no storage was configured. Either configure the storage manually or use an adapter that provides session storage.
1710
+ * @deprecated This error was removed in Astro 5.7, when the Sessions feature stopped being experimental.
1656
1711
  * @see
1657
- * - [experimental.session](https://docs.astro.build/en/reference/experimental-flags/sessions/)
1712
+ * - [Sessions](https://docs.astro.build/en/guides/sessions/)
1658
1713
  * @description
1659
1714
  * Thrown when session storage is enabled but not configured.
1660
1715
  */
@@ -1667,8 +1722,9 @@ export declare const SessionConfigMissingError: {
1667
1722
  /**
1668
1723
  * @docs
1669
1724
  * @message Session config was provided without enabling the `experimental.session` flag
1725
+ * @deprecated This error was removed in Astro 5.7, when the Sessions feature stopped being experimental.
1670
1726
  * @see
1671
- * - [experimental.session](https://docs.astro.build/en/reference/experimental-flags/sessions/)
1727
+ * - [Sessions](https://docs.astro.build/en/guides/sessions/)
1672
1728
  * @description
1673
1729
  * Thrown when session storage is configured but the `experimental.session` flag is not enabled.
1674
1730
  */
@@ -1,8 +1,3 @@
1
- const CantUseAstroConfigModuleError = {
2
- name: "CantUseAstroConfigModuleError",
3
- title: "Cannot use the `astro:config` module without enabling the experimental feature.",
4
- message: (moduleName) => `Cannot import the module "${moduleName}" because the experimental feature is disabled. Enable \`experimental.serializeConfig\` in your \`astro.config.mjs\` `
5
- };
6
1
  const UnknownCompilerError = {
7
2
  name: "UnknownCompilerError",
8
3
  title: "Unknown compiler error.",
@@ -432,6 +427,36 @@ const UnknownFilesystemError = {
432
427
  title: "An unknown error occurred while reading or writing files to disk.",
433
428
  hint: "It can be caused by many things, eg. missing permissions or a file not existing we attempt to read. Check the error cause for more details."
434
429
  };
430
+ const CannotExtractFontType = {
431
+ name: "CannotExtractFontType",
432
+ title: "Cannot extract the font type from the given URL.",
433
+ message: (url) => `An error occurred while trying to extract the font type from ${url}`,
434
+ hint: "Open an issue at https://github.com/withastro/astro/issues."
435
+ };
436
+ const CannotFetchFontFile = {
437
+ name: "CannotFetchFontFile",
438
+ title: "Cannot fetch the given font file.",
439
+ message: (url) => `An error occurred while fetching the font file from ${url}`,
440
+ hint: "This is often caused by connectivity issues. If the error persists, open an issue at https://github.com/withastro/astro/issues."
441
+ };
442
+ const CannotLoadFontProvider = {
443
+ name: "CannotLoadFontProvider",
444
+ title: "Cannot load font provider",
445
+ message: (entrypoint) => `An error occured while loading the "${entrypoint}" provider.`,
446
+ hint: "This is an issue with the font provider. Please open an issue on their repository."
447
+ };
448
+ const ExperimentalFontsNotEnabled = {
449
+ name: "ExperimentalFontsNotEnabled",
450
+ title: "Experimental fonts are not enabled",
451
+ message: "The Font component is used but experimental fonts have not been registered in the config.",
452
+ hint: "Check that you have enabled experimental fonts and also configured your preferred fonts."
453
+ };
454
+ const FontFamilyNotFound = {
455
+ name: "FontFamilyNotFound",
456
+ title: "Font family not found",
457
+ message: (family) => `No data was found for the \`"${family}"\` family passed to the \`<Font>\` component.`,
458
+ hint: "This is often caused by a typo. Check that your Font component is using a `cssVariable` specified in your config."
459
+ };
435
460
  const UnknownCSSError = {
436
461
  name: "UnknownCSSError",
437
462
  title: "Unknown CSS Error."
@@ -638,35 +663,35 @@ const ActionsCantBeLoaded = {
638
663
  title: "Can't load the Astro actions.",
639
664
  message: "An unknown error was thrown while loading the Astro actions file."
640
665
  };
641
- const SessionWithoutSupportedAdapterOutputError = {
642
- name: "SessionWithoutSupportedAdapterOutputError",
643
- title: "Sessions cannot be used with an adapter that doesn't support server output.",
644
- message: 'Sessions require an adapter that supports server output. The adapter must set `"server"` in the `buildOutput` adapter feature.',
645
- hint: 'Ensure your adapter supports `buildOutput: "server"`: https://docs.astro.build/en/reference/adapter-reference/#building-an-adapter'
646
- };
647
666
  const SessionStorageInitError = {
648
667
  name: "SessionStorageInitError",
649
668
  title: "Session storage could not be initialized.",
650
669
  message: (error, driver) => `Error when initializing session storage${driver ? ` with driver \`${driver}\`` : ""}. \`${error ?? ""}\``,
651
- hint: "For more information, see https://docs.astro.build/en/reference/experimental-flags/sessions/"
670
+ hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
652
671
  };
653
672
  const SessionStorageSaveError = {
654
673
  name: "SessionStorageSaveError",
655
674
  title: "Session data could not be saved.",
656
675
  message: (error, driver) => `Error when saving session data${driver ? ` with driver \`${driver}\`` : ""}. \`${error ?? ""}\``,
657
- hint: "For more information, see https://docs.astro.build/en/reference/experimental-flags/sessions/"
676
+ hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
677
+ };
678
+ const SessionWithoutSupportedAdapterOutputError = {
679
+ name: "SessionWithoutSupportedAdapterOutputError",
680
+ title: "Sessions cannot be used with an adapter that doesn't support server output.",
681
+ message: 'Sessions require an adapter that supports server output. The adapter must set `"server"` in the `buildOutput` adapter feature.',
682
+ hint: 'Ensure your adapter supports `buildOutput: "server"`: https://docs.astro.build/en/reference/adapter-reference/#building-an-adapter'
658
683
  };
659
684
  const SessionConfigMissingError = {
660
685
  name: "SessionConfigMissingError",
661
686
  title: "Session storage was enabled but not configured.",
662
687
  message: "The `experimental.session` flag was set to `true`, but no storage was configured. Either configure the storage manually or use an adapter that provides session storage",
663
- hint: "See https://docs.astro.build/en/reference/experimental-flags/sessions/"
688
+ hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
664
689
  };
665
690
  const SessionConfigWithoutFlagError = {
666
691
  name: "SessionConfigWithoutFlagError",
667
692
  title: "Session flag not set",
668
693
  message: "Session config was provided without enabling the `experimental.session` flag",
669
- hint: "See https://docs.astro.build/en/reference/experimental-flags/sessions/"
694
+ hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
670
695
  };
671
696
  export {
672
697
  ActionCalledFromServerError,
@@ -679,8 +704,10 @@ export {
679
704
  AstroGlobUsedOutside,
680
705
  AstroResponseHeadersReassigned,
681
706
  CSSSyntaxError,
707
+ CannotExtractFontType,
708
+ CannotFetchFontFile,
709
+ CannotLoadFontProvider,
682
710
  CantRenderPage,
683
- CantUseAstroConfigModuleError,
684
711
  ClientAddressNotAvailable,
685
712
  ConfigLegacyKey,
686
713
  ConfigNotFound,
@@ -697,9 +724,11 @@ export {
697
724
  ExpectedImage,
698
725
  ExpectedImageOptions,
699
726
  ExpectedNotESMImage,
727
+ ExperimentalFontsNotEnabled,
700
728
  FailedToFetchRemoteImageDimensions,
701
729
  FailedToFindPageMapSSR,
702
730
  FailedToLoadModuleSSR,
731
+ FontFamilyNotFound,
703
732
  ForbiddenRewrite,
704
733
  GenerateContentTypesError,
705
734
  GetEntryDeprecationError,
@@ -7,7 +7,7 @@ export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
7
7
  * rather than specific to a single command, function, use, etc. The label will be
8
8
  * shown in the log message to the user, so it should be relevant.
9
9
  */
10
- export type LoggerLabel = 'add' | 'build' | 'check' | 'config' | 'content' | 'crypto' | 'deprecated' | 'markdown' | 'router' | 'types' | 'vite' | 'watch' | 'middleware' | 'preferences' | 'redirects' | 'sync' | 'toolbar' | 'assets' | 'env' | 'update' | 'adapter' | 'islands' | 'SKIP_FORMAT';
10
+ export type LoggerLabel = 'add' | 'build' | 'check' | 'config' | 'content' | 'crypto' | 'deprecated' | 'markdown' | 'router' | 'types' | 'vite' | 'watch' | 'middleware' | 'preferences' | 'redirects' | 'sync' | 'session' | 'toolbar' | 'assets' | 'env' | 'update' | 'adapter' | 'islands' | 'SKIP_FORMAT';
11
11
  export interface LogOptions {
12
12
  dest: LogWritable<LogMessage>;
13
13
  level: LoggerLevel;
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "5.6.1";
41
+ const version = "5.7.0";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -282,7 +282,7 @@ function printHelp({
282
282
  message.push(
283
283
  linebreak(),
284
284
  ` ${bgGreen(black(` ${commandName} `))} ${green(
285
- `v${"5.6.1"}`
285
+ `v${"5.7.0"}`
286
286
  )} ${headline}`
287
287
  );
288
288
  }
@@ -1,4 +1,4 @@
1
- import { getOutputDirectory } from "../../prerender/utils.js";
1
+ import { getServerOutputDirectory } from "../../prerender/utils.js";
2
2
  import { addRollupInput } from "../build/add-rollup-input.js";
3
3
  import { MIDDLEWARE_PATH_SEGMENT_NAME } from "../constants.js";
4
4
  import { MissingMiddlewareForInternationalization } from "../errors/errors-data.js";
@@ -84,7 +84,7 @@ function vitePluginMiddlewareBuild(opts, internals) {
84
84
  writeBundle(_, bundle) {
85
85
  for (const [chunkName, chunk] of Object.entries(bundle)) {
86
86
  if (chunk.type !== "asset" && chunk.facadeModuleId === MIDDLEWARE_MODULE_ID) {
87
- const outputDirectory = getOutputDirectory(opts.settings);
87
+ const outputDirectory = getServerOutputDirectory(opts.settings);
88
88
  internals.middlewareEntryPoint = new URL(chunkName, outputDirectory);
89
89
  }
90
90
  }
@@ -1,3 +1,4 @@
1
+ import { green } from "kleur/colors";
1
2
  import { getActionContext } from "../actions/runtime/virtual/server.js";
2
3
  import { deserializeActionResult } from "../actions/runtime/virtual/shared.js";
3
4
  import { createCallAction, createGetActionResult, hasActionPayload } from "../actions/utils.js";
@@ -30,7 +31,7 @@ import { copyRequest, getOriginPathname, setOriginPathname } from "./routing/rew
30
31
  import { AstroSession } from "./session.js";
31
32
  const apiContextRoutesSymbol = Symbol.for("context.routes");
32
33
  class RenderContext {
33
- constructor(pipeline, locals, middleware, actions, pathname, request, routeData, status, clientAddress, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url), props = {}, partial = void 0, session = pipeline.manifest.sessionConfig ? new AstroSession(cookies, pipeline.manifest.sessionConfig) : void 0) {
34
+ constructor(pipeline, locals, middleware, actions, pathname, request, routeData, status, clientAddress, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url), props = {}, partial = void 0, session = pipeline.manifest.sessionConfig ? new AstroSession(cookies, pipeline.manifest.sessionConfig, pipeline.runtimeMode) : void 0) {
34
35
  this.pipeline = pipeline;
35
36
  this.locals = locals;
36
37
  this.middleware = middleware;
@@ -268,7 +269,7 @@ class RenderContext {
268
269
  }
269
270
  createActionAPIContext() {
270
271
  const renderContext = this;
271
- const { cookies, params, pipeline, url, session } = this;
272
+ const { cookies, params, pipeline, url } = this;
272
273
  const generator = `Astro v${ASTRO_VERSION}`;
273
274
  const rewrite = async (reroutePayload) => {
274
275
  return await this.#executeRewrite(reroutePayload);
@@ -304,7 +305,23 @@ class RenderContext {
304
305
  get originPathname() {
305
306
  return getOriginPathname(renderContext.request);
306
307
  },
307
- session
308
+ get session() {
309
+ if (this.isPrerendered) {
310
+ pipeline.logger.warn(
311
+ "session",
312
+ `context.session was used when rendering the route ${green(this.routePattern)}, but it is not available on prerendered routes. If you need access to sessions, make sure that the route is server-rendered using \`export const prerender = false;\` or by setting \`output\` to \`"server"\` in your Astro config to make all your routes server-rendered by default. For more information, see https://docs.astro.build/en/guides/sessions/`
313
+ );
314
+ return void 0;
315
+ }
316
+ if (!renderContext.session) {
317
+ pipeline.logger.warn(
318
+ "session",
319
+ `context.session was used when rendering the route ${green(this.routePattern)}, but no storage configuration was provided. Either configure the storage manually or use an adapter that provides session storage. For more information, see https://docs.astro.build/en/guides/sessions/`
320
+ );
321
+ return void 0;
322
+ }
323
+ return renderContext.session;
324
+ }
308
325
  };
309
326
  }
310
327
  async createResult(mod, ctx) {
@@ -357,6 +374,7 @@ class RenderContext {
357
374
  hasRenderedHead: false,
358
375
  renderedScripts: /* @__PURE__ */ new Set(),
359
376
  hasDirectives: /* @__PURE__ */ new Set(),
377
+ hasRenderedServerIslandRuntime: false,
360
378
  headInTree: false,
361
379
  extraHead: [],
362
380
  propagators: /* @__PURE__ */ new Set()
@@ -410,7 +428,7 @@ class RenderContext {
410
428
  }
411
429
  createAstroPagePartial(result, astroStaticPartial, apiContext) {
412
430
  const renderContext = this;
413
- const { cookies, locals, params, pipeline, url, session } = this;
431
+ const { cookies, locals, params, pipeline, url } = this;
414
432
  const { response } = result;
415
433
  const redirect = (path, status = 302) => {
416
434
  if (this.request[responseSentSymbol]) {
@@ -430,7 +448,23 @@ class RenderContext {
430
448
  routePattern: this.routeData.route,
431
449
  isPrerendered: this.routeData.prerender,
432
450
  cookies,
433
- session,
451
+ get session() {
452
+ if (this.isPrerendered) {
453
+ pipeline.logger.warn(
454
+ "session",
455
+ `Astro.session was used when rendering the route ${green(this.routePattern)}, but it is not available on prerendered pages. If you need access to sessions, 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 by default. For more information, see https://docs.astro.build/en/guides/sessions/`
456
+ );
457
+ return void 0;
458
+ }
459
+ if (!renderContext.session) {
460
+ pipeline.logger.warn(
461
+ "session",
462
+ `Astro.session was used when rendering the route ${green(this.routePattern)}, but no storage configuration was provided. Either configure the storage manually or use an adapter that provides session storage. For more information, see https://docs.astro.build/en/guides/sessions/`
463
+ );
464
+ return void 0;
465
+ }
466
+ return renderContext.session;
467
+ },
434
468
  get clientAddress() {
435
469
  return renderContext.getClientAddress();
436
470
  },
@@ -27,17 +27,26 @@ function findRouteToRewrite({
27
27
  }
28
28
  let pathname = newUrl.pathname;
29
29
  const shouldAppendSlash = shouldAppendForwardSlash(trailingSlash, buildFormat);
30
- if (base !== "/" && newUrl.pathname.startsWith(base)) {
31
- pathname = shouldAppendSlash ? appendForwardSlash(newUrl.pathname) : removeTrailingForwardSlash(newUrl.pathname);
32
- pathname = pathname.slice(base.length);
30
+ if (base !== "/") {
31
+ const isBasePathRequest = newUrl.pathname === base || newUrl.pathname === removeTrailingForwardSlash(base);
32
+ if (isBasePathRequest) {
33
+ pathname = shouldAppendSlash ? "/" : "";
34
+ } else if (newUrl.pathname.startsWith(base)) {
35
+ pathname = shouldAppendSlash ? appendForwardSlash(newUrl.pathname) : removeTrailingForwardSlash(newUrl.pathname);
36
+ pathname = pathname.slice(base.length);
37
+ }
33
38
  }
34
39
  if (!pathname.startsWith("/") && shouldAppendSlash && newUrl.pathname.endsWith("/")) {
35
40
  pathname = prependForwardSlash(pathname);
36
41
  }
37
- if (pathname === "/" && base !== "/" && !shouldAppendSlash) {
42
+ if (pathname === "/" && !shouldAppendSlash) {
38
43
  pathname = "";
39
44
  }
40
- newUrl.pathname = joinPaths(...[base, pathname].filter(Boolean));
45
+ if (base !== "/" && (pathname === "" || pathname === "/") && !shouldAppendSlash) {
46
+ newUrl.pathname = removeTrailingForwardSlash(base);
47
+ } else {
48
+ newUrl.pathname = joinPaths(...[base, pathname].filter(Boolean));
49
+ }
41
50
  const decodedPathname = decodeURI(pathname);
42
51
  let foundRoute;
43
52
  for (const route of routes) {
@@ -1,10 +1,9 @@
1
- import type { AstroSettings } from '../types/astro.js';
2
- import type { ResolvedSessionConfig, SessionDriverName } from '../types/public/config.js';
1
+ import type { ResolvedSessionConfig, RuntimeMode, SessionDriverName } from '../types/public/config.js';
3
2
  import type { AstroCookies } from './cookies/cookies.js';
4
3
  export declare const PERSIST_SYMBOL: unique symbol;
5
4
  export declare class AstroSession<TDriver extends SessionDriverName = any> {
6
5
  #private;
7
- constructor(cookies: AstroCookies, { cookie: cookieConfig, ...config }: Exclude<ResolvedSessionConfig<TDriver>, undefined>);
6
+ constructor(cookies: AstroCookies, { cookie: cookieConfig, ...config }: Exclude<ResolvedSessionConfig<TDriver>, undefined>, runtimeMode?: RuntimeMode);
8
7
  /**
9
8
  * Gets a session value. Returns `undefined` if the session or value does not exist.
10
9
  */
@@ -55,4 +54,3 @@ export declare class AstroSession<TDriver extends SessionDriverName = any> {
55
54
  load(sessionID: string): Promise<void>;
56
55
  }
57
56
  export declare function resolveSessionDriver(driver: string | undefined): Promise<string | null>;
58
- export declare function validateSessionConfig(settings: AstroSettings): void;
@@ -3,13 +3,7 @@ import {
3
3
  builtinDrivers,
4
4
  createStorage
5
5
  } from "unstorage";
6
- import {
7
- SessionConfigMissingError,
8
- SessionConfigWithoutFlagError,
9
- SessionStorageInitError,
10
- SessionStorageSaveError,
11
- SessionWithoutSupportedAdapterOutputError
12
- } from "./errors/errors-data.js";
6
+ import { SessionStorageInitError, SessionStorageSaveError } from "./errors/errors-data.js";
13
7
  import { AstroError } from "./errors/index.js";
14
8
  const PERSIST_SYMBOL = Symbol();
15
9
  const DEFAULT_COOKIE_NAME = "astro-session";
@@ -57,7 +51,7 @@ class AstroSession {
57
51
  constructor(cookies, {
58
52
  cookie: cookieConfig = DEFAULT_COOKIE_NAME,
59
53
  ...config
60
- }) {
54
+ }, runtimeMode) {
61
55
  this.#cookies = cookies;
62
56
  let cookieConfigObject;
63
57
  if (typeof cookieConfig === "object") {
@@ -69,7 +63,7 @@ class AstroSession {
69
63
  }
70
64
  this.#cookieConfig = {
71
65
  sameSite: "lax",
72
- secure: true,
66
+ secure: runtimeMode === "production",
73
67
  path: "/",
74
68
  ...cookieConfigObject,
75
69
  httpOnly: true
@@ -414,27 +408,8 @@ async function resolveSessionDriver(driver) {
414
408
  }
415
409
  return driver;
416
410
  }
417
- function validateSessionConfig(settings) {
418
- const { experimental, session } = settings.config;
419
- const { buildOutput } = settings;
420
- let error;
421
- if (experimental.session) {
422
- if (!session?.driver) {
423
- error = new AstroError(SessionConfigMissingError);
424
- } else if (buildOutput === "static") {
425
- error = new AstroError(SessionWithoutSupportedAdapterOutputError);
426
- }
427
- } else if (session?.driver) {
428
- error = new AstroError(SessionConfigWithoutFlagError);
429
- }
430
- if (error) {
431
- error.stack = void 0;
432
- throw error;
433
- }
434
- }
435
411
  export {
436
412
  AstroSession,
437
413
  PERSIST_SYMBOL,
438
- resolveSessionDriver,
439
- validateSessionConfig
414
+ resolveSessionDriver
440
415
  };
@@ -4,6 +4,7 @@ import { performance } from "node:perf_hooks";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { dim } from "kleur/colors";
6
6
  import { createServer } from "vite";
7
+ import { syncFonts } from "../../assets/fonts/sync.js";
7
8
  import { CONTENT_TYPES_FILE } from "../../content/consts.js";
8
9
  import { getDataStoreFile, globalContentLayer } from "../../content/content-layer.js";
9
10
  import { createContentTypesGenerator } from "../../content/index.js";
@@ -124,6 +125,7 @@ async function syncInternal({
124
125
  }
125
126
  }
126
127
  syncAstroEnv(settings);
128
+ syncFonts(settings);
127
129
  writeInjectedTypes(settings, fs);
128
130
  logger.info("types", `Generated ${dim(getTimeStat(timerStart, performance.now()))}`);
129
131
  }
@@ -17,10 +17,10 @@ declare const StringSchema: z.ZodObject<{
17
17
  endsWith?: string | undefined;
18
18
  startsWith?: string | undefined;
19
19
  default?: string | undefined;
20
- url?: boolean | undefined;
21
20
  optional?: boolean | undefined;
22
21
  max?: number | undefined;
23
22
  min?: number | undefined;
23
+ url?: boolean | undefined;
24
24
  }, {
25
25
  type: "string";
26
26
  length?: number | undefined;
@@ -28,10 +28,10 @@ declare const StringSchema: z.ZodObject<{
28
28
  endsWith?: string | undefined;
29
29
  startsWith?: string | undefined;
30
30
  default?: string | undefined;
31
- url?: boolean | undefined;
32
31
  optional?: boolean | undefined;
33
32
  max?: number | undefined;
34
33
  min?: number | undefined;
34
+ url?: boolean | undefined;
35
35
  }>;
36
36
  export type StringSchema = z.infer<typeof StringSchema>;
37
37
  declare const NumberSchema: z.ZodObject<{
@@ -111,10 +111,10 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
111
111
  endsWith?: string | undefined;
112
112
  startsWith?: string | undefined;
113
113
  default?: string | undefined;
114
- url?: boolean | undefined;
115
114
  optional?: boolean | undefined;
116
115
  max?: number | undefined;
117
116
  min?: number | undefined;
117
+ url?: boolean | undefined;
118
118
  }, {
119
119
  type: "string";
120
120
  length?: number | undefined;
@@ -122,10 +122,10 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
122
122
  endsWith?: string | undefined;
123
123
  startsWith?: string | undefined;
124
124
  default?: string | undefined;
125
- url?: boolean | undefined;
126
125
  optional?: boolean | undefined;
127
126
  max?: number | undefined;
128
127
  min?: number | undefined;
128
+ url?: boolean | undefined;
129
129
  }>, z.ZodObject<{
130
130
  type: z.ZodLiteral<"number">;
131
131
  optional: z.ZodOptional<z.ZodBoolean>;
@@ -283,10 +283,10 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
283
283
  endsWith?: string | undefined;
284
284
  startsWith?: string | undefined;
285
285
  default?: string | undefined;
286
- url?: boolean | undefined;
287
286
  optional?: boolean | undefined;
288
287
  max?: number | undefined;
289
288
  min?: number | undefined;
289
+ url?: boolean | undefined;
290
290
  }, {
291
291
  type: "string";
292
292
  length?: number | undefined;
@@ -294,10 +294,10 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
294
294
  endsWith?: string | undefined;
295
295
  startsWith?: string | undefined;
296
296
  default?: string | undefined;
297
- url?: boolean | undefined;
298
297
  optional?: boolean | undefined;
299
298
  max?: number | undefined;
300
299
  min?: number | undefined;
300
+ url?: boolean | undefined;
301
301
  }>, z.ZodObject<{
302
302
  type: z.ZodLiteral<"number">;
303
303
  optional: z.ZodOptional<z.ZodBoolean>;