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.
- package/client.d.ts +1 -16
- package/dist/actions/plugins.js +1 -1
- 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 +31 -30
- package/dist/container/index.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/vite-plugin-content-virtual-mod.js +7 -9
- 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/build/plugins/plugin-component-entry.js +3 -1
- package/dist/core/build/plugins/plugin-manifest.js +1 -1
- package/dist/core/build/plugins/plugin-pages.js +1 -1
- package/dist/core/build/plugins/plugin-prerender.js +3 -0
- package/dist/core/build/plugins/plugin-renderers.js +3 -3
- package/dist/core/build/plugins/plugin-ssr.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} +9 -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 +141 -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/messages.js +2 -2
- package/dist/core/middleware/vite-plugin.js +3 -3
- package/dist/core/server-islands/vite-plugin-server-islands.js +1 -1
- package/dist/core/session.d.ts +8 -0
- package/dist/core/session.js +13 -0
- package/dist/env/vite-plugin-env.js +3 -3
- package/dist/events/session.js +1 -1
- package/dist/integrations/hooks.d.ts +4 -4
- package/dist/integrations/hooks.js +276 -280
- package/dist/manifest/virtual-module.js +2 -2
- package/dist/prefetch/index.d.ts +8 -0
- package/dist/prefetch/index.js +6 -4
- package/dist/prefetch/vite-plugin-prefetch.js +1 -1
- package/dist/toolbar/vite-plugin-dev-toolbar.js +41 -39
- package/dist/transitions/vite-plugin-transitions.js +22 -18
- package/dist/types/public/config.d.ts +3 -25
- package/dist/vite-plugin-load-fallback/index.js +4 -2
- package/dist/vite-plugin-scripts/index.js +9 -3
- package/dist/vite-plugin-ssr-manifest/index.js +4 -3
- package/package.json +4 -4
- 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,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
|
-
|
|
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) {
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
373
|
+
logger
|
|
350
374
|
}) {
|
|
351
375
|
for (const integration of config.integrations) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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,
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
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) {
|