@tschk/moonshine-astro 0.4.49 → 0.4.80
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/README.md +63 -18
- package/package.json +17 -5
- package/src/actions.ts +556 -0
- package/src/assets.ts +710 -0
- package/src/config.ts +269 -0
- package/src/container.ts +560 -0
- package/src/content.ts +1523 -0
- package/src/context.ts +756 -0
- package/src/env.ts +361 -0
- package/src/i18n.ts +420 -0
- package/src/index.ts +264 -0
- package/src/loaders.ts +888 -0
- package/src/middleware.ts +206 -0
- package/src/routing.ts +239 -0
- package/src/ssr.ts +208 -2
- package/src/transitions.ts +496 -0
package/src/i18n.ts
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/** Independent host-free Astro internationalization helpers (`astro:i18n`). */
|
|
2
|
+
import type { ValidRedirectStatus } from "./context";
|
|
3
|
+
import {
|
|
4
|
+
defineMiddleware,
|
|
5
|
+
type APIContext,
|
|
6
|
+
type MiddlewareHandler,
|
|
7
|
+
} from "./middleware";
|
|
8
|
+
|
|
9
|
+
export type AstroI18nLocaleConfig =
|
|
10
|
+
| string
|
|
11
|
+
| {
|
|
12
|
+
path: string;
|
|
13
|
+
codes: [string, ...string[]];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export interface AstroI18nRoutingOptions {
|
|
17
|
+
prefixDefaultLocale?: boolean;
|
|
18
|
+
redirectToDefaultLocale?: boolean;
|
|
19
|
+
fallbackType?: "redirect" | "rewrite";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type AstroI18nRoutingStrategy = "manual" | AstroI18nRoutingOptions;
|
|
23
|
+
|
|
24
|
+
export interface AstroI18nConfig {
|
|
25
|
+
defaultLocale: string;
|
|
26
|
+
locales: AstroI18nLocaleConfig[];
|
|
27
|
+
routing?: AstroI18nRoutingStrategy;
|
|
28
|
+
fallback?: Record<string, string>;
|
|
29
|
+
domains?: Record<string, string>;
|
|
30
|
+
base?: string;
|
|
31
|
+
site?: string;
|
|
32
|
+
trailingSlash?: "always" | "never" | "ignore";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface GetLocaleOptions {
|
|
36
|
+
prependWith?: string;
|
|
37
|
+
normalizeLocale?: boolean;
|
|
38
|
+
base?: string;
|
|
39
|
+
site?: string;
|
|
40
|
+
trailingSlash?: "always" | "never" | "ignore";
|
|
41
|
+
config?: AstroI18nConfig;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class AstroI18nError extends Error {
|
|
45
|
+
readonly code: string;
|
|
46
|
+
|
|
47
|
+
constructor(message: string, code = "AstroI18nError") {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = "AstroI18nError";
|
|
50
|
+
this.code = code;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const DEFAULT_I18N_CONFIG: AstroI18nConfig = {
|
|
55
|
+
defaultLocale: "en",
|
|
56
|
+
locales: ["en"],
|
|
57
|
+
routing: {
|
|
58
|
+
prefixDefaultLocale: false,
|
|
59
|
+
redirectToDefaultLocale: true,
|
|
60
|
+
fallbackType: "redirect",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
let activeI18nConfig: AstroI18nConfig = DEFAULT_I18N_CONFIG;
|
|
65
|
+
|
|
66
|
+
export function configureI18n(config: AstroI18nConfig): AstroI18nConfig {
|
|
67
|
+
activeI18nConfig = {
|
|
68
|
+
...config,
|
|
69
|
+
routing:
|
|
70
|
+
config.routing === "manual"
|
|
71
|
+
? "manual"
|
|
72
|
+
: {
|
|
73
|
+
prefixDefaultLocale: config.routing?.prefixDefaultLocale ?? false,
|
|
74
|
+
redirectToDefaultLocale:
|
|
75
|
+
config.routing?.redirectToDefaultLocale ?? true,
|
|
76
|
+
fallbackType: config.routing?.fallbackType ?? "redirect",
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
return activeI18nConfig;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function getI18nConfig(): AstroI18nConfig {
|
|
83
|
+
return activeI18nConfig;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function resetI18nConfig(): void {
|
|
87
|
+
activeI18nConfig = DEFAULT_I18N_CONFIG;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function resolveRoutingOptions(
|
|
91
|
+
config: AstroI18nConfig,
|
|
92
|
+
): Required<AstroI18nRoutingOptions> {
|
|
93
|
+
if (!config.routing || config.routing === "manual") {
|
|
94
|
+
return {
|
|
95
|
+
prefixDefaultLocale: false,
|
|
96
|
+
redirectToDefaultLocale: true,
|
|
97
|
+
fallbackType: "redirect",
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
prefixDefaultLocale: config.routing.prefixDefaultLocale ?? false,
|
|
102
|
+
redirectToDefaultLocale: config.routing.redirectToDefaultLocale ?? true,
|
|
103
|
+
fallbackType: config.routing.fallbackType ?? "redirect",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function toCodes(locales: AstroI18nLocaleConfig[]): string[] {
|
|
108
|
+
const result: string[] = [];
|
|
109
|
+
for (const entry of locales) {
|
|
110
|
+
if (typeof entry === "string") {
|
|
111
|
+
result.push(entry);
|
|
112
|
+
} else {
|
|
113
|
+
for (const code of entry.codes) {
|
|
114
|
+
result.push(code);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function toPaths(locales: AstroI18nLocaleConfig[]): string[] {
|
|
122
|
+
return locales.map((entry) =>
|
|
123
|
+
typeof entry === "string" ? entry : entry.path,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function getPathByLocale(
|
|
128
|
+
locale: string,
|
|
129
|
+
config: AstroI18nConfig = activeI18nConfig,
|
|
130
|
+
): string {
|
|
131
|
+
for (const entry of config.locales) {
|
|
132
|
+
if (typeof entry === "string") {
|
|
133
|
+
if (entry === locale || entry.toLowerCase() === locale.toLowerCase()) {
|
|
134
|
+
return entry;
|
|
135
|
+
}
|
|
136
|
+
} else if (
|
|
137
|
+
entry.codes.some(
|
|
138
|
+
(code) =>
|
|
139
|
+
code === locale || code.toLowerCase() === locale.toLowerCase(),
|
|
140
|
+
)
|
|
141
|
+
) {
|
|
142
|
+
return entry.path;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
throw new AstroI18nError(
|
|
146
|
+
`The locale "${locale}" is not present in your i18n configuration.`,
|
|
147
|
+
"LocaleNotAvailable",
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function getLocaleByPath(
|
|
152
|
+
path: string,
|
|
153
|
+
config: AstroI18nConfig = activeI18nConfig,
|
|
154
|
+
): string {
|
|
155
|
+
const normalized = path.replace(/^\/+|\/+$/g, "");
|
|
156
|
+
for (const entry of config.locales) {
|
|
157
|
+
if (typeof entry === "string") {
|
|
158
|
+
if (
|
|
159
|
+
entry === normalized ||
|
|
160
|
+
entry.toLowerCase() === normalized.toLowerCase()
|
|
161
|
+
) {
|
|
162
|
+
return entry;
|
|
163
|
+
}
|
|
164
|
+
} else if (
|
|
165
|
+
entry.path === normalized ||
|
|
166
|
+
entry.path.toLowerCase() === normalized.toLowerCase()
|
|
167
|
+
) {
|
|
168
|
+
return entry.codes[0];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
throw new AstroI18nError(
|
|
172
|
+
`No locale matches path "${path}" in your i18n configuration.`,
|
|
173
|
+
"LocaleNotAvailable",
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function normalizeTheLocale(locale: string): string {
|
|
178
|
+
return locale.replaceAll("_", "-").toLowerCase();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function joinSegments(
|
|
182
|
+
segments: Array<string | undefined>,
|
|
183
|
+
trailingSlash: "always" | "never" | "ignore" = "ignore",
|
|
184
|
+
hadTrailingSlash = false,
|
|
185
|
+
): string {
|
|
186
|
+
const cleaned = segments
|
|
187
|
+
.filter((s): s is string => Boolean(s && s.trim().length > 0))
|
|
188
|
+
.map((s) => s.replace(/^\/+|\/+$/g, ""))
|
|
189
|
+
.filter((s) => s.length > 0);
|
|
190
|
+
if (cleaned.length === 0) {
|
|
191
|
+
return "/";
|
|
192
|
+
}
|
|
193
|
+
const joined = "/" + cleaned.join("/");
|
|
194
|
+
if (trailingSlash === "always") {
|
|
195
|
+
return joined + "/";
|
|
196
|
+
}
|
|
197
|
+
if (trailingSlash === "never") {
|
|
198
|
+
return joined;
|
|
199
|
+
}
|
|
200
|
+
return hadTrailingSlash ? joined + "/" : joined;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function getRelativeLocaleUrl(
|
|
204
|
+
locale: string,
|
|
205
|
+
path = "",
|
|
206
|
+
options?: GetLocaleOptions,
|
|
207
|
+
): string {
|
|
208
|
+
const config = options?.config ?? activeI18nConfig;
|
|
209
|
+
const routing = resolveRoutingOptions(config);
|
|
210
|
+
const localePath = getPathByLocale(locale, config);
|
|
211
|
+
const formattedLocale =
|
|
212
|
+
options?.normalizeLocale === true
|
|
213
|
+
? normalizeTheLocale(localePath)
|
|
214
|
+
: localePath;
|
|
215
|
+
const isDefault =
|
|
216
|
+
locale === config.defaultLocale ||
|
|
217
|
+
localePath === getPathByLocale(config.defaultLocale, config);
|
|
218
|
+
const shouldPrefix = !isDefault || routing.prefixDefaultLocale;
|
|
219
|
+
const base = options?.base ?? config.base ?? "";
|
|
220
|
+
const trailingSlash =
|
|
221
|
+
options?.trailingSlash ?? config.trailingSlash ?? "ignore";
|
|
222
|
+
const hadTrailingSlash = path.endsWith("/") && path.length > 1;
|
|
223
|
+
|
|
224
|
+
return joinSegments(
|
|
225
|
+
[
|
|
226
|
+
base,
|
|
227
|
+
options?.prependWith,
|
|
228
|
+
shouldPrefix ? formattedLocale : undefined,
|
|
229
|
+
path,
|
|
230
|
+
],
|
|
231
|
+
trailingSlash,
|
|
232
|
+
hadTrailingSlash,
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function getAbsoluteLocaleUrl(
|
|
237
|
+
locale: string,
|
|
238
|
+
path = "",
|
|
239
|
+
options?: GetLocaleOptions,
|
|
240
|
+
): string {
|
|
241
|
+
const config = options?.config ?? activeI18nConfig;
|
|
242
|
+
const domain = config.domains?.[locale];
|
|
243
|
+
const siteBase = domain ?? options?.site ?? config.site ?? "http://localhost";
|
|
244
|
+
const relative = getRelativeLocaleUrl(locale, path, {
|
|
245
|
+
...options,
|
|
246
|
+
// If a dedicated domain is configured for this locale, don't prefix default locale on that domain unless prefixDefaultLocale is true
|
|
247
|
+
base: domain ? undefined : (options?.base ?? config.base),
|
|
248
|
+
});
|
|
249
|
+
const baseNormalized = siteBase.replace(/\/+$/, "");
|
|
250
|
+
return `${baseNormalized}${relative}`;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function getRelativeLocaleUrlList(
|
|
254
|
+
path = "",
|
|
255
|
+
options?: GetLocaleOptions,
|
|
256
|
+
): string[] {
|
|
257
|
+
const config = options?.config ?? activeI18nConfig;
|
|
258
|
+
return config.locales.map((entry) => {
|
|
259
|
+
const code = typeof entry === "string" ? entry : entry.codes[0];
|
|
260
|
+
return getRelativeLocaleUrl(code, path, options);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function getAbsoluteLocaleUrlList(
|
|
265
|
+
path = "",
|
|
266
|
+
options?: GetLocaleOptions,
|
|
267
|
+
): string[] {
|
|
268
|
+
const config = options?.config ?? activeI18nConfig;
|
|
269
|
+
return config.locales.map((entry) => {
|
|
270
|
+
const code = typeof entry === "string" ? entry : entry.codes[0];
|
|
271
|
+
return getAbsoluteLocaleUrl(code, path, options);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function extractLocaleSegmentFromPathname(
|
|
276
|
+
pathname: string,
|
|
277
|
+
config: AstroI18nConfig,
|
|
278
|
+
): { locale?: string; localePath?: string; restPath: string } {
|
|
279
|
+
const base = (config.base ?? "").replace(/^\/+|\/+$/g, "");
|
|
280
|
+
let stripped = pathname;
|
|
281
|
+
if (base && (stripped === `/${base}` || stripped.startsWith(`/${base}/`))) {
|
|
282
|
+
stripped = stripped.slice(base.length + 1) || "/";
|
|
283
|
+
}
|
|
284
|
+
const parts = stripped.split("/").filter(Boolean);
|
|
285
|
+
const first = parts[0];
|
|
286
|
+
if (!first) {
|
|
287
|
+
return { restPath: "/" };
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
const locale = getLocaleByPath(first, config);
|
|
291
|
+
const rest = "/" + parts.slice(1).join("/");
|
|
292
|
+
return { locale, localePath: first, restPath: rest };
|
|
293
|
+
} catch {
|
|
294
|
+
return { restPath: stripped };
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function redirectToDefaultLocale(
|
|
299
|
+
context: APIContext,
|
|
300
|
+
statusCode: ValidRedirectStatus = 302,
|
|
301
|
+
): Response {
|
|
302
|
+
const config = activeI18nConfig;
|
|
303
|
+
const target = getRelativeLocaleUrl(
|
|
304
|
+
config.defaultLocale,
|
|
305
|
+
context.url.pathname === "/" ? "" : context.url.pathname,
|
|
306
|
+
{ config },
|
|
307
|
+
);
|
|
308
|
+
return context.redirect(target + context.url.search, statusCode);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function redirectToFallback(
|
|
312
|
+
context: APIContext,
|
|
313
|
+
response: Response,
|
|
314
|
+
): Promise<Response> | Response {
|
|
315
|
+
if (response.status < 300 || !activeI18nConfig.fallback) {
|
|
316
|
+
return response;
|
|
317
|
+
}
|
|
318
|
+
const config = activeI18nConfig;
|
|
319
|
+
const routing = resolveRoutingOptions(config);
|
|
320
|
+
const { locale, restPath } = extractLocaleSegmentFromPathname(
|
|
321
|
+
context.url.pathname,
|
|
322
|
+
config,
|
|
323
|
+
);
|
|
324
|
+
if (!locale) {
|
|
325
|
+
return response;
|
|
326
|
+
}
|
|
327
|
+
const fallbackLocale = config.fallback?.[locale];
|
|
328
|
+
if (!fallbackLocale) {
|
|
329
|
+
return response;
|
|
330
|
+
}
|
|
331
|
+
const targetPath = getRelativeLocaleUrl(fallbackLocale, restPath, { config });
|
|
332
|
+
if (routing.fallbackType === "rewrite") {
|
|
333
|
+
return context.rewrite(targetPath + context.url.search);
|
|
334
|
+
}
|
|
335
|
+
return context.redirect(targetPath + context.url.search, 302);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function notFound(context: APIContext, response?: Response): Response {
|
|
339
|
+
if (response && response.headers.get("x-astro-reroute") === "no") {
|
|
340
|
+
return response;
|
|
341
|
+
}
|
|
342
|
+
const config = activeI18nConfig;
|
|
343
|
+
const routing = resolveRoutingOptions(config);
|
|
344
|
+
const { locale } = extractLocaleSegmentFromPathname(
|
|
345
|
+
context.url.pathname,
|
|
346
|
+
config,
|
|
347
|
+
);
|
|
348
|
+
if (!locale && routing.prefixDefaultLocale) {
|
|
349
|
+
return new Response(null, {
|
|
350
|
+
status: 404,
|
|
351
|
+
headers: response?.headers,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
return (
|
|
355
|
+
response ??
|
|
356
|
+
new Response(null, {
|
|
357
|
+
status: 404,
|
|
358
|
+
})
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export function requestHasLocale(
|
|
363
|
+
locales: AstroI18nLocaleConfig[] = activeI18nConfig.locales,
|
|
364
|
+
): MiddlewareHandler {
|
|
365
|
+
const validPaths = new Set(toPaths(locales).map((p) => p.toLowerCase()));
|
|
366
|
+
return defineMiddleware(async (context, next) => {
|
|
367
|
+
const parts = context.url.pathname.split("/").filter(Boolean);
|
|
368
|
+
const hasMatch = parts.some((segment) =>
|
|
369
|
+
validPaths.has(segment.toLowerCase()),
|
|
370
|
+
);
|
|
371
|
+
if (!hasMatch) {
|
|
372
|
+
return new Response(null, { status: 404 });
|
|
373
|
+
}
|
|
374
|
+
return next();
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export function middleware(
|
|
379
|
+
options?: AstroI18nRoutingOptions,
|
|
380
|
+
): MiddlewareHandler {
|
|
381
|
+
return defineMiddleware(async (context, next) => {
|
|
382
|
+
const config = activeI18nConfig;
|
|
383
|
+
const baseRouting = resolveRoutingOptions(config);
|
|
384
|
+
const routing: Required<AstroI18nRoutingOptions> = {
|
|
385
|
+
prefixDefaultLocale:
|
|
386
|
+
options?.prefixDefaultLocale ?? baseRouting.prefixDefaultLocale,
|
|
387
|
+
redirectToDefaultLocale:
|
|
388
|
+
options?.redirectToDefaultLocale ?? baseRouting.redirectToDefaultLocale,
|
|
389
|
+
fallbackType: options?.fallbackType ?? baseRouting.fallbackType,
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const { locale } = extractLocaleSegmentFromPathname(
|
|
393
|
+
context.url.pathname,
|
|
394
|
+
config,
|
|
395
|
+
);
|
|
396
|
+
context.currentLocale = locale ?? config.defaultLocale;
|
|
397
|
+
|
|
398
|
+
if (
|
|
399
|
+
context.url.pathname === "/" &&
|
|
400
|
+
routing.prefixDefaultLocale &&
|
|
401
|
+
routing.redirectToDefaultLocale
|
|
402
|
+
) {
|
|
403
|
+
return redirectToDefaultLocale(context, 302);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const response = await next();
|
|
407
|
+
if (response.status >= 400 && config.fallback) {
|
|
408
|
+
const prevRouting = activeI18nConfig.routing;
|
|
409
|
+
activeI18nConfig = { ...config, routing };
|
|
410
|
+
try {
|
|
411
|
+
return await redirectToFallback(context, response);
|
|
412
|
+
} finally {
|
|
413
|
+
activeI18nConfig = { ...config, routing: prevRouting };
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return response;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export { middleware as i18nMiddleware };
|
package/src/index.ts
CHANGED
|
@@ -34,3 +34,267 @@ export {
|
|
|
34
34
|
} from "@tschk/moonshine";
|
|
35
35
|
export type { Resource, ResourceStatus } from "@tschk/moonshine";
|
|
36
36
|
export { crepusRenderer } from "@tschk/moonshine-dom/framework-lazy";
|
|
37
|
+
export {
|
|
38
|
+
ACTION_ERROR_CODES,
|
|
39
|
+
ActionError,
|
|
40
|
+
ActionInputError,
|
|
41
|
+
isActionError,
|
|
42
|
+
isInputError,
|
|
43
|
+
defineAction,
|
|
44
|
+
getActionQueryString,
|
|
45
|
+
actionPathToString,
|
|
46
|
+
getActionContext,
|
|
47
|
+
serializeActionResult,
|
|
48
|
+
deserializeActionResult,
|
|
49
|
+
type ActionErrorCode,
|
|
50
|
+
type ActionInputIssue,
|
|
51
|
+
type ErrorInferenceObject,
|
|
52
|
+
type SafeResult,
|
|
53
|
+
type ActionAPIContext,
|
|
54
|
+
type SchemaValidator,
|
|
55
|
+
type ActionAccept,
|
|
56
|
+
type ActionHandler,
|
|
57
|
+
type ActionClient,
|
|
58
|
+
type SerializedActionResult,
|
|
59
|
+
type AstroActionContext,
|
|
60
|
+
} from "./actions";
|
|
61
|
+
export {
|
|
62
|
+
AstroCookie,
|
|
63
|
+
AstroCookies,
|
|
64
|
+
AstroSession,
|
|
65
|
+
clearAstroSessions,
|
|
66
|
+
recordAstroActionResult,
|
|
67
|
+
createAstroGlobal,
|
|
68
|
+
withAstroContext,
|
|
69
|
+
peekAstroContext,
|
|
70
|
+
useAstro,
|
|
71
|
+
type AstroCookieGetOptions,
|
|
72
|
+
type AstroCookieSetOptions,
|
|
73
|
+
type AstroCookieDeleteOptions,
|
|
74
|
+
type AstroSessionOptions,
|
|
75
|
+
type AstroActionCallable,
|
|
76
|
+
type AstroServerIslandEntry,
|
|
77
|
+
type AstroSlotValue,
|
|
78
|
+
type AstroSlots,
|
|
79
|
+
type ValidRedirectStatus,
|
|
80
|
+
type AstroResponseInit,
|
|
81
|
+
type AstroGlobal,
|
|
82
|
+
type AstroContextInit,
|
|
83
|
+
} from "./context";
|
|
84
|
+
export {
|
|
85
|
+
defineConfig,
|
|
86
|
+
mergeConfig,
|
|
87
|
+
validateConfig,
|
|
88
|
+
passthroughImageService,
|
|
89
|
+
sharpImageService,
|
|
90
|
+
squooshImageService,
|
|
91
|
+
type ImageServiceConfig,
|
|
92
|
+
type SharpImageServiceConfig,
|
|
93
|
+
type RedirectConfig,
|
|
94
|
+
type AstroIntegration,
|
|
95
|
+
type AstroUserConfig,
|
|
96
|
+
type AstroConfig,
|
|
97
|
+
} from "./config";
|
|
98
|
+
export {
|
|
99
|
+
TRANSITION_BEFORE_PREPARATION,
|
|
100
|
+
TRANSITION_AFTER_PREPARATION,
|
|
101
|
+
TRANSITION_BEFORE_SWAP,
|
|
102
|
+
TRANSITION_AFTER_SWAP,
|
|
103
|
+
TRANSITION_PAGE_LOAD,
|
|
104
|
+
fade,
|
|
105
|
+
slide,
|
|
106
|
+
none,
|
|
107
|
+
createAnimationScope,
|
|
108
|
+
transition,
|
|
109
|
+
supportsViewTransitions,
|
|
110
|
+
isTransitionEnabled,
|
|
111
|
+
swapFunctions,
|
|
112
|
+
navigate,
|
|
113
|
+
ClientRouter,
|
|
114
|
+
ViewTransitions,
|
|
115
|
+
prefetch,
|
|
116
|
+
init,
|
|
117
|
+
getPrefetchedUrls,
|
|
118
|
+
clearPrefetchedUrls,
|
|
119
|
+
type TransitionAnimation,
|
|
120
|
+
type TransitionAnimationPair,
|
|
121
|
+
type TransitionDirectionalAnimations,
|
|
122
|
+
type AnimationOptions,
|
|
123
|
+
type Direction,
|
|
124
|
+
type NavigationOptions,
|
|
125
|
+
type ClientRouterProps,
|
|
126
|
+
type Fallback,
|
|
127
|
+
type PrefetchStrategy,
|
|
128
|
+
type PrefetchOptions,
|
|
129
|
+
type PrefetchInitOptions,
|
|
130
|
+
} from "./transitions";
|
|
131
|
+
export {
|
|
132
|
+
ZodArray,
|
|
133
|
+
ZodBoolean,
|
|
134
|
+
ZodDate,
|
|
135
|
+
ZodError,
|
|
136
|
+
ZodNumber,
|
|
137
|
+
ZodObject,
|
|
138
|
+
ZodString,
|
|
139
|
+
ZodType,
|
|
140
|
+
clearCollections,
|
|
141
|
+
createSchemaContext,
|
|
142
|
+
defineCollection,
|
|
143
|
+
extractMarkdownHeadings,
|
|
144
|
+
file,
|
|
145
|
+
getCollection,
|
|
146
|
+
getEntries,
|
|
147
|
+
getEntry,
|
|
148
|
+
getLiveCollection,
|
|
149
|
+
getLiveEntry,
|
|
150
|
+
glob,
|
|
151
|
+
matchGlobPattern,
|
|
152
|
+
parseFrontmatter,
|
|
153
|
+
parseSimpleCsv,
|
|
154
|
+
parseSimpleToml,
|
|
155
|
+
parseSimpleYaml,
|
|
156
|
+
reference,
|
|
157
|
+
registerCollections,
|
|
158
|
+
render,
|
|
159
|
+
renderSimpleMarkdownToHtml,
|
|
160
|
+
seedCollection,
|
|
161
|
+
slugifyHeading,
|
|
162
|
+
z,
|
|
163
|
+
type CollectionConfig,
|
|
164
|
+
type CollectionEntry,
|
|
165
|
+
type CollectionLoader,
|
|
166
|
+
type ContentLoader,
|
|
167
|
+
type FileLoaderOptions,
|
|
168
|
+
type FrontmatterParseResult,
|
|
169
|
+
type GenerateIdOptions,
|
|
170
|
+
type GlobLoaderOptions,
|
|
171
|
+
type ImageMetadata,
|
|
172
|
+
type InferCollectionSchema,
|
|
173
|
+
type InferObjectOutput,
|
|
174
|
+
type LoaderContext,
|
|
175
|
+
type LoaderStore,
|
|
176
|
+
type LoaderStoreEntry,
|
|
177
|
+
type MarkdownHeading,
|
|
178
|
+
type ReferenceEntry,
|
|
179
|
+
type RenderResult,
|
|
180
|
+
type RenderedContent,
|
|
181
|
+
type SafeParseResult,
|
|
182
|
+
type SchemaContext,
|
|
183
|
+
type SeedEntryInput,
|
|
184
|
+
type ZodIssue,
|
|
185
|
+
type ZodRawShape,
|
|
186
|
+
} from "./content";
|
|
187
|
+
export {
|
|
188
|
+
AstroContainer,
|
|
189
|
+
experimental_AstroContainer,
|
|
190
|
+
type AstroContainerClientRenderer,
|
|
191
|
+
type AstroContainerComponent,
|
|
192
|
+
type AstroContainerOptions,
|
|
193
|
+
type AstroContainerRenderable,
|
|
194
|
+
type AstroContainerRenderer,
|
|
195
|
+
type ContainerRenderOptions,
|
|
196
|
+
type EndpointModule,
|
|
197
|
+
} from "./container";
|
|
198
|
+
export {
|
|
199
|
+
createContext,
|
|
200
|
+
defineMiddleware,
|
|
201
|
+
sequence,
|
|
202
|
+
trySerializeLocals,
|
|
203
|
+
type APIContext,
|
|
204
|
+
type MiddlewareHandler,
|
|
205
|
+
type MiddlewareNext,
|
|
206
|
+
} from "./middleware";
|
|
207
|
+
export {
|
|
208
|
+
AstroI18nError,
|
|
209
|
+
configureI18n,
|
|
210
|
+
getAbsoluteLocaleUrl,
|
|
211
|
+
getAbsoluteLocaleUrlList,
|
|
212
|
+
getI18nConfig,
|
|
213
|
+
getLocaleByPath,
|
|
214
|
+
getPathByLocale,
|
|
215
|
+
getRelativeLocaleUrl,
|
|
216
|
+
getRelativeLocaleUrlList,
|
|
217
|
+
i18nMiddleware,
|
|
218
|
+
middleware,
|
|
219
|
+
normalizeTheLocale,
|
|
220
|
+
notFound,
|
|
221
|
+
redirectToDefaultLocale,
|
|
222
|
+
redirectToFallback,
|
|
223
|
+
requestHasLocale,
|
|
224
|
+
resetI18nConfig,
|
|
225
|
+
toCodes,
|
|
226
|
+
toPaths,
|
|
227
|
+
type AstroI18nConfig,
|
|
228
|
+
type AstroI18nLocaleConfig,
|
|
229
|
+
type AstroI18nRoutingOptions,
|
|
230
|
+
type AstroI18nRoutingStrategy,
|
|
231
|
+
type GetLocaleOptions,
|
|
232
|
+
} from "./i18n";
|
|
233
|
+
export {
|
|
234
|
+
AstroEnvError,
|
|
235
|
+
envField,
|
|
236
|
+
getEnvSource,
|
|
237
|
+
getSecret,
|
|
238
|
+
resetEnvSource,
|
|
239
|
+
setEnvSource,
|
|
240
|
+
validateEnv,
|
|
241
|
+
type AstroEnvIssue,
|
|
242
|
+
type BooleanEnvFieldOptions,
|
|
243
|
+
type EnumEnvFieldOptions,
|
|
244
|
+
type EnvAccess,
|
|
245
|
+
type EnvContext,
|
|
246
|
+
type EnvFieldBaseOptions,
|
|
247
|
+
type EnvFieldDefinition,
|
|
248
|
+
type InferEnvField,
|
|
249
|
+
type InferEnvSchema,
|
|
250
|
+
type NumberEnvFieldOptions,
|
|
251
|
+
type StringEnvFieldOptions,
|
|
252
|
+
} from "./env";
|
|
253
|
+
export {
|
|
254
|
+
configureAssets,
|
|
255
|
+
getAssetsConfig,
|
|
256
|
+
getImage,
|
|
257
|
+
getImageSync,
|
|
258
|
+
Image,
|
|
259
|
+
Picture,
|
|
260
|
+
inferImageDimensions,
|
|
261
|
+
inferRemoteSize,
|
|
262
|
+
resetAssetsConfig,
|
|
263
|
+
type AstroAssetsConfig,
|
|
264
|
+
type GetImageResult,
|
|
265
|
+
type ImageFit,
|
|
266
|
+
type ImageInputFormat,
|
|
267
|
+
type ImageOutputFormat,
|
|
268
|
+
type ImageProps,
|
|
269
|
+
type ImageQuality,
|
|
270
|
+
type ImageQualityPreset,
|
|
271
|
+
type PictureProps,
|
|
272
|
+
type ResolvedImageTransform,
|
|
273
|
+
type SrcSetValue,
|
|
274
|
+
type UnresolvedImageTransform,
|
|
275
|
+
} from "./assets";
|
|
276
|
+
export {
|
|
277
|
+
createPaginate,
|
|
278
|
+
paginate,
|
|
279
|
+
type APIRoute,
|
|
280
|
+
type CreatePaginateOptions,
|
|
281
|
+
type GetStaticPaths,
|
|
282
|
+
type GetStaticPathsItem,
|
|
283
|
+
type GetStaticPathsOptions,
|
|
284
|
+
type GetStaticPathsResult,
|
|
285
|
+
type InferGetStaticParamsType,
|
|
286
|
+
type InferGetStaticPropsType,
|
|
287
|
+
type Page,
|
|
288
|
+
type PaginateFunction,
|
|
289
|
+
type PaginateOptions,
|
|
290
|
+
type Params,
|
|
291
|
+
type Props,
|
|
292
|
+
} from "./routing";
|
|
293
|
+
export {
|
|
294
|
+
defineStyleVars,
|
|
295
|
+
mergeDefineVars,
|
|
296
|
+
sourceRenderSlot,
|
|
297
|
+
transitionAnimateValue,
|
|
298
|
+
transitionPersistValue,
|
|
299
|
+
transitionPersistPropsValue,
|
|
300
|
+
} from "./ssr";
|