astro 4.10.2 → 4.11.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 (72) hide show
  1. package/components/Code.astro +9 -0
  2. package/dist/@types/astro.d.ts +43 -39
  3. package/dist/actions/runtime/virtual/server.d.ts +1 -1
  4. package/dist/assets/internal.d.ts +1 -1
  5. package/dist/assets/internal.js +6 -0
  6. package/dist/assets/types.d.ts +8 -2
  7. package/dist/assets/types.js +7 -0
  8. package/dist/container/index.d.ts +32 -1
  9. package/dist/container/index.js +45 -0
  10. package/dist/container/pipeline.d.ts +0 -1
  11. package/dist/container/pipeline.js +13 -32
  12. package/dist/container/vite-plugin-container.d.ts +2 -0
  13. package/dist/container/vite-plugin-container.js +15 -0
  14. package/dist/content/runtime-assets.d.ts +3 -3
  15. package/dist/content/types-generator.js +55 -34
  16. package/dist/content/utils.d.ts +11 -0
  17. package/dist/content/utils.js +49 -0
  18. package/dist/content/vite-plugin-content-imports.d.ts +3 -1
  19. package/dist/content/vite-plugin-content-imports.js +15 -4
  20. package/dist/core/app/index.d.ts +4 -0
  21. package/dist/core/app/index.js +17 -6
  22. package/dist/core/app/pipeline.d.ts +1 -2
  23. package/dist/core/app/pipeline.js +11 -39
  24. package/dist/core/base-pipeline.d.ts +0 -9
  25. package/dist/core/base-pipeline.js +1 -1
  26. package/dist/core/build/internal.d.ts +4 -0
  27. package/dist/core/build/internal.js +2 -1
  28. package/dist/core/build/page-data.js +2 -4
  29. package/dist/core/build/pipeline.d.ts +1 -2
  30. package/dist/core/build/pipeline.js +16 -42
  31. package/dist/core/build/plugins/plugin-chunks.js +6 -0
  32. package/dist/core/build/plugins/plugin-prerender.js +55 -48
  33. package/dist/core/build/plugins/plugin-ssr.js +15 -12
  34. package/dist/core/build/static-build.js +36 -44
  35. package/dist/core/build/types.d.ts +0 -1
  36. package/dist/core/config/schema.d.ts +4 -156
  37. package/dist/core/constants.d.ts +4 -0
  38. package/dist/core/constants.js +3 -1
  39. package/dist/core/cookies/cookies.d.ts +5 -0
  40. package/dist/core/cookies/cookies.js +12 -0
  41. package/dist/core/cookies/response.d.ts +1 -0
  42. package/dist/core/cookies/response.js +1 -0
  43. package/dist/core/create-vite.js +4 -6
  44. package/dist/core/dev/dev.js +1 -1
  45. package/dist/core/errors/errors-data.d.ts +40 -11
  46. package/dist/core/errors/errors-data.js +13 -6
  47. package/dist/core/messages.js +2 -2
  48. package/dist/core/render-context.d.ts +1 -1
  49. package/dist/core/render-context.js +22 -6
  50. package/dist/core/request.js +7 -1
  51. package/dist/core/routing/astro-designed-error-pages.d.ts +1 -0
  52. package/dist/core/routing/astro-designed-error-pages.js +15 -1
  53. package/dist/core/routing/rewrite.d.ts +10 -0
  54. package/dist/core/routing/rewrite.js +41 -0
  55. package/dist/core/util.js +5 -2
  56. package/dist/env/constants.d.ts +0 -1
  57. package/dist/env/constants.js +0 -2
  58. package/dist/env/runtime.d.ts +3 -1
  59. package/dist/env/runtime.js +8 -1
  60. package/dist/env/schema.d.ts +2 -78
  61. package/dist/env/schema.js +1 -17
  62. package/dist/env/vite-plugin-env.js +15 -15
  63. package/dist/jsx/server.d.ts +3 -5
  64. package/dist/jsx/server.js +3 -1
  65. package/dist/vite-plugin-astro/index.js +1 -1
  66. package/dist/vite-plugin-astro-server/pipeline.d.ts +1 -2
  67. package/dist/vite-plugin-astro-server/pipeline.js +15 -42
  68. package/dist/vite-plugin-astro-server/request.js +1 -1
  69. package/dist/vite-plugin-astro-server/route.js +53 -94
  70. package/package.json +8 -7
  71. package/templates/env/module.mjs +14 -5
  72. package/templates/env/types.d.ts +1 -12
@@ -2,12 +2,15 @@ import fs from "node:fs";
2
2
  import path, { extname } from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import { teardown } from "@astrojs/compiler";
5
- import * as eslexer from "es-module-lexer";
6
5
  import glob from "fast-glob";
7
6
  import { bgGreen, bgMagenta, black, green } from "kleur/colors";
8
7
  import * as vite from "vite";
9
8
  import { PROPAGATED_ASSET_FLAG } from "../../content/consts.js";
10
- import { hasAnyContentFlag } from "../../content/utils.js";
9
+ import {
10
+ getSymlinkedContentCollections,
11
+ hasAnyContentFlag,
12
+ reverseSymlink
13
+ } from "../../content/utils.js";
11
14
  import {
12
15
  createBuildInternals,
13
16
  getPageDatasWithPublicKey
@@ -34,7 +37,7 @@ import { RESOLVED_SPLIT_MODULE_ID, RESOLVED_SSR_VIRTUAL_MODULE_ID } from "./plug
34
37
  import { ASTRO_PAGE_EXTENSION_POST_PATTERN } from "./plugins/util.js";
35
38
  import { encodeName, getTimeStat, viteBuildReturnToRollupOutputs } from "./util.js";
36
39
  async function viteBuild(opts) {
37
- const { allPages, settings } = opts;
40
+ const { allPages, settings, logger } = opts;
38
41
  if (isModeServerWithNoAdapter(opts.settings)) {
39
42
  throw new AstroError(AstroErrorData.NoAdapterInstalled);
40
43
  }
@@ -56,7 +59,7 @@ async function viteBuild(opts) {
56
59
  registerAllPlugins(container);
57
60
  const ssrTime = performance.now();
58
61
  opts.logger.info("build", `Building ${settings.config.output} entrypoints...`);
59
- const ssrOutput = await ssrBuild(opts, internals, pageInput, container);
62
+ const ssrOutput = await ssrBuild(opts, internals, pageInput, container, logger);
60
63
  opts.logger.info("build", green(`\u2713 Completed in ${getTimeStat(ssrTime, performance.now())}.`));
61
64
  settings.timer.end("SSR build");
62
65
  settings.timer.start("Client build");
@@ -107,7 +110,7 @@ async function staticBuild(opts, internals, ssrOutputChunkNames, contentFileName
107
110
  case isServerLikeOutput(settings.config): {
108
111
  settings.timer.start("Server generate");
109
112
  await generatePages(opts, internals);
110
- await cleanStaticOutput(opts, internals, ssrOutputChunkNames);
113
+ await cleanStaticOutput(opts, internals);
111
114
  opts.logger.info(null, `
112
115
  ${bgMagenta(black(" finalizing server assets "))}
113
116
  `);
@@ -119,7 +122,7 @@ ${bgMagenta(black(" finalizing server assets "))}
119
122
  return;
120
123
  }
121
124
  }
122
- async function ssrBuild(opts, internals, input, container) {
125
+ async function ssrBuild(opts, internals, input, container, logger) {
123
126
  const buildID = Date.now().toString();
124
127
  const { allPages, settings, viteConfig } = opts;
125
128
  const ssr = isServerLikeOutput(settings.config);
@@ -127,6 +130,8 @@ async function ssrBuild(opts, internals, input, container) {
127
130
  const routes = Object.values(allPages).flatMap((pageData) => pageData.route);
128
131
  const isContentCache = !ssr && settings.config.experimental.contentCollectionCache;
129
132
  const { lastVitePlugins, vitePlugins } = await container.runBeforeHook("server", input);
133
+ const contentDir = new URL("./src/content", settings.config.root);
134
+ const symlinks = await getSymlinkedContentCollections({ contentDir, logger, fs });
130
135
  const viteBuildConfig = {
131
136
  ...viteConfig,
132
137
  mode: viteConfig.mode || "production",
@@ -143,6 +148,8 @@ async function ssrBuild(opts, internals, input, container) {
143
148
  copyPublicDir: !ssr,
144
149
  rollupOptions: {
145
150
  ...viteConfig.build?.rollupOptions,
151
+ // Setting as `exports-only` allows us to safely delete inputs that are only used during prerendering
152
+ preserveEntrySignatures: "exports-only",
146
153
  input: [],
147
154
  output: {
148
155
  hoistTransitiveImports: isContentCache,
@@ -193,7 +200,12 @@ async function ssrBuild(opts, internals, input, container) {
193
200
  } else if (chunkInfo.facadeModuleId === RESOLVED_SSR_MANIFEST_VIRTUAL_MODULE_ID) {
194
201
  return "manifest_[hash].mjs";
195
202
  } else if (settings.config.experimental.contentCollectionCache && chunkInfo.facadeModuleId && hasAnyContentFlag(chunkInfo.facadeModuleId)) {
196
- const [srcRelative, flag] = chunkInfo.facadeModuleId.split("/src/")[1].split("?");
203
+ const moduleId = reverseSymlink({
204
+ symlinks,
205
+ entry: chunkInfo.facadeModuleId,
206
+ contentDir
207
+ });
208
+ const [srcRelative, flag] = moduleId.split("/src/")[1].split("?");
197
209
  if (flag === PROPAGATED_ASSET_FLAG) {
198
210
  return encodeName(`${removeFileExtension(srcRelative)}.entry.mjs`);
199
211
  }
@@ -285,46 +297,26 @@ async function runPostBuildHooks(container, ssrOutputs, clientOutputs) {
285
297
  await fs.promises.writeFile(fileURL, mutation.code, "utf-8");
286
298
  }
287
299
  }
288
- async function cleanStaticOutput(opts, internals, ssrOutputChunkNames) {
289
- const prerenderedFiles = /* @__PURE__ */ new Set();
290
- const onDemandsFiles = /* @__PURE__ */ new Set();
291
- for (const pageData of internals.pagesByKeys.values()) {
292
- const { moduleSpecifier } = pageData;
293
- const bundleId = internals.pageToBundleMap.get(moduleSpecifier) ?? internals.entrySpecifierToBundleMap.get(moduleSpecifier);
294
- if (pageData.route.prerender && !pageData.hasSharedModules && !onDemandsFiles.has(bundleId)) {
295
- prerenderedFiles.add(bundleId);
296
- } else {
297
- onDemandsFiles.add(bundleId);
298
- if (prerenderedFiles.has(bundleId)) {
299
- prerenderedFiles.delete(bundleId);
300
- }
301
- }
302
- }
300
+ async function cleanStaticOutput(opts, internals) {
303
301
  const ssr = isServerLikeOutput(opts.settings.config);
304
302
  const out = ssr ? opts.settings.config.build.server : getOutDirWithinCwd(opts.settings.config.outDir);
305
- const files = ssrOutputChunkNames.filter((f) => f.endsWith(".mjs"));
306
- if (files.length) {
307
- await eslexer.init;
308
- await Promise.all(
309
- files.map(async (filename) => {
310
- if (!prerenderedFiles.has(filename)) {
311
- return;
312
- }
313
- const url = new URL(filename, out);
314
- const text = await fs.promises.readFile(url, { encoding: "utf8" });
315
- const [, exports] = eslexer.parse(text);
316
- let value = "const noop = () => {};";
317
- for (const e of exports) {
318
- if (e.n === "default") value += `
319
- export default noop;`;
320
- else value += `
321
- export const ${e.n} = noop;`;
303
+ await Promise.all(
304
+ internals.prerenderOnlyChunks.map(async (chunk) => {
305
+ const url = new URL(chunk.fileName, out);
306
+ try {
307
+ if (chunk.isEntry || chunk.isDynamicEntry) {
308
+ await fs.promises.writeFile(
309
+ url,
310
+ "// Contents removed by Astro as it's used for prerendering only",
311
+ "utf-8"
312
+ );
313
+ } else {
314
+ await fs.promises.unlink(url);
322
315
  }
323
- await fs.promises.writeFile(url, value, { encoding: "utf8" });
324
- })
325
- );
326
- removeEmptyDirs(out);
327
- }
316
+ } catch {
317
+ }
318
+ })
319
+ );
328
320
  }
329
321
  async function cleanServerOutput(opts, ssrOutputChunkNames, contentFileNames, internals) {
330
322
  const out = getOutDirWithinCwd(opts.settings.config.outDir);
@@ -27,7 +27,6 @@ export interface PageBuildData {
27
27
  order: number;
28
28
  sheet: StylesheetAsset;
29
29
  }>;
30
- hasSharedModules: boolean;
31
30
  }
32
31
  export type AllPagesData = Record<ComponentPath, PageBuildData>;
33
32
  /** Options for the static build */
@@ -400,7 +400,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
400
400
  globalRoutePriority: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
401
401
  rewriting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
402
402
  env: z.ZodOptional<z.ZodObject<{
403
- schema: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
403
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
404
404
  context: z.ZodLiteral<"client">;
405
405
  access: z.ZodLiteral<"public">;
406
406
  }, "strip", z.ZodTypeAny, {
@@ -524,83 +524,7 @@ export declare const AstroConfigSchema: z.ZodObject<{
524
524
  values: string[];
525
525
  default?: string | undefined;
526
526
  optional?: boolean | undefined;
527
- }>]>>>, Record<string, ({
528
- context: "client";
529
- access: "public";
530
- } | {
531
- context: "server";
532
- access: "public";
533
- } | {
534
- context: "server";
535
- access: "secret";
536
- }) & ({
537
- type: "string";
538
- length?: number | undefined;
539
- includes?: string | undefined;
540
- endsWith?: string | undefined;
541
- startsWith?: string | undefined;
542
- default?: string | undefined;
543
- url?: boolean | undefined;
544
- optional?: boolean | undefined;
545
- min?: number | undefined;
546
- max?: number | undefined;
547
- } | {
548
- type: "number";
549
- default?: number | undefined;
550
- optional?: boolean | undefined;
551
- min?: number | undefined;
552
- max?: number | undefined;
553
- gt?: number | undefined;
554
- lt?: number | undefined;
555
- int?: boolean | undefined;
556
- } | {
557
- type: "boolean";
558
- default?: boolean | undefined;
559
- optional?: boolean | undefined;
560
- } | {
561
- type: "enum";
562
- values: string[];
563
- default?: string | undefined;
564
- optional?: boolean | undefined;
565
- })>, Record<string, ({
566
- context: "client";
567
- access: "public";
568
- } | {
569
- context: "server";
570
- access: "public";
571
- } | {
572
- context: "server";
573
- access: "secret";
574
- }) & ({
575
- type: "string";
576
- length?: number | undefined;
577
- includes?: string | undefined;
578
- endsWith?: string | undefined;
579
- startsWith?: string | undefined;
580
- default?: string | undefined;
581
- url?: boolean | undefined;
582
- optional?: boolean | undefined;
583
- min?: number | undefined;
584
- max?: number | undefined;
585
- } | {
586
- type: "number";
587
- default?: number | undefined;
588
- optional?: boolean | undefined;
589
- min?: number | undefined;
590
- max?: number | undefined;
591
- gt?: number | undefined;
592
- lt?: number | undefined;
593
- int?: boolean | undefined;
594
- } | {
595
- type: "boolean";
596
- default?: boolean | undefined;
597
- optional?: boolean | undefined;
598
- } | {
599
- type: "enum";
600
- values: string[];
601
- default?: string | undefined;
602
- optional?: boolean | undefined;
603
- })>>>;
527
+ }>]>>>>;
604
528
  }, "strict", z.ZodTypeAny, {
605
529
  schema?: Record<string, ({
606
530
  context: "client";
@@ -1410,7 +1334,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1410
1334
  globalRoutePriority: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1411
1335
  rewriting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1412
1336
  env: z.ZodOptional<z.ZodObject<{
1413
- schema: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
1337
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
1414
1338
  context: z.ZodLiteral<"client">;
1415
1339
  access: z.ZodLiteral<"public">;
1416
1340
  }, "strip", z.ZodTypeAny, {
@@ -1534,83 +1458,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1534
1458
  values: string[];
1535
1459
  default?: string | undefined;
1536
1460
  optional?: boolean | undefined;
1537
- }>]>>>, Record<string, ({
1538
- context: "client";
1539
- access: "public";
1540
- } | {
1541
- context: "server";
1542
- access: "public";
1543
- } | {
1544
- context: "server";
1545
- access: "secret";
1546
- }) & ({
1547
- type: "string";
1548
- length?: number | undefined;
1549
- includes?: string | undefined;
1550
- endsWith?: string | undefined;
1551
- startsWith?: string | undefined;
1552
- default?: string | undefined;
1553
- url?: boolean | undefined;
1554
- optional?: boolean | undefined;
1555
- min?: number | undefined;
1556
- max?: number | undefined;
1557
- } | {
1558
- type: "number";
1559
- default?: number | undefined;
1560
- optional?: boolean | undefined;
1561
- min?: number | undefined;
1562
- max?: number | undefined;
1563
- gt?: number | undefined;
1564
- lt?: number | undefined;
1565
- int?: boolean | undefined;
1566
- } | {
1567
- type: "boolean";
1568
- default?: boolean | undefined;
1569
- optional?: boolean | undefined;
1570
- } | {
1571
- type: "enum";
1572
- values: string[];
1573
- default?: string | undefined;
1574
- optional?: boolean | undefined;
1575
- })>, Record<string, ({
1576
- context: "client";
1577
- access: "public";
1578
- } | {
1579
- context: "server";
1580
- access: "public";
1581
- } | {
1582
- context: "server";
1583
- access: "secret";
1584
- }) & ({
1585
- type: "string";
1586
- length?: number | undefined;
1587
- includes?: string | undefined;
1588
- endsWith?: string | undefined;
1589
- startsWith?: string | undefined;
1590
- default?: string | undefined;
1591
- url?: boolean | undefined;
1592
- optional?: boolean | undefined;
1593
- min?: number | undefined;
1594
- max?: number | undefined;
1595
- } | {
1596
- type: "number";
1597
- default?: number | undefined;
1598
- optional?: boolean | undefined;
1599
- min?: number | undefined;
1600
- max?: number | undefined;
1601
- gt?: number | undefined;
1602
- lt?: number | undefined;
1603
- int?: boolean | undefined;
1604
- } | {
1605
- type: "boolean";
1606
- default?: boolean | undefined;
1607
- optional?: boolean | undefined;
1608
- } | {
1609
- type: "enum";
1610
- values: string[];
1611
- default?: string | undefined;
1612
- optional?: boolean | undefined;
1613
- })>>>;
1461
+ }>]>>>>;
1614
1462
  }, "strict", z.ZodTypeAny, {
1615
1463
  schema?: Record<string, ({
1616
1464
  context: "client";
@@ -27,6 +27,10 @@ export declare const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
27
27
  * The value of the `component` field of the default 404 page, which is used when there is no user-provided 404.astro page.
28
28
  */
29
29
  export declare const DEFAULT_404_COMPONENT = "astro-default-404.astro";
30
+ /**
31
+ * The value of the `component` field of the default 500 page, which is used when there is no user-provided 404.astro page.
32
+ */
33
+ export declare const DEFAULT_500_COMPONENT = "astro-default-500.astro";
30
34
  /**
31
35
  * A response with one of these status codes will be rewritten
32
36
  * with the result of rendering the respective error page.
@@ -1,7 +1,8 @@
1
- const ASTRO_VERSION = "4.10.2";
1
+ const ASTRO_VERSION = "4.11.0";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404.astro";
5
+ const DEFAULT_500_COMPONENT = "astro-default-500.astro";
5
6
  const REROUTABLE_STATUS_CODES = [404, 500];
6
7
  const clientAddressSymbol = Symbol.for("astro.clientAddress");
7
8
  const clientLocalsSymbol = Symbol.for("astro.locals");
@@ -18,6 +19,7 @@ const MIDDLEWARE_PATH_SEGMENT_NAME = "middleware";
18
19
  export {
19
20
  ASTRO_VERSION,
20
21
  DEFAULT_404_COMPONENT,
22
+ DEFAULT_500_COMPONENT,
21
23
  MIDDLEWARE_PATH_SEGMENT_NAME,
22
24
  REROUTABLE_STATUS_CODES,
23
25
  REROUTE_DIRECTIVE_HEADER,
@@ -58,6 +58,11 @@ declare class AstroCookies implements AstroCookiesInterface {
58
58
  * @param options Options for the cookie, such as the path and security settings.
59
59
  */
60
60
  set(key: string, value: string | Record<string, any>, options?: AstroCookieSetOptions): void;
61
+ /**
62
+ * Merges a new AstroCookies instance into the current instance. Any new cookies
63
+ * will be added to the current instance, overwriting any existing cookies with the same name.
64
+ */
65
+ merge(cookies: AstroCookies): void;
61
66
  /**
62
67
  * Astro.cookies.header() returns an iterator for the cookies that have previously
63
68
  * been set by either Astro.cookies.set() or Astro.cookies.delete().
@@ -136,6 +136,18 @@ class AstroCookies {
136
136
  });
137
137
  }
138
138
  }
139
+ /**
140
+ * Merges a new AstroCookies instance into the current instance. Any new cookies
141
+ * will be added to the current instance, overwriting any existing cookies with the same name.
142
+ */
143
+ merge(cookies) {
144
+ const outgoing = cookies.#outgoing;
145
+ if (outgoing) {
146
+ for (const [key, value] of outgoing) {
147
+ this.#ensureOutgoingMap().set(key, value);
148
+ }
149
+ }
150
+ }
139
151
  /**
140
152
  * Astro.cookies.header() returns an iterator for the cookies that have previously
141
153
  * been set by either Astro.cookies.set() or Astro.cookies.delete().
@@ -1,4 +1,5 @@
1
1
  import { AstroCookies } from './cookies.js';
2
2
  export declare function attachCookiesToResponse(response: Response, cookies: AstroCookies): void;
3
3
  export declare function responseHasCookies(response: Response): boolean;
4
+ export declare function getFromResponse(response: Response): AstroCookies | undefined;
4
5
  export declare function getSetCookiesFromResponse(response: Response): Generator<string, string[]>;
@@ -26,6 +26,7 @@ function* getSetCookiesFromResponse(response) {
26
26
  }
27
27
  export {
28
28
  attachCookiesToResponse,
29
+ getFromResponse,
29
30
  getSetCookiesFromResponse,
30
31
  responseHasCookies
31
32
  };
@@ -5,6 +5,7 @@ import * as vite from "vite";
5
5
  import { crawlFrameworkPkgs } from "vitefu";
6
6
  import { getAssetsPrefix } from "../assets/utils/getAssetsPrefix.js";
7
7
  import astroAssetsPlugin from "../assets/vite-plugin-assets.js";
8
+ import astroContainer from "../container/vite-plugin-container.js";
8
9
  import {
9
10
  astroContentAssetPropagationPlugin,
10
11
  astroContentImportPlugin,
@@ -122,7 +123,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
122
123
  astroScannerPlugin({ settings, logger }),
123
124
  astroInjectEnvTsPlugin({ settings, logger, fs }),
124
125
  astroContentVirtualModPlugin({ fs, settings }),
125
- astroContentImportPlugin({ fs, settings }),
126
+ astroContentImportPlugin({ fs, settings, logger }),
126
127
  astroContentAssetPropagationPlugin({ mode, settings }),
127
128
  vitePluginMiddleware({ settings }),
128
129
  vitePluginSSRManifest(),
@@ -131,7 +132,8 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
131
132
  astroTransitions({ settings }),
132
133
  astroDevToolbar({ settings, logger }),
133
134
  vitePluginFileURL({}),
134
- astroInternationalization({ settings })
135
+ astroInternationalization({ settings }),
136
+ astroContainer()
135
137
  ],
136
138
  publicDir: fileURLToPath(settings.config.publicDir),
137
139
  root: fileURLToPath(settings.config.root),
@@ -144,10 +146,6 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
144
146
  server: {
145
147
  hmr: process.env.NODE_ENV === "test" || process.env.NODE_ENV === "production" ? false : void 0,
146
148
  // disable HMR for test
147
- // handle Vite URLs
148
- proxy: {
149
- // add proxies here
150
- },
151
149
  watch: {
152
150
  // Prevent watching during the build to speed it up
153
151
  ignored: mode === "build" ? ["**"] : void 0
@@ -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.10.2";
22
+ const currentVersion = "4.11.0";
23
23
  const isPrerelease = currentVersion.includes("-");
24
24
  if (!isPrerelease) {
25
25
  try {
@@ -588,6 +588,26 @@ export declare const ExpectedImageOptions: {
588
588
  title: string;
589
589
  message: (options: string) => string;
590
590
  };
591
+ /**
592
+ * @docs
593
+ * @see
594
+ * - [Images](https://docs.astro.build/en/guides/images/)
595
+ * @description
596
+ * An ESM-imported image cannot be passed directly to `getImage()`. Instead, pass an object with the image in the `src` property.
597
+ *
598
+ * ```diff
599
+ * import { getImage } from "astro:assets";
600
+ * import myImage from "../assets/my_image.png";
601
+ * - const optimizedImage = await getImage( myImage );
602
+ * + const optimizedImage = await getImage({ src: myImage });
603
+ * ```
604
+ */
605
+ export declare const ExpectedNotESMImage: {
606
+ name: string;
607
+ title: string;
608
+ message: string;
609
+ hint: string;
610
+ };
591
611
  /**
592
612
  * @docs
593
613
  * @see
@@ -1010,17 +1030,6 @@ export declare const RewriteEncounteredAnError: {
1010
1030
  title: string;
1011
1031
  message: (route: string, stack?: string) => string;
1012
1032
  };
1013
- /**
1014
- * @docs
1015
- * @description
1016
- *
1017
- * The user tried to rewrite a 404 page inside a static page.
1018
- */
1019
- export declare const InvalidRewrite404: {
1020
- name: string;
1021
- title: string;
1022
- message: string;
1023
- };
1024
1033
  /**
1025
1034
  * @docs
1026
1035
  * @description
@@ -1129,6 +1138,26 @@ export declare const ServerOnlyModule: {
1129
1138
  title: string;
1130
1139
  message: (name: string) => string;
1131
1140
  };
1141
+ /**
1142
+ * @docs
1143
+ * @description
1144
+ * `Astro.rewrite()` cannot be used if the request body has already been read. If you need to read the body, first clone the request. For example:
1145
+ *
1146
+ * ```js
1147
+ * const data = await Astro.request.clone().formData();
1148
+ *
1149
+ * Astro.rewrite("/target")
1150
+ * ```
1151
+ *
1152
+ * @see
1153
+ * - [Request.clone()](https://developer.mozilla.org/en-US/docs/Web/API/Request/clone)
1154
+ * - [Astro.rewrite](https://docs.astro.build/en/reference/configuration-reference/#experimentalrewriting)
1155
+ */
1156
+ export declare const RewriteWithBodyUsed: {
1157
+ name: string;
1158
+ title: string;
1159
+ message: string;
1160
+ };
1132
1161
  /**
1133
1162
  * @docs
1134
1163
  * @kind heading
@@ -209,6 +209,12 @@ const ExpectedImageOptions = {
209
209
  title: "Expected image options.",
210
210
  message: (options) => `Expected getImage() parameter to be an object. Received \`${options}\`.`
211
211
  };
212
+ const ExpectedNotESMImage = {
213
+ name: "ExpectedNotESMImage",
214
+ title: "Expected image options, not an ESM-imported image.",
215
+ message: "An ESM-imported image cannot be passed directly to `getImage()`. Instead, pass an object with the image in the `src` property.",
216
+ hint: "Try changing `getImage(myImage)` to `getImage({ src: myImage })`"
217
+ };
212
218
  const IncompatibleDescriptorOptions = {
213
219
  name: "IncompatibleDescriptorOptions",
214
220
  title: "Cannot set both `densities` and `widths`",
@@ -361,11 +367,6 @@ const RewriteEncounteredAnError = {
361
367
  title: "Astro couldn't find the route to rewrite, or if was found but it emitted an error during the rendering phase.",
362
368
  message: (route, stack) => `The route ${route} that you tried to render doesn't exist, or it emitted an error during the rendering phase. ${stack ? stack : ""}.`
363
369
  };
364
- const InvalidRewrite404 = {
365
- name: "InvalidRewrite404",
366
- title: "You attempted to rewrite a 404 inside a static page, and this isn't allowed.",
367
- message: "Rewriting a 404 is only allowed inside on-demand pages."
368
- };
369
370
  const CantRenderPage = {
370
371
  name: "CantRenderPage",
371
372
  title: "Astro can't render the route.",
@@ -418,6 +419,11 @@ const ServerOnlyModule = {
418
419
  title: "Module is only available server-side",
419
420
  message: (name) => `The "${name}" module is only available server-side.`
420
421
  };
422
+ const RewriteWithBodyUsed = {
423
+ name: "RewriteWithBodyUsed",
424
+ title: "Cannot use Astro.rewrite after the request body has been read",
425
+ message: "Astro.rewrite() cannot be used if the request body has already been read. If you need to read the body, first clone the request."
426
+ };
421
427
  const UnknownCSSError = {
422
428
  name: "UnknownCSSError",
423
429
  title: "Unknown CSS Error."
@@ -576,6 +582,7 @@ export {
576
582
  EnvUnsupportedGetSecret,
577
583
  ExpectedImage,
578
584
  ExpectedImageOptions,
585
+ ExpectedNotESMImage,
579
586
  FailedToFetchRemoteImageDimensions,
580
587
  FailedToFindPageMapSSR,
581
588
  FailedToLoadModuleSSR,
@@ -599,7 +606,6 @@ export {
599
606
  InvalidGlob,
600
607
  InvalidImageService,
601
608
  InvalidPrerenderExport,
602
- InvalidRewrite404,
603
609
  LocalImageUsedWrongly,
604
610
  LocalsNotAnObject,
605
611
  MarkdownFrontmatterParseError,
@@ -631,6 +637,7 @@ export {
631
637
  ReservedSlotName,
632
638
  ResponseSentError,
633
639
  RewriteEncounteredAnError,
640
+ RewriteWithBodyUsed,
634
641
  RouteNotFound,
635
642
  ServerOnlyModule,
636
643
  StaticClientAddressNotAvailable,
@@ -37,7 +37,7 @@ function serverStart({
37
37
  host,
38
38
  base
39
39
  }) {
40
- const version = "4.10.2";
40
+ const version = "4.11.0";
41
41
  const localPrefix = `${dim("\u2503")} Local `;
42
42
  const networkPrefix = `${dim("\u2503")} Network `;
43
43
  const emptyPrefix = " ".repeat(11);
@@ -269,7 +269,7 @@ function printHelp({
269
269
  message.push(
270
270
  linebreak(),
271
271
  ` ${bgGreen(black(` ${commandName} `))} ${green(
272
- `v${"4.10.2"}`
272
+ `v${"4.11.0"}`
273
273
  )} ${headline}`
274
274
  );
275
275
  }
@@ -29,7 +29,7 @@ export declare class RenderContext {
29
29
  * A safety net in case of loops
30
30
  */
31
31
  counter: number;
32
- static create({ locals, middleware, pathname, pipeline, request, routeData, status, }: Pick<RenderContext, 'pathname' | 'pipeline' | 'request' | 'routeData'> & Partial<Pick<RenderContext, 'locals' | 'middleware' | 'status'>>): RenderContext;
32
+ static create({ locals, middleware, pathname, pipeline, request, routeData, status, props, }: Pick<RenderContext, 'pathname' | 'pipeline' | 'request' | 'routeData'> & Partial<Pick<RenderContext, 'locals' | 'middleware' | 'status' | 'props'>>): RenderContext;
33
33
  /**
34
34
  * The main function of the RenderContext.
35
35
  *