From 04458faa10e0ad5d3b469dda9c84db249504ea7e Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 22 Feb 2022 12:23:09 -0800 Subject: [PATCH 01/18] [docs] remove mention of esbuild from Netlify docs (#4058) --- packages/adapter-netlify/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/adapter-netlify/README.md b/packages/adapter-netlify/README.md index ef567b62d5f8..52979b7bc155 100644 --- a/packages/adapter-netlify/README.md +++ b/packages/adapter-netlify/README.md @@ -66,7 +66,6 @@ During compilation, redirect rules are automatically appended to your `_redirect [functions] directory = "functions" - node_bundler = "esbuild" ``` ## Changelog From 50e2d36baddd77ffeef931ba5c21b3be5319046f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 22 Feb 2022 17:18:35 -0800 Subject: [PATCH 02/18] Update dependency @rollup/plugin-replace to v4 (#4064) Co-authored-by: Renovate Bot --- packages/kit/package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/kit/package.json b/packages/kit/package.json index a1c3da708cbd..5369b18a07a6 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -16,7 +16,7 @@ }, "devDependencies": { "@playwright/test": "^1.17.1", - "@rollup/plugin-replace": "^3.0.0", + "@rollup/plugin-replace": "^4.0.0", "@types/amphtml-validator": "^1.0.1", "@types/cookie": "^0.4.1", "@types/marked": "^4.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f886f30f1375..185609670d25 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -225,7 +225,7 @@ importers: packages/kit: specifiers: '@playwright/test': ^1.17.1 - '@rollup/plugin-replace': ^3.0.0 + '@rollup/plugin-replace': ^4.0.0 '@sveltejs/vite-plugin-svelte': ^1.0.0-next.32 '@types/amphtml-validator': ^1.0.1 '@types/cookie': ^0.4.1 @@ -261,7 +261,7 @@ importers: vite: 2.8.0 devDependencies: '@playwright/test': 1.17.1 - '@rollup/plugin-replace': 3.0.0_rollup@2.60.2 + '@rollup/plugin-replace': 4.0.0_rollup@2.60.2 '@types/amphtml-validator': 1.0.1 '@types/cookie': 0.4.1 '@types/marked': 4.0.1 @@ -1402,8 +1402,8 @@ packages: rollup: 2.60.2 dev: true - /@rollup/plugin-replace/3.0.0_rollup@2.60.2: - resolution: {integrity: sha512-3c7JCbMuYXM4PbPWT4+m/4Y6U60SgsnDT/cCyAyUKwFHg7pTSfsSQzIpETha3a3ig6OdOKzZz87D9ZXIK3qsDg==} + /@rollup/plugin-replace/4.0.0_rollup@2.60.2: + resolution: {integrity: sha512-+rumQFiaNac9y64OHtkHGmdjm7us9bo1PlbgQfdihQtuNxzjpaB064HbRnewUOggLQxVCCyINfStkgmBeQpv1g==} peerDependencies: rollup: ^1.20.0 || ^2.0.0 dependencies: From 8fb624168e87256d0b6eefd5da198ec295cf1ee7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 22 Feb 2022 19:43:04 -0800 Subject: [PATCH 03/18] Update pnpm/action-setup action to v2.2.0 (#4067) Co-authored-by: Renovate Bot --- .github/workflows/ci.yml | 4 ++-- .github/workflows/release.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91bb939b2c9e..2ec4201f039d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41bdc990d78c..24da638eb7c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 From 543b09e49314cc461a88ba409fe2312d3d8fb7d4 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 22 Feb 2022 19:46:02 -0800 Subject: [PATCH 04/18] [docs] update endpoint documentation (#4060) * [docs] update endpoint documentation * Update documentation/docs/01-routing.md Co-authored-by: Rich Harris * Update documentation/docs/01-routing.md Co-authored-by: Rich Harris * Update documentation/docs/01-routing.md Co-authored-by: Rich Harris --- documentation/docs/01-routing.md | 46 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/documentation/docs/01-routing.md b/documentation/docs/01-routing.md index 3e5d198feb5c..425ffbf90b51 100644 --- a/documentation/docs/01-routing.md +++ b/documentation/docs/01-routing.md @@ -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 @@ -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) @@ -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 @@ -102,6 +104,23 @@ The returned `body` corresponds to the page's props:

{item.title}

``` +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: @@ -191,8 +210,6 @@ export async function post({ request }) { ``` -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. You can also get the raw data by appending `/__data.json` to the URL, e.g. `/items/__data.json`. - #### 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: @@ -263,21 +280,6 @@ export default config; > Using native `
` 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). - -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 | - ### 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. From 736d7f961df7c1a242f214cdfa9cf29562a9a4aa Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Wed, 23 Feb 2022 13:09:57 +0900 Subject: [PATCH 05/18] [fix] create missing root's `__data.json` (#4066) * fix __data.json path for '/' * add tests * remove useless file * add changeset * fix lint * simplify test * remove adapter-static test * tidy up changeset * amend changeset Co-authored-by: Rich Harris --- .changeset/breezy-onions-remember.md | 5 +++++ packages/kit/src/runtime/server/page/load_node.js | 2 +- packages/kit/test/prerendering/basics/src/routes/index.js | 7 +++++++ .../kit/test/prerendering/basics/src/routes/index.svelte | 7 ++++++- packages/kit/test/prerendering/basics/test/test.js | 6 +++--- 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 .changeset/breezy-onions-remember.md create mode 100644 packages/kit/test/prerendering/basics/src/routes/index.js diff --git a/.changeset/breezy-onions-remember.md b/.changeset/breezy-onions-remember.md new file mode 100644 index 000000000000..0f1e44f4c91a --- /dev/null +++ b/.changeset/breezy-onions-remember.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +create `__data.json` for pathnames with trailing slashes, including `/` diff --git a/packages/kit/src/runtime/server/page/load_node.js b/packages/kit/src/runtime/server/page/load_node.js index 194a00bdfcbf..96bcfc641d89 100644 --- a/packages/kit/src/runtime/server/page/load_node.js +++ b/packages/kit/src/runtime/server/page/load_node.js @@ -346,7 +346,7 @@ export async function load_node({ // generate __data.json files when prerendering if (shadow.body && state.prerender) { - const pathname = `${event.url.pathname}/__data.json`; + const pathname = `${event.url.pathname.replace(/\/$/, '')}/__data.json`; const dependency = { response: new Response(undefined), diff --git a/packages/kit/test/prerendering/basics/src/routes/index.js b/packages/kit/test/prerendering/basics/src/routes/index.js new file mode 100644 index 000000000000..a566f067fabc --- /dev/null +++ b/packages/kit/test/prerendering/basics/src/routes/index.js @@ -0,0 +1,7 @@ +export function get() { + return { + body: { + message: 'hello' + } + }; +} diff --git a/packages/kit/test/prerendering/basics/src/routes/index.svelte b/packages/kit/test/prerendering/basics/src/routes/index.svelte index 6e7c1e6ac83f..7c991db4005a 100644 --- a/packages/kit/test/prerendering/basics/src/routes/index.svelte +++ b/packages/kit/test/prerendering/basics/src/routes/index.svelte @@ -1 +1,6 @@ -

hello

+ + +

{message}

diff --git a/packages/kit/test/prerendering/basics/test/test.js b/packages/kit/test/prerendering/basics/test/test.js index eb07ec1cd2b1..03594e1bd1dd 100644 --- a/packages/kit/test/prerendering/basics/test/test.js +++ b/packages/kit/test/prerendering/basics/test/test.js @@ -63,9 +63,9 @@ test('loads a file with spaces in the filename', () => { assert.ok(content.includes('

answer: 42

'), content); }); -test('generates __data.json file for shadow endpoint', () => { - const json = read('shadowed-get/__data.json'); - assert.equal(json, JSON.stringify({ answer: 42 })); +test('generates __data.json file for shadow endpoints', () => { + assert.equal(read('__data.json'), JSON.stringify({ message: 'hello' })); + assert.equal(read('shadowed-get/__data.json'), JSON.stringify({ answer: 42 })); }); test('does not prerender page with shadow endpoint with non-GET handler', () => { From 3d728d2f59062cf40d13896cf8709ebac8110c83 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 22 Feb 2022 23:51:53 -0500 Subject: [PATCH 06/18] Version Packages (next) (#4069) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 1 + packages/kit/CHANGELOG.md | 6 ++++++ packages/kit/package.json | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index b9c26a0a5e62..16d60225da47 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -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", diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md index 117d5374c5a2..668a85bd6459 100644 --- a/packages/kit/CHANGELOG.md +++ b/packages/kit/CHANGELOG.md @@ -1,5 +1,11 @@ # @sveltejs/kit +## 1.0.0-next.283 + +### Patch Changes + +- create `__data.json` for pathnames with trailing slashes, including `/` ([#4066](https://github.com/sveltejs/kit/pull/4066)) + ## 1.0.0-next.282 ### Patch Changes diff --git a/packages/kit/package.json b/packages/kit/package.json index 5369b18a07a6..26e1cdcdc805 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/kit", - "version": "1.0.0-next.282", + "version": "1.0.0-next.283", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", From 74b0e56c18565250510a0be3977caa22cb0640aa Mon Sep 17 00:00:00 2001 From: Ignatius Bagus Date: Wed, 23 Feb 2022 21:41:31 +0700 Subject: [PATCH 07/18] comment out empty interfaces (#4077) * comment out empty interface in default * add additional empty comment to not get collapsed * add changeset * Update packages/create-svelte/templates/skeleton/src/app.d.ts Co-authored-by: Rich Harris --- .changeset/great-seahorses-fry.md | 5 +++++ packages/create-svelte/templates/default/src/app.d.ts | 6 +++--- packages/create-svelte/templates/skeleton/src/app.d.ts | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 .changeset/great-seahorses-fry.md diff --git a/.changeset/great-seahorses-fry.md b/.changeset/great-seahorses-fry.md new file mode 100644 index 000000000000..fd5436210718 --- /dev/null +++ b/.changeset/great-seahorses-fry.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +fix `@typescript-eslint/no-empty-interface` lint error when starting a new app with eslint diff --git a/packages/create-svelte/templates/default/src/app.d.ts b/packages/create-svelte/templates/default/src/app.d.ts index 5d1bd737f7f5..dec2abdb691e 100644 --- a/packages/create-svelte/templates/default/src/app.d.ts +++ b/packages/create-svelte/templates/default/src/app.d.ts @@ -7,9 +7,9 @@ declare namespace App { userid: string; } - interface Platform {} + // interface Platform {} - interface Session {} + // interface Session {} - interface Stuff {} + // interface Stuff {} } diff --git a/packages/create-svelte/templates/skeleton/src/app.d.ts b/packages/create-svelte/templates/skeleton/src/app.d.ts index 5ec43e560407..4175b0372aa8 100644 --- a/packages/create-svelte/templates/skeleton/src/app.d.ts +++ b/packages/create-svelte/templates/skeleton/src/app.d.ts @@ -3,11 +3,11 @@ // See https://kit.svelte.dev/docs/types#the-app-namespace // for information about these interfaces declare namespace App { - interface Locals {} + // interface Locals {} - interface Platform {} + // interface Platform {} - interface Session {} + // interface Session {} - interface Stuff {} + // interface Stuff {} } From 56ae395da30b6fb8d4c736baa0fe94448bb4b471 Mon Sep 17 00:00:00 2001 From: Ignatius Bagus Date: Wed, 23 Feb 2022 21:49:20 +0700 Subject: [PATCH 08/18] chore: organize and deduplicate types (#4075) * sort import alphabetically * use TrailingSlash type * single quote string literals * don't have any duplicates anymore * make ambient import separation clearer --- packages/kit/src/utils/url.js | 2 +- packages/kit/types/ambient.d.ts | 2 -- packages/kit/types/index.d.ts | 27 ++++++++++++++------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/kit/src/utils/url.js b/packages/kit/src/utils/url.js index 8029bf82472e..5f34ca4306d9 100644 --- a/packages/kit/src/utils/url.js +++ b/packages/kit/src/utils/url.js @@ -39,7 +39,7 @@ export function is_root_relative(path) { /** * @param {string} path - * @param {'always' | 'never' | 'ignore'} trailing_slash + * @param {import('types').TrailingSlash} trailing_slash */ export function normalize_path(path, trailing_slash) { if (path === '/' || trailing_slash === 'ignore') return path; diff --git a/packages/kit/types/ambient.d.ts b/packages/kit/types/ambient.d.ts index 5cffcef510be..5ee79a4340bb 100644 --- a/packages/kit/types/ambient.d.ts +++ b/packages/kit/types/ambient.d.ts @@ -1,5 +1,3 @@ -/* eslint-disable import/no-duplicates */ - declare namespace App { interface Locals {} interface Platform {} diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 666d8dcfd279..2cd30be8c304 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -1,24 +1,25 @@ /// /// +import './ambient'; + import { CompileOptions } from 'svelte/types/compiler/interfaces'; import { - Logger, - PrerenderOnErrorValue, - SSRNodeLoader, - SSRRoute, - TrailingSlash, + AdapterEntry, + Body, Either, + Fallthrough, + Logger, MaybePromise, + PrerenderOnErrorValue, RecursiveRequired, - RouteDefinition, - AdapterEntry, - ResponseHeaders, - Fallthrough, RequiredResolveOptions, - Body + ResponseHeaders, + RouteDefinition, + SSRNodeLoader, + SSRRoute, + TrailingSlash } from './internal'; -import './ambient'; export interface Adapter { name: string; @@ -31,7 +32,7 @@ export interface Builder { mkdirp(dir: string): void; appDir: string; - trailingSlash: 'always' | 'never' | 'ignore'; + trailingSlash: TrailingSlash; /** * Create entry points that map to individual functions @@ -171,7 +172,7 @@ export namespace Csp { type BaseSource = 'self' | 'unsafe-eval' | 'unsafe-hashes' | 'unsafe-inline' | 'none'; type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`; type FrameSource = HostSource | SchemeSource | 'self' | 'none'; - type HostNameScheme = `${string}.${string}` | `localhost`; + type HostNameScheme = `${string}.${string}` | 'localhost'; type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`; type HostProtocolSchemes = `${string}://` | ''; type HttpDelineator = '/' | '?' | '#' | '\\'; From 10f555d2987993c3726cfb7eb4e51e53e6dd6a0e Mon Sep 17 00:00:00 2001 From: Asendia Mayco <9080782+asendia@users.noreply.github.com> Date: Wed, 23 Feb 2022 21:50:05 +0700 Subject: [PATCH 09/18] [fix] Disable meta http-equiv in static amp (#4073) * Disable http-equiv in AMP * Add changeset --- .changeset/eight-chicken-sin.md | 5 +++++ packages/kit/src/runtime/server/page/render.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/eight-chicken-sin.md diff --git a/.changeset/eight-chicken-sin.md b/.changeset/eight-chicken-sin.md new file mode 100644 index 000000000000..7695a508e948 --- /dev/null +++ b/.changeset/eight-chicken-sin.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Disable meta http-equiv tags for static amp configuration diff --git a/packages/kit/src/runtime/server/page/render.js b/packages/kit/src/runtime/server/page/render.js index 6970d2e944a7..eab46902efbe 100644 --- a/packages/kit/src/runtime/server/page/render.js +++ b/packages/kit/src/runtime/server/page/render.js @@ -278,7 +278,7 @@ export async function render_response({ } } - if (state.prerender) { + if (state.prerender && !options.amp) { const http_equiv = []; const csp_headers = csp.get_meta(); From 266a460467baf3882146df81f8a6966998f13385 Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Wed, 23 Feb 2022 23:55:17 +0900 Subject: [PATCH 10/18] [fix] Ignore click event if href is mailto link (#4072) * ignore click event if it is mailto link * add changeset * update logic according to discussion * update changeset --- .changeset/tiny-badgers-love.md | 5 +++++ packages/kit/src/runtime/client/router.js | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/tiny-badgers-love.md diff --git a/.changeset/tiny-badgers-love.md b/.changeset/tiny-badgers-love.md new file mode 100644 index 000000000000..4d38e8402957 --- /dev/null +++ b/.changeset/tiny-badgers-love.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Ignore click event if url does not have origin (e.g. `mailto:`, `tel:`) diff --git a/packages/kit/src/runtime/client/router.js b/packages/kit/src/runtime/client/router.js index a0301ab0e968..53cb01de9b32 100644 --- a/packages/kit/src/runtime/client/router.js +++ b/packages/kit/src/runtime/client/router.js @@ -180,6 +180,7 @@ export class Router { if (!a.href) return; + const is_svg_a_element = a instanceof SVGAElement; const url = get_href(a); const url_string = url.toString(); if (url_string === location.href) { @@ -187,6 +188,11 @@ export class Router { return; } + // Ignore if url does not have origin (e.g. `mailto:`, `tel:`.) + // MEMO: Without this condition, firefox will open mailer twice. + // See: https://github.com/sveltejs/kit/issues/4045 + if (!is_svg_a_element && url.origin === 'null') return; + // Ignore if tag has // 1. 'download' attribute // 2. 'rel' attribute includes external @@ -197,7 +203,7 @@ export class Router { } // Ignore if has a target - if (a instanceof SVGAElement ? a.target.baseVal : a.target) return; + if (is_svg_a_element ? a.target.baseVal : a.target) return; // Check if new url only differs by hash and use the browser default behavior in that case // This will ensure the `hashchange` event is fired From 88ebc8e3033496cd842cf29fa127f5d7efc3d184 Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Wed, 23 Feb 2022 23:58:43 +0900 Subject: [PATCH 11/18] [chore] FIx test flakiness (#4071) * fix wrong test assertion * prevent test flakiness The height of the element is important for this test, but the height of the element is specified by CSS. Since the CSS is loaded separately from the HTML, the test will unintentionally succeed if the assertion is executed before the CSS is loaded. To prevent this, the styles are written directly in the HTML. * fix wrong await and prevent flakiness * prevent test flakiness * fix more wrong await * remove duplicated style --- .../routes/anchor-with-manual-scroll/anchor.svelte | 13 +++---------- .../apps/basics/src/routes/anchor/anchor.svelte | 11 ++--------- .../src/routes/use-action/focus-and-scroll.svelte | 11 ++--------- packages/kit/test/apps/basics/test/test.js | 10 ++++++---- 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor.svelte b/packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor.svelte index 5f7ba71be5cb..be660c5859b2 100644 --- a/packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor.svelte +++ b/packages/kit/test/apps/basics/src/routes/anchor-with-manual-scroll/anchor.svelte @@ -8,16 +8,9 @@ }); -
They (don't) see me...
-
+
They (don't) see me...
+

The browser scrolls to me

-

I take precedence

+

I take precedence

- - diff --git a/packages/kit/test/apps/basics/src/routes/anchor/anchor.svelte b/packages/kit/test/apps/basics/src/routes/anchor/anchor.svelte index 2c4e5feeebf8..57406e6d3a09 100644 --- a/packages/kit/test/apps/basics/src/routes/anchor/anchor.svelte +++ b/packages/kit/test/apps/basics/src/routes/anchor/anchor.svelte @@ -1,11 +1,4 @@ -
They (don't) see me...
-
+
They (don't) see me...
+

The browser scrolls to me

- - diff --git a/packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll.svelte b/packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll.svelte index 430c14300fb4..7dd3bb9fe6fa 100644 --- a/packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll.svelte +++ b/packages/kit/test/apps/basics/src/routes/use-action/focus-and-scroll.svelte @@ -10,15 +10,8 @@
They (don't) see me scrollin'...
-
+
-
They (not) focusin'
- - +
They (not) focusin'
diff --git a/packages/kit/test/apps/basics/test/test.js b/packages/kit/test/apps/basics/test/test.js index c83e450369fb..858659fb4ea8 100644 --- a/packages/kit/test/apps/basics/test/test.js +++ b/packages/kit/test/apps/basics/test/test.js @@ -53,7 +53,7 @@ test.describe.parallel('a11y', () => { page.type('#input', 'bar'), page.waitForFunction(() => window.location.search === '?foo=bar') ]); - expect(await page.locator('#input')).toBeFocused(); + await expect(page.locator('#input')).toBeFocused(); } }); @@ -230,17 +230,19 @@ test.describe('Scrolling', () => { test('url-supplied anchor is ignored with onMount() scrolling on navigation to page', async ({ page, clicknav, + javaScriptEnabled, in_view }) => { await page.goto('/anchor-with-manual-scroll'); await clicknav('[href="/anchor-with-manual-scroll/anchor#go-to-element"]'); - expect(await in_view('#abcde')).toBe(true); + if (javaScriptEnabled) expect(await in_view('#abcde')).toBe(true); + else expect(await in_view('#go-to-element')).toBe(true); }); test('app-supplied scroll and focus work on direct page load', async ({ page, in_view }) => { await page.goto('/use-action/focus-and-scroll'); expect(await in_view('#input')).toBe(true); - expect(await page.locator('#input')).toBeFocused(); + await expect(page.locator('#input')).toBeFocused(); }); test('app-supplied scroll and focus work on navigation to page', async ({ @@ -251,7 +253,7 @@ test.describe('Scrolling', () => { await page.goto('/use-action'); await clicknav('[href="/use-action/focus-and-scroll"]'); expect(await in_view('#input')).toBe(true); - expect(await page.locator('#input')).toBeFocused(); + await expect(page.locator('input')).toBeFocused(); }); test('scroll positions are recovered on reloading the page', async ({ page, back, app }) => { From e4de16496fd6e7b43f2284c2118718d97868520e Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Thu, 24 Feb 2022 00:50:41 +0900 Subject: [PATCH 12/18] [Chore] Fix lint (#4081) * fix lint * update again according to another PR comment * Update app.d.ts Co-authored-by: Rich Harris --- packages/create-svelte/templates/skeleton/src/app.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/create-svelte/templates/skeleton/src/app.d.ts b/packages/create-svelte/templates/skeleton/src/app.d.ts index 4175b0372aa8..9cbf1c51cb74 100644 --- a/packages/create-svelte/templates/skeleton/src/app.d.ts +++ b/packages/create-svelte/templates/skeleton/src/app.d.ts @@ -4,10 +4,7 @@ // for information about these interfaces declare namespace App { // interface Locals {} - // interface Platform {} - // interface Session {} - // interface Stuff {} } From a81ccffad39c51e32b53e141c9e1b35d7f350726 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 23 Feb 2022 11:01:11 -0500 Subject: [PATCH 13/18] changeset (#4082) --- .changeset/four-ties-destroy.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/four-ties-destroy.md diff --git a/.changeset/four-ties-destroy.md b/.changeset/four-ties-destroy.md new file mode 100644 index 000000000000..e8eab00e6f5e --- /dev/null +++ b/.changeset/four-ties-destroy.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-auto': patch +--- + +Attempt to bump @next version of adapter-auto From 56b781e9f58cb3e1d17f54e5e1592742b8f71ac8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 23 Feb 2022 11:02:00 -0500 Subject: [PATCH 14/18] Version Packages (next) (#4080) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 3 +++ packages/create-svelte/CHANGELOG.md | 6 ++++++ packages/create-svelte/package.json | 2 +- packages/kit/CHANGELOG.md | 8 ++++++++ packages/kit/package.json | 2 +- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 16d60225da47..6cce8d4fd66a 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -142,6 +142,7 @@ "early-snakes-peel", "early-wasps-obey", "eight-birds-run", + "eight-chicken-sin", "eight-glasses-sparkle", "eight-hats-worry", "eight-keys-give", @@ -241,6 +242,7 @@ "great-guests-visit", "great-kangaroos-eat", "great-queens-rule", + "great-seahorses-fry", "green-mayflies-shave", "green-spoons-count", "grumpy-days-compete", @@ -688,6 +690,7 @@ "tidy-pigs-peel", "tidy-turkeys-rule", "tidy-wasps-shave", + "tiny-badgers-love", "tiny-candles-repeat", "tiny-files-smile", "tiny-gorillas-whisper", diff --git a/packages/create-svelte/CHANGELOG.md b/packages/create-svelte/CHANGELOG.md index 67a07c0c6163..6b600dbdadc7 100644 --- a/packages/create-svelte/CHANGELOG.md +++ b/packages/create-svelte/CHANGELOG.md @@ -1,5 +1,11 @@ # create-svelte +## 2.0.0-next.120 + +### Patch Changes + +- fix `@typescript-eslint/no-empty-interface` lint error when starting a new app with eslint ([#4077](https://github.com/sveltejs/kit/pull/4077)) + ## 2.0.0-next.119 ### Patch Changes diff --git a/packages/create-svelte/package.json b/packages/create-svelte/package.json index 03c33a1a8657..4faaa7c8a3f6 100644 --- a/packages/create-svelte/package.json +++ b/packages/create-svelte/package.json @@ -1,6 +1,6 @@ { "name": "create-svelte", - "version": "2.0.0-next.119", + "version": "2.0.0-next.120", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md index 668a85bd6459..cefa36e4d781 100644 --- a/packages/kit/CHANGELOG.md +++ b/packages/kit/CHANGELOG.md @@ -1,5 +1,13 @@ # @sveltejs/kit +## 1.0.0-next.284 + +### Patch Changes + +- Disable meta http-equiv tags for static amp configuration ([#4073](https://github.com/sveltejs/kit/pull/4073)) + +* Ignore click event if url does not have origin (e.g. `mailto:`, `tel:`) ([#4072](https://github.com/sveltejs/kit/pull/4072)) + ## 1.0.0-next.283 ### Patch Changes diff --git a/packages/kit/package.json b/packages/kit/package.json index 26e1cdcdc805..d396c3835b0b 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/kit", - "version": "1.0.0-next.283", + "version": "1.0.0-next.284", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", From 39b5053de8fa58fa21118f09763e9d1d65ec7d3d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 23 Feb 2022 11:06:16 -0500 Subject: [PATCH 15/18] Version Packages (next) (#4083) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 1 + packages/adapter-auto/CHANGELOG.md | 6 ++++++ packages/adapter-auto/package.json | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 6cce8d4fd66a..1b5a8bdf3df7 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -199,6 +199,7 @@ "four-cheetahs-yawn", "four-news-turn", "four-pillows-give", + "four-ties-destroy", "fresh-adults-ring", "fresh-dolls-destroy", "fresh-hats-tie", diff --git a/packages/adapter-auto/CHANGELOG.md b/packages/adapter-auto/CHANGELOG.md index d86e0f786211..a4c3437b0d1c 100644 --- a/packages/adapter-auto/CHANGELOG.md +++ b/packages/adapter-auto/CHANGELOG.md @@ -1,5 +1,11 @@ # @sveltejs/adapter-auto +## 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 diff --git a/packages/adapter-auto/package.json b/packages/adapter-auto/package.json index acd5a54d3f10..c3225ac5935a 100644 --- a/packages/adapter-auto/package.json +++ b/packages/adapter-auto/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-auto", - "version": "1.0.0-next.24", + "version": "1.0.0-next.25", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", From e75a24286d03d7e2a177ddac8058bbc2735566da Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 23 Feb 2022 12:35:54 -0500 Subject: [PATCH 16/18] maybe fix next tags? (#4085) --- .changeset/pre.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 1b5a8bdf3df7..4913154934e4 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -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", From 46f44a61624bed525e393e669da9b7db566a1e18 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 23 Feb 2022 12:42:03 -0500 Subject: [PATCH 17/18] ??? (#4088) --- .changeset/twenty-dogs-shout.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/twenty-dogs-shout.md diff --git a/.changeset/twenty-dogs-shout.md b/.changeset/twenty-dogs-shout.md new file mode 100644 index 000000000000..2a5d994c15b0 --- /dev/null +++ b/.changeset/twenty-dogs-shout.md @@ -0,0 +1,6 @@ +--- +'@sveltejs/adapter-auto': patch +'@sveltejs/adapter-cloudflare': patch +--- + +Attempt to force @next version bump From 385b1a5bd84d05efba547e0aad349a216edb6deb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 23 Feb 2022 12:44:00 -0500 Subject: [PATCH 18/18] Version Packages (next) (#4089) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 1 + packages/adapter-auto/CHANGELOG.md | 9 +++++++++ packages/adapter-auto/package.json | 2 +- packages/adapter-cloudflare/CHANGELOG.md | 6 ++++++ packages/adapter-cloudflare/package.json | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 4913154934e4..3a36ac4d5f7f 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -719,6 +719,7 @@ "twelve-feet-deny", "twelve-goats-knock", "twelve-onions-burn", + "twenty-dogs-shout", "twenty-dryers-hope", "twenty-hairs-shave", "twenty-numbers-destroy", diff --git a/packages/adapter-auto/CHANGELOG.md b/packages/adapter-auto/CHANGELOG.md index a4c3437b0d1c..7676deb9877d 100644 --- a/packages/adapter-auto/CHANGELOG.md +++ b/packages/adapter-auto/CHANGELOG.md @@ -1,5 +1,14 @@ # @sveltejs/adapter-auto +## 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 diff --git a/packages/adapter-auto/package.json b/packages/adapter-auto/package.json index c3225ac5935a..0920b09c1524 100644 --- a/packages/adapter-auto/package.json +++ b/packages/adapter-auto/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-auto", - "version": "1.0.0-next.25", + "version": "1.0.0-next.26", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit", diff --git a/packages/adapter-cloudflare/CHANGELOG.md b/packages/adapter-cloudflare/CHANGELOG.md index 21a6a92653a2..41ffeb4431f5 100644 --- a/packages/adapter-cloudflare/CHANGELOG.md +++ b/packages/adapter-cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @sveltejs/adapter-cloudflare +## 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 diff --git a/packages/adapter-cloudflare/package.json b/packages/adapter-cloudflare/package.json index 8ea34245c606..02611503f020 100644 --- a/packages/adapter-cloudflare/package.json +++ b/packages/adapter-cloudflare/package.json @@ -1,6 +1,6 @@ { "name": "@sveltejs/adapter-cloudflare", - "version": "1.0.0-next.12", + "version": "1.0.0-next.13", "repository": { "type": "git", "url": "https://github.com/sveltejs/kit",