astro 5.5.6 → 5.6.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 (52) hide show
  1. package/client.d.ts +1 -16
  2. package/dist/actions/plugins.js +1 -1
  3. package/dist/assets/runtime.js +5 -29
  4. package/dist/assets/utils/svg.d.ts +1 -4
  5. package/dist/assets/utils/svg.js +2 -2
  6. package/dist/assets/vite-plugin-assets.js +31 -30
  7. package/dist/container/index.js +1 -1
  8. package/dist/content/content-layer.js +3 -3
  9. package/dist/content/vite-plugin-content-virtual-mod.js +7 -9
  10. package/dist/core/app/index.d.ts +15 -0
  11. package/dist/core/app/index.js +27 -7
  12. package/dist/core/build/index.js +2 -2
  13. package/dist/core/build/plugins/plugin-component-entry.js +3 -1
  14. package/dist/core/build/plugins/plugin-manifest.js +1 -1
  15. package/dist/core/build/plugins/plugin-pages.js +1 -1
  16. package/dist/core/build/plugins/plugin-prerender.js +3 -0
  17. package/dist/core/build/plugins/plugin-renderers.js +3 -3
  18. package/dist/core/build/plugins/plugin-ssr.js +2 -2
  19. package/dist/core/config/index.d.ts +1 -1
  20. package/dist/core/config/schemas/base.d.ts +1110 -0
  21. package/dist/core/config/{schema.js → schemas/base.js} +9 -254
  22. package/dist/core/config/schemas/index.d.ts +3 -0
  23. package/dist/core/config/schemas/index.js +9 -0
  24. package/dist/core/config/schemas/refined.d.ts +3 -0
  25. package/dist/core/config/schemas/refined.js +141 -0
  26. package/dist/core/config/schemas/relative.d.ts +1462 -0
  27. package/dist/core/config/schemas/relative.js +93 -0
  28. package/dist/core/config/validate.d.ts +6 -0
  29. package/dist/core/config/validate.js +9 -3
  30. package/dist/core/constants.js +1 -1
  31. package/dist/core/dev/dev.js +1 -1
  32. package/dist/core/messages.js +2 -2
  33. package/dist/core/middleware/vite-plugin.js +3 -3
  34. package/dist/core/server-islands/vite-plugin-server-islands.js +1 -1
  35. package/dist/core/session.d.ts +8 -0
  36. package/dist/core/session.js +13 -0
  37. package/dist/env/vite-plugin-env.js +3 -3
  38. package/dist/events/session.js +1 -1
  39. package/dist/integrations/hooks.d.ts +4 -4
  40. package/dist/integrations/hooks.js +276 -280
  41. package/dist/manifest/virtual-module.js +2 -2
  42. package/dist/prefetch/index.d.ts +8 -0
  43. package/dist/prefetch/index.js +6 -4
  44. package/dist/prefetch/vite-plugin-prefetch.js +1 -1
  45. package/dist/toolbar/vite-plugin-dev-toolbar.js +41 -39
  46. package/dist/transitions/vite-plugin-transitions.js +22 -18
  47. package/dist/types/public/config.d.ts +3 -25
  48. package/dist/vite-plugin-load-fallback/index.js +4 -2
  49. package/dist/vite-plugin-scripts/index.js +9 -3
  50. package/dist/vite-plugin-ssr-manifest/index.js +4 -3
  51. package/package.json +4 -4
  52. package/dist/core/config/schema.d.ts +0 -3402
@@ -9,15 +9,16 @@ import { globalContentLayer } from "../content/content-layer.js";
9
9
  import { globalContentConfigObserver } from "../content/utils.js";
10
10
  import { buildClientDirectiveEntrypoint } from "../core/client-directive/index.js";
11
11
  import { mergeConfig } from "../core/config/index.js";
12
+ import { validateConfigRefined } from "../core/config/validate.js";
12
13
  import { validateSetAdapter } from "../core/dev/adapter-validation.js";
13
14
  import { validateSessionConfig } from "../core/session.js";
14
15
  import { validateSupportedFeatures } from "./features-validation.js";
15
16
  async function withTakingALongTimeMsg({
16
17
  name,
17
18
  hookName,
18
- hookResult,
19
- timeoutMs = 3e3,
20
- logger
19
+ hookFn,
20
+ logger,
21
+ integrationLogger
21
22
  }) {
22
23
  const timeout = setTimeout(() => {
23
24
  logger.info(
@@ -26,10 +27,36 @@ async function withTakingALongTimeMsg({
26
27
  JSON.stringify(hookName)
27
28
  )}...`
28
29
  );
29
- }, timeoutMs);
30
- const result = await hookResult;
31
- clearTimeout(timeout);
32
- return result;
30
+ }, 3e3);
31
+ try {
32
+ return await hookFn();
33
+ } catch (err) {
34
+ integrationLogger.error(
35
+ `An unhandled error occurred while running the ${bold(JSON.stringify(hookName))} hook`
36
+ );
37
+ throw err;
38
+ } finally {
39
+ clearTimeout(timeout);
40
+ }
41
+ }
42
+ async function runHookInternal({
43
+ integration,
44
+ hookName,
45
+ logger,
46
+ params
47
+ }) {
48
+ const hook = integration?.hooks?.[hookName];
49
+ const integrationLogger = getLogger(integration, logger);
50
+ if (hook) {
51
+ await withTakingALongTimeMsg({
52
+ name: integration.name,
53
+ hookName,
54
+ hookFn: () => hook(Object.assign(params(), { logger: integrationLogger })),
55
+ logger,
56
+ integrationLogger
57
+ });
58
+ }
59
+ return { integrationLogger };
33
60
  }
34
61
  const Loggers = /* @__PURE__ */ new WeakMap();
35
62
  function getLogger(integration, logger) {
@@ -108,118 +135,130 @@ async function runHookConfigSetup({
108
135
  let astroJSXRenderer = null;
109
136
  for (let i = 0; i < updatedConfig.integrations.length; i++) {
110
137
  const integration = updatedConfig.integrations[i];
111
- if (integration.hooks?.["astro:config:setup"]) {
112
- let addPageExtension2 = function(...input) {
113
- const exts = input.flat(Infinity).map((ext) => `.${ext.replace(/^\./, "")}`);
114
- updatedSettings.pageExtensions.push(...exts);
115
- }, addContentEntryType2 = function(contentEntryType) {
116
- updatedSettings.contentEntryTypes.push(contentEntryType);
117
- }, addDataEntryType2 = function(dataEntryType) {
118
- updatedSettings.dataEntryTypes.push(dataEntryType);
119
- };
120
- var addPageExtension = addPageExtension2, addContentEntryType = addContentEntryType2, addDataEntryType = addDataEntryType2;
121
- const integrationLogger = getLogger(integration, logger);
122
- const hooks = {
123
- config: updatedConfig,
124
- command,
125
- isRestart,
126
- addRenderer(renderer) {
127
- if (!renderer.name) {
128
- throw new Error(`Integration ${bold(integration.name)} has an unnamed renderer.`);
129
- }
130
- if (!renderer.serverEntrypoint) {
131
- throw new Error(`Renderer ${bold(renderer.name)} does not provide a serverEntrypoint.`);
132
- }
133
- if (renderer.name === "astro:jsx") {
134
- astroJSXRenderer = renderer;
135
- } else {
136
- updatedSettings.renderers.push(renderer);
137
- }
138
- },
139
- injectScript: (stage, content) => {
140
- updatedSettings.scripts.push({ stage, content });
141
- },
142
- updateConfig: (newConfig) => {
143
- updatedConfig = mergeConfig(updatedConfig, newConfig);
144
- return { ...updatedConfig };
145
- },
146
- injectRoute: (injectRoute) => {
147
- if (injectRoute.entrypoint == null && "entryPoint" in injectRoute) {
148
- logger.warn(
149
- null,
150
- `The injected route "${injectRoute.pattern}" by ${integration.name} specifies the entry point with the "entryPoint" property. This property is deprecated, please use "entrypoint" instead.`
138
+ const { integrationLogger } = await runHookInternal({
139
+ integration,
140
+ hookName: "astro:config:setup",
141
+ logger,
142
+ params: () => {
143
+ const hooks = {
144
+ config: updatedConfig,
145
+ command,
146
+ isRestart,
147
+ addRenderer(renderer) {
148
+ if (!renderer.name) {
149
+ throw new Error(`Integration ${bold(integration.name)} has an unnamed renderer.`);
150
+ }
151
+ if (!renderer.serverEntrypoint) {
152
+ throw new Error(
153
+ `Renderer ${bold(renderer.name)} does not provide a serverEntrypoint.`
154
+ );
155
+ }
156
+ if (renderer.name === "astro:jsx") {
157
+ astroJSXRenderer = renderer;
158
+ } else {
159
+ updatedSettings.renderers.push(renderer);
160
+ }
161
+ },
162
+ injectScript: (stage, content) => {
163
+ updatedSettings.scripts.push({ stage, content });
164
+ },
165
+ updateConfig: (newConfig) => {
166
+ updatedConfig = mergeConfig(updatedConfig, newConfig);
167
+ return { ...updatedConfig };
168
+ },
169
+ injectRoute: (injectRoute) => {
170
+ if (injectRoute.entrypoint == null && "entryPoint" in injectRoute) {
171
+ logger.warn(
172
+ null,
173
+ `The injected route "${injectRoute.pattern}" by ${integration.name} specifies the entry point with the "entryPoint" property. This property is deprecated, please use "entrypoint" instead.`
174
+ );
175
+ injectRoute.entrypoint = injectRoute.entryPoint;
176
+ }
177
+ updatedSettings.injectedRoutes.push({ ...injectRoute, origin: "external" });
178
+ },
179
+ addWatchFile: (path) => {
180
+ updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path);
181
+ },
182
+ addDevToolbarApp: (entrypoint) => {
183
+ updatedSettings.devToolbarApps.push(entrypoint);
184
+ },
185
+ addClientDirective: ({ name, entrypoint }) => {
186
+ if (updatedSettings.clientDirectives.has(name) || addedClientDirectives.has(name)) {
187
+ throw new Error(
188
+ `The "${integration.name}" integration is trying to add the "${name}" client directive, but it already exists.`
189
+ );
190
+ }
191
+ addedClientDirectives.set(
192
+ name,
193
+ buildClientDirectiveEntrypoint(name, entrypoint, settings.config.root)
151
194
  );
152
- injectRoute.entrypoint = injectRoute.entryPoint;
153
- }
154
- updatedSettings.injectedRoutes.push({ ...injectRoute, origin: "external" });
155
- },
156
- addWatchFile: (path) => {
157
- updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path);
158
- },
159
- addDevToolbarApp: (entrypoint) => {
160
- updatedSettings.devToolbarApps.push(entrypoint);
161
- },
162
- addClientDirective: ({ name, entrypoint }) => {
163
- if (updatedSettings.clientDirectives.has(name) || addedClientDirectives.has(name)) {
164
- throw new Error(
165
- `The "${integration.name}" integration is trying to add the "${name}" client directive, but it already exists.`
195
+ },
196
+ addMiddleware: ({ order, entrypoint }) => {
197
+ if (typeof updatedSettings.middlewares[order] === "undefined") {
198
+ throw new Error(
199
+ `The "${integration.name}" integration is trying to add middleware but did not specify an order.`
200
+ );
201
+ }
202
+ logger.debug(
203
+ "middleware",
204
+ `The integration ${integration.name} has added middleware that runs ${order === "pre" ? "before" : "after"} any application middleware you define.`
166
205
  );
167
- }
168
- addedClientDirectives.set(
169
- name,
170
- buildClientDirectiveEntrypoint(name, entrypoint, settings.config.root)
171
- );
172
- },
173
- addMiddleware: ({ order, entrypoint }) => {
174
- if (typeof updatedSettings.middlewares[order] === "undefined") {
175
- throw new Error(
176
- `The "${integration.name}" integration is trying to add middleware but did not specify an order.`
206
+ updatedSettings.middlewares[order].push(
207
+ typeof entrypoint === "string" ? entrypoint : fileURLToPath(entrypoint)
177
208
  );
209
+ },
210
+ createCodegenDir: () => {
211
+ const codegenDir = new URL(normalizeCodegenDir(integration.name), settings.dotAstroDir);
212
+ fs.mkdirSync(codegenDir, { recursive: true });
213
+ return codegenDir;
178
214
  }
179
- logger.debug(
180
- "middleware",
181
- `The integration ${integration.name} has added middleware that runs ${order === "pre" ? "before" : "after"} any application middleware you define.`
182
- );
183
- updatedSettings.middlewares[order].push(
184
- typeof entrypoint === "string" ? entrypoint : fileURLToPath(entrypoint)
215
+ };
216
+ function addPageExtension(...input) {
217
+ const exts = input.flat(Infinity).map(
218
+ (ext) => `.${ext.replace(/^\./, "")}`
185
219
  );
186
- },
187
- createCodegenDir: () => {
188
- const codegenDir = new URL(normalizeCodegenDir(integration.name), settings.dotAstroDir);
189
- fs.mkdirSync(codegenDir, { recursive: true });
190
- return codegenDir;
191
- },
192
- logger: integrationLogger
193
- };
194
- Object.defineProperty(hooks, "addPageExtension", {
195
- value: addPageExtension2,
196
- writable: false,
197
- enumerable: false
198
- });
199
- Object.defineProperty(hooks, "addContentEntryType", {
200
- value: addContentEntryType2,
201
- writable: false,
202
- enumerable: false
203
- });
204
- Object.defineProperty(hooks, "addDataEntryType", {
205
- value: addDataEntryType2,
206
- writable: false,
207
- enumerable: false
208
- });
209
- await withTakingALongTimeMsg({
210
- name: integration.name,
211
- hookName: "astro:config:setup",
212
- hookResult: integration.hooks["astro:config:setup"](hooks),
213
- logger
214
- });
215
- for (const [name, compiled] of addedClientDirectives) {
216
- updatedSettings.clientDirectives.set(name, await compiled);
220
+ updatedSettings.pageExtensions.push(...exts);
221
+ }
222
+ function addContentEntryType(contentEntryType) {
223
+ updatedSettings.contentEntryTypes.push(contentEntryType);
224
+ }
225
+ function addDataEntryType(dataEntryType) {
226
+ updatedSettings.dataEntryTypes.push(dataEntryType);
227
+ }
228
+ Object.defineProperty(hooks, "addPageExtension", {
229
+ value: addPageExtension,
230
+ writable: false,
231
+ enumerable: false
232
+ });
233
+ Object.defineProperty(hooks, "addContentEntryType", {
234
+ value: addContentEntryType,
235
+ writable: false,
236
+ enumerable: false
237
+ });
238
+ Object.defineProperty(hooks, "addDataEntryType", {
239
+ value: addDataEntryType,
240
+ writable: false,
241
+ enumerable: false
242
+ });
243
+ return hooks;
217
244
  }
245
+ });
246
+ for (const [name, compiled] of addedClientDirectives) {
247
+ updatedSettings.clientDirectives.set(name, await compiled);
248
+ }
249
+ try {
250
+ updatedConfig = await validateConfigRefined(updatedConfig);
251
+ } catch (error) {
252
+ integrationLogger.error("An error occurred while updating the config");
253
+ throw error;
218
254
  }
219
255
  }
220
256
  if (astroJSXRenderer) {
221
257
  updatedSettings.renderers.push(astroJSXRenderer);
222
258
  }
259
+ if (updatedConfig.i18n && typeof updatedConfig.i18n.routing !== "string") {
260
+ updatedConfig.i18n.routing.redirectToDefaultLocale ??= updatedConfig.i18n.routing.prefixDefaultLocale || false;
261
+ }
223
262
  updatedSettings.config = updatedConfig;
224
263
  return updatedSettings;
225
264
  }
@@ -229,50 +268,47 @@ async function runHookConfigDone({
229
268
  command
230
269
  }) {
231
270
  for (const integration of settings.config.integrations) {
232
- if (integration?.hooks?.["astro:config:done"]) {
233
- await withTakingALongTimeMsg({
234
- name: integration.name,
235
- hookName: "astro:config:done",
236
- hookResult: integration.hooks["astro:config:done"]({
237
- config: settings.config,
238
- setAdapter(adapter) {
239
- validateSetAdapter(logger, settings, adapter, integration.name, command);
240
- if (adapter.adapterFeatures?.buildOutput !== "static") {
241
- settings.buildOutput = "server";
242
- }
243
- if (!adapter.supportedAstroFeatures) {
244
- throw new Error(
245
- `The adapter ${adapter.name} doesn't provide a feature map. It is required in Astro 4.0.`
246
- );
247
- } else {
248
- validateSupportedFeatures(
249
- adapter.name,
250
- adapter.supportedAstroFeatures,
251
- settings,
252
- logger
253
- );
254
- }
255
- settings.adapter = adapter;
256
- },
257
- injectTypes(injectedType) {
258
- const normalizedFilename = normalizeInjectedTypeFilename(
259
- injectedType.filename,
260
- integration.name
271
+ await runHookInternal({
272
+ integration,
273
+ hookName: "astro:config:done",
274
+ logger,
275
+ params: () => ({
276
+ config: settings.config,
277
+ setAdapter(adapter) {
278
+ validateSetAdapter(logger, settings, adapter, integration.name, command);
279
+ if (adapter.adapterFeatures?.buildOutput !== "static") {
280
+ settings.buildOutput = "server";
281
+ }
282
+ if (!adapter.supportedAstroFeatures) {
283
+ throw new Error(
284
+ `The adapter ${adapter.name} doesn't provide a feature map. It is required in Astro 4.0.`
285
+ );
286
+ } else {
287
+ validateSupportedFeatures(
288
+ adapter.name,
289
+ adapter.supportedAstroFeatures,
290
+ settings,
291
+ logger
261
292
  );
262
- settings.injectedTypes.push({
263
- filename: normalizedFilename,
264
- content: injectedType.content
265
- });
266
- return new URL(normalizedFilename, settings.dotAstroDir);
267
- },
268
- logger: getLogger(integration, logger),
269
- get buildOutput() {
270
- return settings.buildOutput;
271
293
  }
272
- }),
273
- logger
274
- });
275
- }
294
+ settings.adapter = adapter;
295
+ },
296
+ injectTypes(injectedType) {
297
+ const normalizedFilename = normalizeInjectedTypeFilename(
298
+ injectedType.filename,
299
+ integration.name
300
+ );
301
+ settings.injectedTypes.push({
302
+ filename: normalizedFilename,
303
+ content: injectedType.content
304
+ });
305
+ return new URL(normalizedFilename, settings.dotAstroDir);
306
+ },
307
+ get buildOutput() {
308
+ return settings.buildOutput;
309
+ }
310
+ })
311
+ });
276
312
  }
277
313
  validateSessionConfig(settings);
278
314
  }
@@ -293,19 +329,16 @@ async function runHookServerSetup({
293
329
  await contentLayer?.sync(options);
294
330
  };
295
331
  for (const integration of config.integrations) {
296
- if (integration?.hooks?.["astro:server:setup"]) {
297
- await withTakingALongTimeMsg({
298
- name: integration.name,
299
- hookName: "astro:server:setup",
300
- hookResult: integration.hooks["astro:server:setup"]({
301
- server,
302
- logger: getLogger(integration, logger),
303
- toolbar: getToolbarServerCommunicationHelpers(server),
304
- refreshContent
305
- }),
306
- logger
307
- });
308
- }
332
+ await runHookInternal({
333
+ integration,
334
+ hookName: "astro:server:setup",
335
+ logger,
336
+ params: () => ({
337
+ server,
338
+ toolbar: getToolbarServerCommunicationHelpers(server),
339
+ refreshContent
340
+ })
341
+ });
309
342
  }
310
343
  }
311
344
  async function runHookServerStart({
@@ -314,17 +347,12 @@ async function runHookServerStart({
314
347
  logger
315
348
  }) {
316
349
  for (const integration of config.integrations) {
317
- if (integration?.hooks?.["astro:server:start"]) {
318
- await withTakingALongTimeMsg({
319
- name: integration.name,
320
- hookName: "astro:server:start",
321
- hookResult: integration.hooks["astro:server:start"]({
322
- address,
323
- logger: getLogger(integration, logger)
324
- }),
325
- logger
326
- });
327
- }
350
+ await runHookInternal({
351
+ integration,
352
+ hookName: "astro:server:start",
353
+ logger,
354
+ params: () => ({ address })
355
+ });
328
356
  }
329
357
  }
330
358
  async function runHookServerDone({
@@ -332,32 +360,25 @@ async function runHookServerDone({
332
360
  logger
333
361
  }) {
334
362
  for (const integration of config.integrations) {
335
- if (integration?.hooks?.["astro:server:done"]) {
336
- await withTakingALongTimeMsg({
337
- name: integration.name,
338
- hookName: "astro:server:done",
339
- hookResult: integration.hooks["astro:server:done"]({
340
- logger: getLogger(integration, logger)
341
- }),
342
- logger
343
- });
344
- }
363
+ await runHookInternal({
364
+ integration,
365
+ hookName: "astro:server:done",
366
+ logger,
367
+ params: () => ({})
368
+ });
345
369
  }
346
370
  }
347
371
  async function runHookBuildStart({
348
372
  config,
349
- logging
373
+ logger
350
374
  }) {
351
375
  for (const integration of config.integrations) {
352
- if (integration?.hooks?.["astro:build:start"]) {
353
- const logger = getLogger(integration, logging);
354
- await withTakingALongTimeMsg({
355
- name: integration.name,
356
- hookName: "astro:build:start",
357
- hookResult: integration.hooks["astro:build:start"]({ logger }),
358
- logger: logging
359
- });
360
- }
376
+ await runHookInternal({
377
+ integration,
378
+ hookName: "astro:build:start",
379
+ logger,
380
+ params: () => ({})
381
+ });
361
382
  }
362
383
  }
363
384
  async function runHookBuildSetup({
@@ -369,23 +390,20 @@ async function runHookBuildSetup({
369
390
  }) {
370
391
  let updatedConfig = vite;
371
392
  for (const integration of config.integrations) {
372
- if (integration?.hooks?.["astro:build:setup"]) {
373
- await withTakingALongTimeMsg({
374
- name: integration.name,
375
- hookName: "astro:build:setup",
376
- hookResult: integration.hooks["astro:build:setup"]({
377
- vite,
378
- pages,
379
- target,
380
- updateConfig: (newConfig) => {
381
- updatedConfig = mergeViteConfig(updatedConfig, newConfig);
382
- return { ...updatedConfig };
383
- },
384
- logger: getLogger(integration, logger)
385
- }),
386
- logger
387
- });
388
- }
393
+ await runHookInternal({
394
+ integration,
395
+ hookName: "astro:build:setup",
396
+ logger,
397
+ params: () => ({
398
+ vite,
399
+ pages,
400
+ target,
401
+ updateConfig: (newConfig) => {
402
+ updatedConfig = mergeViteConfig(updatedConfig, newConfig);
403
+ return { ...updatedConfig };
404
+ }
405
+ })
406
+ });
389
407
  }
390
408
  return updatedConfig;
391
409
  }
@@ -401,19 +419,16 @@ async function runHookBuildSsr({
401
419
  entryPointsMap.set(toIntegrationRouteData(key), value);
402
420
  }
403
421
  for (const integration of config.integrations) {
404
- if (integration?.hooks?.["astro:build:ssr"]) {
405
- await withTakingALongTimeMsg({
406
- name: integration.name,
407
- hookName: "astro:build:ssr",
408
- hookResult: integration.hooks["astro:build:ssr"]({
409
- manifest,
410
- entryPoints: entryPointsMap,
411
- middlewareEntryPoint,
412
- logger: getLogger(integration, logger)
413
- }),
414
- logger
415
- });
416
- }
422
+ await runHookInternal({
423
+ integration,
424
+ hookName: "astro:build:ssr",
425
+ logger,
426
+ params: () => ({
427
+ manifest,
428
+ entryPoints: entryPointsMap,
429
+ middlewareEntryPoint
430
+ })
431
+ });
417
432
  }
418
433
  }
419
434
  async function runHookBuildGenerated({
@@ -422,41 +437,32 @@ async function runHookBuildGenerated({
422
437
  }) {
423
438
  const dir = settings.buildOutput === "server" ? settings.config.build.client : settings.config.outDir;
424
439
  for (const integration of settings.config.integrations) {
425
- if (integration?.hooks?.["astro:build:generated"]) {
426
- await withTakingALongTimeMsg({
427
- name: integration.name,
428
- hookName: "astro:build:generated",
429
- hookResult: integration.hooks["astro:build:generated"]({
430
- dir,
431
- logger: getLogger(integration, logger)
432
- }),
433
- logger
434
- });
435
- }
440
+ await runHookInternal({
441
+ integration,
442
+ hookName: "astro:build:generated",
443
+ logger,
444
+ params: () => ({ dir })
445
+ });
436
446
  }
437
447
  }
438
- async function runHookBuildDone({ settings, pages, routes, logging }) {
448
+ async function runHookBuildDone({ settings, pages, routes, logger }) {
439
449
  const dir = settings.buildOutput === "server" ? settings.config.build.client : settings.config.outDir;
440
450
  await fsMod.promises.mkdir(dir, { recursive: true });
441
451
  const integrationRoutes = routes.map(toIntegrationRouteData);
442
452
  for (const integration of settings.config.integrations) {
443
- if (integration?.hooks?.["astro:build:done"]) {
444
- const logger = getLogger(integration, logging);
445
- await withTakingALongTimeMsg({
446
- name: integration.name,
447
- hookName: "astro:build:done",
448
- hookResult: integration.hooks["astro:build:done"]({
449
- pages: pages.map((p) => ({ pathname: p })),
450
- dir,
451
- routes: integrationRoutes,
452
- assets: new Map(
453
- routes.filter((r) => r.distURL !== void 0).map((r) => [r.route, r.distURL])
454
- ),
455
- logger
456
- }),
457
- logger: logging
458
- });
459
- }
453
+ await runHookInternal({
454
+ integration,
455
+ hookName: "astro:build:done",
456
+ logger,
457
+ params: () => ({
458
+ pages: pages.map((p) => ({ pathname: p })),
459
+ dir,
460
+ routes: integrationRoutes,
461
+ assets: new Map(
462
+ routes.filter((r) => r.distURL !== void 0).map((r) => [r.route, r.distURL])
463
+ )
464
+ })
465
+ });
460
466
  }
461
467
  }
462
468
  async function runHookRouteSetup({
@@ -466,21 +472,15 @@ async function runHookRouteSetup({
466
472
  }) {
467
473
  const prerenderChangeLogs = [];
468
474
  for (const integration of settings.config.integrations) {
469
- if (integration?.hooks?.["astro:route:setup"]) {
470
- const originalRoute = { ...route };
471
- const integrationLogger = getLogger(integration, logger);
472
- await withTakingALongTimeMsg({
473
- name: integration.name,
474
- hookName: "astro:route:setup",
475
- hookResult: integration.hooks["astro:route:setup"]({
476
- route,
477
- logger: integrationLogger
478
- }),
479
- logger
480
- });
481
- if (route.prerender !== originalRoute.prerender) {
482
- prerenderChangeLogs.push({ integrationName: integration.name, value: route.prerender });
483
- }
475
+ const originalRoute = { ...route };
476
+ await runHookInternal({
477
+ integration,
478
+ hookName: "astro:route:setup",
479
+ logger,
480
+ params: () => ({ route })
481
+ });
482
+ if (route.prerender !== originalRoute.prerender) {
483
+ prerenderChangeLogs.push({ integrationName: integration.name, value: route.prerender });
484
484
  }
485
485
  }
486
486
  if (prerenderChangeLogs.length > 1) {
@@ -497,18 +497,14 @@ async function runHookRoutesResolved({
497
497
  logger
498
498
  }) {
499
499
  for (const integration of settings.config.integrations) {
500
- if (integration?.hooks?.["astro:routes:resolved"]) {
501
- const integrationLogger = getLogger(integration, logger);
502
- await withTakingALongTimeMsg({
503
- name: integration.name,
504
- hookName: "astro:routes:resolved",
505
- hookResult: integration.hooks["astro:routes:resolved"]({
506
- routes: routes.map((route) => toIntegrationResolvedRoute(route)),
507
- logger: integrationLogger
508
- }),
509
- logger
510
- });
511
- }
500
+ await runHookInternal({
501
+ integration,
502
+ hookName: "astro:routes:resolved",
503
+ logger,
504
+ params: () => ({
505
+ routes: routes.map((route) => toIntegrationResolvedRoute(route))
506
+ })
507
+ });
512
508
  }
513
509
  }
514
510
  function toIntegrationResolvedRoute(route) {