Skip to content

Commit

Permalink
Merge branch 'main' into fix/conditional-slots
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored Jul 7, 2022
2 parents 918b79e + 568960f commit 8c787ce
Show file tree
Hide file tree
Showing 43 changed files with 122 additions and 84 deletions.
5 changes: 0 additions & 5 deletions .changeset/hip-months-invent.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/itchy-bottles-rhyme.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/rare-elephants-add.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 @@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/blog-multiple-authors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/preact": "^0.3.1",
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"sass": "^1.52.2"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/preact": "^0.3.1",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"preact": "^10.7.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/component/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"@example/my-component": "workspace:*",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"serve": "astro --root demo preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"devDependencies": {
"@astrojs/preact": "^0.3.1",
"@astrojs/react": "^0.2.0",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/env-vars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/framework-alpine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"alpinejs": "^3.10.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/lit": "^0.3.0",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"@webcomponents/template-shadowroot": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-multiple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@astrojs/solid-js": "^0.2.0",
"@astrojs/svelte": "^0.2.0",
"@astrojs/vue": "^0.2.0",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"@webcomponents/template-shadowroot": "^0.1.0",
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 @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/preact": "^0.3.1",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"preact": "^10.7.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@astrojs/react": "^0.2.0",
"@types/react": "^18.0.10",
"@types/react-dom": "^18.0.5",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"react": "^18.1.0",
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 @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/solid-js": "^0.2.0",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"solid-js": "^1.4.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/svelte": "^0.2.0",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"svelte": "^3.48.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/framework-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/vue": "^0.2.0",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"vue": "^3.2.37"
Expand Down
2 changes: 1 addition & 1 deletion examples/integrations-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@astrojs/solid-js": "0.2.0",
"@astrojs/tailwind": "^0.2.2",
"@astrojs/turbolinks": "^0.1.3",
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"solid-js": "^1.4.3"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/non-html-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/portfolio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/preact": "^0.3.1",
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"sass": "^1.52.2"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions examples/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"server": "node server/server.mjs"
},
"devDependencies": {
"@astrojs/node": "^0.1.3",
"@astrojs/node": "^0.1.4",
"@astrojs/svelte": "^0.2.0",
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"concurrently": "^7.2.1",
"lightcookie": "^1.0.25",
"unocss": "^0.15.6",
Expand Down
2 changes: 1 addition & 1 deletion examples/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/subpath/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/react": "^0.2.0",
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"sass": "^1.52.2"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/with-markdown-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/markdown-remark": "^0.11.3",
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"hast-util-select": "5.0.1",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.0.1",
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 @@ -10,6 +10,6 @@
},
"devDependencies": {
"@astrojs/markdown-remark": "^0.11.3",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/with-markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/react": "^0.2.0",
"@astrojs/svelte": "^0.2.0",
"@astrojs/vue": "^0.2.0",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
},
"dependencies": {
"preact": "^10.7.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"@astrojs/mdx": "^0.0.2",
"@astrojs/preact": "^0.3.1",
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"preact": "^10.6.5"
}
}
2 changes: 1 addition & 1 deletion examples/with-nanostores/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"@astrojs/solid-js": "^0.2.0",
"@astrojs/svelte": "^0.2.0",
"@astrojs/vue": "^0.2.0",
"astro": "^1.0.0-beta.63"
"astro": "^1.0.0-beta.64"
}
}
2 changes: 1 addition & 1 deletion examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/tailwind": "^0.2.2",
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"autoprefixer": "^10.4.7",
"canvas-confetti": "^1.5.1",
"postcss": "^8.4.14",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vite-plugin-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.63",
"astro": "^1.0.0-beta.64",
"vite-plugin-pwa": "0.11.11",
"workbox-window": "^6.5.3"
}
Expand Down
13 changes: 13 additions & 0 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# astro

## 1.0.0-beta.64

### Patch Changes

- [#3821](https://github.com/withastro/astro/pull/3821) [`c2165c34`](https://github.com/withastro/astro/commit/c2165c34a76c183b3af6303526ae292a1f2426ce) Thanks [@matthewp](https://github.com/matthewp)! - Fix for putting the <head> into its own component

* [#3841](https://github.com/withastro/astro/pull/3841) [`820a26dd`](https://github.com/withastro/astro/commit/820a26dde5cdc11b5bf430bc2a1e3b09084ae045) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix: add default content type to endpoints with { body } shorthand

- [#3839](https://github.com/withastro/astro/pull/3839) [`cd3f6348`](https://github.com/withastro/astro/commit/cd3f6348c4e918b5367587bce58d724aec44eddd) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix `client:visible` directive in safari

- Updated dependencies [[`e4b2dca1`](https://github.com/withastro/astro/commit/e4b2dca1f3f03bd951f1d623695631cebf638c67)]:
- @astrojs/telemetry@0.2.4

## 1.0.0-beta.63

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astro",
"version": "1.0.0-beta.63",
"version": "1.0.0-beta.64",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
Expand Down Expand Up @@ -84,7 +84,7 @@
"@astrojs/language-server": "^0.13.4",
"@astrojs/markdown-remark": "^0.11.3",
"@astrojs/prism": "0.4.1",
"@astrojs/telemetry": "^0.2.3",
"@astrojs/telemetry": "^0.2.4",
"@astrojs/webapi": "^0.12.0",
"@babel/core": "^7.18.2",
"@babel/generator": "^7.18.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export class App {
const headers = new Headers();
const mimeType = mime.getType(url.pathname);
if (mimeType) {
headers.set('Content-Type', mimeType);
headers.set('Content-Type', `${mimeType};charset=utf-8`);
} else {
headers.set('Content-Type', 'text/plain;charset=utf-8');
}
const bytes = this.#encoder.encode(body);
headers.set('Content-Length', bytes.byteLength.toString());
Expand Down
15 changes: 14 additions & 1 deletion packages/astro/src/runtime/server/astro-island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,20 @@ declare const Astro: {
public Component: any;
public hydrator: any;
static observedAttributes = ['props'];
async connectedCallback() {
connectedCallback() {
if (this.getAttribute('client') === 'only' || this.firstChild) {
this.childrenConnectedCallback();
} else {
// connectedCallback may run *before* children are rendered (ex. HTML streaming)
// If SSR children are expected, but not yet rendered,
// Wait with a mutation observer
new MutationObserver((_, mo) => {
mo.disconnect();
this.childrenConnectedCallback();
}).observe(this, { childList: true });
}
}
async childrenConnectedCallback() {
window.addEventListener('astro:hydrate', this.hydrate);
await import(this.getAttribute('before-hydration-url')!);
const opts = JSON.parse(this.getAttribute('opts')!) as Record<string, any>;
Expand Down
8 changes: 7 additions & 1 deletion packages/astro/src/vite-plugin-astro-server/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type http from 'http';
import mime from 'mime';
import type * as vite from 'vite';
import type { AstroConfig, ManifestData } from '../@types/astro';
import type { SSROptions } from '../core/render/dev/index';
Expand Down Expand Up @@ -315,7 +316,12 @@ async function handleRequest(
if (result.type === 'response') {
await writeWebResponse(res, result.response);
} else {
res.writeHead(200);
let contentType = 'text/plain';
const computedMimeType = route.pathname ? mime.getType(route.pathname) : null;
if (computedMimeType) {
contentType = computedMimeType;
}
res.writeHead(200, { 'Content-Type': `${contentType};charset=utf-8` });
res.end(result.body);
}
} else {
Expand Down
9 changes: 8 additions & 1 deletion packages/astro/test/ssr-api-route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('API routes in SSR', () => {
const request = new Request('http://example.com/food.json');
const response = await app.render(request);
expect(response.status).to.equal(200);
expect(response.headers.get('Content-Type')).to.equal('application/json');
expect(response.headers.get('Content-Type')).to.equal('application/json;charset=utf-8');
expect(response.headers.get('Content-Length')).to.not.be.empty;
const body = await response.json();
expect(body.length).to.equal(3);
Expand All @@ -56,6 +56,13 @@ describe('API routes in SSR', () => {
expect(text).to.equal(`ok`);
});

it('Infer content type with charset for { body } shorthand', async () => {
const response = await fixture.fetch('/food.json', {
method: 'GET',
});
expect(response.headers.get('Content-Type')).to.equal('application/json;charset=utf-8');
});

it('Can set multiple headers of the same type', async () => {
const response = await fixture.fetch('/login', {
method: 'POST',
Expand Down
6 changes: 6 additions & 0 deletions packages/integrations/node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @astrojs/node

## 0.1.4

### Patch Changes

- [#3817](https://github.com/withastro/astro/pull/3817) [`2f56664f`](https://github.com/withastro/astro/commit/2f56664f85596c6268ecb44bbb9c36cca2ea49c5) Thanks [@ran-dall](https://github.com/ran-dall)! - Fix example on `README.md`

## 0.1.3

### Patch Changes
Expand Down
Loading

0 comments on commit 8c787ce

Please sign in to comment.