astro 4.5.12 → 4.5.13
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/components/Code.astro +1 -1
- package/dist/@types/astro.d.ts +56 -19
- package/dist/assets/utils/vendor/image-size/types/svg.js +0 -1
- package/dist/assets/vite-plugin-assets.js +45 -46
- package/dist/cli/install-package.js +0 -1
- package/dist/content/vite-plugin-content-assets.js +1 -0
- package/dist/core/constants.d.ts +40 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.d.ts +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.d.ts +4 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/polyfill.d.ts +4 -0
- package/dist/core/render-context.d.ts +4 -0
- package/dist/core/request.d.ts +7 -0
- package/dist/runtime/server/jsx.js +1 -1
- package/dist/runtime/server/render/any.js +4 -1
- package/dist/runtime/server/render/page.js +2 -2
- package/dist/runtime/server/render/util.d.ts +1 -0
- package/dist/runtime/server/render/util.js +29 -16
- package/dist/transitions/router.js +1 -1
- package/dist/vite-plugin-astro-server/request.js +0 -2
- package/dist/vite-plugin-astro-server/route.js +0 -3
- package/dist/vite-plugin-markdown/index.js +3 -0
- package/package.json +3 -3
package/components/Code.astro
CHANGED
|
@@ -87,7 +87,7 @@ const highlighter = await getCachedHighlighter({
|
|
|
87
87
|
wrap,
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
const html = highlighter.highlight(code, typeof lang === 'string' ? lang : lang.name, {
|
|
90
|
+
const html = await highlighter.highlight(code, typeof lang === 'string' ? lang : lang.name, {
|
|
91
91
|
inline,
|
|
92
92
|
attributes: rest as any,
|
|
93
93
|
});
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import type { OutgoingHttpHeaders } from 'node:http';
|
|
4
4
|
import type { AddressInfo } from 'node:net';
|
|
5
|
-
import type { MarkdownHeading,
|
|
5
|
+
import type { MarkdownHeading, MarkdownVFile, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
|
|
6
6
|
import type * as babel from '@babel/core';
|
|
7
7
|
import type * as rollup from 'rollup';
|
|
8
8
|
import type * as vite from 'vite';
|
|
@@ -23,7 +23,7 @@ import type { TransitionBeforePreparationEvent, TransitionBeforeSwapEvent } from
|
|
|
23
23
|
import type { DeepPartial, OmitIndexSignature, Simplify } from '../type-utils.js';
|
|
24
24
|
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
|
25
25
|
export { type AstroIntegrationLogger };
|
|
26
|
-
export type { MarkdownHeading,
|
|
26
|
+
export type { MarkdownHeading, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
|
|
27
27
|
export type { ExternalImageService, ImageService, LocalImageService, } from '../assets/services/service.js';
|
|
28
28
|
export type { GetImageResult, ImageInputFormat, ImageMetadata, ImageOutputFormat, ImageQuality, ImageQualityPreset, ImageTransform, UnresolvedImageTransform, } from '../assets/types.js';
|
|
29
29
|
export type { RemotePattern } from '../assets/utils/remotePattern.js';
|
|
@@ -1986,6 +1986,19 @@ export type JSXTransformFn = (options: {
|
|
|
1986
1986
|
export interface ManifestData {
|
|
1987
1987
|
routes: RouteData[];
|
|
1988
1988
|
}
|
|
1989
|
+
/** @deprecated Type is no longer used by exported APIs */
|
|
1990
|
+
export interface MarkdownMetadata {
|
|
1991
|
+
headings: MarkdownHeading[];
|
|
1992
|
+
source: string;
|
|
1993
|
+
html: string;
|
|
1994
|
+
}
|
|
1995
|
+
/** @deprecated Type is no longer used by exported APIs */
|
|
1996
|
+
export interface MarkdownRenderingResult {
|
|
1997
|
+
metadata: MarkdownMetadata;
|
|
1998
|
+
vfile: MarkdownVFile;
|
|
1999
|
+
code: string;
|
|
2000
|
+
}
|
|
2001
|
+
/** @deprecated Type is no longer used by exported APIs */
|
|
1989
2002
|
export interface MarkdownParserResponse extends MarkdownRenderingResult {
|
|
1990
2003
|
frontmatter: MD['frontmatter'];
|
|
1991
2004
|
}
|
|
@@ -2112,7 +2125,9 @@ export interface AstroAdapter {
|
|
|
2112
2125
|
export type ValidRedirectStatus = 300 | 301 | 302 | 303 | 304 | 307 | 308;
|
|
2113
2126
|
interface AstroSharedContext<Props extends Record<string, any> = Record<string, any>, RouteParams extends Record<string, string | undefined> = Record<string, string | undefined>> {
|
|
2114
2127
|
/**
|
|
2115
|
-
* The address (usually IP address) of the user.
|
|
2128
|
+
* The address (usually IP address) of the user.
|
|
2129
|
+
*
|
|
2130
|
+
* Throws an error if used within a static site, or within a prerendered page.
|
|
2116
2131
|
*/
|
|
2117
2132
|
clientAddress: string;
|
|
2118
2133
|
/**
|
|
@@ -2156,12 +2171,30 @@ interface AstroSharedContext<Props extends Record<string, any> = Record<string,
|
|
|
2156
2171
|
*/
|
|
2157
2172
|
currentLocale: string | undefined;
|
|
2158
2173
|
}
|
|
2174
|
+
/**
|
|
2175
|
+
* The `APIContext` is the object made available to endpoints and middleware.
|
|
2176
|
+
* It is a subset of the `Astro` global object available in pages.
|
|
2177
|
+
*
|
|
2178
|
+
* [Reference](https://docs.astro.build/en/reference/api-reference/#endpoint-context)
|
|
2179
|
+
*/
|
|
2159
2180
|
export interface APIContext<Props extends Record<string, any> = Record<string, any>, APIParams extends Record<string, string | undefined> = Record<string, string | undefined>> extends AstroSharedContext<Props, Params> {
|
|
2181
|
+
/**
|
|
2182
|
+
* The site provided in the astro config, parsed as an instance of `URL`, without base.
|
|
2183
|
+
* `undefined` if the site is not provided in the config.
|
|
2184
|
+
*/
|
|
2160
2185
|
site: URL | undefined;
|
|
2186
|
+
/**
|
|
2187
|
+
* A human-readable string representing the Astro version used to create the project.
|
|
2188
|
+
* For example, `"Astro v1.1.1"`.
|
|
2189
|
+
*/
|
|
2161
2190
|
generator: string;
|
|
2162
2191
|
/**
|
|
2163
|
-
*
|
|
2164
|
-
*
|
|
2192
|
+
* The url of the current request, parsed as an instance of `URL`.
|
|
2193
|
+
*
|
|
2194
|
+
* Equivalent to:
|
|
2195
|
+
* ```ts
|
|
2196
|
+
* new URL(context.request.url)
|
|
2197
|
+
* ```
|
|
2165
2198
|
*/
|
|
2166
2199
|
url: AstroSharedContext['url'];
|
|
2167
2200
|
/**
|
|
@@ -2171,6 +2204,8 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
2171
2204
|
*
|
|
2172
2205
|
* Example usage:
|
|
2173
2206
|
* ```ts
|
|
2207
|
+
* import type { APIContext } from "astro"
|
|
2208
|
+
*
|
|
2174
2209
|
* export function getStaticPaths() {
|
|
2175
2210
|
* return [
|
|
2176
2211
|
* { params: { id: '0' }, props: { name: 'Sarah' } },
|
|
@@ -2179,14 +2214,12 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
2179
2214
|
* ];
|
|
2180
2215
|
* }
|
|
2181
2216
|
*
|
|
2182
|
-
* export async function GET({ params }) {
|
|
2183
|
-
*
|
|
2184
|
-
* body: `Hello user ${params.id}!`,
|
|
2185
|
-
* }
|
|
2217
|
+
* export async function GET({ params }: APIContext) {
|
|
2218
|
+
* return new Response(`Hello user ${params.id}!`)
|
|
2186
2219
|
* }
|
|
2187
2220
|
* ```
|
|
2188
2221
|
*
|
|
2189
|
-
* [
|
|
2222
|
+
* [Reference](https://docs.astro.build/en/reference/api-reference/#contextparams)
|
|
2190
2223
|
*/
|
|
2191
2224
|
params: AstroSharedContext<Props, APIParams>['params'];
|
|
2192
2225
|
/**
|
|
@@ -2194,6 +2227,8 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
2194
2227
|
*
|
|
2195
2228
|
* Example usage:
|
|
2196
2229
|
* ```ts
|
|
2230
|
+
* import type { APIContext } from "astro"
|
|
2231
|
+
*
|
|
2197
2232
|
* export function getStaticPaths() {
|
|
2198
2233
|
* return [
|
|
2199
2234
|
* { params: { id: '0' }, props: { name: 'Sarah' } },
|
|
@@ -2202,18 +2237,16 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
2202
2237
|
* ];
|
|
2203
2238
|
* }
|
|
2204
2239
|
*
|
|
2205
|
-
* export function GET({ props }) {
|
|
2206
|
-
* return {
|
|
2207
|
-
* body: `Hello ${props.name}!`,
|
|
2208
|
-
* }
|
|
2240
|
+
* export function GET({ props }: APIContext): Response {
|
|
2241
|
+
* return new Response(`Hello ${props.name}!`);
|
|
2209
2242
|
* }
|
|
2210
2243
|
* ```
|
|
2211
2244
|
*
|
|
2212
|
-
* [
|
|
2245
|
+
* [Reference](https://docs.astro.build/en/guides/api-reference/#contextprops)
|
|
2213
2246
|
*/
|
|
2214
2247
|
props: AstroSharedContext<Props, APIParams>['props'];
|
|
2215
2248
|
/**
|
|
2216
|
-
*
|
|
2249
|
+
* Create a response that redirects to another page.
|
|
2217
2250
|
*
|
|
2218
2251
|
* Example usage:
|
|
2219
2252
|
* ```ts
|
|
@@ -2223,17 +2256,19 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
2223
2256
|
* }
|
|
2224
2257
|
* ```
|
|
2225
2258
|
*
|
|
2226
|
-
* [
|
|
2259
|
+
* [Reference](https://docs.astro.build/en/guides/api-reference/#contextredirect)
|
|
2227
2260
|
*/
|
|
2228
2261
|
redirect: AstroSharedContext['redirect'];
|
|
2229
2262
|
/**
|
|
2230
|
-
*
|
|
2263
|
+
* An object that middlewares can use to store extra information related to the request.
|
|
2264
|
+
*
|
|
2265
|
+
* It will be made available to pages as `Astro.locals`, and to endpoints as `context.locals`.
|
|
2231
2266
|
*
|
|
2232
2267
|
* Example usage:
|
|
2233
2268
|
*
|
|
2234
2269
|
* ```ts
|
|
2235
2270
|
* // src/middleware.ts
|
|
2236
|
-
* import {defineMiddleware} from "astro:middleware";
|
|
2271
|
+
* import { defineMiddleware } from "astro:middleware";
|
|
2237
2272
|
*
|
|
2238
2273
|
* export const onRequest = defineMiddleware((context, next) => {
|
|
2239
2274
|
* context.locals.greeting = "Hello!";
|
|
@@ -2248,6 +2283,8 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
2248
2283
|
* ---
|
|
2249
2284
|
* <h1>{greeting}</h1>
|
|
2250
2285
|
* ```
|
|
2286
|
+
*
|
|
2287
|
+
* [Reference](https://docs.astro.build/en/reference/api-reference/#contextlocals)
|
|
2251
2288
|
*/
|
|
2252
2289
|
locals: App.Locals;
|
|
2253
2290
|
/**
|
|
@@ -20,6 +20,50 @@ import { hashTransform, propsToFilename } from "./utils/transformToPath.js";
|
|
|
20
20
|
const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
|
|
21
21
|
const assetRegex = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})`, "i");
|
|
22
22
|
const assetRegexEnds = new RegExp(`\\.(${VALID_INPUT_FORMATS.join("|")})$`, "i");
|
|
23
|
+
const addStaticImageFactory = (settings) => {
|
|
24
|
+
return (options, hashProperties, originalFSPath) => {
|
|
25
|
+
if (!globalThis.astroAsset.staticImages) {
|
|
26
|
+
globalThis.astroAsset.staticImages = /* @__PURE__ */ new Map();
|
|
27
|
+
}
|
|
28
|
+
const ESMImportedImageSrc = isESMImportedImage(options.src) ? options.src.src : options.src;
|
|
29
|
+
const fileExtension = extname(ESMImportedImageSrc);
|
|
30
|
+
const assetPrefix = getAssetsPrefix(fileExtension, settings.config.build.assetsPrefix);
|
|
31
|
+
const finalOriginalPath = removeBase(
|
|
32
|
+
removeBase(ESMImportedImageSrc, settings.config.base),
|
|
33
|
+
assetPrefix
|
|
34
|
+
);
|
|
35
|
+
const hash = hashTransform(options, settings.config.image.service.entrypoint, hashProperties);
|
|
36
|
+
let finalFilePath;
|
|
37
|
+
let transformsForPath = globalThis.astroAsset.staticImages.get(finalOriginalPath);
|
|
38
|
+
let transformForHash = transformsForPath?.transforms.get(hash);
|
|
39
|
+
if (transformsForPath && transformForHash) {
|
|
40
|
+
finalFilePath = transformForHash.finalPath;
|
|
41
|
+
} else {
|
|
42
|
+
finalFilePath = prependForwardSlash(
|
|
43
|
+
joinPaths(
|
|
44
|
+
isESMImportedImage(options.src) ? "" : settings.config.build.assets,
|
|
45
|
+
prependForwardSlash(propsToFilename(finalOriginalPath, options, hash))
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
if (!transformsForPath) {
|
|
49
|
+
globalThis.astroAsset.staticImages.set(finalOriginalPath, {
|
|
50
|
+
originalSrcPath: originalFSPath,
|
|
51
|
+
transforms: /* @__PURE__ */ new Map()
|
|
52
|
+
});
|
|
53
|
+
transformsForPath = globalThis.astroAsset.staticImages.get(finalOriginalPath);
|
|
54
|
+
}
|
|
55
|
+
transformsForPath.transforms.set(hash, {
|
|
56
|
+
finalPath: finalFilePath,
|
|
57
|
+
transform: options
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (settings.config.build.assetsPrefix) {
|
|
61
|
+
return encodeURI(joinPaths(assetPrefix, finalFilePath));
|
|
62
|
+
} else {
|
|
63
|
+
return encodeURI(prependForwardSlash(joinPaths(settings.config.base, finalFilePath)));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
23
67
|
function assets({
|
|
24
68
|
settings,
|
|
25
69
|
mode
|
|
@@ -78,52 +122,7 @@ function assets({
|
|
|
78
122
|
if (mode != "build") {
|
|
79
123
|
return;
|
|
80
124
|
}
|
|
81
|
-
globalThis.astroAsset.addStaticImage = (
|
|
82
|
-
if (!globalThis.astroAsset.staticImages) {
|
|
83
|
-
globalThis.astroAsset.staticImages = /* @__PURE__ */ new Map();
|
|
84
|
-
}
|
|
85
|
-
const ESMImportedImageSrc = isESMImportedImage(options.src) ? options.src.src : options.src;
|
|
86
|
-
const fileExtension = extname(ESMImportedImageSrc);
|
|
87
|
-
const assetPrefix = getAssetsPrefix(fileExtension, settings.config.build.assetsPrefix);
|
|
88
|
-
const finalOriginalPath = removeBase(
|
|
89
|
-
removeBase(ESMImportedImageSrc, settings.config.base),
|
|
90
|
-
assetPrefix
|
|
91
|
-
);
|
|
92
|
-
const hash = hashTransform(
|
|
93
|
-
options,
|
|
94
|
-
settings.config.image.service.entrypoint,
|
|
95
|
-
hashProperties
|
|
96
|
-
);
|
|
97
|
-
let finalFilePath;
|
|
98
|
-
let transformsForPath = globalThis.astroAsset.staticImages.get(finalOriginalPath);
|
|
99
|
-
let transformForHash = transformsForPath?.transforms.get(hash);
|
|
100
|
-
if (transformsForPath && transformForHash) {
|
|
101
|
-
finalFilePath = transformForHash.finalPath;
|
|
102
|
-
} else {
|
|
103
|
-
finalFilePath = prependForwardSlash(
|
|
104
|
-
joinPaths(
|
|
105
|
-
isESMImportedImage(options.src) ? "" : settings.config.build.assets,
|
|
106
|
-
prependForwardSlash(propsToFilename(finalOriginalPath, options, hash))
|
|
107
|
-
)
|
|
108
|
-
);
|
|
109
|
-
if (!transformsForPath) {
|
|
110
|
-
globalThis.astroAsset.staticImages.set(finalOriginalPath, {
|
|
111
|
-
originalSrcPath: originalFSPath,
|
|
112
|
-
transforms: /* @__PURE__ */ new Map()
|
|
113
|
-
});
|
|
114
|
-
transformsForPath = globalThis.astroAsset.staticImages.get(finalOriginalPath);
|
|
115
|
-
}
|
|
116
|
-
transformsForPath.transforms.set(hash, {
|
|
117
|
-
finalPath: finalFilePath,
|
|
118
|
-
transform: options
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
if (settings.config.build.assetsPrefix) {
|
|
122
|
-
return encodeURI(joinPaths(assetPrefix, finalFilePath));
|
|
123
|
-
} else {
|
|
124
|
-
return encodeURI(prependForwardSlash(joinPaths(settings.config.base, finalFilePath)));
|
|
125
|
-
}
|
|
126
|
-
};
|
|
125
|
+
globalThis.astroAsset.addStaticImage = addStaticImageFactory(settings);
|
|
127
126
|
},
|
|
128
127
|
// In build, rewrite paths to ESM imported images in code to their final location
|
|
129
128
|
async renderChunk(code) {
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
export declare const ASTRO_VERSION: string;
|
|
2
|
+
/**
|
|
3
|
+
* The name for the header used to help rerouting behavior.
|
|
4
|
+
* When set to "no", astro will NOT try to reroute an error response to the corresponding error page, which is the default behavior that can sometimes lead to loops.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const response = new Response("keep this content as-is", {
|
|
8
|
+
* status: 404,
|
|
9
|
+
* headers: {
|
|
10
|
+
* // note that using a variable name as the key of an object needs to be wrapped in square brackets in javascript
|
|
11
|
+
* // without them, the header name will be interpreted as "REROUTE_DIRECTIVE_HEADER" instead of "X-Astro-Reroute"
|
|
12
|
+
* [REROUTE_DIRECTIVE_HEADER]: 'no',
|
|
13
|
+
* }
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
* Alternatively...
|
|
17
|
+
* ```ts
|
|
18
|
+
* response.headers.set(REROUTE_DIRECTIVE_HEADER, 'no');
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
2
21
|
export declare const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
|
|
22
|
+
/**
|
|
23
|
+
* The name for the header used to help i18n middleware, which only needs to act on "page" and "fallback" route types.
|
|
24
|
+
*/
|
|
3
25
|
export declare const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
|
|
26
|
+
/**
|
|
27
|
+
* The value of the `component` field of the default 404 page, which is used when there is no user-provided 404.astro page.
|
|
28
|
+
*/
|
|
4
29
|
export declare const DEFAULT_404_COMPONENT = "astro-default-404";
|
|
5
30
|
/**
|
|
6
31
|
* A response with one of these status codes will be rewritten
|
|
7
32
|
* with the result of rendering the respective error page.
|
|
8
33
|
*/
|
|
9
34
|
export declare const REROUTABLE_STATUS_CODES: number[];
|
|
35
|
+
/**
|
|
36
|
+
* The symbol which is used as a field on the request object to store the client address.
|
|
37
|
+
* The clientAddresss provided by the adapter (or the dev server) is stored on this field.
|
|
38
|
+
*/
|
|
10
39
|
export declare const clientAddressSymbol: unique symbol;
|
|
40
|
+
/**
|
|
41
|
+
* The symbol used as a field on the request object to store the object to be made available to Astro APIs as `locals`.
|
|
42
|
+
* Use judiciously, as locals are now stored within `RenderContext` by default. Tacking it onto request is no longer necessary.
|
|
43
|
+
*/
|
|
11
44
|
export declare const clientLocalsSymbol: unique symbol;
|
|
45
|
+
/**
|
|
46
|
+
* The symbol used as a field on the response object to keep track of streaming.
|
|
47
|
+
*
|
|
48
|
+
* It is set when the `<head>` element has been completely generated, rendered, and the response object has been passed onto the adapter.
|
|
49
|
+
*
|
|
50
|
+
* Used to provide helpful errors and warnings when headers or cookies are added during streaming, after the response has already been sent.
|
|
51
|
+
*/
|
|
12
52
|
export declare const responseSentSymbol: unique symbol;
|
|
13
53
|
export declare const SUPPORTED_MARKDOWN_FILE_EXTENSIONS: readonly [".markdown", ".mdown", ".mkdn", ".mkd", ".mdwn", ".md"];
|
|
14
54
|
export declare const MIDDLEWARE_PATH_SEGMENT_NAME = "middleware";
|
package/dist/core/constants.js
CHANGED
|
@@ -10,6 +10,6 @@ interface CreateViteOptions {
|
|
|
10
10
|
command?: 'dev' | 'build';
|
|
11
11
|
fs?: typeof nodeFs;
|
|
12
12
|
}
|
|
13
|
-
/** Return a common starting point for all Vite
|
|
13
|
+
/** Return a base vite config as a common starting point for all Vite commands. */
|
|
14
14
|
export declare function createVite(commandConfig: vite.InlineConfig, { settings, logger, mode, command, fs }: CreateViteOptions): Promise<vite.InlineConfig>;
|
|
15
15
|
export {};
|
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.5.
|
|
26
|
+
const currentVersion = "4.5.13";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
package/dist/core/messages.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { ResolvedServerUrls } from 'vite';
|
|
2
2
|
import type { ZodError } from 'zod';
|
|
3
3
|
import { type ErrorWithMetadata } from './errors/index.js';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Prestyled messages for the CLI. Used by astro CLI commands.
|
|
6
|
+
*/
|
|
7
|
+
/** Display each request being served with the path and the status code. */
|
|
5
8
|
export declare function req({ url, method, statusCode, reqTime, }: {
|
|
6
9
|
url: string;
|
|
7
10
|
statusCode: number;
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.5.
|
|
39
|
+
const version = "4.5.13";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -261,7 +261,7 @@ function printHelp({
|
|
|
261
261
|
message.push(
|
|
262
262
|
linebreak(),
|
|
263
263
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
264
|
-
`v${"4.5.
|
|
264
|
+
`v${"4.5.13"}`
|
|
265
265
|
)} ${headline}`
|
|
266
266
|
);
|
|
267
267
|
}
|
package/dist/core/polyfill.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { APIContext, AstroGlobal, AstroGlobalPartial, ComponentInstance, MiddlewareHandler, RouteData, SSRResult } from '../@types/astro.js';
|
|
2
2
|
import { AstroCookies } from './cookies/index.js';
|
|
3
3
|
import { type Pipeline } from './render/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Each request is rendered using a `RenderContext`.
|
|
6
|
+
* It contains data unique to each request. It is responsible for executing middleware, calling endpoints, and rendering the page by gathering necessary data from a `Pipeline`.
|
|
7
|
+
*/
|
|
4
8
|
export declare class RenderContext {
|
|
5
9
|
#private;
|
|
6
10
|
readonly pipeline: Pipeline;
|
package/dist/core/request.d.ts
CHANGED
|
@@ -21,5 +21,12 @@ export interface CreateRequestOptions {
|
|
|
21
21
|
*/
|
|
22
22
|
staticLike?: boolean;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Used by astro internals to create a web standard request object.
|
|
26
|
+
*
|
|
27
|
+
* The user of this function may provide the data in a runtime-agnostic way.
|
|
28
|
+
*
|
|
29
|
+
* This is used by the static build to create fake requests for prerendering, and by the dev server to convert node requests into the standard request object.
|
|
30
|
+
*/
|
|
24
31
|
export declare function createRequest({ base, url, headers, clientAddress, method, body, logger, locals, staticLike, }: CreateRequestOptions): Request;
|
|
25
32
|
export {};
|
|
@@ -100,7 +100,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
100
100
|
};
|
|
101
101
|
extractSlots2(children);
|
|
102
102
|
for (const [key, value] of Object.entries(props)) {
|
|
103
|
-
if (value["$$slot"]) {
|
|
103
|
+
if (value?.["$$slot"]) {
|
|
104
104
|
_slots[key] = value;
|
|
105
105
|
delete props[key];
|
|
106
106
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { escapeHTML, isHTMLString, markHTMLString } from "../escape.js";
|
|
2
|
+
import { isPromise } from "../util.js";
|
|
2
3
|
import { isAstroComponentInstance, isRenderTemplateResult } from "./astro/index.js";
|
|
3
4
|
import { isRenderInstance } from "./common.js";
|
|
4
5
|
import { SlotString } from "./slot.js";
|
|
5
6
|
import { renderToBufferDestination } from "./util.js";
|
|
6
7
|
async function renderChild(destination, child) {
|
|
7
|
-
child
|
|
8
|
+
if (isPromise(child)) {
|
|
9
|
+
child = await child;
|
|
10
|
+
}
|
|
8
11
|
if (child instanceof SlotString) {
|
|
9
12
|
destination.write(child);
|
|
10
13
|
} else if (isHTMLString(child)) {
|
|
@@ -2,7 +2,7 @@ import { renderComponentToString } from "./component.js";
|
|
|
2
2
|
import { isAstroComponentFactory } from "./astro/index.js";
|
|
3
3
|
import { renderToAsyncIterable, renderToReadableStream, renderToString } from "./astro/render.js";
|
|
4
4
|
import { encoder } from "./common.js";
|
|
5
|
-
import { isNode } from "./util.js";
|
|
5
|
+
import { isDeno, isNode } from "./util.js";
|
|
6
6
|
async function renderPage(result, componentFactory, props, children, streaming, route) {
|
|
7
7
|
if (!isAstroComponentFactory(componentFactory)) {
|
|
8
8
|
result._metadata.headInTree = result.componentMetadata.get(componentFactory.moduleId)?.containsHead ?? false;
|
|
@@ -27,7 +27,7 @@ async function renderPage(result, componentFactory, props, children, streaming,
|
|
|
27
27
|
result._metadata.headInTree = result.componentMetadata.get(componentFactory.moduleId)?.containsHead ?? false;
|
|
28
28
|
let body;
|
|
29
29
|
if (streaming) {
|
|
30
|
-
if (isNode) {
|
|
30
|
+
if (isNode && !isDeno) {
|
|
31
31
|
const nodeBody = await renderToAsyncIterable(
|
|
32
32
|
result,
|
|
33
33
|
componentFactory,
|
|
@@ -30,6 +30,7 @@ export declare function renderToBufferDestination(bufferRenderFunction: RenderFu
|
|
|
30
30
|
renderToFinalDestination: RenderFunction;
|
|
31
31
|
};
|
|
32
32
|
export declare const isNode: boolean;
|
|
33
|
+
export declare const isDeno: boolean;
|
|
33
34
|
export type PromiseWithResolvers<T> = {
|
|
34
35
|
promise: Promise<T>;
|
|
35
36
|
resolve: (value: T) => void;
|
|
@@ -103,25 +103,37 @@ function renderElement(name, { props: _props, children = "" }, shouldEscape = tr
|
|
|
103
103
|
}
|
|
104
104
|
return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
const noop = () => {
|
|
107
|
+
};
|
|
108
|
+
class BufferedRenderer {
|
|
109
|
+
chunks = [];
|
|
110
|
+
renderPromise;
|
|
111
|
+
destination;
|
|
112
|
+
constructor(bufferRenderFunction) {
|
|
113
|
+
this.renderPromise = bufferRenderFunction(this);
|
|
114
|
+
Promise.resolve(this.renderPromise).catch(noop);
|
|
115
|
+
}
|
|
116
|
+
write(chunk) {
|
|
117
|
+
if (this.destination) {
|
|
118
|
+
this.destination.write(chunk);
|
|
119
|
+
} else {
|
|
120
|
+
this.chunks.push(chunk);
|
|
121
121
|
}
|
|
122
|
-
}
|
|
122
|
+
}
|
|
123
|
+
async renderToFinalDestination(destination) {
|
|
124
|
+
for (const chunk of this.chunks) {
|
|
125
|
+
destination.write(chunk);
|
|
126
|
+
}
|
|
127
|
+
this.destination = destination;
|
|
128
|
+
await this.renderPromise;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function renderToBufferDestination(bufferRenderFunction) {
|
|
132
|
+
const renderer = new BufferedRenderer(bufferRenderFunction);
|
|
133
|
+
return renderer;
|
|
123
134
|
}
|
|
124
135
|
const isNode = typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]";
|
|
136
|
+
const isDeno = typeof Deno !== "undefined";
|
|
125
137
|
function promiseWithResolvers() {
|
|
126
138
|
let resolve, reject;
|
|
127
139
|
const promise = new Promise((_resolve, _reject) => {
|
|
@@ -147,6 +159,7 @@ export {
|
|
|
147
159
|
defineScriptVars,
|
|
148
160
|
formatList,
|
|
149
161
|
internalSpreadAttributes,
|
|
162
|
+
isDeno,
|
|
150
163
|
isNode,
|
|
151
164
|
promiseWithResolvers,
|
|
152
165
|
renderElement,
|
|
@@ -124,6 +124,7 @@ const moveToLocation = (to, from, options, pageTitleForBrowserHistory, historySt
|
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
document.title = targetPageTitle;
|
|
127
128
|
originalLocation = to;
|
|
128
129
|
if (!intraPage) {
|
|
129
130
|
scrollTo({ left: 0, top: 0, behavior: "instant" });
|
|
@@ -144,7 +145,6 @@ const moveToLocation = (to, from, options, pageTitleForBrowserHistory, historySt
|
|
|
144
145
|
}
|
|
145
146
|
history.scrollRestoration = "manual";
|
|
146
147
|
}
|
|
147
|
-
document.title = targetPageTitle;
|
|
148
148
|
};
|
|
149
149
|
function preloadStyleLinks(newDocument) {
|
|
150
150
|
const links = [];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { collapseDuplicateSlashes, removeTrailingForwardSlash } from "../core/path.js";
|
|
2
|
-
import { isServerLikeOutput } from "../prerender/utils.js";
|
|
3
2
|
import { runWithErrorHandling } from "./controller.js";
|
|
4
3
|
import { recordServerError } from "./error.js";
|
|
5
4
|
import { handle500Response } from "./response.js";
|
|
@@ -13,7 +12,6 @@ async function handleRequest({
|
|
|
13
12
|
}) {
|
|
14
13
|
const { config, loader } = pipeline;
|
|
15
14
|
const origin = `${loader.isHttps() ? "https" : "http"}://${incomingRequest.headers.host}`;
|
|
16
|
-
const buildingToSSR = isServerLikeOutput(config);
|
|
17
15
|
const url = new URL(collapseDuplicateSlashes(origin + incomingRequest.url));
|
|
18
16
|
let pathname;
|
|
19
17
|
if (config.trailingSlash === "never" && !incomingRequest.url) {
|
|
@@ -265,9 +265,6 @@ function getStatus(matchedRoute) {
|
|
|
265
265
|
if (matchedRoute.route.route === "/500")
|
|
266
266
|
return 500;
|
|
267
267
|
}
|
|
268
|
-
function has404Route(manifest) {
|
|
269
|
-
return manifest.routes.some((route) => route.route === "/404");
|
|
270
|
-
}
|
|
271
268
|
export {
|
|
272
269
|
handleRoute,
|
|
273
270
|
matchRoute
|
|
@@ -26,6 +26,9 @@ function markdown({ settings, logger }) {
|
|
|
26
26
|
async buildStart() {
|
|
27
27
|
processor = await createMarkdownProcessor(settings.config.markdown);
|
|
28
28
|
},
|
|
29
|
+
buildEnd() {
|
|
30
|
+
processor = void 0;
|
|
31
|
+
},
|
|
29
32
|
// Why not the "transform" hook instead of "load" + readFile?
|
|
30
33
|
// A: Vite transforms all "import.meta.env" references to their values before
|
|
31
34
|
// passing to the transform hook. This lets us get the truly raw value
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.13",
|
|
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",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"vendor"
|
|
103
103
|
],
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@astrojs/compiler": "^2.7.
|
|
105
|
+
"@astrojs/compiler": "^2.7.1",
|
|
106
106
|
"@babel/core": "^7.24.3",
|
|
107
107
|
"@babel/generator": "^7.23.3",
|
|
108
108
|
"@babel/parser": "^7.23.3",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"zod": "^3.22.4",
|
|
163
163
|
"zod-to-json-schema": "^3.22.4",
|
|
164
164
|
"@astrojs/internal-helpers": "0.4.0",
|
|
165
|
-
"@astrojs/markdown-remark": "
|
|
165
|
+
"@astrojs/markdown-remark": "5.0.0",
|
|
166
166
|
"@astrojs/telemetry": "3.0.4"
|
|
167
167
|
},
|
|
168
168
|
"optionalDependencies": {
|