astro 4.16.6 → 4.16.8
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 -0
- package/dist/@types/astro.d.ts +6 -2
- package/dist/actions/runtime/middleware.js +10 -4
- package/dist/actions/runtime/route.js +2 -1
- package/dist/actions/runtime/virtual/get-action.js +1 -1
- package/dist/assets/endpoint/node.js +4 -0
- package/dist/cli/index.js +1 -1
- package/dist/cli/install-package.js +7 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/types-generator.js +10 -3
- package/dist/core/app/node.js +1 -1
- package/dist/core/constants.d.ts +4 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +5 -6
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/vite-plugin.js +1 -2
- package/dist/core/render-context.js +4 -30
- package/dist/core/routing/rewrite.d.ts +9 -0
- package/dist/core/routing/rewrite.js +38 -1
- package/dist/core/server-islands/endpoint.js +1 -1
- package/dist/integrations/features-validation.js +9 -7
- package/dist/runtime/server/render/astro/head-and-content.js +1 -1
- package/dist/runtime/server/render/astro/instance.js +1 -1
- package/dist/runtime/server/render/astro/render-template.js +1 -1
- package/package.json +14 -14
- package/templates/actions.mjs +1 -1
package/client.d.ts
CHANGED
|
@@ -289,6 +289,7 @@ declare module '*.mdx' {
|
|
|
289
289
|
export const url: MDX['url'];
|
|
290
290
|
export const getHeadings: MDX['getHeadings'];
|
|
291
291
|
export const Content: MDX['Content'];
|
|
292
|
+
export const components: MDX['components'];
|
|
292
293
|
|
|
293
294
|
const load: MDX['default'];
|
|
294
295
|
export default load;
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -2458,7 +2458,9 @@ export interface MarkdownInstance<T extends Record<string, any>> {
|
|
|
2458
2458
|
default: AstroComponentFactory;
|
|
2459
2459
|
}
|
|
2460
2460
|
type MD = MarkdownInstance<Record<string, any>>;
|
|
2461
|
-
export
|
|
2461
|
+
export interface MDXInstance<T extends Record<string, any>> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> {
|
|
2462
|
+
components: Record<string, AstroComponentFactory> | undefined;
|
|
2463
|
+
}
|
|
2462
2464
|
export interface MarkdownLayoutProps<T extends Record<string, any>> {
|
|
2463
2465
|
frontmatter: {
|
|
2464
2466
|
file: MarkdownInstance<T>['file'];
|
|
@@ -2470,7 +2472,9 @@ export interface MarkdownLayoutProps<T extends Record<string, any>> {
|
|
|
2470
2472
|
rawContent: MarkdownInstance<T>['rawContent'];
|
|
2471
2473
|
compiledContent: MarkdownInstance<T>['compiledContent'];
|
|
2472
2474
|
}
|
|
2473
|
-
export
|
|
2475
|
+
export interface MDXLayoutProps<T extends Record<string, any>> extends Omit<MarkdownLayoutProps<T>, 'rawContent' | 'compiledContent'> {
|
|
2476
|
+
components: MDXInstance<T>['components'];
|
|
2477
|
+
}
|
|
2474
2478
|
export type GetHydrateCallback = () => Promise<() => void | Promise<void>>;
|
|
2475
2479
|
/**
|
|
2476
2480
|
* getStaticPaths() options
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { yellow } from "kleur/colors";
|
|
2
2
|
import { defineMiddleware } from "../../core/middleware/index.js";
|
|
3
|
+
import { getOriginPathname } from "../../core/routing/rewrite.js";
|
|
3
4
|
import { ACTION_QUERY_PARAMS } from "../consts.js";
|
|
4
5
|
import { formContentTypes, hasContentType } from "./utils.js";
|
|
5
6
|
import { getAction } from "./virtual/get-action.js";
|
|
@@ -11,7 +12,7 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
11
12
|
if (context.request.method === "POST") {
|
|
12
13
|
console.warn(
|
|
13
14
|
yellow("[astro:actions]"),
|
|
14
|
-
|
|
15
|
+
"POST requests should not be sent to prerendered pages. If you're using Actions, disable prerendering with `export const prerender = false`."
|
|
15
16
|
);
|
|
16
17
|
}
|
|
17
18
|
return next();
|
|
@@ -62,7 +63,8 @@ async function handlePost({
|
|
|
62
63
|
if (contentType && hasContentType(contentType, formContentTypes)) {
|
|
63
64
|
formData = await request.clone().formData();
|
|
64
65
|
}
|
|
65
|
-
const
|
|
66
|
+
const { getActionResult, callAction, props, redirect, ...actionAPIContext } = context;
|
|
67
|
+
const action = baseAction.bind(actionAPIContext);
|
|
66
68
|
const actionResult = await action(formData);
|
|
67
69
|
if (context.url.searchParams.get(ACTION_QUERY_PARAMS.actionRedirect) === "false") {
|
|
68
70
|
return renderResult({
|
|
@@ -84,10 +86,14 @@ async function redirectWithResult({
|
|
|
84
86
|
actionResult: serializeActionResult(actionResult)
|
|
85
87
|
});
|
|
86
88
|
if (actionResult.error) {
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
89
|
+
const referer2 = context.request.headers.get("Referer");
|
|
90
|
+
if (!referer2) {
|
|
89
91
|
throw new Error("Internal: Referer unexpectedly missing from Action POST request.");
|
|
90
92
|
}
|
|
93
|
+
return context.redirect(referer2);
|
|
94
|
+
}
|
|
95
|
+
const referer = getOriginPathname(context.request);
|
|
96
|
+
if (referer) {
|
|
91
97
|
return context.redirect(referer);
|
|
92
98
|
}
|
|
93
99
|
return context.redirect(context.url.pathname);
|
|
@@ -23,7 +23,8 @@ const POST = async (context) => {
|
|
|
23
23
|
} else {
|
|
24
24
|
return new Response(null, { status: 415 });
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const { getActionResult, callAction, props, redirect, ...actionAPIContext } = context;
|
|
27
|
+
const action = baseAction.bind(actionAPIContext);
|
|
27
28
|
const result = await action(args);
|
|
28
29
|
const serialized = serializeActionResult(result);
|
|
29
30
|
if (serialized.type === "empty") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ActionNotFoundError } from "../../../core/errors/errors-data.js";
|
|
2
2
|
import { AstroError } from "../../../core/errors/errors.js";
|
|
3
3
|
async function getAction(path) {
|
|
4
|
-
const pathKeys = path.replace(
|
|
4
|
+
const pathKeys = path.replace(/^.*\/_actions\//, "").split(".").map((key) => decodeURIComponent(key));
|
|
5
5
|
let { server: actionLookup } = await import("astro:internal-actions");
|
|
6
6
|
if (actionLookup == null || !(typeof actionLookup === "object")) {
|
|
7
7
|
throw new TypeError(
|
|
@@ -18,6 +18,10 @@ async function loadLocalImage(src, url) {
|
|
|
18
18
|
fileUrl = pathToFileURL(removeQueryString(replaceFileSystemReferences(src)));
|
|
19
19
|
} else {
|
|
20
20
|
try {
|
|
21
|
+
const idx = url.pathname.indexOf("/_image");
|
|
22
|
+
if (idx > 0) {
|
|
23
|
+
src = src.slice(idx);
|
|
24
|
+
}
|
|
21
25
|
fileUrl = new URL("." + src, outDir);
|
|
22
26
|
const filePath = fileURLToPath(fileUrl);
|
|
23
27
|
if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
|
package/dist/cli/index.js
CHANGED
|
@@ -109,7 +109,13 @@ ${message}`
|
|
|
109
109
|
await exec(
|
|
110
110
|
installCommand.pm,
|
|
111
111
|
[installCommand.command, ...installCommand.flags, ...installCommand.dependencies],
|
|
112
|
-
{
|
|
112
|
+
{
|
|
113
|
+
nodeOptions: {
|
|
114
|
+
cwd,
|
|
115
|
+
// reset NODE_ENV to ensure install command run in dev mode
|
|
116
|
+
env: { NODE_ENV: void 0 }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
113
119
|
);
|
|
114
120
|
spinner.succeed();
|
|
115
121
|
return true;
|
|
@@ -121,7 +121,7 @@ class ContentLayer {
|
|
|
121
121
|
logger.info("Content config changed");
|
|
122
122
|
shouldClear = true;
|
|
123
123
|
}
|
|
124
|
-
if (previousAstroVersion !== "4.16.
|
|
124
|
+
if (previousAstroVersion !== "4.16.8") {
|
|
125
125
|
logger.info("Astro version changed");
|
|
126
126
|
shouldClear = true;
|
|
127
127
|
}
|
|
@@ -129,8 +129,8 @@ class ContentLayer {
|
|
|
129
129
|
logger.info("Clearing content store");
|
|
130
130
|
this.#store.clearAll();
|
|
131
131
|
}
|
|
132
|
-
if ("4.16.
|
|
133
|
-
await this.#store.metaStore().set("astro-version", "4.16.
|
|
132
|
+
if ("4.16.8") {
|
|
133
|
+
await this.#store.metaStore().set("astro-version", "4.16.8");
|
|
134
134
|
}
|
|
135
135
|
if (currentConfigDigest) {
|
|
136
136
|
await this.#store.metaStore().set("config-digest", currentConfigDigest);
|
|
@@ -5,7 +5,6 @@ import { bold, cyan } from "kleur/colors";
|
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
8
|
-
import { printNode, zodToTs } from "zod-to-ts";
|
|
9
8
|
import { AstroError } from "../core/errors/errors.js";
|
|
10
9
|
import { AstroErrorData } from "../core/errors/index.js";
|
|
11
10
|
import { isRelativePath } from "../core/path.js";
|
|
@@ -294,8 +293,16 @@ async function typeForCollection(collection, collectionKey) {
|
|
|
294
293
|
if (collection?.type === CONTENT_LAYER_TYPE) {
|
|
295
294
|
const schema = await getContentLayerSchema(collection, collectionKey);
|
|
296
295
|
if (schema) {
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
try {
|
|
297
|
+
const zodToTs = await import("zod-to-ts");
|
|
298
|
+
const ast = zodToTs.zodToTs(schema);
|
|
299
|
+
return zodToTs.printNode(ast.node);
|
|
300
|
+
} catch (err) {
|
|
301
|
+
if (err.message.includes("Cannot find package 'typescript'")) {
|
|
302
|
+
return "any";
|
|
303
|
+
}
|
|
304
|
+
throw err;
|
|
305
|
+
}
|
|
299
306
|
}
|
|
300
307
|
}
|
|
301
308
|
return "any";
|
package/dist/core/app/node.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { Http2ServerResponse } from "node:http2";
|
|
3
|
+
import { clientAddressSymbol } from "../constants.js";
|
|
3
4
|
import { deserializeManifest } from "./common.js";
|
|
4
5
|
import { createOutgoingHttpHeaders } from "./createOutgoingHttpHeaders.js";
|
|
5
6
|
import { App } from "./index.js";
|
|
6
7
|
import { apply } from "../polyfill.js";
|
|
7
|
-
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
8
8
|
class NodeApp extends App {
|
|
9
9
|
match(req) {
|
|
10
10
|
if (!(req instanceof Request)) {
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -57,6 +57,10 @@ export declare const clientAddressSymbol: unique symbol;
|
|
|
57
57
|
* Use judiciously, as locals are now stored within `RenderContext` by default. Tacking it onto request is no longer necessary.
|
|
58
58
|
*/
|
|
59
59
|
export declare const clientLocalsSymbol: unique symbol;
|
|
60
|
+
/**
|
|
61
|
+
* Use this symbol to set and retrieve the original pathname of a request. This is useful when working with redirects and rewrites
|
|
62
|
+
*/
|
|
63
|
+
export declare const originPathnameSymbol: unique symbol;
|
|
60
64
|
/**
|
|
61
65
|
* The symbol used as a field on the response object to keep track of streaming.
|
|
62
66
|
*
|
package/dist/core/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const ASTRO_VERSION = "4.16.
|
|
1
|
+
const ASTRO_VERSION = "4.16.8";
|
|
2
2
|
const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
|
|
3
3
|
const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
|
|
4
4
|
const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
|
|
@@ -9,6 +9,7 @@ const REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308, 300, 304];
|
|
|
9
9
|
const REROUTABLE_STATUS_CODES = [404, 500];
|
|
10
10
|
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
11
11
|
const clientLocalsSymbol = Symbol.for("astro.locals");
|
|
12
|
+
const originPathnameSymbol = Symbol.for("astro.originPathname");
|
|
12
13
|
const responseSentSymbol = Symbol.for("astro.responseSent");
|
|
13
14
|
const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
|
|
14
15
|
".markdown",
|
|
@@ -33,5 +34,6 @@ export {
|
|
|
33
34
|
SUPPORTED_MARKDOWN_FILE_EXTENSIONS,
|
|
34
35
|
clientAddressSymbol,
|
|
35
36
|
clientLocalsSymbol,
|
|
37
|
+
originPathnameSymbol,
|
|
36
38
|
responseSentSymbol
|
|
37
39
|
};
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "4.16.
|
|
25
|
+
const currentVersion = "4.16.8";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
|
@@ -405,8 +405,8 @@ export declare const PageNumberParamNotFound: {
|
|
|
405
405
|
* @docs
|
|
406
406
|
* @see
|
|
407
407
|
* - [Images](https://docs.astro.build/en/guides/images/)
|
|
408
|
-
* - [Image component](https://docs.astro.build/en/
|
|
409
|
-
* - [Image component#alt](https://docs.astro.build/en/
|
|
408
|
+
* - [Image component](https://docs.astro.build/en/reference/modules/astro-assets/#image-)
|
|
409
|
+
* - [Image component#alt](https://docs.astro.build/en/reference/modules/astro-assets/#alt-required)
|
|
410
410
|
* @description
|
|
411
411
|
* The `alt` property allows you to provide descriptive alt text to users of screen readers and other assistive technologies. In order to ensure your images are accessible, the `Image` component requires that an `alt` be specified.
|
|
412
412
|
*
|
|
@@ -438,9 +438,9 @@ export declare const InvalidImageService: {
|
|
|
438
438
|
* Missing width and height attributes for `IMAGE_URL`. When using remote images, both dimensions are required in order to avoid cumulative layout shift (CLS).
|
|
439
439
|
* @see
|
|
440
440
|
* - [Images](https://docs.astro.build/en/guides/images/)
|
|
441
|
-
* - [Image component#width-and-height-required](https://docs.astro.build/en/
|
|
441
|
+
* - [Image component#width-and-height-required](https://docs.astro.build/en/reference/modules/astro-assets/#width-and-height-required-for-images-in-public)
|
|
442
442
|
* @description
|
|
443
|
-
* For remote images, `width` and `height` cannot automatically be inferred from the original file. To avoid cumulative layout shift (CLS), either specify these two properties, or set [`inferSize`](https://docs.astro.build/en/
|
|
443
|
+
* For remote images, `width` and `height` cannot automatically be inferred from the original file. To avoid cumulative layout shift (CLS), either specify these two properties, or set [`inferSize`](https://docs.astro.build/en/reference/modules/astro-assets/#infersize) to `true` to fetch a remote image's original dimensions.
|
|
444
444
|
*
|
|
445
445
|
* If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets).
|
|
446
446
|
*/
|
|
@@ -841,7 +841,6 @@ export declare const InvalidDynamicRoute: {
|
|
|
841
841
|
* @docs
|
|
842
842
|
* @see
|
|
843
843
|
* - [Default Image Service](https://docs.astro.build/en/guides/images/#default-image-service)
|
|
844
|
-
* - [Image Component](https://docs.astro.build/en/guides/images/#image--astroassets)
|
|
845
844
|
* - [Image Services API](https://docs.astro.build/en/reference/image-service-reference/)
|
|
846
845
|
* @description
|
|
847
846
|
* Sharp is the default image service used for `astro:assets`. When using a [strict package manager](https://pnpm.io/pnpm-vs-npm#npms-flat-tree) like pnpm, Sharp must be installed manually into your project in order to use image processing.
|
|
@@ -1419,7 +1418,7 @@ export declare const ActionsWithoutServerOutputError: {
|
|
|
1419
1418
|
/**
|
|
1420
1419
|
* @docs
|
|
1421
1420
|
* @see
|
|
1422
|
-
* - [Actions handler reference](https://docs.astro.build/en/reference/
|
|
1421
|
+
* - [Actions handler reference](https://docs.astro.build/en/reference/modules/astro-actions/#handler-property)
|
|
1423
1422
|
* @description
|
|
1424
1423
|
* Action handler returned invalid data. Handlers should return serializable data types, and cannot return a Response object.
|
|
1425
1424
|
*/
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "4.16.
|
|
41
|
+
const version = "4.16.8";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -270,7 +270,7 @@ function printHelp({
|
|
|
270
270
|
message.push(
|
|
271
271
|
linebreak(),
|
|
272
272
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
273
|
-
`v${"4.16.
|
|
273
|
+
`v${"4.16.8"}`
|
|
274
274
|
)} ${headline}`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
@@ -13,9 +13,8 @@ function vitePluginMiddleware({ settings }) {
|
|
|
13
13
|
let userMiddlewareIsPresent = false;
|
|
14
14
|
return {
|
|
15
15
|
name: "@astro/plugin-middleware",
|
|
16
|
-
config(
|
|
16
|
+
config(_, { command }) {
|
|
17
17
|
isCommandBuild = command === "build";
|
|
18
|
-
return opts;
|
|
19
18
|
},
|
|
20
19
|
async resolveId(id) {
|
|
21
20
|
if (id === MIDDLEWARE_MODULE_ID) {
|
|
@@ -24,6 +24,7 @@ import { callMiddleware } from "./middleware/callMiddleware.js";
|
|
|
24
24
|
import { sequence } from "./middleware/index.js";
|
|
25
25
|
import { renderRedirect } from "./redirects/render.js";
|
|
26
26
|
import { Slots, getParams, getProps } from "./render/index.js";
|
|
27
|
+
import { copyRequest, setOriginPathname } from "./routing/rewrite.js";
|
|
27
28
|
const apiContextRoutesSymbol = Symbol.for("context.routes");
|
|
28
29
|
class RenderContext {
|
|
29
30
|
constructor(pipeline, locals, middleware, pathname, request, routeData, status, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url), props = {}, partial = void 0) {
|
|
@@ -60,6 +61,7 @@ class RenderContext {
|
|
|
60
61
|
partial = void 0
|
|
61
62
|
}) {
|
|
62
63
|
const pipelineMiddleware = await pipeline.getMiddleware();
|
|
64
|
+
setOriginPathname(request, pathname);
|
|
63
65
|
return new RenderContext(
|
|
64
66
|
pipeline,
|
|
65
67
|
locals,
|
|
@@ -121,7 +123,7 @@ class RenderContext {
|
|
|
121
123
|
if (payload instanceof Request) {
|
|
122
124
|
this.request = payload;
|
|
123
125
|
} else {
|
|
124
|
-
this.request =
|
|
126
|
+
this.request = copyRequest(newUrl, this.request);
|
|
125
127
|
}
|
|
126
128
|
this.isRewriting = true;
|
|
127
129
|
this.url = new URL(this.request.url);
|
|
@@ -205,7 +207,7 @@ class RenderContext {
|
|
|
205
207
|
if (reroutePayload instanceof Request) {
|
|
206
208
|
this.request = reroutePayload;
|
|
207
209
|
} else {
|
|
208
|
-
this.request =
|
|
210
|
+
this.request = copyRequest(newUrl, this.request);
|
|
209
211
|
}
|
|
210
212
|
this.url = new URL(this.request.url);
|
|
211
213
|
this.cookies = new AstroCookies(this.request);
|
|
@@ -461,34 +463,6 @@ class RenderContext {
|
|
|
461
463
|
if (!i18n) return;
|
|
462
464
|
return this.#preferredLocaleList ??= computePreferredLocaleList(request, i18n.locales);
|
|
463
465
|
}
|
|
464
|
-
/**
|
|
465
|
-
* Utility function that creates a new `Request` with a new URL from an old `Request`.
|
|
466
|
-
*
|
|
467
|
-
* @param newUrl The new `URL`
|
|
468
|
-
* @param oldRequest The old `Request`
|
|
469
|
-
*/
|
|
470
|
-
#copyRequest(newUrl, oldRequest) {
|
|
471
|
-
if (oldRequest.bodyUsed) {
|
|
472
|
-
throw new AstroError(AstroErrorData.RewriteWithBodyUsed);
|
|
473
|
-
}
|
|
474
|
-
return new Request(newUrl, {
|
|
475
|
-
method: oldRequest.method,
|
|
476
|
-
headers: oldRequest.headers,
|
|
477
|
-
body: oldRequest.body,
|
|
478
|
-
referrer: oldRequest.referrer,
|
|
479
|
-
referrerPolicy: oldRequest.referrerPolicy,
|
|
480
|
-
mode: oldRequest.mode,
|
|
481
|
-
credentials: oldRequest.credentials,
|
|
482
|
-
cache: oldRequest.cache,
|
|
483
|
-
redirect: oldRequest.redirect,
|
|
484
|
-
integrity: oldRequest.integrity,
|
|
485
|
-
signal: oldRequest.signal,
|
|
486
|
-
keepalive: oldRequest.keepalive,
|
|
487
|
-
// https://fetch.spec.whatwg.org/#dom-request-duplex
|
|
488
|
-
// @ts-expect-error It isn't part of the types, but undici accepts it and it allows to carry over the body to a new request
|
|
489
|
-
duplex: "half"
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
466
|
}
|
|
493
467
|
export {
|
|
494
468
|
RenderContext,
|
|
@@ -18,3 +18,12 @@ export interface FindRouteToRewriteResult {
|
|
|
18
18
|
* 2.
|
|
19
19
|
*/
|
|
20
20
|
export declare function findRouteToRewrite({ payload, routes, request, trailingSlash, buildFormat, base, }: FindRouteToRewrite): FindRouteToRewriteResult;
|
|
21
|
+
/**
|
|
22
|
+
* Utility function that creates a new `Request` with a new URL from an old `Request`.
|
|
23
|
+
*
|
|
24
|
+
* @param newUrl The new `URL`
|
|
25
|
+
* @param oldRequest The old `Request`
|
|
26
|
+
*/
|
|
27
|
+
export declare function copyRequest(newUrl: URL, oldRequest: Request): Request;
|
|
28
|
+
export declare function setOriginPathname(request: Request, pathname: string): void;
|
|
29
|
+
export declare function getOriginPathname(request: Request): string | undefined;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { shouldAppendForwardSlash } from "../build/util.js";
|
|
2
|
+
import { originPathnameSymbol } from "../constants.js";
|
|
3
|
+
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
2
4
|
import { appendForwardSlash, removeTrailingForwardSlash } from "../path.js";
|
|
3
5
|
import { DEFAULT_404_ROUTE } from "./astro-designed-error-pages.js";
|
|
4
6
|
function findRouteToRewrite({
|
|
@@ -44,6 +46,41 @@ function findRouteToRewrite({
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
}
|
|
49
|
+
function copyRequest(newUrl, oldRequest) {
|
|
50
|
+
if (oldRequest.bodyUsed) {
|
|
51
|
+
throw new AstroError(AstroErrorData.RewriteWithBodyUsed);
|
|
52
|
+
}
|
|
53
|
+
return new Request(newUrl, {
|
|
54
|
+
method: oldRequest.method,
|
|
55
|
+
headers: oldRequest.headers,
|
|
56
|
+
body: oldRequest.body,
|
|
57
|
+
referrer: oldRequest.referrer,
|
|
58
|
+
referrerPolicy: oldRequest.referrerPolicy,
|
|
59
|
+
mode: oldRequest.mode,
|
|
60
|
+
credentials: oldRequest.credentials,
|
|
61
|
+
cache: oldRequest.cache,
|
|
62
|
+
redirect: oldRequest.redirect,
|
|
63
|
+
integrity: oldRequest.integrity,
|
|
64
|
+
signal: oldRequest.signal,
|
|
65
|
+
keepalive: oldRequest.keepalive,
|
|
66
|
+
// https://fetch.spec.whatwg.org/#dom-request-duplex
|
|
67
|
+
// @ts-expect-error It isn't part of the types, but undici accepts it and it allows to carry over the body to a new request
|
|
68
|
+
duplex: "half"
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function setOriginPathname(request, pathname) {
|
|
72
|
+
Reflect.set(request, originPathnameSymbol, encodeURIComponent(pathname));
|
|
73
|
+
}
|
|
74
|
+
function getOriginPathname(request) {
|
|
75
|
+
const origin = Reflect.get(request, originPathnameSymbol);
|
|
76
|
+
if (origin) {
|
|
77
|
+
return decodeURIComponent(origin);
|
|
78
|
+
}
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
47
81
|
export {
|
|
48
|
-
|
|
82
|
+
copyRequest,
|
|
83
|
+
findRouteToRewrite,
|
|
84
|
+
getOriginPathname,
|
|
85
|
+
setOriginPathname
|
|
49
86
|
};
|
|
@@ -30,7 +30,7 @@ function ensureServerIslandRoute(config, routeManifest) {
|
|
|
30
30
|
if (routeManifest.routes.some((route) => route.route === "/_server-islands/[name]")) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
routeManifest.routes.
|
|
33
|
+
routeManifest.routes.unshift(getServerIslandRouteData(config));
|
|
34
34
|
}
|
|
35
35
|
function createEndpoint(manifest) {
|
|
36
36
|
const page = async (result) => {
|
|
@@ -56,13 +56,15 @@ function validateSupportedFeatures(adapterName, featureMap, config, adapterFeatu
|
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
envGetSecret
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
if (config.experimental?.env) {
|
|
60
|
+
validationResult.envGetSecret = validateSupportKind(
|
|
61
|
+
envGetSecret,
|
|
62
|
+
adapterName,
|
|
63
|
+
logger,
|
|
64
|
+
"astro:env getSecret",
|
|
65
|
+
() => true
|
|
66
|
+
);
|
|
67
|
+
}
|
|
66
68
|
return validationResult;
|
|
67
69
|
}
|
|
68
70
|
function validateSupportKind(supportKind, adapterName, logger, featureName, hasCorrectConfig) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const headAndContentSym = Symbol.for("astro.headAndContent");
|
|
2
2
|
function isHeadAndContent(obj) {
|
|
3
|
-
return typeof obj === "object" && !!obj[headAndContentSym];
|
|
3
|
+
return typeof obj === "object" && obj !== null && !!obj[headAndContentSym];
|
|
4
4
|
}
|
|
5
5
|
function createHeadAndContent(head, content) {
|
|
6
6
|
return {
|
|
@@ -67,7 +67,7 @@ function createAstroComponentInstance(result, displayName, factory, props, slots
|
|
|
67
67
|
return instance;
|
|
68
68
|
}
|
|
69
69
|
function isAstroComponentInstance(obj) {
|
|
70
|
-
return typeof obj === "object" && !!obj[astroComponentInstanceSym];
|
|
70
|
+
return typeof obj === "object" && obj !== null && !!obj[astroComponentInstanceSym];
|
|
71
71
|
}
|
|
72
72
|
export {
|
|
73
73
|
AstroComponentInstance,
|
|
@@ -42,7 +42,7 @@ class RenderTemplateResult {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
function isRenderTemplateResult(obj) {
|
|
45
|
-
return typeof obj === "object" && !!obj[renderTemplateResultSym];
|
|
45
|
+
return typeof obj === "object" && obj !== null && !!obj[renderTemplateResultSym];
|
|
46
46
|
}
|
|
47
47
|
function renderTemplate(htmlParts, ...expressions) {
|
|
48
48
|
return new RenderTemplateResult(htmlParts, expressions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.16.
|
|
3
|
+
"version": "4.16.8",
|
|
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",
|
|
@@ -109,14 +109,14 @@
|
|
|
109
109
|
],
|
|
110
110
|
"dependencies": {
|
|
111
111
|
"@astrojs/compiler": "^2.10.3",
|
|
112
|
-
"@babel/core": "^7.
|
|
113
|
-
"@babel/plugin-transform-react-jsx": "^7.25.
|
|
114
|
-
"@babel/types": "^7.
|
|
112
|
+
"@babel/core": "^7.26.0",
|
|
113
|
+
"@babel/plugin-transform-react-jsx": "^7.25.9",
|
|
114
|
+
"@babel/types": "^7.26.0",
|
|
115
115
|
"@oslojs/encoding": "^1.1.0",
|
|
116
|
-
"@rollup/pluginutils": "^5.1.
|
|
116
|
+
"@rollup/pluginutils": "^5.1.3",
|
|
117
117
|
"@types/babel__core": "^7.20.5",
|
|
118
118
|
"@types/cookie": "^0.6.0",
|
|
119
|
-
"acorn": "^8.
|
|
119
|
+
"acorn": "^8.14.0",
|
|
120
120
|
"aria-query": "^5.3.2",
|
|
121
121
|
"axobject-query": "^4.1.0",
|
|
122
122
|
"boxen": "8.0.1",
|
|
@@ -154,21 +154,21 @@
|
|
|
154
154
|
"prompts": "^2.4.2",
|
|
155
155
|
"rehype": "^13.0.2",
|
|
156
156
|
"semver": "^7.6.3",
|
|
157
|
-
"shiki": "^1.22.
|
|
158
|
-
"tinyexec": "^0.3.
|
|
157
|
+
"shiki": "^1.22.2",
|
|
158
|
+
"tinyexec": "^0.3.1",
|
|
159
159
|
"tsconfck": "^3.1.4",
|
|
160
160
|
"unist-util-visit": "^5.0.0",
|
|
161
161
|
"vfile": "^6.0.3",
|
|
162
|
-
"vite": "^5.4.
|
|
162
|
+
"vite": "^5.4.10",
|
|
163
163
|
"vitefu": "^1.0.3",
|
|
164
164
|
"which-pm": "^3.0.0",
|
|
165
165
|
"xxhash-wasm": "^1.0.2",
|
|
166
166
|
"yargs-parser": "^21.1.1",
|
|
167
167
|
"zod": "^3.23.8",
|
|
168
|
-
"zod-to-json-schema": "^3.23.
|
|
168
|
+
"zod-to-json-schema": "^3.23.5",
|
|
169
169
|
"zod-to-ts": "^1.2.0",
|
|
170
|
-
"@astrojs/markdown-remark": "5.3.0",
|
|
171
170
|
"@astrojs/internal-helpers": "0.4.1",
|
|
171
|
+
"@astrojs/markdown-remark": "5.3.0",
|
|
172
172
|
"@astrojs/telemetry": "3.1.0"
|
|
173
173
|
},
|
|
174
174
|
"optionalDependencies": {
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
},
|
|
177
177
|
"devDependencies": {
|
|
178
178
|
"@astrojs/check": "^0.9.4",
|
|
179
|
-
"@playwright/test": "^1.48.
|
|
179
|
+
"@playwright/test": "^1.48.2",
|
|
180
180
|
"@types/aria-query": "^5.0.4",
|
|
181
181
|
"@types/common-ancestor-path": "^1.0.2",
|
|
182
182
|
"@types/cssesc": "^3.0.2",
|
|
@@ -204,8 +204,8 @@
|
|
|
204
204
|
"rehype-slug": "^6.0.0",
|
|
205
205
|
"rehype-toc": "^3.0.2",
|
|
206
206
|
"remark-code-titles": "^0.1.2",
|
|
207
|
-
"rollup": "^4.24.
|
|
208
|
-
"sass": "^1.
|
|
207
|
+
"rollup": "^4.24.2",
|
|
208
|
+
"sass": "^1.80.4",
|
|
209
209
|
"undici": "^6.20.1",
|
|
210
210
|
"unified": "^11.0.5",
|
|
211
211
|
"astro-scripts": "0.0.14"
|
package/templates/actions.mjs
CHANGED
|
@@ -92,7 +92,7 @@ async function handleAction(param, path, context) {
|
|
|
92
92
|
headers.set('Content-Length', '0');
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
const rawResult = await fetch(
|
|
95
|
+
const rawResult = await fetch(`${import.meta.env.BASE_URL.replace(/\/$/, '')}/_actions/${path}`, {
|
|
96
96
|
method: 'POST',
|
|
97
97
|
body,
|
|
98
98
|
headers,
|