astro 4.2.0 → 4.2.1
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/cli/preferences/index.js +1 -4
- package/dist/core/build/generate.js +1 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/logger/node.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/routing/manifest/create.js +24 -17
- package/dist/i18n/middleware.js +0 -1
- package/dist/runtime/server/render/util.js +1 -1
- package/package.json +3 -3
|
@@ -5,10 +5,7 @@ import { resolveConfig } from "../../core/config/config.js";
|
|
|
5
5
|
import { createSettings } from "../../core/config/settings.js";
|
|
6
6
|
import * as msg from "../../core/messages.js";
|
|
7
7
|
import { DEFAULT_PREFERENCES } from "../../preferences/defaults.js";
|
|
8
|
-
import {
|
|
9
|
-
coerce,
|
|
10
|
-
isValidKey
|
|
11
|
-
} from "../../preferences/index.js";
|
|
8
|
+
import { coerce, isValidKey } from "../../preferences/index.js";
|
|
12
9
|
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
|
|
13
10
|
import { flattie } from "flattie";
|
|
14
11
|
import { formatWithOptions } from "node:util";
|
|
@@ -344,9 +344,8 @@ function getUrlForPath(pathname, base, origin, format, routeType) {
|
|
|
344
344
|
return url;
|
|
345
345
|
}
|
|
346
346
|
async function generatePath(pathname, pipeline, gopts, route) {
|
|
347
|
-
const { mod, scripts: hoistedScripts, styles: _styles
|
|
347
|
+
const { mod, scripts: hoistedScripts, styles: _styles } = gopts;
|
|
348
348
|
const manifest = pipeline.getManifest();
|
|
349
|
-
const logger = pipeline.getLogger();
|
|
350
349
|
pipeline.getEnvironment().logger.debug("build", `Generating: ${pathname}`);
|
|
351
350
|
const links = /* @__PURE__ */ new Set();
|
|
352
351
|
const scripts = createModuleScriptsSet(
|
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 = "4.2.
|
|
26
|
+
const currentVersion = "4.2.1";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
package/dist/core/logger/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import debugPackage from "debug";
|
|
2
2
|
import { getEventPrefix, levels } from "./core.js";
|
|
3
3
|
const nodeLogDestination = {
|
|
4
|
-
write(event
|
|
4
|
+
write(event) {
|
|
5
5
|
let dest = process.stderr;
|
|
6
6
|
if (levels[event.level] < levels["error"]) {
|
|
7
7
|
dest = process.stdout;
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.2.
|
|
39
|
+
const version = "4.2.1";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -258,7 +258,7 @@ function printHelp({
|
|
|
258
258
|
message.push(
|
|
259
259
|
linebreak(),
|
|
260
260
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
261
|
-
`v${"4.2.
|
|
261
|
+
`v${"4.2.1"}`
|
|
262
262
|
)} ${headline}`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -83,9 +83,26 @@ function validateSegment(segment, file = "") {
|
|
|
83
83
|
throw new Error(`Invalid route ${file} \u2014 rest parameter must be a standalone segment`);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
function isSemanticallyEqualSegment(segmentA, segmentB) {
|
|
87
|
+
if (segmentA.length !== segmentB.length) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
for (const [index, partA] of segmentA.entries()) {
|
|
91
|
+
const partB = segmentB[index];
|
|
92
|
+
if (partA.dynamic !== partB.dynamic || partA.spread !== partB.spread) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (!partA.dynamic && partA.content !== partB.content) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
86
101
|
function routeComparator(a, b) {
|
|
87
|
-
|
|
88
|
-
|
|
102
|
+
const aLength = a.isIndex ? a.segments.length + 1 : a.segments.length;
|
|
103
|
+
const bLength = b.isIndex ? b.segments.length + 1 : b.segments.length;
|
|
104
|
+
if (aLength !== bLength) {
|
|
105
|
+
return aLength > bLength ? -1 : 1;
|
|
89
106
|
}
|
|
90
107
|
const aIsStatic = a.segments.every(
|
|
91
108
|
(segment) => segment.every((part) => !part.dynamic && !part.spread)
|
|
@@ -203,6 +220,7 @@ function createFileBasedRoutes({ settings, cwd, fsMod }, logger) {
|
|
|
203
220
|
const route = `/${segments.map(([{ dynamic, content }]) => dynamic ? `[${content}]` : content).join("/")}`.toLowerCase();
|
|
204
221
|
routes.push({
|
|
205
222
|
route,
|
|
223
|
+
isIndex: item.isIndex,
|
|
206
224
|
type: item.isPage ? "page" : "endpoint",
|
|
207
225
|
pattern,
|
|
208
226
|
segments,
|
|
@@ -257,6 +275,8 @@ function createInjectedRoutes({ settings, cwd }) {
|
|
|
257
275
|
const route = `/${segments.map(([{ dynamic, content }]) => dynamic ? `[${content}]` : content).join("/")}`.toLowerCase();
|
|
258
276
|
routes[priority].push({
|
|
259
277
|
type,
|
|
278
|
+
// For backwards compatibility, an injected route is never considered an index route.
|
|
279
|
+
isIndex: false,
|
|
260
280
|
route,
|
|
261
281
|
pattern,
|
|
262
282
|
segments,
|
|
@@ -302,6 +322,8 @@ function createRedirectRoutes({ settings }, routeMap, logger) {
|
|
|
302
322
|
}
|
|
303
323
|
routes[priority].push({
|
|
304
324
|
type: "redirect",
|
|
325
|
+
// For backwards compatibility, a redirect is never considered an index route.
|
|
326
|
+
isIndex: false,
|
|
305
327
|
route,
|
|
306
328
|
pattern,
|
|
307
329
|
segments,
|
|
@@ -320,21 +342,6 @@ function createRedirectRoutes({ settings }, routeMap, logger) {
|
|
|
320
342
|
function isStaticSegment(segment) {
|
|
321
343
|
return segment.every((part) => !part.dynamic && !part.spread);
|
|
322
344
|
}
|
|
323
|
-
function isSemanticallyEqualSegment(segmentA, segmentB) {
|
|
324
|
-
if (segmentA.length !== segmentB.length) {
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
for (const [index, partA] of segmentA.entries()) {
|
|
328
|
-
const partB = segmentB[index];
|
|
329
|
-
if (partA.dynamic !== partB.dynamic || partA.spread !== partB.spread) {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
if (!partA.dynamic && partA.content !== partB.content) {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return true;
|
|
337
|
-
}
|
|
338
345
|
function detectRouteCollision(a, b, config, logger) {
|
|
339
346
|
if (a.type === "fallback" || b.type === "fallback") {
|
|
340
347
|
return;
|
package/dist/i18n/middleware.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { appendForwardSlash, joinPaths } from "@astrojs/internal-helpers/path";
|
|
2
2
|
import { getPathByLocale, normalizeTheLocale } from "./index.js";
|
|
3
|
-
import { shouldAppendForwardSlash } from "../core/build/util.js";
|
|
4
3
|
const routeDataSymbol = Symbol.for("astro.routeData");
|
|
5
4
|
function pathnameHasLocale(pathname, locales) {
|
|
6
5
|
const segments = pathname.split("/");
|
|
@@ -12,7 +12,7 @@ const toIdent = (k) => k.trim().replace(/(?:(?!^)\b\w|\s+|[^\w]+)/g, (match, ind
|
|
|
12
12
|
});
|
|
13
13
|
const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(/&/g, "&").replace(/"/g, """) : value;
|
|
14
14
|
const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
15
|
-
const toStyleString = (obj) => Object.entries(obj).filter(([
|
|
15
|
+
const toStyleString = (obj) => Object.entries(obj).filter(([_, v]) => typeof v === "string" && v.trim() || typeof v === "number").map(([k, v]) => {
|
|
16
16
|
if (k[0] !== "-" && k[1] !== "-")
|
|
17
17
|
return `${kebab(k)}:${v}`;
|
|
18
18
|
return `${k}:${v}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
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",
|
|
@@ -161,9 +161,9 @@
|
|
|
161
161
|
"which-pm": "^2.1.1",
|
|
162
162
|
"yargs-parser": "^21.1.1",
|
|
163
163
|
"zod": "^3.22.4",
|
|
164
|
-
"@astrojs/internal-helpers": "0.2.1",
|
|
165
164
|
"@astrojs/markdown-remark": "4.1.0",
|
|
166
|
-
"@astrojs/telemetry": "3.0.4"
|
|
165
|
+
"@astrojs/telemetry": "3.0.4",
|
|
166
|
+
"@astrojs/internal-helpers": "0.2.1"
|
|
167
167
|
},
|
|
168
168
|
"optionalDependencies": {
|
|
169
169
|
"sharp": "^0.32.6"
|