astro 4.12.2 → 4.13.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 (50) hide show
  1. package/dist/@types/astro.d.ts +6 -106
  2. package/dist/actions/consts.d.ts +3 -0
  3. package/dist/actions/consts.js +6 -0
  4. package/dist/actions/index.d.ts +12 -2
  5. package/dist/actions/index.js +43 -7
  6. package/dist/actions/runtime/middleware.js +80 -23
  7. package/dist/actions/runtime/route.js +2 -3
  8. package/dist/actions/runtime/utils.d.ts +4 -2
  9. package/dist/actions/runtime/utils.js +1 -1
  10. package/dist/actions/runtime/virtual/server.d.ts +6 -5
  11. package/dist/actions/runtime/virtual/server.js +6 -5
  12. package/dist/actions/runtime/virtual/shared.d.ts +7 -0
  13. package/dist/actions/runtime/virtual/shared.js +11 -1
  14. package/dist/cli/add/index.js +1 -1
  15. package/dist/container/index.js +0 -1
  16. package/dist/content/runtime-assets.d.ts +1 -1
  17. package/dist/content/types-generator.js +5 -3
  18. package/dist/content/vite-plugin-content-assets.js +0 -14
  19. package/dist/core/app/types.d.ts +0 -1
  20. package/dist/core/build/generate.js +10 -4
  21. package/dist/core/build/pipeline.js +0 -1
  22. package/dist/core/build/plugins/plugin-content.js +1 -1
  23. package/dist/core/build/plugins/plugin-manifest.js +0 -1
  24. package/dist/core/config/schema.d.ts +0 -34
  25. package/dist/core/config/schema.js +0 -4
  26. package/dist/core/constants.js +1 -1
  27. package/dist/core/dev/dev.js +1 -1
  28. package/dist/core/errors/dev/utils.js +12 -3
  29. package/dist/core/errors/dev/vite.d.ts +13 -0
  30. package/dist/core/errors/dev/vite.js +18 -4
  31. package/dist/core/errors/errors-data.d.ts +28 -1
  32. package/dist/core/errors/errors-data.js +14 -0
  33. package/dist/core/messages.js +2 -2
  34. package/dist/core/middleware/callMiddleware.d.ts +1 -2
  35. package/dist/core/middleware/callMiddleware.js +2 -12
  36. package/dist/core/render-context.js +13 -37
  37. package/dist/env/runtime.d.ts +2 -2
  38. package/dist/env/runtime.js +1 -1
  39. package/dist/integrations/hooks.js +1 -1
  40. package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +0 -14
  41. package/dist/runtime/server/render/astro/instance.d.ts +2 -2
  42. package/dist/runtime/server/render/server-islands.js +2 -1
  43. package/dist/transitions/router.js +0 -8
  44. package/dist/vite-plugin-astro-server/error.js +1 -2
  45. package/dist/vite-plugin-astro-server/plugin.js +0 -1
  46. package/dist/vite-plugin-astro-server/route.js +0 -1
  47. package/dist/vite-plugin-astro-server/vite.js +4 -0
  48. package/package.json +22 -22
  49. package/templates/actions.mjs +29 -32
  50. package/templates/env/module.mjs +2 -0
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import { fileURLToPath } from "node:url";
4
- import { bgGreen, black, blue, bold, dim, green, magenta } from "kleur/colors";
4
+ import { bgGreen, black, blue, bold, dim, green, magenta, red } from "kleur/colors";
5
5
  import PQueue from "p-queue";
6
6
  import {
7
7
  generateImagesForPath,
@@ -143,8 +143,9 @@ ${bgGreen(black(` ${verb} static routes `))}`);
143
143
  }
144
144
  await runHookBuildGenerated({ config, logger });
145
145
  }
146
+ const THRESHOLD_SLOW_RENDER_TIME_MS = 500;
146
147
  async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
147
- const { config, internals, logger } = pipeline;
148
+ const { config, logger } = pipeline;
148
149
  const pageModulePromise = ssrEntry.page;
149
150
  const styles = pageData.styles.sort(cssOrder).map(({ sheet }) => sheet).reduce(mergeInlineCss, []);
150
151
  const linkIds = [];
@@ -178,7 +179,13 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
178
179
  const timeEnd = performance.now();
179
180
  const timeChange = getTimeStat(prevTimeEnd, timeEnd);
180
181
  const timeIncrease = `(+${timeChange})`;
181
- logger.info("SKIP_FORMAT", ` ${dim(timeIncrease)}`);
182
+ let timeIncreaseLabel;
183
+ if (timeEnd - prevTimeEnd > THRESHOLD_SLOW_RENDER_TIME_MS) {
184
+ timeIncreaseLabel = red(timeIncrease);
185
+ } else {
186
+ timeIncreaseLabel = dim(timeIncrease);
187
+ }
188
+ logger.info("SKIP_FORMAT", ` ${timeIncreaseLabel}`);
182
189
  prevTimeEnd = timeEnd;
183
190
  }
184
191
  }
@@ -398,7 +405,6 @@ function createBuildManifest(settings, internals, renderers, middleware) {
398
405
  i18n: i18nManifest,
399
406
  buildFormat: settings.config.build.format,
400
407
  middleware,
401
- rewritingEnabled: settings.config.experimental.rewriting,
402
408
  checkOrigin: settings.config.security?.checkOrigin ?? false,
403
409
  experimentalEnvGetSecretEnabled: false
404
410
  };
@@ -1,6 +1,5 @@
1
1
  import { getOutputDirectory } from "../../prerender/utils.js";
2
2
  import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
3
- import { DEFAULT_404_COMPONENT } from "../constants.js";
4
3
  import { routeIsFallback, routeIsRedirect } from "../redirects/helpers.js";
5
4
  import { RedirectSinglePageBuiltModule } from "../redirects/index.js";
6
5
  import { Pipeline } from "../render/index.js";
@@ -278,7 +278,7 @@ async function generateContentManifest(opts, lookupMap) {
278
278
  promises.push(
279
279
  limit(async () => {
280
280
  const data = await fsMod.promises.readFile(fileURL, { encoding: "utf8" });
281
- manifest.entries.push([key, checksum(data)]);
281
+ manifest.entries.push([key, checksum(data, fileURL.toString())]);
282
282
  })
283
283
  );
284
284
  }
@@ -213,7 +213,6 @@ function buildManifest(opts, internals, staticFiles) {
213
213
  i18n: i18nManifest,
214
214
  buildFormat: settings.config.build.format,
215
215
  checkOrigin: settings.config.security?.checkOrigin ?? false,
216
- rewritingEnabled: settings.config.experimental.rewriting,
217
216
  serverIslandNameMap: Array.from(settings.serverIslandNameMap),
218
217
  experimentalEnvGetSecretEnabled: settings.config.experimental.env !== void 0 && (settings.adapter?.supportedAstroFeatures.envGetSecret ?? "unsupported") !== "unsupported"
219
218
  };
@@ -54,10 +54,8 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
54
54
  actions: false;
55
55
  directRenderScript: false;
56
56
  contentCollectionCache: false;
57
- contentCollectionJsonSchema: false;
58
57
  clientPrerender: false;
59
58
  globalRoutePriority: false;
60
- rewriting: false;
61
59
  serverIslands: false;
62
60
  env: {
63
61
  validateSecrets: false;
@@ -402,10 +400,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
402
400
  actions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
403
401
  directRenderScript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
404
402
  contentCollectionCache: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
405
- contentCollectionJsonSchema: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
406
403
  clientPrerender: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
407
404
  globalRoutePriority: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
408
- rewriting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
409
405
  env: z.ZodOptional<z.ZodObject<{
410
406
  schema: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
411
407
  context: z.ZodLiteral<"client">;
@@ -621,10 +617,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
621
617
  actions: boolean;
622
618
  directRenderScript: boolean;
623
619
  contentCollectionCache: boolean;
624
- contentCollectionJsonSchema: boolean;
625
620
  clientPrerender: boolean;
626
621
  globalRoutePriority: boolean;
627
- rewriting: boolean;
628
622
  serverIslands: boolean;
629
623
  env?: {
630
624
  validateSecrets: boolean;
@@ -672,10 +666,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
672
666
  actions?: boolean | undefined;
673
667
  directRenderScript?: boolean | undefined;
674
668
  contentCollectionCache?: boolean | undefined;
675
- contentCollectionJsonSchema?: boolean | undefined;
676
669
  clientPrerender?: boolean | undefined;
677
670
  globalRoutePriority?: boolean | undefined;
678
- rewriting?: boolean | undefined;
679
671
  serverIslands?: boolean | undefined;
680
672
  env?: {
681
673
  validateSecrets?: boolean | undefined;
@@ -801,10 +793,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
801
793
  actions: boolean;
802
794
  directRenderScript: boolean;
803
795
  contentCollectionCache: boolean;
804
- contentCollectionJsonSchema: boolean;
805
796
  clientPrerender: boolean;
806
797
  globalRoutePriority: boolean;
807
- rewriting: boolean;
808
798
  serverIslands: boolean;
809
799
  env?: {
810
800
  validateSecrets: boolean;
@@ -966,10 +956,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
966
956
  actions?: boolean | undefined;
967
957
  directRenderScript?: boolean | undefined;
968
958
  contentCollectionCache?: boolean | undefined;
969
- contentCollectionJsonSchema?: boolean | undefined;
970
959
  clientPrerender?: boolean | undefined;
971
960
  globalRoutePriority?: boolean | undefined;
972
- rewriting?: boolean | undefined;
973
961
  serverIslands?: boolean | undefined;
974
962
  env?: {
975
963
  validateSecrets?: boolean | undefined;
@@ -1355,10 +1343,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1355
1343
  actions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1356
1344
  directRenderScript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1357
1345
  contentCollectionCache: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1358
- contentCollectionJsonSchema: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1359
1346
  clientPrerender: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1360
1347
  globalRoutePriority: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1361
- rewriting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1362
1348
  env: z.ZodOptional<z.ZodObject<{
1363
1349
  schema: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
1364
1350
  context: z.ZodLiteral<"client">;
@@ -1574,10 +1560,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1574
1560
  actions: boolean;
1575
1561
  directRenderScript: boolean;
1576
1562
  contentCollectionCache: boolean;
1577
- contentCollectionJsonSchema: boolean;
1578
1563
  clientPrerender: boolean;
1579
1564
  globalRoutePriority: boolean;
1580
- rewriting: boolean;
1581
1565
  serverIslands: boolean;
1582
1566
  env?: {
1583
1567
  validateSecrets: boolean;
@@ -1625,10 +1609,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1625
1609
  actions?: boolean | undefined;
1626
1610
  directRenderScript?: boolean | undefined;
1627
1611
  contentCollectionCache?: boolean | undefined;
1628
- contentCollectionJsonSchema?: boolean | undefined;
1629
1612
  clientPrerender?: boolean | undefined;
1630
1613
  globalRoutePriority?: boolean | undefined;
1631
- rewriting?: boolean | undefined;
1632
1614
  serverIslands?: boolean | undefined;
1633
1615
  env?: {
1634
1616
  validateSecrets?: boolean | undefined;
@@ -1829,10 +1811,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1829
1811
  actions: boolean;
1830
1812
  directRenderScript: boolean;
1831
1813
  contentCollectionCache: boolean;
1832
- contentCollectionJsonSchema: boolean;
1833
1814
  clientPrerender: boolean;
1834
1815
  globalRoutePriority: boolean;
1835
- rewriting: boolean;
1836
1816
  serverIslands: boolean;
1837
1817
  env?: {
1838
1818
  validateSecrets: boolean;
@@ -1994,10 +1974,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1994
1974
  actions?: boolean | undefined;
1995
1975
  directRenderScript?: boolean | undefined;
1996
1976
  contentCollectionCache?: boolean | undefined;
1997
- contentCollectionJsonSchema?: boolean | undefined;
1998
1977
  clientPrerender?: boolean | undefined;
1999
1978
  globalRoutePriority?: boolean | undefined;
2000
- rewriting?: boolean | undefined;
2001
1979
  serverIslands?: boolean | undefined;
2002
1980
  env?: {
2003
1981
  validateSecrets?: boolean | undefined;
@@ -2124,10 +2102,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2124
2102
  actions: boolean;
2125
2103
  directRenderScript: boolean;
2126
2104
  contentCollectionCache: boolean;
2127
- contentCollectionJsonSchema: boolean;
2128
2105
  clientPrerender: boolean;
2129
2106
  globalRoutePriority: boolean;
2130
- rewriting: boolean;
2131
2107
  serverIslands: boolean;
2132
2108
  env?: {
2133
2109
  validateSecrets: boolean;
@@ -2289,10 +2265,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2289
2265
  actions?: boolean | undefined;
2290
2266
  directRenderScript?: boolean | undefined;
2291
2267
  contentCollectionCache?: boolean | undefined;
2292
- contentCollectionJsonSchema?: boolean | undefined;
2293
2268
  clientPrerender?: boolean | undefined;
2294
2269
  globalRoutePriority?: boolean | undefined;
2295
- rewriting?: boolean | undefined;
2296
2270
  serverIslands?: boolean | undefined;
2297
2271
  env?: {
2298
2272
  validateSecrets?: boolean | undefined;
@@ -2419,10 +2393,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2419
2393
  actions: boolean;
2420
2394
  directRenderScript: boolean;
2421
2395
  contentCollectionCache: boolean;
2422
- contentCollectionJsonSchema: boolean;
2423
2396
  clientPrerender: boolean;
2424
2397
  globalRoutePriority: boolean;
2425
- rewriting: boolean;
2426
2398
  serverIslands: boolean;
2427
2399
  env?: {
2428
2400
  validateSecrets: boolean;
@@ -2584,10 +2556,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2584
2556
  actions?: boolean | undefined;
2585
2557
  directRenderScript?: boolean | undefined;
2586
2558
  contentCollectionCache?: boolean | undefined;
2587
- contentCollectionJsonSchema?: boolean | undefined;
2588
2559
  clientPrerender?: boolean | undefined;
2589
2560
  globalRoutePriority?: boolean | undefined;
2590
- rewriting?: boolean | undefined;
2591
2561
  serverIslands?: boolean | undefined;
2592
2562
  env?: {
2593
2563
  validateSecrets?: boolean | undefined;
@@ -2714,10 +2684,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2714
2684
  actions: boolean;
2715
2685
  directRenderScript: boolean;
2716
2686
  contentCollectionCache: boolean;
2717
- contentCollectionJsonSchema: boolean;
2718
2687
  clientPrerender: boolean;
2719
2688
  globalRoutePriority: boolean;
2720
- rewriting: boolean;
2721
2689
  serverIslands: boolean;
2722
2690
  env?: {
2723
2691
  validateSecrets: boolean;
@@ -2879,10 +2847,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
2879
2847
  actions?: boolean | undefined;
2880
2848
  directRenderScript?: boolean | undefined;
2881
2849
  contentCollectionCache?: boolean | undefined;
2882
- contentCollectionJsonSchema?: boolean | undefined;
2883
2850
  clientPrerender?: boolean | undefined;
2884
2851
  globalRoutePriority?: boolean | undefined;
2885
- rewriting?: boolean | undefined;
2886
2852
  serverIslands?: boolean | undefined;
2887
2853
  env?: {
2888
2854
  validateSecrets?: boolean | undefined;
@@ -44,10 +44,8 @@ const ASTRO_CONFIG_DEFAULTS = {
44
44
  actions: false,
45
45
  directRenderScript: false,
46
46
  contentCollectionCache: false,
47
- contentCollectionJsonSchema: false,
48
47
  clientPrerender: false,
49
48
  globalRoutePriority: false,
50
- rewriting: false,
51
49
  serverIslands: false,
52
50
  env: {
53
51
  validateSecrets: false
@@ -328,10 +326,8 @@ const AstroConfigSchema = z.object({
328
326
  actions: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.actions),
329
327
  directRenderScript: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.directRenderScript),
330
328
  contentCollectionCache: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.contentCollectionCache),
331
- contentCollectionJsonSchema: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.contentCollectionJsonSchema),
332
329
  clientPrerender: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.clientPrerender),
333
330
  globalRoutePriority: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.globalRoutePriority),
334
- rewriting: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.rewriting),
335
331
  env: z.object({
336
332
  schema: EnvSchema.optional(),
337
333
  validateSecrets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.env.validateSecrets)
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.12.2";
1
+ const ASTRO_VERSION = "4.13.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";
@@ -19,7 +19,7 @@ async function dev(inlineConfig) {
19
19
  await telemetry.record([]);
20
20
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
21
21
  const logger = restart.container.logger;
22
- const currentVersion = "4.12.2";
22
+ const currentVersion = "4.13.0";
23
23
  const isPrerelease = currentVersion.includes("-");
24
24
  if (!isPrerelease) {
25
25
  try {
@@ -15,7 +15,10 @@ function collectErrorMetadata(e, rootFolder) {
15
15
  err.forEach((error) => {
16
16
  if (e.stack) {
17
17
  const stackInfo = collectInfoFromStacktrace(e);
18
- error.stack = stripAnsi(stackInfo.stack);
18
+ try {
19
+ error.stack = stripAnsi(stackInfo.stack);
20
+ } catch {
21
+ }
19
22
  error.loc = stackInfo.loc;
20
23
  error.plugin = stackInfo.plugin;
21
24
  error.pluginCode = stackInfo.pluginCode;
@@ -40,14 +43,20 @@ function collectErrorMetadata(e, rootFolder) {
40
43
  }
41
44
  error.hint = generateHint(e);
42
45
  if (error.message) {
43
- error.message = stripAnsi(error.message);
46
+ try {
47
+ error.message = stripAnsi(error.message);
48
+ } catch {
49
+ }
44
50
  }
45
51
  });
46
52
  if (!AggregateError.is(e) && Array.isArray(e.errors)) {
47
53
  e.errors.forEach((buildError, i) => {
48
54
  const { location, pluginName, text } = buildError;
49
55
  if (text) {
50
- err[i].message = text;
56
+ try {
57
+ err[i].message = text;
58
+ } catch {
59
+ }
51
60
  }
52
61
  if (location) {
53
62
  err[i].loc = { file: location.file, line: location.line, column: location.column };
@@ -1,3 +1,4 @@
1
+ import type { ShikiTransformer } from 'shiki';
1
2
  import type { ErrorPayload } from 'vite';
2
3
  import type { ModuleLoader } from '../../module-loader/index.js';
3
4
  import { type ErrorWithMetadata } from '../errors.js';
@@ -28,3 +29,15 @@ export interface AstroErrorPayload {
28
29
  * Generate a payload for Vite's error overlay
29
30
  */
30
31
  export declare function getViteErrorPayload(err: ErrorWithMetadata): Promise<AstroErrorPayload>;
32
+ /**
33
+ * Transformer for `shiki`'s legacy `lineOptions`, allows to add classes to specific lines
34
+ * FROM: https://github.com/shikijs/shiki/blob/4a58472070a9a359a4deafec23bb576a73e24c6a/packages/transformers/src/transformers/compact-line-options.ts
35
+ * LICENSE: https://github.com/shikijs/shiki/blob/4a58472070a9a359a4deafec23bb576a73e24c6a/LICENSE
36
+ */
37
+ export declare function transformerCompactLineOptions(lineOptions?: {
38
+ /**
39
+ * 1-based line number.
40
+ */
41
+ line: number;
42
+ classes?: string[];
43
+ }[]): ShikiTransformer;
@@ -86,10 +86,13 @@ async function getViteErrorPayload(err) {
86
86
  highlighterLang = "md";
87
87
  }
88
88
  const highlightedCode = err.fullCode ? await codeToHtml(err.fullCode, {
89
- // @ts-expect-error always assume that shiki can accept the lang string
90
- lang: highlighterLang,
89
+ lang: highlighterLang ?? "text",
91
90
  theme: cssVariablesTheme(),
92
- lineOptions: err.loc?.line ? [{ line: err.loc.line, classes: ["error-line"] }] : void 0
91
+ transformers: [
92
+ transformerCompactLineOptions(
93
+ err.loc?.line ? [{ line: err.loc.line, classes: ["error-line"] }] : void 0
94
+ )
95
+ ]
93
96
  }) : void 0;
94
97
  return {
95
98
  type: "error",
@@ -113,7 +116,18 @@ async function getViteErrorPayload(err) {
113
116
  }
114
117
  };
115
118
  }
119
+ function transformerCompactLineOptions(lineOptions = []) {
120
+ return {
121
+ name: "@shikijs/transformers:compact-line-options",
122
+ line(node, line) {
123
+ const lineOption = lineOptions.find((o) => o.line === line);
124
+ if (lineOption?.classes) this.addClassToHast(node, lineOption.classes);
125
+ return node;
126
+ }
127
+ };
128
+ }
116
129
  export {
117
130
  enhanceViteSSRError,
118
- getViteErrorPayload
131
+ getViteErrorPayload,
132
+ transformerCompactLineOptions
119
133
  };
@@ -1021,6 +1021,7 @@ export declare const MissingMiddlewareForInternationalization: {
1021
1021
  message: string;
1022
1022
  };
1023
1023
  /**
1024
+ * @deprecated
1024
1025
  * @docs
1025
1026
  * @description
1026
1027
  * The user tried to rewrite using a route that doesn't exist, or it emitted a runtime error during its rendering phase.
@@ -1143,7 +1144,7 @@ export declare const ServerOnlyModule: {
1143
1144
  *
1144
1145
  * @see
1145
1146
  * - [Request.clone()](https://developer.mozilla.org/en-US/docs/Web/API/Request/clone)
1146
- * - [Astro.rewrite](https://docs.astro.build/en/reference/configuration-reference/#experimentalrewriting)
1147
+ * - [Astro.rewrite](https://docs.astro.build/en/reference/api-reference/#astrorewrite)
1147
1148
  */
1148
1149
  export declare const RewriteWithBodyUsed: {
1149
1150
  name: string;
@@ -1439,6 +1440,32 @@ export declare const ActionsWithoutServerOutputError: {
1439
1440
  message: string;
1440
1441
  hint: string;
1441
1442
  };
1443
+ /**
1444
+ * @docs
1445
+ * @see
1446
+ * - [Actions RFC](https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md)
1447
+ * @description
1448
+ * Action was called from a form using a GET request, but only POST requests are supported. This often occurs if `method="POST"` is missing on the form.
1449
+ */
1450
+ export declare const ActionsUsedWithForGetError: {
1451
+ name: string;
1452
+ title: string;
1453
+ message: (actionName: string) => string;
1454
+ hint: string;
1455
+ };
1456
+ /**
1457
+ * @docs
1458
+ * @see
1459
+ * - [Actions RFC](https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md)
1460
+ * @description
1461
+ * The server received the query string `?_astroAction=name`, but could not find an action with that name. Use the action function's `.queryString` property to retrieve the form `action` URL.
1462
+ */
1463
+ export declare const ActionQueryStringInvalidError: {
1464
+ name: string;
1465
+ title: string;
1466
+ message: (actionName: string) => string;
1467
+ hint: string;
1468
+ };
1442
1469
  /**
1443
1470
  * @docs
1444
1471
  * @see
@@ -547,6 +547,18 @@ const ActionsWithoutServerOutputError = {
547
547
  message: "Actions enabled without setting a server build output. A server is required to create callable backend functions. To deploy routes to a server, add a server adapter to your astro config.",
548
548
  hint: "Learn about on-demand rendering: https://docs.astro.build/en/basics/rendering-modes/#on-demand-rendered"
549
549
  };
550
+ const ActionsUsedWithForGetError = {
551
+ name: "ActionsUsedWithForGetError",
552
+ title: "An invalid Action query string was passed by a form.",
553
+ message: (actionName) => `Action ${actionName} was called from a form using a GET request, but only POST requests are supported. This often occurs if \`method="POST"\` is missing on the form.`,
554
+ hint: "Actions are experimental. Visit the RFC for usage instructions: https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md"
555
+ };
556
+ const ActionQueryStringInvalidError = {
557
+ name: "ActionQueryStringInvalidError",
558
+ title: "An invalid Action query string was passed by a form.",
559
+ message: (actionName) => `The server received the query string \`?_astroAction=${actionName}\`, but could not find an action with that name. If you changed an action's name in development, remove this query param from your URL and refresh.`,
560
+ hint: "Actions are experimental. Visit the RFC for usage instructions: https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md"
561
+ };
550
562
  const UnsupportedConfigTransformError = {
551
563
  name: "UnsupportedConfigTransformError",
552
564
  title: "Unsupported transform in content config.",
@@ -556,6 +568,8 @@ Full error: ${parseError}`,
556
568
  };
557
569
  const UnknownError = { name: "UnknownError", title: "Unknown Error." };
558
570
  export {
571
+ ActionQueryStringInvalidError,
572
+ ActionsUsedWithForGetError,
559
573
  ActionsWithoutServerOutputError,
560
574
  AstroGlobNoMatch,
561
575
  AstroGlobUsedOutside,
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "4.12.2";
41
+ const version = "4.13.0";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -270,7 +270,7 @@ function printHelp({
270
270
  message.push(
271
271
  linebreak(),
272
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
273
- `v${"4.12.2"}`
273
+ `v${"4.13.0"}`
274
274
  )} ${headline}`
275
275
  );
276
276
  }
@@ -1,5 +1,4 @@
1
1
  import type { APIContext, MiddlewareHandler, RewritePayload } from '../../@types/astro.js';
2
- import type { Logger } from '../logger/core.js';
3
2
  /**
4
3
  * Utility function that is in charge of calling the middleware.
5
4
  *
@@ -34,4 +33,4 @@ import type { Logger } from '../logger/core.js';
34
33
  * @param apiContext The API context
35
34
  * @param responseFunction A callback function that should return a promise with the response
36
35
  */
37
- export declare function callMiddleware(onRequest: MiddlewareHandler, apiContext: APIContext, responseFunction: (apiContext: APIContext, rewritePayload?: RewritePayload) => Promise<Response> | Response, enableRerouting: boolean, logger: Logger): Promise<Response>;
36
+ export declare function callMiddleware(onRequest: MiddlewareHandler, apiContext: APIContext, responseFunction: (apiContext: APIContext, rewritePayload?: RewritePayload) => Promise<Response> | Response): Promise<Response>;
@@ -1,20 +1,10 @@
1
1
  import { AstroError, AstroErrorData } from "../errors/index.js";
2
- async function callMiddleware(onRequest, apiContext, responseFunction, enableRerouting, logger) {
2
+ async function callMiddleware(onRequest, apiContext, responseFunction) {
3
3
  let nextCalled = false;
4
4
  let responseFunctionPromise = void 0;
5
5
  const next = async (payload) => {
6
6
  nextCalled = true;
7
- if (enableRerouting) {
8
- responseFunctionPromise = responseFunction(apiContext, payload);
9
- } else {
10
- if (payload) {
11
- logger.warn(
12
- "router",
13
- "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
14
- );
15
- }
16
- responseFunctionPromise = responseFunction(apiContext);
17
- }
7
+ responseFunctionPromise = responseFunction(apiContext, payload);
18
8
  return responseFunctionPromise;
19
9
  };
20
10
  let middlewarePromise = onRequest(apiContext, next);
@@ -105,23 +105,16 @@ class RenderContext {
105
105
  }
106
106
  const lastNext = async (ctx, payload) => {
107
107
  if (payload) {
108
- if (this.pipeline.manifest.rewritingEnabled) {
109
- pipeline.logger.debug("router", "Called rewriting to:", payload);
110
- const [routeData, component] = await pipeline.tryRewrite(
111
- payload,
112
- this.request,
113
- this.originalRoute
114
- );
115
- this.routeData = routeData;
116
- componentInstance = component;
117
- this.isRewriting = true;
118
- this.status = 200;
119
- } else {
120
- this.pipeline.logger.error(
121
- "router",
122
- "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
123
- );
124
- }
108
+ pipeline.logger.debug("router", "Called rewriting to:", payload);
109
+ const [routeData, component] = await pipeline.tryRewrite(
110
+ payload,
111
+ this.request,
112
+ this.originalRoute
113
+ );
114
+ this.routeData = routeData;
115
+ componentInstance = component;
116
+ this.isRewriting = true;
117
+ this.status = 200;
125
118
  }
126
119
  let response2;
127
120
  switch (this.routeData.type) {
@@ -165,13 +158,7 @@ class RenderContext {
165
158
  }
166
159
  return response2;
167
160
  };
168
- const response = await callMiddleware(
169
- middleware,
170
- apiContext,
171
- lastNext,
172
- this.pipeline.manifest.rewritingEnabled,
173
- this.pipeline.logger
174
- );
161
+ const response = await callMiddleware(middleware, apiContext, lastNext);
175
162
  if (response.headers.get(ROUTE_TYPE_HEADER)) {
176
163
  response.headers.delete(ROUTE_TYPE_HEADER);
177
164
  }
@@ -187,19 +174,6 @@ class RenderContext {
187
174
  }
188
175
  async #executeRewrite(reroutePayload) {
189
176
  this.pipeline.logger.debug("router", "Calling rewrite: ", reroutePayload);
190
- if (!this.pipeline.manifest.rewritingEnabled) {
191
- this.pipeline.logger.error(
192
- "router",
193
- "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
194
- );
195
- return new Response(
196
- "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config.",
197
- {
198
- status: 500,
199
- statusText: "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
200
- }
201
- );
202
- }
203
177
  const [routeData, component, newURL] = await this.pipeline.tryRewrite(
204
178
  reroutePayload,
205
179
  this.request,
@@ -282,6 +256,7 @@ class RenderContext {
282
256
  };
283
257
  const actionResult = hasActionsInternal(this.locals) ? this.locals._actionsInternal?.actionResult : void 0;
284
258
  const result = {
259
+ base: manifest.base,
285
260
  cancelled: false,
286
261
  clientDirectives,
287
262
  inlinedScripts,
@@ -302,6 +277,7 @@ class RenderContext {
302
277
  styles,
303
278
  actionResult,
304
279
  serverIslandNameMap: manifest.serverIslandNameMap ?? /* @__PURE__ */ new Map(),
280
+ trailingSlash: manifest.trailingSlash,
305
281
  _metadata: {
306
282
  hasHydrationScript: false,
307
283
  rendererSpecificHydrationScripts: /* @__PURE__ */ new Set(),
@@ -2,8 +2,8 @@ import { AstroError } from '../core/errors/index.js';
2
2
  import type { ValidationResultInvalid } from './validators.js';
3
3
  export { validateEnvVariable, getEnvFieldType } from './validators.js';
4
4
  export type GetEnv = (key: string) => string | undefined;
5
+ type OnSetGetEnv = (reset: boolean) => void;
5
6
  export declare function setGetEnv(fn: GetEnv, reset?: boolean): void;
6
- declare let _onSetGetEnv: (reset: boolean) => void;
7
- export declare function setOnSetGetEnv(fn: typeof _onSetGetEnv): void;
7
+ export declare function setOnSetGetEnv(fn: OnSetGetEnv): void;
8
8
  export declare function getEnv(...args: Parameters<GetEnv>): string | undefined;
9
9
  export declare function createInvalidVariablesError(key: string, type: string, result: ValidationResultInvalid): AstroError;
@@ -6,7 +6,7 @@ function setGetEnv(fn, reset = false) {
6
6
  _getEnv = fn;
7
7
  _onSetGetEnv(reset);
8
8
  }
9
- let _onSetGetEnv = (reset) => {
9
+ let _onSetGetEnv = () => {
10
10
  };
11
11
  function setOnSetGetEnv(fn) {
12
12
  _onSetGetEnv = fn;
@@ -82,7 +82,7 @@ async function runHookConfigSetup({
82
82
  }
83
83
  if (settings.config.experimental?.actions) {
84
84
  const { default: actionsIntegration } = await import("../actions/index.js");
85
- settings.config.integrations.push(actionsIntegration({ fs }));
85
+ settings.config.integrations.push(actionsIntegration({ fs, settings }));
86
86
  }
87
87
  let updatedConfig = { ...settings.config };
88
88
  let updatedSettings = { ...settings, config: updatedConfig };