Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Oct 4, 2024
2 parents 8f064fa + b8673df commit 7a1d54a
Show file tree
Hide file tree
Showing 67 changed files with 424 additions and 105 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-rice-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Support passing the values `Infinity` and `-Infinity` as island props.
5 changes: 5 additions & 0 deletions .changeset/beige-students-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vue': patch
---

Fixes a case where IDs generated by `useId()` (introduced in Vue 3.5) would not be unique between islands
5 changes: 0 additions & 5 deletions .changeset/bright-swans-shout.md

This file was deleted.

8 changes: 8 additions & 0 deletions .changeset/large-phones-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'create-astro': patch
'@astrojs/upgrade': patch
'astro': patch
'@astrojs/db': patch
---

Removes the `strip-ansi` dependency in favor of the native Node API
5 changes: 5 additions & 0 deletions .changeset/strange-cats-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Updates Vite links to use their new domain
5 changes: 5 additions & 0 deletions .changeset/thin-trains-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes missing `body` property on CollectionEntry types for content layer entries
5 changes: 5 additions & 0 deletions .changeset/wise-pumas-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Adds a helpful error when attempting to render an undefined collection entry
1 change: 1 addition & 0 deletions .github/workflows/dispatch-event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ env:
jobs:
repository-dispatch:
name: Repository dispatch
if: github.repository_owner == 'withastro'
runs-on: ubuntu-latest
steps:
- name: Dispatch event on push - adapters
Expand Down
2 changes: 1 addition & 1 deletion packages/astro-rss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const blog = defineCollection({

## `pagesGlobToRssItems()`

To create an RSS feed from documents in `src/pages/`, use the `pagesGlobToRssItems()` helper. This accepts an `import.meta.glob` result ([see Vite documentation](https://vitejs.dev/guide/features.html#glob-import)) and outputs an array of valid [`RSSFeedItem`s](#items).
To create an RSS feed from documents in `src/pages/`, use the `pagesGlobToRssItems()` helper. This accepts an `import.meta.glob` result ([see Vite documentation](https://vite.dev/guide/features.html#glob-import)) and outputs an array of valid [`RSSFeedItem`s](#items).

This function assumes, but does not verify, you are globbing for items inside `src/pages/`, and all necessary feed properties are present in each document's frontmatter. If you encounter errors, verify each page frontmatter manually.
Expand Down
26 changes: 22 additions & 4 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,24 @@

- [#11974](https://github.com/withastro/astro/pull/11974) [`60211de`](https://github.com/withastro/astro/commit/60211defbfb2992ba17d1369e71c146d8928b09a) Thanks [@ascorbic](https://github.com/ascorbic)! - Exports the `RenderResult` type

## 4.15.11

### Patch Changes

- [#12097](https://github.com/withastro/astro/pull/12097) [`11d447f`](https://github.com/withastro/astro/commit/11d447f66b1a0f39489c2600139ebfb565336ce7) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes error where references in content layer schemas sometimes incorrectly report as missing

- [#12108](https://github.com/withastro/astro/pull/12108) [`918953b`](https://github.com/withastro/astro/commit/918953bd09f057131dfe029e810019c0909345cf) Thanks [@lameuler](https://github.com/lameuler)! - Fixes a bug where [data URL images](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data) were not correctly handled. The bug resulted in an `ENAMETOOLONG` error.

- [#12105](https://github.com/withastro/astro/pull/12105) [`42037f3`](https://github.com/withastro/astro/commit/42037f33e644d5a2bfba71377697fc7336ecb15b) Thanks [@ascorbic](https://github.com/ascorbic)! - Returns custom statusText that has been set in a Response

- [#12109](https://github.com/withastro/astro/pull/12109) [`ea22558`](https://github.com/withastro/astro/commit/ea225585fd12d27006434266163512ca66ad572b) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a regression that was introduced by an internal refactor of how the middleware is loaded by the Astro application. The regression was introduced by [#11550](https://github.com/withastro/astro/pull/11550).

When the edge middleware feature is opted in, Astro removes the middleware function from the SSR manifest, and this wasn't taken into account during the refactor.

- [#12106](https://github.com/withastro/astro/pull/12106) [`d3a74da`](https://github.com/withastro/astro/commit/d3a74da19644477ffc81acf2a3efb26ad3335a5e) Thanks [@ascorbic](https://github.com/ascorbic)! - Handles case where an immutable Response object is returned from an endpoint

- [#12090](https://github.com/withastro/astro/pull/12090) [`d49a537`](https://github.com/withastro/astro/commit/d49a537f2aaccd132154a15f1da4db471272ee90) Thanks [@markjaquith](https://github.com/markjaquith)! - Server islands: changes the server island HTML placeholder comment so that it is much less likely to get removed by HTML minifiers.

## 4.15.10

### Patch Changes
Expand Down Expand Up @@ -4773,7 +4791,7 @@

To not break existing APIs, aliases for the Toolbar-based names have been created. The previous API names will continue to function but will be deprecated in the future. All documentation has been updated to reflect Toolbar-based names.

- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead.
- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead.

- [#9225](https://github.com/withastro/astro/pull/9225) [`c421a3d17`](https://github.com/withastro/astro/commit/c421a3d17911aeda29b5204f6d568ae87e329eaf) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Removes the opt-in `handleForms` property for `<ViewTransitions />`. Form submissions are now handled by default and this property is no longer necessary. This default behavior can be disabled by setting `data-astro-reload` on relevant `<form />` elements.

Expand Down Expand Up @@ -5109,7 +5127,7 @@

The types for middlewares have also been revised. To type a middleware function, you should now use `MiddlewareHandler` instead of `MiddlewareResponseHandler`. If you used `defineMiddleware()` to type the function, no changes are needed.

- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vitejs.dev/guide/migration.html) for details of the breaking changes from Vite instead.
- [#9122](https://github.com/withastro/astro/pull/9122) [`1c48ed286`](https://github.com/withastro/astro/commit/1c48ed286538ab9e354eca4e4dcd7c6385c96721) Thanks [@bluwy](https://github.com/bluwy)! - Adds Vite 5 support. There are no breaking changes from Astro. Check the [Vite migration guide](https://vite.dev/guide/migration.html) for details of the breaking changes from Vite instead.

- [#9196](https://github.com/withastro/astro/pull/9196) [`37697a2c5`](https://github.com/withastro/astro/commit/37697a2c5511572dc29c0a4ea46f90c2f62be8e6) Thanks [@bluwy](https://github.com/bluwy)! - Removes support for Shiki custom language's `path` property. The language JSON file should be imported and passed to the option instead.

Expand Down Expand Up @@ -9318,7 +9336,7 @@
<!-- You have an entry! Use it! -->
```

- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vitejs.dev/guide/migration.html) for more information.
- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vite.dev/guide/migration.html) for more information.

- [#5724](https://github.com/withastro/astro/pull/5724) [`16c7d0bfd`](https://github.com/withastro/astro/commit/16c7d0bfd49d2b9bfae45385f506bcd642f9444a) Thanks [@bluwy](https://github.com/bluwy)! - Remove outdated Vue info log. Remove `toString` support for `RenderTemplateResult`.

Expand Down Expand Up @@ -9875,7 +9893,7 @@

- [#5716](https://github.com/withastro/astro/pull/5716) [`dd56c1941`](https://github.com/withastro/astro/commit/dd56c19411b126439b8bc42d681b6fa8c06e8c61) Thanks [@bluwy](https://github.com/bluwy)! - Remove MDX Fragment hack. This was used by `@astrojs/mdx` to access the `Fragment` component, but isn't require anymore since `@astrojs/mdx` v0.12.1.

- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vitejs.dev/guide/migration.html) for more information.
- [#5685](https://github.com/withastro/astro/pull/5685) [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade to Vite 4. Please see its [migration guide](https://vite.dev/guide/migration.html) for more information.

- [#5724](https://github.com/withastro/astro/pull/5724) [`16c7d0bfd`](https://github.com/withastro/astro/commit/16c7d0bfd49d2b9bfae45385f506bcd642f9444a) Thanks [@bluwy](https://github.com/bluwy)! - Remove outdated Vue info log. Remove `toString` support for `RenderTemplateResult`.

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface ImportMeta {
* Astro and Vite expose environment variables through `import.meta.env`. For a complete list of the environment variables available, see the two references below.
*
* - [Astro reference](https://docs.astro.build/en/guides/environment-variables/#default-environment-variables)
* - [Vite reference](https://vitejs.dev/guide/env-and-mode.html#env-variables)
* - [Vite reference](https://vite.dev/guide/env-and-mode.html#env-variables)
*/
readonly env: ImportMetaEnv;
}
Expand Down
8 changes: 7 additions & 1 deletion packages/astro/e2e/fixtures/pass-js/src/components/React.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ interface Props {
array: any[];
map: Map<string, string>;
set: Set<string>;
infinity: number;
negativeInfinity: number;
}

const isNode = typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]';

/** a counter written in React */
export default function Component({ undefined: undefinedProp, null: nullProp, boolean, number, string, bigint, object, array, map, set }: Props) {
export default function Component({ undefined: undefinedProp, null: nullProp, boolean, number, string, bigint, object, array, map, set, infinity, negativeInfinity }: Props) {
// We are testing hydration, so don't return anything in the server.
if(isNode) {
return <div></div>
Expand All @@ -30,6 +32,10 @@ export default function Component({ undefined: undefinedProp, null: nullProp, bo
<span id="boolean-value">{boolean.toString()}</span>
<span id="number-type">{Object.prototype.toString.call(number)}</span>
<span id="number-value">{number.toString()}</span>
<span id="infinity-type">{Object.prototype.toString.call(infinity)}</span>
<span id="infinity-value">{infinity.toString()}</span>
<span id="negative-infinity-type">{Object.prototype.toString.call(negativeInfinity)}</span>
<span id="negative-infinity-value">{negativeInfinity.toString()}</span>
<span id="string-type">{Object.prototype.toString.call(string)}</span>
<span id="string-value">{string}</span>
<span id="bigint-type">{Object.prototype.toString.call(bigint)}</span>
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/e2e/fixtures/pass-js/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ set.add('test2');
array={[0, "foo"]}
map={map}
set={set}
infinity={Infinity}
negativeInfinity={-Infinity}
/>
</main>
</body>
Expand Down
16 changes: 16 additions & 0 deletions packages/astro/e2e/pass-js.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ test.describe('Passing JS into client components', () => {
await expect(numberValue, 'is visible').toBeVisible();
await expect(numberValue).toHaveText('16');

const infinityType = page.locator('#infinity-type');
await expect(infinityType, 'is visible').toBeVisible();
await expect(infinityType).toHaveText('[object Number]');

const negativeInfinityType = page.locator('#negative-infinity-type');
await expect(negativeInfinityType, 'is visible').toBeVisible();
await expect(negativeInfinityType).toHaveText('[object Number]');

const infinityValue = page.locator('#infinity-value');
await expect(infinityValue, 'is visible').toBeVisible();
await expect(infinityValue).toHaveText('Infinity');

const negativeInfinityValue = page.locator('#negative-infinity-value');
await expect(negativeInfinityValue, 'is visible').toBeVisible();
await expect(negativeInfinityValue).toHaveText('-Infinity');

// string
const stringType = page.locator('#string-type');
await expect(stringType, 'is visible').toBeVisible();
Expand Down
1 change: 0 additions & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
"semver": "^7.6.3",
"shiki": "^1.21.0",
"string-width": "^7.2.0",
"strip-ansi": "^7.1.0",
"tinyexec": "^0.3.0",
"tsconfck": "^3.1.3",
"unist-util-visit": "^5.0.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/astro/src/assets/utils/transformToPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { isESMImportedImage } from './imageKind.js';
export function propsToFilename(filePath: string, transform: ImageTransform, hash: string) {
let filename = decodeURIComponent(removeQueryString(filePath));
const ext = extname(filename);
filename = basename(filename, ext);
if (filePath.startsWith('data:')) {
filename = shorthash(filePath);
} else {
filename = basename(filename, ext);
}
const prefixDirname = isESMImportedImage(transform.src) ? dirname(filePath) : '';

let outputExt = transform.format ? `.${transform.format}` : ext;
Expand Down
6 changes: 5 additions & 1 deletion packages/astro/src/content/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,11 @@ function updateImageReferencesInData<T extends Record<string, unknown>>(
export async function renderEntry(
entry: DataEntry | { render: () => Promise<{ Content: AstroComponentFactory }> },
) {
if (entry && 'render' in entry) {
if (!entry) {
throw new AstroError(AstroErrorData.RenderUndefinedEntryError);
}

if ('render' in entry) {
// This is an old content collection entry, so we use its render method
return entry.render();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/types-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ async function writeContentFiles({
contentTypesStr += `};\n`;
break;
case CONTENT_LAYER_TYPE:
dataTypesStr += `${collectionKey}: Record<string, {\n id: string;\n collection: ${collectionKey};\n data: ${dataType};\n rendered?: RenderedContent;\n filePath?: string \n}>;\n`;
dataTypesStr += `${collectionKey}: Record<string, {\n id: string;\n collection: ${collectionKey};\n data: ${dataType};\n rendered?: RenderedContent;\n filePath?: string;\n body?: string \n}>;\n`;
break;
case 'data':
if (collectionEntryKeys.length === 0) {
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/src/core/app/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export class NodeApp extends App {
* @param destination NodeJS ServerResponse
*/
static async writeResponse(source: Response, destination: ServerResponse) {
const { status, headers, body } = source;
const { status, headers, body, statusText } = source;
destination.statusMessage = statusText;
destination.writeHead(status, createOutgoingHttpHeaders(headers));
if (!body) return destination.end();
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type SSRManifest = {
serverIslandNameMap?: Map<string, string>;
key: Promise<CryptoKey>;
i18n: SSRManifestI18n | undefined;
middleware: () => Promise<AstroMiddlewareInstance> | AstroMiddlewareInstance;
middleware?: () => Promise<AstroMiddlewareInstance> | AstroMiddlewareInstance;
checkOrigin: boolean;
envGetSecretEnabled: boolean;
};
Expand Down
8 changes: 7 additions & 1 deletion packages/astro/src/core/base-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export abstract class Pipeline {
async getMiddleware(): Promise<MiddlewareHandler> {
if (this.resolvedMiddleware) {
return this.resolvedMiddleware;
} else {
}
// The middleware can be undefined when using edge middleware.
// This is set to undefined by the plugin-ssr.ts
else if (this.middleware) {
const middlewareInstance = await this.middleware();
const onRequest = middlewareInstance.onRequest ?? NOOP_MIDDLEWARE_FN;
if (this.manifest.checkOrigin) {
Expand All @@ -117,6 +120,9 @@ export abstract class Pipeline {
this.resolvedMiddleware = onRequest;
}
return this.resolvedMiddleware;
} else {
this.resolvedMiddleware = NOOP_MIDDLEWARE_FN;
return this.resolvedMiddleware;
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions packages/astro/src/core/errors/dev/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as fs from 'node:fs';
import { isAbsolute, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { stripVTControlCharacters } from 'node:util';
import { escape } from 'html-escaper';
import { bold, underline } from 'kleur/colors';
import stripAnsi from 'strip-ansi';
import type { ESBuildTransformResult } from 'vite';
import { normalizePath } from 'vite';
import type { SSRError } from '../../../types/public/internal.js';
Expand All @@ -27,7 +27,7 @@ export function collectErrorMetadata(e: any, rootFolder?: URL): ErrorWithMetadat
if (e.stack) {
const stackInfo = collectInfoFromStacktrace(e);
try {
error.stack = stripAnsi(stackInfo.stack);
error.stack = stripVTControlCharacters(stackInfo.stack);
} catch {}
error.loc = stackInfo.loc;
error.plugin = stackInfo.plugin;
Expand Down Expand Up @@ -59,7 +59,7 @@ export function collectErrorMetadata(e: any, rootFolder?: URL): ErrorWithMetadat

if (!error.frame) {
const frame = codeFrame(fileContents, error.loc);
error.frame = stripAnsi(frame);
error.frame = stripVTControlCharacters(frame);
}

if (!error.fullCode) {
Expand All @@ -75,7 +75,7 @@ export function collectErrorMetadata(e: any, rootFolder?: URL): ErrorWithMetadat
// but it will be handled and added below, which is already ANSI-free
if (error.message) {
try {
error.message = stripAnsi(error.message);
error.message = stripVTControlCharacters(error.message);
} catch {
// Setting `error.message` can fail here if the message is read-only, which for the vast majority of cases will never happen, however some somewhat obscure cases can cause this to happen.
}
Expand Down Expand Up @@ -170,7 +170,7 @@ function collectInfoFromStacktrace(error: SSRError & { stack: string }): StackIn

// normalize error stack line-endings to \n
stackInfo.stack = normalizeLF(error.stack);
const stackText = stripAnsi(error.stack);
const stackText = stripVTControlCharacters(error.stack);

// Try to find possible location from stack if we don't have one
if (!stackInfo.loc || (!stackInfo.loc.column && !stackInfo.loc.line)) {
Expand Down
Loading

0 comments on commit 7a1d54a

Please sign in to comment.