astro 5.1.2 → 5.1.4

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 (43) hide show
  1. package/components/Image.astro +0 -1
  2. package/components/Picture.astro +1 -2
  3. package/components/ResponsiveImage.astro +13 -0
  4. package/components/ResponsivePicture.astro +11 -0
  5. package/dist/assets/build/generate.js +32 -13
  6. package/dist/assets/build/remote.d.ts +1 -1
  7. package/dist/assets/vite-plugin-assets.js +3 -2
  8. package/dist/content/content-layer.js +22 -6
  9. package/dist/content/utils.d.ts +3 -2
  10. package/dist/content/utils.js +9 -1
  11. package/dist/content/vite-plugin-content-virtual-mod.js +20 -13
  12. package/dist/core/app/index.js +15 -3
  13. package/dist/core/build/generate.js +1 -1
  14. package/dist/core/build/index.js +2 -1
  15. package/dist/core/build/static-build.js +1 -1
  16. package/dist/core/config/schema.d.ts +49 -31
  17. package/dist/core/config/schema.js +2 -2
  18. package/dist/core/constants.js +1 -1
  19. package/dist/core/dev/dev.js +20 -18
  20. package/dist/core/messages.js +2 -2
  21. package/dist/core/middleware/sequence.js +5 -1
  22. package/dist/core/render/params-and-props.js +1 -2
  23. package/dist/core/render-context.js +17 -3
  24. package/dist/core/request.d.ts +4 -3
  25. package/dist/core/request.js +4 -2
  26. package/dist/core/routing/manifest/create.js +1 -1
  27. package/dist/core/routing/rewrite.d.ts +5 -1
  28. package/dist/core/routing/rewrite.js +22 -15
  29. package/dist/core/server-islands/endpoint.js +1 -0
  30. package/dist/core/server-islands/vite-plugin-server-islands.js +13 -1
  31. package/dist/core/session.js +17 -11
  32. package/dist/core/sync/index.js +4 -3
  33. package/dist/core/util.d.ts +2 -2
  34. package/dist/core/util.js +5 -2
  35. package/dist/env/schema.d.ts +48 -30
  36. package/dist/env/schema.js +20 -1
  37. package/dist/types/astro.d.ts +1 -1
  38. package/dist/vite-plugin-astro/compile.js +1 -1
  39. package/dist/vite-plugin-astro-server/request.js +1 -1
  40. package/dist/vite-plugin-astro-server/route.js +1 -1
  41. package/dist/vite-plugin-markdown/content-entry-type.js +1 -6
  42. package/package.json +3 -3
  43. package/types/content.d.ts +13 -11
@@ -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} />
@@ -85,8 +85,10 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
85
85
  const finalFileURL = new URL("." + filepath, env.clientRoot);
86
86
  const finalFolderURL = new URL("./", finalFileURL);
87
87
  await fs.promises.mkdir(finalFolderURL, { recursive: true });
88
- const cacheFile = basename(filepath) + (isLocalImage ? "" : ".json");
88
+ const cacheFile = basename(filepath);
89
89
  const cachedFileURL = new URL(cacheFile, env.assetsCacheDir);
90
+ const cacheMetaFile = cacheFile + ".json";
91
+ const cachedMetaFileURL = new URL(cacheMetaFile, env.assetsCacheDir);
90
92
  try {
91
93
  if (isLocalImage) {
92
94
  await fs.promises.copyFile(cachedFileURL, finalFileURL, fs.constants.COPYFILE_FICLONE);
@@ -94,15 +96,26 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
94
96
  cached: "hit"
95
97
  };
96
98
  } else {
97
- const JSONData = JSON.parse(readFileSync(cachedFileURL, "utf-8"));
98
- if (!JSONData.data || !JSONData.expires) {
99
- await fs.promises.unlink(cachedFileURL);
99
+ const JSONData = JSON.parse(readFileSync(cachedMetaFileURL, "utf-8"));
100
+ if (!JSONData.expires) {
101
+ try {
102
+ await fs.promises.unlink(cachedFileURL);
103
+ } catch {
104
+ }
105
+ await fs.promises.unlink(cachedMetaFileURL);
100
106
  throw new Error(
101
107
  `Malformed cache entry for ${filepath}, cache will be regenerated for this file.`
102
108
  );
103
109
  }
110
+ if (JSONData.data) {
111
+ const { data, ...meta } = JSONData;
112
+ await Promise.all([
113
+ fs.promises.writeFile(cachedFileURL, Buffer.from(data, "base64")),
114
+ writeCacheMetaFile(cachedMetaFileURL, meta, env)
115
+ ]);
116
+ }
104
117
  if (JSONData.expires > Date.now()) {
105
- await fs.promises.writeFile(finalFileURL, Buffer.from(JSONData.data, "base64"));
118
+ await fs.promises.copyFile(cachedFileURL, finalFileURL, fs.constants.COPYFILE_FICLONE);
106
119
  return {
107
120
  cached: "hit"
108
121
  };
@@ -116,9 +129,12 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
116
129
  if (revalidatedData.data.length) {
117
130
  originalImage = revalidatedData;
118
131
  } else {
119
- revalidatedData.data = Buffer.from(JSONData.data, "base64");
120
- await writeRemoteCacheFile(cachedFileURL, revalidatedData, env);
121
- await fs.promises.writeFile(finalFileURL, revalidatedData.data);
132
+ await writeCacheMetaFile(cachedMetaFileURL, revalidatedData, env);
133
+ await fs.promises.copyFile(
134
+ cachedFileURL,
135
+ finalFileURL,
136
+ fs.constants.COPYFILE_FICLONE
137
+ );
122
138
  return { cached: "revalidated" };
123
139
  }
124
140
  } catch (e) {
@@ -126,11 +142,12 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
126
142
  null,
127
143
  `An error was encountered while revalidating a cached remote asset. Proceeding with stale cache. ${e}`
128
144
  );
129
- await fs.promises.writeFile(finalFileURL, Buffer.from(JSONData.data, "base64"));
145
+ await fs.promises.copyFile(cachedFileURL, finalFileURL, fs.constants.COPYFILE_FICLONE);
130
146
  return { cached: "hit" };
131
147
  }
132
148
  }
133
149
  await fs.promises.unlink(cachedFileURL);
150
+ await fs.promises.unlink(cachedMetaFileURL);
134
151
  }
135
152
  } catch (e) {
136
153
  if (e.code !== "ENOENT") {
@@ -169,7 +186,10 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
169
186
  if (isLocalImage) {
170
187
  await fs.promises.writeFile(cachedFileURL, resultData.data);
171
188
  } else {
172
- await writeRemoteCacheFile(cachedFileURL, resultData, env);
189
+ await Promise.all([
190
+ fs.promises.writeFile(cachedFileURL, resultData.data),
191
+ writeCacheMetaFile(cachedMetaFileURL, resultData, env)
192
+ ]);
173
193
  }
174
194
  }
175
195
  } catch (e) {
@@ -190,12 +210,11 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
190
210
  };
191
211
  }
192
212
  }
193
- async function writeRemoteCacheFile(cachedFileURL, resultData, env) {
213
+ async function writeCacheMetaFile(cachedMetaFileURL, resultData, env) {
194
214
  try {
195
215
  return await fs.promises.writeFile(
196
- cachedFileURL,
216
+ cachedMetaFileURL,
197
217
  JSON.stringify({
198
- data: Buffer.from(resultData.data).toString("base64"),
199
218
  expires: resultData.expires,
200
219
  etag: resultData.etag,
201
220
  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;
@@ -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 })};
@@ -99,15 +99,31 @@ class ContentLayer {
99
99
  return this.#queue.add(() => this.#doSync(options));
100
100
  }
101
101
  async #doSync(options) {
102
- const contentConfig = globalContentConfigObserver.get();
102
+ let contentConfig = globalContentConfigObserver.get();
103
103
  const logger = this.#logger.forkIntegrationLogger("content");
104
+ if (contentConfig?.status === "loading") {
105
+ contentConfig = await Promise.race([
106
+ new Promise((resolve) => {
107
+ const unsub = globalContentConfigObserver.subscribe((ctx) => {
108
+ unsub();
109
+ resolve(ctx);
110
+ });
111
+ }),
112
+ new Promise(
113
+ (resolve) => setTimeout(
114
+ () => resolve({ status: "error", error: new Error("Content config loading timed out") }),
115
+ 5e3
116
+ )
117
+ )
118
+ ]);
119
+ }
104
120
  if (contentConfig?.status === "error") {
105
121
  logger.error(`Error loading content config. Skipping sync.
106
122
  ${contentConfig.error.message}`);
107
123
  return;
108
124
  }
109
125
  if (contentConfig?.status !== "loaded") {
110
- logger.error("Content config not loaded, skipping sync");
126
+ logger.error(`Content config not loaded, skipping sync. Status was ${contentConfig?.status}`);
111
127
  return;
112
128
  }
113
129
  logger.info("Syncing content");
@@ -128,11 +144,11 @@ ${contentConfig.error.message}`);
128
144
  logger.info("Astro config changed");
129
145
  shouldClear = true;
130
146
  }
131
- if (currentConfigDigest && previousConfigDigest !== currentConfigDigest) {
147
+ if (previousConfigDigest && previousConfigDigest !== currentConfigDigest) {
132
148
  logger.info("Content config changed");
133
149
  shouldClear = true;
134
150
  }
135
- if (previousAstroVersion !== "5.1.2") {
151
+ if (previousAstroVersion && previousAstroVersion !== "5.1.4") {
136
152
  logger.info("Astro version changed");
137
153
  shouldClear = true;
138
154
  }
@@ -140,8 +156,8 @@ ${contentConfig.error.message}`);
140
156
  logger.info("Clearing content store");
141
157
  this.#store.clearAll();
142
158
  }
143
- if ("5.1.2") {
144
- await this.#store.metaStore().set("astro-version", "5.1.2");
159
+ if ("5.1.4") {
160
+ await this.#store.metaStore().set("astro-version", "5.1.4");
145
161
  }
146
162
  if (currentConfigDigest) {
147
163
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -506,7 +506,7 @@ export declare function getContentEntryIdAndSlug({ entry, contentDir, collection
506
506
  id: string;
507
507
  slug: string;
508
508
  };
509
- export declare function getEntryType(entryPath: string, paths: Pick<ContentPaths, 'config' | 'contentDir'>, contentFileExts: string[], dataFileExts: string[]): 'content' | 'data' | 'config' | 'ignored';
509
+ export declare function getEntryType(entryPath: string, paths: Pick<ContentPaths, 'config' | 'contentDir' | 'root'>, contentFileExts: string[], dataFileExts: string[]): 'content' | 'data' | 'config' | 'ignored';
510
510
  export declare function safeParseFrontmatter(source: string, id?: string): import("@astrojs/markdown-remark").ParseFrontmatterResult;
511
511
  /**
512
512
  * The content config is loaded separately from other `src/` files.
@@ -549,6 +549,7 @@ type Observable<C> = {
549
549
  export type ContentObservable = Observable<ContentCtx>;
550
550
  export declare function contentObservable(initialCtx: ContentCtx): ContentObservable;
551
551
  export type ContentPaths = {
552
+ root: URL;
552
553
  contentDir: URL;
553
554
  assetsDir: URL;
554
555
  typesTemplate: URL;
@@ -558,7 +559,7 @@ export type ContentPaths = {
558
559
  url: URL;
559
560
  };
560
561
  };
561
- export declare function getContentPaths({ srcDir, legacy }: Pick<AstroConfig, 'root' | 'srcDir' | 'legacy'>, fs?: typeof fsMod): ContentPaths;
562
+ export declare function getContentPaths({ srcDir, legacy, root }: Pick<AstroConfig, 'root' | 'srcDir' | 'legacy'>, fs?: typeof fsMod): ContentPaths;
562
563
  /**
563
564
  * Check for slug in content entry frontmatter and validate the type,
564
565
  * falling back to the `generatedSlug` if none is found.
@@ -295,13 +295,20 @@ function getRelativeEntryPath(entry, collection, contentDir) {
295
295
  const relativeToCollection = path.relative(collection, relativeToContent);
296
296
  return relativeToCollection;
297
297
  }
298
+ function isParentDirectory(parent, child) {
299
+ const relative = path.relative(fileURLToPath(parent), fileURLToPath(child));
300
+ return !relative.startsWith("..") && !path.isAbsolute(relative);
301
+ }
298
302
  function getEntryType(entryPath, paths, contentFileExts, dataFileExts) {
299
303
  const { ext } = path.parse(entryPath);
300
304
  const fileUrl = pathToFileURL(entryPath);
305
+ const dotAstroDir = new URL("./.astro/", paths.root);
301
306
  if (fileUrl.href === paths.config.url.href) {
302
307
  return "config";
303
308
  } else if (hasUnderscoreBelowContentDirectoryPath(fileUrl, paths.contentDir)) {
304
309
  return "ignored";
310
+ } else if (isParentDirectory(dotAstroDir, fileUrl)) {
311
+ return "ignored";
305
312
  } else if (contentFileExts.includes(ext)) {
306
313
  return "content";
307
314
  } else if (dataFileExts.includes(ext)) {
@@ -509,10 +516,11 @@ function contentObservable(initialCtx) {
509
516
  subscribe
510
517
  };
511
518
  }
512
- function getContentPaths({ srcDir, legacy }, fs = fsMod) {
519
+ function getContentPaths({ srcDir, legacy, root }, fs = fsMod) {
513
520
  const configStats = search(fs, srcDir, legacy?.collections);
514
521
  const pkgBase = new URL("../../", import.meta.url);
515
522
  return {
523
+ root: new URL("./", root),
516
524
  contentDir: new URL("./content/", srcDir),
517
525
  assetsDir: new URL("./assets/", srcDir),
518
526
  typesTemplate: new URL("templates/content/types.d.ts", pkgBase),
@@ -36,17 +36,34 @@ 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
42
52
  }) {
43
53
  let dataStoreFile;
54
+ let devServer;
44
55
  return {
45
56
  name: "astro-content-virtual-mod-plugin",
46
57
  enforce: "pre",
47
58
  config(_, env) {
48
59
  dataStoreFile = getDataStoreFile(settings, env.command === "serve");
49
60
  },
61
+ buildStart() {
62
+ if (devServer) {
63
+ devServer.watcher.add(fileURLToPath(dataStoreFile));
64
+ invalidateDataStore(devServer);
65
+ }
66
+ },
50
67
  async resolveId(id) {
51
68
  if (id === VIRTUAL_MODULE_ID) {
52
69
  return RESOLVED_VIRTUAL_MODULE_ID;
@@ -137,26 +154,16 @@ function astroContentVirtualModPlugin({
137
154
  }
138
155
  },
139
156
  configureServer(server) {
157
+ devServer = server;
140
158
  const dataStorePath = fileURLToPath(dataStoreFile);
141
- server.watcher.add(dataStorePath);
142
- function invalidateDataStore() {
143
- const module = server.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
144
- if (module) {
145
- server.moduleGraph.invalidateModule(module);
146
- }
147
- server.ws.send({
148
- type: "full-reload",
149
- path: "*"
150
- });
151
- }
152
159
  server.watcher.on("add", (addedPath) => {
153
160
  if (addedPath === dataStorePath) {
154
- invalidateDataStore();
161
+ invalidateDataStore(server);
155
162
  }
156
163
  });
157
164
  server.watcher.on("change", (changedPath) => {
158
165
  if (changedPath === dataStorePath) {
159
- invalidateDataStore();
166
+ invalidateDataStore(server);
160
167
  }
161
168
  });
162
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);
@@ -207,7 +219,7 @@ class App {
207
219
  this.#logger.error(null, err.stack || err.message || String(err));
208
220
  return this.#renderError(request, { locals, status: 500, error: err, clientAddress });
209
221
  } finally {
210
- session?.[PERSIST_SYMBOL]();
222
+ await session?.[PERSIST_SYMBOL]();
211
223
  }
212
224
  if (REROUTABLE_STATUS_CODES.includes(response.status) && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
213
225
  return this.#renderError(request, {
@@ -302,7 +314,7 @@ class App {
302
314
  });
303
315
  }
304
316
  } finally {
305
- session?.[PERSIST_SYMBOL]();
317
+ await session?.[PERSIST_SYMBOL]();
306
318
  }
307
319
  }
308
320
  const response = this.#mergeResponses(new Response(null, { status }), originalResponse);
@@ -128,7 +128,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
128
128
  async function generatePathWithLogs(path, route, index, paths, isConcurrent) {
129
129
  const timeStart = performance.now();
130
130
  pipeline.logger.debug("build", `Generating: ${path}`);
131
- const filePath = getOutputFilename(config, path, pageData.route.type);
131
+ const filePath = getOutputFilename(config, path, pageData.route);
132
132
  const lineIcon = index === paths.length - 1 && !isConcurrent || paths.length === 1 ? "\u2514\u2500" : "\u251C\u2500";
133
133
  if (!isConcurrent) {
134
134
  logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false);
@@ -19,6 +19,7 @@ import { AstroError, AstroErrorData } from "../errors/index.js";
19
19
  import { levels, timerMessage } from "../logger/core.js";
20
20
  import { apply as applyPolyfill } from "../polyfill.js";
21
21
  import { createRouteManifest } from "../routing/index.js";
22
+ import { getServerIslandRouteData } from "../server-islands/endpoint.js";
22
23
  import { clearContentLayerCache } from "../sync/index.js";
23
24
  import { ensureProcessNodeEnv } from "../util.js";
24
25
  import { collectPagesData } from "./page-data.js";
@@ -157,7 +158,7 @@ class AstroBuilder {
157
158
  await runHookBuildDone({
158
159
  settings: this.settings,
159
160
  pages: pageNames,
160
- routes: Object.values(allPages).flat().map((pageData) => pageData.route),
161
+ routes: Object.values(allPages).flat().map((pageData) => pageData.route).concat(hasServerIslands ? getServerIslandRouteData(this.settings.config) : []),
161
162
  logging: this.logger
162
163
  });
163
164
  if (this.logger.level && levels[this.logger.level()] <= levels["info"]) {
@@ -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,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>;
@@ -1,7 +1,7 @@
1
- import { markdownConfigDefaults } from "@astrojs/markdown-remark";
2
- import { bundledThemes } from "shiki";
3
1
  import path from "node:path";
4
2
  import { fileURLToPath, pathToFileURL } from "node:url";
3
+ import { markdownConfigDefaults } from "@astrojs/markdown-remark";
4
+ import { bundledThemes } from "shiki";
5
5
  import { z } from "zod";
6
6
  import { EnvSchema } from "../../env/schema.js";
7
7
  import { appendForwardSlash, prependForwardSlash, removeTrailingForwardSlash } from "../path.js";
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.1.2";
1
+ const ASTRO_VERSION = "5.1.4";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "5.1.2";
25
+ const currentVersion = "5.1.4";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -50,23 +50,6 @@ async function dev(inlineConfig) {
50
50
  } catch {
51
51
  }
52
52
  }
53
- const devServerAddressInfo = await startContainer(restart.container);
54
- logger.info(
55
- "SKIP_FORMAT",
56
- msg.serverStart({
57
- startupTime: performance.now() - devStart,
58
- resolvedUrls: restart.container.viteServer.resolvedUrls || { local: [], network: [] },
59
- host: restart.container.settings.config.server.host,
60
- base: restart.container.settings.config.base
61
- })
62
- );
63
- if (isPrerelease) {
64
- logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
65
- }
66
- if (restart.container.viteServer.config.server?.fs?.strict === false) {
67
- logger.warn("SKIP_FORMAT", msg.fsStrictWarning());
68
- }
69
- await attachContentServerListeners(restart.container);
70
53
  let store;
71
54
  try {
72
55
  const dataStoreFile = getDataStoreFile(restart.container.settings, true);
@@ -79,6 +62,7 @@ async function dev(inlineConfig) {
79
62
  if (!store) {
80
63
  store = new MutableDataStore();
81
64
  }
65
+ await attachContentServerListeners(restart.container);
82
66
  const config = globalContentConfigObserver.get();
83
67
  if (config.status === "error") {
84
68
  logger.error("content", config.error.message);
@@ -92,6 +76,24 @@ async function dev(inlineConfig) {
92
76
  });
93
77
  contentLayer.watchContentConfig();
94
78
  await contentLayer.sync();
79
+ } else {
80
+ logger.warn("content", "Content config not loaded");
81
+ }
82
+ const devServerAddressInfo = await startContainer(restart.container);
83
+ logger.info(
84
+ "SKIP_FORMAT",
85
+ msg.serverStart({
86
+ startupTime: performance.now() - devStart,
87
+ resolvedUrls: restart.container.viteServer.resolvedUrls || { local: [], network: [] },
88
+ host: restart.container.settings.config.server.host,
89
+ base: restart.container.settings.config.base
90
+ })
91
+ );
92
+ if (isPrerelease) {
93
+ logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
94
+ }
95
+ if (restart.container.viteServer.config.server?.fs?.strict === false) {
96
+ logger.warn("SKIP_FORMAT", msg.fsStrictWarning());
95
97
  }
96
98
  logger.info(null, green("watching for file changes..."));
97
99
  return {