astro 6.4.6 → 6.4.8
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/dist/assets/build/generate.js +4 -3
- package/dist/cli/add/index.js +1 -0
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/container/index.d.ts +3 -3
- package/dist/content/content-layer.js +3 -3
- package/dist/content/runtime.d.ts +1 -1
- package/dist/content/runtime.js +1 -0
- package/dist/core/app/base.js +7 -15
- package/dist/core/build/plugins/plugin-css.js +1 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/fetch/fetch-state.d.ts +6 -0
- package/dist/core/fetch/fetch-state.js +12 -1
- package/dist/core/i18n/handler.js +1 -1
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/vite-plugin.d.ts +1 -0
- package/dist/core/middleware/vite-plugin.js +5 -1
- package/dist/core/routing/handler.js +3 -0
- package/dist/core/routing/rewrite.js +2 -1
- package/dist/core/util/normalized-url.js +2 -5
- package/dist/core/util/pathname.d.ts +17 -10
- package/dist/core/util/pathname.js +14 -7
- package/dist/i18n/index.js +6 -2
- package/dist/runtime/server/jsx.js +2 -1
- package/dist/runtime/server/render/head.js +2 -1
- package/dist/vite-plugin-hmr-reload/index.js +19 -6
- package/dist/vite-plugin-pages/pages.d.ts +11 -0
- package/dist/vite-plugin-pages/pages.js +1 -3
- package/package.json +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fs, { readFileSync } from "node:fs";
|
|
2
2
|
import { basename } from "node:path/posix";
|
|
3
3
|
import colors from "piccolore";
|
|
4
|
-
import { getOutDirWithinCwd } from "../../core/build/common.js";
|
|
5
4
|
import { getTimeStat } from "../../core/build/util.js";
|
|
6
5
|
import { AstroError } from "../../core/errors/errors.js";
|
|
7
6
|
import { AstroErrorData } from "../../core/errors/index.js";
|
|
8
7
|
import { isRemotePath, removeLeadingForwardSlash } from "../../core/path.js";
|
|
8
|
+
import { getClientOutputDirectory } from "../../prerender/utils.js";
|
|
9
9
|
import { getConfiguredImageService } from "../internal.js";
|
|
10
10
|
import { isESMImportedImage } from "../utils/imageKind.js";
|
|
11
11
|
import { loadRemoteImage, revalidateRemoteImage } from "./remote.js";
|
|
@@ -29,8 +29,9 @@ async function prepareAssetsGenerationEnv(options, totalCount) {
|
|
|
29
29
|
serverRoot = new URL(".prerender/", settings.config.build.server);
|
|
30
30
|
clientRoot = settings.config.build.client;
|
|
31
31
|
} else {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const clientOutputDir = getClientOutputDirectory(settings);
|
|
33
|
+
serverRoot = clientOutputDir;
|
|
34
|
+
clientRoot = clientOutputDir;
|
|
34
35
|
}
|
|
35
36
|
return {
|
|
36
37
|
logger,
|
package/dist/cli/add/index.js
CHANGED
|
@@ -62,6 +62,7 @@ export default async function seed() {
|
|
|
62
62
|
}
|
|
63
63
|
`,
|
|
64
64
|
CLOUDFLARE_WRANGLER_CONFIG: (name, compatibilityDate) => `{
|
|
65
|
+
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
65
66
|
"compatibility_date": ${JSON.stringify(compatibilityDate)},
|
|
66
67
|
"compatibility_flags": ["global_fetch_strictly_public"],
|
|
67
68
|
"name": ${JSON.stringify(name)},
|
|
@@ -67,7 +67,7 @@ export type ContainerRenderOptions = {
|
|
|
67
67
|
*/
|
|
68
68
|
routeType?: RouteType;
|
|
69
69
|
/**
|
|
70
|
-
* Allows
|
|
70
|
+
* Allows passing `Astro.props` to an Astro component:
|
|
71
71
|
*
|
|
72
72
|
* ```js
|
|
73
73
|
* container.renderToString(Endpoint, { props: { "lorem": "ipsum" } });
|
|
@@ -75,9 +75,9 @@ export type ContainerRenderOptions = {
|
|
|
75
75
|
*/
|
|
76
76
|
props?: Props;
|
|
77
77
|
/**
|
|
78
|
-
* When `false`, it forces to render
|
|
78
|
+
* When `false`, it forces the component to render as if it were a full-fledged page.
|
|
79
79
|
*
|
|
80
|
-
* By default, the container API
|
|
80
|
+
* By default, the container API renders components as [partials](https://docs.astro.build/en/basics/astro-pages/#page-partials).
|
|
81
81
|
*
|
|
82
82
|
*/
|
|
83
83
|
partial?: boolean;
|
|
@@ -197,7 +197,7 @@ ${contentConfig.error.message}`
|
|
|
197
197
|
logger.info("Content config changed");
|
|
198
198
|
shouldClear = true;
|
|
199
199
|
}
|
|
200
|
-
if (previousAstroVersion && previousAstroVersion !== "6.4.
|
|
200
|
+
if (previousAstroVersion && previousAstroVersion !== "6.4.8") {
|
|
201
201
|
logger.info("Astro version changed");
|
|
202
202
|
shouldClear = true;
|
|
203
203
|
}
|
|
@@ -205,8 +205,8 @@ ${contentConfig.error.message}`
|
|
|
205
205
|
logger.info("Clearing content store");
|
|
206
206
|
this.#store.clearAll();
|
|
207
207
|
}
|
|
208
|
-
if ("6.4.
|
|
209
|
-
this.#store.metaStore().set("astro-version", "6.4.
|
|
208
|
+
if ("6.4.8") {
|
|
209
|
+
this.#store.metaStore().set("astro-version", "6.4.8");
|
|
210
210
|
}
|
|
211
211
|
if (currentConfigDigest) {
|
|
212
212
|
this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -70,7 +70,7 @@ type RenderResult = {
|
|
|
70
70
|
};
|
|
71
71
|
export declare function updateImageReferencesInData<T extends Record<string, unknown>>(data: T, fileName?: string, imageAssetMap?: Map<string, ImageMetadata>): T;
|
|
72
72
|
export declare function renderEntry(entry: DataEntry): Promise<RenderResult>;
|
|
73
|
-
export declare function createReference(): (collection: string) => z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
73
|
+
export declare function createReference(): (collection: string) => z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>, z.ZodString, z.ZodObject<{
|
|
74
74
|
id: z.ZodString;
|
|
75
75
|
collection: z.ZodString;
|
|
76
76
|
}, z.core.$strip>, z.ZodObject<{
|
package/dist/content/runtime.js
CHANGED
package/dist/core/app/base.js
CHANGED
|
@@ -14,7 +14,6 @@ import { DefaultFetchHandler } from "../fetch/default-handler.js";
|
|
|
14
14
|
import { appSymbol } from "../constants.js";
|
|
15
15
|
import { DefaultErrorHandler } from "../errors/default-handler.js";
|
|
16
16
|
import { setRenderOptions } from "./render-options.js";
|
|
17
|
-
import { MultiLevelEncodingError } from "../util/pathname.js";
|
|
18
17
|
class BaseApp {
|
|
19
18
|
manifest;
|
|
20
19
|
manifestData;
|
|
@@ -237,20 +236,13 @@ class BaseApp {
|
|
|
237
236
|
waitUntil
|
|
238
237
|
};
|
|
239
238
|
let response;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
response = await this.#fetchHandler.fetch(request);
|
|
248
|
-
}
|
|
249
|
-
} catch (err) {
|
|
250
|
-
if (err instanceof MultiLevelEncodingError) {
|
|
251
|
-
return new Response("Bad Request", { status: 400 });
|
|
252
|
-
}
|
|
253
|
-
throw err;
|
|
239
|
+
if (this.#fetchHandler instanceof DefaultFetchHandler) {
|
|
240
|
+
Reflect.set(request, appSymbol, this);
|
|
241
|
+
response = await this.#fetchHandler.renderWithOptions(request, resolvedOptions);
|
|
242
|
+
} else {
|
|
243
|
+
setRenderOptions(request, resolvedOptions);
|
|
244
|
+
Reflect.set(request, appSymbol, this);
|
|
245
|
+
response = await this.#fetchHandler.fetch(request);
|
|
254
246
|
}
|
|
255
247
|
this.#warnMissingFeatures();
|
|
256
248
|
if (response.headers.get(ASTRO_ERROR_HEADER)) {
|
|
@@ -107,6 +107,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
107
107
|
if (meta.importedCss.size < 1) continue;
|
|
108
108
|
if (this.environment?.name === ASTRO_VITE_ENVIRONMENT_NAMES.client) {
|
|
109
109
|
for (const id of Object.keys(chunk.modules)) {
|
|
110
|
+
if (!isCSSRequest(id)) continue;
|
|
110
111
|
for (const pageData of getParentClientOnlys(id, this, internals)) {
|
|
111
112
|
for (const importedCssImport of meta.importedCss) {
|
|
112
113
|
const cssToInfoRecord = pagesToCss[pageData.moduleSpecifier] ??= {};
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -37,7 +37,7 @@ async function dev(inlineConfig) {
|
|
|
37
37
|
await telemetry.record([]);
|
|
38
38
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
39
39
|
const logger = restart.container.logger;
|
|
40
|
-
const currentVersion = "6.4.
|
|
40
|
+
const currentVersion = "6.4.8";
|
|
41
41
|
const isPrerelease = currentVersion.includes("-");
|
|
42
42
|
if (!isPrerelease) {
|
|
43
43
|
try {
|
|
@@ -134,6 +134,12 @@ export declare class FetchState implements AstroFetchState {
|
|
|
134
134
|
status: number;
|
|
135
135
|
/** Whether user middleware should be skipped for this request. */
|
|
136
136
|
skipMiddleware: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Set to `true` when the request path was encoded too many times to fully
|
|
139
|
+
* decode (see {@link validateAndDecodePathname}). These requests are
|
|
140
|
+
* rejected with a `400` before middleware or routing run.
|
|
141
|
+
*/
|
|
142
|
+
invalidEncoding: boolean;
|
|
137
143
|
/** A flag that tells the render content if the rewriting was triggered. */
|
|
138
144
|
isRewriting: boolean;
|
|
139
145
|
/** A safety net in case of loops (rewrite counter). */
|
|
@@ -29,6 +29,7 @@ import { getParams, getProps } from "../render/index.js";
|
|
|
29
29
|
import { Rewrites } from "../rewrites/handler.js";
|
|
30
30
|
import { isRoute404or500, isRouteServerIsland } from "../routing/match.js";
|
|
31
31
|
import { normalizeUrl } from "../util/normalized-url.js";
|
|
32
|
+
import { MultiLevelEncodingError, validateAndDecodePathname } from "../util/pathname.js";
|
|
32
33
|
import { getOriginPathname, setOriginPathname } from "../routing/rewrite.js";
|
|
33
34
|
import { computePathnameFromDomain } from "../i18n/domain.js";
|
|
34
35
|
import { getCustom404Route, routeHasHtmlExtension } from "../routing/helpers.js";
|
|
@@ -87,6 +88,12 @@ class FetchState {
|
|
|
87
88
|
status = 200;
|
|
88
89
|
/** Whether user middleware should be skipped for this request. */
|
|
89
90
|
skipMiddleware = false;
|
|
91
|
+
/**
|
|
92
|
+
* Set to `true` when the request path was encoded too many times to fully
|
|
93
|
+
* decode (see {@link validateAndDecodePathname}). These requests are
|
|
94
|
+
* rejected with a `400` before middleware or routing run.
|
|
95
|
+
*/
|
|
96
|
+
invalidEncoding = false;
|
|
90
97
|
/** A flag that tells the render content if the rewriting was triggered. */
|
|
91
98
|
isRewriting = false;
|
|
92
99
|
/** A safety net in case of loops (rewrite counter). */
|
|
@@ -678,8 +685,12 @@ class FetchState {
|
|
|
678
685
|
}
|
|
679
686
|
pathname = prependForwardSlash(pathname);
|
|
680
687
|
try {
|
|
681
|
-
return
|
|
688
|
+
return validateAndDecodePathname(pathname);
|
|
682
689
|
} catch (e) {
|
|
690
|
+
if (e instanceof MultiLevelEncodingError) {
|
|
691
|
+
this.invalidEncoding = true;
|
|
692
|
+
return pathname;
|
|
693
|
+
}
|
|
683
694
|
this.pipeline.logger.error(null, e.toString());
|
|
684
695
|
return pathname;
|
|
685
696
|
}
|
|
@@ -47,7 +47,7 @@ class I18n {
|
|
|
47
47
|
if (typeHeader !== "page" && typeHeader !== "fallback") {
|
|
48
48
|
return response;
|
|
49
49
|
}
|
|
50
|
-
const url =
|
|
50
|
+
const url = state.url;
|
|
51
51
|
const currentLocale = state.computeCurrentLocale();
|
|
52
52
|
const isPrerendered = state.routeData.prerender;
|
|
53
53
|
const routerContext = {
|
|
@@ -3,6 +3,7 @@ import type { AstroSettings } from '../../types/astro.js';
|
|
|
3
3
|
import type { BuildInternals } from '../build/internal.js';
|
|
4
4
|
import type { StaticBuildOptions } from '../build/types.js';
|
|
5
5
|
export declare const MIDDLEWARE_MODULE_ID = "virtual:astro:middleware";
|
|
6
|
+
export declare function isMiddlewarePath(relativePath: string): boolean;
|
|
6
7
|
export declare function vitePluginMiddleware({ settings }: {
|
|
7
8
|
settings: AstroSettings;
|
|
8
9
|
}): VitePlugin;
|
|
@@ -11,6 +11,9 @@ import { normalizePath } from "../viteUtils.js";
|
|
|
11
11
|
const MIDDLEWARE_MODULE_ID = "virtual:astro:middleware";
|
|
12
12
|
const MIDDLEWARE_RESOLVED_MODULE_ID = "\0" + MIDDLEWARE_MODULE_ID;
|
|
13
13
|
const NOOP_MIDDLEWARE = "\0noop-middleware";
|
|
14
|
+
function isMiddlewarePath(relativePath) {
|
|
15
|
+
return relativePath.startsWith(`${MIDDLEWARE_PATH_SEGMENT_NAME}.`) || relativePath.startsWith(`${MIDDLEWARE_PATH_SEGMENT_NAME}/`);
|
|
16
|
+
}
|
|
14
17
|
function vitePluginMiddleware({ settings }) {
|
|
15
18
|
let resolvedMiddlewareId = void 0;
|
|
16
19
|
const hasIntegrationMiddleware = settings.middlewares.pre.length > 0 || settings.middlewares.post.length > 0;
|
|
@@ -26,7 +29,7 @@ function vitePluginMiddleware({ settings }) {
|
|
|
26
29
|
const normalizedPath = viteNormalizePath(path);
|
|
27
30
|
if (!normalizedPath.startsWith(normalizedSrcDir)) return;
|
|
28
31
|
const relativePath = normalizedPath.slice(normalizedSrcDir.length);
|
|
29
|
-
if (!relativePath
|
|
32
|
+
if (!isMiddlewarePath(relativePath)) return;
|
|
30
33
|
for (const name of [
|
|
31
34
|
ASTRO_VITE_ENVIRONMENT_NAMES.ssr,
|
|
32
35
|
ASTRO_VITE_ENVIRONMENT_NAMES.astro
|
|
@@ -135,6 +138,7 @@ function vitePluginMiddlewareBuild(opts, internals) {
|
|
|
135
138
|
}
|
|
136
139
|
export {
|
|
137
140
|
MIDDLEWARE_MODULE_ID,
|
|
141
|
+
isMiddlewarePath,
|
|
138
142
|
vitePluginMiddleware,
|
|
139
143
|
vitePluginMiddlewareBuild
|
|
140
144
|
};
|
|
@@ -65,6 +65,9 @@ class AstroHandler {
|
|
|
65
65
|
}
|
|
66
66
|
async handle(state) {
|
|
67
67
|
state.pipeline.usedFeatures |= ALL_PIPELINE_FEATURES;
|
|
68
|
+
if (state.invalidEncoding) {
|
|
69
|
+
return new Response(null, { status: 400, statusText: "Bad Request" });
|
|
70
|
+
}
|
|
68
71
|
const trailingSlashRedirect = this.#trailingSlashHandler.handle(state);
|
|
69
72
|
if (trailingSlashRedirect) {
|
|
70
73
|
return trailingSlashRedirect;
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
trimSlashes
|
|
11
11
|
} from "../path.js";
|
|
12
12
|
import { createRequest } from "../request.js";
|
|
13
|
+
import { validateAndDecodePathname } from "../util/pathname.js";
|
|
13
14
|
import { DEFAULT_404_ROUTE } from "./internal/astro-designed-error-pages.js";
|
|
14
15
|
import { isRoute404, isRoute500 } from "./internal/route-errors.js";
|
|
15
16
|
function findRouteToRewrite({
|
|
@@ -36,7 +37,7 @@ function findRouteToRewrite({
|
|
|
36
37
|
buildFormat
|
|
37
38
|
);
|
|
38
39
|
newUrl.pathname = resolvedUrlPathname;
|
|
39
|
-
const decodedPathname =
|
|
40
|
+
const decodedPathname = validateAndDecodePathname(pathname);
|
|
40
41
|
if (isRoute404(decodedPathname)) {
|
|
41
42
|
const errorRoute = routes.find((route) => route.route === "/404");
|
|
42
43
|
if (errorRoute) {
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { collapseDuplicateSlashes } from "@astrojs/internal-helpers/path";
|
|
2
|
-
import {
|
|
2
|
+
import { validateAndDecodePathname } from "./pathname.js";
|
|
3
3
|
function createNormalizedUrl(requestUrl) {
|
|
4
4
|
return normalizeUrl(new URL(requestUrl));
|
|
5
5
|
}
|
|
6
6
|
function normalizeUrl(url) {
|
|
7
7
|
try {
|
|
8
8
|
url.pathname = validateAndDecodePathname(url.pathname);
|
|
9
|
-
} catch
|
|
10
|
-
if (e instanceof MultiLevelEncodingError) {
|
|
11
|
-
throw e;
|
|
12
|
-
}
|
|
9
|
+
} catch {
|
|
13
10
|
try {
|
|
14
11
|
url.pathname = decodeURI(url.pathname);
|
|
15
12
|
} catch {
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Thrown when a URL path is encoded so many times that we give up decoding it
|
|
3
|
+
* (see {@link validateAndDecodePathname}). When this happens we reject the
|
|
4
|
+
* request with a `400` instead of guessing the path. If we let a half-decoded
|
|
5
|
+
* path through, your middleware might check one path while Astro routes to a
|
|
6
|
+
* different one.
|
|
5
7
|
*/
|
|
6
8
|
export declare class MultiLevelEncodingError extends Error {
|
|
7
9
|
constructor();
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* Decodes a URL path over and over until it stops changing, so a path that was
|
|
13
|
+
* encoded several times ends up as a single, final path. This stops someone
|
|
14
|
+
* from sneaking a path like `/admin` past middleware by encoding it multiple
|
|
15
|
+
* times — middleware always sees the real, decoded path.
|
|
13
16
|
*
|
|
14
|
-
* @param pathname - The
|
|
15
|
-
* @returns The
|
|
16
|
-
* @throws
|
|
17
|
-
*
|
|
17
|
+
* @param pathname - The path to decode
|
|
18
|
+
* @returns The final, fully decoded path
|
|
19
|
+
* @throws Error if the path has broken encoding that can't be decoded at all
|
|
20
|
+
* (for example a lone `%` that isn't followed by two hex digits)
|
|
21
|
+
* @throws MultiLevelEncodingError if the path is still changing after
|
|
22
|
+
* {@link MAX_DECODE_ITERATIONS} tries (it was encoded too many times).
|
|
23
|
+
* Handing back a half-decoded path here would bring back the security hole
|
|
24
|
+
* this function exists to close.
|
|
18
25
|
*/
|
|
19
26
|
export declare function validateAndDecodePathname(pathname: string): string;
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
class MultiLevelEncodingError extends Error {
|
|
2
2
|
constructor() {
|
|
3
|
-
super("
|
|
3
|
+
super("URL encoding depth exceeded the maximum number of decode iterations");
|
|
4
4
|
this.name = "MultiLevelEncodingError";
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const MAX_DECODE_ITERATIONS = 10;
|
|
8
8
|
function validateAndDecodePathname(pathname) {
|
|
9
|
-
if (ENCODING_REGEX.test(pathname)) {
|
|
10
|
-
throw new MultiLevelEncodingError();
|
|
11
|
-
}
|
|
12
9
|
let decoded;
|
|
13
10
|
try {
|
|
14
11
|
decoded = decodeURI(pathname);
|
|
15
12
|
} catch (_e) {
|
|
16
13
|
throw new Error("Invalid URL encoding");
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
let iterations = 0;
|
|
16
|
+
while (decoded !== pathname) {
|
|
17
|
+
if (iterations >= MAX_DECODE_ITERATIONS) {
|
|
18
|
+
throw new MultiLevelEncodingError();
|
|
19
|
+
}
|
|
20
|
+
pathname = decoded;
|
|
21
|
+
try {
|
|
22
|
+
decoded = decodeURI(pathname);
|
|
23
|
+
} catch {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
iterations++;
|
|
20
27
|
}
|
|
21
28
|
return decoded;
|
|
22
29
|
}
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
appendForwardSlash,
|
|
3
|
+
joinPaths,
|
|
4
|
+
removeTrailingForwardSlash
|
|
5
|
+
} from "@astrojs/internal-helpers/path";
|
|
2
6
|
import { shouldAppendForwardSlash } from "../core/build/util.js";
|
|
3
7
|
import { REROUTE_DIRECTIVE_HEADER } from "../core/constants.js";
|
|
4
8
|
import { i18nNoLocaleFoundInPath, MissingLocale } from "../core/errors/errors-data.js";
|
|
@@ -55,7 +59,7 @@ function getLocaleRelativeUrl({
|
|
|
55
59
|
if (shouldAppendForwardSlash(trailingSlash, format)) {
|
|
56
60
|
relativePath = appendForwardSlash(joinPaths(...pathsToJoin));
|
|
57
61
|
} else {
|
|
58
|
-
relativePath = joinPaths(...pathsToJoin);
|
|
62
|
+
relativePath = removeTrailingForwardSlash(joinPaths(...pathsToJoin));
|
|
59
63
|
}
|
|
60
64
|
if (relativePath === "") {
|
|
61
65
|
return "/";
|
|
@@ -87,7 +87,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
87
87
|
_slots.default.push(child);
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
if ("slot" in child.props) {
|
|
90
|
+
if ("slot" in child.props && !isCustomElement) {
|
|
91
91
|
_slots[child.props.slot] = [..._slots[child.props.slot] ?? [], child];
|
|
92
92
|
delete child.props.slot;
|
|
93
93
|
return;
|
|
@@ -116,6 +116,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
116
116
|
const _slots = {
|
|
117
117
|
default: []
|
|
118
118
|
};
|
|
119
|
+
const isCustomElement = typeof vnode.type === "string" && vnode.type.includes("-");
|
|
119
120
|
extractSlots2(children);
|
|
120
121
|
for (const [key, value] of Object.entries(props)) {
|
|
121
122
|
if (value?.["$$slot"]) {
|
|
@@ -51,7 +51,8 @@ function renderAllHeadContent(result) {
|
|
|
51
51
|
const links = deduplicateElements(Array.from(result.links)).map(
|
|
52
52
|
(link) => renderElement("link", link, false)
|
|
53
53
|
);
|
|
54
|
-
|
|
54
|
+
const sep = result.compressHTML === true || result.compressHTML === "jsx" ? "" : "\n";
|
|
55
|
+
content += styles.join(sep) + links.join(sep) + scripts.join(sep);
|
|
55
56
|
content += result._metadata.extraHead.join("");
|
|
56
57
|
return markHTMLString(content);
|
|
57
58
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { isRunnableDevEnvironment } from "vite";
|
|
2
2
|
import { VIRTUAL_PAGE_RESOLVED_MODULE_ID } from "../vite-plugin-pages/const.js";
|
|
3
|
+
import { RESOLVED_MODULE_DEV_CSS_PREFIX } from "../vite-plugin-css/const.js";
|
|
3
4
|
import { getDevCssModuleNameFromPageVirtualModuleName } from "../vite-plugin-css/util.js";
|
|
4
5
|
import { isAstroServerEnvironment } from "../environments.js";
|
|
5
6
|
const STYLE_EXT_REGEX = /\.(?:css|scss|sass|less|styl|pcss)$/i;
|
|
7
|
+
const RAW_QUERY_REGEX = /(?:\?|&)raw(?:&|$)/;
|
|
8
|
+
function hasStyleExtension(id) {
|
|
9
|
+
return STYLE_EXT_REGEX.test(id.split("?")[0]);
|
|
10
|
+
}
|
|
6
11
|
function isStyleModule(mod) {
|
|
7
|
-
if (mod.
|
|
8
|
-
if (mod.
|
|
9
|
-
|
|
10
|
-
if (STYLE_EXT_REGEX.test(idPath)) return true;
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
12
|
+
if (mod.id && RAW_QUERY_REGEX.test(mod.id) && hasStyleExtension(mod.id)) return false;
|
|
13
|
+
if (mod.file && hasStyleExtension(mod.file)) return true;
|
|
14
|
+
return mod.id ? hasStyleExtension(mod.id) : false;
|
|
13
15
|
}
|
|
14
16
|
function hmrReload() {
|
|
15
17
|
return {
|
|
@@ -65,6 +67,17 @@ function hmrReload() {
|
|
|
65
67
|
return [];
|
|
66
68
|
}
|
|
67
69
|
if (hasSkippedStyleModules) {
|
|
70
|
+
for (const [id, mod] of this.environment.moduleGraph.idToModuleMap) {
|
|
71
|
+
if (id.startsWith(RESOLVED_MODULE_DEV_CSS_PREFIX)) {
|
|
72
|
+
this.environment.moduleGraph.invalidateModule(mod, void 0, timestamp, true);
|
|
73
|
+
if (isRunnableDevEnvironment(this.environment)) {
|
|
74
|
+
const runnerMod = this.environment.runner.evaluatedModules.getModuleById(id);
|
|
75
|
+
if (runnerMod) {
|
|
76
|
+
this.environment.runner.evaluatedModules.invalidateModule(runnerMod);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
68
81
|
return [];
|
|
69
82
|
}
|
|
70
83
|
if (modules.length > 0) {
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite';
|
|
2
2
|
import type { RoutesList } from '../types/astro.js';
|
|
3
|
+
import type { RouteData } from '../types/public/internal.js';
|
|
3
4
|
export declare const VIRTUAL_PAGES_MODULE_ID = "virtual:astro:pages";
|
|
4
5
|
interface PagesPluginOptions {
|
|
5
6
|
routesList: RoutesList;
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Filters routes for a specific build environment.
|
|
10
|
+
*
|
|
11
|
+
* Redirect target routes do not need special handling here: they already
|
|
12
|
+
* appear in the routes list with their own `prerender` flag and are
|
|
13
|
+
* included when it matches `isPrerender`. At SSR runtime, redirect
|
|
14
|
+
* responses are generated from route metadata alone (no component is
|
|
15
|
+
* loaded), so the target's component is never needed in the SSR page map.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getRoutesForEnvironment(routes: RouteData[], isPrerender: boolean): Set<RouteData>;
|
|
7
18
|
export declare function pluginPages({ routesList }: PagesPluginOptions): VitePlugin;
|
|
8
19
|
export {};
|
|
@@ -11,9 +11,6 @@ function getRoutesForEnvironment(routes, isPrerender) {
|
|
|
11
11
|
if (route.prerender === isPrerender) {
|
|
12
12
|
result.add(route);
|
|
13
13
|
}
|
|
14
|
-
if (route.redirectRoute) {
|
|
15
|
-
result.add(route.redirectRoute);
|
|
16
|
-
}
|
|
17
14
|
}
|
|
18
15
|
return result;
|
|
19
16
|
}
|
|
@@ -75,5 +72,6 @@ export { pageMap };`;
|
|
|
75
72
|
}
|
|
76
73
|
export {
|
|
77
74
|
VIRTUAL_PAGES_MODULE_ID,
|
|
75
|
+
getRoutesForEnvironment,
|
|
78
76
|
pluginPages
|
|
79
77
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.8",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
"sharp": "^0.34.0"
|
|
174
174
|
},
|
|
175
175
|
"devDependencies": {
|
|
176
|
-
"@astrojs/compiler-rs": "^0.
|
|
176
|
+
"@astrojs/compiler-rs": "^0.2.2",
|
|
177
177
|
"@playwright/test": "1.58.2",
|
|
178
178
|
"@types/aria-query": "^5.0.4",
|
|
179
179
|
"@types/hast": "^3.0.4",
|