astro 2.10.0 → 2.10.2
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/components/ViewTransitions.astro +8 -3
- package/dist/@types/astro.d.ts +8 -4
- package/dist/content/types-generator.js +1 -1
- package/dist/content/vite-plugin-content-imports.js +2 -1
- package/dist/core/app/index.js +14 -10
- package/dist/core/build/static-build.js +3 -14
- package/dist/core/compile/compile.js +1 -0
- package/dist/core/compile/style.js +1 -0
- package/dist/core/config/config.d.ts +6 -0
- package/dist/core/config/config.js +3 -0
- package/dist/core/config/settings.js +1 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/vite.js +10 -10
- package/dist/core/errors/errors-data.d.ts +1048 -962
- package/dist/core/errors/errors-data.js +446 -996
- package/dist/core/errors/errors.d.ts +1 -1
- package/dist/core/errors/errors.js +1 -11
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/index.js +1 -1
- package/dist/core/errors/utils.d.ts +0 -5
- package/dist/core/errors/utils.js +0 -11
- package/dist/core/messages.js +2 -2
- package/dist/core/util.js +3 -2
- package/dist/jsx/babel.js +1 -1
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +2 -1
- package/dist/template/4xx.js +27 -5
- package/dist/transitions/vite-plugin-transitions.js +1 -0
- package/dist/vite-plugin-astro-server/request.js +2 -2
- package/dist/vite-plugin-integrations-container/index.js +13 -0
- package/dist/vite-plugin-markdown/index.js +1 -0
- package/package.json +2 -2
|
@@ -168,13 +168,18 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
168
168
|
|
|
169
169
|
// Trigger the animations
|
|
170
170
|
document.documentElement.dataset.astroTransitionFallback = 'old';
|
|
171
|
-
|
|
171
|
+
const fallbackSwap = () => {
|
|
172
|
+
removeEventListener('animationend', fallbackSwap);
|
|
173
|
+
clearTimeout(timeout);
|
|
174
|
+
swap();
|
|
175
|
+
document.documentElement.dataset.astroTransitionFallback = 'new';
|
|
176
|
+
};
|
|
172
177
|
// If there are any animations, want for the animationend event.
|
|
173
|
-
addEventListener('animationend',
|
|
178
|
+
addEventListener('animationend', fallbackSwap, { once: true });
|
|
174
179
|
// If there are no animations, go ahead and swap on next tick
|
|
175
180
|
// This is necessary because we do not know if there are animations.
|
|
176
181
|
// The setTimeout is a fallback in case there are none.
|
|
177
|
-
setTimeout(() => !isAnimating &&
|
|
182
|
+
let timeout = setTimeout(() => !isAnimating && fallbackSwap());
|
|
178
183
|
} else {
|
|
179
184
|
swap();
|
|
180
185
|
}
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1216,15 +1216,18 @@ export interface AstroUserConfig {
|
|
|
1216
1216
|
* - "page-ssr": Injected into the frontmatter of every Astro page. Processed & resolved by Vite.
|
|
1217
1217
|
*/
|
|
1218
1218
|
export type InjectedScriptStage = 'before-hydration' | 'head-inline' | 'page' | 'page-ssr';
|
|
1219
|
-
/**
|
|
1220
|
-
* Resolved Astro Config
|
|
1221
|
-
* Config with user settings along with all defaults filled in.
|
|
1222
|
-
*/
|
|
1223
1219
|
export interface InjectedRoute {
|
|
1224
1220
|
pattern: string;
|
|
1225
1221
|
entryPoint: string;
|
|
1226
1222
|
prerender?: boolean;
|
|
1227
1223
|
}
|
|
1224
|
+
export interface ResolvedInjectedRoute extends InjectedRoute {
|
|
1225
|
+
resolvedEntryPoint?: URL;
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Resolved Astro Config
|
|
1229
|
+
* Config with user settings along with all defaults filled in.
|
|
1230
|
+
*/
|
|
1228
1231
|
export interface AstroConfig extends z.output<typeof AstroConfigSchema> {
|
|
1229
1232
|
integrations: AstroIntegration[];
|
|
1230
1233
|
}
|
|
@@ -1304,6 +1307,7 @@ export interface AstroSettings {
|
|
|
1304
1307
|
config: AstroConfig;
|
|
1305
1308
|
adapter: AstroAdapter | undefined;
|
|
1306
1309
|
injectedRoutes: InjectedRoute[];
|
|
1310
|
+
resolvedInjectedRoutes: ResolvedInjectedRoute[];
|
|
1307
1311
|
pageExtensions: string[];
|
|
1308
1312
|
contentEntryTypes: ContentEntryType[];
|
|
1309
1313
|
dataEntryTypes: DataEntryType[];
|
|
@@ -3,8 +3,8 @@ import { cyan } from "kleur/colors";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
|
-
import { AstroErrorData } from "../core/errors/errors-data.js";
|
|
7
6
|
import { AstroError } from "../core/errors/errors.js";
|
|
7
|
+
import { AstroErrorData } from "../core/errors/index.js";
|
|
8
8
|
import { info, warn } from "../core/logger/core.js";
|
|
9
9
|
import { isRelativePath } from "../core/path.js";
|
|
10
10
|
import { CONTENT_TYPES_FILE, VIRTUAL_MODULE_ID } from "./consts.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as devalue from "devalue";
|
|
2
2
|
import { extname } from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
|
-
import { AstroErrorData } from "../core/errors/errors-data.js";
|
|
5
4
|
import { AstroError } from "../core/errors/errors.js";
|
|
5
|
+
import { AstroErrorData } from "../core/errors/index.js";
|
|
6
6
|
import { escapeViteEnvReferences } from "../vite-plugin-utils/index.js";
|
|
7
7
|
import { CONTENT_FLAG, DATA_FLAG } from "./consts.js";
|
|
8
8
|
import {
|
|
@@ -277,6 +277,7 @@ function stringifyEntryData(data) {
|
|
|
277
277
|
});
|
|
278
278
|
} else {
|
|
279
279
|
throw new AstroError({
|
|
280
|
+
name: "PluginContentImportsError",
|
|
280
281
|
message: "Unexpected error processing content collection data."
|
|
281
282
|
});
|
|
282
283
|
}
|
package/dist/core/app/index.js
CHANGED
|
@@ -2,7 +2,11 @@ import mime from "mime";
|
|
|
2
2
|
import { attachToResponse, getSetCookiesFromResponse } from "../cookies/index.js";
|
|
3
3
|
import { consoleLogDestination } from "../logger/console.js";
|
|
4
4
|
import { error } from "../logger/core.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
collapseDuplicateSlashes,
|
|
7
|
+
prependForwardSlash,
|
|
8
|
+
removeTrailingForwardSlash
|
|
9
|
+
} from "../path.js";
|
|
6
10
|
import { RedirectSinglePageBuiltModule } from "../redirects/index.js";
|
|
7
11
|
import { isResponse } from "../render/core.js";
|
|
8
12
|
import {
|
|
@@ -98,18 +102,21 @@ class App {
|
|
|
98
102
|
const url = new URL(request.url);
|
|
99
103
|
if (this.#manifest.assets.has(url.pathname))
|
|
100
104
|
return void 0;
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
const pathname = prependForwardSlash(this.removeBase(url.pathname));
|
|
106
|
+
const routeData = matchRoute(pathname, this.#manifestData);
|
|
103
107
|
if (!routeData || routeData.prerender)
|
|
104
108
|
return void 0;
|
|
105
109
|
return routeData;
|
|
106
110
|
}
|
|
107
111
|
async render(request, routeData, locals) {
|
|
112
|
+
if (request.url !== collapseDuplicateSlashes(request.url)) {
|
|
113
|
+
request = new Request(collapseDuplicateSlashes(request.url), request);
|
|
114
|
+
}
|
|
108
115
|
if (!routeData) {
|
|
109
116
|
routeData = this.match(request);
|
|
110
117
|
}
|
|
111
118
|
if (!routeData) {
|
|
112
|
-
return this.#renderError(request, {
|
|
119
|
+
return this.#renderError(request, { status: 404 });
|
|
113
120
|
}
|
|
114
121
|
Reflect.set(request, clientLocalsSymbol, locals ?? {});
|
|
115
122
|
const defaultStatus = this.#getDefaultStatusCode(routeData.route);
|
|
@@ -134,12 +141,11 @@ class App {
|
|
|
134
141
|
);
|
|
135
142
|
} catch (err) {
|
|
136
143
|
error(this.#logging, "ssr", err.stack || err.message || String(err));
|
|
137
|
-
return this.#renderError(request, {
|
|
144
|
+
return this.#renderError(request, { status: 500 });
|
|
138
145
|
}
|
|
139
146
|
if (isResponse(response, routeData.type)) {
|
|
140
147
|
if (STATUS_CODES.has(response.status)) {
|
|
141
148
|
return this.#renderError(request, {
|
|
142
|
-
routeData,
|
|
143
149
|
response,
|
|
144
150
|
status: response.status
|
|
145
151
|
});
|
|
@@ -150,7 +156,6 @@ class App {
|
|
|
150
156
|
if (response.type === "response") {
|
|
151
157
|
if (response.response.headers.get("X-Astro-Response") === "Not-Found") {
|
|
152
158
|
return this.#renderError(request, {
|
|
153
|
-
routeData,
|
|
154
159
|
response: response.response,
|
|
155
160
|
status: 404
|
|
156
161
|
});
|
|
@@ -232,7 +237,7 @@ class App {
|
|
|
232
237
|
* If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro).
|
|
233
238
|
* This also handles pre-rendered /404 or /500 routes
|
|
234
239
|
*/
|
|
235
|
-
async #renderError(request, {
|
|
240
|
+
async #renderError(request, { status, response: originalResponse }) {
|
|
236
241
|
const errorRouteData = matchRoute("/" + status, this.#manifestData);
|
|
237
242
|
const url = new URL(request.url);
|
|
238
243
|
if (errorRouteData) {
|
|
@@ -241,13 +246,12 @@ class App {
|
|
|
241
246
|
const response2 = await fetch(statusURL.toString());
|
|
242
247
|
return this.#mergeResponses(response2, originalResponse);
|
|
243
248
|
}
|
|
244
|
-
const finalRouteData = routeData ?? errorRouteData;
|
|
245
249
|
const mod = await this.#getModuleForRoute(errorRouteData);
|
|
246
250
|
try {
|
|
247
251
|
const newRenderContext = await this.#createRenderContext(
|
|
248
252
|
url,
|
|
249
253
|
request,
|
|
250
|
-
|
|
254
|
+
errorRouteData,
|
|
251
255
|
mod,
|
|
252
256
|
status
|
|
253
257
|
);
|
|
@@ -328,20 +328,9 @@ async function ssrMoveAssets(opts) {
|
|
|
328
328
|
}
|
|
329
329
|
function makeAstroPageEntryPointFileName(prefix, facadeModuleId, routes) {
|
|
330
330
|
const pageModuleId = facadeModuleId.replace(prefix, "").replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".");
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
let name = pageModuleId;
|
|
335
|
-
if (route) {
|
|
336
|
-
name = route.route;
|
|
337
|
-
}
|
|
338
|
-
if (name.endsWith("/"))
|
|
339
|
-
name += "index";
|
|
340
|
-
const fileName = `${name.replaceAll("[", "_").replaceAll("]", "_").replaceAll("...", "---")}.mjs`;
|
|
341
|
-
if (name.startsWith("..")) {
|
|
342
|
-
return `pages${fileName}`;
|
|
343
|
-
}
|
|
344
|
-
return fileName;
|
|
331
|
+
const route = routes.find((routeData) => routeData.component === pageModuleId);
|
|
332
|
+
const name = (route == null ? void 0 : route.route) ?? pageModuleId;
|
|
333
|
+
return `pages${name.replace(/\/$/, "/index").replaceAll(/[\[\]]/g, "_").replaceAll("...", "---")}.astro.mjs`;
|
|
345
334
|
}
|
|
346
335
|
function makeSplitEntryPointFileName(facadeModuleId, routes) {
|
|
347
336
|
const filePath = `${makeAstroPageEntryPointFileName(
|
|
@@ -58,6 +58,7 @@ function handleCompileResultErrors(result, cssTransformErrors) {
|
|
|
58
58
|
const compilerError = result.diagnostics.find((diag) => diag.severity === 1);
|
|
59
59
|
if (compilerError) {
|
|
60
60
|
throw new CompilerError({
|
|
61
|
+
name: "CompilerError",
|
|
61
62
|
message: compilerError.text,
|
|
62
63
|
location: {
|
|
63
64
|
line: compilerError.location.line,
|
|
@@ -20,5 +20,11 @@ interface ResolveConfigResult {
|
|
|
20
20
|
userConfig: AstroUserConfig;
|
|
21
21
|
astroConfig: AstroConfig;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the Astro config with a given inline config.
|
|
25
|
+
*
|
|
26
|
+
* @param inlineConfig An inline config that takes highest priority when merging and resolving the final config.
|
|
27
|
+
* @param command The running command that uses this config. Usually 'dev' or 'build'.
|
|
28
|
+
*/
|
|
23
29
|
export declare function resolveConfig(inlineConfig: AstroInlineConfig, command: string, fsMod?: typeof fs): Promise<ResolveConfigResult>;
|
|
24
30
|
export {};
|
|
@@ -163,6 +163,9 @@ function splitInlineConfig(inlineConfig) {
|
|
|
163
163
|
async function resolveConfig(inlineConfig, command, fsMod = fs) {
|
|
164
164
|
const root = resolveRoot(inlineConfig.root);
|
|
165
165
|
const { inlineUserConfig, inlineOnlyConfig } = splitInlineConfig(inlineConfig);
|
|
166
|
+
if (inlineConfig.root) {
|
|
167
|
+
inlineUserConfig.root = root;
|
|
168
|
+
}
|
|
166
169
|
const userConfig = await loadConfig(root, inlineOnlyConfig.configFile, fsMod);
|
|
167
170
|
const mergedConfig = mergeConfig(userConfig, inlineUserConfig);
|
|
168
171
|
const astroConfig = await validateConfig(mergedConfig, root, command);
|
|
@@ -18,6 +18,7 @@ function createBaseSettings(config) {
|
|
|
18
18
|
tsConfigPath: void 0,
|
|
19
19
|
adapter: void 0,
|
|
20
20
|
injectedRoutes: [],
|
|
21
|
+
resolvedInjectedRoutes: [],
|
|
21
22
|
pageExtensions: [".astro", ".html", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
|
|
22
23
|
contentEntryTypes: [markdownContentEntryType],
|
|
23
24
|
dataEntryTypes: [
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
23
23
|
base: restart.container.settings.config.base
|
|
24
24
|
})
|
|
25
25
|
);
|
|
26
|
-
const currentVersion = "2.10.
|
|
26
|
+
const currentVersion = "2.10.2";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
warn(logging, null, msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { getHighlighter } from "shiki";
|
|
4
|
-
import {
|
|
4
|
+
import { FailedToLoadModuleSSR, InvalidGlob, MdxIntegrationMissingError } from "../errors-data.js";
|
|
5
5
|
import { AstroError } from "../errors.js";
|
|
6
6
|
import { createSafeError } from "../utils.js";
|
|
7
7
|
import { renderErrorMarkdown } from "./utils.js";
|
|
@@ -25,10 +25,10 @@ function enhanceViteSSRError({
|
|
|
25
25
|
const lns = content.split("\n");
|
|
26
26
|
let importName;
|
|
27
27
|
if (importName = (_a = safeError.message.match(/Failed to load url (.*?) \(resolved id:/)) == null ? void 0 : _a[1]) {
|
|
28
|
-
safeError.title =
|
|
28
|
+
safeError.title = FailedToLoadModuleSSR.title;
|
|
29
29
|
safeError.name = "FailedToLoadModuleSSR";
|
|
30
|
-
safeError.message =
|
|
31
|
-
safeError.hint =
|
|
30
|
+
safeError.message = FailedToLoadModuleSSR.message(importName);
|
|
31
|
+
safeError.hint = FailedToLoadModuleSSR.hint;
|
|
32
32
|
const line = lns.findIndex((ln) => ln.includes(importName));
|
|
33
33
|
if (line !== -1) {
|
|
34
34
|
const column = (_b = lns[line]) == null ? void 0 : _b.indexOf(importName);
|
|
@@ -42,8 +42,8 @@ function enhanceViteSSRError({
|
|
|
42
42
|
const fileId = safeError.id ?? ((_c = safeError.loc) == null ? void 0 : _c.file);
|
|
43
43
|
if (!(renderers == null ? void 0 : renderers.find((r) => r.name === "@astrojs/mdx")) && safeError.message.match(/Syntax error/) && (fileId == null ? void 0 : fileId.match(/\.mdx$/))) {
|
|
44
44
|
safeError = new AstroError({
|
|
45
|
-
...
|
|
46
|
-
message:
|
|
45
|
+
...MdxIntegrationMissingError,
|
|
46
|
+
message: MdxIntegrationMissingError.message(JSON.stringify(fileId)),
|
|
47
47
|
location: safeError.loc,
|
|
48
48
|
stack: safeError.stack
|
|
49
49
|
});
|
|
@@ -51,10 +51,10 @@ function enhanceViteSSRError({
|
|
|
51
51
|
if (/Invalid glob/.test(safeError.message)) {
|
|
52
52
|
const globPattern = (_d = safeError.message.match(/glob: "(.+)" \(/)) == null ? void 0 : _d[1];
|
|
53
53
|
if (globPattern) {
|
|
54
|
-
safeError.message =
|
|
54
|
+
safeError.message = InvalidGlob.message(globPattern);
|
|
55
55
|
safeError.name = "InvalidGlob";
|
|
56
|
-
safeError.hint =
|
|
57
|
-
safeError.title =
|
|
56
|
+
safeError.hint = InvalidGlob.hint;
|
|
57
|
+
safeError.title = InvalidGlob.title;
|
|
58
58
|
const line = lns.findIndex((ln) => ln.includes(globPattern));
|
|
59
59
|
if (line !== -1) {
|
|
60
60
|
const column = (_e = lns[line]) == null ? void 0 : _e.indexOf(globPattern);
|
|
@@ -79,7 +79,7 @@ async function getViteErrorPayload(err) {
|
|
|
79
79
|
}
|
|
80
80
|
const message = renderErrorMarkdown(err.message.trim(), "html");
|
|
81
81
|
const hint = err.hint ? renderErrorMarkdown(err.hint.trim(), "html") : void 0;
|
|
82
|
-
const hasDocs = err.name
|
|
82
|
+
const hasDocs = !!err.name;
|
|
83
83
|
const docslink = hasDocs ? `https://docs.astro.build/en/reference/errors/${getKebabErrorName(err.name)}/` : void 0;
|
|
84
84
|
const highlighter = await getHighlighter({ theme: "css-variables" });
|
|
85
85
|
let highlighterLang = (_b = (_a = err.loc) == null ? void 0 : _a.file) == null ? void 0 : _b.split(".").pop();
|