astro 5.1.5 → 5.1.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/client.d.ts +1 -1
- package/dist/actions/runtime/virtual/server.d.ts +1 -1
- package/dist/assets/build/remote.js +1 -1
- package/dist/assets/layout.js +4 -0
- package/dist/cli/add/index.js +2 -0
- package/dist/content/content-layer.js +3 -3
- package/dist/content/loaders/glob.js +6 -2
- package/dist/content/mutable-data-store.js +4 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +4 -4
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +2 -0
- package/dist/core/errors/errors-data.js +2 -2
- package/dist/core/messages.js +2 -2
- package/dist/core/render-context.js +10 -1
- package/dist/core/routing/match.d.ts +2 -0
- package/dist/core/routing/match.js +11 -1
- package/dist/core/server-islands/endpoint.js +1 -1
- package/dist/env/env-loader.d.ts +2 -2
- package/dist/env/env-loader.js +5 -10
- package/dist/env/vite-plugin-env.d.ts +1 -2
- package/dist/env/vite-plugin-env.js +28 -19
- package/dist/{vite-plugin-env/index.d.ts → env/vite-plugin-import-meta-env.d.ts} +2 -2
- package/dist/{vite-plugin-env/index.js → env/vite-plugin-import-meta-env.js} +2 -2
- package/dist/i18n/index.js +3 -1
- package/dist/i18n/middleware.js +1 -0
- package/dist/jsx/rehype.js +3 -0
- package/dist/runtime/server/hydration.js +2 -0
- package/dist/runtime/server/render/server-islands.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +6 -5
- package/package.json +24 -24
package/client.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ declare module '*.avif' {
|
|
|
110
110
|
declare module '*.svg' {
|
|
111
111
|
type Props = {
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* Accessible, short-text description
|
|
114
114
|
*
|
|
115
115
|
* {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title|MDN Reference}
|
|
116
116
|
*/
|
|
@@ -26,7 +26,7 @@ export type ActionMiddlewareContext = {
|
|
|
26
26
|
calledFrom: 'rpc' | 'form';
|
|
27
27
|
/** The name of the action. Useful to track the source of an action result during a redirect. */
|
|
28
28
|
name: string;
|
|
29
|
-
/**
|
|
29
|
+
/** Programmatically call the action to get the result. */
|
|
30
30
|
handler: () => Promise<SafeResult<any, any>>;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -37,7 +37,7 @@ async function revalidateRemoteImage(src, revalidationData) {
|
|
|
37
37
|
webToCachePolicyResponse(
|
|
38
38
|
res.ok ? res : new Response(null, { status: 200, headers: res.headers })
|
|
39
39
|
)
|
|
40
|
-
// 304 responses themselves are not
|
|
40
|
+
// 304 responses themselves are not cacheable, so just pretend to get the refreshed TTL
|
|
41
41
|
);
|
|
42
42
|
const expires = policy.storable() ? policy.timeToLive() : 0;
|
|
43
43
|
return {
|
package/dist/assets/layout.js
CHANGED
|
@@ -84,10 +84,14 @@ const getSizesAttribute = ({
|
|
|
84
84
|
return void 0;
|
|
85
85
|
}
|
|
86
86
|
switch (layout) {
|
|
87
|
+
// If screen is wider than the max size then image width is the max size,
|
|
88
|
+
// otherwise it's the width of the screen
|
|
87
89
|
case `responsive`:
|
|
88
90
|
return `(min-width: ${width}px) ${width}px, 100vw`;
|
|
91
|
+
// Image is always the same width, whatever the size of the screen
|
|
89
92
|
case `fixed`:
|
|
90
93
|
return `${width}px`;
|
|
94
|
+
// Image is always the width of the screen
|
|
91
95
|
case `full-width`:
|
|
92
96
|
return `100vw`;
|
|
93
97
|
case "none":
|
package/dist/cli/add/index.js
CHANGED
|
@@ -307,6 +307,8 @@ async function add(names, { flags }) {
|
|
|
307
307
|
logger.info("SKIP_FORMAT", msg.success(`Configuration up-to-date.`));
|
|
308
308
|
break;
|
|
309
309
|
}
|
|
310
|
+
// NOTE: failure shouldn't happen in practice because `updateAstroConfig` doesn't return that.
|
|
311
|
+
// Pipe this to the same handling as `UpdateResult.updated` for now.
|
|
310
312
|
case 3 /* failure */:
|
|
311
313
|
case 1 /* updated */:
|
|
312
314
|
case void 0: {
|
|
@@ -148,7 +148,7 @@ ${contentConfig.error.message}`);
|
|
|
148
148
|
logger.info("Content config changed");
|
|
149
149
|
shouldClear = true;
|
|
150
150
|
}
|
|
151
|
-
if (previousAstroVersion && previousAstroVersion !== "5.1.
|
|
151
|
+
if (previousAstroVersion && previousAstroVersion !== "5.1.7") {
|
|
152
152
|
logger.info("Astro version changed");
|
|
153
153
|
shouldClear = true;
|
|
154
154
|
}
|
|
@@ -156,8 +156,8 @@ ${contentConfig.error.message}`);
|
|
|
156
156
|
logger.info("Clearing content store");
|
|
157
157
|
this.#store.clearAll();
|
|
158
158
|
}
|
|
159
|
-
if ("5.1.
|
|
160
|
-
await this.#store.metaStore().set("astro-version", "5.1.
|
|
159
|
+
if ("5.1.7") {
|
|
160
|
+
await this.#store.metaStore().set("astro-version", "5.1.7");
|
|
161
161
|
}
|
|
162
162
|
if (currentConfigDigest) {
|
|
163
163
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -44,7 +44,7 @@ function glob(globOptions) {
|
|
|
44
44
|
const untouchedEntries = new Set(store.keys());
|
|
45
45
|
const isLegacy = globOptions._legacy;
|
|
46
46
|
const emulateLegacyCollections = !config.legacy.collections;
|
|
47
|
-
async function syncData(entry, base, entryType) {
|
|
47
|
+
async function syncData(entry, base, entryType, oldId) {
|
|
48
48
|
if (!entryType) {
|
|
49
49
|
logger.warn(`No entry type found for ${entry}`);
|
|
50
50
|
return;
|
|
@@ -63,6 +63,9 @@ function glob(globOptions) {
|
|
|
63
63
|
fileUrl
|
|
64
64
|
});
|
|
65
65
|
const id = generateId({ entry, base, data });
|
|
66
|
+
if (oldId && oldId !== id) {
|
|
67
|
+
store.delete(oldId);
|
|
68
|
+
}
|
|
66
69
|
let legacyId;
|
|
67
70
|
if (isLegacy) {
|
|
68
71
|
const entryURL = new URL(encodeURI(entry), base);
|
|
@@ -225,7 +228,8 @@ function glob(globOptions) {
|
|
|
225
228
|
}
|
|
226
229
|
const entryType = configForFile(changedPath);
|
|
227
230
|
const baseUrl = pathToFileURL(basePath);
|
|
228
|
-
|
|
231
|
+
const oldId = fileToIdMap.get(changedPath);
|
|
232
|
+
await syncData(entry, baseUrl, entryType, oldId);
|
|
229
233
|
logger.info(`Reloaded data from ${green(entry)}`);
|
|
230
234
|
}
|
|
231
235
|
watcher.on("change", onChange);
|
|
@@ -168,6 +168,10 @@ ${lines.join(",\n")}]);
|
|
|
168
168
|
this.#writing.add(fileKey);
|
|
169
169
|
const tempFile = filePath instanceof URL ? new URL(`${filePath.href}.tmp`) : `${filePath}.tmp`;
|
|
170
170
|
try {
|
|
171
|
+
const oldData = await fs.readFile(filePath, "utf-8").catch(() => "");
|
|
172
|
+
if (oldData === data) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
171
175
|
await fs.writeFile(tempFile, data);
|
|
172
176
|
await fs.rename(tempFile, filePath);
|
|
173
177
|
} finally {
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "../content/index.js";
|
|
15
15
|
import { createEnvLoader } from "../env/env-loader.js";
|
|
16
16
|
import { astroEnv } from "../env/vite-plugin-env.js";
|
|
17
|
+
import { importMetaEnv } from "../env/vite-plugin-import-meta-env.js";
|
|
17
18
|
import astroInternationalization from "../i18n/vite-plugin-i18n.js";
|
|
18
19
|
import astroPrefetch from "../prefetch/vite-plugin-prefetch.js";
|
|
19
20
|
import astroDevToolbar from "../toolbar/vite-plugin-dev-toolbar.js";
|
|
@@ -22,7 +23,6 @@ import astroPostprocessVitePlugin from "../vite-plugin-astro-postprocess/index.j
|
|
|
22
23
|
import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
|
|
23
24
|
import astroVitePlugin from "../vite-plugin-astro/index.js";
|
|
24
25
|
import configAliasVitePlugin from "../vite-plugin-config-alias/index.js";
|
|
25
|
-
import envVitePlugin from "../vite-plugin-env/index.js";
|
|
26
26
|
import vitePluginFileURL from "../vite-plugin-fileurl/index.js";
|
|
27
27
|
import astroHeadPlugin from "../vite-plugin-head/index.js";
|
|
28
28
|
import astroHmrReloadPlugin from "../vite-plugin-hmr-reload/index.js";
|
|
@@ -84,7 +84,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
const srcDirPattern = glob.convertPathToPattern(fileURLToPath(settings.config.srcDir));
|
|
87
|
-
const envLoader = createEnvLoader();
|
|
87
|
+
const envLoader = createEnvLoader(mode, settings.config);
|
|
88
88
|
const commonConfig = {
|
|
89
89
|
// Tell Vite not to combine config from vite.config.js with our provided inline config
|
|
90
90
|
configFile: false,
|
|
@@ -109,8 +109,8 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
109
109
|
// the build to run very slow as the filewatcher is triggered often.
|
|
110
110
|
command === "dev" && vitePluginAstroServer({ settings, logger, fs, manifest, ssrManifest }),
|
|
111
111
|
// ssrManifest is only required in dev mode, where it gets created before a Vite instance is created, and get passed to this function
|
|
112
|
-
|
|
113
|
-
astroEnv({ settings,
|
|
112
|
+
importMetaEnv({ envLoader }),
|
|
113
|
+
astroEnv({ settings, sync, envLoader }),
|
|
114
114
|
markdownVitePlugin({ settings, logger }),
|
|
115
115
|
htmlVitePlugin(),
|
|
116
116
|
astroPostprocessVitePlugin(),
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.1.
|
|
25
|
+
const currentVersion = "5.1.7";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
|
@@ -776,6 +776,7 @@ export declare const AstroResponseHeadersReassigned: {
|
|
|
776
776
|
};
|
|
777
777
|
/**
|
|
778
778
|
* @docs
|
|
779
|
+
* @message Error when initializing session storage with driver `DRIVER`. `ERROR`
|
|
779
780
|
* @see
|
|
780
781
|
* - [experimental.session](https://docs.astro.build/en/reference/experimental-flags/sessions/)
|
|
781
782
|
* @description
|
|
@@ -789,6 +790,7 @@ export declare const SessionStorageInitError: {
|
|
|
789
790
|
};
|
|
790
791
|
/**
|
|
791
792
|
* @docs
|
|
793
|
+
* @message Error when saving session data with driver `DRIVER`. `ERROR`
|
|
792
794
|
* @see
|
|
793
795
|
* - [experimental.session](https://docs.astro.build/en/reference/experimental-flags/sessions/)
|
|
794
796
|
* @description
|
|
@@ -278,13 +278,13 @@ const AstroResponseHeadersReassigned = {
|
|
|
278
278
|
const SessionStorageInitError = {
|
|
279
279
|
name: "SessionStorageInitError",
|
|
280
280
|
title: "Session storage could not be initialized.",
|
|
281
|
-
message: (error, driver) => `Error when initializing session storage${driver ? ` with driver
|
|
281
|
+
message: (error, driver) => `Error when initializing session storage${driver ? ` with driver \`${driver}\`` : ""}. \`${error ?? ""}\``,
|
|
282
282
|
hint: "For more information, see https://docs.astro.build/en/reference/experimental-flags/sessions/"
|
|
283
283
|
};
|
|
284
284
|
const SessionStorageSaveError = {
|
|
285
285
|
name: "SessionStorageSaveError",
|
|
286
286
|
title: "Session data could not be saved.",
|
|
287
|
-
message: (error, driver) => `Error when saving session data${driver ? ` with driver
|
|
287
|
+
message: (error, driver) => `Error when saving session data${driver ? ` with driver \`${driver}\`` : ""}. \`${error ?? ""}\``,
|
|
288
288
|
hint: "For more information, see https://docs.astro.build/en/reference/experimental-flags/sessions/"
|
|
289
289
|
};
|
|
290
290
|
const MiddlewareCantBeLoaded = {
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "5.1.
|
|
41
|
+
const version = "5.1.7";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -276,7 +276,7 @@ function printHelp({
|
|
|
276
276
|
message.push(
|
|
277
277
|
linebreak(),
|
|
278
278
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
279
|
-
`v${"5.1.
|
|
279
|
+
`v${"5.1.7"}`
|
|
280
280
|
)} ${headline}`
|
|
281
281
|
);
|
|
282
282
|
}
|
|
@@ -488,7 +488,16 @@ class RenderContext {
|
|
|
488
488
|
computedLocale = computeCurrentLocale(referer, locales, defaultLocale);
|
|
489
489
|
}
|
|
490
490
|
} else {
|
|
491
|
-
|
|
491
|
+
let pathname = routeData.pathname;
|
|
492
|
+
if (!routeData.pattern.test(url.pathname)) {
|
|
493
|
+
for (const fallbackRoute of routeData.fallbackRoutes) {
|
|
494
|
+
if (fallbackRoute.pattern.test(url.pathname)) {
|
|
495
|
+
pathname = fallbackRoute.pathname;
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
pathname = pathname && !isRoute404or500(routeData) ? pathname : url.pathname;
|
|
492
501
|
computedLocale = computeCurrentLocale(pathname, locales, defaultLocale);
|
|
493
502
|
}
|
|
494
503
|
this.#currentLocale = computedLocale ?? fallbackTo;
|
|
@@ -4,6 +4,8 @@ import type { RouteData } from '../../types/public/internal.js';
|
|
|
4
4
|
export declare function matchRoute(pathname: string, manifest: ManifestData): RouteData | undefined;
|
|
5
5
|
/** Finds all matching routes from pathname */
|
|
6
6
|
export declare function matchAllRoutes(pathname: string, manifest: ManifestData): RouteData[];
|
|
7
|
+
export declare function isRoute404(route: string): boolean;
|
|
8
|
+
export declare function isRoute500(route: string): boolean;
|
|
7
9
|
/**
|
|
8
10
|
* Determines if the given route matches a 404 or 500 error page.
|
|
9
11
|
*
|
|
@@ -7,11 +7,21 @@ function matchRoute(pathname, manifest) {
|
|
|
7
7
|
function matchAllRoutes(pathname, manifest) {
|
|
8
8
|
return manifest.routes.filter((route) => route.pattern.test(decodeURI(pathname)));
|
|
9
9
|
}
|
|
10
|
+
const ROUTE404_RE = /^\/404\/?$/;
|
|
11
|
+
const ROUTE500_RE = /^\/500\/?$/;
|
|
12
|
+
function isRoute404(route) {
|
|
13
|
+
return ROUTE404_RE.test(route);
|
|
14
|
+
}
|
|
15
|
+
function isRoute500(route) {
|
|
16
|
+
return ROUTE500_RE.test(route);
|
|
17
|
+
}
|
|
10
18
|
function isRoute404or500(route) {
|
|
11
|
-
return route.
|
|
19
|
+
return isRoute404(route.route) || isRoute500(route.route);
|
|
12
20
|
}
|
|
13
21
|
export {
|
|
22
|
+
isRoute404,
|
|
14
23
|
isRoute404or500,
|
|
24
|
+
isRoute500,
|
|
15
25
|
matchAllRoutes,
|
|
16
26
|
matchRoute
|
|
17
27
|
};
|
|
@@ -93,7 +93,7 @@ function createEndpoint(manifest) {
|
|
|
93
93
|
}
|
|
94
94
|
const key = await manifest.key;
|
|
95
95
|
const encryptedProps = data.encryptedProps;
|
|
96
|
-
const propString = await decryptString(key, encryptedProps);
|
|
96
|
+
const propString = encryptedProps === "" ? "{}" : await decryptString(key, encryptedProps);
|
|
97
97
|
const props = JSON.parse(propString);
|
|
98
98
|
const componentModule = await imp();
|
|
99
99
|
let Component = componentModule[data.componentExport];
|
package/dist/env/env-loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AstroConfig } from '../types/public/index.js';
|
|
2
|
-
export declare const createEnvLoader: () => {
|
|
3
|
-
|
|
2
|
+
export declare const createEnvLoader: (mode: string, config: AstroConfig) => {
|
|
3
|
+
get: () => Record<string, string>;
|
|
4
4
|
getPrivateEnv: () => Record<string, string>;
|
|
5
5
|
};
|
|
6
6
|
export type EnvLoader = ReturnType<typeof createEnvLoader>;
|
package/dist/env/env-loader.js
CHANGED
|
@@ -27,17 +27,12 @@ function getPrivateEnv(fullEnv, astroConfig) {
|
|
|
27
27
|
}
|
|
28
28
|
return privateEnv;
|
|
29
29
|
}
|
|
30
|
-
const createEnvLoader = () => {
|
|
31
|
-
|
|
30
|
+
const createEnvLoader = (mode, config) => {
|
|
31
|
+
const loaded = loadEnv(mode, config.vite.envDir ?? fileURLToPath(config.root), "");
|
|
32
|
+
const privateEnv = getPrivateEnv(loaded, config);
|
|
32
33
|
return {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
privateEnv = getPrivateEnv(loaded, config);
|
|
36
|
-
return loaded;
|
|
37
|
-
},
|
|
38
|
-
getPrivateEnv: () => {
|
|
39
|
-
return privateEnv;
|
|
40
|
-
}
|
|
34
|
+
get: () => loaded,
|
|
35
|
+
getPrivateEnv: () => privateEnv
|
|
41
36
|
};
|
|
42
37
|
};
|
|
43
38
|
export {
|
|
@@ -3,9 +3,8 @@ import type { AstroSettings } from '../types/astro.js';
|
|
|
3
3
|
import type { EnvLoader } from './env-loader.js';
|
|
4
4
|
interface AstroEnvPluginParams {
|
|
5
5
|
settings: AstroSettings;
|
|
6
|
-
mode: string;
|
|
7
6
|
sync: boolean;
|
|
8
7
|
envLoader: EnvLoader;
|
|
9
8
|
}
|
|
10
|
-
export declare function astroEnv({ settings,
|
|
9
|
+
export declare function astroEnv({ settings, sync, envLoader }: AstroEnvPluginParams): Plugin;
|
|
11
10
|
export {};
|
|
@@ -7,10 +7,33 @@ import {
|
|
|
7
7
|
} from "./constants.js";
|
|
8
8
|
import { invalidVariablesToError } from "./errors.js";
|
|
9
9
|
import { getEnvFieldType, validateEnvVariable } from "./validators.js";
|
|
10
|
-
function astroEnv({ settings,
|
|
10
|
+
function astroEnv({ settings, sync, envLoader }) {
|
|
11
11
|
const { schema, validateSecrets } = settings.config.env;
|
|
12
12
|
let isDev;
|
|
13
13
|
let templates = null;
|
|
14
|
+
function ensureTemplateAreLoaded() {
|
|
15
|
+
if (templates !== null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const loadedEnv = envLoader.get();
|
|
19
|
+
if (!isDev) {
|
|
20
|
+
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
21
|
+
if (value !== void 0) {
|
|
22
|
+
process.env[key] = value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const validatedVariables = validatePublicVariables({
|
|
27
|
+
schema,
|
|
28
|
+
loadedEnv,
|
|
29
|
+
validateSecrets,
|
|
30
|
+
sync
|
|
31
|
+
});
|
|
32
|
+
templates = {
|
|
33
|
+
...getTemplates(schema, validatedVariables, isDev ? loadedEnv : null),
|
|
34
|
+
internal: `export const schema = ${JSON.stringify(schema)};`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
14
37
|
return {
|
|
15
38
|
name: "astro-env-plugin",
|
|
16
39
|
enforce: "pre",
|
|
@@ -18,24 +41,7 @@ function astroEnv({ settings, mode, sync, envLoader }) {
|
|
|
18
41
|
isDev = command !== "build";
|
|
19
42
|
},
|
|
20
43
|
buildStart() {
|
|
21
|
-
|
|
22
|
-
if (!isDev) {
|
|
23
|
-
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
24
|
-
if (value !== void 0) {
|
|
25
|
-
process.env[key] = value;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const validatedVariables = validatePublicVariables({
|
|
30
|
-
schema,
|
|
31
|
-
loadedEnv,
|
|
32
|
-
validateSecrets,
|
|
33
|
-
sync
|
|
34
|
-
});
|
|
35
|
-
templates = {
|
|
36
|
-
...getTemplates(schema, validatedVariables, isDev ? loadedEnv : null),
|
|
37
|
-
internal: `export const schema = ${JSON.stringify(schema)};`
|
|
38
|
-
};
|
|
44
|
+
ensureTemplateAreLoaded();
|
|
39
45
|
},
|
|
40
46
|
buildEnd() {
|
|
41
47
|
templates = null;
|
|
@@ -47,10 +53,12 @@ function astroEnv({ settings, mode, sync, envLoader }) {
|
|
|
47
53
|
},
|
|
48
54
|
load(id, options) {
|
|
49
55
|
if (id === resolveVirtualModuleId(VIRTUAL_MODULES_IDS.client)) {
|
|
56
|
+
ensureTemplateAreLoaded();
|
|
50
57
|
return templates.client;
|
|
51
58
|
}
|
|
52
59
|
if (id === resolveVirtualModuleId(VIRTUAL_MODULES_IDS.server)) {
|
|
53
60
|
if (options?.ssr) {
|
|
61
|
+
ensureTemplateAreLoaded();
|
|
54
62
|
return templates.server;
|
|
55
63
|
}
|
|
56
64
|
throw new AstroError({
|
|
@@ -59,6 +67,7 @@ function astroEnv({ settings, mode, sync, envLoader }) {
|
|
|
59
67
|
});
|
|
60
68
|
}
|
|
61
69
|
if (id === resolveVirtualModuleId(VIRTUAL_MODULES_IDS.internal)) {
|
|
70
|
+
ensureTemplateAreLoaded();
|
|
62
71
|
return templates.internal;
|
|
63
72
|
}
|
|
64
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
|
-
import type { EnvLoader } from '
|
|
2
|
+
import type { EnvLoader } from './env-loader.js';
|
|
3
3
|
interface EnvPluginOptions {
|
|
4
4
|
envLoader: EnvLoader;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export declare function importMetaEnv({ envLoader }: EnvPluginOptions): vite.Plugin;
|
|
7
7
|
export {};
|
|
@@ -37,7 +37,7 @@ async function replaceDefine(code, id, define, config) {
|
|
|
37
37
|
map: result.map || null
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function importMetaEnv({ envLoader }) {
|
|
41
41
|
let privateEnv;
|
|
42
42
|
let defaultDefines;
|
|
43
43
|
let isDev;
|
|
@@ -108,5 +108,5 @@ function envVitePlugin({ envLoader }) {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
export {
|
|
111
|
-
|
|
111
|
+
importMetaEnv
|
|
112
112
|
};
|
package/dist/i18n/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { shouldAppendForwardSlash } from "../core/build/util.js";
|
|
|
3
3
|
import { REROUTE_DIRECTIVE_HEADER } from "../core/constants.js";
|
|
4
4
|
import { MissingLocale, i18nNoLocaleFoundInPath } from "../core/errors/errors-data.js";
|
|
5
5
|
import { AstroError } from "../core/errors/index.js";
|
|
6
|
+
import { isRoute404, isRoute500 } from "../core/routing/match.js";
|
|
6
7
|
import { createI18nMiddleware } from "./middleware.js";
|
|
7
8
|
function requestHasLocale(locales) {
|
|
8
9
|
return function(context) {
|
|
@@ -11,7 +12,8 @@ function requestHasLocale(locales) {
|
|
|
11
12
|
}
|
|
12
13
|
function requestIs404Or500(request, base = "") {
|
|
13
14
|
const url = new URL(request.url);
|
|
14
|
-
|
|
15
|
+
const pathname = url.pathname.slice(base.length);
|
|
16
|
+
return isRoute404(pathname) || isRoute500(pathname);
|
|
15
17
|
}
|
|
16
18
|
function pathHasLocale(path, locales) {
|
|
17
19
|
const segments = path.split("/");
|
package/dist/i18n/middleware.js
CHANGED
package/dist/jsx/rehype.js
CHANGED
|
@@ -111,14 +111,17 @@ function findMatchingImport(tagName, imports) {
|
|
|
111
111
|
if (local === tagSpecifier) {
|
|
112
112
|
if (tagSpecifier !== tagName) {
|
|
113
113
|
switch (imported) {
|
|
114
|
+
// Namespace import: "<buttons.Foo.Bar />" => name: "Foo.Bar"
|
|
114
115
|
case "*": {
|
|
115
116
|
const accessPath = tagName.slice(tagSpecifier.length + 1);
|
|
116
117
|
return { name: accessPath, path: source };
|
|
117
118
|
}
|
|
119
|
+
// Default import: "<buttons.Foo.Bar />" => name: "default.Foo.Bar"
|
|
118
120
|
case "default": {
|
|
119
121
|
const accessPath = tagName.slice(tagSpecifier.length + 1);
|
|
120
122
|
return { name: `default.${accessPath}`, path: source };
|
|
121
123
|
}
|
|
124
|
+
// Named import: "<buttons.Foo.Bar />" => name: "buttons.Foo.Bar"
|
|
122
125
|
default: {
|
|
123
126
|
return { name: tagName, path: source };
|
|
124
127
|
}
|
|
@@ -37,6 +37,8 @@ function extractDirectives(inputProps, clientDirectives) {
|
|
|
37
37
|
extracted.hydration.componentExport.value = value;
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
|
+
// This is a special prop added to prove that the client hydration method
|
|
41
|
+
// was added statically.
|
|
40
42
|
case "client:component-hydration": {
|
|
41
43
|
break;
|
|
42
44
|
}
|
|
@@ -50,7 +50,7 @@ function renderServerIsland(result, _displayName, props, slots) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
const key = await result.key;
|
|
53
|
-
const propsEncrypted = await encryptString(key, JSON.stringify(props));
|
|
53
|
+
const propsEncrypted = Object.keys(props).length === 0 ? "" : await encryptString(key, JSON.stringify(props));
|
|
54
54
|
const hostId = crypto.randomUUID();
|
|
55
55
|
const slash = result.base.endsWith("/") ? "" : "/";
|
|
56
56
|
let serverIslandUrl = `${result.base}${slash}_server-islands/${componentId}${result.trailingSlash === "always" ? "/" : ""}`;
|
|
@@ -14,6 +14,7 @@ import { getProps } from "../core/render/index.js";
|
|
|
14
14
|
import { createRequest } from "../core/request.js";
|
|
15
15
|
import { redirectTemplate } from "../core/routing/3xx.js";
|
|
16
16
|
import { matchAllRoutes } from "../core/routing/index.js";
|
|
17
|
+
import { isRoute404, isRoute500 } from "../core/routing/match.js";
|
|
17
18
|
import { PERSIST_SYMBOL } from "../core/session.js";
|
|
18
19
|
import { getSortedPreloadedMatches } from "../prerender/routing.js";
|
|
19
20
|
import { writeSSRResult, writeWebResponse } from "./response.js";
|
|
@@ -21,12 +22,10 @@ function isLoggedRequest(url) {
|
|
|
21
22
|
return url !== "/favicon.ico";
|
|
22
23
|
}
|
|
23
24
|
function getCustom404Route(manifestData) {
|
|
24
|
-
|
|
25
|
-
return manifestData.routes.find((r) => route404.test(r.route));
|
|
25
|
+
return manifestData.routes.find((r) => isRoute404(r.route));
|
|
26
26
|
}
|
|
27
27
|
function getCustom500Route(manifestData) {
|
|
28
|
-
|
|
29
|
-
return manifestData.routes.find((r) => route500.test(r.route));
|
|
28
|
+
return manifestData.routes.find((r) => isRoute500(r.route));
|
|
30
29
|
}
|
|
31
30
|
async function matchRoute(pathname, manifestData, pipeline) {
|
|
32
31
|
const { config, logger, routeCache, serverLike, settings } = pipeline;
|
|
@@ -175,7 +174,9 @@ async function handleRoute({
|
|
|
175
174
|
})
|
|
176
175
|
);
|
|
177
176
|
}
|
|
178
|
-
if (statusCode === 404 &&
|
|
177
|
+
if (statusCode === 404 && // If the body isn't null, that means the user sets the 404 status
|
|
178
|
+
// but uses the current route to handle the 404
|
|
179
|
+
response.body === null && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
|
|
179
180
|
const fourOhFourRoute = await matchRoute("/404", manifestData, pipeline);
|
|
180
181
|
if (fourOhFourRoute) {
|
|
181
182
|
renderContext = await RenderContext.create({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.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",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"dependencies": {
|
|
106
106
|
"@astrojs/compiler": "^2.10.3",
|
|
107
107
|
"@oslojs/encoding": "^1.1.0",
|
|
108
|
-
"@rollup/pluginutils": "^5.1.
|
|
108
|
+
"@rollup/pluginutils": "^5.1.4",
|
|
109
109
|
"@types/cookie": "^0.6.0",
|
|
110
110
|
"acorn": "^8.14.0",
|
|
111
111
|
"aria-query": "^5.3.2",
|
|
@@ -116,51 +116,51 @@
|
|
|
116
116
|
"common-ancestor-path": "^1.0.1",
|
|
117
117
|
"cookie": "^0.7.2",
|
|
118
118
|
"cssesc": "^3.0.0",
|
|
119
|
-
"debug": "^4.
|
|
119
|
+
"debug": "^4.4.0",
|
|
120
120
|
"deterministic-object-hash": "^2.0.2",
|
|
121
121
|
"devalue": "^5.1.1",
|
|
122
122
|
"diff": "^5.2.0",
|
|
123
123
|
"dlv": "^1.1.3",
|
|
124
124
|
"dset": "^3.1.4",
|
|
125
|
-
"es-module-lexer": "^1.
|
|
126
|
-
"esbuild": "^0.
|
|
125
|
+
"es-module-lexer": "^1.6.0",
|
|
126
|
+
"esbuild": "^0.24.2",
|
|
127
127
|
"estree-walker": "^3.0.3",
|
|
128
|
-
"fast-glob": "^3.3.
|
|
128
|
+
"fast-glob": "^3.3.3",
|
|
129
129
|
"flattie": "^1.1.1",
|
|
130
130
|
"github-slugger": "^2.0.0",
|
|
131
131
|
"html-escaper": "^3.0.3",
|
|
132
132
|
"http-cache-semantics": "^4.1.1",
|
|
133
133
|
"js-yaml": "^4.1.0",
|
|
134
134
|
"kleur": "^4.1.5",
|
|
135
|
-
"magic-string": "^0.30.
|
|
135
|
+
"magic-string": "^0.30.17",
|
|
136
136
|
"magicast": "^0.3.5",
|
|
137
137
|
"micromatch": "^4.0.8",
|
|
138
138
|
"mrmime": "^2.0.0",
|
|
139
139
|
"neotraverse": "^0.6.18",
|
|
140
|
-
"p-limit": "^6.
|
|
140
|
+
"p-limit": "^6.2.0",
|
|
141
141
|
"p-queue": "^8.0.1",
|
|
142
142
|
"preferred-pm": "^4.0.0",
|
|
143
143
|
"prompts": "^2.4.2",
|
|
144
144
|
"rehype": "^13.0.2",
|
|
145
145
|
"semver": "^7.6.3",
|
|
146
|
-
"shiki": "^1.
|
|
147
|
-
"tinyexec": "^0.3.
|
|
146
|
+
"shiki": "^1.26.2",
|
|
147
|
+
"tinyexec": "^0.3.2",
|
|
148
148
|
"tsconfck": "^3.1.4",
|
|
149
149
|
"ultrahtml": "^1.5.3",
|
|
150
150
|
"unist-util-visit": "^5.0.0",
|
|
151
|
-
"unstorage": "^1.14.
|
|
151
|
+
"unstorage": "^1.14.4",
|
|
152
152
|
"vfile": "^6.0.3",
|
|
153
|
-
"vite": "^6.0.
|
|
154
|
-
"vitefu": "^1.0.
|
|
153
|
+
"vite": "^6.0.7",
|
|
154
|
+
"vitefu": "^1.0.5",
|
|
155
155
|
"which-pm": "^3.0.0",
|
|
156
156
|
"xxhash-wasm": "^1.1.0",
|
|
157
157
|
"yargs-parser": "^21.1.1",
|
|
158
|
-
"yocto-spinner": "^0.1.
|
|
159
|
-
"zod": "^3.
|
|
160
|
-
"zod-to-json-schema": "^3.
|
|
158
|
+
"yocto-spinner": "^0.1.2",
|
|
159
|
+
"zod": "^3.24.1",
|
|
160
|
+
"zod-to-json-schema": "^3.24.1",
|
|
161
161
|
"zod-to-ts": "^1.2.0",
|
|
162
162
|
"@astrojs/internal-helpers": "0.4.2",
|
|
163
|
-
"@astrojs/markdown-remark": "6.0.
|
|
163
|
+
"@astrojs/markdown-remark": "6.0.2",
|
|
164
164
|
"@astrojs/telemetry": "3.2.0"
|
|
165
165
|
},
|
|
166
166
|
"optionalDependencies": {
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
},
|
|
169
169
|
"devDependencies": {
|
|
170
170
|
"@astrojs/check": "^0.9.4",
|
|
171
|
-
"@playwright/test": "^1.49.
|
|
171
|
+
"@playwright/test": "^1.49.1",
|
|
172
172
|
"@types/aria-query": "^5.0.4",
|
|
173
173
|
"@types/common-ancestor-path": "^1.0.2",
|
|
174
174
|
"@types/cssesc": "^3.0.2",
|
|
@@ -189,18 +189,18 @@
|
|
|
189
189
|
"expect-type": "^1.1.0",
|
|
190
190
|
"fs-fixture": "^2.6.0",
|
|
191
191
|
"mdast-util-mdx": "^3.0.0",
|
|
192
|
-
"mdast-util-mdx-jsx": "^3.
|
|
193
|
-
"node-mocks-http": "^1.16.
|
|
192
|
+
"mdast-util-mdx-jsx": "^3.2.0",
|
|
193
|
+
"node-mocks-http": "^1.16.2",
|
|
194
194
|
"parse-srcset": "^1.0.2",
|
|
195
195
|
"rehype-autolink-headings": "^7.1.0",
|
|
196
196
|
"rehype-slug": "^6.0.0",
|
|
197
197
|
"rehype-toc": "^3.0.2",
|
|
198
198
|
"remark-code-titles": "^0.1.2",
|
|
199
|
-
"rollup": "^4.
|
|
200
|
-
"sass": "^1.
|
|
201
|
-
"undici": "^7.2.
|
|
199
|
+
"rollup": "^4.30.1",
|
|
200
|
+
"sass": "^1.83.1",
|
|
201
|
+
"undici": "^7.2.1",
|
|
202
202
|
"unified": "^11.0.5",
|
|
203
|
-
"vitest": "^3.0.0-beta.
|
|
203
|
+
"vitest": "^3.0.0-beta.4",
|
|
204
204
|
"astro-scripts": "0.0.14"
|
|
205
205
|
},
|
|
206
206
|
"engines": {
|