astro 4.2.4 → 4.2.6
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 -141
- package/dist/@types/astro.d.ts +256 -256
- package/dist/content/types-generator.js +8 -8
- package/dist/core/app/common.js +4 -0
- package/dist/core/app/index.d.ts +1 -1
- package/dist/core/app/index.js +9 -14
- package/dist/core/app/types.d.ts +3 -2
- package/dist/core/build/generate.d.ts +1 -9
- package/dist/core/build/generate.js +20 -15
- package/dist/core/build/page-data.js +4 -2
- package/dist/core/build/plugins/plugin-manifest.js +8 -11
- package/dist/core/build/plugins/plugin-pages.d.ts +0 -2
- package/dist/core/build/plugins/plugin-pages.js +1 -16
- package/dist/core/build/plugins/plugin-prerender.js +29 -0
- package/dist/core/build/plugins/plugin-ssr.js +38 -38
- package/dist/core/build/static-build.js +1 -1
- package/dist/core/build/types.d.ts +1 -0
- 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/errors/errors-data.d.ts +36 -1
- package/dist/core/errors/errors-data.js +13 -5
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/vite-plugin.js +6 -6
- package/dist/core/routing/manifest/create.js +4 -3
- package/dist/events/toolbar.d.ts +10 -0
- package/dist/events/toolbar.js +10 -0
- package/dist/i18n/index.d.ts +9 -6
- package/dist/i18n/index.js +11 -1
- package/dist/i18n/middleware.d.ts +1 -1
- package/dist/i18n/middleware.js +4 -10
- package/dist/i18n/vite-plugin-i18n.d.ts +3 -1
- package/dist/i18n/vite-plugin-i18n.js +29 -46
- package/dist/runtime/client/dev-toolbar/apps/audit/a11y.js +1 -29
- package/dist/runtime/client/dev-toolbar/toolbar.js +5 -0
- package/dist/runtime/server/consts.d.ts +1 -0
- package/dist/runtime/server/consts.js +4 -0
- package/dist/runtime/server/endpoint.js +2 -1
- package/dist/runtime/server/transition.js +2 -4
- package/dist/virtual-modules/i18n.d.ts +126 -1
- package/dist/virtual-modules/i18n.js +62 -1
- package/dist/vite-plugin-astro-server/plugin.js +4 -1
- package/dist/vite-plugin-astro-server/route.js +8 -13
- package/dist/vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.js +24 -3
- package/dist/vite-plugin-env/index.js +8 -0
- package/package.json +3 -1
|
@@ -259,7 +259,7 @@ const LocalImageUsedWrongly = {
|
|
|
259
259
|
name: "LocalImageUsedWrongly",
|
|
260
260
|
title: "Local images must be imported.",
|
|
261
261
|
message: (imageFilePath) => `\`Image\`'s and \`getImage\`'s \`src\` parameter must be an imported image or an URL, it cannot be a string filepath. Received \`${imageFilePath}\`.`,
|
|
262
|
-
hint: "If you want to use an image from your `src` folder, you need to either import it or if the image is coming from a content collection, use the [image() schema helper](https://docs.astro.build/en/guides/images/#images-in-content-collections) See https://docs.astro.build/en/guides/images/#src-required for more information on the `src` property."
|
|
262
|
+
hint: "If you want to use an image from your `src` folder, you need to either import it or if the image is coming from a content collection, use the [image() schema helper](https://docs.astro.build/en/guides/images/#images-in-content-collections). See https://docs.astro.build/en/guides/images/#src-required for more information on the `src` property."
|
|
263
263
|
};
|
|
264
264
|
const AstroGlobUsedOutside = {
|
|
265
265
|
name: "AstroGlobUsedOutside",
|
|
@@ -270,7 +270,8 @@ const AstroGlobUsedOutside = {
|
|
|
270
270
|
const AstroGlobNoMatch = {
|
|
271
271
|
name: "AstroGlobNoMatch",
|
|
272
272
|
title: "Astro.glob() did not match any files.",
|
|
273
|
-
message: (globStr) => `\`Astro.glob(${globStr})\` did not return any matching files
|
|
273
|
+
message: (globStr) => `\`Astro.glob(${globStr})\` did not return any matching files.`,
|
|
274
|
+
hint: "Check the pattern for typos."
|
|
274
275
|
};
|
|
275
276
|
const RedirectWithNoLocation = {
|
|
276
277
|
name: "RedirectWithNoLocation",
|
|
@@ -316,8 +317,8 @@ const MissingLocale = {
|
|
|
316
317
|
const MissingIndexForInternationalization = {
|
|
317
318
|
name: "MissingIndexForInternationalizationError",
|
|
318
319
|
title: "Index page not found.",
|
|
319
|
-
message: (
|
|
320
|
-
Create an index page in \`${src}
|
|
320
|
+
message: (defaultLocale) => `Could not find index page. A root index page is required in order to create a redirect to the index URL of the default locale. (\`/${defaultLocale}\`)`,
|
|
321
|
+
hint: (src) => `Create an index page (\`index.astro, index.md, etc.\`) in \`${src}\`.`
|
|
321
322
|
};
|
|
322
323
|
const CantRenderPage = {
|
|
323
324
|
name: "CantRenderPage",
|
|
@@ -332,6 +333,12 @@ const UnhandledRejection = {
|
|
|
332
333
|
${stack}`,
|
|
333
334
|
hint: "Make sure your promises all have an `await` or a `.catch()` handler."
|
|
334
335
|
};
|
|
336
|
+
const i18nNotEnabled = {
|
|
337
|
+
name: "i18nNotEnabled",
|
|
338
|
+
title: "i18n Not Enabled",
|
|
339
|
+
message: "The `astro:i18n` module can not be used without enabling i18n in your Astro config.",
|
|
340
|
+
hint: "See https://docs.astro.build/en/guides/internationalization for a guide on setting up i18n."
|
|
341
|
+
};
|
|
335
342
|
const UnknownCSSError = {
|
|
336
343
|
name: "UnknownCSSError",
|
|
337
344
|
title: "Unknown CSS Error."
|
|
@@ -539,5 +546,6 @@ export {
|
|
|
539
546
|
UnknownViteError,
|
|
540
547
|
UnsupportedConfigTransformError,
|
|
541
548
|
UnsupportedImageConversion,
|
|
542
|
-
UnsupportedImageFormat
|
|
549
|
+
UnsupportedImageFormat,
|
|
550
|
+
i18nNotEnabled
|
|
543
551
|
};
|
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.6";
|
|
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.6"}`
|
|
262
262
|
)} ${headline}`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -3,7 +3,7 @@ import { getOutputDirectory } from "../../prerender/utils.js";
|
|
|
3
3
|
import { addRollupInput } from "../build/add-rollup-input.js";
|
|
4
4
|
import { MIDDLEWARE_PATH_SEGMENT_NAME } from "../constants.js";
|
|
5
5
|
const MIDDLEWARE_MODULE_ID = "\0astro-internal:middleware";
|
|
6
|
-
const
|
|
6
|
+
const NOOP_MIDDLEWARE = "\0noop-middleware";
|
|
7
7
|
function vitePluginMiddleware({ settings }) {
|
|
8
8
|
let isCommandBuild = false;
|
|
9
9
|
let resolvedMiddlewareId = void 0;
|
|
@@ -27,16 +27,16 @@ function vitePluginMiddleware({ settings }) {
|
|
|
27
27
|
} else if (hasIntegrationMiddleware) {
|
|
28
28
|
return MIDDLEWARE_MODULE_ID;
|
|
29
29
|
} else {
|
|
30
|
-
return
|
|
30
|
+
return NOOP_MIDDLEWARE;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
if (id ===
|
|
34
|
-
return
|
|
33
|
+
if (id === NOOP_MIDDLEWARE) {
|
|
34
|
+
return NOOP_MIDDLEWARE;
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
async load(id) {
|
|
38
|
-
if (id ===
|
|
39
|
-
return "export const onRequest =
|
|
38
|
+
if (id === NOOP_MIDDLEWARE) {
|
|
39
|
+
return "export const onRequest = (_, next) => next()";
|
|
40
40
|
} else if (id === MIDDLEWARE_MODULE_ID) {
|
|
41
41
|
if (isCommandBuild) {
|
|
42
42
|
this.emitFile({
|
|
@@ -5,11 +5,11 @@ import path from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { getPrerenderDefault } from "../../../prerender/utils.js";
|
|
7
7
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "../../constants.js";
|
|
8
|
+
import { MissingIndexForInternationalization } from "../../errors/errors-data.js";
|
|
9
|
+
import { AstroError } from "../../errors/index.js";
|
|
8
10
|
import { removeLeadingForwardSlash, slash } from "../../path.js";
|
|
9
11
|
import { resolvePages } from "../../util.js";
|
|
10
12
|
import { getRouteGenerator } from "./generator.js";
|
|
11
|
-
import { AstroError } from "../../errors/index.js";
|
|
12
|
-
import { MissingIndexForInternationalization } from "../../errors/errors-data.js";
|
|
13
13
|
const require2 = createRequire(import.meta.url);
|
|
14
14
|
function countOccurrences(needle, haystack) {
|
|
15
15
|
let count = 0;
|
|
@@ -446,7 +446,8 @@ function createRouteManifest(params, logger) {
|
|
|
446
446
|
);
|
|
447
447
|
throw new AstroError({
|
|
448
448
|
...MissingIndexForInternationalization,
|
|
449
|
-
message: MissingIndexForInternationalization.message(
|
|
449
|
+
message: MissingIndexForInternationalization.message(i18n.defaultLocale),
|
|
450
|
+
hint: MissingIndexForInternationalization.hint(relativePath)
|
|
450
451
|
});
|
|
451
452
|
}
|
|
452
453
|
}
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -35,29 +35,32 @@ export declare function getLocaleRelativeUrl({ locale, base, locales: _locales,
|
|
|
35
35
|
* The absolute URL
|
|
36
36
|
*/
|
|
37
37
|
export declare function getLocaleAbsoluteUrl({ site, ...rest }: GetLocaleAbsoluteUrl): string;
|
|
38
|
-
|
|
38
|
+
interface GetLocalesRelativeUrlList extends GetLocaleOptions {
|
|
39
39
|
base: string;
|
|
40
40
|
locales: Locales;
|
|
41
41
|
trailingSlash: AstroConfig['trailingSlash'];
|
|
42
42
|
format: AstroConfig['build']['format'];
|
|
43
43
|
routing?: RoutingStrategies;
|
|
44
44
|
defaultLocale: string;
|
|
45
|
-
}
|
|
46
|
-
export declare function getLocaleRelativeUrlList({ base, locales: _locales, trailingSlash, format, path, prependWith, normalizeLocale, routing, defaultLocale, }:
|
|
47
|
-
|
|
45
|
+
}
|
|
46
|
+
export declare function getLocaleRelativeUrlList({ base, locales: _locales, trailingSlash, format, path, prependWith, normalizeLocale, routing, defaultLocale, }: GetLocalesRelativeUrlList): string[];
|
|
47
|
+
interface GetLocalesAbsoluteUrlList extends GetLocalesRelativeUrlList {
|
|
48
|
+
site?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare function getLocaleAbsoluteUrlList({ site, ...rest }: GetLocalesAbsoluteUrlList): string[];
|
|
48
51
|
/**
|
|
49
52
|
* Given a locale (code), it returns its corresponding path
|
|
50
53
|
* @param locale
|
|
51
54
|
* @param locales
|
|
52
55
|
*/
|
|
53
|
-
export declare function getPathByLocale(locale: string, locales: Locales): string
|
|
56
|
+
export declare function getPathByLocale(locale: string, locales: Locales): string;
|
|
54
57
|
/**
|
|
55
58
|
* An utility function that retrieves the preferred locale that correspond to a path.
|
|
56
59
|
*
|
|
57
60
|
* @param path
|
|
58
61
|
* @param locales
|
|
59
62
|
*/
|
|
60
|
-
export declare function getLocaleByPath(path: string, locales: Locales): string
|
|
63
|
+
export declare function getLocaleByPath(path: string, locales: Locales): string;
|
|
61
64
|
/**
|
|
62
65
|
*
|
|
63
66
|
* Given a locale, this function:
|
package/dist/i18n/index.js
CHANGED
|
@@ -95,19 +95,22 @@ function getPathByLocale(locale, locales) {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
throw new Unreachable();
|
|
98
99
|
}
|
|
99
100
|
function getLocaleByPath(path, locales) {
|
|
100
101
|
for (const locale of locales) {
|
|
101
102
|
if (typeof locale !== "string") {
|
|
102
103
|
if (locale.path === path) {
|
|
103
104
|
const code = locale.codes.at(0);
|
|
105
|
+
if (code === void 0)
|
|
106
|
+
throw new Unreachable();
|
|
104
107
|
return code;
|
|
105
108
|
}
|
|
106
109
|
} else if (locale === path) {
|
|
107
110
|
return locale;
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
|
-
|
|
113
|
+
throw new Unreachable();
|
|
111
114
|
}
|
|
112
115
|
function normalizeTheLocale(locale) {
|
|
113
116
|
return locale.replaceAll("_", "-").toLowerCase();
|
|
@@ -150,6 +153,13 @@ function peekCodePathToUse(locales, locale) {
|
|
|
150
153
|
}
|
|
151
154
|
return void 0;
|
|
152
155
|
}
|
|
156
|
+
class Unreachable extends Error {
|
|
157
|
+
constructor() {
|
|
158
|
+
super(
|
|
159
|
+
"Astro encountered an unexpected line of code.\nIn most cases, this is not your fault, but a bug in astro code.\nIf there isn't one already, please create an issue.\nhttps://astro.build/issues"
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
153
163
|
export {
|
|
154
164
|
getLocaleAbsoluteUrl,
|
|
155
165
|
getLocaleAbsoluteUrlList,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MiddlewareHandler, SSRManifest } from '../@types/astro.js';
|
|
2
2
|
import type { PipelineHookFunction } from '../core/pipeline.js';
|
|
3
|
-
export declare function createI18nMiddleware(i18n: SSRManifest['i18n'], base: SSRManifest['base'], trailingSlash: SSRManifest['trailingSlash'], buildFormat: SSRManifest['buildFormat']): MiddlewareHandler
|
|
3
|
+
export declare function createI18nMiddleware(i18n: SSRManifest['i18n'], base: SSRManifest['base'], trailingSlash: SSRManifest['trailingSlash'], buildFormat: SSRManifest['buildFormat']): MiddlewareHandler;
|
|
4
4
|
/**
|
|
5
5
|
* This pipeline hook attaches a `RouteData` object to the `Request`
|
|
6
6
|
*/
|
package/dist/i18n/middleware.js
CHANGED
|
@@ -18,18 +18,12 @@ function pathnameHasLocale(pathname, locales) {
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
function createI18nMiddleware(i18n, base, trailingSlash, buildFormat) {
|
|
21
|
-
if (!i18n)
|
|
22
|
-
return
|
|
23
|
-
}
|
|
21
|
+
if (!i18n)
|
|
22
|
+
return (_, next) => next();
|
|
24
23
|
return async (context, next) => {
|
|
25
|
-
if (!i18n) {
|
|
26
|
-
return await next();
|
|
27
|
-
}
|
|
28
24
|
const routeData = Reflect.get(context.request, routeDataSymbol);
|
|
29
|
-
if (routeData) {
|
|
30
|
-
|
|
31
|
-
return await next();
|
|
32
|
-
}
|
|
25
|
+
if (routeData?.type !== "page" && routeData?.type !== "fallback") {
|
|
26
|
+
return await next();
|
|
33
27
|
}
|
|
34
28
|
const url = context.url;
|
|
35
29
|
const { locales, defaultLocale, fallback, routing } = i18n;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
|
-
import type { AstroSettings } from '../@types/astro.js';
|
|
2
|
+
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'>, NonNullable<AstroConfig['i18n']>, Pick<AstroConfig['build'], 'format'> {
|
|
7
|
+
}
|
|
6
8
|
export default function astroInternationalization({ settings, }: AstroInternationalization): vite.Plugin;
|
|
7
9
|
export {};
|
|
@@ -1,61 +1,44 @@
|
|
|
1
|
+
import { AstroError } from "../core/errors/errors.js";
|
|
2
|
+
import { AstroErrorData } from "../core/errors/index.js";
|
|
1
3
|
const virtualModuleId = "astro:i18n";
|
|
2
|
-
const
|
|
4
|
+
const configId = "astro-internal:i18n-config";
|
|
5
|
+
const resolvedConfigId = `\0${configId}`;
|
|
3
6
|
function astroInternationalization({
|
|
4
7
|
settings
|
|
5
8
|
}) {
|
|
9
|
+
const {
|
|
10
|
+
base,
|
|
11
|
+
build: { format },
|
|
12
|
+
i18n,
|
|
13
|
+
site,
|
|
14
|
+
trailingSlash
|
|
15
|
+
} = settings.config;
|
|
6
16
|
return {
|
|
7
17
|
name: "astro:i18n",
|
|
8
18
|
enforce: "pre",
|
|
9
19
|
async resolveId(id) {
|
|
10
20
|
if (id === virtualModuleId) {
|
|
11
|
-
|
|
21
|
+
if (i18n === void 0)
|
|
22
|
+
throw new AstroError(AstroErrorData.i18nNotEnabled);
|
|
23
|
+
return this.resolve("astro/virtual-modules/i18n.js");
|
|
12
24
|
}
|
|
25
|
+
if (id === configId)
|
|
26
|
+
return resolvedConfigId;
|
|
13
27
|
},
|
|
14
28
|
load(id) {
|
|
15
|
-
if (id ===
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const format = ${JSON.stringify(settings.config.build.format)};
|
|
29
|
-
const site = ${JSON.stringify(settings.config.site)};
|
|
30
|
-
const i18n = ${JSON.stringify(settings.config.i18n)};
|
|
31
|
-
|
|
32
|
-
export const getRelativeLocaleUrl = (locale, path = "", opts) => _getLocaleRelativeUrl({
|
|
33
|
-
locale,
|
|
34
|
-
path,
|
|
35
|
-
base,
|
|
36
|
-
trailingSlash,
|
|
37
|
-
format,
|
|
38
|
-
...i18n,
|
|
39
|
-
...opts
|
|
40
|
-
});
|
|
41
|
-
export const getAbsoluteLocaleUrl = (locale, path = "", opts) => _getLocaleAbsoluteUrl({
|
|
42
|
-
locale,
|
|
43
|
-
path,
|
|
44
|
-
base,
|
|
45
|
-
trailingSlash,
|
|
46
|
-
format,
|
|
47
|
-
site,
|
|
48
|
-
...i18n,
|
|
49
|
-
...opts
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
export const getRelativeLocaleUrlList = (path = "", opts) => _getLocaleRelativeUrlList({
|
|
53
|
-
base, path, trailingSlash, format, ...i18n, ...opts });
|
|
54
|
-
export const getAbsoluteLocaleUrlList = (path = "", opts) => _getLocaleAbsoluteUrlList({ base, path, trailingSlash, format, site, ...i18n, ...opts });
|
|
55
|
-
|
|
56
|
-
export const getPathByLocale = (locale) => _getPathByLocale(locale, i18n.locales);
|
|
57
|
-
export const getLocaleByPath = (path) => _getLocaleByPath(path, i18n.locales);
|
|
58
|
-
`;
|
|
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)};`;
|
|
59
42
|
}
|
|
60
43
|
}
|
|
61
44
|
};
|
|
@@ -42,11 +42,8 @@ const aria_non_interactive_roles = [
|
|
|
42
42
|
"application",
|
|
43
43
|
"article",
|
|
44
44
|
"banner",
|
|
45
|
-
"button",
|
|
46
45
|
"cell",
|
|
47
|
-
"checkbox",
|
|
48
46
|
"columnheader",
|
|
49
|
-
"combobox",
|
|
50
47
|
"complementary",
|
|
51
48
|
"contentinfo",
|
|
52
49
|
"definition",
|
|
@@ -56,55 +53,30 @@ const aria_non_interactive_roles = [
|
|
|
56
53
|
"feed",
|
|
57
54
|
"figure",
|
|
58
55
|
"form",
|
|
59
|
-
"grid",
|
|
60
|
-
"gridcell",
|
|
61
56
|
"group",
|
|
62
57
|
"heading",
|
|
63
58
|
"img",
|
|
64
|
-
"link",
|
|
65
59
|
"list",
|
|
66
|
-
"listbox",
|
|
67
60
|
"listitem",
|
|
68
61
|
"log",
|
|
69
62
|
"main",
|
|
70
63
|
"marquee",
|
|
71
64
|
"math",
|
|
72
|
-
"menu",
|
|
73
|
-
"menubar",
|
|
74
|
-
"menuitem",
|
|
75
|
-
"menuitemcheckbox",
|
|
76
65
|
"menuitemradio",
|
|
77
66
|
"navigation",
|
|
78
67
|
"none",
|
|
79
68
|
"note",
|
|
80
|
-
"option",
|
|
81
69
|
"presentation",
|
|
82
|
-
"progressbar",
|
|
83
|
-
"radio",
|
|
84
|
-
"radiogroup",
|
|
85
70
|
"region",
|
|
86
71
|
"row",
|
|
87
72
|
"rowgroup",
|
|
88
73
|
"rowheader",
|
|
89
|
-
"scrollbar",
|
|
90
74
|
"search",
|
|
91
|
-
"searchbox",
|
|
92
|
-
"separator",
|
|
93
|
-
"slider",
|
|
94
|
-
"spinbutton",
|
|
95
75
|
"status",
|
|
96
|
-
"switch",
|
|
97
|
-
"tab",
|
|
98
|
-
"tablist",
|
|
99
|
-
"tabpanel",
|
|
100
76
|
"term",
|
|
101
|
-
"textbox",
|
|
102
77
|
"timer",
|
|
103
78
|
"toolbar",
|
|
104
|
-
"tooltip"
|
|
105
|
-
"tree",
|
|
106
|
-
"treegrid",
|
|
107
|
-
"treeitem"
|
|
79
|
+
"tooltip"
|
|
108
80
|
];
|
|
109
81
|
const a11y_required_content = [
|
|
110
82
|
// anchor-has-content
|
|
@@ -371,6 +371,11 @@ class AstroDevToolbar extends HTMLElement {
|
|
|
371
371
|
return;
|
|
372
372
|
if (app !== activeApp) {
|
|
373
373
|
await this.setAppStatus(app, true);
|
|
374
|
+
if (import.meta.hot && app.id !== "astro:more") {
|
|
375
|
+
import.meta.hot.send("astro:devtoolbar:app:toggled", {
|
|
376
|
+
app
|
|
377
|
+
});
|
|
378
|
+
}
|
|
374
379
|
}
|
|
375
380
|
}
|
|
376
381
|
async setAppStatus(app, newStatus) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { bold } from "kleur/colors";
|
|
2
|
+
import { REROUTE_DIRECTIVE_HEADER } from "./consts.js";
|
|
2
3
|
async function renderEndpoint(mod, context, ssr, logger) {
|
|
3
4
|
const { request, url } = context;
|
|
4
5
|
const method = request.method.toUpperCase();
|
|
@@ -22,7 +23,7 @@ Found handlers: ${Object.keys(mod).map((exp) => JSON.stringify(exp)).join(", ")}
|
|
|
22
23
|
return new Response(null, { status: 404 });
|
|
23
24
|
}
|
|
24
25
|
const response = await handler.call(mod, context);
|
|
25
|
-
response.headers.set(
|
|
26
|
+
response.headers.set(REROUTE_DIRECTIVE_HEADER, "no");
|
|
26
27
|
return response;
|
|
27
28
|
}
|
|
28
29
|
export {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fade, slide } from "../../transitions/index.js";
|
|
2
2
|
import { markHTMLString } from "./escape.js";
|
|
3
|
+
import cssesc from "cssesc";
|
|
3
4
|
const transitionNameMap = /* @__PURE__ */ new WeakMap();
|
|
4
5
|
function incrementTransitionNumber(result) {
|
|
5
6
|
let num = 1;
|
|
@@ -13,9 +14,6 @@ function createTransitionScope(result, hash) {
|
|
|
13
14
|
const num = incrementTransitionNumber(result);
|
|
14
15
|
return `astro-${hash}-${num}`;
|
|
15
16
|
}
|
|
16
|
-
function toValidIdent(name) {
|
|
17
|
-
return name.replace(/[^a-zA-Z0-9\-\_]/g, "_").replace(/^\_+|\_+$/g, "");
|
|
18
|
-
}
|
|
19
17
|
const getAnimations = (name) => {
|
|
20
18
|
if (name === "fade")
|
|
21
19
|
return fade();
|
|
@@ -35,7 +33,7 @@ function renderTransition(result, hash, animationName, transitionName) {
|
|
|
35
33
|
if (!animationName)
|
|
36
34
|
animationName = "fade";
|
|
37
35
|
const scope = createTransitionScope(result, hash);
|
|
38
|
-
const name = transitionName ?
|
|
36
|
+
const name = transitionName ? cssesc(transitionName, { isIdentifier: true }) : scope;
|
|
39
37
|
const sheet = new ViewTransitionStyleSheet(scope, name);
|
|
40
38
|
const animations = getAnimations(animationName);
|
|
41
39
|
if (animations) {
|
|
@@ -1 +1,126 @@
|
|
|
1
|
-
|
|
1
|
+
import * as I18nInternals from '../i18n/index.js';
|
|
2
|
+
export { normalizeTheLocale, toCodes, toPaths } from '../i18n/index.js';
|
|
3
|
+
export type GetLocaleOptions = I18nInternals.GetLocaleOptions;
|
|
4
|
+
/**
|
|
5
|
+
* @param locale A locale
|
|
6
|
+
* @param path An optional path to add after the `locale`.
|
|
7
|
+
* @param options Customise the generated path
|
|
8
|
+
*
|
|
9
|
+
* Returns a _relative_ path with passed locale.
|
|
10
|
+
*
|
|
11
|
+
* ## Errors
|
|
12
|
+
*
|
|
13
|
+
* Throws an error if the locale doesn't exist in the list of locales defined in the configuration.
|
|
14
|
+
*
|
|
15
|
+
* ## Examples
|
|
16
|
+
*
|
|
17
|
+
* ```js
|
|
18
|
+
* import { getRelativeLocaleUrl } from "astro:i18n";
|
|
19
|
+
* getRelativeLocaleUrl("es"); // /es
|
|
20
|
+
* getRelativeLocaleUrl("es", "getting-started"); // /es/getting-started
|
|
21
|
+
* getRelativeLocaleUrl("es_US", "getting-started", { prependWith: "blog" }); // /blog/es-us/getting-started
|
|
22
|
+
* getRelativeLocaleUrl("es_US", "getting-started", { prependWith: "blog", normalizeLocale: false }); // /blog/es_US/getting-started
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const getRelativeLocaleUrl: (locale: string, path?: string, options?: GetLocaleOptions) => string;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param locale A locale
|
|
29
|
+
* @param path An optional path to add after the `locale`.
|
|
30
|
+
* @param options Customise the generated path
|
|
31
|
+
*
|
|
32
|
+
* Returns an absolute path with the passed locale. The behaviour is subject to change based on `site` configuration.
|
|
33
|
+
* If _not_ provided, the function will return a _relative_ URL.
|
|
34
|
+
*
|
|
35
|
+
* ## Errors
|
|
36
|
+
*
|
|
37
|
+
* Throws an error if the locale doesn't exist in the list of locales defined in the configuration.
|
|
38
|
+
*
|
|
39
|
+
* ## Examples
|
|
40
|
+
*
|
|
41
|
+
* If `site` is `https://example.com`:
|
|
42
|
+
*
|
|
43
|
+
* ```js
|
|
44
|
+
* import { getAbsoluteLocaleUrl } from "astro:i18n";
|
|
45
|
+
* getAbsoluteLocaleUrl("es"); // https://example.com/es
|
|
46
|
+
* getAbsoluteLocaleUrl("es", "getting-started"); // https://example.com/es/getting-started
|
|
47
|
+
* getAbsoluteLocaleUrl("es_US", "getting-started", { prependWith: "blog" }); // https://example.com/blog/es-us/getting-started
|
|
48
|
+
* getAbsoluteLocaleUrl("es_US", "getting-started", { prependWith: "blog", normalizeLocale: false }); // https://example.com/blog/es_US/getting-started
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const getAbsoluteLocaleUrl: (locale: string, path?: string, options?: GetLocaleOptions) => string;
|
|
52
|
+
/**
|
|
53
|
+
* @param path An optional path to add after the `locale`.
|
|
54
|
+
* @param options Customise the generated path
|
|
55
|
+
*
|
|
56
|
+
* Works like `getRelativeLocaleUrl` but it emits the relative URLs for ALL locales:
|
|
57
|
+
*/
|
|
58
|
+
export declare const getRelativeLocaleUrlList: (path?: string, options?: GetLocaleOptions) => string[];
|
|
59
|
+
/**
|
|
60
|
+
* @param path An optional path to add after the `locale`.
|
|
61
|
+
* @param options Customise the generated path
|
|
62
|
+
*
|
|
63
|
+
* Works like `getAbsoluteLocaleUrl` but it emits the absolute URLs for ALL locales:
|
|
64
|
+
*/
|
|
65
|
+
export declare const getAbsoluteLocaleUrlList: (path?: string, options?: GetLocaleOptions) => string[];
|
|
66
|
+
/**
|
|
67
|
+
* A function that return the `path` associated to a locale (defined as code). It's particularly useful in case you decide
|
|
68
|
+
* to use locales that are broken down in paths and codes.
|
|
69
|
+
*
|
|
70
|
+
* @param locale The code of the locale
|
|
71
|
+
* @returns The path associated to the locale
|
|
72
|
+
*
|
|
73
|
+
* ## Example
|
|
74
|
+
*
|
|
75
|
+
* ```js
|
|
76
|
+
* // astro.config.mjs
|
|
77
|
+
*
|
|
78
|
+
* export default defineConfig({
|
|
79
|
+
* i18n: {
|
|
80
|
+
* locales: [
|
|
81
|
+
* { codes: ["it", "it-VT"], path: "italiano" },
|
|
82
|
+
* "es"
|
|
83
|
+
* ]
|
|
84
|
+
* }
|
|
85
|
+
* })
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* ```js
|
|
89
|
+
* import { getPathByLocale } from "astro:i18n";
|
|
90
|
+
* getPathByLocale("it"); // returns "italiano"
|
|
91
|
+
* getPathByLocale("it-VT"); // returns "italiano"
|
|
92
|
+
* getPathByLocale("es"); // returns "es"
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare const getPathByLocale: (locale: string) => string;
|
|
96
|
+
/**
|
|
97
|
+
* A function that returns the preferred locale given a certain path. This is particularly useful if you configure a locale using
|
|
98
|
+
* `path` and `codes`. When you define multiple `code`, this function will return the first code of the array.
|
|
99
|
+
*
|
|
100
|
+
* Astro will treat the first code as the one that the user prefers.
|
|
101
|
+
*
|
|
102
|
+
* @param path The path that maps to a locale
|
|
103
|
+
* @returns The path associated to the locale
|
|
104
|
+
*
|
|
105
|
+
* ## Example
|
|
106
|
+
*
|
|
107
|
+
* ```js
|
|
108
|
+
* // astro.config.mjs
|
|
109
|
+
*
|
|
110
|
+
* export default defineConfig({
|
|
111
|
+
* i18n: {
|
|
112
|
+
* locales: [
|
|
113
|
+
* { codes: ["it-VT", "it"], path: "italiano" },
|
|
114
|
+
* "es"
|
|
115
|
+
* ]
|
|
116
|
+
* }
|
|
117
|
+
* })
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* ```js
|
|
121
|
+
* import { getLocaleByPath } from "astro:i18n";
|
|
122
|
+
* getLocaleByPath("italiano"); // returns "it-VT" because that's the first code configured
|
|
123
|
+
* getLocaleByPath("es"); // returns "es"
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare const getLocaleByPath: (path: string) => string;
|