astro 5.5.5 → 5.6.0

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/client.d.ts +1 -16
  2. package/dist/actions/runtime/utils.d.ts +8 -2
  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 +1 -3
  7. package/dist/cli/add/index.js +1 -1
  8. package/dist/container/index.js +1 -1
  9. package/dist/content/content-layer.js +3 -3
  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/config/index.d.ts +1 -1
  14. package/dist/core/config/schemas/base.d.ts +1110 -0
  15. package/dist/core/config/{schema.js → schemas/base.js} +8 -254
  16. package/dist/core/config/schemas/index.d.ts +3 -0
  17. package/dist/core/config/schemas/index.js +9 -0
  18. package/dist/core/config/schemas/refined.d.ts +3 -0
  19. package/dist/core/config/schemas/refined.js +148 -0
  20. package/dist/core/config/schemas/relative.d.ts +1462 -0
  21. package/dist/core/config/schemas/relative.js +93 -0
  22. package/dist/core/config/validate.d.ts +6 -0
  23. package/dist/core/config/validate.js +9 -3
  24. package/dist/core/constants.js +1 -1
  25. package/dist/core/dev/dev.js +1 -1
  26. package/dist/core/errors/errors-data.d.ts +1 -1
  27. package/dist/core/errors/errors-data.js +1 -1
  28. package/dist/core/messages.js +2 -2
  29. package/dist/core/render-context.js +5 -2
  30. package/dist/core/session.d.ts +8 -0
  31. package/dist/core/session.js +13 -0
  32. package/dist/events/session.js +1 -1
  33. package/dist/i18n/index.d.ts +1 -0
  34. package/dist/i18n/index.js +12 -0
  35. package/dist/i18n/utils.js +7 -11
  36. package/dist/integrations/hooks.d.ts +4 -4
  37. package/dist/integrations/hooks.js +273 -280
  38. package/dist/prefetch/index.d.ts +8 -0
  39. package/dist/prefetch/index.js +6 -4
  40. package/dist/types/public/config.d.ts +3 -25
  41. package/dist/types/public/context.d.ts +1 -1
  42. package/package.json +11 -11
  43. 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,113 +135,122 @@ 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) {
@@ -229,50 +265,47 @@ async function runHookConfigDone({
229
265
  command
230
266
  }) {
231
267
  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
268
+ await runHookInternal({
269
+ integration,
270
+ hookName: "astro:config:done",
271
+ logger,
272
+ params: () => ({
273
+ config: settings.config,
274
+ setAdapter(adapter) {
275
+ validateSetAdapter(logger, settings, adapter, integration.name, command);
276
+ if (adapter.adapterFeatures?.buildOutput !== "static") {
277
+ settings.buildOutput = "server";
278
+ }
279
+ if (!adapter.supportedAstroFeatures) {
280
+ throw new Error(
281
+ `The adapter ${adapter.name} doesn't provide a feature map. It is required in Astro 4.0.`
282
+ );
283
+ } else {
284
+ validateSupportedFeatures(
285
+ adapter.name,
286
+ adapter.supportedAstroFeatures,
287
+ settings,
288
+ logger
261
289
  );
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
290
  }
272
- }),
273
- logger
274
- });
275
- }
291
+ settings.adapter = adapter;
292
+ },
293
+ injectTypes(injectedType) {
294
+ const normalizedFilename = normalizeInjectedTypeFilename(
295
+ injectedType.filename,
296
+ integration.name
297
+ );
298
+ settings.injectedTypes.push({
299
+ filename: normalizedFilename,
300
+ content: injectedType.content
301
+ });
302
+ return new URL(normalizedFilename, settings.dotAstroDir);
303
+ },
304
+ get buildOutput() {
305
+ return settings.buildOutput;
306
+ }
307
+ })
308
+ });
276
309
  }
277
310
  validateSessionConfig(settings);
278
311
  }
@@ -293,19 +326,16 @@ async function runHookServerSetup({
293
326
  await contentLayer?.sync(options);
294
327
  };
295
328
  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
- }
329
+ await runHookInternal({
330
+ integration,
331
+ hookName: "astro:server:setup",
332
+ logger,
333
+ params: () => ({
334
+ server,
335
+ toolbar: getToolbarServerCommunicationHelpers(server),
336
+ refreshContent
337
+ })
338
+ });
309
339
  }
310
340
  }
311
341
  async function runHookServerStart({
@@ -314,17 +344,12 @@ async function runHookServerStart({
314
344
  logger
315
345
  }) {
316
346
  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
- }
347
+ await runHookInternal({
348
+ integration,
349
+ hookName: "astro:server:start",
350
+ logger,
351
+ params: () => ({ address })
352
+ });
328
353
  }
329
354
  }
330
355
  async function runHookServerDone({
@@ -332,32 +357,25 @@ async function runHookServerDone({
332
357
  logger
333
358
  }) {
334
359
  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
- }
360
+ await runHookInternal({
361
+ integration,
362
+ hookName: "astro:server:done",
363
+ logger,
364
+ params: () => ({})
365
+ });
345
366
  }
346
367
  }
347
368
  async function runHookBuildStart({
348
369
  config,
349
- logging
370
+ logger
350
371
  }) {
351
372
  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
- }
373
+ await runHookInternal({
374
+ integration,
375
+ hookName: "astro:build:start",
376
+ logger,
377
+ params: () => ({})
378
+ });
361
379
  }
362
380
  }
363
381
  async function runHookBuildSetup({
@@ -369,23 +387,20 @@ async function runHookBuildSetup({
369
387
  }) {
370
388
  let updatedConfig = vite;
371
389
  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
- }
390
+ await runHookInternal({
391
+ integration,
392
+ hookName: "astro:build:setup",
393
+ logger,
394
+ params: () => ({
395
+ vite,
396
+ pages,
397
+ target,
398
+ updateConfig: (newConfig) => {
399
+ updatedConfig = mergeViteConfig(updatedConfig, newConfig);
400
+ return { ...updatedConfig };
401
+ }
402
+ })
403
+ });
389
404
  }
390
405
  return updatedConfig;
391
406
  }
@@ -401,19 +416,16 @@ async function runHookBuildSsr({
401
416
  entryPointsMap.set(toIntegrationRouteData(key), value);
402
417
  }
403
418
  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
- }
419
+ await runHookInternal({
420
+ integration,
421
+ hookName: "astro:build:ssr",
422
+ logger,
423
+ params: () => ({
424
+ manifest,
425
+ entryPoints: entryPointsMap,
426
+ middlewareEntryPoint
427
+ })
428
+ });
417
429
  }
418
430
  }
419
431
  async function runHookBuildGenerated({
@@ -422,41 +434,32 @@ async function runHookBuildGenerated({
422
434
  }) {
423
435
  const dir = settings.buildOutput === "server" ? settings.config.build.client : settings.config.outDir;
424
436
  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
- }
437
+ await runHookInternal({
438
+ integration,
439
+ hookName: "astro:build:generated",
440
+ logger,
441
+ params: () => ({ dir })
442
+ });
436
443
  }
437
444
  }
438
- async function runHookBuildDone({ settings, pages, routes, logging }) {
445
+ async function runHookBuildDone({ settings, pages, routes, logger }) {
439
446
  const dir = settings.buildOutput === "server" ? settings.config.build.client : settings.config.outDir;
440
447
  await fsMod.promises.mkdir(dir, { recursive: true });
441
448
  const integrationRoutes = routes.map(toIntegrationRouteData);
442
449
  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
- }
450
+ await runHookInternal({
451
+ integration,
452
+ hookName: "astro:build:done",
453
+ logger,
454
+ params: () => ({
455
+ pages: pages.map((p) => ({ pathname: p })),
456
+ dir,
457
+ routes: integrationRoutes,
458
+ assets: new Map(
459
+ routes.filter((r) => r.distURL !== void 0).map((r) => [r.route, r.distURL])
460
+ )
461
+ })
462
+ });
460
463
  }
461
464
  }
462
465
  async function runHookRouteSetup({
@@ -466,21 +469,15 @@ async function runHookRouteSetup({
466
469
  }) {
467
470
  const prerenderChangeLogs = [];
468
471
  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
- }
472
+ const originalRoute = { ...route };
473
+ await runHookInternal({
474
+ integration,
475
+ hookName: "astro:route:setup",
476
+ logger,
477
+ params: () => ({ route })
478
+ });
479
+ if (route.prerender !== originalRoute.prerender) {
480
+ prerenderChangeLogs.push({ integrationName: integration.name, value: route.prerender });
484
481
  }
485
482
  }
486
483
  if (prerenderChangeLogs.length > 1) {
@@ -497,18 +494,14 @@ async function runHookRoutesResolved({
497
494
  logger
498
495
  }) {
499
496
  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
- }
497
+ await runHookInternal({
498
+ integration,
499
+ hookName: "astro:routes:resolved",
500
+ logger,
501
+ params: () => ({
502
+ routes: routes.map((route) => toIntegrationResolvedRoute(route))
503
+ })
504
+ });
512
505
  }
513
506
  }
514
507
  function toIntegrationResolvedRoute(route) {