astro 6.0.0-alpha.1 → 6.0.0-alpha.2

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 (77) hide show
  1. package/dist/actions/vite-plugin-actions.js +49 -35
  2. package/dist/assets/consts.d.ts +1 -0
  3. package/dist/assets/consts.js +2 -0
  4. package/dist/assets/fonts/vite-plugin-fonts.js +10 -4
  5. package/dist/assets/services/noop.js +10 -5
  6. package/dist/assets/services/service.d.ts +1 -1
  7. package/dist/assets/services/service.js +55 -51
  8. package/dist/assets/types.d.ts +2 -2
  9. package/dist/assets/utils/index.d.ts +1 -1
  10. package/dist/assets/utils/index.js +4 -4
  11. package/dist/assets/vite-plugin-assets.js +30 -15
  12. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  13. package/dist/container/vite-plugin-container.js +7 -4
  14. package/dist/content/content-layer.js +3 -3
  15. package/dist/content/types-generator.js +10 -1
  16. package/dist/content/utils.js +9 -2
  17. package/dist/content/vite-plugin-content-assets.js +59 -53
  18. package/dist/content/vite-plugin-content-imports.js +48 -36
  19. package/dist/content/vite-plugin-content-virtual-mod.js +90 -75
  20. package/dist/core/app/validate-forwarded-headers.d.ts +1 -1
  21. package/dist/core/app/validate-forwarded-headers.js +1 -1
  22. package/dist/core/build/plugins/plugin-component-entry.js +10 -4
  23. package/dist/core/build/plugins/plugin-css.js +6 -2
  24. package/dist/core/build/plugins/plugin-noop.js +10 -4
  25. package/dist/core/build/plugins/plugin-ssr.js +30 -12
  26. package/dist/core/constants.js +1 -1
  27. package/dist/core/create-vite.js +5 -5
  28. package/dist/core/dev/dev.js +1 -1
  29. package/dist/core/errors/errors-data.d.ts +5 -9
  30. package/dist/core/errors/errors-data.js +6 -6
  31. package/dist/core/messages.js +2 -2
  32. package/dist/core/middleware/vite-plugin.js +24 -18
  33. package/dist/core/server-islands/vite-plugin-server-islands.js +70 -55
  34. package/dist/core/session/vite-plugin.js +10 -4
  35. package/dist/core/viteUtils.d.ts +1 -0
  36. package/dist/core/viteUtils.js +2 -0
  37. package/dist/env/vite-plugin-env.js +52 -38
  38. package/dist/env/vite-plugin-import-meta-env.js +44 -37
  39. package/dist/i18n/vite-plugin-i18n.js +7 -4
  40. package/dist/manifest/serialized.js +10 -4
  41. package/dist/manifest/virtual-module.js +29 -17
  42. package/dist/prefetch/vite-plugin-prefetch.js +20 -9
  43. package/dist/toolbar/vite-plugin-dev-toolbar.js +13 -7
  44. package/dist/transitions/vite-plugin-transitions.js +35 -22
  45. package/dist/types/public/config.d.ts +38 -5
  46. package/dist/types/public/extendables.d.ts +2 -0
  47. package/dist/vite-plugin-adapter-config/index.js +10 -4
  48. package/dist/vite-plugin-app/index.js +6 -3
  49. package/dist/vite-plugin-app/pipeline.js +1 -1
  50. package/dist/vite-plugin-astro/index.js +211 -180
  51. package/dist/vite-plugin-astro-server/index.d.ts +1 -1
  52. package/dist/vite-plugin-astro-server/index.js +2 -6
  53. package/dist/vite-plugin-astro-server/plugin.d.ts +0 -1
  54. package/dist/vite-plugin-astro-server/plugin.js +0 -57
  55. package/dist/vite-plugin-astro-server/util.d.ts +2 -0
  56. package/dist/vite-plugin-astro-server/util.js +3 -1
  57. package/dist/vite-plugin-chromedevtools/index.d.ts +7 -0
  58. package/dist/vite-plugin-chromedevtools/index.js +47 -0
  59. package/dist/vite-plugin-config-alias/index.js +19 -12
  60. package/dist/vite-plugin-css/index.js +73 -52
  61. package/dist/vite-plugin-fileurl/index.js +6 -3
  62. package/dist/vite-plugin-html/index.d.ts +7 -4
  63. package/dist/vite-plugin-html/index.js +5 -3
  64. package/dist/vite-plugin-load-fallback/index.js +12 -5
  65. package/dist/vite-plugin-markdown/index.js +27 -8
  66. package/dist/vite-plugin-overlay/index.d.ts +2 -0
  67. package/dist/vite-plugin-overlay/index.js +21 -0
  68. package/dist/vite-plugin-pages/page.js +10 -4
  69. package/dist/vite-plugin-pages/pages.js +10 -4
  70. package/dist/vite-plugin-renderers/index.js +11 -6
  71. package/dist/vite-plugin-routes/index.js +14 -10
  72. package/dist/vite-plugin-scripts/index.js +25 -19
  73. package/dist/vite-plugin-utils/index.d.ts +1 -0
  74. package/dist/vite-plugin-utils/index.js +2 -1
  75. package/package.json +3 -3
  76. package/dist/assets/utils/remotePattern.d.ts +0 -1
  77. package/dist/assets/utils/remotePattern.js +0 -16
@@ -35,22 +35,29 @@ function vitePluginActions({
35
35
  return {
36
36
  name: VIRTUAL_MODULE_ID,
37
37
  enforce: "pre",
38
- async resolveId(id) {
39
- if (id === VIRTUAL_MODULE_ID) {
40
- return RESOLVED_VIRTUAL_MODULE_ID;
41
- }
42
- if (id === OPTIONS_VIRTUAL_MODULE_ID) {
43
- return RESOLVED_OPTIONS_VIRTUAL_MODULE_ID;
44
- }
45
- if (id === ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID) {
46
- const resolvedModule = await this.resolve(
47
- `${decodeURI(new URL("actions", settings.config.srcDir).pathname)}`
48
- );
49
- if (!resolvedModule) {
50
- return RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID;
38
+ resolveId: {
39
+ filter: {
40
+ id: new RegExp(
41
+ `^(${VIRTUAL_MODULE_ID}|${OPTIONS_VIRTUAL_MODULE_ID}|${ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID})$`
42
+ )
43
+ },
44
+ async handler(id) {
45
+ if (id === VIRTUAL_MODULE_ID) {
46
+ return RESOLVED_VIRTUAL_MODULE_ID;
47
+ }
48
+ if (id === OPTIONS_VIRTUAL_MODULE_ID) {
49
+ return RESOLVED_OPTIONS_VIRTUAL_MODULE_ID;
50
+ }
51
+ if (id === ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID) {
52
+ const resolvedModule = await this.resolve(
53
+ `${decodeURI(new URL("actions", settings.config.srcDir).pathname)}`
54
+ );
55
+ if (!resolvedModule) {
56
+ return RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID;
57
+ }
58
+ resolvedActionsId = resolvedModule.id;
59
+ return ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID;
51
60
  }
52
- resolvedActionsId = resolvedModule.id;
53
- return ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID;
54
61
  }
55
62
  },
56
63
  async configureServer(server) {
@@ -64,31 +71,38 @@ function vitePluginActions({
64
71
  server.watcher.on("add", watcherCallback);
65
72
  server.watcher.on("change", watcherCallback);
66
73
  },
67
- async load(id) {
68
- if (id === RESOLVED_VIRTUAL_MODULE_ID) {
69
- if (this.environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client) {
74
+ load: {
75
+ filter: {
76
+ id: new RegExp(
77
+ `^(${RESOLVED_VIRTUAL_MODULE_ID}|${RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID}|${ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID}|${RESOLVED_OPTIONS_VIRTUAL_MODULE_ID})$`
78
+ )
79
+ },
80
+ async handler(id) {
81
+ if (id === RESOLVED_VIRTUAL_MODULE_ID) {
82
+ if (this.environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client) {
83
+ return {
84
+ code: `export * from 'astro/actions/runtime/entrypoints/client.js';`
85
+ };
86
+ }
70
87
  return {
71
- code: `export * from 'astro/actions/runtime/entrypoints/client.js';`
88
+ code: `export * from 'astro/actions/runtime/entrypoints/server.js';`
72
89
  };
73
90
  }
74
- return {
75
- code: `export * from 'astro/actions/runtime/entrypoints/server.js';`
76
- };
77
- }
78
- if (id === RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID) {
79
- return { code: "export const server = {}" };
80
- }
81
- if (id === ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID) {
82
- return { code: `export { server } from ${JSON.stringify(resolvedActionsId)};` };
83
- }
84
- if (id === RESOLVED_OPTIONS_VIRTUAL_MODULE_ID) {
85
- return {
86
- code: `
91
+ if (id === RESOLVED_NOOP_ENTRYPOINT_VIRTUAL_MODULE_ID) {
92
+ return { code: "export const server = {}" };
93
+ }
94
+ if (id === ACTIONS_RESOLVED_ENTRYPOINT_VIRTUAL_MODULE_ID) {
95
+ return { code: `export { server } from ${JSON.stringify(resolvedActionsId)};` };
96
+ }
97
+ if (id === RESOLVED_OPTIONS_VIRTUAL_MODULE_ID) {
98
+ return {
99
+ code: `
87
100
  export const shouldAppendTrailingSlash = ${JSON.stringify(
88
- shouldAppendForwardSlash(settings.config.trailingSlash, settings.config.build.format)
89
- )};
101
+ shouldAppendForwardSlash(settings.config.trailingSlash, settings.config.build.format)
102
+ )};
90
103
  `
91
- };
104
+ };
105
+ }
92
106
  }
93
107
  }
94
108
  };
@@ -1,4 +1,5 @@
1
1
  export declare const VIRTUAL_MODULE_ID = "astro:assets";
2
+ export declare const RESOLVED_VIRTUAL_MODULE_ID: string;
2
3
  export declare const VIRTUAL_SERVICE_ID = "virtual:image-service";
3
4
  export declare const VALID_INPUT_FORMATS: readonly ["jpeg", "jpg", "png", "tiff", "webp", "gif", "svg", "avif"];
4
5
  /**
@@ -1,4 +1,5 @@
1
1
  const VIRTUAL_MODULE_ID = "astro:assets";
2
+ const RESOLVED_VIRTUAL_MODULE_ID = "\0" + VIRTUAL_MODULE_ID;
2
3
  const VIRTUAL_SERVICE_ID = "virtual:image-service";
3
4
  const VALID_INPUT_FORMATS = [
4
5
  "jpeg",
@@ -34,6 +35,7 @@ const DEFAULT_HASH_PROPS = [
34
35
  export {
35
36
  DEFAULT_HASH_PROPS,
36
37
  DEFAULT_OUTPUT_FORMAT,
38
+ RESOLVED_VIRTUAL_MODULE_ID,
37
39
  VALID_INPUT_FORMATS,
38
40
  VALID_OUTPUT_FORMATS,
39
41
  VALID_SUPPORTED_FORMATS,
@@ -228,13 +228,19 @@ function fontsPlugin({ settings, sync, logger }) {
228
228
  }
229
229
  });
230
230
  },
231
- resolveId(id) {
232
- if (id === VIRTUAL_MODULE_ID) {
231
+ resolveId: {
232
+ filter: {
233
+ id: new RegExp(`^(${VIRTUAL_MODULE_ID})$`)
234
+ },
235
+ handler() {
233
236
  return RESOLVED_VIRTUAL_MODULE_ID;
234
237
  }
235
238
  },
236
- load(id) {
237
- if (id === RESOLVED_VIRTUAL_MODULE_ID) {
239
+ load: {
240
+ filter: {
241
+ id: new RegExp(`^(${RESOLVED_VIRTUAL_MODULE_ID})$`)
242
+ },
243
+ handler() {
238
244
  return {
239
245
  code: `
240
246
  export const internalConsumableMap = new Map(${JSON.stringify(Array.from(internalConsumableMap?.entries() ?? []))});
@@ -1,11 +1,16 @@
1
- import { baseService } from "./service.js";
1
+ import { isESMImportedImage } from "../utils/imageKind.js";
2
+ import { baseService, verifyOptions } from "./service.js";
2
3
  const noopService = {
3
4
  ...baseService,
4
5
  propertiesToHash: ["src"],
5
- async validateOptions(options, imageConfig) {
6
- const newOptions = await (baseService.validateOptions?.(options, imageConfig) ?? options);
7
- delete newOptions.format;
8
- return newOptions;
6
+ async validateOptions(options) {
7
+ if (isESMImportedImage(options.src) && options.src.format === "svg") {
8
+ options.format = "svg";
9
+ } else {
10
+ delete options.format;
11
+ }
12
+ verifyOptions(options);
13
+ return options;
9
14
  },
10
15
  async transform(inputBuffer, transformOptions) {
11
16
  return {
@@ -80,6 +80,7 @@ export type BaseServiceTransform = {
80
80
  fit?: ImageFit;
81
81
  position?: string;
82
82
  };
83
+ export declare function verifyOptions(options: ImageTransform): void;
83
84
  /**
84
85
  * Basic local service using the included `_image` endpoint.
85
86
  * This service intentionally does not implement `transform`.
@@ -95,7 +96,6 @@ export type BaseServiceTransform = {
95
96
  * ```
96
97
  *
97
98
  * This service adhere to the included services limitations:
98
- * - Remote images are passed as is.
99
99
  * - Only a limited amount of formats are supported.
100
100
  * - For remote images, `width` and `height` are always required.
101
101
  *
@@ -17,61 +17,64 @@ function parseQuality(quality) {
17
17
  return result;
18
18
  }
19
19
  const sortNumeric = (a, b) => a - b;
20
- const baseService = {
21
- propertiesToHash: DEFAULT_HASH_PROPS,
22
- validateOptions(options) {
23
- if (!options.src || !isRemoteImage(options.src) && !isESMImportedImage(options.src)) {
20
+ function verifyOptions(options) {
21
+ if (!options.src || !isRemoteImage(options.src) && !isESMImportedImage(options.src)) {
22
+ throw new AstroError({
23
+ ...AstroErrorData.ExpectedImage,
24
+ message: AstroErrorData.ExpectedImage.message(
25
+ JSON.stringify(options.src),
26
+ typeof options.src,
27
+ JSON.stringify(options, (_, v) => v === void 0 ? null : v)
28
+ )
29
+ });
30
+ }
31
+ if (!isESMImportedImage(options.src)) {
32
+ if (options.src.startsWith("/@fs/") || !isRemotePath(options.src) && !options.src.startsWith("/")) {
33
+ throw new AstroError({
34
+ ...AstroErrorData.LocalImageUsedWrongly,
35
+ message: AstroErrorData.LocalImageUsedWrongly.message(options.src)
36
+ });
37
+ }
38
+ let missingDimension;
39
+ if (!options.width && !options.height) {
40
+ missingDimension = "both";
41
+ } else if (!options.width && options.height) {
42
+ missingDimension = "width";
43
+ } else if (options.width && !options.height) {
44
+ missingDimension = "height";
45
+ }
46
+ if (missingDimension) {
24
47
  throw new AstroError({
25
- ...AstroErrorData.ExpectedImage,
26
- message: AstroErrorData.ExpectedImage.message(
27
- JSON.stringify(options.src),
28
- typeof options.src,
29
- JSON.stringify(options, (_, v) => v === void 0 ? null : v)
48
+ ...AstroErrorData.MissingImageDimension,
49
+ message: AstroErrorData.MissingImageDimension.message(missingDimension, options.src)
50
+ });
51
+ }
52
+ } else {
53
+ if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
54
+ throw new AstroError({
55
+ ...AstroErrorData.UnsupportedImageFormat,
56
+ message: AstroErrorData.UnsupportedImageFormat.message(
57
+ options.src.format,
58
+ options.src.src,
59
+ VALID_SUPPORTED_FORMATS
30
60
  )
31
61
  });
32
62
  }
33
- if (!isESMImportedImage(options.src)) {
34
- if (options.src.startsWith("/@fs/") || !isRemotePath(options.src) && !options.src.startsWith("/")) {
35
- throw new AstroError({
36
- ...AstroErrorData.LocalImageUsedWrongly,
37
- message: AstroErrorData.LocalImageUsedWrongly.message(options.src)
38
- });
39
- }
40
- let missingDimension;
41
- if (!options.width && !options.height) {
42
- missingDimension = "both";
43
- } else if (!options.width && options.height) {
44
- missingDimension = "width";
45
- } else if (options.width && !options.height) {
46
- missingDimension = "height";
47
- }
48
- if (missingDimension) {
49
- throw new AstroError({
50
- ...AstroErrorData.MissingImageDimension,
51
- message: AstroErrorData.MissingImageDimension.message(missingDimension, options.src)
52
- });
53
- }
54
- } else {
55
- if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
56
- throw new AstroError({
57
- ...AstroErrorData.UnsupportedImageFormat,
58
- message: AstroErrorData.UnsupportedImageFormat.message(
59
- options.src.format,
60
- options.src.src,
61
- VALID_SUPPORTED_FORMATS
62
- )
63
- });
64
- }
65
- if (options.widths && options.densities) {
66
- throw new AstroError(AstroErrorData.IncompatibleDescriptorOptions);
67
- }
68
- if (options.src.format === "svg") {
69
- options.format = "svg";
70
- }
71
- if (options.src.format === "svg" && options.format !== "svg" || options.src.format !== "svg" && options.format === "svg") {
72
- throw new AstroError(AstroErrorData.UnsupportedImageConversion);
73
- }
63
+ if (options.widths && options.densities) {
64
+ throw new AstroError(AstroErrorData.IncompatibleDescriptorOptions);
65
+ }
66
+ if (options.src.format === "svg" && options.format !== "svg" || options.src.format !== "svg" && options.format === "svg") {
67
+ throw new AstroError(AstroErrorData.UnsupportedImageConversion);
68
+ }
69
+ }
70
+ }
71
+ const baseService = {
72
+ propertiesToHash: DEFAULT_HASH_PROPS,
73
+ validateOptions(options) {
74
+ if (isESMImportedImage(options.src) && options.src.format === "svg") {
75
+ options.format = "svg";
74
76
  }
77
+ verifyOptions(options);
75
78
  if (!options.format) {
76
79
  options.format = DEFAULT_OUTPUT_FORMAT;
77
80
  }
@@ -234,5 +237,6 @@ function getTargetDimensions(options) {
234
237
  export {
235
238
  baseService,
236
239
  isLocalService,
237
- parseQuality
240
+ parseQuality,
241
+ verifyOptions
238
242
  };
@@ -72,7 +72,7 @@ export type ImageTransform = {
72
72
  fit?: ImageFit | undefined;
73
73
  position?: string | undefined;
74
74
  [key: string]: any;
75
- };
75
+ } & Astro.CustomImageProps;
76
76
  export interface GetImageResult {
77
77
  rawOptions: ImageTransform;
78
78
  options: ImageTransform;
@@ -201,7 +201,7 @@ type ImageSharedProps<T> = T & {
201
201
  layout?: never;
202
202
  fit?: never;
203
203
  position?: never;
204
- });
204
+ }) & Astro.CustomImageProps;
205
205
  export type LocalImageProps<T> = ImageSharedProps<T> & {
206
206
  /**
207
207
  * A reference to a local image imported through an ESM import.
@@ -4,8 +4,8 @@
4
4
  *
5
5
  * If some functions don't need to be exposed, just import the file that contains the functions.
6
6
  */
7
+ export { isRemoteAllowed, matchHostname, matchPathname, matchPattern, matchPort, matchProtocol, type RemotePattern, } from '@astrojs/internal-helpers/remote';
7
8
  export { isESMImportedImage, isRemoteImage, resolveSrc } from './imageKind.js';
8
9
  export { imageMetadata } from './metadata.js';
9
10
  export { getOrigQueryParams } from './queryParams.js';
10
- export { isRemoteAllowed, matchHostname, matchPathname, matchPattern, matchPort, matchProtocol, type RemotePattern, } from './remotePattern.js';
11
11
  export { inferRemoteSize } from './remoteProbe.js';
@@ -1,6 +1,3 @@
1
- import { isESMImportedImage, isRemoteImage, resolveSrc } from "./imageKind.js";
2
- import { imageMetadata } from "./metadata.js";
3
- import { getOrigQueryParams } from "./queryParams.js";
4
1
  import {
5
2
  isRemoteAllowed,
6
3
  matchHostname,
@@ -8,7 +5,10 @@ import {
8
5
  matchPattern,
9
6
  matchPort,
10
7
  matchProtocol
11
- } from "./remotePattern.js";
8
+ } from "@astrojs/internal-helpers/remote";
9
+ import { isESMImportedImage, isRemoteImage, resolveSrc } from "./imageKind.js";
10
+ import { imageMetadata } from "./metadata.js";
11
+ import { getOrigQueryParams } from "./queryParams.js";
12
12
  import { inferRemoteSize } from "./remoteProbe.js";
13
13
  export {
14
14
  getOrigQueryParams,
@@ -9,7 +9,13 @@ import {
9
9
  removeQueryString
10
10
  } from "../core/path.js";
11
11
  import { normalizePath } from "../core/viteUtils.js";
12
- import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from "./consts.js";
12
+ import { isAstroServerEnvironment } from "../environments.js";
13
+ import {
14
+ RESOLVED_VIRTUAL_MODULE_ID,
15
+ VALID_INPUT_FORMATS,
16
+ VIRTUAL_MODULE_ID,
17
+ VIRTUAL_SERVICE_ID
18
+ } from "./consts.js";
13
19
  import { fontsPlugin } from "./fonts/vite-plugin-fonts.js";
14
20
  import { getAssetsPrefix } from "./utils/getAssetsPrefix.js";
15
21
  import { isESMImportedImage } from "./utils/index.js";
@@ -17,8 +23,6 @@ import { emitImageMetadata, hashTransform, propsToFilename } from "./utils/node.
17
23
  import { getProxyCode } from "./utils/proxy.js";
18
24
  import { makeSvgComponent } from "./utils/svg.js";
19
25
  import { createPlaceholderURL, stringifyPlaceholderURL } from "./utils/url.js";
20
- import { isAstroServerEnvironment } from "../environments.js";
21
- const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
22
26
  const assetRegex = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})`, "i");
23
27
  const assetRegexEnds = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})$`, "i");
24
28
  const addStaticImageFactory = (settings) => {
@@ -85,19 +89,27 @@ function assets({ fs, settings, sync, logger }) {
85
89
  config(_, env) {
86
90
  isBuild = env.command === "build";
87
91
  },
88
- async resolveId(id, _importer) {
89
- if (id === VIRTUAL_SERVICE_ID) {
90
- if (isAstroServerEnvironment(this.environment)) {
91
- return await this.resolve(settings.config.image.service.entrypoint);
92
+ resolveId: {
93
+ filter: {
94
+ id: new RegExp(`^(${VIRTUAL_SERVICE_ID}|${VIRTUAL_MODULE_ID})$`)
95
+ },
96
+ async handler(id) {
97
+ if (id === VIRTUAL_SERVICE_ID) {
98
+ if (isAstroServerEnvironment(this.environment)) {
99
+ return await this.resolve(settings.config.image.service.entrypoint);
100
+ }
101
+ return await this.resolve("astro/assets/services/noop");
102
+ }
103
+ if (id === VIRTUAL_MODULE_ID) {
104
+ return RESOLVED_VIRTUAL_MODULE_ID;
92
105
  }
93
- return await this.resolve("astro/assets/services/noop");
94
- }
95
- if (id === VIRTUAL_MODULE_ID) {
96
- return resolvedVirtualModuleId;
97
106
  }
98
107
  },
99
- load(id) {
100
- if (id === resolvedVirtualModuleId) {
108
+ load: {
109
+ filter: {
110
+ id: new RegExp(`^(${RESOLVED_VIRTUAL_MODULE_ID})$`)
111
+ },
112
+ handler() {
101
113
  return {
102
114
  code: `
103
115
  export { getConfiguredImageService, isLocalService } from "astro/assets";
@@ -179,8 +191,11 @@ function assets({ fs, settings, sync, logger }) {
179
191
  configResolved(viteConfig) {
180
192
  resolvedConfig = viteConfig;
181
193
  },
182
- async load(id) {
183
- if (assetRegex.test(id)) {
194
+ load: {
195
+ filter: {
196
+ id: assetRegex
197
+ },
198
+ async handler(id) {
184
199
  if (!globalThis.astroAsset.referencedImages)
185
200
  globalThis.astroAsset.referencedImages = /* @__PURE__ */ new Set();
186
201
  if (id !== removeQueryString(id)) {
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "6.0.0-alpha.1";
3
+ version = "6.0.0-alpha.2";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -1,10 +1,13 @@
1
- const virtualModuleId = "astro:container";
1
+ const VIRTUAL_MODULE_ID = "astro:container";
2
2
  function astroContainer() {
3
3
  return {
4
- name: "astro:container",
4
+ name: VIRTUAL_MODULE_ID,
5
5
  enforce: "pre",
6
- resolveId(id) {
7
- if (id === virtualModuleId) {
6
+ resolveId: {
7
+ filter: {
8
+ id: new RegExp(`^(${VIRTUAL_MODULE_ID})$`)
9
+ },
10
+ handler() {
8
11
  return this.resolve("astro/virtual-modules/container.js");
9
12
  }
10
13
  }
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
164
164
  logger.info("Content config changed");
165
165
  shouldClear = true;
166
166
  }
167
- if (previousAstroVersion && previousAstroVersion !== "6.0.0-alpha.1") {
167
+ if (previousAstroVersion && previousAstroVersion !== "6.0.0-alpha.2") {
168
168
  logger.info("Astro version changed");
169
169
  shouldClear = true;
170
170
  }
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
172
172
  logger.info("Clearing content store");
173
173
  this.#store.clearAll();
174
174
  }
175
- if ("6.0.0-alpha.1") {
176
- await this.#store.metaStore().set("astro-version", "6.0.0-alpha.1");
175
+ if ("6.0.0-alpha.2") {
176
+ await this.#store.metaStore().set("astro-version", "6.0.0-alpha.2");
177
177
  }
178
178
  if (currentConfigDigest) {
179
179
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -451,7 +451,16 @@ async function generateJSONSchema(fsMod, collectionConfig, collectionKey, collec
451
451
  });
452
452
  }
453
453
  try {
454
- const schema = z.toJSONSchema(zodSchemaForJson);
454
+ const schema = z.toJSONSchema(zodSchemaForJson, {
455
+ unrepresentable: "any",
456
+ override: (ctx) => {
457
+ const def = ctx.zodSchema._zod.def;
458
+ if (def.type === "date") {
459
+ ctx.jsonSchema.type = "string";
460
+ ctx.jsonSchema.format = "date-time";
461
+ }
462
+ }
463
+ });
455
464
  const schemaStr = JSON.stringify(schema, null, 2);
456
465
  const schemaJsonPath = new URL(
457
466
  `./${collectionKey.replace(/"/g, "")}.schema.json`,
@@ -112,8 +112,15 @@ async function getEntryData(entry, collectionConfig, shouldEmitFile, pluginConte
112
112
  schema = schema({
113
113
  image: () => z.string().transform((val) => {
114
114
  let normalizedPath = val;
115
- if (val && !val.startsWith("./") && !val.startsWith("../") && !val.startsWith("/") && !val.startsWith("~") && !val.startsWith("@") && !val.includes("://")) {
116
- normalizedPath = `./${val}`;
115
+ const isUrl = val.includes("://");
116
+ const isAbsolute = val.startsWith("/");
117
+ const isRelative = val.startsWith(".");
118
+ if (val && !isUrl && !isAbsolute && !isRelative) {
119
+ const entryDir = path.dirname(entry._internal.filePath);
120
+ const resolvedPath = path.resolve(entryDir, val);
121
+ if (fsMod.existsSync(resolvedPath)) {
122
+ normalizedPath = `./${val}`;
123
+ }
117
124
  }
118
125
  return `${IMAGE_IMPORT_PREFIX}${normalizedPath}`;
119
126
  })