astro 2.8.4 → 2.8.5
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/assets/utils/index.d.ts +1 -0
- package/dist/assets/utils/index.js +4 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/route-cache.js +2 -2
- package/dist/core/routing/params.d.ts +2 -2
- package/dist/core/routing/params.js +3 -3
- package/dist/vite-plugin-astro-server/route.d.ts +3 -2
- package/dist/vite-plugin-astro-server/route.js +31 -1
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { emitESMImage } from './emitAsset.js';
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -54,7 +54,7 @@ async function dev(settings, options) {
|
|
|
54
54
|
isRestart: options.isRestart
|
|
55
55
|
})
|
|
56
56
|
);
|
|
57
|
-
const currentVersion = "2.8.
|
|
57
|
+
const currentVersion = "2.8.5";
|
|
58
58
|
if (currentVersion.includes("-")) {
|
|
59
59
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
60
60
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.8.
|
|
50
|
+
const version = "2.8.5";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.8.
|
|
236
|
+
`v${"2.8.5"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -39,7 +39,7 @@ async function callGetStaticPaths({
|
|
|
39
39
|
const keyedStaticPaths = staticPaths;
|
|
40
40
|
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
|
|
41
41
|
for (const sp of keyedStaticPaths) {
|
|
42
|
-
const paramsKey = stringifyParams(sp.params, route
|
|
42
|
+
const paramsKey = stringifyParams(sp.params, route);
|
|
43
43
|
keyedStaticPaths.keyed.set(paramsKey, sp);
|
|
44
44
|
}
|
|
45
45
|
routeCache.set(route, { ...cached, staticPaths: keyedStaticPaths });
|
|
@@ -71,7 +71,7 @@ class RouteCache {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
function findPathItemByKey(staticPaths, params, route) {
|
|
74
|
-
const paramsKey = stringifyParams(params, route
|
|
74
|
+
const paramsKey = stringifyParams(params, route);
|
|
75
75
|
const matchedStaticPath = staticPaths.keyed.get(paramsKey);
|
|
76
76
|
if (matchedStaticPath) {
|
|
77
77
|
return matchedStaticPath;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetStaticPathsItem, Params } from '../../@types/astro';
|
|
1
|
+
import type { GetStaticPathsItem, Params, RouteData } from '../../@types/astro';
|
|
2
2
|
/**
|
|
3
3
|
* given an array of params like `['x', 'y', 'z']` for
|
|
4
4
|
* src/routes/[x]/[y]/[z]/svelte, create a function
|
|
@@ -10,4 +10,4 @@ export declare function getParams(array: string[]): (match: RegExpExecArray) =>
|
|
|
10
10
|
* values and create a stringified key for the route
|
|
11
11
|
* that can be used to match request routes
|
|
12
12
|
*/
|
|
13
|
-
export declare function stringifyParams(params: GetStaticPathsItem['params'],
|
|
13
|
+
export declare function stringifyParams(params: GetStaticPathsItem['params'], route: RouteData): string;
|
|
@@ -13,14 +13,14 @@ function getParams(array) {
|
|
|
13
13
|
};
|
|
14
14
|
return fn;
|
|
15
15
|
}
|
|
16
|
-
function stringifyParams(params,
|
|
16
|
+
function stringifyParams(params, route) {
|
|
17
17
|
const validatedParams = Object.entries(params).reduce((acc, next) => {
|
|
18
|
-
validateGetStaticPathsParameter(next,
|
|
18
|
+
validateGetStaticPathsParameter(next, route.component);
|
|
19
19
|
const [key, value] = next;
|
|
20
20
|
acc[key] = value == null ? void 0 : value.toString();
|
|
21
21
|
return acc;
|
|
22
22
|
}, {});
|
|
23
|
-
return JSON.stringify(
|
|
23
|
+
return JSON.stringify(route.generate(validatedParams));
|
|
24
24
|
}
|
|
25
25
|
export {
|
|
26
26
|
getParams,
|
|
@@ -3,7 +3,7 @@ import type http from 'node:http';
|
|
|
3
3
|
import type { ComponentInstance, ManifestData, RouteData, SSRManifest } from '../@types/astro';
|
|
4
4
|
import type { DevelopmentEnvironment } from '../core/render/dev/index';
|
|
5
5
|
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
6
|
-
interface MatchedRoute {
|
|
6
|
+
export interface MatchedRoute {
|
|
7
7
|
route: RouteData;
|
|
8
8
|
filePath: URL;
|
|
9
9
|
resolvedPathname: string;
|
|
@@ -22,6 +22,7 @@ type HandleRoute = {
|
|
|
22
22
|
incomingRequest: http.IncomingMessage;
|
|
23
23
|
incomingResponse: http.ServerResponse;
|
|
24
24
|
manifest: SSRManifest;
|
|
25
|
+
status?: number;
|
|
25
26
|
};
|
|
26
|
-
export declare function handleRoute({ matchedRoute, url, pathname, body, origin, env, manifestData, incomingRequest, incomingResponse, manifest, }: HandleRoute): Promise<void>;
|
|
27
|
+
export declare function handleRoute({ matchedRoute, url, pathname, status, body, origin, env, manifestData, incomingRequest, incomingResponse, manifest, }: HandleRoute): Promise<void>;
|
|
27
28
|
export {};
|
|
@@ -81,6 +81,7 @@ async function handleRoute({
|
|
|
81
81
|
matchedRoute,
|
|
82
82
|
url,
|
|
83
83
|
pathname,
|
|
84
|
+
status = getStatus(matchedRoute),
|
|
84
85
|
body,
|
|
85
86
|
origin,
|
|
86
87
|
env,
|
|
@@ -142,6 +143,7 @@ async function handleRoute({
|
|
|
142
143
|
matchedRoute: fourOhFourRoute,
|
|
143
144
|
url: new URL("/404", url),
|
|
144
145
|
pathname: "/404",
|
|
146
|
+
status: 404,
|
|
145
147
|
body,
|
|
146
148
|
origin,
|
|
147
149
|
env,
|
|
@@ -171,10 +173,38 @@ async function handleRoute({
|
|
|
171
173
|
}
|
|
172
174
|
} else {
|
|
173
175
|
const result = await renderPage(options);
|
|
176
|
+
if (result.status === 404) {
|
|
177
|
+
const fourOhFourRoute = await matchRoute("/404", env, manifestData);
|
|
178
|
+
return handleRoute({
|
|
179
|
+
...options,
|
|
180
|
+
matchedRoute: fourOhFourRoute,
|
|
181
|
+
url: new URL(pathname, url),
|
|
182
|
+
status: 404,
|
|
183
|
+
body,
|
|
184
|
+
origin,
|
|
185
|
+
env,
|
|
186
|
+
manifestData,
|
|
187
|
+
incomingRequest,
|
|
188
|
+
incomingResponse,
|
|
189
|
+
manifest
|
|
190
|
+
});
|
|
191
|
+
}
|
|
174
192
|
throwIfRedirectNotAllowed(result, config);
|
|
175
|
-
|
|
193
|
+
let response = result;
|
|
194
|
+
if (status && response.status !== status) {
|
|
195
|
+
response = new Response(result.body, { ...result, status });
|
|
196
|
+
}
|
|
197
|
+
return await writeSSRResult(request, response, incomingResponse);
|
|
176
198
|
}
|
|
177
199
|
}
|
|
200
|
+
function getStatus(matchedRoute) {
|
|
201
|
+
if (!matchedRoute)
|
|
202
|
+
return 404;
|
|
203
|
+
if (matchedRoute.route.route === "/404")
|
|
204
|
+
return 404;
|
|
205
|
+
if (matchedRoute.route.route === "/500")
|
|
206
|
+
return 500;
|
|
207
|
+
}
|
|
178
208
|
export {
|
|
179
209
|
handleRoute,
|
|
180
210
|
matchRoute
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.5",
|
|
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",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"./components": "./components/index.ts",
|
|
53
53
|
"./components/*": "./components/*",
|
|
54
54
|
"./assets": "./dist/assets/index.js",
|
|
55
|
+
"./assets/utils": "./dist/assets/utils/index.js",
|
|
55
56
|
"./assets/image-endpoint": "./dist/assets/image-endpoint.js",
|
|
56
57
|
"./assets/services/sharp": "./dist/assets/services/sharp.js",
|
|
57
58
|
"./assets/services/squoosh": "./dist/assets/services/squoosh.js",
|