astro 5.15.4 → 6.0.0-alpha.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 (107) hide show
  1. package/{astro.js → bin/astro.mjs} +7 -8
  2. package/client.d.ts +2 -4
  3. package/components/ClientRouter.astro +0 -5
  4. package/dist/actions/runtime/utils.d.ts +2 -8
  5. package/dist/assets/build/remote.js +4 -14
  6. package/dist/assets/fonts/implementations/font-metrics-resolver.js +15 -9
  7. package/dist/assets/services/sharp.js +5 -6
  8. package/dist/assets/utils/index.d.ts +1 -5
  9. package/dist/assets/utils/index.js +1 -5
  10. package/dist/assets/utils/node/emitAsset.d.ts +0 -14
  11. package/dist/assets/utils/node/emitAsset.js +0 -50
  12. package/dist/assets/vite-plugin-assets.js +3 -8
  13. package/dist/cli/add/index.js +0 -2
  14. package/dist/cli/db/index.js +0 -2
  15. package/dist/cli/info/index.js +0 -2
  16. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  17. package/dist/cli/preferences/index.js +0 -2
  18. package/dist/config/index.js +3 -12
  19. package/dist/container/index.d.ts +0 -1
  20. package/dist/container/index.js +0 -1
  21. package/dist/content/config.js +17 -13
  22. package/dist/content/content-layer.js +4 -6
  23. package/dist/content/data-store.d.ts +0 -2
  24. package/dist/content/loaders/glob.d.ts +0 -5
  25. package/dist/content/loaders/glob.js +3 -30
  26. package/dist/content/mutable-data-store.js +1 -14
  27. package/dist/content/runtime-assets.d.ts +1 -1
  28. package/dist/content/runtime-assets.js +3 -6
  29. package/dist/content/runtime.d.ts +19 -58
  30. package/dist/content/runtime.js +52 -218
  31. package/dist/content/server-listeners.js +25 -88
  32. package/dist/content/types-generator.d.ts +1 -6
  33. package/dist/content/types-generator.js +20 -116
  34. package/dist/content/utils.d.ts +31 -104
  35. package/dist/content/utils.js +48 -158
  36. package/dist/content/vite-plugin-content-imports.js +0 -4
  37. package/dist/content/vite-plugin-content-virtual-mod.js +3 -134
  38. package/dist/core/app/index.d.ts +1 -1
  39. package/dist/core/app/index.js +7 -10
  40. package/dist/core/app/node.d.ts +2 -8
  41. package/dist/core/app/node.js +4 -6
  42. package/dist/core/build/generate.js +0 -1
  43. package/dist/core/build/index.js +1 -4
  44. package/dist/core/build/internal.d.ts +1 -2
  45. package/dist/core/build/internal.js +0 -1
  46. package/dist/core/build/plugins/plugin-manifest.js +2 -4
  47. package/dist/core/compile/compile.js +0 -2
  48. package/dist/core/config/schemas/base.d.ts +4 -40
  49. package/dist/core/config/schemas/base.js +3 -16
  50. package/dist/core/config/schemas/refined.js +7 -0
  51. package/dist/core/config/schemas/relative.d.ts +5 -47
  52. package/dist/core/constants.d.ts +1 -0
  53. package/dist/core/constants.js +3 -1
  54. package/dist/core/create-vite.js +1 -4
  55. package/dist/core/dev/container.js +0 -2
  56. package/dist/core/dev/dev.js +1 -1
  57. package/dist/core/errors/dev/vite.js +1 -18
  58. package/dist/core/errors/errors-data.d.ts +68 -50
  59. package/dist/core/errors/errors-data.js +30 -24
  60. package/dist/core/errors/overlay.js +1 -1
  61. package/dist/core/messages.js +2 -2
  62. package/dist/core/middleware/index.d.ts +1 -1
  63. package/dist/core/middleware/index.js +5 -9
  64. package/dist/core/preview/index.js +0 -2
  65. package/dist/core/render/params-and-props.js +0 -1
  66. package/dist/core/render/route-cache.d.ts +1 -2
  67. package/dist/core/render/route-cache.js +1 -2
  68. package/dist/core/render-context.d.ts +3 -3
  69. package/dist/core/render-context.js +13 -27
  70. package/dist/core/routing/manifest/create.js +1 -1
  71. package/dist/core/routing/params.js +5 -6
  72. package/dist/core/routing/validation.d.ts +1 -2
  73. package/dist/core/routing/validation.js +2 -18
  74. package/dist/core/server-islands/endpoint.d.ts +1 -2
  75. package/dist/core/server-islands/endpoint.js +0 -1
  76. package/dist/core/sync/index.js +2 -10
  77. package/dist/env/env-loader.d.ts +0 -1
  78. package/dist/env/env-loader.js +4 -17
  79. package/dist/env/vite-plugin-env.js +41 -45
  80. package/dist/i18n/index.js +0 -3
  81. package/dist/integrations/hooks.d.ts +1 -2
  82. package/dist/integrations/hooks.js +0 -27
  83. package/dist/prefetch/index.d.ts +0 -10
  84. package/dist/prefetch/index.js +1 -1
  85. package/dist/runtime/server/astro-global.d.ts +2 -2
  86. package/dist/runtime/server/astro-global.js +86 -24
  87. package/dist/transitions/vite-plugin-transitions.js +1 -4
  88. package/dist/types/astro.d.ts +2 -2
  89. package/dist/types/public/common.d.ts +1 -3
  90. package/dist/types/public/config.d.ts +4 -127
  91. package/dist/types/public/context.d.ts +18 -39
  92. package/dist/types/public/integrations.d.ts +0 -17
  93. package/dist/types/public/internal.d.ts +2 -2
  94. package/dist/virtual-modules/live-config.d.ts +0 -2
  95. package/dist/virtual-modules/live-config.js +0 -4
  96. package/dist/vite-plugin-markdown/index.js +0 -1
  97. package/package.json +8 -11
  98. package/templates/content/module.mjs +8 -63
  99. package/templates/content/types.d.ts +10 -69
  100. package/dist/config/vite-plugin-content-listen.d.ts +0 -17
  101. package/dist/config/vite-plugin-content-listen.js +0 -26
  102. package/dist/container/polyfill.d.ts +0 -1
  103. package/dist/container/polyfill.js +0 -2
  104. package/dist/core/polyfill.d.ts +0 -5
  105. package/dist/core/polyfill.js +0 -17
  106. package/dist/vite-plugin-astro-postprocess/index.d.ts +0 -2
  107. package/dist/vite-plugin-astro-postprocess/index.js +0 -48
@@ -282,8 +282,9 @@ export declare const GetStaticPathsExpectedParams: {
282
282
  * export async function getStaticPaths() {
283
283
  * return [
284
284
  * { params: { id: '1' } } // Works
285
- * { params: { id: 2 } } // Works
285
+ * { params: { id: 2 } } // Does not work
286
286
  * { params: { id: false } } // Does not work
287
+ * { params: { id: [1, 2] } } // Does not work
287
288
  * ];
288
289
  * }
289
290
  * ---
@@ -295,8 +296,8 @@ export declare const GetStaticPathsExpectedParams: {
295
296
  * ---
296
297
  * export async function getStaticPaths() {
297
298
  * return [
298
- * { params: { id: 1 } } // /route/1
299
- * { params: { id: 2 } } // /route/2
299
+ * { params: { id: '1' } } // /route/1
300
+ * { params: { id: '2' } } // /route/2
300
301
  * { params: { id: undefined } } // /route/
301
302
  * ];
302
303
  * }
@@ -306,7 +307,7 @@ export declare const GetStaticPathsExpectedParams: {
306
307
  export declare const GetStaticPathsInvalidRouteParam: {
307
308
  name: string;
308
309
  title: string;
309
- message: (key: string, value: any, valueType: any) => string;
310
+ message: (key: string, value: any, valueType: string) => string;
310
311
  hint: string;
311
312
  };
312
313
  /**
@@ -850,6 +851,7 @@ export declare const LocalImageUsedWrongly: {
850
851
  * - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob)
851
852
  * @description
852
853
  * `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vite.dev/guide/features.html#glob-import) instead to achieve the same result.
854
+ * @deprecated This error was removed in Astro v6.0.0 along with the removal of `Astro.glob()`.
853
855
  */
854
856
  export declare const AstroGlobUsedOutside: {
855
857
  name: string;
@@ -863,6 +865,7 @@ export declare const AstroGlobUsedOutside: {
863
865
  * - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob)
864
866
  * @description
865
867
  * `Astro.glob()` did not return any matching files. There might be a typo in the glob pattern.
868
+ * @deprecated This error was removed in Astro v6.0.0 along with the removal of `Astro.glob()`.
866
869
  */
867
870
  export declare const AstroGlobNoMatch: {
868
871
  name: string;
@@ -965,6 +968,7 @@ export declare const FailedToLoadModuleSSR: {
965
968
  * - [Glob Patterns](https://docs.astro.build/en/guides/imports/#glob-patterns)
966
969
  * @description
967
970
  * Astro encountered an invalid glob pattern. This is often caused by the glob pattern not being a valid file path.
971
+ * @deprecated This error was removed in Astro v6.0.0 along with the removal of `Astro.glob()`.
968
972
  */
969
973
  export declare const InvalidGlob: {
970
974
  name: string;
@@ -1259,6 +1263,18 @@ export declare const CspNotEnabled: {
1259
1263
  title: string;
1260
1264
  message: string;
1261
1265
  };
1266
+ /**
1267
+ * @docs
1268
+ * @description
1269
+ * Unavailable Astro global in getStaticPaths
1270
+ * @message
1271
+ * The Astro global is not available in getStaticPaths().
1272
+ */
1273
+ export declare const UnavailableAstroGlobal: {
1274
+ name: string;
1275
+ title: string;
1276
+ message: (name: string) => string;
1277
+ };
1262
1278
  /**
1263
1279
  * @docs
1264
1280
  * @kind heading
@@ -1441,7 +1457,7 @@ export declare const RenderUndefinedEntryError: {
1441
1457
  /**
1442
1458
  * @docs
1443
1459
  * @description
1444
- * The `getDataEntryById` and `getEntryBySlug` functions are deprecated and cannot be used with content layer collections. Use the `getEntry` function instead.
1460
+ * The `getDataEntryById` and `getEntryBySlug` functions are deprecated and cannot be used with content collections. Use the `getEntry` function instead.
1445
1461
  */
1446
1462
  export declare const GetEntryDeprecationError: {
1447
1463
  name: string;
@@ -1461,6 +1477,7 @@ export declare const GetEntryDeprecationError: {
1461
1477
  * Make sure that all required fields are present, and that all fields are of the correct type.
1462
1478
  * You can check against the collection schema in your `src/content.config.*` file.
1463
1479
  * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information.
1480
+ * @deprecated This error only applies to legacy content collections which were removed in Astro 6.
1464
1481
  */
1465
1482
  export declare const InvalidContentEntryFrontmatterError: {
1466
1483
  name: string;
@@ -1472,7 +1489,7 @@ export declare const InvalidContentEntryFrontmatterError: {
1472
1489
  * @docs
1473
1490
  * @message
1474
1491
  * **Example error message:**<br/>
1475
- * **blog** → **post** frontmatter does not match collection schema.<br/>
1492
+ * **blog** → **post** data does not match collection schema.<br/>
1476
1493
  * "title" is required.<br/>
1477
1494
  * "date" must be a valid date.
1478
1495
  * @description
@@ -1487,6 +1504,51 @@ export declare const InvalidContentEntryDataError: {
1487
1504
  message(collection: string, entryId: string, error: ZodError): string;
1488
1505
  hint: string;
1489
1506
  };
1507
+ /**
1508
+ * @docs
1509
+ * @message
1510
+ * **Example error message:**<br/>
1511
+ * Found legacy content config file in "src/content/config.ts". Please move this file to "src/content.config.ts" and ensure each collection has a loader defined.<br/>
1512
+ * @description
1513
+ * A legacy content config file was found. Move the file to `src/content.config.ts` and update any collection definitions if needed.
1514
+ * See the [Astro 6 migration guide](https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections) for more information.
1515
+ */
1516
+ export declare const LegacyContentConfigError: {
1517
+ name: string;
1518
+ title: string;
1519
+ message: (filename: string) => string;
1520
+ hint: string;
1521
+ };
1522
+ /**
1523
+ * @docs
1524
+ * @message
1525
+ * **Example error message:**<br/>
1526
+ * Collections must have a `loader` defined. Check your collection definitions in your content config file.<br/>
1527
+ * @description
1528
+ * A content collection is missing a `loader` definition. Make sure that each collection in your content config file has a `loader`.
1529
+ * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information.
1530
+ */
1531
+ export declare const ContentCollectionMissingLoader: {
1532
+ name: string;
1533
+ title: string;
1534
+ message: (file?: any) => string;
1535
+ hint: string;
1536
+ };
1537
+ /**
1538
+ * @docs
1539
+ * @message
1540
+ * **Example error message:**<br/>
1541
+ * Invalid collection type "data". Remove the type from your collection definition in your content config file.
1542
+ * @description
1543
+ * Content collections should no longer have a `type` field. Remove this field from your content config file.
1544
+ * See the [Astro 6 migration guide](https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections) for more information.
1545
+ */
1546
+ export declare const ContentCollectionInvalidType: {
1547
+ name: string;
1548
+ title: string;
1549
+ message: (type: string, file?: any) => string;
1550
+ hint: string;
1551
+ };
1490
1552
  /**
1491
1553
  * @docs
1492
1554
  * @message
@@ -1774,47 +1836,3 @@ export declare const SessionStorageSaveError: {
1774
1836
  message: (error: string, driver?: string) => string;
1775
1837
  hint: string;
1776
1838
  };
1777
- /**
1778
- * @docs
1779
- * @see
1780
- * - [Sessions](https://docs.astro.build/en/guides/sessions/)
1781
- * @deprecated This error was removed in Astro 5.7, when the Sessions feature stopped being experimental.
1782
- * @description
1783
- * Your adapter must support server output to use sessions.
1784
- */
1785
- export declare const SessionWithoutSupportedAdapterOutputError: {
1786
- name: string;
1787
- title: string;
1788
- message: string;
1789
- hint: string;
1790
- };
1791
- /**
1792
- * @docs
1793
- * @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.
1794
- * @deprecated This error was removed in Astro 5.7, when the Sessions feature stopped being experimental.
1795
- * @see
1796
- * - [Sessions](https://docs.astro.build/en/guides/sessions/)
1797
- * @description
1798
- * Thrown when session storage is enabled but not configured.
1799
- */
1800
- export declare const SessionConfigMissingError: {
1801
- name: string;
1802
- title: string;
1803
- message: string;
1804
- hint: string;
1805
- };
1806
- /**
1807
- * @docs
1808
- * @message Session config was provided without enabling the `experimental.session` flag
1809
- * @deprecated This error was removed in Astro 5.7, when the Sessions feature stopped being experimental.
1810
- * @see
1811
- * - [Sessions](https://docs.astro.build/en/guides/sessions/)
1812
- * @description
1813
- * Thrown when session storage is configured but the `experimental.session` flag is not enabled.
1814
- */
1815
- export declare const SessionConfigWithoutFlagError: {
1816
- name: string;
1817
- title: string;
1818
- message: string;
1819
- hint: string;
1820
- };
@@ -85,8 +85,8 @@ const GetStaticPathsExpectedParams = {
85
85
  };
86
86
  const GetStaticPathsInvalidRouteParam = {
87
87
  name: "GetStaticPathsInvalidRouteParam",
88
- title: "Invalid value for `getStaticPaths` route parameter.",
89
- message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
88
+ title: "Invalid route parameter returned by `getStaticPaths()`.",
89
+ message: (key, value, valueType) => `Invalid \`getStaticPaths()\` route parameter for \`${key}\`. Expected a string or undefined, received \`${valueType}\` (\`${value}\`)`,
90
90
  hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
91
91
  };
92
92
  const GetStaticPathsRequired = {
@@ -475,6 +475,11 @@ const CspNotEnabled = {
475
475
  title: "CSP feature isn't enabled",
476
476
  message: "The `experimental.csp` configuration isn't enabled."
477
477
  };
478
+ const UnavailableAstroGlobal = {
479
+ name: "UnavailableAstroGlobal",
480
+ title: "Unavailable Astro global in getStaticPaths()",
481
+ message: (name) => `The Astro global is not available in this scope. Please remove "Astro.${name}" from your getStaticPaths() function.`
482
+ };
478
483
  const UnknownCSSError = {
479
484
  name: "UnknownCSSError",
480
485
  title: "Unknown CSS Error."
@@ -541,7 +546,7 @@ const GetEntryDeprecationError = {
541
546
  name: "GetEntryDeprecationError",
542
547
  title: "Invalid use of `getDataEntryById` or `getEntryBySlug` function.",
543
548
  message: (collection, method) => `The \`${method}\` function is deprecated and cannot be used to query the "${collection}" collection. Use \`getEntry\` instead.`,
544
- hint: "Use the `getEntry` or `getCollection` functions to query content layer collections."
549
+ hint: "See https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections for more information."
545
550
  };
546
551
  const InvalidContentEntryFrontmatterError = {
547
552
  name: "InvalidContentEntryFrontmatterError",
@@ -569,6 +574,24 @@ const InvalidContentEntryDataError = {
569
574
  },
570
575
  hint: "See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas."
571
576
  };
577
+ const LegacyContentConfigError = {
578
+ name: "LegacyContentConfigError",
579
+ title: "Legacy content config file found.",
580
+ message: (filename) => `Found legacy content config file in "${filename}". Please move this file to "src/content.config.${filename.split(".").at(-1)}" and ensure each collection has a loader defined.`,
581
+ hint: "See https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections for more information on updating collections."
582
+ };
583
+ const ContentCollectionMissingLoader = {
584
+ name: "ContentCollectionMissingLoader",
585
+ title: "Content collection is missing a `loader` definition.",
586
+ message: (file = "your content config file") => `Collections must have a \`loader\` defined. Check your collection definitions in ${file}.`,
587
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more information on content loaders and https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections for more information on migrating from legacy collections."
588
+ };
589
+ const ContentCollectionInvalidType = {
590
+ name: "ContentCollectionInvalidType",
591
+ title: "Content collection has an invalid `type` field.",
592
+ message: (type, file = "your content config file") => `Invalid collection type "${type}". Remove the type from your collection definition in ${file}.`,
593
+ hint: "See https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections for more information on migrating from legacy collections."
594
+ };
572
595
  const ContentLoaderReturnsInvalidId = {
573
596
  name: "ContentLoaderReturnsInvalidId",
574
597
  title: "Content loader returned an entry with an invalid `id`.",
@@ -714,24 +737,6 @@ const SessionStorageSaveError = {
714
737
  message: (error, driver) => `Error when saving session data${driver ? ` with driver \`${driver}\`` : ""}. \`${error ?? ""}\``,
715
738
  hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
716
739
  };
717
- const SessionWithoutSupportedAdapterOutputError = {
718
- name: "SessionWithoutSupportedAdapterOutputError",
719
- title: "Sessions cannot be used with an adapter that doesn't support server output.",
720
- message: 'Sessions require an adapter that supports server output. The adapter must set `"server"` in the `buildOutput` adapter feature.',
721
- hint: 'Ensure your adapter supports `buildOutput: "server"`: https://docs.astro.build/en/reference/adapter-reference/#building-an-adapter'
722
- };
723
- const SessionConfigMissingError = {
724
- name: "SessionConfigMissingError",
725
- title: "Session storage was enabled but not configured.",
726
- 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",
727
- hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
728
- };
729
- const SessionConfigWithoutFlagError = {
730
- name: "SessionConfigWithoutFlagError",
731
- title: "Session flag not set",
732
- message: "Session config was provided without enabling the `experimental.session` flag",
733
- hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
734
- };
735
740
  export {
736
741
  ActionCalledFromServerError,
737
742
  ActionNotFoundError,
@@ -751,6 +756,8 @@ export {
751
756
  ClientAddressNotAvailable,
752
757
  ConfigLegacyKey,
753
758
  ConfigNotFound,
759
+ ContentCollectionInvalidType,
760
+ ContentCollectionMissingLoader,
754
761
  ContentCollectionTypeMismatchError,
755
762
  ContentEntryDataError,
756
763
  ContentLoaderInvalidDataError,
@@ -794,6 +801,7 @@ export {
794
801
  InvalidGlob,
795
802
  InvalidImageService,
796
803
  InvalidPrerenderExport,
804
+ LegacyContentConfigError,
797
805
  LiveContentConfigError,
798
806
  LocalImageUsedWrongly,
799
807
  LocalsNotAnObject,
@@ -831,12 +839,10 @@ export {
831
839
  RewriteWithBodyUsed,
832
840
  RouteNotFound,
833
841
  ServerOnlyModule,
834
- SessionConfigMissingError,
835
- SessionConfigWithoutFlagError,
836
842
  SessionStorageInitError,
837
843
  SessionStorageSaveError,
838
- SessionWithoutSupportedAdapterOutputError,
839
844
  StaticClientAddressNotAvailable,
845
+ UnavailableAstroGlobal,
840
846
  UnhandledRejection,
841
847
  UnknownCLIError,
842
848
  UnknownCSSError,
@@ -754,7 +754,7 @@ function getOverlayCode() {
754
754
  `;
755
755
  }
756
756
  function patchOverlay(code) {
757
- return code.replace("class ErrorOverlay", getOverlayCode() + "\nclass ViteErrorOverlay");
757
+ return code.replace("var ErrorOverlay", getOverlayCode() + "\nvar ViteErrorOverlay");
758
758
  }
759
759
  export {
760
760
  patchOverlay
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "5.15.4";
41
+ const version = "6.0.0-alpha.0";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -275,7 +275,7 @@ function printHelp({
275
275
  message.push(
276
276
  linebreak(),
277
277
  ` ${bgGreen(black(` ${commandName} `))} ${green(
278
- `v${"5.15.4"}`
278
+ `v${"6.0.0-alpha.0"}`
279
279
  )} ${headline}`
280
280
  );
281
281
  }
@@ -25,7 +25,7 @@ export type CreateContext = {
25
25
  /**
26
26
  * Initial value of the locals
27
27
  */
28
- locals: App.Locals;
28
+ locals?: App.Locals;
29
29
  };
30
30
  /**
31
31
  * Creates a context to be passed to Astro middleware `onRequest` function.
@@ -4,7 +4,7 @@ import {
4
4
  computePreferredLocale,
5
5
  computePreferredLocaleList
6
6
  } from "../../i18n/utils.js";
7
- import { ASTRO_VERSION, clientLocalsSymbol } from "../constants.js";
7
+ import { ASTRO_GENERATOR } from "../constants.js";
8
8
  import { AstroCookies } from "../cookies/index.js";
9
9
  import { AstroError, AstroErrorData } from "../errors/index.js";
10
10
  import { getClientIpAddress } from "../routing/request.js";
@@ -18,7 +18,7 @@ function createContext({
18
18
  params = {},
19
19
  userDefinedLocales = [],
20
20
  defaultLocale = "",
21
- locals
21
+ locals = {}
22
22
  }) {
23
23
  let preferredLocale = void 0;
24
24
  let preferredLocaleList = void 0;
@@ -34,7 +34,7 @@ function createContext({
34
34
  request,
35
35
  params,
36
36
  site: void 0,
37
- generator: `Astro v${ASTRO_VERSION}`,
37
+ generator: ASTRO_GENERATOR,
38
38
  props: {},
39
39
  rewrite,
40
40
  routePattern: "",
@@ -71,14 +71,10 @@ function createContext({
71
71
  return clientIpAddress;
72
72
  },
73
73
  get locals() {
74
- let _locals = locals ?? Reflect.get(request, clientLocalsSymbol);
75
- if (locals === void 0) {
76
- _locals = {};
77
- }
78
- if (typeof _locals !== "object") {
74
+ if (typeof locals !== "object") {
79
75
  throw new AstroError(AstroErrorData.LocalsNotAnObject);
80
76
  }
81
- return _locals;
77
+ return locals;
82
78
  },
83
79
  set locals(_) {
84
80
  throw new AstroError(AstroErrorData.LocalsReassigned);
@@ -8,13 +8,11 @@ import { runHookConfigDone, runHookConfigSetup } from "../../integrations/hooks.
8
8
  import { resolveConfig } from "../config/config.js";
9
9
  import { createNodeLogger } from "../config/logging.js";
10
10
  import { createSettings } from "../config/settings.js";
11
- import { apply as applyPolyfills } from "../polyfill.js";
12
11
  import { createRoutesList } from "../routing/index.js";
13
12
  import { ensureProcessNodeEnv } from "../util.js";
14
13
  import createStaticPreviewServer from "./static-preview-server.js";
15
14
  import { getResolvedHostForHttpServer } from "./util.js";
16
15
  async function preview(inlineConfig) {
17
- applyPolyfills();
18
16
  ensureProcessNodeEnv("production");
19
17
  const logger = createNodeLogger(inlineConfig);
20
18
  const { userConfig, astroConfig } = await resolveConfig(inlineConfig ?? {}, "preview");
@@ -15,7 +15,6 @@ async function getProps(opts) {
15
15
  mod,
16
16
  route,
17
17
  routeCache,
18
- logger,
19
18
  ssr: serverLike,
20
19
  base
21
20
  });
@@ -7,11 +7,10 @@ interface CallGetStaticPathsOptions {
7
7
  mod: ComponentInstance | undefined;
8
8
  route: RouteData;
9
9
  routeCache: RouteCache;
10
- logger: Logger;
11
10
  ssr: boolean;
12
11
  base: AstroConfig['base'];
13
12
  }
14
- export declare function callGetStaticPaths({ mod, route, routeCache, logger, ssr, base, }: CallGetStaticPathsOptions): Promise<GetStaticPathsResultKeyed>;
13
+ export declare function callGetStaticPaths({ mod, route, routeCache, ssr, base, }: CallGetStaticPathsOptions): Promise<GetStaticPathsResultKeyed>;
15
14
  interface RouteCacheEntry {
16
15
  staticPaths: GetStaticPathsResultKeyed;
17
16
  }
@@ -5,7 +5,6 @@ async function callGetStaticPaths({
5
5
  mod,
6
6
  route,
7
7
  routeCache,
8
- logger,
9
8
  ssr,
10
9
  base
11
10
  }) {
@@ -32,7 +31,7 @@ async function callGetStaticPaths({
32
31
  paginate: generatePaginateFunction(route, base),
33
32
  routePattern: route.route
34
33
  });
35
- validateGetStaticPathsResult(staticPaths, logger, route);
34
+ validateGetStaticPathsResult(staticPaths, route);
36
35
  const keyedStaticPaths = staticPaths;
37
36
  keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
38
37
  for (const sp of keyedStaticPaths) {
@@ -1,7 +1,7 @@
1
1
  import type { ActionAPIContext } from '../actions/runtime/utils.js';
2
2
  import type { ComponentInstance } from '../types/astro.js';
3
3
  import type { MiddlewareHandler, Props } from '../types/public/common.js';
4
- import type { APIContext, AstroGlobal, AstroGlobalPartial } from '../types/public/context.js';
4
+ import type { APIContext, AstroGlobal } from '../types/public/context.js';
5
5
  import type { RouteData, SSRResult } from '../types/public/internal.js';
6
6
  import type { SSRActions } from './app/types.js';
7
7
  import { AstroCookies } from './cookies/index.js';
@@ -64,8 +64,8 @@ export declare class RenderContext {
64
64
  *
65
65
  * The page level partial is used as the prototype of the user-visible `Astro` global object, which is instantiated once per use of a component.
66
66
  */
67
- createAstro(result: SSRResult, astroStaticPartial: AstroGlobalPartial, props: Record<string, any>, slotValues: Record<string, any> | null, apiContext: ActionAPIContext): AstroGlobal;
68
- createAstroPagePartial(result: SSRResult, astroStaticPartial: AstroGlobalPartial, apiContext: ActionAPIContext): Omit<AstroGlobal, 'props' | 'self' | 'slots'>;
67
+ createAstro(result: SSRResult, props: Record<string, any>, slotValues: Record<string, any> | null, apiContext: ActionAPIContext): AstroGlobal;
68
+ createAstroPagePartial(result: SSRResult, apiContext: ActionAPIContext): Omit<AstroGlobal, 'props' | 'self' | 'slots'>;
69
69
  getClientAddress(): string;
70
70
  computeCurrentLocale(): string | undefined;
71
71
  computePreferredLocale(): string | undefined;
@@ -10,8 +10,7 @@ import {
10
10
  import { renderEndpoint } from "../runtime/server/endpoint.js";
11
11
  import { renderPage } from "../runtime/server/index.js";
12
12
  import {
13
- ASTRO_VERSION,
14
- clientAddressSymbol,
13
+ ASTRO_GENERATOR,
15
14
  REROUTE_DIRECTIVE_HEADER,
16
15
  REWRITE_DIRECTIVE_HEADER_KEY,
17
16
  REWRITE_DIRECTIVE_HEADER_VALUE,
@@ -241,10 +240,14 @@ class RenderContext {
241
240
  }
242
241
  createAPIContext(props, context) {
243
242
  const redirect = (path, status = 302) => new Response(null, { status, headers: { Location: path } });
243
+ const rewrite = async (reroutePayload) => {
244
+ return await this.#executeRewrite(reroutePayload);
245
+ };
244
246
  Reflect.set(context, apiContextRoutesSymbol, this.pipeline);
245
247
  return Object.assign(context, {
246
248
  props,
247
249
  redirect,
250
+ rewrite,
248
251
  getActionResult: createGetActionResult(context.locals),
249
252
  callAction: createCallAction(context)
250
253
  });
@@ -298,10 +301,6 @@ class RenderContext {
298
301
  createActionAPIContext() {
299
302
  const renderContext = this;
300
303
  const { params, pipeline, url } = this;
301
- const generator = `Astro v${ASTRO_VERSION}`;
302
- const rewrite = async (reroutePayload) => {
303
- return await this.#executeRewrite(reroutePayload);
304
- };
305
304
  return {
306
305
  // Don't allow reassignment of cookies because it doesn't work
307
306
  get cookies() {
@@ -315,7 +314,7 @@ class RenderContext {
315
314
  get currentLocale() {
316
315
  return renderContext.computeCurrentLocale();
317
316
  },
318
- generator,
317
+ generator: ASTRO_GENERATOR,
319
318
  get locals() {
320
319
  return renderContext.locals;
321
320
  },
@@ -329,7 +328,6 @@ class RenderContext {
329
328
  get preferredLocaleList() {
330
329
  return renderContext.computePreferredLocaleList();
331
330
  },
332
- rewrite,
333
331
  request: this.request,
334
332
  site: pipeline.site,
335
333
  url,
@@ -430,7 +428,7 @@ class RenderContext {
430
428
  compressHTML,
431
429
  cookies,
432
430
  /** This function returns the `Astro` faux-global */
433
- createAstro: (astroGlobal, props, slots) => this.createAstro(result, astroGlobal, props, slots, ctx),
431
+ createAstro: (props, slots) => this.createAstro(result, props, slots, ctx),
434
432
  links,
435
433
  params: this.params,
436
434
  partial,
@@ -481,20 +479,12 @@ class RenderContext {
481
479
  *
482
480
  * The page level partial is used as the prototype of the user-visible `Astro` global object, which is instantiated once per use of a component.
483
481
  */
484
- createAstro(result, astroStaticPartial, props, slotValues, apiContext) {
482
+ createAstro(result, props, slotValues, apiContext) {
485
483
  let astroPagePartial;
486
484
  if (this.isRewriting) {
487
- astroPagePartial = this.#astroPagePartial = this.createAstroPagePartial(
488
- result,
489
- astroStaticPartial,
490
- apiContext
491
- );
485
+ astroPagePartial = this.#astroPagePartial = this.createAstroPagePartial(result, apiContext);
492
486
  } else {
493
- astroPagePartial = this.#astroPagePartial ??= this.createAstroPagePartial(
494
- result,
495
- astroStaticPartial,
496
- apiContext
497
- );
487
+ astroPagePartial = this.#astroPagePartial ??= this.createAstroPagePartial(result, apiContext);
498
488
  }
499
489
  const astroComponentPartial = { props, self: null };
500
490
  const Astro = Object.assign(
@@ -516,7 +506,7 @@ class RenderContext {
516
506
  });
517
507
  return Astro;
518
508
  }
519
- createAstroPagePartial(result, astroStaticPartial, apiContext) {
509
+ createAstroPagePartial(result, apiContext) {
520
510
  const renderContext = this;
521
511
  const { cookies, locals, params, pipeline, url } = this;
522
512
  const { response } = result;
@@ -533,8 +523,7 @@ class RenderContext {
533
523
  };
534
524
  const callAction = createCallAction(apiContext);
535
525
  return {
536
- generator: astroStaticPartial.generator,
537
- glob: astroStaticPartial.glob,
526
+ generator: ASTRO_GENERATOR,
538
527
  routePattern: this.routeData.route,
539
528
  isPrerendered: this.routeData.prerender,
540
529
  cookies,
@@ -619,7 +608,7 @@ class RenderContext {
619
608
  };
620
609
  }
621
610
  getClientAddress() {
622
- const { pipeline, request, routeData, clientAddress } = this;
611
+ const { pipeline, routeData, clientAddress } = this;
623
612
  if (routeData.prerender) {
624
613
  throw new AstroError({
625
614
  ...AstroErrorData.PrerenderClientAddressNotAvailable,
@@ -629,9 +618,6 @@ class RenderContext {
629
618
  if (clientAddress) {
630
619
  return clientAddress;
631
620
  }
632
- if (clientAddressSymbol in request) {
633
- return Reflect.get(request, clientAddressSymbol);
634
- }
635
621
  if (pipeline.adapterName) {
636
622
  throw new AstroError({
637
623
  ...AstroErrorData.ClientAddressNotAvailable,
@@ -178,7 +178,7 @@ function createFileBasedRoutes({ settings, cwd, fsMod }, logger) {
178
178
  }
179
179
  return routes;
180
180
  }
181
- const trailingSlashForPath = (pathname, config) => pathname && hasFileExtension(pathname) ? "ignore" : config.trailingSlash;
181
+ const trailingSlashForPath = (pathname, config) => pathname && hasFileExtension(pathname) ? "never" : config.trailingSlash;
182
182
  function createInjectedRoutes({ settings, cwd }) {
183
183
  const { config } = settings;
184
184
  const prerender = getPrerenderDefault(config);
@@ -1,14 +1,13 @@
1
1
  import { trimSlashes } from "../path.js";
2
2
  import { validateGetStaticPathsParameter } from "./validation.js";
3
3
  function stringifyParams(params, route) {
4
- const validatedParams = Object.entries(params).reduce((acc, next) => {
5
- validateGetStaticPathsParameter(next, route.component);
6
- const [key, value] = next;
4
+ const validatedParams = {};
5
+ for (const [key, value] of Object.entries(params)) {
6
+ validateGetStaticPathsParameter([key, value], route.component);
7
7
  if (value !== void 0) {
8
- acc[key] = typeof value === "string" ? trimSlashes(value) : value.toString();
8
+ validatedParams[key] = trimSlashes(value);
9
9
  }
10
- return acc;
11
- }, {});
10
+ }
12
11
  return route.generate(validatedParams);
13
12
  }
14
13
  export {
@@ -1,7 +1,6 @@
1
1
  import type { ComponentInstance } from '../../types/astro.js';
2
2
  import type { GetStaticPathsResult } from '../../types/public/common.js';
3
3
  import type { RouteData } from '../../types/public/internal.js';
4
- import type { Logger } from '../logger/core.js';
5
4
  /** Throws error for invalid parameter in getStaticPaths() response */
6
5
  export declare function validateGetStaticPathsParameter([key, value]: [string, any], route: string): void;
7
6
  /** Error for deprecated or malformed route components */
@@ -10,4 +9,4 @@ export declare function validateDynamicRouteModule(mod: ComponentInstance, { ssr
10
9
  route: RouteData;
11
10
  }): void;
12
11
  /** Throw error and log warnings for malformed getStaticPaths() response */
13
- export declare function validateGetStaticPathsResult(result: GetStaticPathsResult, logger: Logger, route: RouteData): void;
12
+ export declare function validateGetStaticPathsResult(result: GetStaticPathsResult, route: RouteData): void;