astro 3.6.2 → 4.0.0-beta.1

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 (135) hide show
  1. package/client.d.ts +19 -20
  2. package/components/Code.astro +0 -20
  3. package/components/ViewTransitions.astro +2 -2
  4. package/dist/@types/astro.d.ts +19 -81
  5. package/dist/assets/build/generate.js +2 -2
  6. package/dist/assets/internal.js +1 -1
  7. package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +3 -3
  8. package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +3 -3
  9. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +3 -3
  10. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +3 -3
  11. package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +3 -3
  12. package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +3 -3
  13. package/dist/cli/add/babel.d.ts +1 -1
  14. package/dist/cli/build/index.js +0 -1
  15. package/dist/cli/flags.js +0 -3
  16. package/dist/cli/info/index.d.ts +5 -0
  17. package/dist/cli/info/index.js +16 -7
  18. package/dist/cli/install-package.js +1 -1
  19. package/dist/cli/telemetry/index.js +6 -6
  20. package/dist/content/server-listeners.js +7 -7
  21. package/dist/content/types-generator.d.ts +1 -4
  22. package/dist/content/types-generator.js +31 -51
  23. package/dist/core/app/index.js +2 -4
  24. package/dist/core/build/buildPipeline.js +3 -3
  25. package/dist/core/build/generate.js +18 -39
  26. package/dist/core/build/index.js +10 -32
  27. package/dist/core/build/internal.js +3 -3
  28. package/dist/core/build/plugin.d.ts +2 -2
  29. package/dist/core/build/plugins/plugin-manifest.js +1 -4
  30. package/dist/core/build/plugins/plugin-pages.js +0 -3
  31. package/dist/core/build/plugins/plugin-renderers.d.ts +1 -1
  32. package/dist/core/build/plugins/plugin-ssr.js +5 -6
  33. package/dist/core/build/static-build.js +4 -7
  34. package/dist/core/build/types.d.ts +1 -1
  35. package/dist/core/build/util.js +1 -1
  36. package/dist/core/config/config.js +1 -2
  37. package/dist/core/config/schema.d.ts +209 -277
  38. package/dist/core/config/schema.js +5 -38
  39. package/dist/core/constants.js +1 -1
  40. package/dist/core/create-vite.d.ts +2 -2
  41. package/dist/core/create-vite.js +12 -1
  42. package/dist/core/dev/dev.js +6 -4
  43. package/dist/core/dev/restart.js +7 -7
  44. package/dist/core/endpoint/index.d.ts +2 -7
  45. package/dist/core/endpoint/index.js +3 -87
  46. package/dist/core/errors/dev/vite.js +0 -1
  47. package/dist/core/logger/console.d.ts +2 -4
  48. package/dist/core/logger/console.js +4 -28
  49. package/dist/core/logger/core.d.ts +17 -5
  50. package/dist/core/logger/core.js +27 -2
  51. package/dist/core/logger/node.d.ts +2 -32
  52. package/dist/core/logger/node.js +8 -69
  53. package/dist/core/messages.d.ts +4 -11
  54. package/dist/core/messages.js +43 -59
  55. package/dist/core/middleware/callMiddleware.d.ts +1 -2
  56. package/dist/core/middleware/callMiddleware.js +1 -12
  57. package/dist/core/middleware/index.d.ts +2 -2
  58. package/dist/core/middleware/sequence.d.ts +2 -2
  59. package/dist/core/pipeline.d.ts +2 -2
  60. package/dist/core/pipeline.js +8 -13
  61. package/dist/core/preview/static-preview-server.js +2 -4
  62. package/dist/core/preview/vite-plugin-astro-preview.js +31 -21
  63. package/dist/core/render/core.js +0 -6
  64. package/dist/core/render/index.d.ts +1 -1
  65. package/dist/core/render/result.js +1 -1
  66. package/dist/core/render/route-cache.js +2 -5
  67. package/dist/core/request.js +3 -3
  68. package/dist/core/routing/manifest/create.js +14 -12
  69. package/dist/core/routing/validation.js +4 -4
  70. package/dist/core/sync/index.js +2 -2
  71. package/dist/i18n/middleware.d.ts +2 -2
  72. package/dist/i18n/vite-plugin-i18n.js +1 -1
  73. package/dist/integrations/astroFeaturesValidation.d.ts +1 -1
  74. package/dist/integrations/astroFeaturesValidation.js +12 -18
  75. package/dist/integrations/index.js +28 -6
  76. package/dist/prefetch/vite-plugin-prefetch.js +3 -3
  77. package/dist/runtime/client/dev-overlay/entrypoint.js +14 -10
  78. package/dist/runtime/client/dev-overlay/overlay.js +1 -1
  79. package/dist/runtime/client/dev-overlay/plugins/astro.d.ts +14 -1
  80. package/dist/runtime/client/dev-overlay/plugins/astro.js +326 -15
  81. package/dist/runtime/client/dev-overlay/plugins/settings.js +26 -2
  82. package/dist/runtime/client/dev-overlay/plugins/utils/icons.d.ts +3 -0
  83. package/dist/runtime/client/dev-overlay/plugins/utils/icons.js +37 -0
  84. package/dist/runtime/client/dev-overlay/plugins/utils/window.d.ts +1 -2
  85. package/dist/runtime/client/dev-overlay/plugins/utils/window.js +25 -29
  86. package/dist/runtime/client/dev-overlay/ui-library/badge.d.ts +9 -0
  87. package/dist/runtime/client/dev-overlay/ui-library/badge.js +67 -0
  88. package/dist/runtime/client/dev-overlay/ui-library/button.d.ts +9 -0
  89. package/dist/runtime/client/dev-overlay/ui-library/button.js +83 -0
  90. package/dist/runtime/client/dev-overlay/ui-library/card.d.ts +1 -3
  91. package/dist/runtime/client/dev-overlay/ui-library/card.js +17 -25
  92. package/dist/runtime/client/dev-overlay/ui-library/highlight.js +1 -0
  93. package/dist/runtime/client/dev-overlay/ui-library/icon.d.ts +10 -0
  94. package/dist/runtime/client/dev-overlay/ui-library/icon.js +36 -0
  95. package/dist/runtime/client/dev-overlay/ui-library/icons.d.ts +21 -6
  96. package/dist/runtime/client/dev-overlay/ui-library/icons.js +22 -7
  97. package/dist/runtime/client/dev-overlay/ui-library/index.d.ts +8 -0
  98. package/dist/runtime/client/dev-overlay/ui-library/index.js +18 -0
  99. package/dist/runtime/client/dev-overlay/ui-library/window.d.ts +0 -4
  100. package/dist/runtime/client/dev-overlay/ui-library/window.js +0 -33
  101. package/dist/runtime/server/endpoint.d.ts +1 -1
  102. package/dist/runtime/server/endpoint.js +11 -22
  103. package/dist/transitions/vite-plugin-transitions.js +4 -4
  104. package/dist/virtual-modules/i18n.d.ts +1 -0
  105. package/dist/virtual-modules/i18n.js +1 -0
  106. package/dist/virtual-modules/middleware.d.ts +1 -0
  107. package/dist/virtual-modules/middleware.js +5 -0
  108. package/dist/virtual-modules/prefetch.d.ts +1 -0
  109. package/dist/virtual-modules/prefetch.js +1 -0
  110. package/dist/virtual-modules/transitions-events.d.ts +1 -0
  111. package/dist/virtual-modules/transitions-events.js +1 -0
  112. package/dist/virtual-modules/transitions-router.d.ts +1 -0
  113. package/dist/virtual-modules/transitions-router.js +1 -0
  114. package/dist/virtual-modules/transitions-types.d.ts +1 -0
  115. package/dist/virtual-modules/transitions-types.js +1 -0
  116. package/dist/virtual-modules/transitions.d.ts +1 -0
  117. package/dist/virtual-modules/transitions.js +1 -0
  118. package/dist/vite-plugin-astro/hmr.js +8 -14
  119. package/dist/vite-plugin-astro/index.js +28 -6
  120. package/dist/vite-plugin-astro-server/base.js +5 -5
  121. package/dist/vite-plugin-astro-server/response.js +1 -1
  122. package/dist/vite-plugin-astro-server/route.js +30 -6
  123. package/dist/vite-plugin-inject-env-ts/index.js +3 -3
  124. package/dist/vite-plugin-integrations-container/index.js +1 -1
  125. package/dist/vite-plugin-load-fallback/index.js +1 -3
  126. package/dist/vite-plugin-scanner/index.js +3 -6
  127. package/dist/vite-plugin-scripts/index.js +1 -1
  128. package/dist/vite-plugin-utils/index.d.ts +1 -0
  129. package/dist/vite-plugin-utils/index.js +5 -0
  130. package/package.json +56 -68
  131. package/dist/core/middleware/namespace.d.ts +0 -1
  132. package/dist/core/middleware/namespace.js +0 -5
  133. package/dist/vite-plugin-astro-server/common.d.ts +0 -2
  134. package/dist/vite-plugin-astro-server/common.js +0 -7
  135. package/import-meta.d.ts +0 -30
@@ -7,16 +7,7 @@ const UNSUPPORTED_ASSETS_FEATURE = {
7
7
  isSquooshCompatible: false,
8
8
  isSharpCompatible: false
9
9
  };
10
- const ALL_UNSUPPORTED = {
11
- serverOutput: UNSUPPORTED,
12
- staticOutput: UNSUPPORTED,
13
- hybridOutput: UNSUPPORTED,
14
- assets: UNSUPPORTED_ASSETS_FEATURE,
15
- i18n: {
16
- detectBrowserLanguage: UNSUPPORTED
17
- }
18
- };
19
- function validateSupportedFeatures(adapterName, featureMap = ALL_UNSUPPORTED, config, logger) {
10
+ function validateSupportedFeatures(adapterName, featureMap, config, logger) {
20
11
  const {
21
12
  assets = UNSUPPORTED_ASSETS_FEATURE,
22
13
  serverOutput = UNSUPPORTED,
@@ -64,16 +55,19 @@ function validateSupportKind(supportKind, adapterName, logger, featureName, hasC
64
55
  }
65
56
  }
66
57
  function featureIsUnsupported(adapterName, logger, featureName) {
67
- logger.error(
68
- `${adapterName}`,
69
- `The feature ${featureName} is not supported by the adapter ${adapterName}.`
70
- );
58
+ logger.error("config", `The feature ${featureName} is not supported (used by ${adapterName}).`);
71
59
  }
72
60
  function featureIsExperimental(adapterName, logger) {
73
- logger.warn(`${adapterName}`, "The feature is experimental and subject to issues or changes.");
61
+ logger.warn(
62
+ "config",
63
+ `The feature is experimental and subject to change (used by ${adapterName}).`
64
+ );
74
65
  }
75
66
  function featureIsDeprecated(adapterName, logger) {
76
- logger.warn(`${adapterName}`, "The feature is deprecated and will be moved in the next release.");
67
+ logger.warn(
68
+ "config",
69
+ `The feature is deprecated and will be removed in the future (used by ${adapterName}).`
70
+ );
77
71
  }
78
72
  const SHARP_SERVICE = "astro/assets/services/sharp";
79
73
  const SQUOOSH_SERVICE = "astro/assets/services/squoosh";
@@ -85,14 +79,14 @@ function validateAssetsFeature(assets, adapterName, config, logger) {
85
79
  } = assets;
86
80
  if (config?.image?.service?.entrypoint === SHARP_SERVICE && !isSharpCompatible) {
87
81
  logger.warn(
88
- "astro",
82
+ null,
89
83
  `The currently selected adapter \`${adapterName}\` is not compatible with the image service "Sharp".`
90
84
  );
91
85
  return false;
92
86
  }
93
87
  if (config?.image?.service?.entrypoint === SQUOOSH_SERVICE && !isSquooshCompatible) {
94
88
  logger.warn(
95
- "astro",
89
+ null,
96
90
  `The currently selected adapter \`${adapterName}\` is not compatible with the image service "Squoosh".`
97
91
  );
98
92
  return false;
@@ -1,4 +1,4 @@
1
- import { bold } from "kleur/colors";
1
+ import { bold, cyan, underline } from "kleur/colors";
2
2
  import fs from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { buildClientDirectiveEntrypoint } from "../core/client-directive/index.js";
@@ -8,12 +8,18 @@ import { isServerLikeOutput } from "../prerender/utils.js";
8
8
  import { validateSupportedFeatures } from "./astroFeaturesValidation.js";
9
9
  async function withTakingALongTimeMsg({
10
10
  name,
11
+ hookName,
11
12
  hookResult,
12
13
  timeoutMs = 3e3,
13
14
  logger
14
15
  }) {
15
16
  const timeout = setTimeout(() => {
16
- logger.info("build", `Waiting for the ${bold(name)} integration...`);
17
+ logger.info(
18
+ "build",
19
+ `Waiting for integration ${bold(JSON.stringify(name))}, hook ${bold(
20
+ JSON.stringify(hookName)
21
+ )}...`
22
+ );
17
23
  }, timeoutMs);
18
24
  const result = await hookResult;
19
25
  clearTimeout(timeout);
@@ -78,6 +84,13 @@ async function runHookConfigSetup({
78
84
  updatedConfig = mergeConfig(updatedConfig, newConfig);
79
85
  },
80
86
  injectRoute: (injectRoute) => {
87
+ if (injectRoute.entrypoint == null && "entryPoint" in injectRoute) {
88
+ logger.warn(
89
+ null,
90
+ `The injected route "${injectRoute.pattern}" by ${integration.name} specifies the entry point with the "entryPoint" property. This property is deprecated, please use "entrypoint" instead.`
91
+ );
92
+ injectRoute.entrypoint = injectRoute.entryPoint;
93
+ }
81
94
  updatedSettings.injectedRoutes.push(injectRoute);
82
95
  },
83
96
  addWatchFile: (path) => {
@@ -125,6 +138,7 @@ async function runHookConfigSetup({
125
138
  });
126
139
  await withTakingALongTimeMsg({
127
140
  name: integration.name,
141
+ hookName: "astro:config:setup",
128
142
  hookResult: integration.hooks["astro:config:setup"](hooks),
129
143
  logger
130
144
  });
@@ -147,6 +161,7 @@ async function runHookConfigDone({
147
161
  if (integration?.hooks?.["astro:config:done"]) {
148
162
  await withTakingALongTimeMsg({
149
163
  name: integration.name,
164
+ hookName: "astro:config:done",
150
165
  hookResult: integration.hooks["astro:config:done"]({
151
166
  config: settings.config,
152
167
  setAdapter(adapter) {
@@ -156,9 +171,8 @@ async function runHookConfigDone({
156
171
  );
157
172
  }
158
173
  if (!adapter.supportedAstroFeatures) {
159
- logger.warn(
160
- "astro",
161
- `The adapter ${adapter.name} doesn't provide a feature map. From Astro 3.0, an adapter can provide a feature map. Not providing a feature map will cause an error in Astro 4.0.`
174
+ throw new Error(
175
+ `The adapter ${adapter.name} doesn't provide a feature map. It is required in Astro 4.0.`
162
176
  );
163
177
  } else {
164
178
  const validationResult = validateSupportedFeatures(
@@ -170,7 +184,7 @@ async function runHookConfigDone({
170
184
  for (const [featureName, supported] of Object.entries(validationResult)) {
171
185
  if (!supported && featureName !== "assets") {
172
186
  logger.error(
173
- "astro",
187
+ null,
174
188
  `The adapter ${adapter.name} doesn't support the feature ${featureName}. Your project won't be built. You should not use it.`
175
189
  );
176
190
  }
@@ -194,6 +208,7 @@ async function runHookServerSetup({
194
208
  if (integration?.hooks?.["astro:server:setup"]) {
195
209
  await withTakingALongTimeMsg({
196
210
  name: integration.name,
211
+ hookName: "astro:server:setup",
197
212
  hookResult: integration.hooks["astro:server:setup"]({
198
213
  server,
199
214
  logger: getLogger(integration, logger)
@@ -212,6 +227,7 @@ async function runHookServerStart({
212
227
  if (integration?.hooks?.["astro:server:start"]) {
213
228
  await withTakingALongTimeMsg({
214
229
  name: integration.name,
230
+ hookName: "astro:server:start",
215
231
  hookResult: integration.hooks["astro:server:start"]({
216
232
  address,
217
233
  logger: getLogger(integration, logger)
@@ -229,6 +245,7 @@ async function runHookServerDone({
229
245
  if (integration?.hooks?.["astro:server:done"]) {
230
246
  await withTakingALongTimeMsg({
231
247
  name: integration.name,
248
+ hookName: "astro:server:done",
232
249
  hookResult: integration.hooks["astro:server:done"]({
233
250
  logger: getLogger(integration, logger)
234
251
  }),
@@ -246,6 +263,7 @@ async function runHookBuildStart({
246
263
  const logger = getLogger(integration, logging);
247
264
  await withTakingALongTimeMsg({
248
265
  name: integration.name,
266
+ hookName: "astro:build:start",
249
267
  hookResult: integration.hooks["astro:build:start"]({ logger }),
250
268
  logger: logging
251
269
  });
@@ -264,6 +282,7 @@ async function runHookBuildSetup({
264
282
  if (integration?.hooks?.["astro:build:setup"]) {
265
283
  await withTakingALongTimeMsg({
266
284
  name: integration.name,
285
+ hookName: "astro:build:setup",
267
286
  hookResult: integration.hooks["astro:build:setup"]({
268
287
  vite,
269
288
  pages,
@@ -290,6 +309,7 @@ async function runHookBuildSsr({
290
309
  if (integration?.hooks?.["astro:build:ssr"]) {
291
310
  await withTakingALongTimeMsg({
292
311
  name: integration.name,
312
+ hookName: "astro:build:ssr",
293
313
  hookResult: integration.hooks["astro:build:ssr"]({
294
314
  manifest,
295
315
  entryPoints,
@@ -310,6 +330,7 @@ async function runHookBuildGenerated({
310
330
  if (integration?.hooks?.["astro:build:generated"]) {
311
331
  await withTakingALongTimeMsg({
312
332
  name: integration.name,
333
+ hookName: "astro:build:generated",
313
334
  hookResult: integration.hooks["astro:build:generated"]({
314
335
  dir,
315
336
  logger: getLogger(integration, logger)
@@ -327,6 +348,7 @@ async function runHookBuildDone({ config, pages, routes, logging }) {
327
348
  const logger = getLogger(integration, logging);
328
349
  await withTakingALongTimeMsg({
329
350
  name: integration.name,
351
+ hookName: "astro:build:done",
330
352
  hookResult: integration.hooks["astro:build:done"]({
331
353
  pages: pages.map((p) => ({ pathname: p })),
332
354
  dir,
@@ -2,14 +2,14 @@ import * as vite from "vite";
2
2
  const virtualModuleId = "astro:prefetch";
3
3
  const resolvedVirtualModuleId = "\0" + virtualModuleId;
4
4
  const prefetchInternalModuleFsSubpath = "astro/dist/prefetch/index.js";
5
- const prefetchCode = `import { init } from 'astro/prefetch';init()`;
5
+ const prefetchCode = `import { init } from 'astro/virtual-modules/prefetch.js';init()`;
6
6
  function astroPrefetch({ settings }) {
7
7
  const prefetchOption = settings.config.prefetch;
8
8
  const prefetch = prefetchOption ? typeof prefetchOption === "object" ? prefetchOption : {} : void 0;
9
9
  if (prefetch && settings.scripts.every((s) => s.content !== prefetchCode)) {
10
10
  settings.scripts.push({
11
11
  stage: "page",
12
- content: `import { init } from 'astro/prefetch';init()`
12
+ content: `import { init } from 'astro/virtual-modules/prefetch.js';init()`
13
13
  });
14
14
  }
15
15
  const throwPrefetchNotEnabledError = () => {
@@ -28,7 +28,7 @@ function astroPrefetch({ settings }) {
28
28
  if (id === resolvedVirtualModuleId) {
29
29
  if (!prefetch)
30
30
  throwPrefetchNotEnabledError();
31
- return `export { prefetch } from "astro/prefetch";`;
31
+ return `export { prefetch } from "astro/virtual-modules/prefetch.js";`;
32
32
  }
33
33
  },
34
34
  transform(code, id) {
@@ -9,11 +9,16 @@ document.addEventListener("DOMContentLoaded", async () => {
9
9
  { default: astroXrayPlugin },
10
10
  { default: astroSettingsPlugin },
11
11
  { AstroDevOverlay, DevOverlayCanvas },
12
- { DevOverlayCard },
13
- { DevOverlayHighlight },
14
- { DevOverlayTooltip },
15
- { DevOverlayWindow },
16
- { DevOverlayToggle },
12
+ {
13
+ DevOverlayCard,
14
+ DevOverlayHighlight,
15
+ DevOverlayTooltip,
16
+ DevOverlayWindow,
17
+ DevOverlayToggle,
18
+ DevOverlayButton,
19
+ DevOverlayBadge,
20
+ DevOverlayIcon
21
+ },
17
22
  { getIconElement, isDefinedIcon }
18
23
  ] = await Promise.all([
19
24
  // @ts-expect-error
@@ -23,11 +28,7 @@ document.addEventListener("DOMContentLoaded", async () => {
23
28
  import("./plugins/xray.js"),
24
29
  import("./plugins/settings.js"),
25
30
  import("./overlay.js"),
26
- import("./ui-library/card.js"),
27
- import("./ui-library/highlight.js"),
28
- import("./ui-library/tooltip.js"),
29
- import("./ui-library/window.js"),
30
- import("./ui-library/toggle.js"),
31
+ import("./ui-library/index.js"),
31
32
  import("./ui-library/icons.js")
32
33
  ]);
33
34
  customElements.define("astro-dev-overlay", AstroDevOverlay);
@@ -37,6 +38,9 @@ document.addEventListener("DOMContentLoaded", async () => {
37
38
  customElements.define("astro-dev-overlay-highlight", DevOverlayHighlight);
38
39
  customElements.define("astro-dev-overlay-card", DevOverlayCard);
39
40
  customElements.define("astro-dev-overlay-toggle", DevOverlayToggle);
41
+ customElements.define("astro-dev-overlay-button", DevOverlayButton);
42
+ customElements.define("astro-dev-overlay-badge", DevOverlayBadge);
43
+ customElements.define("astro-dev-overlay-icon", DevOverlayIcon);
40
44
  overlay = document.createElement("astro-dev-overlay");
41
45
  const preparePlugin = (pluginDefinition, builtIn) => {
42
46
  const eventTarget = new EventTarget();
@@ -187,7 +187,7 @@ class AstroDevOverlay extends HTMLElement {
187
187
  transition: opacity 0.2s ease-in-out;
188
188
  pointer-events: auto;
189
189
  border: 0;
190
- color: white;
190
+ color: #13151A;
191
191
  font-family: system-ui, sans-serif;
192
192
  font-size: 1rem;
193
193
  line-height: 1.2;
@@ -1,8 +1,21 @@
1
+ export interface Integration {
2
+ name: string;
3
+ title: string;
4
+ description: string;
5
+ image?: string;
6
+ categories: string[];
7
+ repoUrl: string;
8
+ npmUrl: string;
9
+ homepageUrl: string;
10
+ official: boolean;
11
+ featured: number;
12
+ downloads: number;
13
+ }
1
14
  declare const _default: {
2
15
  id: string;
3
16
  name: string;
4
17
  icon: "astro:logo";
5
- init(canvas: ShadowRoot): void;
18
+ init(canvas: ShadowRoot, eventTarget: EventTarget): Promise<void>;
6
19
  beforeTogglingOff(canvas: ShadowRoot): Promise<boolean>;
7
20
  };
8
21
  export default _default;