Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Feb 24, 2022
2 parents b96a10b + 11b4d97 commit 8c35bf7
Show file tree
Hide file tree
Showing 68 changed files with 482 additions and 178 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-pugs-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Prevent double-fixing of error stack traces in dev mode
5 changes: 5 additions & 0 deletions .changeset/breezy-onions-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

create `__data.json` for pathnames with trailing slashes, including `/`
5 changes: 5 additions & 0 deletions .changeset/clean-islands-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] remove private methods to make Safari 14.1 work
5 changes: 5 additions & 0 deletions .changeset/curvy-rivers-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-svelte": patch
---

[fix] update docs URL for App namespace interfaces
5 changes: 5 additions & 0 deletions .changeset/cyan-cobras-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[breaking] referer header sent by fetch in load matches page's referer header, not the page itself
5 changes: 5 additions & 0 deletions .changeset/eight-chicken-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Disable meta http-equiv tags for static amp configuration
5 changes: 5 additions & 0 deletions .changeset/four-ties-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-auto': patch
---

Attempt to bump @next version of adapter-auto
5 changes: 5 additions & 0 deletions .changeset/great-seahorses-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

fix `@typescript-eslint/no-empty-interface` lint error when starting a new app with eslint
5 changes: 5 additions & 0 deletions .changeset/green-garlics-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Add option to create integration tests with Playwright
6 changes: 6 additions & 0 deletions .changeset/hip-windows-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sveltejs/adapter-auto': patch
'@sveltejs/adapter-cloudflare': patch
---

Bumping versions again
5 changes: 5 additions & 0 deletions .changeset/little-geckos-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[breaking] remove sveltekit:navigation-{start,end} events
5 changes: 5 additions & 0 deletions .changeset/old-years-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[breaking] defer pushState until navigation occurs
19 changes: 16 additions & 3 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"@sveltejs/app-utils": "0.0.18",
"create-svelte": "2.0.0-alpha.19",
"@sveltejs/kit": "0.0.30",
"@sveltejs/vite-plugin-svelte": "1.0.0-next.0",
"@sveltejs/vite-plugin-svelte": "0.0.1",
"@sveltejs/adapter-cloudflare-workers": "0.0.1",
"@sveltejs/adapter-cloudflare": "1.0.0-next.0",
"@sveltejs/adapter-auto": "1.0.0-next",
"@sveltejs/adapter-cloudflare": "0.0.1",
"@sveltejs/adapter-auto": "0.0.1",
"set-env-action": "1.0.0",
"~TODO~": "0.0.1",
"prerendering-test-basics": "0.0.1",
Expand Down Expand Up @@ -51,6 +51,7 @@
"brave-turkeys-bathe",
"brave-weeks-allow",
"breezy-games-count",
"breezy-onions-remember",
"breezy-sheep-dress",
"breezy-students-refuse",
"bright-cherries-hug",
Expand Down Expand Up @@ -88,6 +89,7 @@
"clean-camels-pump",
"clean-chicken-walk",
"clean-countries-push",
"clean-islands-do",
"clever-dolls-poke",
"clever-donuts-smile",
"clever-eagles-live",
Expand Down Expand Up @@ -115,9 +117,11 @@
"curvy-dots-join",
"curvy-eggs-sip",
"curvy-experts-try",
"curvy-rivers-share",
"curvy-sloths-brake",
"curvy-zebras-tan",
"cyan-ads-pump",
"cyan-cobras-explode",
"cyan-knives-mix",
"cyan-numbers-change",
"cyan-parents-enjoy",
Expand All @@ -139,6 +143,7 @@
"early-snakes-peel",
"early-wasps-obey",
"eight-birds-run",
"eight-chicken-sin",
"eight-glasses-sparkle",
"eight-hats-worry",
"eight-keys-give",
Expand Down Expand Up @@ -195,6 +200,7 @@
"four-cheetahs-yawn",
"four-news-turn",
"four-pillows-give",
"four-ties-destroy",
"fresh-adults-ring",
"fresh-dolls-destroy",
"fresh-hats-tie",
Expand Down Expand Up @@ -238,6 +244,8 @@
"great-guests-visit",
"great-kangaroos-eat",
"great-queens-rule",
"great-seahorses-fry",
"green-garlics-warn",
"green-mayflies-shave",
"green-spoons-count",
"grumpy-days-compete",
Expand Down Expand Up @@ -265,6 +273,7 @@
"hip-nails-burn",
"hip-nails-taste",
"hip-walls-flash",
"hip-windows-sit",
"honest-beers-sing",
"honest-bikes-pull",
"honest-jars-report",
Expand Down Expand Up @@ -323,6 +332,7 @@
"light-roses-teach",
"little-boats-allow",
"little-candles-trade",
"little-geckos-smell",
"little-shirts-happen",
"little-tables-decide",
"long-bulldogs-invent",
Expand Down Expand Up @@ -414,6 +424,7 @@
"odd-ligers-swim",
"old-ears-wait",
"old-files-jump",
"old-years-march",
"olive-frogs-add",
"olive-frogs-drive",
"olive-maps-join",
Expand Down Expand Up @@ -685,6 +696,7 @@
"tidy-pigs-peel",
"tidy-turkeys-rule",
"tidy-wasps-shave",
"tiny-badgers-love",
"tiny-candles-repeat",
"tiny-files-smile",
"tiny-gorillas-whisper",
Expand Down Expand Up @@ -712,6 +724,7 @@
"twelve-feet-deny",
"twelve-goats-knock",
"twelve-onions-burn",
"twenty-dogs-shout",
"twenty-dryers-hope",
"twenty-hairs-shave",
"twenty-numbers-destroy",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/serious-panthers-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Expose Navigation type
5 changes: 5 additions & 0 deletions .changeset/stupid-beds-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

add new `Page` type
5 changes: 5 additions & 0 deletions .changeset/three-elephants-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-netlify': patch
---

Fix incorrect set-cookie header handling on adapter-netlify
5 changes: 5 additions & 0 deletions .changeset/tiny-badgers-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Ignore click event if url does not have origin (e.g. `mailto:`, `tel:`)
6 changes: 6 additions & 0 deletions .changeset/twenty-dogs-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sveltejs/adapter-auto': patch
'@sveltejs/adapter-cloudflare': patch
---

Attempt to force @next version bump
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.1.0
- uses: pnpm/action-setup@v2.2.0
with:
version: 6.23.2
- uses: actions/setup-node@v2
Expand All @@ -39,7 +39,7 @@ jobs:
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.1.0
- uses: pnpm/action-setup@v2.2.0
with:
version: 6.23.2
- uses: actions/setup-node@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
- uses: pnpm/action-setup@v2.1.0
- uses: pnpm/action-setup@v2.2.0
with:
version: 6.23.2
- name: Setup Node.js
Expand Down
37 changes: 24 additions & 13 deletions documentation/docs/01-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ A file or directory can have multiple dynamic parts, like `[id]-[category].svelt

### Endpoints

Endpoints are modules written in `.js` (or `.ts`) files that export functions corresponding to HTTP methods. Their job is to allow pages to read and write data that is only available on the server (for example in a database, or on the filesystem).

If an endpoint has the same filename as a page (except for the extension), the page will get its props from the endpoint. So a page like `src/routes/items/[id].svelte` could get its props from this file:
Endpoints are modules written in `.js` (or `.ts`) files that export [request handler](/docs/types#sveltejs-kit-requesthandler) functions corresponding to HTTP methods. Their job is to make it possible to read and write data that is only available on the server (for example in a database, or on the filesystem).

```js
/// file: src/routes/items/[id].js
Expand Down Expand Up @@ -81,7 +79,7 @@ export async function get({ params }) {

> All server-side code, including endpoints, has access to `fetch` in case you need to request data from external APIs. Don't worry about the `$lib` import, we'll get to that [later](/docs/modules#$lib).
The job of this function is to return a `{ status, headers, body }` object representing the response, where `status` is an [HTTP status code](https://httpstatusdogs.com):
The job of a [request handler](/docs/types#sveltejs-kit-requesthandler) is to return a `{ status, headers, body }` object representing the response, where `status` is an [HTTP status code](https://httpstatusdogs.com):

- `2xx` — successful response (default is `200`)
- `3xx` — redirection (should be accompanied by a `location` header)
Expand All @@ -90,7 +88,11 @@ The job of this function is to return a `{ status, headers, body }` object repre

> If `{fallthrough: true}` is returned SvelteKit will [fall through](/docs/routing#advanced-routing-fallthrough-routes) to other routes until something responds, or will respond with a generic 404.
The returned `body` corresponds to the page's props:
#### Page endpoints

If an endpoint has the same filename as a page (except for the extension), the page gets its props from the endpoint — via `fetch` during client-side navigation, or via direct function call during SSR.

A page like `src/routes/items/[id].svelte` could get its props from the `body` in the endpoint above:

```svelte
/// file: src/routes/items/[id].svelte
Expand All @@ -102,6 +104,23 @@ The returned `body` corresponds to the page's props:
<h1>{item.title}</h1>
```

Because the page and route have the same URL, you will need to include an `accept: application/json` header to get JSON from the endpoint rather than HTML from the page. You can also get the raw data by appending `/__data.json` to the URL, e.g. `/items/__data.json`.

#### Standalone endpoints

Most commonly, endpoints exist to provide data to the page with which they're paired. They can, however, exist separately from pages. Standalone endpoints have slightly more flexibility over the returned `body` type — in addition to objects, they can return a `Uint8Array`.

Standalone endpoints can be given a file extension if desired, or accessed directly if not:

| filename | endpoint |
| ----------------------------- | ---------- |
| src/routes/data/index.json.js | /data.json |
| src/routes/data.json.js | /data.json |
| src/routes/data/index.js | /data |
| src/routes/data.js | /data |

> Support for streaming request and response bodies is [coming soon](/~https://github.com/sveltejs/kit/issues/3419).
#### POST, PUT, PATCH, DELETE

Endpoints can handle any HTTP method — not just `GET` — by exporting the corresponding function:
Expand Down Expand Up @@ -191,8 +210,6 @@ export async function post({ request }) {
</form>
```

If you request the route with an `accept: application/json` header, SvelteKit will render the endpoint data as JSON, rather than the page as HTML.

#### Body parsing

The `request` object is an instance of the standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) class. As such, accessing the request body is easy:
Expand Down Expand Up @@ -263,12 +280,6 @@ export default config;

> Using native `<form>` behaviour ensures your app continues to work when JavaScript fails or is disabled.
### Standalone endpoints

Most commonly, endpoints exist to provide data to the page with which they're paired. They can, however, exist separately from pages. Standalone endpoints have slightly more flexibility over the returned `body` type — in addition to objects, they can return a string or a `Uint8Array`.

> Support for streaming request and response bodies is [coming soon](/~https://github.com/sveltejs/kit/issues/3419).
### Private modules

Files and directories with a leading `_` or `.` (other than [`.well-known`](https://en.wikipedia.org/wiki/Well-known_URI)) are private by default, meaning that they do not create routes (but can be imported by files that do). You can configure which modules are considered public or private with the [`routes`](/docs/configuration#routes) configuration.
Expand Down
8 changes: 2 additions & 6 deletions documentation/docs/08-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
title: Events
---

SvelteKit emits [CustomEvents](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) on the `window` object when certain things happen:
SvelteKit emits a `sveltekit:start` [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) on the `window` object once the app has hydrated.

- `sveltekit:start` — fired once the app has hydrated
- `sveltekit:navigation-start` — navigation has started
- `sveltekit:navigation-end` — navigation has ended

You probably won't need to use these, but they can be useful in the context of (for example) integration tests.
You probably won't need to use it, but it can be useful in the context of (for example) integration tests.
24 changes: 24 additions & 0 deletions packages/adapter-auto/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# @sveltejs/adapter-auto

## 1.0.0-next.27

### Patch Changes

- Bumping versions again ([#4090](/~https://github.com/sveltejs/kit/pull/4090))

- Updated dependencies [[`69401762`](/~https://github.com/sveltejs/kit/commit/694017624ec8f1abaad7ebefb867bb065f7adf05)]:
- @sveltejs/adapter-cloudflare@1.0.0-next.14

## 1.0.0-next.26

### Patch Changes

- Attempt to force @next version bump ([#4088](/~https://github.com/sveltejs/kit/pull/4088))

- Updated dependencies [[`46f44a61`](/~https://github.com/sveltejs/kit/commit/46f44a61624bed525e393e669da9b7db566a1e18)]:
- @sveltejs/adapter-cloudflare@1.0.0-next.13

## 1.0.0-next.25

### Patch Changes

- Attempt to bump @next version of adapter-auto ([#4082](/~https://github.com/sveltejs/kit/pull/4082))

## 1.0.0-next.24

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-auto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/adapter-auto",
"version": "1.0.0-next.24",
"version": "1.0.0-next.27",
"repository": {
"type": "git",
"url": "/~https://github.com/sveltejs/kit",
Expand Down
12 changes: 12 additions & 0 deletions packages/adapter-cloudflare/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @sveltejs/adapter-cloudflare

## 1.0.0-next.14

### Patch Changes

- Bumping versions again ([#4090](/~https://github.com/sveltejs/kit/pull/4090))

## 1.0.0-next.13

### Patch Changes

- Attempt to force @next version bump ([#4088](/~https://github.com/sveltejs/kit/pull/4088))

## 1.0.0-next.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/adapter-cloudflare",
"version": "1.0.0-next.12",
"version": "1.0.0-next.14",
"repository": {
"type": "git",
"url": "/~https://github.com/sveltejs/kit",
Expand Down
Loading

0 comments on commit 8c35bf7

Please sign in to comment.