mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
Merge branch 'main' into next
This commit is contained in:
commit
57dedbf28d
40 changed files with 197 additions and 72 deletions
|
@ -17,6 +17,6 @@
|
||||||
"port-authority": "^2.0.1",
|
"port-authority": "^2.0.1",
|
||||||
"pretty-bytes": "^6.1.1",
|
"pretty-bytes": "^6.1.1",
|
||||||
"sharp": "^0.33.3",
|
"sharp": "^0.33.3",
|
||||||
"tinyexec": "^0.3.0"
|
"tinyexec": "^0.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/alpinejs": "^0.4.0",
|
"@astrojs/alpinejs": "^0.4.0",
|
||||||
"@types/alpinejs": "^3.13.10",
|
"@types/alpinejs": "^3.13.10",
|
||||||
"alpinejs": "^3.14.1",
|
"alpinejs": "^3.14.3",
|
||||||
"astro": "^5.0.0-beta.5"
|
"astro": "^5.0.0-beta.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"astro": "^5.0.0-beta.5",
|
"astro": "^5.0.0-beta.5",
|
||||||
"sass": "^1.79.5",
|
"sass": "^1.80.3",
|
||||||
"sharp": "^0.33.3"
|
"sharp": "^0.33.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,6 @@
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"canvas-confetti": "^1.9.3",
|
"canvas-confetti": "^1.9.3",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.47",
|
||||||
"tailwindcss": "^3.4.13"
|
"tailwindcss": "^3.4.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,15 +59,15 @@
|
||||||
"@changesets/cli": "^2.27.9",
|
"@changesets/cli": "^2.27.9",
|
||||||
"@types/node": "^18.17.8",
|
"@types/node": "^18.17.8",
|
||||||
"esbuild": "^0.21.5",
|
"esbuild": "^0.21.5",
|
||||||
"eslint": "^9.12.0",
|
"eslint": "^9.13.0",
|
||||||
"eslint-plugin-regexp": "^2.6.0",
|
"eslint-plugin-regexp": "^2.6.0",
|
||||||
"globby": "^14.0.2",
|
"globby": "^14.0.2",
|
||||||
"only-allow": "^1.2.1",
|
"only-allow": "^1.2.1",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"prettier-plugin-astro": "^0.14.1",
|
"prettier-plugin-astro": "^0.14.1",
|
||||||
"turbo": "^2.1.3",
|
"turbo": "^2.2.3",
|
||||||
"typescript": "~5.6.3",
|
"typescript": "~5.6.3",
|
||||||
"typescript-eslint": "^8.9.0"
|
"typescript-eslint": "^8.11.0"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"overrides": {
|
"overrides": {
|
||||||
|
|
|
@ -1062,6 +1062,22 @@
|
||||||
- Updated dependencies [[`83a2a64`](https://github.com/withastro/astro/commit/83a2a648418ad30f4eb781d1c1b5f2d8a8ac846e)]:
|
- Updated dependencies [[`83a2a64`](https://github.com/withastro/astro/commit/83a2a648418ad30f4eb781d1c1b5f2d8a8ac846e)]:
|
||||||
- @astrojs/markdown-remark@6.0.0-alpha.0
|
- @astrojs/markdown-remark@6.0.0-alpha.0
|
||||||
|
|
||||||
|
## 4.16.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#12263](https://github.com/withastro/astro/pull/12263) [`e9e8080`](https://github.com/withastro/astro/commit/e9e8080a8139f898dcfa3c030f5ddaa98413c160) Thanks [@Fryuni](https://github.com/Fryuni)! - Fixes conflict between server islands and on-demand dynamic routes in the form of `/[...rest]` or `/[paramA]/[paramB]`.
|
||||||
|
|
||||||
|
- [#12279](https://github.com/withastro/astro/pull/12279) [`b781f88`](https://github.com/withastro/astro/commit/b781f8860c7d11e51fb60a0d6528bc88913ffc35) Thanks [@jsparkdev](https://github.com/jsparkdev)! - Update wrong error message
|
||||||
|
|
||||||
|
- [#12273](https://github.com/withastro/astro/pull/12273) [`c2ee963`](https://github.com/withastro/astro/commit/c2ee963cb6c0a65481be505848a7272d800f2f7b) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes an issue with some package managers where sites would not build if TypeScript was not installed.
|
||||||
|
|
||||||
|
- [#12235](https://github.com/withastro/astro/pull/12235) [`a75bc5e`](https://github.com/withastro/astro/commit/a75bc5e3068ed80366a03efbec78b3b0f8837516) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a bug where Astro Actions couldn't redirect to the correct pathname when there was a rewrite involved.
|
||||||
|
|
||||||
|
- [#11839](https://github.com/withastro/astro/pull/11839) [`ff522b9`](https://github.com/withastro/astro/commit/ff522b96a01391a29b44f820dfcc2a2176d871e7) Thanks [@icaliman](https://github.com/icaliman)! - Fixes error when returning a top-level `null` from an Astro file frontmatter
|
||||||
|
|
||||||
|
- [#12272](https://github.com/withastro/astro/pull/12272) [`388d237`](https://github.com/withastro/astro/commit/388d2375b6900e6401e1c711087ee0b2176418dd) Thanks [@ascorbic](https://github.com/ascorbic)! - Correctly handles local images when using a base path in SSR
|
||||||
|
|
||||||
## 4.16.6
|
## 4.16.6
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
|
@ -155,8 +155,7 @@ test.describe('Astro Actions - Blog', () => {
|
||||||
await expect(page).toHaveURL(astro.resolveUrl('/blog/'));
|
await expect(page).toHaveURL(astro.resolveUrl('/blog/'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: fix regression #12201 and #12202
|
test('Should redirect to the origin pathname when there is a rewrite', async ({
|
||||||
test.skip('Should redirect to the origin pathname when there is a rewrite', async ({
|
|
||||||
page,
|
page,
|
||||||
astro,
|
astro,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"sass": "^1.79.5"
|
"sass": "^1.80.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"preact": "^10.24.3",
|
"preact": "^10.24.3",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"sass": "^1.79.5",
|
"sass": "^1.80.3",
|
||||||
"solid-js": "^1.9.2",
|
"solid-js": "^1.9.2",
|
||||||
"svelte": "^4.2.19",
|
"svelte": "^4.2.19",
|
||||||
"vue": "^3.5.12"
|
"vue": "^3.5.12"
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"sass": "^1.79.5"
|
"sass": "^1.80.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
export const prerender = false;
|
||||||
|
---
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Conflicting route</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
This route would conflict with the route generated for server islands.
|
||||||
|
<br />
|
||||||
|
This file is here so the tests break if that happens.
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -7,6 +7,6 @@
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.47",
|
||||||
"tailwindcss": "^3.4.13"
|
"tailwindcss": "^3.4.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
"@oslojs/encoding": "^1.1.0",
|
"@oslojs/encoding": "^1.1.0",
|
||||||
"@rollup/pluginutils": "^5.1.2",
|
"@rollup/pluginutils": "^5.1.2",
|
||||||
"@types/cookie": "^0.6.0",
|
"@types/cookie": "^0.6.0",
|
||||||
"acorn": "^8.12.1",
|
"acorn": "^8.13.0",
|
||||||
"aria-query": "^5.3.2",
|
"aria-query": "^5.3.2",
|
||||||
"axobject-query": "^4.1.0",
|
"axobject-query": "^4.1.0",
|
||||||
"boxen": "8.0.1",
|
"boxen": "8.0.1",
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
"rehype": "^13.0.2",
|
"rehype": "^13.0.2",
|
||||||
"semver": "^7.6.3",
|
"semver": "^7.6.3",
|
||||||
"shiki": "^1.22.0",
|
"shiki": "^1.22.0",
|
||||||
"tinyexec": "^0.3.0",
|
"tinyexec": "^0.3.1",
|
||||||
"tsconfck": "^3.1.4",
|
"tsconfck": "^3.1.4",
|
||||||
"unist-util-visit": "^5.0.0",
|
"unist-util-visit": "^5.0.0",
|
||||||
"vfile": "^6.0.3",
|
"vfile": "^6.0.3",
|
||||||
|
@ -180,7 +180,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/check": "^0.9.4",
|
"@astrojs/check": "^0.9.4",
|
||||||
"@playwright/test": "^1.48.0",
|
"@playwright/test": "^1.48.1",
|
||||||
"@types/aria-query": "^5.0.4",
|
"@types/aria-query": "^5.0.4",
|
||||||
"@types/common-ancestor-path": "^1.0.2",
|
"@types/common-ancestor-path": "^1.0.2",
|
||||||
"@types/cssesc": "^3.0.2",
|
"@types/cssesc": "^3.0.2",
|
||||||
|
@ -210,7 +210,7 @@
|
||||||
"rehype-toc": "^3.0.2",
|
"rehype-toc": "^3.0.2",
|
||||||
"remark-code-titles": "^0.1.2",
|
"remark-code-titles": "^0.1.2",
|
||||||
"rollup": "^4.24.0",
|
"rollup": "^4.24.0",
|
||||||
"sass": "^1.79.5",
|
"sass": "^1.80.3",
|
||||||
"undici": "^6.20.1",
|
"undici": "^6.20.1",
|
||||||
"unified": "^11.0.5",
|
"unified": "^11.0.5",
|
||||||
"vitest": "^2.1.1"
|
"vitest": "^2.1.1"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { decodeBase64, encodeBase64 } from '@oslojs/encoding';
|
import { decodeBase64, encodeBase64 } from '@oslojs/encoding';
|
||||||
import { yellow } from 'kleur/colors';
|
import { yellow } from 'kleur/colors';
|
||||||
import { defineMiddleware } from '../../core/middleware/index.js';
|
import { defineMiddleware } from '../../core/middleware/index.js';
|
||||||
|
import { getOriginPathname } from '../../core/routing/rewrite.js';
|
||||||
import type { MiddlewareNext } from '../../types/public/common.js';
|
import type { MiddlewareNext } from '../../types/public/common.js';
|
||||||
import type { APIContext } from '../../types/public/context.js';
|
import type { APIContext } from '../../types/public/context.js';
|
||||||
import { ACTION_QUERY_PARAMS } from '../consts.js';
|
import { ACTION_QUERY_PARAMS } from '../consts.js';
|
||||||
|
@ -29,7 +30,7 @@ export const onRequest = defineMiddleware(async (context, next) => {
|
||||||
if (context.request.method === 'POST') {
|
if (context.request.method === 'POST') {
|
||||||
console.warn(
|
console.warn(
|
||||||
yellow('[astro:actions]'),
|
yellow('[astro:actions]'),
|
||||||
'POST requests should not be sent to prerendered pages. If you\'re using Actions, disable prerendering with `export const prerender = "false".',
|
"POST requests should not be sent to prerendered pages. If you're using Actions, disable prerendering with `export const prerender = false`.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return next();
|
return next();
|
||||||
|
@ -147,6 +148,11 @@ async function redirectWithResult({
|
||||||
return context.redirect(referer);
|
return context.redirect(referer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const referer = getOriginPathname(context.request);
|
||||||
|
if (referer) {
|
||||||
|
return context.redirect(referer);
|
||||||
|
}
|
||||||
|
|
||||||
return context.redirect(context.url.pathname);
|
return context.redirect(context.url.pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,12 @@ async function loadLocalImage(src: string, url: URL) {
|
||||||
fileUrl = pathToFileURL(removeQueryString(replaceFileSystemReferences(src)));
|
fileUrl = pathToFileURL(removeQueryString(replaceFileSystemReferences(src)));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
// If the _image segment isn't at the start of the path, we have a base
|
||||||
|
const idx = url.pathname.indexOf('/_image');
|
||||||
|
if (idx > 0) {
|
||||||
|
// Remove the base path
|
||||||
|
src = src.slice(idx);
|
||||||
|
}
|
||||||
fileUrl = new URL('.' + src, outDir);
|
fileUrl = new URL('.' + src, outDir);
|
||||||
const filePath = fileURLToPath(fileUrl);
|
const filePath = fileURLToPath(fileUrl);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import { bold, cyan } from 'kleur/colors';
|
||||||
import { type ViteDevServer, normalizePath } from 'vite';
|
import { type ViteDevServer, normalizePath } from 'vite';
|
||||||
import { type ZodSchema, z } from 'zod';
|
import { type ZodSchema, z } from 'zod';
|
||||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||||
import { printNode, zodToTs } from 'zod-to-ts';
|
|
||||||
import { AstroError } from '../core/errors/errors.js';
|
import { AstroError } from '../core/errors/errors.js';
|
||||||
import { AstroErrorData } from '../core/errors/index.js';
|
import { AstroErrorData } from '../core/errors/index.js';
|
||||||
import type { Logger } from '../core/logger/core.js';
|
import type { Logger } from '../core/logger/core.js';
|
||||||
|
@ -402,8 +401,17 @@ async function typeForCollection<T extends keyof ContentConfig['collections']>(
|
||||||
if (collection?.type === CONTENT_LAYER_TYPE) {
|
if (collection?.type === CONTENT_LAYER_TYPE) {
|
||||||
const schema = await getContentLayerSchema(collection, collectionKey);
|
const schema = await getContentLayerSchema(collection, collectionKey);
|
||||||
if (schema) {
|
if (schema) {
|
||||||
const ast = zodToTs(schema);
|
try {
|
||||||
return printNode(ast.node);
|
const zodToTs = await import('zod-to-ts');
|
||||||
|
const ast = zodToTs.zodToTs(schema);
|
||||||
|
return zodToTs.printNode(ast.node);
|
||||||
|
} catch (err: any) {
|
||||||
|
// zod-to-ts is sad if we don't have TypeScript installed, but that's fine as we won't be needing types in that case
|
||||||
|
if (err.message.includes("Cannot find package 'typescript'")) {
|
||||||
|
return 'any';
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 'any';
|
return 'any';
|
||||||
|
|
|
@ -2,6 +2,7 @@ import fs from 'node:fs';
|
||||||
import type { IncomingMessage, ServerResponse } from 'node:http';
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||||
import { Http2ServerResponse } from 'node:http2';
|
import { Http2ServerResponse } from 'node:http2';
|
||||||
import type { RouteData } from '../../types/public/internal.js';
|
import type { RouteData } from '../../types/public/internal.js';
|
||||||
|
import { clientAddressSymbol } from '../constants.js';
|
||||||
import { deserializeManifest } from './common.js';
|
import { deserializeManifest } from './common.js';
|
||||||
import { createOutgoingHttpHeaders } from './createOutgoingHttpHeaders.js';
|
import { createOutgoingHttpHeaders } from './createOutgoingHttpHeaders.js';
|
||||||
import { App } from './index.js';
|
import { App } from './index.js';
|
||||||
|
@ -10,8 +11,6 @@ import type { SSRManifest, SerializedSSRManifest } from './types.js';
|
||||||
|
|
||||||
export { apply as applyPolyfills } from '../polyfill.js';
|
export { apply as applyPolyfills } from '../polyfill.js';
|
||||||
|
|
||||||
const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow the request body to be explicitly overridden. For example, this
|
* Allow the request body to be explicitly overridden. For example, this
|
||||||
* is used by the Express JSON middleware.
|
* is used by the Express JSON middleware.
|
||||||
|
|
|
@ -28,6 +28,7 @@ export const REROUTE_DIRECTIVE_HEADER = 'X-Astro-Reroute';
|
||||||
* This metadata is used to determine the origin of a Response. If a rewrite has occurred, it should be prioritised over other logic.
|
* This metadata is used to determine the origin of a Response. If a rewrite has occurred, it should be prioritised over other logic.
|
||||||
*/
|
*/
|
||||||
export const REWRITE_DIRECTIVE_HEADER_KEY = 'X-Astro-Rewrite';
|
export const REWRITE_DIRECTIVE_HEADER_KEY = 'X-Astro-Rewrite';
|
||||||
|
|
||||||
export const REWRITE_DIRECTIVE_HEADER_VALUE = 'yes';
|
export const REWRITE_DIRECTIVE_HEADER_VALUE = 'yes';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,6 +69,11 @@ export const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
||||||
*/
|
*/
|
||||||
export const clientLocalsSymbol = Symbol.for('astro.locals');
|
export const clientLocalsSymbol = Symbol.for('astro.locals');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this symbol to set and retrieve the original pathname of a request. This is useful when working with redirects and rewrites
|
||||||
|
*/
|
||||||
|
export const originPathnameSymbol = Symbol.for('astro.originPathname');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The symbol used as a field on the response object to keep track of streaming.
|
* The symbol used as a field on the response object to keep track of streaming.
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,6 +28,7 @@ import { callMiddleware } from './middleware/callMiddleware.js';
|
||||||
import { sequence } from './middleware/index.js';
|
import { sequence } from './middleware/index.js';
|
||||||
import { renderRedirect } from './redirects/render.js';
|
import { renderRedirect } from './redirects/render.js';
|
||||||
import { type Pipeline, Slots, getParams, getProps } from './render/index.js';
|
import { type Pipeline, Slots, getParams, getProps } from './render/index.js';
|
||||||
|
import { copyRequest, setOriginPathname } from './routing/rewrite.js';
|
||||||
|
|
||||||
export const apiContextRoutesSymbol = Symbol.for('context.routes');
|
export const apiContextRoutesSymbol = Symbol.for('context.routes');
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ export class RenderContext {
|
||||||
Pick<RenderContext, 'locals' | 'middleware' | 'status' | 'props' | 'partial'>
|
Pick<RenderContext, 'locals' | 'middleware' | 'status' | 'props' | 'partial'>
|
||||||
>): Promise<RenderContext> {
|
>): Promise<RenderContext> {
|
||||||
const pipelineMiddleware = await pipeline.getMiddleware();
|
const pipelineMiddleware = await pipeline.getMiddleware();
|
||||||
|
setOriginPathname(request, pathname);
|
||||||
return new RenderContext(
|
return new RenderContext(
|
||||||
pipeline,
|
pipeline,
|
||||||
locals,
|
locals,
|
||||||
|
@ -147,7 +149,7 @@ export class RenderContext {
|
||||||
if (payload instanceof Request) {
|
if (payload instanceof Request) {
|
||||||
this.request = payload;
|
this.request = payload;
|
||||||
} else {
|
} else {
|
||||||
this.request = this.#copyRequest(newUrl, this.request);
|
this.request = copyRequest(newUrl, this.request);
|
||||||
}
|
}
|
||||||
this.isRewriting = true;
|
this.isRewriting = true;
|
||||||
this.url = new URL(this.request.url);
|
this.url = new URL(this.request.url);
|
||||||
|
@ -247,7 +249,7 @@ export class RenderContext {
|
||||||
if (reroutePayload instanceof Request) {
|
if (reroutePayload instanceof Request) {
|
||||||
this.request = reroutePayload;
|
this.request = reroutePayload;
|
||||||
} else {
|
} else {
|
||||||
this.request = this.#copyRequest(newUrl, this.request);
|
this.request = copyRequest(newUrl, this.request);
|
||||||
}
|
}
|
||||||
this.url = new URL(this.request.url);
|
this.url = new URL(this.request.url);
|
||||||
this.cookies = new AstroCookies(this.request);
|
this.cookies = new AstroCookies(this.request);
|
||||||
|
@ -555,33 +557,4 @@ export class RenderContext {
|
||||||
if (!i18n) return;
|
if (!i18n) return;
|
||||||
return (this.#preferredLocaleList ??= computePreferredLocaleList(request, i18n.locales));
|
return (this.#preferredLocaleList ??= computePreferredLocaleList(request, i18n.locales));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility function that creates a new `Request` with a new URL from an old `Request`.
|
|
||||||
*
|
|
||||||
* @param newUrl The new `URL`
|
|
||||||
* @param oldRequest The old `Request`
|
|
||||||
*/
|
|
||||||
#copyRequest(newUrl: URL, oldRequest: Request): Request {
|
|
||||||
if (oldRequest.bodyUsed) {
|
|
||||||
throw new AstroError(AstroErrorData.RewriteWithBodyUsed);
|
|
||||||
}
|
|
||||||
return new Request(newUrl, {
|
|
||||||
method: oldRequest.method,
|
|
||||||
headers: oldRequest.headers,
|
|
||||||
body: oldRequest.body,
|
|
||||||
referrer: oldRequest.referrer,
|
|
||||||
referrerPolicy: oldRequest.referrerPolicy,
|
|
||||||
mode: oldRequest.mode,
|
|
||||||
credentials: oldRequest.credentials,
|
|
||||||
cache: oldRequest.cache,
|
|
||||||
redirect: oldRequest.redirect,
|
|
||||||
integrity: oldRequest.integrity,
|
|
||||||
signal: oldRequest.signal,
|
|
||||||
keepalive: oldRequest.keepalive,
|
|
||||||
// https://fetch.spec.whatwg.org/#dom-request-duplex
|
|
||||||
// @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
|
|
||||||
duplex: 'half',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ import type { RewritePayload } from '../../types/public/common.js';
|
||||||
import type { AstroConfig } from '../../types/public/config.js';
|
import type { AstroConfig } from '../../types/public/config.js';
|
||||||
import type { RouteData } from '../../types/public/internal.js';
|
import type { RouteData } from '../../types/public/internal.js';
|
||||||
import { shouldAppendForwardSlash } from '../build/util.js';
|
import { shouldAppendForwardSlash } from '../build/util.js';
|
||||||
|
import { originPathnameSymbol } from '../constants.js';
|
||||||
|
import { AstroError, AstroErrorData } from '../errors/index.js';
|
||||||
import { appendForwardSlash, removeTrailingForwardSlash } from '../path.js';
|
import { appendForwardSlash, removeTrailingForwardSlash } from '../path.js';
|
||||||
import { DEFAULT_404_ROUTE } from './astro-designed-error-pages.js';
|
import { DEFAULT_404_ROUTE } from './astro-designed-error-pages.js';
|
||||||
|
|
||||||
|
@ -72,3 +74,44 @@ export function findRouteToRewrite({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function that creates a new `Request` with a new URL from an old `Request`.
|
||||||
|
*
|
||||||
|
* @param newUrl The new `URL`
|
||||||
|
* @param oldRequest The old `Request`
|
||||||
|
*/
|
||||||
|
export function copyRequest(newUrl: URL, oldRequest: Request): Request {
|
||||||
|
if (oldRequest.bodyUsed) {
|
||||||
|
throw new AstroError(AstroErrorData.RewriteWithBodyUsed);
|
||||||
|
}
|
||||||
|
return new Request(newUrl, {
|
||||||
|
method: oldRequest.method,
|
||||||
|
headers: oldRequest.headers,
|
||||||
|
body: oldRequest.body,
|
||||||
|
referrer: oldRequest.referrer,
|
||||||
|
referrerPolicy: oldRequest.referrerPolicy,
|
||||||
|
mode: oldRequest.mode,
|
||||||
|
credentials: oldRequest.credentials,
|
||||||
|
cache: oldRequest.cache,
|
||||||
|
redirect: oldRequest.redirect,
|
||||||
|
integrity: oldRequest.integrity,
|
||||||
|
signal: oldRequest.signal,
|
||||||
|
keepalive: oldRequest.keepalive,
|
||||||
|
// https://fetch.spec.whatwg.org/#dom-request-duplex
|
||||||
|
// @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
|
||||||
|
duplex: 'half',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setOriginPathname(request: Request, pathname: string): void {
|
||||||
|
Reflect.set(request, originPathnameSymbol, encodeURIComponent(pathname));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getOriginPathname(request: Request): string | undefined {
|
||||||
|
const origin = Reflect.get(request, originPathnameSymbol);
|
||||||
|
if (origin) {
|
||||||
|
return decodeURIComponent(origin);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ export function ensureServerIslandRoute(config: ConfigFields, routeManifest: Man
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
routeManifest.routes.push(getServerIslandRouteData(config));
|
routeManifest.routes.unshift(getServerIslandRouteData(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
type RenderOptions = {
|
type RenderOptions = {
|
||||||
|
|
|
@ -9,7 +9,7 @@ export type HeadAndContent = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isHeadAndContent(obj: unknown): obj is HeadAndContent {
|
export function isHeadAndContent(obj: unknown): obj is HeadAndContent {
|
||||||
return typeof obj === 'object' && !!(obj as any)[headAndContentSym];
|
return typeof obj === 'object' && obj !== null && !!(obj as any)[headAndContentSym];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createHeadAndContent(head: string, content: RenderTemplateResult): HeadAndContent {
|
export function createHeadAndContent(head: string, content: RenderTemplateResult): HeadAndContent {
|
||||||
|
|
|
@ -101,5 +101,5 @@ export function createAstroComponentInstance(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isAstroComponentInstance(obj: unknown): obj is AstroComponentInstance {
|
export function isAstroComponentInstance(obj: unknown): obj is AstroComponentInstance {
|
||||||
return typeof obj === 'object' && !!(obj as any)[astroComponentInstanceSym];
|
return typeof obj === 'object' && obj !== null && !!(obj as any)[astroComponentInstanceSym];
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ export class RenderTemplateResult {
|
||||||
|
|
||||||
// Determines if a component is an .astro component
|
// Determines if a component is an .astro component
|
||||||
export function isRenderTemplateResult(obj: unknown): obj is RenderTemplateResult {
|
export function isRenderTemplateResult(obj: unknown): obj is RenderTemplateResult {
|
||||||
return typeof obj === 'object' && !!(obj as any)[renderTemplateResultSym];
|
return typeof obj === 'object' && obj !== null && !!(obj as any)[renderTemplateResultSym];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderTemplate(htmlParts: TemplateStringsArray, ...expressions: any[]) {
|
export function renderTemplate(htmlParts: TemplateStringsArray, ...expressions: any[]) {
|
||||||
|
|
|
@ -816,6 +816,7 @@ describe('astro:image', () => {
|
||||||
outDir: './dist/server-base-path',
|
outDir: './dist/server-base-path',
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
image: {
|
image: {
|
||||||
|
endpoint: 'astro/assets/endpoint/node',
|
||||||
service: testImageService(),
|
service: testImageService(),
|
||||||
},
|
},
|
||||||
base: '/blog',
|
base: '/blog',
|
||||||
|
@ -829,6 +830,8 @@ describe('astro:image', () => {
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
const src = $('#local img').attr('src');
|
const src = $('#local img').attr('src');
|
||||||
assert.equal(src.startsWith('/blog'), true);
|
assert.equal(src.startsWith('/blog'), true);
|
||||||
|
const img = await app.render(new Request(`https://example.com${src}`));
|
||||||
|
assert.equal(img.status, 200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/solid-js": "workspace:*",
|
"@astrojs/solid-js": "workspace:*",
|
||||||
"@solidjs/router": "^0.14.8",
|
"@solidjs/router": "^0.14.10",
|
||||||
"@test/solid-jsx-component": "file:./deps/solid-jsx-component",
|
"@test/solid-jsx-component": "file:./deps/solid-jsx-component",
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"solid-js": "^1.9.2"
|
"solid-js": "^1.9.2"
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
"@astrojs/tailwind": "workspace:*",
|
"@astrojs/tailwind": "workspace:*",
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.47",
|
||||||
"tailwindcss": "^3.4.13"
|
"tailwindcss": "^3.4.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.47",
|
||||||
"tailwindcss": "^3.4.13"
|
"tailwindcss": "^3.4.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,4 +108,43 @@ describe('core/render components', () => {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render component with `null` response', async () => {
|
||||||
|
const fixture = await createFixture({
|
||||||
|
'/src/pages/index.astro': `
|
||||||
|
---
|
||||||
|
import NullComponent from '../components/NullComponent.astro';
|
||||||
|
---
|
||||||
|
<NullComponent />
|
||||||
|
`,
|
||||||
|
'/src/components/NullComponent.astro': `
|
||||||
|
---
|
||||||
|
return null;
|
||||||
|
---
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
await runInContainer(
|
||||||
|
{
|
||||||
|
inlineConfig: {
|
||||||
|
root: fixture.path,
|
||||||
|
logLevel: 'silent',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
async (container) => {
|
||||||
|
const { req, res, done, text } = createRequestAndResponse({
|
||||||
|
method: 'GET',
|
||||||
|
url: '/',
|
||||||
|
});
|
||||||
|
container.handle(req, res);
|
||||||
|
|
||||||
|
await done;
|
||||||
|
const html = await text();
|
||||||
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
|
assert.equal($('body').text(), '');
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,15 @@
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @astrojs/studio@0.1.1
|
||||||
|
|
||||||
|
## 0.14.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#11435](https://github.com/withastro/astro/pull/11435) [`f32a7a8`](https://github.com/withastro/astro/commit/f32a7a83889dd6180b2e4cde9b30286ab6874e49) Thanks [@haivuw](https://github.com/haivuw)! - Fixes a bug where `astro:db:seed` couldn't access to the environment variable `ASTRO_DATABASE_FILE`
|
||||||
|
|
||||||
- Updated dependencies []:
|
- Updated dependencies []:
|
||||||
- @astrojs/studio@0.1.1
|
- @astrojs/studio@0.1.1
|
||||||
|
|
||||||
|
@ -34,6 +43,9 @@
|
||||||
|
|
||||||
- [#12089](https://github.com/withastro/astro/pull/12089) [`6e06e6e`](https://github.com/withastro/astro/commit/6e06e6ed4f1c983f842527d7e3561a45a4407777) Thanks [@Fryuni](https://github.com/Fryuni)! - Fixes relative local libSQL db URL
|
- [#12089](https://github.com/withastro/astro/pull/12089) [`6e06e6e`](https://github.com/withastro/astro/commit/6e06e6ed4f1c983f842527d7e3561a45a4407777) Thanks [@Fryuni](https://github.com/Fryuni)! - Fixes relative local libSQL db URL
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @astrojs/studio@0.1.1
|
||||||
|
|
||||||
## 0.14.1
|
## 0.14.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
|
@ -124,12 +124,13 @@ export function getLocalVirtualModContents({
|
||||||
tables: DBTables;
|
tables: DBTables;
|
||||||
root: URL;
|
root: URL;
|
||||||
}) {
|
}) {
|
||||||
|
const { ASTRO_DATABASE_FILE } = getAstroEnv();
|
||||||
const dbInfo = getRemoteDatabaseInfo();
|
const dbInfo = getRemoteDatabaseInfo();
|
||||||
const dbUrl = new URL(DB_PATH, root);
|
const dbUrl = new URL(DB_PATH, root);
|
||||||
return `
|
return `
|
||||||
import { asDrizzleTable, createLocalDatabaseClient, normalizeDatabaseUrl } from ${RUNTIME_IMPORT};
|
import { asDrizzleTable, createLocalDatabaseClient, normalizeDatabaseUrl } from ${RUNTIME_IMPORT};
|
||||||
|
|
||||||
const dbUrl = normalizeDatabaseUrl(import.meta.env.ASTRO_DATABASE_FILE, ${JSON.stringify(dbUrl)});
|
const dbUrl = normalizeDatabaseUrl(${JSON.stringify(ASTRO_DATABASE_FILE)}, ${JSON.stringify(dbUrl)});
|
||||||
export const db = createLocalDatabaseClient({ dbUrl, enableTransactions: ${dbInfo.url === 'libsql'} });
|
export const db = createLocalDatabaseClient({ dbUrl, enableTransactions: ${dbInfo.url === 'libsql'} });
|
||||||
|
|
||||||
export * from ${RUNTIME_VIRTUAL_IMPORT};
|
export * from ${RUNTIME_VIRTUAL_IMPORT};
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
"alpinejs": "^3.0.0"
|
"alpinejs": "^3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "1.48.0",
|
"@playwright/test": "1.48.1",
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"astro-scripts": "workspace:*",
|
"astro-scripts": "workspace:*",
|
||||||
"vite": "6.0.0-beta.2"
|
"vite": "6.0.0-beta.2"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/alpinejs": "workspace:*",
|
"@astrojs/alpinejs": "workspace:*",
|
||||||
"@types/alpinejs": "^3.13.10",
|
"@types/alpinejs": "^3.13.10",
|
||||||
"alpinejs": "^3.14.1",
|
"alpinejs": "^3.14.3",
|
||||||
"astro": "workspace:*"
|
"astro": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/alpinejs": "workspace:*",
|
"@astrojs/alpinejs": "workspace:*",
|
||||||
"@types/alpinejs": "^3.13.10",
|
"@types/alpinejs": "^3.13.10",
|
||||||
"alpinejs": "^3.14.1",
|
"alpinejs": "^3.14.3",
|
||||||
"astro": "workspace:*"
|
"astro": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/alpinejs": "workspace:*",
|
"@astrojs/alpinejs": "workspace:*",
|
||||||
"@types/alpinejs": "^3.13.10",
|
"@types/alpinejs": "^3.13.10",
|
||||||
"alpinejs": "^3.14.1",
|
"alpinejs": "^3.14.3",
|
||||||
"astro": "workspace:*"
|
"astro": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/markdown-remark": "workspace:*",
|
"@astrojs/markdown-remark": "workspace:*",
|
||||||
"@mdx-js/mdx": "^3.0.1",
|
"@mdx-js/mdx": "^3.1.0",
|
||||||
"acorn": "^8.12.1",
|
"acorn": "^8.13.0",
|
||||||
"es-module-lexer": "^1.5.4",
|
"es-module-lexer": "^1.5.4",
|
||||||
"estree-util-visit": "^2.0.0",
|
"estree-util-visit": "^2.0.0",
|
||||||
"hast-util-to-html": "^9.0.3",
|
"hast-util-to-html": "^9.0.3",
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
"test": "astro-scripts test \"test/**/*.test.js\""
|
"test": "astro-scripts test \"test/**/*.test.js\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vitejs/plugin-react": "^4.3.2",
|
"@vitejs/plugin-react": "^4.3.3",
|
||||||
"ultrahtml": "^1.5.3"
|
"ultrahtml": "^1.5.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
"astro-scripts": "workspace:*",
|
"astro-scripts": "workspace:*",
|
||||||
"tailwindcss": "^3.4.13",
|
"tailwindcss": "^3.4.14",
|
||||||
"vite": "6.0.0-beta.2"
|
"vite": "6.0.0-beta.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
"@vitejs/plugin-vue": "^5.1.4",
|
"@vitejs/plugin-vue": "^5.1.4",
|
||||||
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
||||||
"@vue/compiler-sfc": "^3.5.12",
|
"@vue/compiler-sfc": "^3.5.12",
|
||||||
"vite-plugin-vue-devtools": "^7.4.6"
|
"vite-plugin-vue-devtools": "^7.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "workspace:*",
|
"astro": "workspace:*",
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.2",
|
||||||
"kleur": "^4.1.5",
|
"kleur": "^4.1.5",
|
||||||
"p-limit": "^6.1.0",
|
"p-limit": "^6.1.0",
|
||||||
"tinyexec": "^0.3.0",
|
"tinyexec": "^0.3.1",
|
||||||
"tsconfck": "^3.1.4"
|
"tsconfck": "^3.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue