Skip to content

Commit

Permalink
Merge pull request #177 from withastro/main
Browse files Browse the repository at this point in the history
A2790
  • Loading branch information
akshit20421 authored May 16, 2024
2 parents 2153a84 + 4d32a80 commit 0644d2b
Show file tree
Hide file tree
Showing 71 changed files with 435 additions and 146 deletions.
5 changes: 0 additions & 5 deletions .changeset/khaki-papayas-knock.md

This file was deleted.

2 changes: 1 addition & 1 deletion examples/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"@astrojs/mdx": "^3.0.0",
"@astrojs/rss": "^4.0.6",
"@astrojs/sitemap": "^3.1.4",
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.8.4"
"astro": "^4.8.5"
},
"peerDependencies": {
"astro": "^4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-alpine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"@astrojs/alpinejs": "^0.4.0",
"@types/alpinejs": "^3.13.10",
"alpinejs": "^3.13.10",
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/framework-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/lit": "^4.0.1",
"@webcomponents/template-shadowroot": "^0.2.1",
"astro": "^4.8.4",
"astro": "^4.8.5",
"lit": "^3.1.3"
}
}
2 changes: 1 addition & 1 deletion examples/framework-multiple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@astrojs/vue": "^4.2.0",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"astro": "^4.8.4",
"astro": "^4.8.5",
"preact": "^10.21.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/preact": "^3.3.0",
"@preact/signals": "^1.2.3",
"astro": "^4.8.4",
"astro": "^4.8.5",
"preact": "^10.21.0"
}
}
2 changes: 1 addition & 1 deletion examples/framework-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/react": "^3.3.4",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"astro": "^4.8.4",
"astro": "^4.8.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/solid-js": "^4.2.0",
"astro": "^4.8.4",
"astro": "^4.8.5",
"solid-js": "^1.8.17"
}
}
2 changes: 1 addition & 1 deletion examples/framework-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/svelte": "^5.4.0",
"astro": "^4.8.4",
"astro": "^4.8.5",
"svelte": "^4.2.16"
}
}
2 changes: 1 addition & 1 deletion examples/framework-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/vue": "^4.2.0",
"astro": "^4.8.4",
"astro": "^4.8.5",
"vue": "^3.4.27"
}
}
2 changes: 1 addition & 1 deletion examples/hackernews/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"dependencies": {
"@astrojs/node": "^8.2.5",
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.8.4"
"astro": "^4.8.5"
},
"peerDependencies": {
"astro": "^4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@astrojs/node": "^8.2.5",
"astro": "^4.8.4",
"astro": "^4.8.5",
"html-minifier": "^4.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/non-html-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/portfolio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@astrojs/node": "^8.2.5",
"@astrojs/svelte": "^5.4.0",
"astro": "^4.8.4",
"astro": "^4.8.5",
"svelte": "^4.2.16"
}
}
2 changes: 1 addition & 1 deletion examples/starlog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.8.4",
"astro": "^4.8.5",
"sass": "^1.77.1",
"sharp": "^0.33.3"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/toolbar-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"./app": "./dist/app.js"
},
"devDependencies": {
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/view-transitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"devDependencies": {
"@astrojs/tailwind": "^5.1.0",
"@astrojs/node": "^8.2.5",
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/with-markdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"dependencies": {
"@astrojs/markdoc": "^0.11.0",
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/with-markdown-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/markdown-remark": "^5.1.0",
"astro": "^4.8.4",
"astro": "^4.8.5",
"hast-util-select": "^6.0.2",
"rehype-autolink-headings": "^7.1.0",
"rehype-slug": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-markdown-shiki/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.8.4"
"astro": "^4.8.5"
}
}
2 changes: 1 addition & 1 deletion examples/with-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/mdx": "^3.0.0",
"@astrojs/preact": "^3.3.0",
"astro": "^4.8.4",
"astro": "^4.8.5",
"preact": "^10.21.0"
}
}
2 changes: 1 addition & 1 deletion examples/with-nanostores/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/preact": "^3.3.0",
"@nanostores/preact": "^0.5.1",
"astro": "^4.8.4",
"astro": "^4.8.5",
"nanostores": "^0.10.3",
"preact": "^10.21.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/mdx": "^3.0.0",
"@astrojs/tailwind": "^5.1.0",
"@types/canvas-confetti": "^1.6.4",
"astro": "^4.8.4",
"astro": "^4.8.5",
"autoprefixer": "^10.4.19",
"canvas-confetti": "^1.9.3",
"postcss": "^8.4.38",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^4.8.4",
"astro": "^4.8.5",
"vitest": "^1.6.0"
}
}
18 changes: 18 additions & 0 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# astro

## 4.8.5

### Patch Changes

- [#11065](https://github.com/withastro/astro/pull/11065) [`1f988ed`](https://github.com/withastro/astro/commit/1f988ed10f4737b5333c9978115ee531786eb539) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a bug in the Astro rewrite logic, where rewriting the index with parameters - `next("/?foo=bar")` - didn't work as expected.

- [#10924](https://github.com/withastro/astro/pull/10924) [`3a0c02a`](https://github.com/withastro/astro/commit/3a0c02ae0357c267881b30454b5320075378894b) Thanks [@Its-Just-Nans](https://github.com/Its-Just-Nans)! - Handle image-size errors by displaying a clearer message

- [#11058](https://github.com/withastro/astro/pull/11058) [`749a7ac`](https://github.com/withastro/astro/commit/749a7ac967146952450a4173dcb6a5494755460c) Thanks [@matthewp](https://github.com/matthewp)! - Fix streaming in Node.js fast path

- [#11052](https://github.com/withastro/astro/pull/11052) [`a05ca38`](https://github.com/withastro/astro/commit/a05ca38c2cf327ae9130ee1c139a0e510b9da50a) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a case where rewriting would conflict with the actions internal middleware

- [#11062](https://github.com/withastro/astro/pull/11062) [`16f12e4`](https://github.com/withastro/astro/commit/16f12e426e5869721313bb771e2ec5b821c5452e) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a bug where `astro build` didn't create custom `404.html` and `500.html` when a certain combination of i18n options was applied

- [#10965](https://github.com/withastro/astro/pull/10965) [`a8f0372`](https://github.com/withastro/astro/commit/a8f0372ea71479ef80c58e74201dea6a5a2b2ae4) Thanks [@Elias-Chairi](https://github.com/Elias-Chairi)! - Update generator.ts to allow %23 (#) in dynamic urls

- [#11069](https://github.com/withastro/astro/pull/11069) [`240a70a`](https://github.com/withastro/astro/commit/240a70a29f8e11d161da021845c208f982d64e5c) Thanks [@ematipico](https://github.com/ematipico)! - Improves debug logging for on-demand pages

## 4.8.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astro",
"version": "4.8.4",
"version": "4.8.5",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
Expand Down
30 changes: 18 additions & 12 deletions packages/astro/src/assets/utils/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@ export async function imageMetadata(
data: Uint8Array,
src?: string
): Promise<Omit<ImageMetadata, 'src' | 'fsPath'>> {
const result = probe(data);
try {
const result = probe(data);
if (!result.height || !result.width || !result.type) {
throw new AstroError({
...AstroErrorData.NoImageMetadata,
message: AstroErrorData.NoImageMetadata.message(src),
});
}

if (!result.height || !result.width || !result.type) {
const { width, height, type, orientation } = result;
const isPortrait = (orientation || 0) >= 5;

return {
width: isPortrait ? height : width,
height: isPortrait ? width : height,
format: type as ImageInputFormat,
orientation,
};
} catch (e) {
throw new AstroError({
...AstroErrorData.NoImageMetadata,
message: AstroErrorData.NoImageMetadata.message(src),
});
}

const { width, height, type, orientation } = result;
const isPortrait = (orientation || 0) >= 5;

return {
width: isPortrait ? height : width,
height: isPortrait ? width : height,
format: type as ImageInputFormat,
orientation,
};
}
12 changes: 12 additions & 0 deletions packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ export class App {
this.#logRenderOptionsDeprecationWarning();
}
}
if (routeData) {
this.#logger.debug(
'router',
'The adapter ' + this.#manifest.adapterName + ' provided a custom RouteData for ',
request.url
);
this.#logger.debug('router', 'RouteData:\n' + routeData);
}
if (locals) {
if (typeof locals !== 'object') {
this.#logger.error(null, new AstroError(AstroErrorData.LocalsNotAnObject).stack!);
Expand All @@ -296,8 +304,12 @@ export class App {
}
if (!routeData) {
routeData = this.match(request);
this.#logger.debug('router', 'Astro matched the following route for ' + request.url);
this.#logger.debug('router', 'RouteData:\n' + routeData);
}
if (!routeData) {
this.#logger.debug('router', "Astro hasn't found routes that match " + request.url);
this.#logger.debug('router', "Here's the available routes:\n", this.#manifestData);
return this.#renderError(request, { locals, status: 404 });
}
const pathname = this.#getPathnameFromRequest(request);
Expand Down
14 changes: 10 additions & 4 deletions packages/astro/src/core/app/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ export class AppPipeline extends Pipeline {
return module.page();
}

async tryRewrite(payload: RewritePayload): Promise<[RouteData, ComponentInstance]> {
async tryRewrite(
payload: RewritePayload,
request: Request
): Promise<[RouteData, ComponentInstance]> {
let foundRoute;

for (const route of this.#manifestData!.routes) {
Expand All @@ -86,9 +89,12 @@ export class AppPipeline extends Pipeline {
foundRoute = route;
break;
}
} else if (route.pattern.test(decodeURI(payload))) {
foundRoute = route;
break;
} else {
const newUrl = new URL(payload, new URL(request.url).origin);
if (route.pattern.test(decodeURI(newUrl.pathname))) {
foundRoute = route;
break;
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/astro/src/core/base-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ export abstract class Pipeline {
*
* @param {RewritePayload} rewritePayload
*/
abstract tryRewrite(rewritePayload: RewritePayload): Promise<[RouteData, ComponentInstance]>;
abstract tryRewrite(
rewritePayload: RewritePayload,
request: Request
): Promise<[RouteData, ComponentInstance]>;

/**
* Tells the pipeline how to retrieve a component give a `RouteData`
Expand Down
Loading

0 comments on commit 0644d2b

Please sign in to comment.