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.
- package/client.d.ts +1 -16
- package/dist/actions/runtime/utils.d.ts +8 -2
- package/dist/assets/runtime.js +5 -29
- package/dist/assets/utils/svg.d.ts +1 -4
- package/dist/assets/utils/svg.js +2 -2
- package/dist/assets/vite-plugin-assets.js +1 -3
- package/dist/cli/add/index.js +1 -1
- package/dist/container/index.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/core/app/index.d.ts +15 -0
- package/dist/core/app/index.js +27 -7
- package/dist/core/build/index.js +2 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/schemas/base.d.ts +1110 -0
- package/dist/core/config/{schema.js → schemas/base.js} +8 -254
- package/dist/core/config/schemas/index.d.ts +3 -0
- package/dist/core/config/schemas/index.js +9 -0
- package/dist/core/config/schemas/refined.d.ts +3 -0
- package/dist/core/config/schemas/refined.js +148 -0
- package/dist/core/config/schemas/relative.d.ts +1462 -0
- package/dist/core/config/schemas/relative.js +93 -0
- package/dist/core/config/validate.d.ts +6 -0
- package/dist/core/config/validate.js +9 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +1 -1
- package/dist/core/errors/errors-data.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render-context.js +5 -2
- package/dist/core/session.d.ts +8 -0
- package/dist/core/session.js +13 -0
- package/dist/events/session.js +1 -1
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +12 -0
- package/dist/i18n/utils.js +7 -11
- package/dist/integrations/hooks.d.ts +4 -4
- package/dist/integrations/hooks.js +273 -280
- package/dist/prefetch/index.d.ts +8 -0
- package/dist/prefetch/index.js +6 -4
- package/dist/types/public/config.d.ts +3 -25
- package/dist/types/public/context.d.ts +1 -1
- package/package.json +11 -11
- 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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
updatedSettings.
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
370
|
+
logger
|
|
350
371
|
}) {
|
|
351
372
|
for (const integration of config.integrations) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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,
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
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
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
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) {
|