astro 3.6.2 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +19 -20
- package/components/Code.astro +0 -20
- package/components/ViewTransitions.astro +2 -2
- package/dist/@types/astro.d.ts +19 -81
- package/dist/assets/build/generate.js +2 -2
- package/dist/assets/internal.js +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +3 -3
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +3 -3
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +3 -3
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +3 -3
- package/dist/cli/add/babel.d.ts +1 -1
- package/dist/cli/build/index.js +0 -1
- package/dist/cli/flags.js +0 -3
- package/dist/cli/info/index.d.ts +5 -0
- package/dist/cli/info/index.js +16 -7
- package/dist/cli/install-package.js +1 -1
- package/dist/cli/telemetry/index.js +6 -6
- package/dist/content/server-listeners.js +7 -7
- package/dist/content/types-generator.d.ts +1 -4
- package/dist/content/types-generator.js +31 -51
- package/dist/core/app/index.js +2 -4
- package/dist/core/build/buildPipeline.js +3 -3
- package/dist/core/build/generate.js +18 -39
- package/dist/core/build/index.js +10 -32
- package/dist/core/build/internal.js +3 -3
- package/dist/core/build/plugin.d.ts +2 -2
- package/dist/core/build/plugins/plugin-manifest.js +1 -4
- package/dist/core/build/plugins/plugin-pages.js +0 -3
- package/dist/core/build/plugins/plugin-renderers.d.ts +1 -1
- package/dist/core/build/plugins/plugin-ssr.js +5 -6
- package/dist/core/build/static-build.js +4 -7
- package/dist/core/build/types.d.ts +1 -1
- package/dist/core/build/util.js +1 -1
- package/dist/core/config/config.js +1 -2
- package/dist/core/config/schema.d.ts +209 -277
- package/dist/core/config/schema.js +5 -38
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.d.ts +2 -2
- package/dist/core/create-vite.js +12 -1
- package/dist/core/dev/dev.js +6 -4
- package/dist/core/dev/restart.js +7 -7
- package/dist/core/endpoint/index.d.ts +2 -7
- package/dist/core/endpoint/index.js +3 -87
- package/dist/core/errors/dev/vite.js +0 -1
- package/dist/core/logger/console.d.ts +2 -4
- package/dist/core/logger/console.js +4 -28
- package/dist/core/logger/core.d.ts +17 -5
- package/dist/core/logger/core.js +27 -2
- package/dist/core/logger/node.d.ts +2 -32
- package/dist/core/logger/node.js +8 -69
- package/dist/core/messages.d.ts +4 -11
- package/dist/core/messages.js +43 -59
- package/dist/core/middleware/callMiddleware.d.ts +1 -2
- package/dist/core/middleware/callMiddleware.js +1 -12
- package/dist/core/middleware/index.d.ts +2 -2
- package/dist/core/middleware/sequence.d.ts +2 -2
- package/dist/core/pipeline.d.ts +2 -2
- package/dist/core/pipeline.js +8 -13
- package/dist/core/preview/static-preview-server.js +2 -4
- package/dist/core/preview/vite-plugin-astro-preview.js +31 -21
- package/dist/core/render/core.js +0 -6
- package/dist/core/render/index.d.ts +1 -1
- package/dist/core/render/result.js +1 -1
- package/dist/core/render/route-cache.js +2 -5
- package/dist/core/request.js +3 -3
- package/dist/core/routing/manifest/create.js +14 -12
- package/dist/core/routing/validation.js +4 -4
- package/dist/core/sync/index.js +2 -2
- package/dist/i18n/middleware.d.ts +2 -2
- package/dist/i18n/vite-plugin-i18n.js +1 -1
- package/dist/integrations/astroFeaturesValidation.d.ts +1 -1
- package/dist/integrations/astroFeaturesValidation.js +12 -18
- package/dist/integrations/index.js +28 -6
- package/dist/prefetch/vite-plugin-prefetch.js +3 -3
- package/dist/runtime/client/dev-overlay/entrypoint.js +14 -10
- package/dist/runtime/client/dev-overlay/overlay.js +1 -1
- package/dist/runtime/client/dev-overlay/plugins/astro.d.ts +14 -1
- package/dist/runtime/client/dev-overlay/plugins/astro.js +326 -15
- package/dist/runtime/client/dev-overlay/plugins/settings.js +26 -2
- package/dist/runtime/client/dev-overlay/plugins/utils/icons.d.ts +3 -0
- package/dist/runtime/client/dev-overlay/plugins/utils/icons.js +37 -0
- package/dist/runtime/client/dev-overlay/plugins/utils/window.d.ts +1 -2
- package/dist/runtime/client/dev-overlay/plugins/utils/window.js +25 -29
- package/dist/runtime/client/dev-overlay/ui-library/badge.d.ts +9 -0
- package/dist/runtime/client/dev-overlay/ui-library/badge.js +67 -0
- package/dist/runtime/client/dev-overlay/ui-library/button.d.ts +9 -0
- package/dist/runtime/client/dev-overlay/ui-library/button.js +83 -0
- package/dist/runtime/client/dev-overlay/ui-library/card.d.ts +1 -3
- package/dist/runtime/client/dev-overlay/ui-library/card.js +17 -25
- package/dist/runtime/client/dev-overlay/ui-library/highlight.js +1 -0
- package/dist/runtime/client/dev-overlay/ui-library/icon.d.ts +10 -0
- package/dist/runtime/client/dev-overlay/ui-library/icon.js +36 -0
- package/dist/runtime/client/dev-overlay/ui-library/icons.d.ts +21 -6
- package/dist/runtime/client/dev-overlay/ui-library/icons.js +22 -7
- package/dist/runtime/client/dev-overlay/ui-library/index.d.ts +8 -0
- package/dist/runtime/client/dev-overlay/ui-library/index.js +18 -0
- package/dist/runtime/client/dev-overlay/ui-library/window.d.ts +0 -4
- package/dist/runtime/client/dev-overlay/ui-library/window.js +0 -33
- package/dist/runtime/server/endpoint.d.ts +1 -1
- package/dist/runtime/server/endpoint.js +11 -22
- package/dist/transitions/vite-plugin-transitions.js +4 -4
- package/dist/virtual-modules/i18n.d.ts +1 -0
- package/dist/virtual-modules/i18n.js +1 -0
- package/dist/virtual-modules/middleware.d.ts +1 -0
- package/dist/virtual-modules/middleware.js +5 -0
- package/dist/virtual-modules/prefetch.d.ts +1 -0
- package/dist/virtual-modules/prefetch.js +1 -0
- package/dist/virtual-modules/transitions-events.d.ts +1 -0
- package/dist/virtual-modules/transitions-events.js +1 -0
- package/dist/virtual-modules/transitions-router.d.ts +1 -0
- package/dist/virtual-modules/transitions-router.js +1 -0
- package/dist/virtual-modules/transitions-types.d.ts +1 -0
- package/dist/virtual-modules/transitions-types.js +1 -0
- package/dist/virtual-modules/transitions.d.ts +1 -0
- package/dist/virtual-modules/transitions.js +1 -0
- package/dist/vite-plugin-astro/hmr.js +8 -14
- package/dist/vite-plugin-astro/index.js +28 -6
- package/dist/vite-plugin-astro-server/base.js +5 -5
- package/dist/vite-plugin-astro-server/response.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +30 -6
- package/dist/vite-plugin-inject-env-ts/index.js +3 -3
- package/dist/vite-plugin-integrations-container/index.js +1 -1
- package/dist/vite-plugin-load-fallback/index.js +1 -3
- package/dist/vite-plugin-scanner/index.js +3 -6
- package/dist/vite-plugin-scripts/index.js +1 -1
- package/dist/vite-plugin-utils/index.d.ts +1 -0
- package/dist/vite-plugin-utils/index.js +5 -0
- package/package.json +56 -68
- package/dist/core/middleware/namespace.d.ts +0 -1
- package/dist/core/middleware/namespace.js +0 -5
- package/dist/vite-plugin-astro-server/common.d.ts +0 -2
- package/dist/vite-plugin-astro-server/common.js +0 -7
- package/import-meta.d.ts +0 -30
|
@@ -1,35 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (mod[lowerCaseMethod]) {
|
|
4
|
-
logger.warn(
|
|
5
|
-
"astro",
|
|
6
|
-
`Lower case endpoint names are deprecated and will not be supported in Astro 4.0. Rename the endpoint ${lowerCaseMethod} to ${method}.`
|
|
7
|
-
);
|
|
8
|
-
}
|
|
1
|
+
import { bold } from "kleur/colors";
|
|
2
|
+
function getHandlerFromModule(mod, method) {
|
|
9
3
|
if (mod[method]) {
|
|
10
4
|
return mod[method];
|
|
11
5
|
}
|
|
12
|
-
if (mod[lowerCaseMethod]) {
|
|
13
|
-
return mod[lowerCaseMethod];
|
|
14
|
-
}
|
|
15
|
-
if (method === "delete" && mod["del"]) {
|
|
16
|
-
return mod["del"];
|
|
17
|
-
}
|
|
18
|
-
if (mod["all"]) {
|
|
19
|
-
return mod["all"];
|
|
20
|
-
}
|
|
21
6
|
if (mod["ALL"]) {
|
|
22
7
|
return mod["ALL"];
|
|
23
8
|
}
|
|
24
9
|
return void 0;
|
|
25
10
|
}
|
|
26
11
|
async function renderEndpoint(mod, context, ssr, logger) {
|
|
27
|
-
const { request } = context;
|
|
12
|
+
const { request, url } = context;
|
|
28
13
|
const chosenMethod = request.method?.toUpperCase();
|
|
29
|
-
const handler = getHandlerFromModule(mod, chosenMethod
|
|
30
|
-
if (!ssr && ssr === false && chosenMethod && chosenMethod !== "GET"
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
const handler = getHandlerFromModule(mod, chosenMethod);
|
|
15
|
+
if (!ssr && ssr === false && chosenMethod && chosenMethod !== "GET") {
|
|
16
|
+
logger.warn(
|
|
17
|
+
null,
|
|
18
|
+
`${url.pathname} ${bold(
|
|
19
|
+
chosenMethod
|
|
20
|
+
)} requests are not available for a static site. Update your config to \`output: 'server'\` or \`output: 'hybrid'\` to enable.`
|
|
21
|
+
);
|
|
33
22
|
}
|
|
34
23
|
if (!handler || typeof handler !== "function") {
|
|
35
24
|
let response = new Response(null, {
|
|
@@ -17,20 +17,20 @@ function astroTransitions({ settings }) {
|
|
|
17
17
|
load(id) {
|
|
18
18
|
if (id === resolvedVirtualModuleId) {
|
|
19
19
|
return `
|
|
20
|
-
export * from "astro/transitions";
|
|
20
|
+
export * from "astro/virtual-modules/transitions.js";
|
|
21
21
|
export { default as ViewTransitions } from "astro/components/ViewTransitions.astro";
|
|
22
22
|
`;
|
|
23
23
|
}
|
|
24
24
|
if (id === resolvedVirtualClientModuleId) {
|
|
25
25
|
return `
|
|
26
|
-
export { navigate, supportsViewTransitions, transitionEnabledOnThisPage } from "astro/transitions
|
|
27
|
-
export * from "astro/transitions
|
|
26
|
+
export { navigate, supportsViewTransitions, transitionEnabledOnThisPage } from "astro/virtual-modules/transitions-router.js";
|
|
27
|
+
export * from "astro/virtual-modules/transitions-types.js";
|
|
28
28
|
export {
|
|
29
29
|
TRANSITION_BEFORE_PREPARATION, isTransitionBeforePreparationEvent, TransitionBeforePreparationEvent,
|
|
30
30
|
TRANSITION_AFTER_PREPARATION,
|
|
31
31
|
TRANSITION_BEFORE_SWAP, isTransitionBeforeSwapEvent, TransitionBeforeSwapEvent,
|
|
32
32
|
TRANSITION_AFTER_SWAP, TRANSITION_PAGE_LOAD
|
|
33
|
-
} from "astro/transitions
|
|
33
|
+
} from "astro/virtual-modules/transitions-events.js";
|
|
34
34
|
`;
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../i18n/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../i18n/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineMiddleware, sequence } from '../core/middleware/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../prefetch/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../prefetch/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../transitions/events.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../transitions/events.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../transitions/router.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../transitions/router.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../transitions/types.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../transitions/types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../transitions/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../transitions/index.js";
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
invalidateCompilation,
|
|
6
6
|
isCached
|
|
7
7
|
} from "../core/compile/index.js";
|
|
8
|
-
import * as msg from "../core/messages.js";
|
|
9
8
|
import { isAstroScript } from "./query.js";
|
|
10
9
|
const PKG_PREFIX = fileURLToPath(new URL("../../", import.meta.url));
|
|
11
10
|
const E2E_PREFIX = fileURLToPath(new URL("../../e2e", import.meta.url));
|
|
@@ -47,18 +46,17 @@ async function handleHotUpdate(ctx, { config, logger, compile, source }) {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
for (const
|
|
51
|
-
if (isStyleOnlyChange &&
|
|
49
|
+
for (const file of files) {
|
|
50
|
+
if (isStyleOnlyChange && file === ctx.file)
|
|
52
51
|
continue;
|
|
53
|
-
invalidateCompilation(config,
|
|
54
|
-
if (
|
|
55
|
-
ctx.server.moduleGraph.onFileChange(
|
|
52
|
+
invalidateCompilation(config, file);
|
|
53
|
+
if (file.endsWith(".astro")) {
|
|
54
|
+
ctx.server.moduleGraph.onFileChange(file);
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
const mods = [...filtered].filter((m) => !m.url.endsWith("="));
|
|
59
|
-
const file = ctx.file.replace(slash(fileURLToPath(config.root)), "/");
|
|
60
58
|
if (isStyleOnlyChange) {
|
|
61
|
-
logger.
|
|
59
|
+
logger.debug("watch", "style-only change");
|
|
62
60
|
return mods.filter((mod) => mod.id !== ctx.file && !mod.id?.endsWith(".ts"));
|
|
63
61
|
}
|
|
64
62
|
for (const mod of mods) {
|
|
@@ -69,12 +67,8 @@ async function handleHotUpdate(ctx, { config, logger, compile, source }) {
|
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
const isSelfAccepting = mods.every((m) => m.isSelfAccepting || m.url.endsWith(".svelte"));
|
|
72
|
-
if (isSelfAccepting) {
|
|
73
|
-
|
|
74
|
-
return mods;
|
|
75
|
-
logger.info("astro", msg.hmr({ file }));
|
|
76
|
-
} else {
|
|
77
|
-
logger.info("astro", msg.reload({ file }));
|
|
70
|
+
if (!isSelfAccepting) {
|
|
71
|
+
logger.debug("watch", "full page reload triggered");
|
|
78
72
|
}
|
|
79
73
|
return mods;
|
|
80
74
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileURLToPath } from "url";
|
|
1
2
|
import { normalizePath } from "vite";
|
|
2
3
|
import {
|
|
3
4
|
cachedCompilation,
|
|
@@ -9,6 +10,22 @@ import { cachedFullCompilation } from "./compile.js";
|
|
|
9
10
|
import { handleHotUpdate } from "./hmr.js";
|
|
10
11
|
import { parseAstroRequest } from "./query.js";
|
|
11
12
|
import { getAstroMetadata } from "./metadata.js";
|
|
13
|
+
const PKG_PREFIX = fileURLToPath(new URL("../../", import.meta.url));
|
|
14
|
+
const E2E_PREFIX = fileURLToPath(new URL("../../e2e", import.meta.url));
|
|
15
|
+
const isPkgFile = (id) => {
|
|
16
|
+
return id?.startsWith(PKG_PREFIX) && !id.startsWith(E2E_PREFIX);
|
|
17
|
+
};
|
|
18
|
+
const dedupeHotUpdateLogsCache = /* @__PURE__ */ new Map();
|
|
19
|
+
function dedupeHotUpdateLogs(filename) {
|
|
20
|
+
if (dedupeHotUpdateLogsCache.has(filename)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
dedupeHotUpdateLogsCache.set(
|
|
24
|
+
filename,
|
|
25
|
+
setTimeout(() => dedupeHotUpdateLogsCache.delete(filename), 150)
|
|
26
|
+
);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
12
29
|
function astro({ settings, logger }) {
|
|
13
30
|
const { config } = settings;
|
|
14
31
|
let resolvedConfig;
|
|
@@ -144,18 +161,23 @@ File: ${id}`
|
|
|
144
161
|
async handleHotUpdate(context) {
|
|
145
162
|
if (context.server.config.isProduction)
|
|
146
163
|
return;
|
|
147
|
-
const
|
|
164
|
+
const filename = context.file;
|
|
165
|
+
const isSkipLog = /astro\.config\.[cm][jt]s$/.test(filename) || /(\/|\\)\.astro(\/|\\)/.test(filename) || isPkgFile(filename);
|
|
166
|
+
if (!isSkipLog && dedupeHotUpdateLogs(filename)) {
|
|
167
|
+
logger.info("watch", filename.replace(config.root.pathname, "/"));
|
|
168
|
+
}
|
|
169
|
+
const source = await context.read();
|
|
170
|
+
const compile = () => cachedCompilation({
|
|
148
171
|
astroConfig: config,
|
|
149
172
|
viteConfig: resolvedConfig,
|
|
150
|
-
filename
|
|
151
|
-
source
|
|
152
|
-
};
|
|
153
|
-
const compile = () => cachedCompilation(compileProps);
|
|
173
|
+
filename,
|
|
174
|
+
source
|
|
175
|
+
});
|
|
154
176
|
return handleHotUpdate(context, {
|
|
155
177
|
config,
|
|
156
178
|
logger,
|
|
157
179
|
compile,
|
|
158
|
-
source
|
|
180
|
+
source
|
|
159
181
|
});
|
|
160
182
|
}
|
|
161
183
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { bold } from "kleur/colors";
|
|
1
2
|
import * as fs from "node:fs";
|
|
2
3
|
import notFoundTemplate, { subpathNotUsedTemplate } from "../template/4xx.js";
|
|
3
|
-
import { log404 } from "./common.js";
|
|
4
4
|
import { writeHtmlResponse } from "./response.js";
|
|
5
5
|
function baseMiddleware(settings, logger) {
|
|
6
6
|
const { config } = settings;
|
|
@@ -16,12 +16,10 @@ function baseMiddleware(settings, logger) {
|
|
|
16
16
|
return next();
|
|
17
17
|
}
|
|
18
18
|
if (pathname === "/" || pathname === "/index.html") {
|
|
19
|
-
log404(logger, pathname);
|
|
20
19
|
const html = subpathNotUsedTemplate(devRoot, pathname);
|
|
21
20
|
return writeHtmlResponse(res, 404, html);
|
|
22
21
|
}
|
|
23
22
|
if (req.headers.accept?.includes("text/html")) {
|
|
24
|
-
log404(logger, pathname);
|
|
25
23
|
const html = notFoundTemplate({
|
|
26
24
|
statusCode: 404,
|
|
27
25
|
title: "Not found",
|
|
@@ -35,8 +33,10 @@ function baseMiddleware(settings, logger) {
|
|
|
35
33
|
if (stats) {
|
|
36
34
|
const expectedLocation = new URL("." + url, devRootURL).pathname;
|
|
37
35
|
logger.warn(
|
|
38
|
-
"
|
|
39
|
-
`
|
|
36
|
+
"router",
|
|
37
|
+
`Request URLs for ${bold(
|
|
38
|
+
"public/"
|
|
39
|
+
)} assets must also include your base. "${expectedLocation}" expected, but received "${url}".`
|
|
40
40
|
);
|
|
41
41
|
res.writeHead(301, {
|
|
42
42
|
Location: expectedLocation
|
|
@@ -45,7 +45,7 @@ async function writeWebResponse(res, webResponse) {
|
|
|
45
45
|
const _headers = Object.fromEntries(headers.entries());
|
|
46
46
|
if (headers.has("set-cookie")) {
|
|
47
47
|
if ("getSetCookie" in headers && typeof headers.getSetCookie === "function") {
|
|
48
|
-
_headers["set-cookie"] = headers.getSetCookie();
|
|
48
|
+
_headers["set-cookie"] = headers.getSetCookie().toString();
|
|
49
49
|
} else {
|
|
50
50
|
_headers["set-cookie"] = headers.get("set-cookie");
|
|
51
51
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { getInfoOutput } from "../cli/info/index.js";
|
|
3
|
+
import { ASTRO_VERSION } from "../core/constants.js";
|
|
2
4
|
import { AstroErrorData, isAstroError } from "../core/errors/index.js";
|
|
3
5
|
import { sequence } from "../core/middleware/index.js";
|
|
6
|
+
import { req } from "../core/messages.js";
|
|
4
7
|
import { loadMiddleware } from "../core/middleware/loadMiddleware.js";
|
|
5
8
|
import {
|
|
6
9
|
createRenderContext,
|
|
@@ -13,13 +16,15 @@ import { createI18nMiddleware, i18nPipelineHook } from "../i18n/middleware.js";
|
|
|
13
16
|
import { getSortedPreloadedMatches } from "../prerender/routing.js";
|
|
14
17
|
import { isServerLikeOutput } from "../prerender/utils.js";
|
|
15
18
|
import { PAGE_SCRIPT_ID } from "../vite-plugin-scripts/index.js";
|
|
16
|
-
import { log404 } from "./common.js";
|
|
17
19
|
import { getStylesForURL } from "./css.js";
|
|
18
20
|
import { preload } from "./index.js";
|
|
19
21
|
import { getComponentMetadata } from "./metadata.js";
|
|
20
22
|
import { handle404Response, writeSSRResult, writeWebResponse } from "./response.js";
|
|
21
23
|
import { getScriptsForURL } from "./scripts.js";
|
|
22
24
|
const clientLocalsSymbol = Symbol.for("astro.locals");
|
|
25
|
+
function isLoggedRequest(url) {
|
|
26
|
+
return url !== "/favicon.ico";
|
|
27
|
+
}
|
|
23
28
|
function getCustom404Route(manifestData) {
|
|
24
29
|
const route404 = /^\/404\/?$/;
|
|
25
30
|
return manifestData.routes.find((r) => route404.test(r.route));
|
|
@@ -64,7 +69,7 @@ async function matchRoute(pathname, manifestData, pipeline) {
|
|
|
64
69
|
if (matches.length) {
|
|
65
70
|
const possibleRoutes = matches.flatMap((route) => route.component);
|
|
66
71
|
pipeline.logger.warn(
|
|
67
|
-
"
|
|
72
|
+
"router",
|
|
68
73
|
`${AstroErrorData.NoMatchingStaticPathFound.message(
|
|
69
74
|
pathname
|
|
70
75
|
)}
|
|
@@ -72,7 +77,6 @@ async function matchRoute(pathname, manifestData, pipeline) {
|
|
|
72
77
|
${AstroErrorData.NoMatchingStaticPathFound.hint(possibleRoutes)}`
|
|
73
78
|
);
|
|
74
79
|
}
|
|
75
|
-
log404(logger, pathname);
|
|
76
80
|
const custom404 = getCustom404Route(manifestData);
|
|
77
81
|
if (custom404) {
|
|
78
82
|
const filePath = new URL(`./${custom404.component}`, pipeline.getConfig().root);
|
|
@@ -100,11 +104,15 @@ async function handleRoute({
|
|
|
100
104
|
incomingResponse,
|
|
101
105
|
manifest
|
|
102
106
|
}) {
|
|
107
|
+
const timeStart = performance.now();
|
|
103
108
|
const env = pipeline.getEnvironment();
|
|
104
109
|
const config = pipeline.getConfig();
|
|
105
110
|
const moduleLoader = pipeline.getModuleLoader();
|
|
106
111
|
const { logger } = env;
|
|
107
112
|
if (!matchedRoute && !config.experimental.i18n) {
|
|
113
|
+
if (isLoggedRequest(pathname)) {
|
|
114
|
+
logger.info(null, req({ url: pathname, method: incomingRequest.method, statusCode: 404 }));
|
|
115
|
+
}
|
|
108
116
|
return handle404Response(origin, incomingRequest, incomingResponse);
|
|
109
117
|
}
|
|
110
118
|
const buildingToSSR = isServerLikeOutput(config);
|
|
@@ -227,6 +235,18 @@ async function handleRoute({
|
|
|
227
235
|
pipeline.setMiddlewareFunction(onRequest);
|
|
228
236
|
}
|
|
229
237
|
let response = await pipeline.renderRoute(renderContext, mod);
|
|
238
|
+
if (isLoggedRequest(pathname)) {
|
|
239
|
+
const timeEnd = performance.now();
|
|
240
|
+
logger.info(
|
|
241
|
+
null,
|
|
242
|
+
req({
|
|
243
|
+
url: pathname,
|
|
244
|
+
method: incomingRequest.method,
|
|
245
|
+
statusCode: response.status,
|
|
246
|
+
reqTime: timeEnd - timeStart
|
|
247
|
+
})
|
|
248
|
+
);
|
|
249
|
+
}
|
|
230
250
|
if (response.status === 404 && has404Route(manifestData)) {
|
|
231
251
|
const fourOhFourRoute = await matchRoute("/404", manifestData, pipeline);
|
|
232
252
|
if (options && fourOhFourRoute?.route !== options.route)
|
|
@@ -281,11 +301,15 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
|
|
|
281
301
|
},
|
|
282
302
|
children: ""
|
|
283
303
|
});
|
|
304
|
+
const additionalMetadata = {
|
|
305
|
+
root: fileURLToPath(settings.config.root),
|
|
306
|
+
version: ASTRO_VERSION,
|
|
307
|
+
debugInfo: await getInfoOutput({ userConfig: settings.config, print: false })
|
|
308
|
+
};
|
|
309
|
+
settings.config;
|
|
284
310
|
scripts.add({
|
|
285
311
|
props: {},
|
|
286
|
-
children: `window.__astro_dev_overlay__ =
|
|
287
|
-
fileURLToPath(settings.config.root)
|
|
288
|
-
)}}`
|
|
312
|
+
children: `window.__astro_dev_overlay__ = ${JSON.stringify(additionalMetadata)}`
|
|
289
313
|
});
|
|
290
314
|
}
|
|
291
315
|
}
|
|
@@ -41,7 +41,7 @@ async function setUpEnvTs({
|
|
|
41
41
|
'types="astro/client"'
|
|
42
42
|
);
|
|
43
43
|
await fs.promises.writeFile(envTsPath, typesEnvContents, "utf-8");
|
|
44
|
-
logger.info("
|
|
44
|
+
logger.info("types", `Removed ${bold(envTsPathRelativetoRoot)} type declarations`);
|
|
45
45
|
}
|
|
46
46
|
if (!fs.existsSync(dotAstroDir))
|
|
47
47
|
return;
|
|
@@ -50,7 +50,7 @@ async function setUpEnvTs({
|
|
|
50
50
|
typesEnvContents = `${expectedTypeReference}
|
|
51
51
|
${typesEnvContents}`;
|
|
52
52
|
await fs.promises.writeFile(envTsPath, typesEnvContents, "utf-8");
|
|
53
|
-
logger.info("
|
|
53
|
+
logger.info("types", `Added ${bold(envTsPathRelativetoRoot)} type declarations`);
|
|
54
54
|
}
|
|
55
55
|
} else {
|
|
56
56
|
let referenceDefs = [];
|
|
@@ -60,7 +60,7 @@ ${typesEnvContents}`;
|
|
|
60
60
|
}
|
|
61
61
|
await fs.promises.mkdir(settings.config.srcDir, { recursive: true });
|
|
62
62
|
await fs.promises.writeFile(envTsPath, referenceDefs.join("\n"), "utf-8");
|
|
63
|
-
logger.info("
|
|
63
|
+
logger.info("types", `Added ${bold(envTsPathRelativetoRoot)} type declarations`);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
export {
|
|
@@ -21,7 +21,7 @@ function astroIntegrationsContainerPlugin({
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
async function resolveEntryPoint(route) {
|
|
24
|
-
const resolvedId = await this.resolve(route.
|
|
24
|
+
const resolvedId = await this.resolve(route.entrypoint).then((res) => res?.id).catch(() => void 0);
|
|
25
25
|
if (!resolvedId)
|
|
26
26
|
return route;
|
|
27
27
|
const resolvedEntryPoint = new URL(`file://${normalizePath(resolvedId)}`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import nodeFs from "node:fs";
|
|
2
2
|
import npath from "node:path";
|
|
3
3
|
import { slash } from "../core/path.js";
|
|
4
|
+
import { cleanUrl } from "../vite-plugin-utils/index.js";
|
|
4
5
|
function loadFallbackPlugin({
|
|
5
6
|
fs,
|
|
6
7
|
root
|
|
@@ -59,9 +60,6 @@ function loadFallbackPlugin({
|
|
|
59
60
|
}
|
|
60
61
|
];
|
|
61
62
|
}
|
|
62
|
-
const queryRE = /\?.*$/s;
|
|
63
|
-
const hashRE = /#.*$/s;
|
|
64
|
-
const cleanUrl = (url) => url.replace(hashRE, "").replace(queryRE, "");
|
|
65
63
|
export {
|
|
66
64
|
loadFallbackPlugin as default
|
|
67
65
|
};
|
|
@@ -34,14 +34,11 @@ function astroScannerPlugin({
|
|
|
34
34
|
}
|
|
35
35
|
if (!pageOptions.prerender && isServerLikeOutput(settings.config) && code.includes("getStaticPaths") && // this should only be valid for `.astro`, `.js` and `.ts` files
|
|
36
36
|
KNOWN_FILE_EXTENSIONS.includes(extname(filename))) {
|
|
37
|
-
const reason = ` because \`output: "${settings.config.output}"\` is set`;
|
|
38
37
|
logger.warn(
|
|
39
|
-
"
|
|
40
|
-
`
|
|
38
|
+
"router",
|
|
39
|
+
`getStaticPaths() ignored in dynamic page ${bold(
|
|
41
40
|
rootRelativePath(settings.config.root, fileURL, true)
|
|
42
|
-
)}
|
|
43
|
-
|
|
44
|
-
Add \`export const prerender = true;\` to prerender this page.`
|
|
41
|
+
)}. Add \`export const prerender = true;\` to prerender the page as static HTML during the build process.`
|
|
45
42
|
);
|
|
46
43
|
}
|
|
47
44
|
const { meta = {} } = this.getModuleInfo(id) ?? {};
|
|
@@ -29,7 +29,7 @@ function astroScriptsPlugin({ settings }) {
|
|
|
29
29
|
},
|
|
30
30
|
buildStart() {
|
|
31
31
|
const hasHydrationScripts = settings.scripts.some((s) => s.stage === "before-hydration");
|
|
32
|
-
const isSsrBuild = env?.
|
|
32
|
+
const isSsrBuild = env?.isSsrBuild;
|
|
33
33
|
if (hasHydrationScripts && env?.command === "build" && !isSsrBuild) {
|
|
34
34
|
this.emitFile({
|
|
35
35
|
type: "chunk",
|
|
@@ -32,7 +32,12 @@ function normalizeFilename(filename, root) {
|
|
|
32
32
|
}
|
|
33
33
|
return removeLeadingForwardSlashWindows(filename);
|
|
34
34
|
}
|
|
35
|
+
const postfixRE = /[?#].*$/s;
|
|
36
|
+
function cleanUrl(url) {
|
|
37
|
+
return url.replace(postfixRE, "");
|
|
38
|
+
}
|
|
35
39
|
export {
|
|
40
|
+
cleanUrl,
|
|
36
41
|
escapeViteEnvReferences,
|
|
37
42
|
getFileInfo,
|
|
38
43
|
normalizeFilename
|