astro 6.4.5 → 6.4.7
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/content/vite-plugin-content-virtual-mod.js +27 -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/errors/default-handler.js +21 -8
- package/dist/core/fetch/fetch-state.js +2 -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/util/normalized-url.js +2 -5
- package/dist/core/util/pathname.d.ts +13 -7
- package/dist/core/util/pathname.js +9 -6
- 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/runtime/server/render/util.js +4 -0
- 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 +4 -4
|
@@ -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.7") {
|
|
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.7") {
|
|
209
|
+
this.#store.metaStore().set("astro-version", "6.4.7");
|
|
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
|
@@ -23,6 +23,25 @@ import {
|
|
|
23
23
|
} from "./consts.js";
|
|
24
24
|
import { getDataStoreFile } from "./content-layer.js";
|
|
25
25
|
import { getContentPaths, isDeferredModule } from "./utils.js";
|
|
26
|
+
function invalidateAssetImports(viteServer, filePath) {
|
|
27
|
+
const timestamp = Date.now();
|
|
28
|
+
for (const environment of Object.values(viteServer.environments)) {
|
|
29
|
+
const modules = environment.moduleGraph.getModulesByFile(filePath);
|
|
30
|
+
if (modules) {
|
|
31
|
+
for (const module of modules) {
|
|
32
|
+
environment.moduleGraph.invalidateModule(module, void 0, timestamp, true);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (isRunnableDevEnvironment(environment)) {
|
|
36
|
+
const runnerModules = environment.runner.evaluatedModules.getModulesByFile(filePath);
|
|
37
|
+
if (runnerModules) {
|
|
38
|
+
for (const runnerModule of runnerModules) {
|
|
39
|
+
environment.runner.evaluatedModules.invalidateModule(runnerModule);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
26
45
|
function invalidateDataStore(viteServer) {
|
|
27
46
|
const environment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
|
|
28
47
|
const module = environment.moduleGraph.getModuleById(RESOLVED_DATA_STORE_VIRTUAL_ID);
|
|
@@ -67,8 +86,11 @@ function astroContentVirtualModPlugin({
|
|
|
67
86
|
},
|
|
68
87
|
buildStart() {
|
|
69
88
|
if (devServer) {
|
|
89
|
+
const assetImportsPath = fileURLToPath(new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir));
|
|
70
90
|
devServer.watcher.add(fileURLToPath(dataStoreFile));
|
|
91
|
+
devServer.watcher.add(assetImportsPath);
|
|
71
92
|
invalidateDataStore(devServer);
|
|
93
|
+
invalidateAssetImports(devServer, assetImportsPath);
|
|
72
94
|
}
|
|
73
95
|
},
|
|
74
96
|
resolveId: {
|
|
@@ -175,14 +197,19 @@ function astroContentVirtualModPlugin({
|
|
|
175
197
|
configureServer(server) {
|
|
176
198
|
devServer = server;
|
|
177
199
|
const dataStorePath = fileURLToPath(dataStoreFile);
|
|
200
|
+
const assetImportsPath = fileURLToPath(new URL(ASSET_IMPORTS_FILE, settings.dotAstroDir));
|
|
178
201
|
server.watcher.on("add", (addedPath) => {
|
|
179
202
|
if (addedPath === dataStorePath) {
|
|
180
203
|
invalidateDataStore(server);
|
|
204
|
+
invalidateAssetImports(server, assetImportsPath);
|
|
181
205
|
}
|
|
182
206
|
});
|
|
183
207
|
server.watcher.on("change", (changedPath) => {
|
|
184
208
|
if (changedPath === dataStorePath) {
|
|
185
209
|
invalidateDataStore(server);
|
|
210
|
+
invalidateAssetImports(server, assetImportsPath);
|
|
211
|
+
} else if (changedPath === assetImportsPath) {
|
|
212
|
+
invalidateAssetImports(server, assetImportsPath);
|
|
186
213
|
}
|
|
187
214
|
});
|
|
188
215
|
}
|
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.7";
|
|
41
41
|
const isPrerelease = currentVersion.includes("-");
|
|
42
42
|
if (!isPrerelease) {
|
|
43
43
|
try {
|
|
@@ -6,6 +6,7 @@ import { AstroMiddleware } from "../middleware/astro-middleware.js";
|
|
|
6
6
|
import { PagesHandler } from "../pages/handler.js";
|
|
7
7
|
import { matchRoute } from "../routing/match.js";
|
|
8
8
|
import { provideSession } from "../session/handler.js";
|
|
9
|
+
import { validateHost } from "../app/validate-headers.js";
|
|
9
10
|
class DefaultErrorHandler {
|
|
10
11
|
#app;
|
|
11
12
|
#astroMiddleware;
|
|
@@ -31,15 +32,27 @@ class DefaultErrorHandler {
|
|
|
31
32
|
if (errorRouteData) {
|
|
32
33
|
if (errorRouteData.prerender) {
|
|
33
34
|
const maybeDotHtml = errorRouteData.route.endsWith(`/${status}`) ? ".html" : "";
|
|
34
|
-
const
|
|
35
|
+
const allowedDomains = app.manifest.allowedDomains;
|
|
36
|
+
const validatedHost = validateHost(url.host, url.protocol.replace(":", ""), allowedDomains);
|
|
37
|
+
const safeOrigin = validatedHost ? url.origin : `${url.protocol}//localhost`;
|
|
38
|
+
const statusURL = new URL(
|
|
39
|
+
`${app.baseWithoutTrailingSlash}/${status}${maybeDotHtml}`,
|
|
40
|
+
safeOrigin
|
|
41
|
+
);
|
|
35
42
|
if (statusURL.toString() !== request.url && resolvedRenderOptions.prerenderedErrorPageFetch) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
try {
|
|
44
|
+
const response2 = await resolvedRenderOptions.prerenderedErrorPageFetch(
|
|
45
|
+
statusURL.toString()
|
|
46
|
+
);
|
|
47
|
+
const override = { status, removeContentEncodingHeaders: true };
|
|
48
|
+
const newResponse = mergeResponses(response2, originalResponse, override);
|
|
49
|
+
prepareResponse(newResponse, resolvedRenderOptions);
|
|
50
|
+
return newResponse;
|
|
51
|
+
} catch {
|
|
52
|
+
const response2 = mergeResponses(new Response(null, { status }), originalResponse);
|
|
53
|
+
prepareResponse(response2, resolvedRenderOptions);
|
|
54
|
+
return response2;
|
|
55
|
+
}
|
|
43
56
|
}
|
|
44
57
|
}
|
|
45
58
|
const mod = await app.pipeline.getComponentByRoute(errorRouteData);
|
|
@@ -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 { 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";
|
|
@@ -678,7 +679,7 @@ class FetchState {
|
|
|
678
679
|
}
|
|
679
680
|
pathname = prependForwardSlash(pathname);
|
|
680
681
|
try {
|
|
681
|
-
return
|
|
682
|
+
return validateAndDecodePathname(pathname);
|
|
682
683
|
} catch (e) {
|
|
683
684
|
this.pipeline.logger.error(null, e.toString());
|
|
684
685
|
return pathname;
|
|
@@ -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
|
};
|
|
@@ -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 {
|
|
@@ -2,18 +2,24 @@
|
|
|
2
2
|
* Error thrown when multi-level URL encoding is detected in a pathname.
|
|
3
3
|
* This is a distinct error type so callers can handle it specifically
|
|
4
4
|
* (e.g., returning a 400 response) rather than falling back to partial decoding.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated No longer thrown internally — multi-level encoding is now
|
|
7
|
+
* decoded iteratively instead of rejected. Kept for backwards compatibility
|
|
8
|
+
* in case third-party code references the class.
|
|
5
9
|
*/
|
|
6
10
|
export declare class MultiLevelEncodingError extends Error {
|
|
7
11
|
constructor();
|
|
8
12
|
}
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
14
|
+
* Decodes a pathname iteratively until stable, collapsing all levels of
|
|
15
|
+
* percent-encoding into a single canonical form. This prevents
|
|
16
|
+
* double/triple encoding from bypassing middleware authorization checks
|
|
17
|
+
* (CVE-2025-66202) — instead of rejecting multi-level encoding, we
|
|
18
|
+
* fully resolve it so middleware always sees the true decoded path.
|
|
13
19
|
*
|
|
14
|
-
* @param pathname - The pathname to
|
|
15
|
-
* @returns The decoded pathname
|
|
16
|
-
* @throws
|
|
17
|
-
*
|
|
20
|
+
* @param pathname - The pathname to decode
|
|
21
|
+
* @returns The fully decoded pathname
|
|
22
|
+
* @throws Error if the pathname contains invalid URL encoding that
|
|
23
|
+
* cannot be decoded at all (e.g., a bare `%` not followed by hex digits)
|
|
18
24
|
*/
|
|
19
25
|
export declare function validateAndDecodePathname(pathname: string): string;
|
|
@@ -4,19 +4,22 @@ class MultiLevelEncodingError extends Error {
|
|
|
4
4
|
this.name = "MultiLevelEncodingError";
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
const ENCODING_REGEX = /%25[0-9a-fA-F]{2}/;
|
|
8
7
|
function validateAndDecodePathname(pathname) {
|
|
9
|
-
if (ENCODING_REGEX.test(pathname)) {
|
|
10
|
-
throw new MultiLevelEncodingError();
|
|
11
|
-
}
|
|
12
8
|
let decoded;
|
|
13
9
|
try {
|
|
14
10
|
decoded = decodeURI(pathname);
|
|
15
11
|
} catch (_e) {
|
|
16
12
|
throw new Error("Invalid URL encoding");
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
let iterations = 0;
|
|
15
|
+
while (decoded !== pathname && iterations < 10) {
|
|
16
|
+
pathname = decoded;
|
|
17
|
+
try {
|
|
18
|
+
decoded = decodeURI(pathname);
|
|
19
|
+
} catch {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
iterations++;
|
|
20
23
|
}
|
|
21
24
|
return decoded;
|
|
22
25
|
}
|
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
|
}
|
|
@@ -6,6 +6,7 @@ const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|chec
|
|
|
6
6
|
const AMPERSAND_REGEX = /&/g;
|
|
7
7
|
const DOUBLE_QUOTE_REGEX = /"/g;
|
|
8
8
|
const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
|
|
9
|
+
const INVALID_ATTR_NAME_CHAR = /[\s"'>/=]/;
|
|
9
10
|
const toIdent = (k) => k.trim().replace(/(?!^)\b\w|\s+|\W+/g, (match, index) => {
|
|
10
11
|
if (/\W/.test(match)) return "";
|
|
11
12
|
return index === 0 ? match : match.toUpperCase();
|
|
@@ -43,6 +44,9 @@ function addAttribute(value, key, shouldEscape = true, tagName = "") {
|
|
|
43
44
|
if (value == null) {
|
|
44
45
|
return "";
|
|
45
46
|
}
|
|
47
|
+
if (INVALID_ATTR_NAME_CHAR.test(key)) {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
46
50
|
if (STATIC_DIRECTIVES.has(key)) {
|
|
47
51
|
console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
|
|
48
52
|
|
|
@@ -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.7",
|
|
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",
|
|
@@ -203,8 +203,8 @@
|
|
|
203
203
|
"undici": "^7.22.0",
|
|
204
204
|
"unified": "^11.0.5",
|
|
205
205
|
"vitest": "^4.1.0",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
206
|
+
"astro-scripts": "0.0.14",
|
|
207
|
+
"@astrojs/check": "0.9.9"
|
|
208
208
|
},
|
|
209
209
|
"engines": {
|
|
210
210
|
"node": ">=22.12.0",
|