astro 4.2.6 → 4.2.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/content-types.template.d.ts +1 -1
- package/dist/assets/services/squoosh.js +2 -0
- package/dist/cli/add/index.js +2 -0
- package/dist/core/app/types.d.ts +1 -1
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/context.js +7 -2
- package/dist/i18n/middleware.js +2 -1
- package/dist/i18n/vite-plugin-i18n.d.ts +2 -1
- package/dist/i18n/vite-plugin-i18n.js +9 -21
- package/dist/preferences/index.js +3 -0
- package/dist/runtime/client/dev-toolbar/apps/settings.js +3 -0
- package/dist/runtime/server/scripts.js +2 -0
- package/dist/virtual-modules/i18n.js +2 -2
- package/package.json +2 -2
package/dist/cli/add/index.js
CHANGED
|
@@ -180,6 +180,8 @@ async function add(names, { flags }) {
|
|
|
180
180
|
case 3 /* failure */: {
|
|
181
181
|
throw createPrettyError(new Error(`Unable to install dependencies`));
|
|
182
182
|
}
|
|
183
|
+
case 0 /* none */:
|
|
184
|
+
break;
|
|
183
185
|
}
|
|
184
186
|
const rawConfigPath = await resolveConfigPath({
|
|
185
187
|
root: rootPath,
|
package/dist/core/app/types.d.ts
CHANGED
package/dist/core/constants.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const ASTRO_VERSION: string;
|
|
2
2
|
export declare const SUPPORTED_MARKDOWN_FILE_EXTENSIONS: readonly [".markdown", ".mdown", ".mkdn", ".mkd", ".mdwn", ".md"];
|
|
3
3
|
export declare const MIDDLEWARE_PATH_SEGMENT_NAME = "middleware";
|
|
4
|
+
export declare const ROUTE_DATA_SYMBOL = "astro.routeData";
|
package/dist/core/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const ASTRO_VERSION = "4.2.
|
|
1
|
+
const ASTRO_VERSION = "4.2.7";
|
|
2
2
|
const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
|
|
3
3
|
".markdown",
|
|
4
4
|
".mdown",
|
|
@@ -8,8 +8,10 @@ const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
|
|
|
8
8
|
".md"
|
|
9
9
|
];
|
|
10
10
|
const MIDDLEWARE_PATH_SEGMENT_NAME = "middleware";
|
|
11
|
+
const ROUTE_DATA_SYMBOL = "astro.routeData";
|
|
11
12
|
export {
|
|
12
13
|
ASTRO_VERSION,
|
|
13
14
|
MIDDLEWARE_PATH_SEGMENT_NAME,
|
|
15
|
+
ROUTE_DATA_SYMBOL,
|
|
14
16
|
SUPPORTED_MARKDOWN_FILE_EXTENSIONS
|
|
15
17
|
};
|
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.7";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
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.7";
|
|
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.7"}`
|
|
262
262
|
)} ${headline}`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { normalizeTheLocale, toCodes } from "../../i18n/index.js";
|
|
2
2
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
3
3
|
import { getParamsAndProps } from "./params-and-props.js";
|
|
4
|
+
import { ROUTE_DATA_SYMBOL } from "../constants.js";
|
|
4
5
|
const clientLocalsSymbol = Symbol.for("astro.locals");
|
|
6
|
+
const routeDataSymbol = Symbol.for(ROUTE_DATA_SYMBOL);
|
|
5
7
|
async function createRenderContext(options) {
|
|
6
8
|
const request = options.request;
|
|
7
9
|
const pathname = options.pathname ?? new URL(request.url).pathname;
|
|
@@ -148,8 +150,11 @@ function computePreferredLocaleList(request, locales) {
|
|
|
148
150
|
return result;
|
|
149
151
|
}
|
|
150
152
|
function computeCurrentLocale(request, locales, routingStrategy, defaultLocale) {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
+
const routeData = Reflect.get(request, routeDataSymbol);
|
|
154
|
+
if (!routeData) {
|
|
155
|
+
return defaultLocale;
|
|
156
|
+
}
|
|
157
|
+
for (const segment of routeData.route.split("/")) {
|
|
153
158
|
for (const locale of locales) {
|
|
154
159
|
if (typeof locale === "string") {
|
|
155
160
|
if (normalizeTheLocale(locale) === normalizeTheLocale(segment)) {
|
package/dist/i18n/middleware.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { appendForwardSlash, joinPaths } from "@astrojs/internal-helpers/path";
|
|
2
2
|
import { getPathByLocale, normalizeTheLocale } from "./index.js";
|
|
3
3
|
import { shouldAppendForwardSlash } from "../core/build/util.js";
|
|
4
|
-
|
|
4
|
+
import { ROUTE_DATA_SYMBOL } from "../core/constants.js";
|
|
5
|
+
const routeDataSymbol = Symbol.for(ROUTE_DATA_SYMBOL);
|
|
5
6
|
function pathnameHasLocale(pathname, locales) {
|
|
6
7
|
const segments = pathname.split("/");
|
|
7
8
|
for (const segment of segments) {
|
|
@@ -3,7 +3,8 @@ import type { AstroConfig, AstroSettings } from '../@types/astro.js';
|
|
|
3
3
|
type AstroInternationalization = {
|
|
4
4
|
settings: AstroSettings;
|
|
5
5
|
};
|
|
6
|
-
export interface I18nInternalConfig extends Pick<AstroConfig, 'base' | 'site' | 'trailingSlash'>,
|
|
6
|
+
export interface I18nInternalConfig extends Pick<AstroConfig, 'base' | 'site' | 'trailingSlash'>, Pick<AstroConfig['build'], 'format'> {
|
|
7
|
+
i18n: AstroConfig['i18n'];
|
|
7
8
|
}
|
|
8
9
|
export default function astroInternationalization({ settings, }: AstroInternationalization): vite.Plugin;
|
|
9
10
|
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { AstroError } from "../core/errors/errors.js";
|
|
2
2
|
import { AstroErrorData } from "../core/errors/index.js";
|
|
3
3
|
const virtualModuleId = "astro:i18n";
|
|
4
|
-
const configId = "astro-internal:i18n-config";
|
|
5
|
-
const resolvedConfigId = `\0${configId}`;
|
|
6
4
|
function astroInternationalization({
|
|
7
5
|
settings
|
|
8
6
|
}) {
|
|
@@ -16,30 +14,20 @@ function astroInternationalization({
|
|
|
16
14
|
return {
|
|
17
15
|
name: "astro:i18n",
|
|
18
16
|
enforce: "pre",
|
|
19
|
-
|
|
17
|
+
config(config) {
|
|
18
|
+
const i18nConfig = { base, format, site, trailingSlash, i18n };
|
|
19
|
+
return {
|
|
20
|
+
define: {
|
|
21
|
+
__ASTRO_INTERNAL_I18N_CONFIG__: JSON.stringify(i18nConfig)
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
resolveId(id) {
|
|
20
26
|
if (id === virtualModuleId) {
|
|
21
27
|
if (i18n === void 0)
|
|
22
28
|
throw new AstroError(AstroErrorData.i18nNotEnabled);
|
|
23
29
|
return this.resolve("astro/virtual-modules/i18n.js");
|
|
24
30
|
}
|
|
25
|
-
if (id === configId)
|
|
26
|
-
return resolvedConfigId;
|
|
27
|
-
},
|
|
28
|
-
load(id) {
|
|
29
|
-
if (id === resolvedConfigId) {
|
|
30
|
-
const { defaultLocale, locales, routing, fallback } = i18n;
|
|
31
|
-
const config = {
|
|
32
|
-
base,
|
|
33
|
-
format,
|
|
34
|
-
site,
|
|
35
|
-
trailingSlash,
|
|
36
|
-
defaultLocale,
|
|
37
|
-
locales,
|
|
38
|
-
routing,
|
|
39
|
-
fallback
|
|
40
|
-
};
|
|
41
|
-
return `export default ${JSON.stringify(config)};`;
|
|
42
|
-
}
|
|
43
31
|
}
|
|
44
32
|
};
|
|
45
33
|
}
|
|
@@ -144,7 +144,10 @@ var settings_default = {
|
|
|
144
144
|
astroToggle.input.addEventListener("change", setting.changeEvent);
|
|
145
145
|
astroToggle.input.checked = settings.config[setting.settingKey];
|
|
146
146
|
label.append(astroToggle);
|
|
147
|
+
break;
|
|
147
148
|
}
|
|
149
|
+
default:
|
|
150
|
+
break;
|
|
148
151
|
}
|
|
149
152
|
return label;
|
|
150
153
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as I18nInternals from "../i18n/index.js";
|
|
2
2
|
import { normalizeTheLocale, toCodes, toPaths } from "../i18n/index.js";
|
|
3
|
-
|
|
4
|
-
const {
|
|
3
|
+
const { trailingSlash, format, site, i18n } = __ASTRO_INTERNAL_I18N_CONFIG__;
|
|
4
|
+
const { defaultLocale, locales, routing } = i18n;
|
|
5
5
|
const base = import.meta.env.BASE_URL;
|
|
6
6
|
const getRelativeLocaleUrl = (locale, path, options) => I18nInternals.getLocaleRelativeUrl({
|
|
7
7
|
locale,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.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",
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
"yargs-parser": "^21.1.1",
|
|
164
164
|
"zod": "^3.22.4",
|
|
165
165
|
"@astrojs/internal-helpers": "0.2.1",
|
|
166
|
-
"@astrojs/markdown-remark": "4.2.
|
|
166
|
+
"@astrojs/markdown-remark": "4.2.1",
|
|
167
167
|
"@astrojs/telemetry": "3.0.4"
|
|
168
168
|
},
|
|
169
169
|
"optionalDependencies": {
|