astro 2.0.17 → 2.1.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 (142) hide show
  1. package/README.md +3 -3
  2. package/client-base.d.ts +27 -0
  3. package/client-image.d.ts +48 -0
  4. package/components/Image.astro +28 -0
  5. package/dist/@types/astro.d.ts +101 -1
  6. package/dist/assets/consts.d.ts +4 -0
  7. package/dist/assets/consts.js +20 -0
  8. package/dist/assets/image-endpoint.d.ts +5 -0
  9. package/dist/assets/image-endpoint.js +50 -0
  10. package/dist/assets/index.d.ts +4 -0
  11. package/dist/assets/index.js +10 -0
  12. package/dist/assets/internal.d.ts +36 -0
  13. package/dist/assets/internal.js +70 -0
  14. package/dist/assets/services/service.d.ts +71 -0
  15. package/dist/assets/services/service.js +88 -0
  16. package/dist/assets/services/sharp.d.ts +3 -0
  17. package/dist/assets/services/sharp.js +57 -0
  18. package/dist/assets/services/squoosh.d.ts +3 -0
  19. package/dist/assets/services/squoosh.js +56 -0
  20. package/dist/assets/services/vendor/squoosh/avif/avif_enc.d.js +11 -0
  21. package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.d.ts +2 -0
  22. package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +1628 -0
  23. package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm +0 -0
  24. package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.d.ts +2 -0
  25. package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +1850 -0
  26. package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm +0 -0
  27. package/dist/assets/services/vendor/squoosh/codecs.d.ts +158 -0
  28. package/dist/assets/services/vendor/squoosh/codecs.js +284 -0
  29. package/dist/assets/services/vendor/squoosh/copy-wasm.d.ts +1 -0
  30. package/dist/assets/services/vendor/squoosh/copy-wasm.js +24 -0
  31. package/dist/assets/services/vendor/squoosh/emscripten-types.d.js +0 -0
  32. package/dist/assets/services/vendor/squoosh/emscripten-utils.d.ts +9 -0
  33. package/dist/assets/services/vendor/squoosh/emscripten-utils.js +33 -0
  34. package/dist/assets/services/vendor/squoosh/image-pool.d.ts +4 -0
  35. package/dist/assets/services/vendor/squoosh/image-pool.js +94 -0
  36. package/dist/assets/services/vendor/squoosh/image.d.ts +14 -0
  37. package/dist/assets/services/vendor/squoosh/image.js +27 -0
  38. package/dist/assets/services/vendor/squoosh/image_data.d.ts +9 -0
  39. package/dist/assets/services/vendor/squoosh/image_data.js +22 -0
  40. package/dist/assets/services/vendor/squoosh/impl.d.ts +22 -0
  41. package/dist/assets/services/vendor/squoosh/impl.js +110 -0
  42. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_enc.d.js +11 -0
  43. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.d.ts +2 -0
  44. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +1631 -0
  45. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.wasm +0 -0
  46. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.d.ts +2 -0
  47. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +1737 -0
  48. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.wasm +0 -0
  49. package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng.d.ts +10 -0
  50. package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng.js +89 -0
  51. package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm +0 -0
  52. package/dist/assets/services/vendor/squoosh/png/squoosh_png.d.ts +15 -0
  53. package/dist/assets/services/vendor/squoosh/png/squoosh_png.js +138 -0
  54. package/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm +0 -0
  55. package/dist/assets/services/vendor/squoosh/resize/squoosh_resize.d.ts +15 -0
  56. package/dist/assets/services/vendor/squoosh/resize/squoosh_resize.js +95 -0
  57. package/dist/assets/services/vendor/squoosh/resize/squoosh_resize_bg.wasm +0 -0
  58. package/dist/assets/services/vendor/squoosh/rotate/rotate.wasm +0 -0
  59. package/dist/assets/services/vendor/squoosh/utils/execOnce.d.ts +1 -0
  60. package/dist/assets/services/vendor/squoosh/utils/execOnce.js +14 -0
  61. package/dist/assets/services/vendor/squoosh/utils/workerPool.d.ts +22 -0
  62. package/dist/assets/services/vendor/squoosh/utils/workerPool.js +95 -0
  63. package/dist/assets/services/vendor/squoosh/webp/webp_enc.d.js +4 -0
  64. package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.d.ts +2 -0
  65. package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +1473 -0
  66. package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm +0 -0
  67. package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.d.ts +2 -0
  68. package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +1640 -0
  69. package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm +0 -0
  70. package/dist/assets/types.d.ts +119 -0
  71. package/dist/assets/types.js +0 -0
  72. package/dist/assets/utils/etag.d.ts +12 -0
  73. package/dist/assets/utils/etag.js +28 -0
  74. package/dist/assets/utils/metadata.d.ts +6 -0
  75. package/dist/assets/utils/metadata.js +30 -0
  76. package/dist/assets/utils/queryParams.d.ts +2 -0
  77. package/dist/assets/utils/queryParams.js +16 -0
  78. package/dist/assets/utils/transformToPath.d.ts +2 -0
  79. package/dist/assets/utils/transformToPath.js +17 -0
  80. package/dist/assets/vite-plugin-assets.d.ts +5 -0
  81. package/dist/assets/vite-plugin-assets.js +187 -0
  82. package/dist/cli/check/index.d.ts +81 -2
  83. package/dist/cli/check/index.js +190 -44
  84. package/dist/cli/index.js +39 -16
  85. package/dist/cli/telemetry.js +1 -1
  86. package/dist/content/consts.d.ts +0 -1
  87. package/dist/content/consts.js +1 -3
  88. package/dist/content/internal.d.ts +7 -0
  89. package/dist/content/internal.js +27 -5
  90. package/dist/content/template/virtual-mod.d.mts +1 -0
  91. package/dist/content/types-generator.js +25 -10
  92. package/dist/content/utils.d.ts +16 -13
  93. package/dist/content/utils.js +29 -6
  94. package/dist/content/vite-plugin-content-assets.d.ts +3 -1
  95. package/dist/content/vite-plugin-content-assets.js +10 -6
  96. package/dist/content/vite-plugin-content-imports.js +54 -27
  97. package/dist/content/vite-plugin-content-virtual-mod.js +7 -4
  98. package/dist/core/add/index.js +2 -1
  99. package/dist/core/app/index.js +104 -134
  100. package/dist/core/build/generate.js +30 -5
  101. package/dist/core/build/index.d.ts +2 -0
  102. package/dist/core/build/index.js +16 -0
  103. package/dist/core/build/plugins/plugin-ssr.js +3 -5
  104. package/dist/core/config/config.js +2 -1
  105. package/dist/core/config/schema.d.ts +64 -8
  106. package/dist/core/config/schema.js +17 -3
  107. package/dist/core/config/settings.js +4 -2
  108. package/dist/core/constants.js +1 -1
  109. package/dist/core/cookies/cookies.js +36 -68
  110. package/dist/core/create-vite.js +5 -1
  111. package/dist/core/dev/dev.d.ts +2 -2
  112. package/dist/core/dev/dev.js +24 -4
  113. package/dist/core/errors/dev/vite.js +6 -1
  114. package/dist/core/errors/errors-data.d.ts +17 -1
  115. package/dist/core/errors/errors-data.js +16 -0
  116. package/dist/core/messages.js +2 -2
  117. package/dist/core/path.d.ts +1 -0
  118. package/dist/core/path.js +4 -0
  119. package/dist/core/preview/index.d.ts +3 -1
  120. package/dist/core/preview/index.js +16 -1
  121. package/dist/core/render/dev/css.js +2 -2
  122. package/dist/core/render/dev/environment.js +1 -5
  123. package/dist/core/render/environment.js +1 -2
  124. package/dist/core/render/result.js +13 -35
  125. package/dist/core/sync/index.d.ts +18 -5
  126. package/dist/core/sync/index.js +13 -1
  127. package/dist/integrations/index.js +12 -1
  128. package/dist/runtime/server/render/component.js +1 -1
  129. package/dist/runtime/server/response.js +11 -30
  130. package/dist/vite-plugin-astro-postprocess/index.js +1 -1
  131. package/dist/vite-plugin-astro-server/plugin.js +1 -1
  132. package/dist/vite-plugin-env/index.js +4 -4
  133. package/dist/vite-plugin-inject-env-ts/index.js +17 -2
  134. package/dist/vite-plugin-markdown/content-entry-type.d.ts +7 -0
  135. package/dist/vite-plugin-markdown/content-entry-type.js +39 -0
  136. package/dist/vite-plugin-markdown/index.js +70 -4
  137. package/dist/vite-plugin-ssr-manifest/index.d.ts +2 -0
  138. package/dist/vite-plugin-ssr-manifest/index.js +25 -0
  139. package/package.json +26 -9
  140. package/src/content/template/types.d.ts +18 -9
  141. package/src/content/template/virtual-mod.mjs +6 -0
  142. package/tsconfigs/base.json +6 -1
@@ -3,7 +3,10 @@ import * as colors from "kleur/colors";
3
3
  import { bgGreen, black, cyan, dim, green, magenta } from "kleur/colors";
4
4
  import npath from "path";
5
5
  import { fileURLToPath } from "url";
6
- import { getContentPaths } from "../../content/index.js";
6
+ import {
7
+ generateImage as generateImageInternal,
8
+ getStaticImageList
9
+ } from "../../assets/internal.js";
7
10
  import { hasPrerenderedPages } from "../../core/build/internal.js";
8
11
  import {
9
12
  prependForwardSlash,
@@ -71,6 +74,14 @@ ${bgGreen(black(` ${verb} static routes `))}`);
71
74
  await generatePage(opts, internals, pageData, ssrEntry, builtPaths);
72
75
  }
73
76
  }
77
+ if (opts.settings.config.experimental.assets) {
78
+ info(opts.logging, null, `
79
+ ${bgGreen(black(` generating optimized images `))}`);
80
+ for (const imageData of getStaticImageList()) {
81
+ await generateImage(opts, imageData[0], imageData[1]);
82
+ }
83
+ delete globalThis.astroAsset.addStaticImage;
84
+ }
74
85
  await runHookBuildGenerated({
75
86
  config: opts.settings.config,
76
87
  buildConfig: opts.buildConfig,
@@ -79,6 +90,23 @@ ${bgGreen(black(` ${verb} static routes `))}`);
79
90
  info(opts.logging, null, dim(`Completed in ${getTimeStat(timer, performance.now())}.
80
91
  `));
81
92
  }
93
+ async function generateImage(opts, transform, path) {
94
+ let timeStart = performance.now();
95
+ const generationData = await generateImageInternal(opts, transform, path);
96
+ if (!generationData) {
97
+ return;
98
+ }
99
+ const timeEnd = performance.now();
100
+ const timeChange = getTimeStat(timeStart, timeEnd);
101
+ const timeIncrease = `(+${timeChange})`;
102
+ info(
103
+ opts.logging,
104
+ null,
105
+ ` ${green("\u25B6")} ${path} ${dim(
106
+ `(before: ${generationData.weight.before}kb, after: ${generationData.weight.after}kb)`
107
+ )} ${dim(timeIncrease)}`
108
+ );
109
+ }
82
110
  async function generatePage(opts, internals, pageData, ssrEntry, builtPaths) {
83
111
  var _a;
84
112
  let timeStart = performance.now();
@@ -237,10 +265,7 @@ async function generatePath(pathname, opts, gopts) {
237
265
  const env = createEnvironment({
238
266
  adapterName: void 0,
239
267
  logging,
240
- markdown: {
241
- ...settings.config.markdown,
242
- contentDir: getContentPaths(settings.config).contentDir
243
- },
268
+ markdown: settings.config.markdown,
244
269
  mode: opts.mode,
245
270
  renderers,
246
271
  async resolve(specifier) {
@@ -1,6 +1,7 @@
1
1
  import type { AstroTelemetry } from '@astrojs/telemetry';
2
2
  import type { AstroSettings, RuntimeMode } from '../../@types/astro';
3
3
  import type { LogOptions } from '../logger/core';
4
+ import yargs from 'yargs-parser';
4
5
  export interface BuildOptions {
5
6
  mode?: RuntimeMode;
6
7
  logging: LogOptions;
@@ -10,6 +11,7 @@ export interface BuildOptions {
10
11
  * building once, but may cause a performance hit if building multiple times in a row.
11
12
  */
12
13
  teardownCompiler?: boolean;
14
+ flags?: yargs.Arguments;
13
15
  }
14
16
  /** `astro build` */
15
17
  export default function build(settings: AstroSettings, options: BuildOptions): Promise<void>;
@@ -9,6 +9,7 @@ import {
9
9
  } from "../../integrations/index.js";
10
10
  import { createVite } from "../create-vite.js";
11
11
  import { debug, info, levels, timerMessage } from "../logger/core.js";
12
+ import { printHelp } from "../messages.js";
12
13
  import { apply as applyPolyfill } from "../polyfill.js";
13
14
  import { RouteCache } from "../render/route-cache.js";
14
15
  import { createRouteManifest } from "../routing/index.js";
@@ -16,7 +17,22 @@ import { collectPagesData } from "./page-data.js";
16
17
  import { staticBuild, viteBuild } from "./static-build.js";
17
18
  import { getTimeStat } from "./util.js";
18
19
  async function build(settings, options) {
20
+ var _a, _b;
19
21
  applyPolyfill();
22
+ if (((_a = options.flags) == null ? void 0 : _a.help) || ((_b = options.flags) == null ? void 0 : _b.h)) {
23
+ printHelp({
24
+ commandName: "astro build",
25
+ usage: "[...flags]",
26
+ tables: {
27
+ Flags: [
28
+ ["--drafts", `Include Markdown draft pages in the build.`],
29
+ ["--help (-h)", "See all available flags."]
30
+ ]
31
+ },
32
+ description: `Builds your site for deployment.`
33
+ });
34
+ return;
35
+ }
20
36
  const builder = new AstroBuilder(settings, options);
21
37
  await builder.run();
22
38
  }
@@ -1,6 +1,5 @@
1
1
  import glob from "fast-glob";
2
2
  import { fileURLToPath } from "url";
3
- import { getContentPaths } from "../../../content/index.js";
4
3
  import { runHookBuildSsr } from "../../../integrations/index.js";
5
4
  import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from "../../../vite-plugin-scripts/index.js";
6
5
  import { pagesVirtualModuleId } from "../../app/index.js";
@@ -30,10 +29,12 @@ function vitePluginSSR(internals, adapter) {
30
29
  return `import * as adapter from '${adapter.serverEntrypoint}';
31
30
  import * as _main from '${pagesVirtualModuleId}';
32
31
  import { deserializeManifest as _deserializeManifest } from 'astro/app';
32
+ import { _privateSetManifestDontUseThis } from 'astro:ssr-manifest';
33
33
  const _manifest = Object.assign(_deserializeManifest('${manifestReplace}'), {
34
34
  pageMap: _main.pageMap,
35
35
  renderers: _main.renderers
36
36
  });
37
+ _privateSetManifestDontUseThis(_manifest);
37
38
  const _args = ${adapter.args ? JSON.stringify(adapter.args) : "undefined"};
38
39
  export * from '${pagesVirtualModuleId}';
39
40
  ${adapter.exports ? `const _exports = adapter.createExports(_manifest, _args);
@@ -165,10 +166,7 @@ function buildManifest(opts, internals, staticFiles) {
165
166
  routes,
166
167
  site: settings.config.site,
167
168
  base: settings.config.base,
168
- markdown: {
169
- ...settings.config.markdown,
170
- contentDir: getContentPaths(settings.config).contentDir
171
- },
169
+ markdown: settings.config.markdown,
172
170
  pageMap: null,
173
171
  propagation: Array.from(internals.propagation),
174
172
  renderers: [],
@@ -73,7 +73,8 @@ function resolveFlags(flags) {
73
73
  port: typeof flags.port === "number" ? flags.port : void 0,
74
74
  config: typeof flags.config === "string" ? flags.config : void 0,
75
75
  host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
76
- drafts: typeof flags.drafts === "boolean" ? flags.drafts : void 0
76
+ drafts: typeof flags.drafts === "boolean" ? flags.drafts : void 0,
77
+ experimentalAssets: typeof flags.experimentalAssets === "boolean" ? flags.experimentalAssets : void 0
77
78
  };
78
79
  }
79
80
  function resolveRoot(cwd) {
@@ -72,6 +72,13 @@ export declare const AstroConfigSchema: z.ZodObject<{
72
72
  host: string | boolean;
73
73
  port: number;
74
74
  }, unknown>;
75
+ image: z.ZodDefault<z.ZodObject<{
76
+ service: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodIntersection<z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>]>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
79
+ }, {
80
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
81
+ }>>;
75
82
  markdown: z.ZodDefault<z.ZodObject<{
76
83
  drafts: z.ZodDefault<z.ZodBoolean>;
77
84
  syntaxHighlight: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"shiki">, z.ZodLiteral<"prism">, z.ZodLiteral<false>]>>;
@@ -121,7 +128,13 @@ export declare const AstroConfigSchema: z.ZodObject<{
121
128
  smartypants?: boolean | undefined;
122
129
  }>>;
123
130
  vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
124
- experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
131
+ experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{
132
+ assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ assets: boolean;
135
+ }, {
136
+ assets?: boolean | undefined;
137
+ }>>>;
125
138
  legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
126
139
  }, "strip", z.ZodTypeAny, {
127
140
  site?: string | undefined;
@@ -166,8 +179,13 @@ export declare const AstroConfigSchema: z.ZodObject<{
166
179
  client: URL;
167
180
  serverEntry: string;
168
181
  };
182
+ image: {
183
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
184
+ };
169
185
  vite: ViteUserConfig;
170
- experimental: {};
186
+ experimental: {
187
+ assets: boolean;
188
+ };
171
189
  legacy: {};
172
190
  }, {
173
191
  site?: string | undefined;
@@ -205,8 +223,13 @@ export declare const AstroConfigSchema: z.ZodObject<{
205
223
  client?: string | undefined;
206
224
  serverEntry?: string | undefined;
207
225
  } | undefined;
226
+ image?: {
227
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
228
+ } | undefined;
208
229
  vite?: ViteUserConfig | undefined;
209
- experimental?: {} | undefined;
230
+ experimental?: {
231
+ assets?: boolean | undefined;
232
+ } | undefined;
210
233
  legacy?: {} | undefined;
211
234
  }>;
212
235
  export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL): z.ZodEffects<z.ZodObject<{
@@ -285,8 +308,21 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
285
308
  name: string;
286
309
  hooks: {};
287
310
  }[], unknown>;
311
+ image: z.ZodDefault<z.ZodObject<{
312
+ service: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodIntersection<z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>]>;
313
+ }, "strip", z.ZodTypeAny, {
314
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
315
+ }, {
316
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
317
+ }>>;
288
318
  vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
289
- experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
319
+ experimental: z.ZodDefault<z.ZodOptional<z.ZodObject<{
320
+ assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
321
+ }, "strip", z.ZodTypeAny, {
322
+ assets: boolean;
323
+ }, {
324
+ assets?: boolean | undefined;
325
+ }>>>;
290
326
  legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
291
327
  root: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
292
328
  srcDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
@@ -376,8 +412,13 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
376
412
  client: URL;
377
413
  serverEntry: string;
378
414
  };
415
+ image: {
416
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
417
+ };
379
418
  vite: ViteUserConfig;
380
- experimental: {};
419
+ experimental: {
420
+ assets: boolean;
421
+ };
381
422
  legacy: {};
382
423
  }, {
383
424
  site?: string | undefined;
@@ -415,8 +456,13 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
415
456
  client?: string | undefined;
416
457
  serverEntry?: string | undefined;
417
458
  } | undefined;
459
+ image?: {
460
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
461
+ } | undefined;
418
462
  vite?: ViteUserConfig | undefined;
419
- experimental?: {} | undefined;
463
+ experimental?: {
464
+ assets?: boolean | undefined;
465
+ } | undefined;
420
466
  legacy?: {} | undefined;
421
467
  }>, {
422
468
  site?: string | undefined;
@@ -462,8 +508,13 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
462
508
  client: URL;
463
509
  serverEntry: string;
464
510
  };
511
+ image: {
512
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
513
+ };
465
514
  vite: ViteUserConfig;
466
- experimental: {};
515
+ experimental: {
516
+ assets: boolean;
517
+ };
467
518
  legacy: {};
468
519
  }, {
469
520
  site?: string | undefined;
@@ -501,7 +552,12 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL)
501
552
  client?: string | undefined;
502
553
  serverEntry?: string | undefined;
503
554
  } | undefined;
555
+ image?: {
556
+ service: "astro/assets/services/sharp" | "astro/assets/services/squoosh" | (string & {});
557
+ } | undefined;
504
558
  vite?: ViteUserConfig | undefined;
505
- experimental?: {} | undefined;
559
+ experimental?: {
560
+ assets?: boolean | undefined;
561
+ } | undefined;
506
562
  legacy?: {} | undefined;
507
563
  }>;
@@ -27,7 +27,10 @@ const ASTRO_CONFIG_DEFAULTS = {
27
27
  ...markdownConfigDefaults
28
28
  },
29
29
  vite: {},
30
- legacy: {}
30
+ legacy: {},
31
+ experimental: {
32
+ assets: false
33
+ }
31
34
  };
32
35
  const AstroConfigSchema = z.object({
33
36
  root: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.root).transform((val) => new URL(val)),
@@ -58,6 +61,15 @@ const AstroConfigSchema = z.object({
58
61
  headers: z.custom().optional()
59
62
  }).optional().default({})
60
63
  ),
64
+ image: z.object({
65
+ service: z.union([
66
+ z.literal("astro/assets/services/sharp"),
67
+ z.literal("astro/assets/services/squoosh"),
68
+ z.string().and(z.object({}))
69
+ ])
70
+ }).default({
71
+ service: "astro/assets/services/squoosh"
72
+ }),
61
73
  markdown: z.object({
62
74
  drafts: z.boolean().default(false),
63
75
  syntaxHighlight: z.union([z.literal("shiki"), z.literal("prism"), z.literal(false)]).default(ASTRO_CONFIG_DEFAULTS.markdown.syntaxHighlight),
@@ -83,7 +95,9 @@ const AstroConfigSchema = z.object({
83
95
  smartypants: z.boolean().default(ASTRO_CONFIG_DEFAULTS.markdown.smartypants)
84
96
  }).default({}),
85
97
  vite: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.vite),
86
- experimental: z.object({}).optional().default({}),
98
+ experimental: z.object({
99
+ assets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.assets)
100
+ }).optional().default({}),
87
101
  legacy: z.object({}).optional().default({})
88
102
  });
89
103
  function createRelativeSchema(cmd, fileProtocolRoot) {
@@ -131,7 +145,7 @@ function createRelativeSchema(cmd, fileProtocolRoot) {
131
145
  if (!trimmedBase.length && sitePathname && sitePathname !== "/") {
132
146
  config.base = sitePathname;
133
147
  console.warn(`The site configuration value includes a pathname of ${sitePathname} but there is no base configuration.
134
-
148
+
135
149
  A future version of Astro will stop using the site pathname when producing <link> and <script> tags. Set your site's base with the base configuration.`);
136
150
  }
137
151
  if (trimmedBase.length && config.trailingSlash === "never") {
@@ -1,17 +1,19 @@
1
1
  import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./../constants.js";
2
2
  import { fileURLToPath, pathToFileURL } from "url";
3
3
  import jsxRenderer from "../../jsx/renderer.js";
4
+ import { markdownContentEntryType } from "../../vite-plugin-markdown/content-entry-type.js";
4
5
  import { createDefaultDevConfig } from "./config.js";
5
- import { loadTSConfig } from "./tsconfig.js";
6
6
  import { AstroTimer } from "./timer.js";
7
+ import { loadTSConfig } from "./tsconfig.js";
7
8
  function createBaseSettings(config) {
8
9
  return {
9
10
  config,
10
11
  tsConfig: void 0,
11
12
  tsConfigPath: void 0,
12
13
  adapter: void 0,
13
- injectedRoutes: [],
14
+ injectedRoutes: config.experimental.assets && config.output === "server" ? [{ pattern: "/_image", entryPoint: "astro/assets/image-endpoint" }] : [],
14
15
  pageExtensions: [".astro", ".html", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
16
+ contentEntryTypes: [markdownContentEntryType],
15
17
  renderers: [jsxRenderer],
16
18
  scripts: [],
17
19
  watchFiles: [],
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.0.17";
1
+ const ASTRO_VERSION = "2.1.0";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -1,26 +1,3 @@
1
- var __accessCheck = (obj, member, msg) => {
2
- if (!member.has(obj))
3
- throw TypeError("Cannot " + msg);
4
- };
5
- var __privateGet = (obj, member, getter) => {
6
- __accessCheck(obj, member, "read from private field");
7
- return getter ? getter.call(obj) : member.get(obj);
8
- };
9
- var __privateAdd = (obj, member, value) => {
10
- if (member.has(obj))
11
- throw TypeError("Cannot add the same private member more than once");
12
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
- };
14
- var __privateSet = (obj, member, value, setter) => {
15
- __accessCheck(obj, member, "write to private field");
16
- setter ? setter.call(obj, value) : member.set(obj, value);
17
- return value;
18
- };
19
- var __privateMethod = (obj, member, method) => {
20
- __accessCheck(obj, member, "access private method");
21
- return method;
22
- };
23
- var _request, _requestValues, _outgoing, _ensureParsed, ensureParsed_fn, _ensureOutgoingMap, ensureOutgoingMap_fn, _parse, parse_fn;
24
1
  import { parse, serialize } from "cookie";
25
2
  const DELETED_EXPIRATION = new Date(0);
26
3
  const DELETED_VALUE = "deleted";
@@ -46,16 +23,13 @@ class AstroCookie {
46
23
  }
47
24
  }
48
25
  class AstroCookies {
26
+ #request;
27
+ #requestValues;
28
+ #outgoing;
49
29
  constructor(request) {
50
- __privateAdd(this, _ensureParsed);
51
- __privateAdd(this, _ensureOutgoingMap);
52
- __privateAdd(this, _parse);
53
- __privateAdd(this, _request, void 0);
54
- __privateAdd(this, _requestValues, void 0);
55
- __privateAdd(this, _outgoing, void 0);
56
- __privateSet(this, _request, request);
57
- __privateSet(this, _requestValues, null);
58
- __privateSet(this, _outgoing, null);
30
+ this.#request = request;
31
+ this.#requestValues = null;
32
+ this.#outgoing = null;
59
33
  }
60
34
  delete(key, options) {
61
35
  const serializeOptions = {
@@ -67,31 +41,31 @@ class AstroCookies {
67
41
  if (options == null ? void 0 : options.path) {
68
42
  serializeOptions.path = options.path;
69
43
  }
70
- __privateMethod(this, _ensureOutgoingMap, ensureOutgoingMap_fn).call(this).set(key, [
44
+ this.#ensureOutgoingMap().set(key, [
71
45
  DELETED_VALUE,
72
46
  serialize(key, DELETED_VALUE, serializeOptions),
73
47
  false
74
48
  ]);
75
49
  }
76
50
  get(key) {
77
- if (__privateGet(this, _outgoing) !== null && __privateGet(this, _outgoing).has(key)) {
78
- let [serializedValue, , isSetValue] = __privateGet(this, _outgoing).get(key);
51
+ if (this.#outgoing !== null && this.#outgoing.has(key)) {
52
+ let [serializedValue, , isSetValue] = this.#outgoing.get(key);
79
53
  if (isSetValue) {
80
54
  return new AstroCookie(serializedValue);
81
55
  } else {
82
56
  return new AstroCookie(void 0);
83
57
  }
84
58
  }
85
- const values = __privateMethod(this, _ensureParsed, ensureParsed_fn).call(this);
59
+ const values = this.#ensureParsed();
86
60
  const value = values[key];
87
61
  return new AstroCookie(value);
88
62
  }
89
63
  has(key) {
90
- if (__privateGet(this, _outgoing) !== null && __privateGet(this, _outgoing).has(key)) {
91
- let [, , isSetValue] = __privateGet(this, _outgoing).get(key);
64
+ if (this.#outgoing !== null && this.#outgoing.has(key)) {
65
+ let [, , isSetValue] = this.#outgoing.get(key);
92
66
  return isSetValue;
93
67
  }
94
- const values = __privateMethod(this, _ensureParsed, ensureParsed_fn).call(this);
68
+ const values = this.#ensureParsed();
95
69
  return !!values[key];
96
70
  }
97
71
  set(key, value, options) {
@@ -110,48 +84,42 @@ class AstroCookies {
110
84
  if (options) {
111
85
  Object.assign(serializeOptions, options);
112
86
  }
113
- __privateMethod(this, _ensureOutgoingMap, ensureOutgoingMap_fn).call(this).set(key, [
87
+ this.#ensureOutgoingMap().set(key, [
114
88
  serializedValue,
115
89
  serialize(key, serializedValue, serializeOptions),
116
90
  true
117
91
  ]);
118
92
  }
119
93
  *headers() {
120
- if (__privateGet(this, _outgoing) == null)
94
+ if (this.#outgoing == null)
121
95
  return;
122
- for (const [, value] of __privateGet(this, _outgoing)) {
96
+ for (const [, value] of this.#outgoing) {
123
97
  yield value[1];
124
98
  }
125
99
  }
126
- }
127
- _request = new WeakMap();
128
- _requestValues = new WeakMap();
129
- _outgoing = new WeakMap();
130
- _ensureParsed = new WeakSet();
131
- ensureParsed_fn = function() {
132
- if (!__privateGet(this, _requestValues)) {
133
- __privateMethod(this, _parse, parse_fn).call(this);
134
- }
135
- if (!__privateGet(this, _requestValues)) {
136
- __privateSet(this, _requestValues, {});
100
+ #ensureParsed() {
101
+ if (!this.#requestValues) {
102
+ this.#parse();
103
+ }
104
+ if (!this.#requestValues) {
105
+ this.#requestValues = {};
106
+ }
107
+ return this.#requestValues;
137
108
  }
138
- return __privateGet(this, _requestValues);
139
- };
140
- _ensureOutgoingMap = new WeakSet();
141
- ensureOutgoingMap_fn = function() {
142
- if (!__privateGet(this, _outgoing)) {
143
- __privateSet(this, _outgoing, /* @__PURE__ */ new Map());
109
+ #ensureOutgoingMap() {
110
+ if (!this.#outgoing) {
111
+ this.#outgoing = /* @__PURE__ */ new Map();
112
+ }
113
+ return this.#outgoing;
144
114
  }
145
- return __privateGet(this, _outgoing);
146
- };
147
- _parse = new WeakSet();
148
- parse_fn = function() {
149
- const raw = __privateGet(this, _request).headers.get("cookie");
150
- if (!raw) {
151
- return;
115
+ #parse() {
116
+ const raw = this.#request.headers.get("cookie");
117
+ if (!raw) {
118
+ return;
119
+ }
120
+ this.#requestValues = parse(raw);
152
121
  }
153
- __privateSet(this, _requestValues, parse(raw));
154
- };
122
+ }
155
123
  export {
156
124
  AstroCookies
157
125
  };
@@ -2,6 +2,7 @@ import nodeFs from "fs";
2
2
  import { fileURLToPath } from "url";
3
3
  import * as vite from "vite";
4
4
  import { crawlFrameworkPkgs } from "vitefu";
5
+ import astroAssetsPlugin from "../assets/vite-plugin-assets.js";
5
6
  import {
6
7
  astroContentAssetPropagationPlugin,
7
8
  astroContentImportPlugin,
@@ -22,6 +23,7 @@ import markdownVitePlugin from "../vite-plugin-markdown/index.js";
22
23
  import astroScannerPlugin from "../vite-plugin-scanner/index.js";
23
24
  import astroScriptsPlugin from "../vite-plugin-scripts/index.js";
24
25
  import astroScriptsPageSSRPlugin from "../vite-plugin-scripts/page-ssr.js";
26
+ import { vitePluginSSRManifest } from "../vite-plugin-ssr-manifest/index.js";
25
27
  const ALWAYS_NOEXTERNAL = [
26
28
  "astro",
27
29
  "astro/components",
@@ -77,7 +79,9 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
77
79
  astroInjectEnvTsPlugin({ settings, logging, fs }),
78
80
  astroContentVirtualModPlugin({ settings }),
79
81
  astroContentImportPlugin({ fs, settings }),
80
- astroContentAssetPropagationPlugin({ mode })
82
+ astroContentAssetPropagationPlugin({ mode, settings }),
83
+ vitePluginSSRManifest(),
84
+ settings.config.experimental.assets ? [astroAssetsPlugin({ settings, logging, mode })] : []
81
85
  ],
82
86
  publicDir: fileURLToPath(settings.config.publicDir),
83
87
  root: fileURLToPath(settings.config.root),
@@ -10,7 +10,7 @@ import { LogOptions } from '../logger/core.js';
10
10
  export interface DevOptions {
11
11
  configFlag: string | undefined;
12
12
  configFlagPath: string | undefined;
13
- flags: yargs.Arguments | undefined;
13
+ flags?: yargs.Arguments;
14
14
  logging: LogOptions;
15
15
  telemetry: AstroTelemetry;
16
16
  handleConfigError: (error: Error) => void;
@@ -23,4 +23,4 @@ export interface DevServer {
23
23
  stop(): Promise<void>;
24
24
  }
25
25
  /** `astro dev` */
26
- export default function dev(settings: AstroSettings, options: DevOptions): Promise<DevServer>;
26
+ export default function dev(settings: AstroSettings, options: DevOptions): Promise<DevServer | undefined>;
@@ -1,11 +1,31 @@
1
+ import { cyan } from "kleur/colors";
1
2
  import { performance } from "perf_hooks";
2
3
  import { attachContentServerListeners } from "../../content/index.js";
3
4
  import { info, warn } from "../logger/core.js";
4
5
  import * as msg from "../messages.js";
6
+ import { printHelp } from "../messages.js";
5
7
  import { startContainer } from "./container.js";
6
8
  import { createContainerWithAutomaticRestart } from "./restart.js";
7
9
  async function dev(settings, options) {
8
- var _a, _b, _c;
10
+ var _a, _b, _c, _d, _e;
11
+ if (((_a = options.flags) == null ? void 0 : _a.help) || ((_b = options.flags) == null ? void 0 : _b.h)) {
12
+ printHelp({
13
+ commandName: "astro dev",
14
+ usage: "[...flags]",
15
+ tables: {
16
+ Flags: [
17
+ ["--port", `Specify which port to run on. Defaults to 3000.`],
18
+ ["--host", `Listen on all addresses, including LAN and public addresses.`],
19
+ ["--host <custom-address>", `Expose on a network IP address at <custom-address>`],
20
+ ["--help (-h)", "See all available flags."]
21
+ ]
22
+ },
23
+ description: `Check ${cyan(
24
+ "https://docs.astro.build/en/reference/cli-reference/#astro-dev"
25
+ )} for more information.`
26
+ });
27
+ return;
28
+ }
9
29
  const devStart = performance.now();
10
30
  await options.telemetry.record([]);
11
31
  const restart = await createContainerWithAutomaticRestart({
@@ -14,7 +34,7 @@ async function dev(settings, options) {
14
34
  beforeRestart: () => console.clear(),
15
35
  params: {
16
36
  settings,
17
- root: (_a = options.flags) == null ? void 0 : _a.root,
37
+ root: (_c = options.flags) == null ? void 0 : _c.root,
18
38
  logging: options.logging,
19
39
  isRestart: options.isRestart
20
40
  }
@@ -31,11 +51,11 @@ async function dev(settings, options) {
31
51
  isRestart: options.isRestart
32
52
  })
33
53
  );
34
- const currentVersion = "2.0.17";
54
+ const currentVersion = "2.1.0";
35
55
  if (currentVersion.includes("-")) {
36
56
  warn(options.logging, null, msg.prerelease({ currentVersion }));
37
57
  }
38
- if (((_c = (_b = restart.container.viteConfig.server) == null ? void 0 : _b.fs) == null ? void 0 : _c.strict) === false) {
58
+ if (((_e = (_d = restart.container.viteConfig.server) == null ? void 0 : _d.fs) == null ? void 0 : _e.strict) === false) {
39
59
  warn(options.logging, null, msg.fsStrictWarning());
40
60
  }
41
61
  await attachContentServerListeners(restart.container);
@@ -71,6 +71,7 @@ function enhanceViteSSRError({
71
71
  }
72
72
  return safeError;
73
73
  }
74
+ const ALTERNATIVE_JS_EXTS = ["cjs", "mjs"];
74
75
  async function getViteErrorPayload(err) {
75
76
  var _a, _b, _c, _d, _e, _f;
76
77
  let plugin = err.plugin;
@@ -87,8 +88,12 @@ async function getViteErrorPayload(err) {
87
88
  ] || ["FailedToLoadModuleSSR", "InvalidGlob"].includes(err.name);
88
89
  const docslink = hasDocs ? `https://docs.astro.build/en/reference/errors/${getKebabErrorName(err.name)}/` : void 0;
89
90
  const highlighter = await getHighlighter({ theme: "css-variables" });
91
+ let highlighterLang = (_b = (_a = err.loc) == null ? void 0 : _a.file) == null ? void 0 : _b.split(".").pop();
92
+ if (ALTERNATIVE_JS_EXTS.includes(highlighterLang ?? "")) {
93
+ highlighterLang = "js";
94
+ }
90
95
  const highlightedCode = err.fullCode ? highlighter.codeToHtml(err.fullCode, {
91
- lang: (_b = (_a = err.loc) == null ? void 0 : _a.file) == null ? void 0 : _b.split(".").pop(),
96
+ lang: highlighterLang,
92
97
  lineOptions: ((_c = err.loc) == null ? void 0 : _c.line) ? [{ line: err.loc.line, classes: ["error-line"] }] : void 0
93
98
  }) : void 0;
94
99
  return {