astro 5.1.3 → 5.1.5

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 (56) hide show
  1. package/astro-jsx.d.ts +3 -1
  2. package/components/Image.astro +0 -1
  3. package/components/Picture.astro +1 -2
  4. package/components/ResponsiveImage.astro +13 -0
  5. package/components/ResponsivePicture.astro +11 -0
  6. package/dist/assets/build/generate.d.ts +1 -2
  7. package/dist/assets/build/generate.js +34 -17
  8. package/dist/assets/build/remote.d.ts +1 -1
  9. package/dist/assets/vite-plugin-assets.js +4 -3
  10. package/dist/container/index.js +2 -1
  11. package/dist/content/content-layer.d.ts +1 -1
  12. package/dist/content/content-layer.js +4 -6
  13. package/dist/content/mutable-data-store.d.ts +1 -1
  14. package/dist/content/mutable-data-store.js +21 -13
  15. package/dist/content/vite-plugin-content-virtual-mod.js +16 -13
  16. package/dist/core/app/index.js +13 -1
  17. package/dist/core/build/css-asset-name.js +1 -1
  18. package/dist/core/build/generate.js +4 -2
  19. package/dist/core/build/index.js +3 -2
  20. package/dist/core/build/static-build.js +1 -1
  21. package/dist/core/compile/compile.js +1 -2
  22. package/dist/core/compile/style.js +2 -1
  23. package/dist/core/config/schema.d.ts +49 -31
  24. package/dist/core/config/schema.js +2 -2
  25. package/dist/core/constants.js +1 -1
  26. package/dist/core/dev/container.js +2 -1
  27. package/dist/core/dev/dev.js +5 -7
  28. package/dist/core/errors/dev/utils.js +1 -1
  29. package/dist/core/messages.js +2 -2
  30. package/dist/core/middleware/sequence.js +5 -1
  31. package/dist/core/middleware/vite-plugin.js +1 -1
  32. package/dist/core/render/params-and-props.js +1 -1
  33. package/dist/core/render-context.js +17 -3
  34. package/dist/core/request.d.ts +3 -3
  35. package/dist/core/request.js +4 -2
  36. package/dist/core/routing/manifest/create.d.ts +0 -1
  37. package/dist/core/routing/manifest/create.js +2 -21
  38. package/dist/core/routing/manifest/parts.d.ts +2 -0
  39. package/dist/core/routing/manifest/parts.js +22 -0
  40. package/dist/core/routing/manifest/segment.d.ts +1 -0
  41. package/dist/core/routing/manifest/segment.js +22 -0
  42. package/dist/core/routing/rewrite.d.ts +5 -1
  43. package/dist/core/routing/rewrite.js +22 -15
  44. package/dist/core/sync/index.d.ts +4 -2
  45. package/dist/core/sync/index.js +15 -12
  46. package/dist/core/util.d.ts +2 -2
  47. package/dist/core/util.js +5 -2
  48. package/dist/env/schema.d.ts +48 -30
  49. package/dist/env/schema.js +20 -1
  50. package/dist/vite-plugin-astro/compile.js +1 -1
  51. package/dist/vite-plugin-astro-server/request.js +1 -1
  52. package/dist/vite-plugin-astro-server/route.js +1 -1
  53. package/dist/vite-plugin-markdown/content-entry-type.js +1 -6
  54. package/dist/vite-plugin-markdown/index.js +1 -1
  55. package/dist/vite-plugin-scanner/index.js +1 -2
  56. package/package.json +5 -1
package/astro-jsx.d.ts CHANGED
@@ -837,10 +837,12 @@ declare namespace astroHTML.JSX {
837
837
 
838
838
  interface LinkHTMLAttributes extends HTMLAttributes {
839
839
  as?: string | undefined | null;
840
+ blocking?: 'render' | undefined | null;
840
841
  crossorigin?: boolean | string | undefined | null;
842
+ disabled?: boolean | undefined | null;
843
+ fetchpriority?: 'auto' | 'high' | 'low' | undefined | null;
841
844
  href?: string | URL | undefined | null;
842
845
  hreflang?: string | undefined | null;
843
- fetchpriority?: 'auto' | 'high' | 'low' | undefined | null;
844
846
  integrity?: string | undefined | null;
845
847
  media?: string | undefined | null;
846
848
  imagesrcset?: string | undefined | null;
@@ -4,7 +4,6 @@ import type { UnresolvedImageTransform } from '../dist/assets/types';
4
4
  import { applyResponsiveAttributes } from '../dist/assets/utils/imageAttributes.js';
5
5
  import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
6
6
  import type { HTMLAttributes } from '../types';
7
- import './image.css';
8
7
 
9
8
  // The TypeScript diagnostic for JSX props uses the last member of the union to suggest props, so it would be better for
10
9
  // LocalImageProps to be last. Unfortunately, when we do this the error messages that remote images get are complete nonsense
@@ -10,9 +10,8 @@ import type {
10
10
  UnresolvedImageTransform,
11
11
  } from '../dist/types/public/index.js';
12
12
  import type { HTMLAttributes } from '../types';
13
- import './image.css';
14
13
 
15
- type Props = (LocalImageProps | RemoteImageProps) & {
14
+ export type Props = (LocalImageProps | RemoteImageProps) & {
16
15
  formats?: ImageOutputFormat[];
17
16
  fallbackFormat?: ImageOutputFormat;
18
17
  pictureAttributes?: HTMLAttributes<'picture'>;
@@ -0,0 +1,13 @@
1
+ ---
2
+ import type { LocalImageProps, RemoteImageProps } from 'astro:assets';
3
+ import Image from './Image.astro';
4
+
5
+ type Props = LocalImageProps | RemoteImageProps;
6
+
7
+ const { class: className, ...props } = Astro.props;
8
+
9
+ import './image.css';
10
+ ---
11
+
12
+ {/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
13
+ <Image {...props} class={className} />
@@ -0,0 +1,11 @@
1
+ ---
2
+ import { default as Picture, type Props as PictureProps } from './Picture.astro';
3
+
4
+ type Props = PictureProps;
5
+
6
+ const { class: className, ...props } = Astro.props;
7
+ ---
8
+
9
+ {/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
10
+
11
+ <Picture {...props} class={className} />
@@ -1,4 +1,3 @@
1
- import type PQueue from 'p-queue';
2
1
  import type { BuildPipeline } from '../../core/build/pipeline.js';
3
2
  import type { Logger } from '../../core/logger/core.js';
4
3
  import type { MapValue } from '../../type-utils.js';
@@ -19,6 +18,6 @@ type AssetEnv = {
19
18
  assetsFolder: AstroConfig['build']['assets'];
20
19
  };
21
20
  export declare function prepareAssetsGenerationEnv(pipeline: BuildPipeline, totalCount: number): Promise<AssetEnv>;
22
- export declare function generateImagesForPath(originalFilePath: string, transformsAndPath: MapValue<AssetsGlobalStaticImagesList>, env: AssetEnv, queue: PQueue): Promise<void>;
21
+ export declare function generateImagesForPath(originalFilePath: string, transformsAndPath: MapValue<AssetsGlobalStaticImagesList>, env: AssetEnv): Promise<void>;
23
22
  export declare function getStaticImageList(): AssetsGlobalStaticImagesList;
24
23
  export {};
@@ -47,12 +47,10 @@ async function prepareAssetsGenerationEnv(pipeline, totalCount) {
47
47
  function getFullImagePath(originalFilePath, env) {
48
48
  return new URL(removeLeadingForwardSlash(originalFilePath), env.serverRoot);
49
49
  }
50
- async function generateImagesForPath(originalFilePath, transformsAndPath, env, queue) {
50
+ async function generateImagesForPath(originalFilePath, transformsAndPath, env) {
51
51
  let originalImage;
52
52
  for (const [_, transform] of transformsAndPath.transforms) {
53
- await queue.add(async () => generateImage(transform.finalPath, transform.transform)).catch((e) => {
54
- throw e;
55
- });
53
+ await generateImage(transform.finalPath, transform.transform);
56
54
  }
57
55
  if (!env.isSSR && transformsAndPath.originalSrcPath && !globalThis.astroAsset.referencedImages?.has(transformsAndPath.originalSrcPath)) {
58
56
  try {
@@ -85,8 +83,10 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
85
83
  const finalFileURL = new URL("." + filepath, env.clientRoot);
86
84
  const finalFolderURL = new URL("./", finalFileURL);
87
85
  await fs.promises.mkdir(finalFolderURL, { recursive: true });
88
- const cacheFile = basename(filepath) + (isLocalImage ? "" : ".json");
86
+ const cacheFile = basename(filepath);
89
87
  const cachedFileURL = new URL(cacheFile, env.assetsCacheDir);
88
+ const cacheMetaFile = cacheFile + ".json";
89
+ const cachedMetaFileURL = new URL(cacheMetaFile, env.assetsCacheDir);
90
90
  try {
91
91
  if (isLocalImage) {
92
92
  await fs.promises.copyFile(cachedFileURL, finalFileURL, fs.constants.COPYFILE_FICLONE);
@@ -94,15 +94,26 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
94
94
  cached: "hit"
95
95
  };
96
96
  } else {
97
- const JSONData = JSON.parse(readFileSync(cachedFileURL, "utf-8"));
98
- if (!JSONData.data || !JSONData.expires) {
99
- await fs.promises.unlink(cachedFileURL);
97
+ const JSONData = JSON.parse(readFileSync(cachedMetaFileURL, "utf-8"));
98
+ if (!JSONData.expires) {
99
+ try {
100
+ await fs.promises.unlink(cachedFileURL);
101
+ } catch {
102
+ }
103
+ await fs.promises.unlink(cachedMetaFileURL);
100
104
  throw new Error(
101
105
  `Malformed cache entry for ${filepath}, cache will be regenerated for this file.`
102
106
  );
103
107
  }
108
+ if (JSONData.data) {
109
+ const { data, ...meta } = JSONData;
110
+ await Promise.all([
111
+ fs.promises.writeFile(cachedFileURL, Buffer.from(data, "base64")),
112
+ writeCacheMetaFile(cachedMetaFileURL, meta, env)
113
+ ]);
114
+ }
104
115
  if (JSONData.expires > Date.now()) {
105
- await fs.promises.writeFile(finalFileURL, Buffer.from(JSONData.data, "base64"));
116
+ await fs.promises.copyFile(cachedFileURL, finalFileURL, fs.constants.COPYFILE_FICLONE);
106
117
  return {
107
118
  cached: "hit"
108
119
  };
@@ -116,9 +127,12 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
116
127
  if (revalidatedData.data.length) {
117
128
  originalImage = revalidatedData;
118
129
  } else {
119
- revalidatedData.data = Buffer.from(JSONData.data, "base64");
120
- await writeRemoteCacheFile(cachedFileURL, revalidatedData, env);
121
- await fs.promises.writeFile(finalFileURL, revalidatedData.data);
130
+ await writeCacheMetaFile(cachedMetaFileURL, revalidatedData, env);
131
+ await fs.promises.copyFile(
132
+ cachedFileURL,
133
+ finalFileURL,
134
+ fs.constants.COPYFILE_FICLONE
135
+ );
122
136
  return { cached: "revalidated" };
123
137
  }
124
138
  } catch (e) {
@@ -126,11 +140,12 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
126
140
  null,
127
141
  `An error was encountered while revalidating a cached remote asset. Proceeding with stale cache. ${e}`
128
142
  );
129
- await fs.promises.writeFile(finalFileURL, Buffer.from(JSONData.data, "base64"));
143
+ await fs.promises.copyFile(cachedFileURL, finalFileURL, fs.constants.COPYFILE_FICLONE);
130
144
  return { cached: "hit" };
131
145
  }
132
146
  }
133
147
  await fs.promises.unlink(cachedFileURL);
148
+ await fs.promises.unlink(cachedMetaFileURL);
134
149
  }
135
150
  } catch (e) {
136
151
  if (e.code !== "ENOENT") {
@@ -169,7 +184,10 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
169
184
  if (isLocalImage) {
170
185
  await fs.promises.writeFile(cachedFileURL, resultData.data);
171
186
  } else {
172
- await writeRemoteCacheFile(cachedFileURL, resultData, env);
187
+ await Promise.all([
188
+ fs.promises.writeFile(cachedFileURL, resultData.data),
189
+ writeCacheMetaFile(cachedMetaFileURL, resultData, env)
190
+ ]);
173
191
  }
174
192
  }
175
193
  } catch (e) {
@@ -190,12 +208,11 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
190
208
  };
191
209
  }
192
210
  }
193
- async function writeRemoteCacheFile(cachedFileURL, resultData, env) {
211
+ async function writeCacheMetaFile(cachedMetaFileURL, resultData, env) {
194
212
  try {
195
213
  return await fs.promises.writeFile(
196
- cachedFileURL,
214
+ cachedMetaFileURL,
197
215
  JSON.stringify({
198
- data: Buffer.from(resultData.data).toString("base64"),
199
216
  expires: resultData.expires,
200
217
  etag: resultData.etag,
201
218
  lastModified: resultData.lastModified
@@ -1,5 +1,5 @@
1
1
  export type RemoteCacheEntry = {
2
- data: string;
2
+ data?: string;
3
3
  expires: number;
4
4
  etag?: string;
5
5
  lastModified?: string;
@@ -1,6 +1,5 @@
1
1
  import { extname } from "node:path";
2
2
  import MagicString from "magic-string";
3
- import { normalizePath } from "vite";
4
3
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
5
4
  import {
6
5
  appendForwardSlash,
@@ -9,6 +8,7 @@ import {
9
8
  removeBase,
10
9
  removeQueryString
11
10
  } from "../core/path.js";
11
+ import { normalizePath } from "../core/viteUtils.js";
12
12
  import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from "./consts.js";
13
13
  import { getAssetsPrefix } from "./utils/getAssetsPrefix.js";
14
14
  import { isESMImportedImage } from "./utils/imageKind.js";
@@ -70,6 +70,7 @@ function assets({ settings }) {
70
70
  globalThis.astroAsset = {
71
71
  referencedImages: /* @__PURE__ */ new Set()
72
72
  };
73
+ const imageComponentPrefix = settings.config.experimental.responsiveImages ? "Responsive" : "";
73
74
  return [
74
75
  // Expose the components and different utilities from `astro:assets`
75
76
  {
@@ -92,8 +93,8 @@ function assets({ settings }) {
92
93
  `
93
94
  export { getConfiguredImageService, isLocalService } from "astro/assets";
94
95
  import { getImage as getImageInternal } from "astro/assets";
95
- export { default as Image } from "astro/components/Image.astro";
96
- export { default as Picture } from "astro/components/Picture.astro";
96
+ export { default as Image } from "astro/components/${imageComponentPrefix}Image.astro";
97
+ export { default as Picture } from "astro/components/${imageComponentPrefix}Picture.astro";
97
98
  export { inferRemoteSize } from "astro/assets/utils/inferRemoteSize.js";
98
99
 
99
100
  export const imageConfig = ${JSON.stringify({ ...settings.config.image, experimentalResponsiveImages: settings.config.experimental.responsiveImages })};
@@ -9,8 +9,9 @@ import { nodeLogDestination } from "../core/logger/node.js";
9
9
  import { NOOP_MIDDLEWARE_FN } from "../core/middleware/noop-middleware.js";
10
10
  import { removeLeadingForwardSlash } from "../core/path.js";
11
11
  import { RenderContext } from "../core/render-context.js";
12
- import { getParts, validateSegment } from "../core/routing/manifest/create.js";
12
+ import { getParts } from "../core/routing/manifest/parts.js";
13
13
  import { getPattern } from "../core/routing/manifest/pattern.js";
14
+ import { validateSegment } from "../core/routing/manifest/segment.js";
14
15
  import { ContainerPipeline } from "./pipeline.js";
15
16
  function createManifest(manifest, renderers, middleware) {
16
17
  function middlewareInstance() {
@@ -40,7 +40,7 @@ export declare function simpleLoader<TData extends {
40
40
  * During development, this is in the `.astro` directory so that the Vite watcher can see it.
41
41
  * In production, it's in the cache directory so that it's preserved between builds.
42
42
  */
43
- export declare function getDataStoreFile(settings: AstroSettings, isDev?: boolean): URL;
43
+ export declare function getDataStoreFile(settings: AstroSettings, isDev: boolean): URL;
44
44
  export declare const globalContentLayer: {
45
45
  init: (options: ContentLayerOptions) => ContentLayer;
46
46
  get: () => ContentLayer | null;
@@ -148,7 +148,7 @@ ${contentConfig.error.message}`);
148
148
  logger.info("Content config changed");
149
149
  shouldClear = true;
150
150
  }
151
- if (previousAstroVersion && previousAstroVersion !== "5.1.3") {
151
+ if (previousAstroVersion && previousAstroVersion !== "5.1.5") {
152
152
  logger.info("Astro version changed");
153
153
  shouldClear = true;
154
154
  }
@@ -156,8 +156,8 @@ ${contentConfig.error.message}`);
156
156
  logger.info("Clearing content store");
157
157
  this.#store.clearAll();
158
158
  }
159
- if ("5.1.3") {
160
- await this.#store.metaStore().set("astro-version", "5.1.3");
159
+ if ("5.1.5") {
160
+ await this.#store.metaStore().set("astro-version", "5.1.5");
161
161
  }
162
162
  if (currentConfigDigest) {
163
163
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -215,8 +215,7 @@ ${contentConfig.error.message}`);
215
215
  );
216
216
  await fs.mkdir(this.#settings.config.cacheDir, { recursive: true });
217
217
  await fs.mkdir(this.#settings.dotAstroDir, { recursive: true });
218
- const cacheFile = getDataStoreFile(this.#settings);
219
- await this.#store.writeToDisk(cacheFile);
218
+ await this.#store.writeToDisk();
220
219
  const assetImportsFile = new URL(ASSET_IMPORTS_FILE, this.#settings.dotAstroDir);
221
220
  await this.#store.writeAssetImports(assetImportsFile);
222
221
  const modulesImportsFile = new URL(MODULES_IMPORTS_FILE, this.#settings.dotAstroDir);
@@ -303,7 +302,6 @@ ${JSON.stringify({ ...raw, id: void 0 }, null, 2)}`
303
302
  });
304
303
  }
305
304
  function getDataStoreFile(settings, isDev) {
306
- isDev ??= process?.env.NODE_ENV === "development";
307
305
  return new URL(DATA_STORE_FILE, isDev ? settings.dotAstroDir : settings.config.cacheDir);
308
306
  }
309
307
  function contentLayerSingleton() {
@@ -21,7 +21,7 @@ export declare class MutableDataStore extends ImmutableDataStore {
21
21
  */
22
22
  metaStore(collectionName?: string): MetaStore;
23
23
  toString(): string;
24
- writeToDisk(filePath: PathLike): Promise<void>;
24
+ writeToDisk(): Promise<void>;
25
25
  /**
26
26
  * Attempts to load a MutableDataStore from the virtual module.
27
27
  * This only works in Vite.
@@ -144,15 +144,15 @@ ${lines.join(",\n")}]);
144
144
  }
145
145
  #saveToDiskDebounced() {
146
146
  this.#dirty = true;
147
- if (this.#file) {
148
- if (this.#saveTimeout) {
149
- clearTimeout(this.#saveTimeout);
150
- }
151
- this.#saveTimeout = setTimeout(() => {
152
- this.#saveTimeout = void 0;
153
- this.writeToDisk(this.#file);
154
- }, SAVE_DEBOUNCE_MS);
147
+ if (this.#saveTimeout) {
148
+ clearTimeout(this.#saveTimeout);
155
149
  }
150
+ this.#saveTimeout = setTimeout(() => {
151
+ this.#saveTimeout = void 0;
152
+ if (this.#file) {
153
+ this.writeToDisk();
154
+ }
155
+ }, SAVE_DEBOUNCE_MS);
156
156
  }
157
157
  #writing = /* @__PURE__ */ new Set();
158
158
  #pending = /* @__PURE__ */ new Set();
@@ -270,13 +270,15 @@ ${lines.join(",\n")}]);
270
270
  toString() {
271
271
  return devalue.stringify(this._collections);
272
272
  }
273
- async writeToDisk(filePath) {
273
+ async writeToDisk() {
274
274
  if (!this.#dirty) {
275
275
  return;
276
276
  }
277
+ if (!this.#file) {
278
+ throw new AstroError(AstroErrorData.UnknownFilesystemError);
279
+ }
277
280
  try {
278
- await this.#writeFileAtomic(filePath, this.toString());
279
- this.#file = filePath;
281
+ await this.#writeFileAtomic(this.#file, this.toString());
280
282
  this.#dirty = false;
281
283
  } catch (err) {
282
284
  throw new AstroError(AstroErrorData.UnknownFilesystemError, { cause: err });
@@ -308,11 +310,17 @@ ${lines.join(",\n")}]);
308
310
  try {
309
311
  if (existsSync(filePath)) {
310
312
  const data = await fs.readFile(filePath, "utf-8");
311
- return MutableDataStore.fromString(data);
313
+ const store2 = await MutableDataStore.fromString(data);
314
+ store2.#file = filePath;
315
+ return store2;
316
+ } else {
317
+ await fs.mkdir(new URL("./", filePath), { recursive: true });
312
318
  }
313
319
  } catch {
314
320
  }
315
- return new MutableDataStore();
321
+ const store = new MutableDataStore();
322
+ store.#file = filePath;
323
+ return store;
316
324
  }
317
325
  }
318
326
  export {
@@ -36,6 +36,16 @@ import {
36
36
  globWithUnderscoresIgnored,
37
37
  isDeferredModule
38
38
  } from "./utils.js";
39
+ function invalidateDataStore(server) {
40
+ const module = server.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
41
+ if (module) {
42
+ server.moduleGraph.invalidateModule(module);
43
+ }
44
+ server.ws.send({
45
+ type: "full-reload",
46
+ path: "*"
47
+ });
48
+ }
39
49
  function astroContentVirtualModPlugin({
40
50
  settings,
41
51
  fs
@@ -49,7 +59,10 @@ function astroContentVirtualModPlugin({
49
59
  dataStoreFile = getDataStoreFile(settings, env.command === "serve");
50
60
  },
51
61
  buildStart() {
52
- devServer?.watcher.add(fileURLToPath(dataStoreFile));
62
+ if (devServer) {
63
+ devServer.watcher.add(fileURLToPath(dataStoreFile));
64
+ invalidateDataStore(devServer);
65
+ }
53
66
  },
54
67
  async resolveId(id) {
55
68
  if (id === VIRTUAL_MODULE_ID) {
@@ -143,24 +156,14 @@ function astroContentVirtualModPlugin({
143
156
  configureServer(server) {
144
157
  devServer = server;
145
158
  const dataStorePath = fileURLToPath(dataStoreFile);
146
- function invalidateDataStore() {
147
- const module = server.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
148
- if (module) {
149
- server.moduleGraph.invalidateModule(module);
150
- }
151
- server.ws.send({
152
- type: "full-reload",
153
- path: "*"
154
- });
155
- }
156
159
  server.watcher.on("add", (addedPath) => {
157
160
  if (addedPath === dataStorePath) {
158
- invalidateDataStore();
161
+ invalidateDataStore(server);
159
162
  }
160
163
  });
161
164
  server.watcher.on("change", (changedPath) => {
162
165
  if (changedPath === dataStorePath) {
163
- invalidateDataStore();
166
+ invalidateDataStore(server);
164
167
  }
165
168
  });
166
169
  }
@@ -89,10 +89,22 @@ class App {
89
89
  }
90
90
  return pathname;
91
91
  }
92
+ /**
93
+ * It removes the base from the request URL, prepends it with a forward slash and attempts to decoded it.
94
+ *
95
+ * If the decoding fails, it logs the error and return the pathname as is.
96
+ * @param request
97
+ * @private
98
+ */
92
99
  #getPathnameFromRequest(request) {
93
100
  const url = new URL(request.url);
94
101
  const pathname = prependForwardSlash(this.removeBase(url.pathname));
95
- return pathname;
102
+ try {
103
+ return decodeURI(pathname);
104
+ } catch (e) {
105
+ this.getAdapterLogger().error(e.toString());
106
+ return pathname;
107
+ }
96
108
  }
97
109
  match(request) {
98
110
  const url = new URL(request.url);
@@ -1,8 +1,8 @@
1
1
  import crypto from "node:crypto";
2
2
  import npath from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import { normalizePath } from "vite";
5
4
  import { viteID } from "../util.js";
5
+ import { normalizePath } from "../viteUtils.js";
6
6
  import { getTopLevelPageModuleInfos } from "./graph.js";
7
7
  const confusingBaseNames = ["404", "500"];
8
8
  function shortHashedName(settings) {
@@ -96,7 +96,9 @@ ${bgGreen(black(` ${verb} static routes `))}`);
96
96
  const queue = new PQueue({ concurrency: Math.max(cpuCount, 1) });
97
97
  const assetsTimer = performance.now();
98
98
  for (const [originalPath, transforms] of staticImageList) {
99
- await generateImagesForPath(originalPath, transforms, assetsCreationPipeline, queue);
99
+ queue.add(() => generateImagesForPath(originalPath, transforms, assetsCreationPipeline)).catch((e) => {
100
+ throw e;
101
+ });
100
102
  }
101
103
  await queue.onIdle();
102
104
  const assetsTimeEnd = performance.now();
@@ -128,7 +130,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
128
130
  async function generatePathWithLogs(path, route, index, paths, isConcurrent) {
129
131
  const timeStart = performance.now();
130
132
  pipeline.logger.debug("build", `Generating: ${path}`);
131
- const filePath = getOutputFilename(config, path, pageData.route.type);
133
+ const filePath = getOutputFilename(config, path, pageData.route);
132
134
  const lineIcon = index === paths.length - 1 && !isConcurrent || paths.length === 1 ? "\u2514\u2500" : "\u251C\u2500";
133
135
  if (!isConcurrent) {
134
136
  logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false);
@@ -33,7 +33,7 @@ async function build(inlineConfig, options = {}) {
33
33
  telemetry.record(eventCliSession("build", userConfig));
34
34
  const settings = await createSettings(astroConfig, fileURLToPath(astroConfig.root));
35
35
  if (inlineConfig.force) {
36
- await clearContentLayerCache({ settings, logger, fs });
36
+ await clearContentLayerCache({ settings, logger, fs, isDev: false });
37
37
  }
38
38
  const builder = new AstroBuilder(settings, {
39
39
  ...options,
@@ -99,7 +99,8 @@ class AstroBuilder {
99
99
  settings: this.settings,
100
100
  logger,
101
101
  fs,
102
- manifest: this.manifest
102
+ manifest: this.manifest,
103
+ command: "build"
103
104
  });
104
105
  return { viteConfig };
105
106
  }
@@ -272,7 +272,7 @@ async function cleanServerOutput(opts, ssrOutputChunkNames, internals) {
272
272
  files.map(async (filename) => {
273
273
  const url = new URL(filename, out);
274
274
  const map = new URL(url + ".map");
275
- await Promise.all([fs.promises.rm(url), fs.promises.rm(new URL(map)).catch((e) => {
275
+ await Promise.all([fs.promises.rm(url), fs.promises.rm(map).catch(() => {
276
276
  })]);
277
277
  })
278
278
  );
@@ -1,9 +1,8 @@
1
1
  import { fileURLToPath } from "node:url";
2
2
  import { transform } from "@astrojs/compiler";
3
- import { normalizePath } from "vite";
4
3
  import { AggregateError, CompilerError } from "../errors/errors.js";
5
4
  import { AstroErrorData } from "../errors/index.js";
6
- import { resolvePath } from "../viteUtils.js";
5
+ import { normalizePath, resolvePath } from "../viteUtils.js";
7
6
  import { createStylePreprocessor } from "./style.js";
8
7
  async function compile({
9
8
  astroConfig,
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs";
2
- import { normalizePath, preprocessCSS } from "vite";
2
+ import { preprocessCSS } from "vite";
3
3
  import { AstroErrorData, CSSError, positionAt } from "../errors/index.js";
4
+ import { normalizePath } from "../viteUtils.js";
4
5
  function createStylePreprocessor({
5
6
  filename,
6
7
  viteConfig,
@@ -1,5 +1,5 @@
1
- import type { ShikiConfig, RehypePlugin as _RehypePlugin, RemarkPlugin as _RemarkPlugin, RemarkRehype as _RemarkRehype } from '@astrojs/markdown-remark';
2
1
  import type { OutgoingHttpHeaders } from 'node:http';
2
+ import type { ShikiConfig, RehypePlugin as _RehypePlugin, RemarkPlugin as _RemarkPlugin, RemarkRehype as _RemarkRehype } from '@astrojs/markdown-remark';
3
3
  import { z } from 'zod';
4
4
  import type { ViteUserConfig } from '../../types/public/config.js';
5
5
  interface ComplexifyUnionObj {
@@ -449,34 +449,43 @@ export declare const AstroConfigSchema: z.ZodObject<{
449
449
  checkOrigin?: boolean | undefined;
450
450
  }>>>;
451
451
  env: z.ZodDefault<z.ZodOptional<z.ZodObject<{
452
- schema: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
453
- context: z.ZodLiteral<"client">;
454
- access: z.ZodLiteral<"public">;
455
- }, "strip", z.ZodTypeAny, {
452
+ schema: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodIntersection<z.ZodEffects<z.ZodType<{
456
453
  context: "client";
457
454
  access: "public";
458
- }, {
455
+ } | {
456
+ context: "server";
457
+ access: "public";
458
+ } | {
459
+ context: "server";
460
+ access: "secret";
461
+ }, z.ZodTypeDef, {
459
462
  context: "client";
460
463
  access: "public";
461
- }>, z.ZodObject<{
462
- context: z.ZodLiteral<"server">;
463
- access: z.ZodLiteral<"public">;
464
- }, "strip", z.ZodTypeAny, {
464
+ } | {
465
465
  context: "server";
466
466
  access: "public";
467
- }, {
467
+ } | {
468
468
  context: "server";
469
+ access: "secret";
470
+ }>, {
471
+ context: "client";
469
472
  access: "public";
470
- }>, z.ZodObject<{
471
- context: z.ZodLiteral<"server">;
472
- access: z.ZodLiteral<"secret">;
473
- }, "strip", z.ZodTypeAny, {
473
+ } | {
474
+ context: "server";
475
+ access: "public";
476
+ } | {
474
477
  context: "server";
475
478
  access: "secret";
476
479
  }, {
480
+ context: "client";
481
+ access: "public";
482
+ } | {
483
+ context: "server";
484
+ access: "public";
485
+ } | {
477
486
  context: "server";
478
487
  access: "secret";
479
- }>]>, z.ZodUnion<[z.ZodObject<{
488
+ }>, z.ZodUnion<[z.ZodObject<{
480
489
  type: z.ZodLiteral<"string">;
481
490
  optional: z.ZodOptional<z.ZodBoolean>;
482
491
  default: z.ZodOptional<z.ZodString>;
@@ -1507,34 +1516,43 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
1507
1516
  checkOrigin?: boolean | undefined;
1508
1517
  }>>>;
1509
1518
  env: z.ZodDefault<z.ZodOptional<z.ZodObject<{
1510
- schema: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
1511
- context: z.ZodLiteral<"client">;
1512
- access: z.ZodLiteral<"public">;
1513
- }, "strip", z.ZodTypeAny, {
1519
+ schema: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodIntersection<z.ZodEffects<z.ZodType<{
1514
1520
  context: "client";
1515
1521
  access: "public";
1516
- }, {
1522
+ } | {
1523
+ context: "server";
1524
+ access: "public";
1525
+ } | {
1526
+ context: "server";
1527
+ access: "secret";
1528
+ }, z.ZodTypeDef, {
1517
1529
  context: "client";
1518
1530
  access: "public";
1519
- }>, z.ZodObject<{
1520
- context: z.ZodLiteral<"server">;
1521
- access: z.ZodLiteral<"public">;
1522
- }, "strip", z.ZodTypeAny, {
1531
+ } | {
1523
1532
  context: "server";
1524
1533
  access: "public";
1525
- }, {
1534
+ } | {
1526
1535
  context: "server";
1536
+ access: "secret";
1537
+ }>, {
1538
+ context: "client";
1527
1539
  access: "public";
1528
- }>, z.ZodObject<{
1529
- context: z.ZodLiteral<"server">;
1530
- access: z.ZodLiteral<"secret">;
1531
- }, "strip", z.ZodTypeAny, {
1540
+ } | {
1541
+ context: "server";
1542
+ access: "public";
1543
+ } | {
1532
1544
  context: "server";
1533
1545
  access: "secret";
1534
1546
  }, {
1547
+ context: "client";
1548
+ access: "public";
1549
+ } | {
1550
+ context: "server";
1551
+ access: "public";
1552
+ } | {
1535
1553
  context: "server";
1536
1554
  access: "secret";
1537
- }>]>, z.ZodUnion<[z.ZodObject<{
1555
+ }>, z.ZodUnion<[z.ZodObject<{
1538
1556
  type: z.ZodLiteral<"string">;
1539
1557
  optional: z.ZodOptional<z.ZodBoolean>;
1540
1558
  default: z.ZodOptional<z.ZodString>;