astro 4.16.5 → 4.16.7
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/actions/runtime/middleware.js +8 -3
- package/dist/assets/endpoint/node.js +4 -0
- package/dist/assets/internal.js +2 -1
- package/dist/container/index.d.ts +7 -0
- package/dist/container/index.js +2 -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/messages.js +2 -2
- package/dist/core/render-context.d.ts +2 -1
- package/dist/core/render-context.js +11 -34
- 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/env/runtime-constants.d.ts +1 -0
- package/dist/env/runtime-constants.js +4 -0
- package/dist/env/runtime.js +5 -1
- package/dist/env/vite-plugin-env.js +2 -5
- 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 +6 -6
|
@@ -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();
|
|
@@ -84,10 +85,14 @@ async function redirectWithResult({
|
|
|
84
85
|
actionResult: serializeActionResult(actionResult)
|
|
85
86
|
});
|
|
86
87
|
if (actionResult.error) {
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
88
|
+
const referer2 = context.request.headers.get("Referer");
|
|
89
|
+
if (!referer2) {
|
|
89
90
|
throw new Error("Internal: Referer unexpectedly missing from Action POST request.");
|
|
90
91
|
}
|
|
92
|
+
return context.redirect(referer2);
|
|
93
|
+
}
|
|
94
|
+
const referer = getOriginPathname(context.request);
|
|
95
|
+
if (referer) {
|
|
91
96
|
return context.redirect(referer);
|
|
92
97
|
}
|
|
93
98
|
return context.redirect(context.url.pathname);
|
|
@@ -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/assets/internal.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRemotePath } from "@astrojs/internal-helpers/path";
|
|
1
2
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
2
3
|
import { DEFAULT_HASH_PROPS } from "./consts.js";
|
|
3
4
|
import { isLocalService } from "./services/service.js";
|
|
@@ -47,7 +48,7 @@ async function getImage(options, imageConfig) {
|
|
|
47
48
|
...options,
|
|
48
49
|
src: await resolveSrc(options.src)
|
|
49
50
|
};
|
|
50
|
-
if (options.inferSize && isRemoteImage(resolvedOptions.src)) {
|
|
51
|
+
if (options.inferSize && isRemoteImage(resolvedOptions.src) && isRemotePath(resolvedOptions.src)) {
|
|
51
52
|
const result = await inferRemoteSize(resolvedOptions.src);
|
|
52
53
|
resolvedOptions.width ??= result.width;
|
|
53
54
|
resolvedOptions.height ??= result.height;
|
|
@@ -59,6 +59,13 @@ export type ContainerRenderOptions = {
|
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
61
|
props?: Props;
|
|
62
|
+
/**
|
|
63
|
+
* When `false`, it forces to render the component as it was a full-fledged page.
|
|
64
|
+
*
|
|
65
|
+
* By default, the container API render components as [partials](https://docs.astro.build/en/basics/astro-pages/#page-partials).
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
partial?: boolean;
|
|
62
69
|
};
|
|
63
70
|
export type AddServerRenderer = {
|
|
64
71
|
renderer: NamedSSRLoadedRendererValue;
|
package/dist/container/index.js
CHANGED
|
@@ -266,7 +266,8 @@ class experimental_AstroContainer {
|
|
|
266
266
|
status: 200,
|
|
267
267
|
request,
|
|
268
268
|
pathname: url.pathname,
|
|
269
|
-
locals: options?.locals ?? {}
|
|
269
|
+
locals: options?.locals ?? {},
|
|
270
|
+
partial: options?.partial ?? true
|
|
270
271
|
});
|
|
271
272
|
if (options.params) {
|
|
272
273
|
renderContext.params = options.params;
|
|
@@ -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.7") {
|
|
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.7") {
|
|
133
|
+
await this.#store.metaStore().set("astro-version", "4.16.7");
|
|
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.7";
|
|
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.7";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
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.7";
|
|
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.7"}`
|
|
274
274
|
)} ${headline}`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
@@ -20,6 +20,7 @@ export declare class RenderContext {
|
|
|
20
20
|
params: import("../@types/astro.js").Params;
|
|
21
21
|
protected url: URL;
|
|
22
22
|
props: Props;
|
|
23
|
+
partial: undefined | boolean;
|
|
23
24
|
private constructor();
|
|
24
25
|
/**
|
|
25
26
|
* A flag that tells the render content if the rewriting was triggered
|
|
@@ -29,7 +30,7 @@ export declare class RenderContext {
|
|
|
29
30
|
* A safety net in case of loops
|
|
30
31
|
*/
|
|
31
32
|
counter: number;
|
|
32
|
-
static create({ locals, middleware, pathname, pipeline, request, routeData, status, props, }: Pick<RenderContext, 'pathname' | 'pipeline' | 'request' | 'routeData'> & Partial<Pick<RenderContext, 'locals' | 'middleware' | 'status' | 'props'>>): Promise<RenderContext>;
|
|
33
|
+
static create({ locals, middleware, pathname, pipeline, request, routeData, status, props, partial, }: Pick<RenderContext, 'pathname' | 'pipeline' | 'request' | 'routeData'> & Partial<Pick<RenderContext, 'locals' | 'middleware' | 'status' | 'props' | 'partial'>>): Promise<RenderContext>;
|
|
33
34
|
/**
|
|
34
35
|
* The main function of the RenderContext.
|
|
35
36
|
*
|
|
@@ -24,9 +24,10 @@ 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
|
-
constructor(pipeline, locals, middleware, pathname, request, routeData, status, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url), props = {}) {
|
|
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) {
|
|
30
31
|
this.pipeline = pipeline;
|
|
31
32
|
this.locals = locals;
|
|
32
33
|
this.middleware = middleware;
|
|
@@ -38,6 +39,7 @@ class RenderContext {
|
|
|
38
39
|
this.params = params;
|
|
39
40
|
this.url = url;
|
|
40
41
|
this.props = props;
|
|
42
|
+
this.partial = partial;
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
45
|
* A flag that tells the render content if the rewriting was triggered
|
|
@@ -55,9 +57,11 @@ class RenderContext {
|
|
|
55
57
|
request,
|
|
56
58
|
routeData,
|
|
57
59
|
status = 200,
|
|
58
|
-
props
|
|
60
|
+
props,
|
|
61
|
+
partial = void 0
|
|
59
62
|
}) {
|
|
60
63
|
const pipelineMiddleware = await pipeline.getMiddleware();
|
|
64
|
+
setOriginPathname(request, pathname);
|
|
61
65
|
return new RenderContext(
|
|
62
66
|
pipeline,
|
|
63
67
|
locals,
|
|
@@ -69,7 +73,8 @@ class RenderContext {
|
|
|
69
73
|
void 0,
|
|
70
74
|
void 0,
|
|
71
75
|
void 0,
|
|
72
|
-
props
|
|
76
|
+
props,
|
|
77
|
+
partial
|
|
73
78
|
);
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
@@ -118,7 +123,7 @@ class RenderContext {
|
|
|
118
123
|
if (payload instanceof Request) {
|
|
119
124
|
this.request = payload;
|
|
120
125
|
} else {
|
|
121
|
-
this.request =
|
|
126
|
+
this.request = copyRequest(newUrl, this.request);
|
|
122
127
|
}
|
|
123
128
|
this.isRewriting = true;
|
|
124
129
|
this.url = new URL(this.request.url);
|
|
@@ -202,7 +207,7 @@ class RenderContext {
|
|
|
202
207
|
if (reroutePayload instanceof Request) {
|
|
203
208
|
this.request = reroutePayload;
|
|
204
209
|
} else {
|
|
205
|
-
this.request =
|
|
210
|
+
this.request = copyRequest(newUrl, this.request);
|
|
206
211
|
}
|
|
207
212
|
this.url = new URL(this.request.url);
|
|
208
213
|
this.cookies = new AstroCookies(this.request);
|
|
@@ -259,7 +264,7 @@ class RenderContext {
|
|
|
259
264
|
const { links, scripts, styles } = await pipeline.headElements(routeData);
|
|
260
265
|
const componentMetadata = await pipeline.componentMetadata(routeData) ?? manifest.componentMetadata;
|
|
261
266
|
const headers = new Headers({ "Content-Type": "text/html" });
|
|
262
|
-
const partial = Boolean(mod.partial);
|
|
267
|
+
const partial = typeof this.partial === "boolean" ? this.partial : Boolean(mod.partial);
|
|
263
268
|
const response = {
|
|
264
269
|
status,
|
|
265
270
|
statusText: "OK",
|
|
@@ -458,34 +463,6 @@ class RenderContext {
|
|
|
458
463
|
if (!i18n) return;
|
|
459
464
|
return this.#preferredLocaleList ??= computePreferredLocaleList(request, i18n.locales);
|
|
460
465
|
}
|
|
461
|
-
/**
|
|
462
|
-
* Utility function that creates a new `Request` with a new URL from an old `Request`.
|
|
463
|
-
*
|
|
464
|
-
* @param newUrl The new `URL`
|
|
465
|
-
* @param oldRequest The old `Request`
|
|
466
|
-
*/
|
|
467
|
-
#copyRequest(newUrl, oldRequest) {
|
|
468
|
-
if (oldRequest.bodyUsed) {
|
|
469
|
-
throw new AstroError(AstroErrorData.RewriteWithBodyUsed);
|
|
470
|
-
}
|
|
471
|
-
return new Request(newUrl, {
|
|
472
|
-
method: oldRequest.method,
|
|
473
|
-
headers: oldRequest.headers,
|
|
474
|
-
body: oldRequest.body,
|
|
475
|
-
referrer: oldRequest.referrer,
|
|
476
|
-
referrerPolicy: oldRequest.referrerPolicy,
|
|
477
|
-
mode: oldRequest.mode,
|
|
478
|
-
credentials: oldRequest.credentials,
|
|
479
|
-
cache: oldRequest.cache,
|
|
480
|
-
redirect: oldRequest.redirect,
|
|
481
|
-
integrity: oldRequest.integrity,
|
|
482
|
-
signal: oldRequest.signal,
|
|
483
|
-
keepalive: oldRequest.keepalive,
|
|
484
|
-
// https://fetch.spec.whatwg.org/#dom-request-duplex
|
|
485
|
-
// @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
|
|
486
|
-
duplex: "half"
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
466
|
}
|
|
490
467
|
export {
|
|
491
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) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ENV_SYMBOL: unique symbol;
|
package/dist/env/runtime.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
2
2
|
import { invalidVariablesToError } from "./errors.js";
|
|
3
|
+
import { ENV_SYMBOL } from "./runtime-constants.js";
|
|
3
4
|
import { validateEnvVariable, getEnvFieldType } from "./validators.js";
|
|
4
|
-
let _getEnv = (key) =>
|
|
5
|
+
let _getEnv = (key) => {
|
|
6
|
+
const env = globalThis[ENV_SYMBOL] ?? {};
|
|
7
|
+
return env[key];
|
|
8
|
+
};
|
|
5
9
|
function setGetEnv(fn, reset = false) {
|
|
6
10
|
_getEnv = fn;
|
|
7
11
|
_onSetGetEnv(reset);
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
VIRTUAL_MODULES_IDS_VALUES
|
|
8
8
|
} from "./constants.js";
|
|
9
9
|
import { invalidVariablesToError } from "./errors.js";
|
|
10
|
+
import { ENV_SYMBOL } from "./runtime-constants.js";
|
|
10
11
|
import { getEnvFieldType, validateEnvVariable } from "./validators.js";
|
|
11
12
|
function astroEnv({
|
|
12
13
|
settings,
|
|
@@ -28,11 +29,7 @@ function astroEnv({
|
|
|
28
29
|
fileURLToPath(settings.config.root),
|
|
29
30
|
""
|
|
30
31
|
);
|
|
31
|
-
|
|
32
|
-
if (value !== void 0) {
|
|
33
|
-
process.env[key] = value;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
32
|
+
globalThis[ENV_SYMBOL] = loadedEnv;
|
|
36
33
|
const validatedVariables = validatePublicVariables({
|
|
37
34
|
schema,
|
|
38
35
|
loadedEnv,
|
|
@@ -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.7",
|
|
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",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"@rollup/pluginutils": "^5.1.2",
|
|
117
117
|
"@types/babel__core": "^7.20.5",
|
|
118
118
|
"@types/cookie": "^0.6.0",
|
|
119
|
-
"acorn": "^8.
|
|
119
|
+
"acorn": "^8.13.0",
|
|
120
120
|
"aria-query": "^5.3.2",
|
|
121
121
|
"axobject-query": "^4.1.0",
|
|
122
122
|
"boxen": "8.0.1",
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
"rehype": "^13.0.2",
|
|
156
156
|
"semver": "^7.6.3",
|
|
157
157
|
"shiki": "^1.22.0",
|
|
158
|
-
"tinyexec": "^0.3.
|
|
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",
|
|
@@ -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.1",
|
|
180
180
|
"@types/aria-query": "^5.0.4",
|
|
181
181
|
"@types/common-ancestor-path": "^1.0.2",
|
|
182
182
|
"@types/cssesc": "^3.0.2",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
"eol": "^0.10.0",
|
|
196
196
|
"execa": "^8.0.1",
|
|
197
197
|
"expect-type": "^1.1.0",
|
|
198
|
-
"fs-fixture": "^2.
|
|
198
|
+
"fs-fixture": "^2.5.0",
|
|
199
199
|
"mdast-util-mdx": "^3.0.0",
|
|
200
200
|
"mdast-util-mdx-jsx": "^3.1.3",
|
|
201
201
|
"node-mocks-http": "^1.16.1",
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
"rehype-toc": "^3.0.2",
|
|
206
206
|
"remark-code-titles": "^0.1.2",
|
|
207
207
|
"rollup": "^4.24.0",
|
|
208
|
-
"sass": "^1.
|
|
208
|
+
"sass": "^1.80.3",
|
|
209
209
|
"undici": "^6.20.1",
|
|
210
210
|
"unified": "^11.0.5",
|
|
211
211
|
"astro-scripts": "0.0.14"
|