astro 1.5.1 → 1.5.2
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/core/build/common.js +2 -1
- package/dist/core/build/generate.js +0 -18
- package/dist/core/build/static-build.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/vite-plugin-astro-server/index.js +12 -0
- package/package.json +1 -1
|
@@ -20,7 +20,8 @@ function getOutFolder(astroConfig, pathname, routeType) {
|
|
|
20
20
|
return new URL("." + appendForwardSlash(pathname), outRoot);
|
|
21
21
|
}
|
|
22
22
|
case "file": {
|
|
23
|
-
|
|
23
|
+
const d = pathname === "" ? pathname : npath.dirname(pathname);
|
|
24
|
+
return new URL("." + appendForwardSlash(d), outRoot);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -22,24 +22,6 @@ import { getOutputFilename } from "../util.js";
|
|
|
22
22
|
import { getOutDirWithinCwd, getOutFile, getOutFolder } from "./common.js";
|
|
23
23
|
import { eachPageData, getPageDataByComponent, sortedCSS } from "./internal.js";
|
|
24
24
|
import { getTimeStat } from "./util.js";
|
|
25
|
-
const MAX_CONCURRENT_RENDERS = 1;
|
|
26
|
-
function* throttle(max, inPaths) {
|
|
27
|
-
let tmp = [];
|
|
28
|
-
let i = 0;
|
|
29
|
-
for (let path of inPaths) {
|
|
30
|
-
tmp.push(path);
|
|
31
|
-
if (i === max) {
|
|
32
|
-
yield tmp;
|
|
33
|
-
tmp.length = 0;
|
|
34
|
-
i = 0;
|
|
35
|
-
} else {
|
|
36
|
-
i++;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (tmp.length) {
|
|
40
|
-
yield tmp;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
25
|
function shouldSkipDraft(pageModule, settings) {
|
|
44
26
|
var _a;
|
|
45
27
|
return !settings.config.markdown.drafts && "frontmatter" in pageModule && ((_a = pageModule.frontmatter) == null ? void 0 : _a.draft) === true;
|
|
@@ -218,7 +218,7 @@ async function cleanSsrOutput(opts) {
|
|
|
218
218
|
const url = new URL(filename, out);
|
|
219
219
|
const folder = await fs.promises.readdir(url);
|
|
220
220
|
if (!folder.length) {
|
|
221
|
-
await fs.promises.
|
|
221
|
+
await fs.promises.rm(url, { recursive: true, force: true });
|
|
222
222
|
}
|
|
223
223
|
})
|
|
224
224
|
);
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/index.js
CHANGED
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
site,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "1.5.
|
|
50
|
+
const version = "1.5.2";
|
|
51
51
|
const rootPath = site ? site.pathname : "/";
|
|
52
52
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
53
53
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -250,7 +250,7 @@ function printHelp({
|
|
|
250
250
|
message.push(
|
|
251
251
|
linebreak(),
|
|
252
252
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
253
|
-
`v${"1.5.
|
|
253
|
+
`v${"1.5.2"}`
|
|
254
254
|
)} ${headline}`
|
|
255
255
|
);
|
|
256
256
|
}
|
|
@@ -212,6 +212,16 @@ async function handleRequest(env, manifest, req, res) {
|
|
|
212
212
|
handle500Response(viteServer, origin, req, res, errorWithMetadata);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
+
function isRedirect(statusCode) {
|
|
216
|
+
return statusCode >= 300 && statusCode < 400;
|
|
217
|
+
}
|
|
218
|
+
function throwIfRedirectNotAllowed(response, config) {
|
|
219
|
+
if (config.output !== "server" && isRedirect(response.status)) {
|
|
220
|
+
throw new Error(
|
|
221
|
+
`Redirects are only available when using output: 'server'. Update your Astro config if you need SSR features.`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
215
225
|
async function handleRoute(matchedRoute, url, pathname, body, origin, env, manifest, req, res) {
|
|
216
226
|
const { logging, settings } = env;
|
|
217
227
|
if (!matchedRoute) {
|
|
@@ -264,6 +274,7 @@ async function handleRoute(matchedRoute, url, pathname, body, origin, env, manif
|
|
|
264
274
|
res
|
|
265
275
|
);
|
|
266
276
|
}
|
|
277
|
+
throwIfRedirectNotAllowed(result.response, config);
|
|
267
278
|
await writeWebResponse(res, result.response);
|
|
268
279
|
} else {
|
|
269
280
|
let contentType = "text/plain";
|
|
@@ -283,6 +294,7 @@ async function handleRoute(matchedRoute, url, pathname, body, origin, env, manif
|
|
|
283
294
|
}
|
|
284
295
|
} else {
|
|
285
296
|
const result = await renderPage(options);
|
|
297
|
+
throwIfRedirectNotAllowed(result, config);
|
|
286
298
|
return await writeSSRResult(result, res);
|
|
287
299
|
}
|
|
288
300
|
}
|