astro 4.3.3 → 4.3.5
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 -4
- package/dist/@types/astro.d.ts +1 -1
- package/dist/assets/services/vendor/squoosh/codecs.js +4 -0
- package/dist/cli/add/index.js +1 -1
- package/dist/content/utils.js +1 -1
- package/dist/core/build/css-asset-name.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +1 -1
- package/dist/core/build/static-build.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.js +2 -2
- package/dist/core/errors/dev/utils.js +9 -9
- package/dist/core/errors/errors-data.js +1 -1
- package/dist/core/logger/vite.js +4 -5
- package/dist/core/messages.js +3 -3
- package/dist/core/preview/vite-plugin-astro-preview.js +1 -1
- package/dist/core/routing/manifest/create.js +1 -1
- package/dist/events/error.js +2 -2
- package/dist/i18n/middleware.js +7 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/a11y.js +1 -1
- package/dist/runtime/server/render/component.js +3 -3
- package/dist/runtime/server/render/util.js +5 -5
- package/dist/vite-plugin-astro/compile.js +2 -2
- package/dist/vite-plugin-astro/hmr.js +1 -1
- package/dist/vite-plugin-astro/utils.d.ts +1 -0
- package/dist/vite-plugin-astro/utils.js +4 -0
- package/dist/vite-plugin-astro-server/route.js +3 -1
- package/dist/vite-plugin-env/index.js +1 -1
- package/dist/vite-plugin-head/index.js +1 -1
- package/dist/vite-plugin-html/transform/utils.js +2 -2
- package/dist/vite-plugin-scanner/scan.js +1 -1
- package/dist/vite-plugin-utils/index.js +1 -1
- package/package.json +6 -4
- package/types/content.d.ts +75 -0
- package/dist/virtual-modules/content.d.ts +0 -54
- package/dist/virtual-modules/content.js +0 -23
package/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="vite/types/import-meta.d.ts" />
|
|
2
|
+
/// <reference path="./types/content.d.ts" />
|
|
2
3
|
|
|
3
4
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
4
5
|
declare namespace App {
|
|
@@ -160,10 +161,6 @@ declare module 'astro:components' {
|
|
|
160
161
|
export * from 'astro/components';
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
declare module 'astro:content' {
|
|
164
|
-
export * from 'astro/virtual-modules/content.js';
|
|
165
|
-
}
|
|
166
|
-
|
|
167
164
|
type MD = import('./dist/@types/astro.js').MarkdownInstance<Record<string, any>>;
|
|
168
165
|
interface ExportedMarkdownModuleEntities {
|
|
169
166
|
frontmatter: MD['frontmatter'];
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -467,7 +467,7 @@ export interface AstroUserConfig {
|
|
|
467
467
|
*
|
|
468
468
|
* Specifies the output target for builds.
|
|
469
469
|
*
|
|
470
|
-
* - `'static'` - Building a static site to be
|
|
470
|
+
* - `'static'` - Building a static site to be deployed to any static host.
|
|
471
471
|
* - `'server'` - Building an app to be deployed to a host supporting SSR (server-side rendering).
|
|
472
472
|
* - `'hybrid'` - Building a static site with a few server-side rendered pages.
|
|
473
473
|
*
|
|
@@ -211,6 +211,8 @@ const codecs = {
|
|
|
211
211
|
avif: {
|
|
212
212
|
name: "AVIF",
|
|
213
213
|
extension: "avif",
|
|
214
|
+
// Disable eslint rule to not touch the original code
|
|
215
|
+
// eslint-disable-next-line no-control-regex, regexp/control-character-escape
|
|
214
216
|
detectors: [/^\x00\x00\x00 ftypavif\x00\x00\x00\x00/],
|
|
215
217
|
dec: () => instantiateEmscriptenWasm(avifDec, avifDecWasm),
|
|
216
218
|
enc: async () => {
|
|
@@ -240,6 +242,8 @@ const codecs = {
|
|
|
240
242
|
oxipng: {
|
|
241
243
|
name: "OxiPNG",
|
|
242
244
|
extension: "png",
|
|
245
|
+
// Disable eslint rule to not touch the original code
|
|
246
|
+
// eslint-disable-next-line no-control-regex, regexp/control-character-escape
|
|
243
247
|
detectors: [/^\x89PNG\x0D\x0A\x1A\x0A/],
|
|
244
248
|
dec: async () => {
|
|
245
249
|
await pngEncDecInit();
|
package/dist/cli/add/index.js
CHANGED
|
@@ -316,7 +316,7 @@ async function parseAstroConfig(configURL) {
|
|
|
316
316
|
return result;
|
|
317
317
|
}
|
|
318
318
|
const toIdent = (name) => {
|
|
319
|
-
const ident = name.trim().replace(/[-_
|
|
319
|
+
const ident = name.trim().replace(/[-_./]?astro(?:js)?[-_.]?/g, "").replace(/\.js/, "").replace(/[.\-_/]+([a-zA-Z])/g, (_, w) => w.toUpperCase()).replace(/^[^a-zA-Z$_]+/, "");
|
|
320
320
|
return `${ident[0].toLowerCase()}${ident.slice(1)}`;
|
|
321
321
|
};
|
|
322
322
|
function createPrettyError(err) {
|
package/dist/content/utils.js
CHANGED
|
@@ -71,7 +71,7 @@ async function getEntryData(entry, collectionConfig, pluginContext) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
let formattedError;
|
|
74
|
-
const parsed = await schema.safeParseAsync(
|
|
74
|
+
const parsed = await schema.safeParseAsync(data, {
|
|
75
75
|
errorMap(error, ctx) {
|
|
76
76
|
if (error.code === "custom" && error.params?.isHoistedAstroError) {
|
|
77
77
|
formattedError = error.params?.astroError;
|
|
@@ -70,7 +70,7 @@ function getFirstParentId(parents) {
|
|
|
70
70
|
}
|
|
71
71
|
return parents[0]?.[0].id;
|
|
72
72
|
}
|
|
73
|
-
const charsToReplaceRe = /[
|
|
73
|
+
const charsToReplaceRe = /[.[\]]/g;
|
|
74
74
|
const underscoresRe = /_+/g;
|
|
75
75
|
function prettifyBaseName(str) {
|
|
76
76
|
return str.replace(charsToReplaceRe, "_").replace(underscoresRe, "_");
|
|
@@ -10,7 +10,7 @@ import { getOutFile, getOutFolder } from "../common.js";
|
|
|
10
10
|
import { cssOrder, mergeInlineCss } from "../internal.js";
|
|
11
11
|
import { normalizeTheLocale } from "../../../i18n/index.js";
|
|
12
12
|
const manifestReplace = "@@ASTRO_MANIFEST_REPLACE@@";
|
|
13
|
-
const replaceExp = new RegExp(`['"]
|
|
13
|
+
const replaceExp = new RegExp(`['"]${manifestReplace}['"]`, "g");
|
|
14
14
|
const SSR_MANIFEST_VIRTUAL_MODULE_ID = "@astrojs-manifest";
|
|
15
15
|
const RESOLVED_SSR_MANIFEST_VIRTUAL_MODULE_ID = "\0" + SSR_MANIFEST_VIRTUAL_MODULE_ID;
|
|
16
16
|
function vitePluginManifest(options, internals) {
|
|
@@ -382,7 +382,7 @@ function makeAstroPageEntryPointFileName(prefix, facadeModuleId, routes) {
|
|
|
382
382
|
const pageModuleId = facadeModuleId.replace(prefix, "").replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, ".");
|
|
383
383
|
const route = routes.find((routeData) => routeData.component === pageModuleId);
|
|
384
384
|
const name = route?.route ?? pageModuleId;
|
|
385
|
-
return `pages${name.replace(/\/$/, "/index").replaceAll(/[
|
|
385
|
+
return `pages${name.replace(/\/$/, "/index").replaceAll(/[[\]]/g, "_").replaceAll("...", "---")}.astro.mjs`;
|
|
386
386
|
}
|
|
387
387
|
function makeSplitEntryPointFileName(facadeModuleId, routes) {
|
|
388
388
|
const filePath = `${makeAstroPageEntryPointFileName(
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -62,7 +62,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
62
62
|
// Attempt: package relies on `astro`. ✅ Definitely an Astro package
|
|
63
63
|
pkgJson.peerDependencies?.astro || pkgJson.dependencies?.astro || // Attempt: package is tagged with `astro` or `astro-component`. ✅ Likely a community package
|
|
64
64
|
pkgJson.keywords?.includes("astro") || pkgJson.keywords?.includes("astro-component") || // Attempt: package is named `astro-something` or `@scope/astro-something`. ✅ Likely a community package
|
|
65
|
-
/^(
|
|
65
|
+
/^(?:@[^/]+\/)?astro-/.test(pkgJson.name)
|
|
66
66
|
);
|
|
67
67
|
},
|
|
68
68
|
isFrameworkPkgByName(pkgName) {
|
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 = "4.3.
|
|
26
|
+
const currentVersion = "4.3.5";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
package/dist/core/dev/restart.js
CHANGED
|
@@ -19,8 +19,8 @@ async function createRestartedContainer(container, settings) {
|
|
|
19
19
|
await startContainer(newContainer);
|
|
20
20
|
return newContainer;
|
|
21
21
|
}
|
|
22
|
-
const configRE =
|
|
23
|
-
const preferencesRE =
|
|
22
|
+
const configRE = /.*astro.config.(?:mjs|cjs|js|ts)$/;
|
|
23
|
+
const preferencesRE = /.*\.astro\/settings.json$/;
|
|
24
24
|
function shouldRestartContainer({ settings, inlineConfig, restartInFlight }, changedFile) {
|
|
25
25
|
if (restartInFlight)
|
|
26
26
|
return false;
|
|
@@ -81,7 +81,7 @@ function collectErrorMetadata(e, rootFolder) {
|
|
|
81
81
|
}
|
|
82
82
|
function generateHint(err) {
|
|
83
83
|
const commonBrowserAPIs = ["document", "window"];
|
|
84
|
-
if (/Unknown file extension
|
|
84
|
+
if (/Unknown file extension "\.(?:jsx|vue|svelte|astro|css)" for /.test(err.message)) {
|
|
85
85
|
return "You likely need to add this package to `vite.ssr.noExternal` in your astro config file.";
|
|
86
86
|
} else if (commonBrowserAPIs.some((api) => err.toString().includes(api))) {
|
|
87
87
|
const hint = `Browser APIs are not available on the server.
|
|
@@ -107,8 +107,8 @@ function collectInfoFromStacktrace(error) {
|
|
|
107
107
|
const possibleFilePath = error.loc?.file || error.pluginCode || error.id || // TODO: this could be better, `src` might be something else
|
|
108
108
|
stackText.split("\n").find((ln) => ln.includes("src") || ln.includes("node_modules"));
|
|
109
109
|
const source = possibleFilePath?.replace(/^[^(]+\(([^)]+).*$/, "$1").replace(/^\s+at\s+/, "");
|
|
110
|
-
let file = source?.replace(
|
|
111
|
-
const location = /:(
|
|
110
|
+
let file = source?.replace(/:\d+/g, "");
|
|
111
|
+
const location = /:(\d+):(\d+)/.exec(source) ?? [];
|
|
112
112
|
const line = location[1];
|
|
113
113
|
const column = location[2];
|
|
114
114
|
if (file && line && column) {
|
|
@@ -124,13 +124,13 @@ function collectInfoFromStacktrace(error) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
if (!stackInfo.plugin) {
|
|
127
|
-
stackInfo.plugin = /withastro\/astro\/packages\/integrations\/([\w-]+)/
|
|
127
|
+
stackInfo.plugin = /withastro\/astro\/packages\/integrations\/([\w-]+)/i.exec(stackText)?.at(1) || /(@astrojs\/[\w-]+)\/(server|client|index)/i.exec(stackText)?.at(1) || void 0;
|
|
128
128
|
}
|
|
129
129
|
stackInfo.stack = cleanErrorStack(error.stack);
|
|
130
130
|
return stackInfo;
|
|
131
131
|
}
|
|
132
132
|
function cleanErrorStack(stack) {
|
|
133
|
-
return stack.split(/\n/
|
|
133
|
+
return stack.split(/\n/).map((l) => l.replace(/\/@fs\//g, "/")).join("\n");
|
|
134
134
|
}
|
|
135
135
|
function getDocsForError(err) {
|
|
136
136
|
if (err.name !== "UnknownError" && err.name in AstroErrorData) {
|
|
@@ -142,10 +142,10 @@ function getDocsForError(err) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
function renderErrorMarkdown(markdown, target) {
|
|
145
|
-
const linkRegex = /\[([
|
|
146
|
-
const boldRegex = /\*\*(.+)\*\*/
|
|
147
|
-
const urlRegex = / (
|
|
148
|
-
const codeRegex = /`([^`]+)`/
|
|
145
|
+
const linkRegex = /\[([^[]+)\]\((.*)\)/g;
|
|
146
|
+
const boldRegex = /\*\*(.+)\*\*/g;
|
|
147
|
+
const urlRegex = / ((?:https?|ftp):\/\/[-\w+&@#\\/%?=~|!:,.;]*[-\w+&@#\\/%=~|])/gi;
|
|
148
|
+
const codeRegex = /`([^`]+)`/g;
|
|
149
149
|
if (target === "html") {
|
|
150
150
|
return escape(markdown).replace(linkRegex, `<a href="$2" target="_blank">$1</a>`).replace(boldRegex, "<b>$1</b>").replace(urlRegex, ' <a href="$1" target="_blank">$1</a>').replace(codeRegex, "<code>$1</code>");
|
|
151
151
|
} else {
|
|
@@ -184,7 +184,7 @@ const PrerenderDynamicEndpointPathCollide = {
|
|
|
184
184
|
name: "PrerenderDynamicEndpointPathCollide",
|
|
185
185
|
title: "Prerendered dynamic endpoint has path collision.",
|
|
186
186
|
message: (pathname) => `Could not render \`${pathname}\` with an \`undefined\` param as the generated path will collide during prerendering. Prevent passing \`undefined\` as \`params\` for the endpoint's \`getStaticPaths()\` function, or add an additional extension to the endpoint's filename.`,
|
|
187
|
-
hint: (filename) => `Rename \`${filename}\` to \`${filename.replace(/\.(js|ts)/, (m) => `.json` + m)}\``
|
|
187
|
+
hint: (filename) => `Rename \`${filename}\` to \`${filename.replace(/\.(?:js|ts)/, (m) => `.json` + m)}\``
|
|
188
188
|
};
|
|
189
189
|
const ExpectedImage = {
|
|
190
190
|
name: "ExpectedImage",
|
package/dist/core/logger/vite.js
CHANGED
|
@@ -8,11 +8,11 @@ const E2E_PREFIX = fileURLToPath(new URL("../../../e2e", import.meta.url));
|
|
|
8
8
|
function isAstroSrcFile(id) {
|
|
9
9
|
return id?.startsWith(PKG_PREFIX) && !id.startsWith(E2E_PREFIX);
|
|
10
10
|
}
|
|
11
|
-
const vitePageReloadMsg = /page reload (.*)
|
|
11
|
+
const vitePageReloadMsg = /page reload (.*)/;
|
|
12
12
|
const viteHmrUpdateMsg = /hmr update (.*)/;
|
|
13
13
|
const viteBuildMsg = /vite.*building.*for production/;
|
|
14
|
-
const viteShortcutTitleMsg = /^\s*Shortcuts\s
|
|
15
|
-
const viteShortcutHelpMsg = /press
|
|
14
|
+
const viteShortcutTitleMsg = /^\s*Shortcuts\s*$/;
|
|
15
|
+
const viteShortcutHelpMsg = /press (.+?) to (.+)$/s;
|
|
16
16
|
function createViteLogger(astroLogger, viteLogLevel = "info") {
|
|
17
17
|
const warnedMessages = /* @__PURE__ */ new Set();
|
|
18
18
|
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
|
@@ -26,8 +26,7 @@ function createViteLogger(astroLogger, viteLogLevel = "info") {
|
|
|
26
26
|
if (m = vitePageReloadMsg.exec(stripped)) {
|
|
27
27
|
if (isAstroSrcFile(m[1]))
|
|
28
28
|
return;
|
|
29
|
-
|
|
30
|
-
astroLogger.info("watch", m[1] + extra);
|
|
29
|
+
astroLogger.info("watch", m[1]);
|
|
31
30
|
} else if (m = viteHmrUpdateMsg.exec(stripped)) {
|
|
32
31
|
if (isAstroSrcFile(m[1]))
|
|
33
32
|
return;
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.3.
|
|
39
|
+
const version = "4.3.5";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -180,7 +180,7 @@ ${errorList.join(
|
|
|
180
180
|
)}`;
|
|
181
181
|
}
|
|
182
182
|
const STACK_LINE_REGEXP = /^\s+at /g;
|
|
183
|
-
const IRRELEVANT_STACK_REGEXP = /
|
|
183
|
+
const IRRELEVANT_STACK_REGEXP = /node_modules|astro[/\\]dist/g;
|
|
184
184
|
function formatErrorStackTrace(err, showFullStacktrace) {
|
|
185
185
|
const stackLines = (err.stack || "").split("\n").filter((line) => STACK_LINE_REGEXP.test(line));
|
|
186
186
|
if (showFullStacktrace) {
|
|
@@ -261,7 +261,7 @@ function printHelp({
|
|
|
261
261
|
message.push(
|
|
262
262
|
linebreak(),
|
|
263
263
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
264
|
-
`v${"4.3.
|
|
264
|
+
`v${"4.3.5"}`
|
|
265
265
|
)} ${headline}`
|
|
266
266
|
);
|
|
267
267
|
}
|
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from "node:url";
|
|
|
3
3
|
import { notFoundTemplate, subpathNotUsedTemplate } from "../../template/4xx.js";
|
|
4
4
|
import { cleanUrl } from "../../vite-plugin-utils/index.js";
|
|
5
5
|
import { stripBase } from "./util.js";
|
|
6
|
-
const HAS_FILE_EXTENSION_REGEXP =
|
|
6
|
+
const HAS_FILE_EXTENSION_REGEXP = /\.[^/]+$/;
|
|
7
7
|
function vitePluginAstroPreview(settings) {
|
|
8
8
|
const { base, outDir, trailingSlash } = settings.config;
|
|
9
9
|
function handle404(req, res) {
|
|
@@ -26,7 +26,7 @@ function getParts(part, file) {
|
|
|
26
26
|
return;
|
|
27
27
|
const dynamic = i % 2 === 1;
|
|
28
28
|
const [, content] = dynamic ? /([^(]+)$/.exec(str) || [null, null] : [null, str];
|
|
29
|
-
if (!content || dynamic && !/^(
|
|
29
|
+
if (!content || dynamic && !/^(?:\.\.\.)?[\w$]+$/.test(content)) {
|
|
30
30
|
throw new Error(`Invalid route ${file} \u2014 parameter name must match /^[a-zA-Z0-9_$]+$/`);
|
|
31
31
|
}
|
|
32
32
|
result.push({
|
package/dist/events/error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
2
2
|
const EVENT_ERROR = "ASTRO_CLI_ERROR";
|
|
3
|
-
const ANONYMIZE_MESSAGE_REGEX = /^(
|
|
3
|
+
const ANONYMIZE_MESSAGE_REGEX = /^(?:\w| )+/;
|
|
4
4
|
function anonymizeErrorMessage(msg) {
|
|
5
5
|
const matchedMessage = msg.match(ANONYMIZE_MESSAGE_REGEX);
|
|
6
6
|
if (!matchedMessage?.[0]) {
|
|
@@ -48,7 +48,7 @@ function getSafeErrorMessage(message) {
|
|
|
48
48
|
function extractStringFromFunction(func) {
|
|
49
49
|
const arrowIndex = func.indexOf("=>") + "=>".length;
|
|
50
50
|
return func.slice(arrowIndex).trim().slice(1, -1).replace(
|
|
51
|
-
|
|
51
|
+
/\$\{([^}]+)\}/g,
|
|
52
52
|
(str, match1) => `${match1.split(/\.?(?=[A-Z])/).join("_").toUpperCase()}`
|
|
53
53
|
).replace(/\\`/g, "`");
|
|
54
54
|
}
|
package/dist/i18n/middleware.js
CHANGED
|
@@ -37,7 +37,13 @@ function createI18nMiddleware(i18n, base, trailingSlash, buildFormat) {
|
|
|
37
37
|
return void 0;
|
|
38
38
|
};
|
|
39
39
|
const prefixOtherLocales = (url, response) => {
|
|
40
|
-
|
|
40
|
+
let pathnameContainsDefaultLocale = false;
|
|
41
|
+
for (const segment of url.pathname.split("/")) {
|
|
42
|
+
if (normalizeTheLocale(segment) === normalizeTheLocale(i18n.defaultLocale)) {
|
|
43
|
+
pathnameContainsDefaultLocale = true;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
41
47
|
if (pathnameContainsDefaultLocale) {
|
|
42
48
|
const newLocation = url.pathname.replace(`/${i18n.defaultLocale}`, "");
|
|
43
49
|
response.headers.set("Location", newLocation);
|
|
@@ -221,7 +221,7 @@ const a11y = [
|
|
|
221
221
|
title: "Redundant text in alt attribute",
|
|
222
222
|
message: 'Screen readers already announce `img` elements as an image. There is no need to use words such as "image", "photo", and/or "picture".',
|
|
223
223
|
selector: "img[alt]:not([aria-hidden])",
|
|
224
|
-
match: (img) => /\b(image|picture|photo)\b/i.test(img.alt)
|
|
224
|
+
match: (img) => /\b(?:image|picture|photo)\b/i.test(img.alt)
|
|
225
225
|
},
|
|
226
226
|
{
|
|
227
227
|
code: "a11y-incorrect-aria-attribute-type",
|
|
@@ -47,8 +47,8 @@ function isFragmentComponent(Component) {
|
|
|
47
47
|
function isHTMLComponent(Component) {
|
|
48
48
|
return Component && Component["astro:html"] === true;
|
|
49
49
|
}
|
|
50
|
-
const ASTRO_SLOT_EXP =
|
|
51
|
-
const ASTRO_STATIC_SLOT_EXP =
|
|
50
|
+
const ASTRO_SLOT_EXP = /<\/?astro-slot\b[^>]*>/g;
|
|
51
|
+
const ASTRO_STATIC_SLOT_EXP = /<\/?astro-static-slot\b[^>]*>/g;
|
|
52
52
|
function removeStaticAstroSlot(html, supportsAstroStaticSlot) {
|
|
53
53
|
const exp = supportsAstroStaticSlot ? ASTRO_STATIC_SLOT_EXP : ASTRO_SLOT_EXP;
|
|
54
54
|
return html.replace(exp, "");
|
|
@@ -305,7 +305,7 @@ ${serializeProps(
|
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
function sanitizeElementName(tag) {
|
|
308
|
-
const unsafe = /[&<>'"\s]
|
|
308
|
+
const unsafe = /[&<>'"\s]+/;
|
|
309
309
|
if (!unsafe.test(tag))
|
|
310
310
|
return tag;
|
|
311
311
|
return tag.trim().split(unsafe)[0].trim();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
2
|
import { HTMLString, markHTMLString } from "../escape.js";
|
|
3
3
|
const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
|
|
4
|
-
const htmlBooleanAttributes = /^(allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
|
|
5
|
-
const htmlEnumAttributes = /^(contenteditable|draggable|spellcheck|value)$/i;
|
|
6
|
-
const svgEnumAttributes = /^(autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
|
|
4
|
+
const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
|
|
5
|
+
const htmlEnumAttributes = /^(?:contenteditable|draggable|spellcheck|value)$/i;
|
|
6
|
+
const svgEnumAttributes = /^(?:autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
|
|
7
7
|
const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
|
|
8
|
-
const toIdent = (k) => k.trim().replace(/(
|
|
9
|
-
if (
|
|
8
|
+
const toIdent = (k) => k.trim().replace(/(?!^)\b\w|\s+|\W+/g, (match, index) => {
|
|
9
|
+
if (/\W/.test(match))
|
|
10
10
|
return "";
|
|
11
11
|
return index === 0 ? match : match.toUpperCase();
|
|
12
12
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { transformWithEsbuild } from "vite";
|
|
2
2
|
import { compile } from "../core/compile/index.js";
|
|
3
3
|
import { getFileInfo } from "../vite-plugin-utils/index.js";
|
|
4
|
-
|
|
4
|
+
import { frontmatterRE } from "./utils.js";
|
|
5
5
|
async function compileAstro({
|
|
6
6
|
compileProps,
|
|
7
7
|
astroFileToCompileMetadata,
|
|
@@ -68,7 +68,7 @@ async function enhanceCompileError({
|
|
|
68
68
|
source
|
|
69
69
|
}) {
|
|
70
70
|
const lineText = err.loc?.lineText;
|
|
71
|
-
const scannedFrontmatter =
|
|
71
|
+
const scannedFrontmatter = frontmatterRE.exec(source);
|
|
72
72
|
if (scannedFrontmatter) {
|
|
73
73
|
const frontmatter = scannedFrontmatter[1].replace(/\breturn\b/g, "throw");
|
|
74
74
|
if (lineText && !frontmatter.includes(lineText))
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { appendForwardSlash } from "@astrojs/internal-helpers/path";
|
|
3
|
+
import { frontmatterRE } from "./utils.js";
|
|
3
4
|
async function handleHotUpdate(ctx, { logger, compile, astroFileToCssAstroDeps, astroFileToCompileMetadata }) {
|
|
4
5
|
const oldCode = astroFileToCompileMetadata.get(ctx.file)?.originalCode;
|
|
5
6
|
const newCode = await ctx.read();
|
|
@@ -21,7 +22,6 @@ async function handleHotUpdate(ctx, { logger, compile, astroFileToCssAstroDeps,
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
const frontmatterRE = /^\-\-\-.*?^\-\-\-/ms;
|
|
25
25
|
const scriptRE = /<script(?:\s.*?)?>.*?<\/script>/gs;
|
|
26
26
|
const styleRE = /<style(?:\s.*?)?>.*?<\/style>/gs;
|
|
27
27
|
function isStyleOnlyChanged(oldCode, newCode) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const frontmatterRE: RegExp;
|
|
@@ -64,7 +64,7 @@ async function matchRoute(pathname, manifestData, pipeline) {
|
|
|
64
64
|
throw e;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
const altPathname = pathname.replace(/(index)?\.html$/, "");
|
|
67
|
+
const altPathname = pathname.replace(/(?:index)?\.html$/, "");
|
|
68
68
|
if (altPathname !== pathname) {
|
|
69
69
|
return await matchRoute(altPathname, manifestData, pipeline);
|
|
70
70
|
}
|
|
@@ -159,6 +159,8 @@ async function handleRoute({
|
|
|
159
159
|
return "";
|
|
160
160
|
},
|
|
161
161
|
params: [],
|
|
162
|
+
// Disable eslint as we only want to generate an empty RegExp
|
|
163
|
+
// eslint-disable-next-line prefer-regex-literals
|
|
162
164
|
pattern: new RegExp(""),
|
|
163
165
|
prerender: false,
|
|
164
166
|
segments: [],
|
|
@@ -3,7 +3,7 @@ import { loadEnv } from "vite";
|
|
|
3
3
|
import { transform } from "esbuild";
|
|
4
4
|
import MagicString from "magic-string";
|
|
5
5
|
const importMetaEnvOnlyRe = /\bimport\.meta\.env\b(?!\.)/;
|
|
6
|
-
const isValidIdentifierRe = /^[_$a-zA-Z][
|
|
6
|
+
const isValidIdentifierRe = /^[_$a-zA-Z][\w$]*$/;
|
|
7
7
|
const exportConstPrerenderRe = /\bexport\s+const\s+prerender\s*=\s*import\.meta\.env\.(.+?)\b/;
|
|
8
8
|
function getPrivateEnv(viteConfig, astroConfig) {
|
|
9
9
|
let envPrefixes = ["PUBLIC_"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTopLevelPages, walkParentInfos } from "../core/build/graph.js";
|
|
2
2
|
import { getAstroMetadata } from "../vite-plugin-astro/index.js";
|
|
3
|
-
const injectExp = /(
|
|
3
|
+
const injectExp = /(?:^\/\/|\/\/!)\s*astro-head-inject/;
|
|
4
4
|
function configHeadVitePlugin() {
|
|
5
5
|
let server;
|
|
6
6
|
function propagateMetadata(id, prop, value, seen = /* @__PURE__ */ new Set()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const splitAttrsTokenizer = /([
|
|
1
|
+
const splitAttrsTokenizer = /([${}@\w:\-]*)\s*=\s*?(['"]?)(.*?)\2\s+/g;
|
|
2
2
|
function replaceAttribute(s, node, key, newValue) {
|
|
3
3
|
splitAttrsTokenizer.lastIndex = 0;
|
|
4
4
|
const text = s.original.slice(node.position?.start.offset ?? 0, node.position?.end.offset ?? 0).toString();
|
|
@@ -7,7 +7,7 @@ function replaceAttribute(s, node, key, newValue) {
|
|
|
7
7
|
return;
|
|
8
8
|
const start = node.position.start.offset + offset;
|
|
9
9
|
const tokens = text.slice(offset).split(splitAttrsTokenizer);
|
|
10
|
-
const token = tokens[0].replace(/([^>])
|
|
10
|
+
const token = tokens[0].replace(/([^>])>[\s\S]*$/gm, "$1");
|
|
11
11
|
if (token.trim() === key) {
|
|
12
12
|
const end = start + key.length;
|
|
13
13
|
return s.overwrite(start, end, newValue, { contentOnly: true });
|
|
@@ -37,7 +37,7 @@ async function scan(code, id, settings) {
|
|
|
37
37
|
const { n: name, le: endOfLocalName } = _export;
|
|
38
38
|
if (BOOLEAN_EXPORTS.has(name)) {
|
|
39
39
|
const prefix = code.slice(0, endOfLocalName).split("export").pop().trim().replace("prerender", "").trim();
|
|
40
|
-
const suffix = code.slice(endOfLocalName).trim().replace(
|
|
40
|
+
const suffix = code.slice(endOfLocalName).trim().replace(/=/, "").trim().split(/[;\n]/)[0];
|
|
41
41
|
if (prefix !== "const" || !(isTruthy(suffix) || isFalsy(suffix))) {
|
|
42
42
|
throw new AstroError({
|
|
43
43
|
...AstroErrorData.InvalidPrerenderExport,
|
|
@@ -11,7 +11,7 @@ function getFileInfo(id, config) {
|
|
|
11
11
|
config.site ? new URL(config.base, config.site).pathname : config.base
|
|
12
12
|
);
|
|
13
13
|
const fileId = id.split("?")[0];
|
|
14
|
-
let fileUrl = fileId.includes("/pages/") ? fileId.replace(/^.*?\/pages\//, sitePathname).replace(/(
|
|
14
|
+
let fileUrl = fileId.includes("/pages/") ? fileId.replace(/^.*?\/pages\//, sitePathname).replace(/(?:\/index)?\.(?:md|markdown|mdown|mkdn|mkd|mdwn|astro)$/, "") : void 0;
|
|
15
15
|
if (fileUrl && config.trailingSlash === "always") {
|
|
16
16
|
fileUrl = appendForwardSlash(fileUrl);
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.5",
|
|
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",
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"content-types.template.d.ts",
|
|
97
97
|
"content-module.template.mjs",
|
|
98
98
|
"astro-jsx.d.ts",
|
|
99
|
+
"types/content.d.ts",
|
|
99
100
|
"types.d.ts",
|
|
100
101
|
"README.md",
|
|
101
102
|
"vendor"
|
|
@@ -231,10 +232,11 @@
|
|
|
231
232
|
"dev": "astro-scripts dev --copy-wasm --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.{ts,js}\"",
|
|
232
233
|
"postbuild": "astro-scripts copy \"src/**/*.astro\" && astro-scripts copy \"src/**/*.wasm\"",
|
|
233
234
|
"test:unit": "mocha --exit --timeout 30000 ./test/units/**/*.test.js",
|
|
234
|
-
"test:unit:match": "mocha --exit --timeout 30000 ./test/units/**/*.test.js -g",
|
|
235
|
-
"test": "pnpm run test:unit && mocha --exit --timeout 30000 --ignore **/lit-element.test.js && mocha --timeout 30000 **/lit-element.test.js",
|
|
235
|
+
"test:unit:match": "mocha --exit --timeout 30000 ./test/units/**/*.test.js -g --ignore **/*.nodetest.js",
|
|
236
|
+
"test": "pnpm run test:node && pnpm run test:unit && mocha --exit --timeout 30000 --ignore **/*.nodetest.js --ignore **/lit-element.test.js && mocha --timeout 30000 **/lit-element.test.js --ignore **/*.nodetest.js",
|
|
236
237
|
"test:match": "mocha --timeout 30000 -g",
|
|
237
238
|
"test:e2e": "playwright test",
|
|
238
|
-
"test:e2e:match": "playwright test -g"
|
|
239
|
+
"test:e2e:match": "playwright test -g",
|
|
240
|
+
"test:node": "astro-scripts test \"test/**/*.nodetest.js\""
|
|
239
241
|
}
|
|
240
242
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
declare module 'astro:content' {
|
|
2
|
+
export { z } from 'astro/zod';
|
|
3
|
+
|
|
4
|
+
// This needs to be in sync with ImageMetadata
|
|
5
|
+
export type ImageFunction = () => import('astro/zod').ZodObject<{
|
|
6
|
+
src: import('astro/zod').ZodString;
|
|
7
|
+
width: import('astro/zod').ZodNumber;
|
|
8
|
+
height: import('astro/zod').ZodNumber;
|
|
9
|
+
format: import('astro/zod').ZodUnion<
|
|
10
|
+
[
|
|
11
|
+
import('astro/zod').ZodLiteral<'png'>,
|
|
12
|
+
import('astro/zod').ZodLiteral<'jpg'>,
|
|
13
|
+
import('astro/zod').ZodLiteral<'jpeg'>,
|
|
14
|
+
import('astro/zod').ZodLiteral<'tiff'>,
|
|
15
|
+
import('astro/zod').ZodLiteral<'webp'>,
|
|
16
|
+
import('astro/zod').ZodLiteral<'gif'>,
|
|
17
|
+
import('astro/zod').ZodLiteral<'svg'>,
|
|
18
|
+
import('astro/zod').ZodLiteral<'avif'>,
|
|
19
|
+
]
|
|
20
|
+
>;
|
|
21
|
+
}>;
|
|
22
|
+
|
|
23
|
+
type BaseSchemaWithoutEffects =
|
|
24
|
+
| import('astro/zod').AnyZodObject
|
|
25
|
+
| import('astro/zod').ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]>
|
|
26
|
+
| import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
|
|
27
|
+
| import('astro/zod').ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
|
|
28
|
+
|
|
29
|
+
type BaseSchema =
|
|
30
|
+
| BaseSchemaWithoutEffects
|
|
31
|
+
| import('astro/zod').ZodEffects<BaseSchemaWithoutEffects>;
|
|
32
|
+
|
|
33
|
+
export type SchemaContext = { image: ImageFunction };
|
|
34
|
+
|
|
35
|
+
type DataCollectionConfig<S extends BaseSchema> = {
|
|
36
|
+
type: 'data';
|
|
37
|
+
schema?: S | ((context: SchemaContext) => S);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type ContentCollectionConfig<S extends BaseSchema> = {
|
|
41
|
+
type?: 'content';
|
|
42
|
+
schema?: S | ((context: SchemaContext) => S);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type CollectionConfig<S extends BaseSchema> =
|
|
46
|
+
| ContentCollectionConfig<S>
|
|
47
|
+
| DataCollectionConfig<S>;
|
|
48
|
+
|
|
49
|
+
export function defineCollection<S extends BaseSchema>(
|
|
50
|
+
input: CollectionConfig<S>
|
|
51
|
+
): CollectionConfig<S>;
|
|
52
|
+
|
|
53
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
54
|
+
export const getEntryBySlug: (...args: any[]) => any;
|
|
55
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
56
|
+
export const getDataEntryById: (...args: any[]) => any;
|
|
57
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
58
|
+
export const getCollection: (...args: any[]) => any;
|
|
59
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
60
|
+
export const getEntry: (...args: any[]) => any;
|
|
61
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
62
|
+
export const getEntries: (...args: any[]) => any;
|
|
63
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
64
|
+
export const reference: (...args: any[]) => any;
|
|
65
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
66
|
+
export type CollectionKey = any;
|
|
67
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
68
|
+
export type CollectionEntry<C> = any;
|
|
69
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
70
|
+
export type ContentCollectionKey = any;
|
|
71
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
72
|
+
export type DataCollectionKey = any;
|
|
73
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
74
|
+
export type ContentConfig = any;
|
|
75
|
+
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export { z };
|
|
3
|
-
export type ImageFunction = () => z.ZodObject<{
|
|
4
|
-
src: z.ZodString;
|
|
5
|
-
width: z.ZodNumber;
|
|
6
|
-
height: z.ZodNumber;
|
|
7
|
-
format: z.ZodUnion<[
|
|
8
|
-
z.ZodLiteral<'png'>,
|
|
9
|
-
z.ZodLiteral<'jpg'>,
|
|
10
|
-
z.ZodLiteral<'jpeg'>,
|
|
11
|
-
z.ZodLiteral<'tiff'>,
|
|
12
|
-
z.ZodLiteral<'webp'>,
|
|
13
|
-
z.ZodLiteral<'gif'>,
|
|
14
|
-
z.ZodLiteral<'svg'>,
|
|
15
|
-
z.ZodLiteral<'avif'>
|
|
16
|
-
]>;
|
|
17
|
-
}>;
|
|
18
|
-
type BaseSchemaWithoutEffects = z.AnyZodObject | z.ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]> | z.ZodDiscriminatedUnion<string, z.AnyZodObject[]> | z.ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
|
|
19
|
-
type BaseSchema = BaseSchemaWithoutEffects | z.ZodEffects<BaseSchemaWithoutEffects>;
|
|
20
|
-
export type SchemaContext = {
|
|
21
|
-
image: ImageFunction;
|
|
22
|
-
};
|
|
23
|
-
type DataCollectionConfig<S extends BaseSchema> = {
|
|
24
|
-
type: 'data';
|
|
25
|
-
schema?: S | ((context: SchemaContext) => S);
|
|
26
|
-
};
|
|
27
|
-
type ContentCollectionConfig<S extends BaseSchema> = {
|
|
28
|
-
type?: 'content';
|
|
29
|
-
schema?: S | ((context: SchemaContext) => S);
|
|
30
|
-
};
|
|
31
|
-
type CollectionConfig<S extends BaseSchema> = ContentCollectionConfig<S> | DataCollectionConfig<S>;
|
|
32
|
-
export declare function defineCollection<S extends BaseSchema>(input: CollectionConfig<S>): CollectionConfig<S>;
|
|
33
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
34
|
-
export declare const getEntryBySlug: (...args: any[]) => any;
|
|
35
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
36
|
-
export declare const getDataEntryById: (...args: any[]) => any;
|
|
37
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
38
|
-
export declare const getCollection: (...args: any[]) => any;
|
|
39
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
40
|
-
export declare const getEntry: (...args: any[]) => any;
|
|
41
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
42
|
-
export declare const getEntries: (...args: any[]) => any;
|
|
43
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
44
|
-
export declare const reference: (...args: any[]) => any;
|
|
45
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
46
|
-
export type CollectionKey = any;
|
|
47
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
48
|
-
export type CollectionEntry<C> = any;
|
|
49
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
50
|
-
export type ContentCollectionKey = any;
|
|
51
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
52
|
-
export type DataCollectionKey = any;
|
|
53
|
-
/** Run `astro sync` to generate high fidelity types */
|
|
54
|
-
export type ContentConfig = any;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineCollection as _defineCollection } from "../content/runtime.js";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
function defineCollection(input) {
|
|
4
|
-
return _defineCollection(input);
|
|
5
|
-
}
|
|
6
|
-
const noop = () => {
|
|
7
|
-
};
|
|
8
|
-
const getEntryBySlug = noop;
|
|
9
|
-
const getDataEntryById = noop;
|
|
10
|
-
const getCollection = noop;
|
|
11
|
-
const getEntry = noop;
|
|
12
|
-
const getEntries = noop;
|
|
13
|
-
const reference = noop;
|
|
14
|
-
export {
|
|
15
|
-
defineCollection,
|
|
16
|
-
getCollection,
|
|
17
|
-
getDataEntryById,
|
|
18
|
-
getEntries,
|
|
19
|
-
getEntry,
|
|
20
|
-
getEntryBySlug,
|
|
21
|
-
reference,
|
|
22
|
-
z
|
|
23
|
-
};
|