Modify prettierrc

pull/8289/head
Puru Vijay 4 years ago
parent 1a4d4844c2
commit 19f79c3314

@ -2,5 +2,7 @@
"singleQuote": true, "singleQuote": true,
"printWidth": 100, "printWidth": 100,
"useTabs": true, "useTabs": true,
"trailingComma": "es5" "tabWidth": 2,
"trailingComma": "none",
"plugins": ["prettier-plugin-svelte"]
} }

41
package-lock.json generated

@ -41,6 +41,7 @@
"magic-string": "^0.30.0", "magic-string": "^0.30.0",
"mocha": "^7.0.0", "mocha": "^7.0.0",
"periscopic": "^3.1.0", "periscopic": "^3.1.0",
"prettier-plugin-svelte": "^2.10.0",
"puppeteer": "^2.0.0", "puppeteer": "^2.0.0",
"rollup": "^1.27.14", "rollup": "^1.27.14",
"source-map": "^0.7.4", "source-map": "^0.7.4",
@ -4200,6 +4201,32 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/prettier": {
"version": "2.8.7",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz",
"integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==",
"dev": true,
"peer": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/prettier-plugin-svelte": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-2.10.0.tgz",
"integrity": "sha512-GXMY6t86thctyCvQq+jqElO+MKdB09BkL3hexyGP3Oi8XLKRFaJP1ud/xlWCZ9ZIa2BxHka32zhHfcuU+XsRQg==",
"dev": true,
"peerDependencies": {
"prettier": "^1.16.4 || ^2.0.0",
"svelte": "^3.2.0"
}
},
"node_modules/process-nextick-args": { "node_modules/process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@ -8537,6 +8564,20 @@
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
"dev": true "dev": true
}, },
"prettier": {
"version": "2.8.7",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz",
"integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==",
"dev": true,
"peer": true
},
"prettier-plugin-svelte": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-2.10.0.tgz",
"integrity": "sha512-GXMY6t86thctyCvQq+jqElO+MKdB09BkL3hexyGP3Oi8XLKRFaJP1ud/xlWCZ9ZIa2BxHka32zhHfcuU+XsRQg==",
"dev": true,
"requires": {}
},
"process-nextick-args": { "process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",

@ -151,6 +151,7 @@
"magic-string": "^0.30.0", "magic-string": "^0.30.0",
"mocha": "^7.0.0", "mocha": "^7.0.0",
"periscopic": "^3.1.0", "periscopic": "^3.1.0",
"prettier-plugin-svelte": "^2.10.0",
"puppeteer": "^2.0.0", "puppeteer": "^2.0.0",
"rollup": "^1.27.14", "rollup": "^1.27.14",
"source-map": "^0.7.4", "source-map": "^0.7.4",

@ -51,8 +51,8 @@ Another thing that people often found confusing about Svelte is the way computed
```js ```js
export default { export default {
computed: { computed: {
d: (a, b, c) => (a = b + c), d: (a, b, c) => (a = b + c)
}, }
}; };
``` ```
@ -63,8 +63,8 @@ In v2, we use [destructuring](http://www.jstips.co/en/javascript/use-destructuri
```js ```js
export default { export default {
computed: { computed: {
d: ({ a, b, c }) => (a = b + c), d: ({ a, b, c }) => (a = b + c)
}, }
}; };
``` ```
@ -93,7 +93,7 @@ export default {
// this fires after oncreate, and // this fires after oncreate, and
// whenever the DOM has been updated // whenever the DOM has been updated
// following a state change // following a state change
}, }
}; };
``` ```
@ -138,8 +138,8 @@ import { observe } from 'svelte-extras';
export default { export default {
methods: { methods: {
observe, observe
}, }
}; };
``` ```
@ -173,7 +173,7 @@ Previously, numeric values passed to components were treated as numbers:
That causes unexpected behaviour, and has been changed: if you need to pass a literal number, do so as an expression: That causes unexpected behaviour, and has been changed: if you need to pass a literal number, do so as an expression:
```svelte ```svelte
<Counter start="{1}" /> <Counter start={1} />
``` ```
## Compiler changes ## Compiler changes

@ -38,7 +38,7 @@ In old Svelte, you would tell the computer that some state had changed by callin
```js ```js
const { count } = this.get(); const { count } = this.get();
this.set({ this.set({
count: count + 1, count: count + 1
}); });
``` ```
@ -47,7 +47,7 @@ That would cause the component to _react_. Speaking of which, `this.set` is almo
```js ```js
const { count } = this.state; const { count } = this.state;
this.setState({ this.setState({
count: count + 1, count: count + 1
}); });
``` ```

@ -27,7 +27,7 @@ import type { ServerLoadEvent } from '@sveltejs/kit';
export async function load(event: ServerLoadEvent) { export async function load(event: ServerLoadEvent) {
return { return {
post: await database.getPost(event.params.post), post: await database.getPost(event.params.post)
}; };
} }
``` ```
@ -61,8 +61,8 @@ After we have loaded our data, we want to display it in our `+page.svelte`. The
export let data: PageData; export let data: PageData;
</script> </script>
<h1>{data.post.title}</h1> <h1>{data.post.title}</h1>
<div>{@html data.post.content}</div> <div>{@html data.post.content}</div>
``` ```

@ -61,8 +61,8 @@ Boolean attributes are included on the element if their value is [truthy](https:
All other attributes are included unless their value is [nullish](https://developer.mozilla.org/en-US/docs/Glossary/Nullish) (`null` or `undefined`). All other attributes are included unless their value is [nullish](https://developer.mozilla.org/en-US/docs/Glossary/Nullish) (`null` or `undefined`).
```svelte ```svelte
<input required="{false}" placeholder="This input field is not required" /> <input required={false} placeholder="This input field is not required" />
<div title="{null}">This div has no title attribute</div> <div title={null}>This div has no title attribute</div>
``` ```
--- ---

@ -540,7 +540,7 @@ If the initial value is `undefined` or `null`, the first value change will take
```js ```js
const size = tweened(undefined, { const size = tweened(undefined, {
duration: 300, duration: 300,
easing: cubicOut, easing: cubicOut
}); });
$: $size = big ? 100 : 10; $: $size = big ? 100 : 10;
@ -555,11 +555,7 @@ The `interpolate` option allows you to tween between _any_ arbitrary values. It
import { interpolateLab } from 'd3-interpolate'; import { interpolateLab } from 'd3-interpolate';
import { tweened } from 'svelte/motion'; import { tweened } from 'svelte/motion';
const colors = [ const colors = ['rgb(255, 62, 0)', 'rgb(64, 179, 255)', 'rgb(103, 103, 120)'];
'rgb(255, 62, 0)',
'rgb(64, 179, 255)',
'rgb(103, 103, 120)'
];
const color = tweened(colors[0], { const color = tweened(colors[0], {
duration: 800, duration: 800,
@ -568,10 +564,7 @@ The `interpolate` option allows you to tween between _any_ arbitrary values. It
</script> </script>
{#each colors as c} {#each colors as c}
<button <button style="background-color: {c}; color: white; border: none;" on:click={(e) => color.set(c)}>
style="background-color: {c}; color: white; border: none;"
on:click={e => color.set(c)}
>
{c} {c}
</button> </button>
{/each} {/each}
@ -1004,7 +997,7 @@ To set compile options, or to use a custom file extension, call the `register` h
```js ```js
require('svelte/register')({ require('svelte/register')({
extensions: ['.customextension'], // defaults to ['.html', '.svelte'] extensions: ['.customextension'], // defaults to ['.html', '.svelte']
preserveComments: true, preserveComments: true
}); });
``` ```
@ -1026,8 +1019,8 @@ const app = new App({
props: { props: {
// assuming App.svelte contains something like // assuming App.svelte contains something like
// `export let answer`: // `export let answer`:
answer: 42, answer: 42
}, }
}); });
``` ```
@ -1057,7 +1050,7 @@ import App from './App.svelte';
const app = new App({ const app = new App({
target: document.querySelector('#server-rendered-html'), target: document.querySelector('#server-rendered-html'),
hydrate: true, hydrate: true
}); });
``` ```
@ -1210,7 +1203,7 @@ require('svelte/register');
const App = require('./App.svelte').default; const App = require('./App.svelte').default;
const { head, html, css } = App.render({ const { head, html, css } = App.render({
answer: 42, answer: 42
}); });
``` ```
@ -1235,7 +1228,7 @@ const { head, html, css } = App.render(
{ answer: 42 }, { answer: 42 },
// options // options
{ {
context: new Map([['context-key', 'context-value']]), context: new Map([['context-key', 'context-value']])
} }
); );
``` ```

@ -231,12 +231,12 @@ const { code } = await svelte.preprocess(
s.overwrite(pos, pos + 3, 'bar', { storeName: true }); s.overwrite(pos, pos + 3, 'bar', { storeName: true });
return { return {
code: s.toString(), code: s.toString(),
map: s.generateMap(), map: s.generateMap()
}; };
}, }
}, },
{ {
filename: 'App.svelte', filename: 'App.svelte'
} }
); );
``` ```
@ -264,7 +264,7 @@ const { code, dependencies } = await svelte.preprocess(
{ {
file: filename, file: filename,
data: content, data: content,
includePaths: [dirname(filename)], includePaths: [dirname(filename)]
}, },
(err, result) => { (err, result) => {
if (err) reject(err); if (err) reject(err);
@ -275,12 +275,12 @@ const { code, dependencies } = await svelte.preprocess(
return { return {
code: css.toString(), code: css.toString(),
dependencies: stats.includedFiles, dependencies: stats.includedFiles
}; };
}, }
}, },
{ {
filename: 'App.svelte', filename: 'App.svelte'
} }
); );
``` ```
@ -304,7 +304,7 @@ const { code } = await svelte.preprocess(
}, },
style: () => { style: () => {
console.log('this runs fifth'); console.log('this runs fifth');
}, }
}, },
{ {
markup: () => { markup: () => {
@ -315,11 +315,11 @@ const { code } = await svelte.preprocess(
}, },
style: () => { style: () => {
console.log('this runs sixth'); console.log('this runs sixth');
}, }
}, }
], ],
{ {
filename: 'App.svelte', filename: 'App.svelte'
} }
); );
``` ```
@ -350,7 +350,7 @@ svelte.walk(ast, {
}, },
leave(node, parent, prop, index) { leave(node, parent, prop, index) {
do_something_else(node); do_something_else(node);
}, }
}); });
``` ```

@ -7,7 +7,7 @@ function createCount() {
subscribe, subscribe,
increment: () => update((n) => n + 1), increment: () => update((n) => n + 1),
decrement: () => update((n) => n - 1), decrement: () => update((n) => n - 1),
reset: () => set(0), reset: () => set(0)
}; };
} }

@ -1,16 +1,16 @@
const BY = { const BY = {
name: 'CC BY 2.0', name: 'CC BY 2.0',
url: 'https://creativecommons.org/licenses/by/2.0/', url: 'https://creativecommons.org/licenses/by/2.0/'
}; };
const BY_SA = { const BY_SA = {
name: 'CC BY-SA 2.0', name: 'CC BY-SA 2.0',
url: 'https://creativecommons.org/licenses/by-sa/2.0/', url: 'https://creativecommons.org/licenses/by-sa/2.0/'
}; };
const BY_ND = { const BY_ND = {
name: 'CC BY-ND 2.0', name: 'CC BY-ND 2.0',
url: 'https://creativecommons.org/licenses/by-nd/2.0/', url: 'https://creativecommons.org/licenses/by-nd/2.0/'
}; };
// via http://labs.tineye.com/multicolr // via http://labs.tineye.com/multicolr
@ -20,83 +20,83 @@ export default [
id: '1', id: '1',
alt: 'Crepuscular rays', alt: 'Crepuscular rays',
path: '43428526@N03/7863279376', path: '43428526@N03/7863279376',
license: BY, license: BY
}, },
{ {
color: '#0074D9', color: '#0074D9',
id: '2', id: '2',
alt: 'Lapland winter scene', alt: 'Lapland winter scene',
path: '25507134@N00/6527537485', path: '25507134@N00/6527537485',
license: BY, license: BY
}, },
{ {
color: '#7FDBFF', color: '#7FDBFF',
id: '3', id: '3',
alt: 'Jellyfish', alt: 'Jellyfish',
path: '37707866@N00/3354331318', path: '37707866@N00/3354331318',
license: BY, license: BY
}, },
{ {
color: '#39CCCC', color: '#39CCCC',
id: '4', id: '4',
alt: 'A man scuba diving', alt: 'A man scuba diving',
path: '32751486@N00/4608886209', path: '32751486@N00/4608886209',
license: BY_SA, license: BY_SA
}, },
{ {
color: '#3D9970', color: '#3D9970',
id: '5', id: '5',
alt: 'Underwater scene', alt: 'Underwater scene',
path: '25483059@N08/5548569010', path: '25483059@N08/5548569010',
license: BY, license: BY
}, },
{ {
color: '#2ECC40', color: '#2ECC40',
id: '6', id: '6',
alt: 'Ferns', alt: 'Ferns',
path: '8404611@N06/2447470760', path: '8404611@N06/2447470760',
license: BY, license: BY
}, },
{ {
color: '#01FF70', color: '#01FF70',
id: '7', id: '7',
alt: 'Posters in a bar', alt: 'Posters in a bar',
path: '33917831@N00/114428206', path: '33917831@N00/114428206',
license: BY_SA, license: BY_SA
}, },
{ {
color: '#FFDC00', color: '#FFDC00',
id: '8', id: '8',
alt: 'Daffodil', alt: 'Daffodil',
path: '46417125@N04/4818617089', path: '46417125@N04/4818617089',
license: BY_ND, license: BY_ND
}, },
{ {
color: '#FF851B', color: '#FF851B',
id: '9', id: '9',
alt: 'Dust storm in Sydney', alt: 'Dust storm in Sydney',
path: '56068058@N00/3945496657', path: '56068058@N00/3945496657',
license: BY, license: BY
}, },
{ {
color: '#FF4136', color: '#FF4136',
id: '10', id: '10',
alt: 'Postbox', alt: 'Postbox',
path: '31883499@N05/4216820032', path: '31883499@N05/4216820032',
license: BY, license: BY
}, },
{ {
color: '#85144b', color: '#85144b',
id: '11', id: '11',
alt: 'Fireworks', alt: 'Fireworks',
path: '8484971@N07/2625506561', path: '8484971@N07/2625506561',
license: BY_ND, license: BY_ND
}, },
{ {
color: '#B10DC9', color: '#B10DC9',
id: '12', id: '12',
alt: 'The Stereophonics', alt: 'The Stereophonics',
path: '58028312@N00/5385464371', path: '58028312@N00/5385464371',
license: BY_ND, license: BY_ND
}, }
]; ];

@ -31,13 +31,13 @@ const sorted_eases = new Map([
['circ', processed_eases.circ], ['circ', processed_eases.circ],
['back', processed_eases.back], ['back', processed_eases.back],
['elastic', processed_eases.elastic], ['elastic', processed_eases.elastic],
['bounce', processed_eases.bounce], ['bounce', processed_eases.bounce]
]); ]);
export const types = [ export const types = [
['Ease In', 'In'], ['Ease In', 'In'],
['Ease Out', 'Out'], ['Ease Out', 'Out'],
['Ease In Out', 'InOut'], ['Ease In Out', 'InOut']
]; ];
export { sorted_eases as eases }; export { sorted_eases as eases };

@ -41,5 +41,5 @@ export default [
{ x: 2018, y: 4.79 }, { x: 2018, y: 4.79 },
{ x: 2019, y: 4.36 }, { x: 2019, y: 4.36 },
{ x: 2020, y: 4 }, { x: 2020, y: 4 },
{ x: 2021, y: 4.92 }, { x: 2021, y: 4.92 }
]; ];

@ -10,7 +10,7 @@ export default {
{ x: 4, y: 4.26 }, { x: 4, y: 4.26 },
{ x: 12, y: 10.84 }, { x: 12, y: 10.84 },
{ x: 7, y: 4.82 }, { x: 7, y: 4.82 },
{ x: 5, y: 5.68 }, { x: 5, y: 5.68 }
], ],
b: [ b: [
{ x: 10, y: 9.14 }, { x: 10, y: 9.14 },
@ -23,7 +23,7 @@ export default {
{ x: 4, y: 3.1 }, { x: 4, y: 3.1 },
{ x: 12, y: 9.13 }, { x: 12, y: 9.13 },
{ x: 7, y: 7.26 }, { x: 7, y: 7.26 },
{ x: 5, y: 4.74 }, { x: 5, y: 4.74 }
], ],
c: [ c: [
{ x: 10, y: 7.46 }, { x: 10, y: 7.46 },
@ -36,7 +36,7 @@ export default {
{ x: 4, y: 5.39 }, { x: 4, y: 5.39 },
{ x: 12, y: 8.15 }, { x: 12, y: 8.15 },
{ x: 7, y: 6.42 }, { x: 7, y: 6.42 },
{ x: 5, y: 5.73 }, { x: 5, y: 5.73 }
], ],
d: [ d: [
{ x: 8, y: 6.58 }, { x: 8, y: 6.58 },
@ -49,6 +49,6 @@ export default {
{ x: 19, y: 12.5 }, { x: 19, y: 12.5 },
{ x: 8, y: 5.56 }, { x: 8, y: 5.56 },
{ x: 8, y: 7.91 }, { x: 8, y: 7.91 },
{ x: 8, y: 6.89 }, { x: 8, y: 6.89 }
], ]
}; };

@ -9,6 +9,6 @@ export function expand(node, params) {
delay, delay,
duration, duration,
easing, easing,
css: (t) => `opacity: ${t}; stroke-width: ${t * w}`, css: (t) => `opacity: ${t}; stroke-width: ${t * w}`
}; };
} }

@ -10,6 +10,6 @@ export function clickOutside(node) {
return { return {
destroy() { destroy() {
document.removeEventListener('click', handleClick, true); document.removeEventListener('click', handleClick, true);
}, }
}; };
} }

@ -21,6 +21,6 @@ export function longpress(node, duration) {
destroy() { destroy() {
node.removeEventListener('mousedown', handleMousedown); node.removeEventListener('mousedown', handleMousedown);
node.removeEventListener('mouseup', handleMouseup); node.removeEventListener('mouseup', handleMouseup);
}, }
}; };
} }

@ -8,7 +8,7 @@ export function pannable(node) {
node.dispatchEvent( node.dispatchEvent(
new CustomEvent('panstart', { new CustomEvent('panstart', {
detail: { x, y }, detail: { x, y }
}) })
); );
@ -24,7 +24,7 @@ export function pannable(node) {
node.dispatchEvent( node.dispatchEvent(
new CustomEvent('panmove', { new CustomEvent('panmove', {
detail: { x, y, dx, dy }, detail: { x, y, dx, dy }
}) })
); );
} }
@ -35,7 +35,7 @@ export function pannable(node) {
node.dispatchEvent( node.dispatchEvent(
new CustomEvent('panend', { new CustomEvent('panend', {
detail: { x, y }, detail: { x, y }
}) })
); );
@ -48,6 +48,6 @@ export function pannable(node) {
return { return {
destroy() { destroy() {
node.removeEventListener('mousedown', handleMousedown); node.removeEventListener('mousedown', handleMousedown);
}, }
}; };
} }

@ -6,8 +6,9 @@ You can use curly braces to control element attributes, just like you use them t
Our image is missing a `src` attribute — let's add one: Our image is missing a `src` attribute — let's add one:
<!-- prettier-ignore -->
```svelte ```svelte
<img src={src}> <img src={src} />
``` ```
That's better. But Svelte is giving us a warning: That's better. But Svelte is giving us a warning:
@ -18,8 +19,9 @@ When building web apps, it's important to make sure that they're _accessible_ to
In this case, we're missing the `alt` attribute that describes the image for people using screenreaders, or people with slow or flaky internet connections that can't download the image. Let's add one: In this case, we're missing the `alt` attribute that describes the image for people using screenreaders, or people with slow or flaky internet connections that can't download the image. Let's add one:
<!-- prettier-ignore -->
```svelte ```svelte
<img src={src} alt="A man dances."> <img src={src} alt="A man dances." />
``` ```
We can use curly braces _inside_ attributes. Try changing it to `"{name} dances."` — remember to declare a `name` variable in the `<script>` block. We can use curly braces _inside_ attributes. Try changing it to `"{name} dances."` — remember to declare a `name` variable in the `<script>` block.
@ -29,5 +31,5 @@ We can use curly braces _inside_ attributes. Try changing it to `"{name} dances.
It's not uncommon to have an attribute where the name and value are the same, like `src={src}`. Svelte gives us a convenient shorthand for these cases: It's not uncommon to have an attribute where the name and value are the same, like `src={src}`. Svelte gives us a convenient shorthand for these cases:
```svelte ```svelte
<img {src} alt="A man dances."> <img {src} alt="A man dances." />
``` ```

@ -29,8 +29,8 @@ const app = new App({
target: document.body, target: document.body,
props: { props: {
// we'll learn about props later // we'll learn about props later
answer: 42, answer: 42
}, }
}); });
``` ```

@ -8,15 +8,11 @@ To conditionally render some markup, we wrap it in an `if` block:
```svelte ```svelte
{#if user.loggedIn} {#if user.loggedIn}
<button on:click={toggle}> <button on:click={toggle}> Log out </button>
Log out
</button>
{/if} {/if}
{#if !user.loggedIn} {#if !user.loggedIn}
<button on:click={toggle}> <button on:click={toggle}> Log in </button>
Log in
</button>
{/if} {/if}
``` ```

@ -6,13 +6,9 @@ Since the two conditions — `if user.loggedIn` and `if !user.loggedIn` — are
```svelte ```svelte
{#if user.loggedIn} {#if user.loggedIn}
<button on:click={toggle}> <button on:click={toggle}> Log out </button>
Log out
</button>
{:else} {:else}
<button on:click={toggle}> <button on:click={toggle}> Log in </button>
Log in
</button>
{/if} {/if}
``` ```

@ -7,9 +7,11 @@ If you need to loop over lists of data, use an `each` block:
```svelte ```svelte
<ul> <ul>
{#each cats as cat} {#each cats as cat}
<li><a target="_blank" href="https://www.youtube.com/watch?v={cat.id}" rel="noreferrer"> <li>
<a target="_blank" href="https://www.youtube.com/watch?v={cat.id}" rel="noreferrer">
{cat.name} {cat.name}
</a></li> </a>
</li>
{/each} {/each}
</ul> </ul>
``` ```
@ -20,9 +22,11 @@ You can get the current _index_ as a second argument, like so:
```svelte ```svelte
{#each cats as cat, i} {#each cats as cat, i}
<li><a target="_blank" href="https://www.youtube.com/watch?v={cat.id}" rel="noreferrer"> <li>
<a target="_blank" href="https://www.youtube.com/watch?v={cat.id}" rel="noreferrer">
{i + 1}: {cat.name} {i + 1}: {cat.name}
</a></li> </a>
</li>
{/each} {/each}
``` ```

@ -5,7 +5,7 @@ title: Inline handlers
You can also declare event handlers inline: You can also declare event handlers inline:
```svelte ```svelte
<div on:mousemove="{e => m = { x: e.clientX, y: e.clientY }}"> <div on:mousemove={(e) => (m = { x: e.clientX, y: e.clientY })}>
The mouse position is {m.x} x {m.y} The mouse position is {m.x} x {m.y}
</div> </div>
``` ```

@ -7,13 +7,11 @@ DOM event handlers can have _modifiers_ that alter their behaviour. For example,
```svelte ```svelte
<script> <script>
function handleClick() { function handleClick() {
alert('no more alerts') alert('no more alerts');
} }
</script> </script>
<button on:click|once={handleClick}> <button on:click|once={handleClick}> Click me </button>
Click me
</button>
``` ```
The full list of modifiers: The full list of modifiers:

@ -7,7 +7,5 @@ Event forwarding works for DOM events too.
We want to get notified of clicks on our `<CustomButton>` — to do that, we just need to forward `click` events on the `<button>` element in `CustomButton.svelte`: We want to get notified of clicks on our `<CustomButton>` — to do that, we just need to forward `click` events on the `<button>` element in `CustomButton.svelte`:
```svelte ```svelte
<button on:click> <button on:click> Click me </button>
Click me
</button>
``` ```

@ -9,7 +9,7 @@ Sometimes it's useful to break that rule. Take the case of the `<input>` element
Instead, we can use the `bind:value` directive: Instead, we can use the `bind:value` directive:
```svelte ```svelte
<input bind:value={name}> <input bind:value={name} />
``` ```
This means that not only will changes to the value of `name` update the input value, but changes to the input value will update `name`. This means that not only will changes to the value of `name` update the input value, but changes to the input value will update `name`.

@ -7,6 +7,6 @@ In the DOM, everything is a string. That's unhelpful when you're dealing with nu
With `bind:value`, Svelte takes care of it for you: With `bind:value`, Svelte takes care of it for you:
```svelte ```svelte
<input type=number bind:value={a} min=0 max=10> <input type="number" bind:value={a} min="0" max="10" />
<input type=range bind:value={a} min=0 max=10> <input type="range" bind:value={a} min="0" max="10" />
``` ```

@ -5,5 +5,5 @@ title: Checkbox inputs
Checkboxes are used for toggling between states. Instead of binding to `input.value`, we bind to `input.checked`: Checkboxes are used for toggling between states. Instead of binding to `input.value`, we bind to `input.checked`:
```svelte ```svelte
<input type=checkbox bind:checked={yes}> <input type="checkbox" bind:checked={yes} />
``` ```

@ -7,7 +7,7 @@ If you have multiple inputs relating to the same value, you can use `bind:group`
Add `bind:group` to each input: Add `bind:group` to each input:
```svelte ```svelte
<input type=radio bind:group={scoops} name="scoops" value={1}> <input type="radio" bind:group={scoops} name="scoops" value={1} />
``` ```
In this case, we could make the code simpler by moving the checkbox inputs into an `each` block. First, add a `menu` variable to the `<script>` block... In this case, we could make the code simpler by moving the checkbox inputs into an `each` block. First, add a `menu` variable to the `<script>` block...
@ -23,7 +23,7 @@ let menu = ['Cookies and cream', 'Mint choc chip', 'Raspberry ripple'];
{#each menu as flavour} {#each menu as flavour}
<label> <label>
<input type=checkbox bind:group={flavours} name="flavours" value={flavour}> <input type="checkbox" bind:group={flavours} name="flavours" value={flavour} />
{flavour} {flavour}
</label> </label>
{/each} {/each}

@ -5,13 +5,13 @@ title: Textarea inputs
The `<textarea>` element behaves similarly to a text input in Svelte — use `bind:value` to create a two-way binding between the `<textarea>` content and the `value` variable: The `<textarea>` element behaves similarly to a text input in Svelte — use `bind:value` to create a two-way binding between the `<textarea>` content and the `value` variable:
```svelte ```svelte
<textarea bind:value={value}></textarea> <textarea bind:value />
``` ```
In cases like these, where the names match, we can also use a shorthand form: In cases like these, where the names match, we can also use a shorthand form:
```svelte ```svelte
<textarea bind:value></textarea> <textarea bind:value />
``` ```
This applies to all bindings, not just textareas. This applies to all bindings, not just textareas.

@ -3,6 +3,7 @@ title: Contenteditable bindings
--- ---
Elements with the `contenteditable` attribute support the following bindings: Elements with the `contenteditable` attribute support the following bindings:
- [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) - [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML)
- [`innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText) - [`innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText)
- [`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) - [`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)
@ -10,8 +11,5 @@ Elements with the `contenteditable` attribute support the following bindings:
There are slight differences between each of these, read more about them [here](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#Differences_from_innerText). There are slight differences between each of these, read more about them [here](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#Differences_from_innerText).
```svelte ```svelte
<div <div contenteditable="true" bind:innerHTML={html} />
contenteditable="true"
bind:innerHTML={html}
></div>
``` ```

@ -7,15 +7,9 @@ You can even bind to properties inside an `each` block.
```svelte ```svelte
{#each todos as todo} {#each todos as todo}
<div class:done={todo.done}> <div class:done={todo.done}>
<input <input type="checkbox" bind:checked={todo.done} />
type=checkbox
bind:checked={todo.done}
>
<input <input placeholder="What needs to be done?" bind:value={todo.text} />
placeholder="What needs to be done?"
bind:value={todo.text}
>
</div> </div>
{/each} {/each}
``` ```

@ -16,8 +16,9 @@ On line 62, add `currentTime={time}`, `duration` and `paused` bindings:
on:mouseup={handleMouseup} on:mouseup={handleMouseup}
bind:currentTime={time} bind:currentTime={time}
bind:duration bind:duration
bind:paused> bind:paused
<track kind="captions"> >
<track kind="captions" />
</video> </video>
``` ```

@ -5,11 +5,7 @@ title: This
The readonly `this` binding applies to every element (and component) and allows you to obtain a reference to rendered elements. For example, we can get a reference to a `<canvas>` element: The readonly `this` binding applies to every element (and component) and allows you to obtain a reference to rendered elements. For example, we can get a reference to a `<canvas>` element:
```svelte ```svelte
<canvas <canvas bind:this={canvas} width={32} height={32} />
bind:this={canvas}
width={32}
height={32}
></canvas>
``` ```
Note that the value of `canvas` will be `undefined` until the component has mounted, so we put the logic inside the `onMount` [lifecycle function](/tutorial/onmount). Note that the value of `canvas` will be `undefined` until the component has mounted, so we put the logic inside the `onMount` [lifecycle function](/tutorial/onmount).

@ -15,9 +15,7 @@ Just as you can bind to DOM elements, you can bind to component instances themse
Now we can programmatically interact with this component using `field`. Now we can programmatically interact with this component using `field`.
```svelte ```svelte
<button on:click="{() => field.focus()}"> <button on:click={() => field.focus()}> Focus field </button>
Focus field
</button>
``` ```
> Note that we can't do `{field.focus}` since field is undefined when the button is first rendered and throws an error. > Note that we can't do `{field.focus}` since field is undefined when the button is first rendered and throws an error.

@ -11,7 +11,7 @@ For example, we can add a `setInterval` function when our component initialises,
import { onDestroy } from 'svelte'; import { onDestroy } from 'svelte';
let counter = 0; let counter = 0;
const interval = setInterval(() => counter += 1, 1000); const interval = setInterval(() => (counter += 1), 1000);
onDestroy(() => clearInterval(interval)); onDestroy(() => clearInterval(interval));
</script> </script>
@ -38,7 +38,7 @@ export function onInterval(callback, milliseconds) {
import { onInterval } from './utils.js'; import { onInterval } from './utils.js';
let counter = 0; let counter = 0;
onInterval(() => counter += 1, 1000); onInterval(() => (counter += 1), 1000);
</script> </script>
``` ```

@ -26,7 +26,7 @@ You now declared `unsubscribe`, but it still needs to be called, for example thr
let countValue; let countValue;
const unsubscribe = count.subscribe(value => { const unsubscribe = count.subscribe((value) => {
countValue = value; countValue = value;
}); });

@ -7,7 +7,7 @@ function createCount() {
subscribe, subscribe,
increment: () => {}, increment: () => {},
decrement: () => {}, decrement: () => {},
reset: () => {}, reset: () => {}
}; };
} }

@ -7,7 +7,7 @@ function createCount() {
subscribe, subscribe,
increment: () => update((n) => n + 1), increment: () => update((n) => n + 1),
decrement: () => update((n) => n - 1), decrement: () => update((n) => n - 1),
reset: () => set(0), reset: () => set(0)
}; };
} }

@ -14,7 +14,7 @@ function createCount() {
subscribe, subscribe,
increment: () => update((n) => n + 1), increment: () => update((n) => n + 1),
decrement: () => update((n) => n - 1), decrement: () => update((n) => n - 1),
reset: () => set(0), reset: () => set(0)
}; };
} }
``` ```

@ -7,7 +7,7 @@ If a store is writable — i.e. it has a `set` method — you can bind to its va
In this example we have a writable store `name` and a derived store `greeting`. Update the `<input>` element: In this example we have a writable store `name` and a derived store `greeting`. Update the `<input>` element:
```svelte ```svelte
<input bind:value={$name}> <input bind:value={$name} />
``` ```
Changing the input value will now update `name` and all its dependents. Changing the input value will now update `name` and all its dependents.
@ -15,9 +15,7 @@ Changing the input value will now update `name` and all its dependents.
We can also assign directly to store values inside a component. Add a `<button>` element: We can also assign directly to store values inside a component. Add a `<button>` element:
```svelte ```svelte
<button on:click="{() => $name += '!'}"> <button on:click={() => ($name += '!')}> Add exclamation mark! </button>
Add exclamation mark!
</button>
``` ```
The `$name += '!'` assignment is equivalent to `name.set($name + '!')`. The `$name += '!'` assignment is equivalent to `name.set($name + '!')`.

@ -8,7 +8,7 @@ In this example we have two stores — one representing the circle's coordinates
```svelte ```svelte
<script> <script>
import { spring } from "svelte/motion"; import { spring } from 'svelte/motion';
let coords = spring({ x: 50, y: 50 }); let coords = spring({ x: 50, y: 50 });
let size = spring(10); let size = spring(10);
@ -22,7 +22,7 @@ let coords = spring(
{ x: 50, y: 50 }, { x: 50, y: 50 },
{ {
stiffness: 0.1, stiffness: 0.1,
damping: 0.25, damping: 0.25
} }
); );
``` ```

@ -14,9 +14,7 @@ Transition functions can accept parameters. Replace the `fade` transition with `
...and apply it to the `<p>` along with some options: ...and apply it to the `<p>` along with some options:
```svelte ```svelte
<p transition:fly="{{ y: 200, duration: 2000 }}"> <p transition:fly={{ y: 200, duration: 2000 }}>Flies in and out</p>
Flies in and out
</p>
``` ```
Note that the transition is _reversible_ — if you toggle the checkbox while the transition is ongoing, it transitions from the current point, rather than the beginning or the end. Note that the transition is _reversible_ — if you toggle the checkbox while the transition is ongoing, it transitions from the current point, rather than the beginning or the end.

@ -11,9 +11,7 @@ import { fade, fly } from 'svelte/transition';
...then replace the `transition` directive with separate `in` and `out` directives: ...then replace the `transition` directive with separate `in` and `out` directives:
```svelte ```svelte
<p in:fly="{{ y: 200, duration: 2000 }}" out:fade> <p in:fly={{ y: 200, duration: 2000 }} out:fade>Flies in, fades out</p>
Flies in, fades out
</p>
``` ```
In this case, the transitions are _not_ reversed. In this case, the transitions are _not_ reversed.

@ -11,7 +11,7 @@ function fade(node, { delay = 0, duration = 400 }) {
return { return {
delay, delay,
duration, duration,
css: (t) => `opacity: ${t * o}`, css: (t) => `opacity: ${t * o}`
}; };
} }
``` ```
@ -58,7 +58,7 @@ We can get a lot more creative though. Let's make something truly gratuitous:
function spin(node, { duration }) { function spin(node, { duration }) {
return { return {
duration, duration,
css: t => { css: (t) => {
const eased = elasticOut(t); const eased = elasticOut(t);
return ` return `
@ -67,7 +67,7 @@ We can get a lot more creative though. Let's make something truly gratuitous:
${Math.trunc(t * 360)}, ${Math.trunc(t * 360)},
${Math.min(100, 1000 - 1000 * t)}%, ${Math.min(100, 1000 - 1000 * t)}%,
${Math.min(50, 500 - 500 * t)}% ${Math.min(50, 500 - 500 * t)}%
);` );`;
} }
}; };
} }

@ -20,7 +20,7 @@ function typewriter(node, { speed = 1 }) {
tick: (t) => { tick: (t) => {
const i = Math.trunc(text.length * t); const i = Math.trunc(text.length * t);
node.textContent = text.slice(0, i); node.textContent = text.slice(0, i);
}, }
}; };
} }
``` ```

@ -6,11 +6,11 @@ It can be useful to know when transitions are beginning and ending. Svelte dispa
```svelte ```svelte
<p <p
transition:fly="{{ y: 200, duration: 2000 }}" transition:fly={{ y: 200, duration: 2000 }}
on:introstart="{() => status = 'intro started'}" on:introstart={() => (status = 'intro started')}
on:outrostart="{() => status = 'outro started'}" on:outrostart={() => (status = 'outro started')}
on:introend="{() => status = 'intro ended'}" on:introend={() => (status = 'intro ended')}
on:outroend="{() => status = 'outro ended'}" on:outroend={() => (status = 'outro ended')}
> >
Flies in and out Flies in and out
</p> </p>

@ -4,6 +4,6 @@ export function clickOutside(node) {
return { return {
destroy() { destroy() {
// ...cleanup goes here // ...cleanup goes here
}, }
}; };
} }

@ -10,6 +10,6 @@ export function clickOutside(node) {
return { return {
destroy() { destroy() {
document.removeEventListener('click', handleClick, true); document.removeEventListener('click', handleClick, true);
}, }
}; };
} }

@ -18,9 +18,7 @@ import { clickOutside } from './click_outside.js';
...then use it with the element: ...then use it with the element:
```svelte ```svelte
<div class="box" use:clickOutside on:outclick="{() => (showModal = false)}"> <div class="box" use:clickOutside on:outclick={() => (showModal = false)}>Click outside me!</div>
Click outside me!
</div>
``` ```
Open the `click_outside.js` file. Like transition functions, an action function receives a `node` (which is the element that the action is applied to) and some optional parameters, and returns an action object. That object can have a `destroy` function, which is called when the element is unmounted. Open the `click_outside.js` file. Like transition functions, an action function receives a `node` (which is the element that the action is applied to) and some optional parameters, and returns an action object. That object can have a `destroy` function, which is called when the element is unmounted.
@ -40,7 +38,7 @@ export function clickOutside(node) {
return { return {
destroy() { destroy() {
document.removeEventListener('click', handleClick, true); document.removeEventListener('click', handleClick, true);
}, }
}; };
} }
``` ```

@ -19,6 +19,6 @@ export function longpress(node, duration) {
clearTimeout(timer); clearTimeout(timer);
node.removeEventListener('mousedown', handleMousedown); node.removeEventListener('mousedown', handleMousedown);
node.removeEventListener('mouseup', handleMouseup); node.removeEventListener('mouseup', handleMouseup);
}, }
}; };
} }

@ -22,6 +22,6 @@ export function longpress(node, duration) {
clearTimeout(timer); clearTimeout(timer);
node.removeEventListener('mousedown', handleMousedown); node.removeEventListener('mousedown', handleMousedown);
node.removeEventListener('mouseup', handleMouseup); node.removeEventListener('mouseup', handleMouseup);
}, }
}; };
} }

@ -36,7 +36,7 @@ To change that, we can add an `update` method in `longpress.js`. This will be ca
return { return {
update(newDuration) { update(newDuration) {
duration = newDuration; duration = newDuration;
}, }
// ... // ...
}; };
``` ```

@ -4,19 +4,21 @@ title: The class directive
Like any other attribute, you can specify classes with a JavaScript attribute, seen here: Like any other attribute, you can specify classes with a JavaScript attribute, seen here:
<!-- prettier-ignore -->
```svelte ```svelte
<button <button
class="{current === 'foo' ? 'selected' : ''}" class={current === 'foo' ? 'selected' : ''}
on:click="{() => current = 'foo'}" on:click={() => current = 'foo'}
>foo</button> >foo</button>
``` ```
This is such a common pattern in UI development that Svelte includes a special directive to simplify it: This is such a common pattern in UI development that Svelte includes a special directive to simplify it:
<!-- prettier-ignore -->
```svelte ```svelte
<button <button
class:selected="{current === 'foo'}" class:selected={current === 'foo'}
on:click="{() => current = 'foo'}" on:click={() => current = 'foo'}
>foo</button> >foo</button>
``` ```

@ -4,6 +4,7 @@ title: Shorthand class directive
Often, the name of the class will be the same as the name of the value it depends on: Often, the name of the class will be the same as the name of the value it depends on:
<!-- prettier-ignore -->
```svelte ```svelte
<div class:big={big}> <div class:big={big}>
<!-- ... --> <!-- ... -->

@ -14,7 +14,7 @@ Just like elements can have children...
```svelte ```svelte
<div class="box"> <div class="box">
<slot></slot> <slot />
</div> </div>
``` ```

@ -32,12 +32,10 @@ Then, add elements with corresponding `slot="..."` attributes inside the `<Conta
```svelte ```svelte
<ContactCard> <ContactCard>
<span slot="name"> <span slot="name"> P. Sherman </span>
P. Sherman
</span>
<span slot="address"> <span slot="address">
42 Wallaby Way<br> 42 Wallaby Way<br />
Sydney Sydney
</span> </span>
</ContactCard> </ContactCard>

@ -20,7 +20,7 @@ Next, wrap the `comments` slot and its wrapping `<div>` in an `if` block that ch
{#if $$slots.comments} {#if $$slots.comments}
<div class="discussion"> <div class="discussion">
<h3>Comments</h3> <h3>Comments</h3>
<slot name="comments"></slot> <slot name="comments" />
</div> </div>
{/if} {/if}
``` ```

@ -6,9 +6,10 @@ In this app, we have a `<Hoverable>` component that tracks whether the mouse is
For this, we use _slot props_. In `Hoverable.svelte`, pass the `hovering` value into the slot: For this, we use _slot props_. In `Hoverable.svelte`, pass the `hovering` value into the slot:
<!-- prettier-ignore -->
```svelte ```svelte
<div on:mouseenter={enter} on:mouseleave={leave}> <div on:mouseenter={enter} on:mouseleave={leave}>
<slot hovering={hovering}></slot> <slot hovering={hovering} />
</div> </div>
``` ```
@ -16,6 +17,7 @@ For this, we use _slot props_. In `Hoverable.svelte`, pass the `hovering` value
Then, to expose `hovering` to the contents of the `<Hoverable>` component, we use the `let` directive: Then, to expose `hovering` to the contents of the `<Hoverable>` component, we use the `let` directive:
<!-- prettier-ignore -->
```svelte ```svelte
<Hoverable let:hovering={hovering}> <Hoverable let:hovering={hovering}>
<div class:active={hovering}> <div class:active={hovering}>

@ -15,7 +15,7 @@ import { onDestroy, setContext } from 'svelte';
import { mapbox, key } from './mapbox.js'; import { mapbox, key } from './mapbox.js';
setContext(key, { setContext(key, {
getMap: () => map, getMap: () => map
}); });
``` ```

@ -6,6 +6,7 @@ Similar to `<svelte:window>` and `<svelte:document>`, the `<svelte:body>` elemen
Add the `mouseenter` and `mouseleave` handlers to the `<svelte:body>` tag: Add the `mouseenter` and `mouseleave` handlers to the `<svelte:body>` tag:
<!-- prettier-ignore -->
```svelte ```svelte
<svelte:body <svelte:body
on:mouseenter={handleMouseenter} on:mouseenter={handleMouseenter}

@ -6,7 +6,7 @@ The `<svelte:head>` element allows you to insert elements inside the `<head>` of
```svelte ```svelte
<svelte:head> <svelte:head>
<link rel="stylesheet" href="/tutorial/dark-theme.css"> <link rel="stylesheet" href="/tutorial/dark-theme.css" />
</svelte:head> </svelte:head>
``` ```

@ -9,7 +9,7 @@ Anything exported from a `context="module"` script block becomes an export from
const elements = new Set(); const elements = new Set();
export function stopAll() { export function stopAll() {
elements.forEach(element => { elements.forEach((element) => {
element.pause(); element.pause();
}); });
} }
@ -27,9 +27,7 @@ Anything exported from a `context="module"` script block becomes an export from
...and use it in an event handler: ...and use it in an event handler:
```svelte ```svelte
<button on:click={stopAll}> <button on:click={stopAll}> stop all audio </button>
stop all audio
</button>
``` ```
> You can't have a default export, because the component _is_ the default export. > You can't have a default export, because the component _is_ the default export.

@ -21,25 +21,25 @@ module.exports = {
'prefer-const': [2, { destructuring: 'all' }], 'prefer-const': [2, { destructuring: 'all' }],
'arrow-spacing': 2, 'arrow-spacing': 2,
'no-inner-declarations': 0, 'no-inner-declarations': 0,
'require-atomic-updates': 0, 'require-atomic-updates': 0
}, },
env: { env: {
es6: true, es6: true,
browser: true, browser: true,
node: true, node: true,
mocha: true, mocha: true
}, },
extends: ['eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings'], extends: ['eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings'],
plugins: ['svelte3'], plugins: ['svelte3'],
overrides: [ overrides: [
{ {
files: ['*.svelte'], files: ['*.svelte'],
processor: 'svelte3/svelte3', processor: 'svelte3/svelte3'
}, }
], ],
parserOptions: { parserOptions: {
ecmaVersion: 9, ecmaVersion: 9,
sourceType: 'module', sourceType: 'module'
}, },
settings: { settings: {
'import/core-modules': ['svelte'], 'import/core-modules': ['svelte'],
@ -49,6 +49,6 @@ module.exports = {
} catch (e) { } catch (e) {
return null; return null;
} }
})(), })()
}, }
}; };

@ -5,5 +5,5 @@ sh.env['FORCE_UPDATE'] = process.argv.includes('--force=true');
Promise.all([ Promise.all([
sh.exec('node ./scripts/get_contributors.js'), sh.exec('node ./scripts/get_contributors.js'),
sh.exec('node ./scripts/get_donors.js'), sh.exec('node ./scripts/get_donors.js'),
sh.exec('node ./scripts/update_template.js'), sh.exec('node ./scripts/update_template.js')
]); ]);

@ -10,7 +10,7 @@ export async function list(user, { offset, search }) {
list_search: search || '', list_search: search || '',
list_userid: user.id, list_userid: user.id,
list_count: PAGE_SIZE, list_count: PAGE_SIZE,
list_start: offset, list_start: offset
}); });
if (error) throw new Error(error.message); if (error) throw new Error(error.message);
@ -22,7 +22,7 @@ export async function list(user, { offset, search }) {
return { return {
gists: data.slice(0, PAGE_SIZE), gists: data.slice(0, PAGE_SIZE),
next: data.length > PAGE_SIZE ? offset + PAGE_SIZE : null, next: data.length > PAGE_SIZE ? offset + PAGE_SIZE : null
}; };
} }
@ -35,7 +35,7 @@ export async function create(user, gist) {
const { data, error } = await client.rpc('gist_create', { const { data, error } = await client.rpc('gist_create', {
name: gist.name, name: gist.name,
files: gist.files, files: gist.files,
userid: user.id, userid: user.id
}); });
if (error) { if (error) {
@ -71,7 +71,7 @@ export async function update(user, gistid, gist) {
gist_id: gistid, gist_id: gistid,
gist_name: gist.name, gist_name: gist.name,
gist_files: gist.files, gist_files: gist.files,
gist_userid: user.id, gist_userid: user.id
}); });
if (error) { if (error) {
@ -88,7 +88,7 @@ export async function update(user, gistid, gist) {
export async function destroy(userid, ids) { export async function destroy(userid, ids) {
const { error } = await client.rpc('gist_destroy', { const { error } = await client.rpc('gist_destroy', {
gist_ids: ids, gist_ids: ids,
gist_userid: userid, gist_userid: userid
}); });
if (error) { if (error) {

@ -15,7 +15,7 @@ export async function create(user, access_token) {
user_github_id: user.github_id, user_github_id: user.github_id,
user_github_name: user.github_name, user_github_name: user.github_name,
user_github_login: user.github_login, user_github_login: user.github_login,
user_github_avatar_url: user.github_avatar_url, user_github_avatar_url: user.github_avatar_url
}); });
if (error) { if (error) {
@ -26,12 +26,12 @@ export async function create(user, access_token) {
id: data.userid, id: data.userid,
github_name: user.github_name, github_name: user.github_name,
github_login: user.github_login, github_login: user.github_login,
github_avatar_url: user.github_avatar_url, github_avatar_url: user.github_avatar_url
}); });
return { return {
sessionid: data.sessionid, sessionid: data.sessionid,
expires: new Date(data.expires), expires: new Date(data.expires)
}; };
} }

@ -24,7 +24,7 @@ export function get_index() {
date, date,
title: metadata.title, title: metadata.title,
description: metadata.description, description: metadata.description,
draft: !!metadata.draft, draft: !!metadata.draft
}; };
}); });
} }
@ -50,10 +50,10 @@ export function get_post(slug) {
description: metadata.description, description: metadata.description,
author: { author: {
name: metadata.author, name: metadata.author,
url: metadata.authorURL, url: metadata.authorURL
}, },
draft: !!metadata.draft, draft: !!metadata.draft,
content: transform(body), content: transform(body)
}; };
} }
} }

@ -14,7 +14,7 @@ const escape_replacements = {
'<': '&lt;', '<': '&lt;',
'>': '&gt;', '>': '&gt;',
'"': '&quot;', '"': '&quot;',
"'": '&#39;', "'": '&#39;'
}; };
const get_escape_replacement = (ch) => escape_replacements[ch]; const get_escape_replacement = (ch) => escape_replacements[ch];
@ -45,7 +45,7 @@ const prism_languages = {
css: 'css', css: 'css',
diff: 'diff', diff: 'diff',
ts: 'typescript', ts: 'typescript',
'': '', '': ''
}; };
/** @type {Partial<import('marked').Renderer>} */ /** @type {Partial<import('marked').Renderer>} */
@ -165,7 +165,7 @@ const default_renderer = {
text(text) { text(text) {
return text; return text;
}, }
}; };
/** /**
@ -179,8 +179,8 @@ export function transform(markdown, renderer = {}) {
// options are global, and merged in confusing ways. You can't do e.g. // options are global, and merged in confusing ways. You can't do e.g.
// `new Marked(options).parse(markdown)` // `new Marked(options).parse(markdown)`
...default_renderer, ...default_renderer,
...renderer, ...renderer
}, }
}); });
return marked(markdown); return marked(markdown);

@ -62,7 +62,7 @@ const languages = {
css: 'css', css: 'css',
diff: 'diff', diff: 'diff',
ts: 'typescript', ts: 'typescript',
'': '', '': ''
}; };
/** /**
@ -310,7 +310,7 @@ export async function read_file(file) {
// }) + // }) +
'</code>' '</code>'
); );
}, }
}); });
return { return {
@ -318,7 +318,7 @@ export async function read_file(file) {
slug: match[1], slug: match[1],
title: metadata.title, title: metadata.title,
content, content,
sections, sections
}; };
} }
@ -370,14 +370,14 @@ function parse({ file, body, code, codespan }) {
section = { section = {
title, title,
slug, slug,
sections: [], sections: []
}; };
sections.push(section); sections.push(section);
} else if (level === 4 || level === 5) { } else if (level === 4 || level === 5) {
(section?.sections ?? sections).push({ (section?.sections ?? sections).push({
title, title,
slug, slug
}); });
} else { } else {
throw new Error(`Unexpected <h${level}> in ${file}`); throw new Error(`Unexpected <h${level}> in ${file}`);
@ -388,12 +388,12 @@ function parse({ file, body, code, codespan }) {
} id="${slug}">${html}<a href="#${slug}" class="permalink"><span class="visually-hidden">permalink</span></a></h${level}>`; } id="${slug}">${html}<a href="#${slug}" class="permalink"><span class="visually-hidden">permalink</span></a></h${level}>`;
}, },
code: (source, language) => code(source, language, current), code: (source, language) => code(source, language, current),
codespan, codespan
}); });
return { return {
sections, sections,
content, content
}; };
} }
@ -585,7 +585,7 @@ function convert_to_ts(js_code, indent = '', offset = '') {
name, name,
generics generics
.replaceAll('*', '') // get rid of JSDoc asterisks .replaceAll('*', '') // get rid of JSDoc asterisks
.replace(' }>', '}>'), // unindent closing brace .replace(' }>', '}>') // unindent closing brace
]; ];
} }
} }

@ -9,7 +9,7 @@ const escapeReplacements = {
'<': '&lt;', '<': '&lt;',
'>': '&gt;', '>': '&gt;',
'"': '&quot;', '"': '&quot;',
"'": '&#39;', "'": '&#39;'
}; };
/** /**
@ -153,7 +153,7 @@ const default_renderer = {
text(text) { text(text) {
return text; return text;
}, }
}; };
/** /**
@ -167,8 +167,8 @@ export function transform(markdown, renderer = {}) {
// options are global, and merged in confusing ways. You can't do e.g. // options are global, and merged in confusing ways. You can't do e.g.
// `new Marked(options).parse(markdown)` // `new Marked(options).parse(markdown)`
...default_renderer, ...default_renderer,
...renderer, ...renderer
}, }
}); });
return marked(markdown); return marked(markdown);

@ -7,7 +7,7 @@ const o = {
day: 24 * 60 * 1000 * 60, day: 24 * 60 * 1000 * 60,
week: 7 * 24 * 60 * 1000 * 60, week: 7 * 24 * 60 * 1000 * 60,
month: 30 * 24 * 60 * 1000 * 60, month: 30 * 24 * 60 * 1000 * 60,
year: 365 * 24 * 60 * 1000 * 60, year: 365 * 24 * 60 * 1000 * 60
}; };
export const ago = (nd, s) => { export const ago = (nd, s) => {

@ -11,7 +11,7 @@ export function keyEvent(code) {
return { return {
destroy() { destroy() {
node.removeEventListener('keydown', handleKeydown); node.removeEventListener('keydown', handleKeydown);
}, }
}; };
}; };
} }

@ -2,6 +2,6 @@ import * as session from '$lib/db/session';
export async function load({ request }) { export async function load({ request }) {
return { return {
user: await session.from_cookie(request.headers.get('cookie')), user: await session.from_cookie(request.headers.get('cookie'))
}; };
} }

@ -47,7 +47,7 @@ export async function GET({ params }) {
if (!res.ok) { if (!res.ok) {
return new Response(await res.json(), { return new Response(await res.json(), {
status: res.status, status: res.status,
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' }
}); });
} }
@ -58,7 +58,7 @@ export async function GET({ params }) {
name: example.name, name: example.name,
owner: null, owner: null,
relaxed: example.relaxed, // TODO is this right? relaxed: example.relaxed, // TODO is this right?
components: munge(example.files), components: munge(example.files)
}); });
} }
@ -83,7 +83,7 @@ export async function GET({ params }) {
name: app.name, name: app.name,
owner: app.userid, owner: app.userid,
relaxed: false, relaxed: false,
components: munge(app.files), components: munge(app.files)
}); });
} }

@ -11,6 +11,6 @@ export async function load({ fetch, params, url }) {
return { return {
gist, gist,
version: url.searchParams.get('version') || '3', version: url.searchParams.get('version') || '3'
}; };
} }

@ -14,6 +14,6 @@ export async function POST({ request }) {
result.id = result.id.replace(/-/g, ''); result.id = result.id.replace(/-/g, '');
return json(result, { return json(result, {
status: 201, status: 201
}); });
} }

@ -3,6 +3,6 @@ export function load({ url }) {
return { return {
version: query.get('version') || '3', version: query.get('version') || '3',
gist: query.get('gist'), gist: query.get('gist'),
example: query.get('example'), example: query.get('example')
}; };
} }

@ -9,6 +9,6 @@ export function GET({ params: { path } }) {
return new Response(undefined, { status: 403 }); return new Response(undefined, { status: 403 });
} }
return new Response(readFileSync(join(local_svelte_path, path)), { return new Response(readFileSync(join(local_svelte_path, path)), {
headers: { 'Content-Type': 'text/javascript' }, headers: { 'Content-Type': 'text/javascript' }
}); });
} }

@ -4,7 +4,7 @@ export const companies = [
filename: '1password.svg', filename: '1password.svg',
alt: '1Password logo', alt: '1Password logo',
width: 364, width: 364,
height: 68, height: 68
}, },
{ {
href: 'https://www.alaskaair.com/', href: 'https://www.alaskaair.com/',
@ -13,14 +13,14 @@ export const companies = [
alt: 'Alaska Airlines logo', alt: 'Alaska Airlines logo',
invert: true, invert: true,
width: 113, width: 113,
height: 48, height: 48
}, },
{ {
href: 'https://avast.com', href: 'https://avast.com',
filename: 'avast.svg', filename: 'avast.svg',
alt: 'Avast logo', alt: 'Avast logo',
width: 300, width: 300,
height: 95, height: 95
}, },
{ {
href: 'https://chess.com', href: 'https://chess.com',
@ -29,56 +29,56 @@ export const companies = [
alt: 'Chess.com logo', alt: 'Chess.com logo',
invert: true, invert: true,
width: 300, width: 300,
height: 85, height: 85
}, },
{ {
href: 'https://fusioncharts.com', href: 'https://fusioncharts.com',
filename: 'fusioncharts.svg', filename: 'fusioncharts.svg',
alt: 'FusionCharts logo', alt: 'FusionCharts logo',
width: 735, width: 735,
height: 115, height: 115
}, },
{ {
href: 'https://godaddy.com', href: 'https://godaddy.com',
filename: 'godaddy.svg', filename: 'godaddy.svg',
alt: 'GoDaddy logo', alt: 'GoDaddy logo',
width: 300, width: 300,
height: 84, height: 84
}, },
{ {
href: 'https://www.ibm.com/', href: 'https://www.ibm.com/',
filename: 'ibm.svg', filename: 'ibm.svg',
alt: 'IBM logo', alt: 'IBM logo',
width: 1000, width: 1000,
height: 400, height: 400
}, },
{ {
href: 'https://media.lesechos.fr/infographie', href: 'https://media.lesechos.fr/infographie',
filename: 'les-echos.svg', filename: 'les-echos.svg',
alt: 'Les Echos', alt: 'Les Echos',
width: 142, width: 142,
height: 33, height: 33
}, },
{ {
href: 'https://www.philips.co.uk', href: 'https://www.philips.co.uk',
filename: 'philips.svg', filename: 'philips.svg',
alt: 'Philips logo', alt: 'Philips logo',
width: 140, width: 140,
height: 30, height: 30
}, },
{ {
href: 'https://global.rakuten.com/corp/', href: 'https://global.rakuten.com/corp/',
filename: 'rakuten.svg', filename: 'rakuten.svg',
alt: 'Rakuten logo', alt: 'Rakuten logo',
width: 300, width: 300,
height: 89, height: 89
}, },
{ {
href: 'https://razorpay.com', href: 'https://razorpay.com',
filename: 'razorpay.svg', filename: 'razorpay.svg',
alt: 'Razorpay logo', alt: 'Razorpay logo',
width: 316, width: 316,
height: 67, height: 67
}, },
// { // {
// href: 'https://www.se.com', // href: 'https://www.se.com',
@ -92,20 +92,20 @@ export const companies = [
filename: 'square.svg', filename: 'square.svg',
alt: 'Square', alt: 'Square',
width: 144, width: 144,
height: 36, height: 36
}, },
{ {
href: 'https://nytimes.com', href: 'https://nytimes.com',
filename: 'nyt.svg', filename: 'nyt.svg',
alt: 'The New York Times logo', alt: 'The New York Times logo',
width: 300, width: 300,
height: 49, height: 49
}, },
{ {
href: 'https://transloadit.com', href: 'https://transloadit.com',
filename: 'transloadit.svg', filename: 'transloadit.svg',
alt: 'Transloadit', alt: 'Transloadit',
width: 239, width: 239,
height: 60, height: 60
}, }
]; ];

@ -12,7 +12,7 @@ export async function GET({ url }) {
stringify({ stringify({
code: url.searchParams.get('code'), code: url.searchParams.get('code'),
client_id, client_id,
client_secret, client_secret
}) })
); );
const access_token = new URLSearchParams(await r1.text()).get('access_token'); const access_token = new URLSearchParams(await r1.text()).get('access_token');
@ -21,8 +21,8 @@ export async function GET({ url }) {
const r2 = await fetch('https://api.github.com/user', { const r2 = await fetch('https://api.github.com/user', {
headers: { headers: {
'User-Agent': 'svelte.dev', 'User-Agent': 'svelte.dev',
Authorization: `token ${access_token}`, Authorization: `token ${access_token}`
}, }
}); });
const profile = await r2.json(); const profile = await r2.json();
@ -33,7 +33,7 @@ export async function GET({ url }) {
github_id: profile.id, github_id: profile.id,
github_name: profile.name, github_name: profile.name,
github_login: profile.login, github_login: profile.login,
github_avatar_url: profile.avatar_url, github_avatar_url: profile.avatar_url
}; };
const { sessionid, expires } = await session.create(user, access_token); const { sessionid, expires } = await session.create(user, access_token);
@ -52,10 +52,10 @@ export async function GET({ url }) {
expires: new Date(expires), expires: new Date(expires),
path: '/', path: '/',
httpOnly: true, httpOnly: true,
secure: url.protocol === 'https', secure: url.protocol === 'https'
}), }),
'Content-Type': 'text/html; charset=utf-8', 'Content-Type': 'text/html; charset=utf-8'
}, }
} }
); );
} catch (err) { } catch (err) {

@ -9,7 +9,7 @@ export const GET = client_id
stringify({ stringify({
scope: 'read:user', scope: 'read:user',
client_id, client_id,
redirect_uri: `${url.origin}/auth/callback`, redirect_uri: `${url.origin}/auth/callback`
}); });
throw redirect(302, Location); throw redirect(302, Location);
@ -28,7 +28,7 @@ export const GET = client_id
{ {
status: 500, status: 500,
headers: { headers: {
'Content-Type': 'text/html; charset=utf-8', 'Content-Type': 'text/html; charset=utf-8'
}, }
} }
); );

@ -11,8 +11,8 @@ export async function GET({ request }) {
maxAge: -1, maxAge: -1,
path: '/', path: '/',
httpOnly: true, httpOnly: true,
secure: request.url.protocol === 'https', secure: request.url.protocol === 'https'
}), })
}, }
}); });
} }

@ -4,6 +4,6 @@ export const prerender = true;
export async function load() { export async function load() {
return { return {
posts: get_index(), posts: get_index()
}; };
} }

@ -11,6 +11,6 @@ export async function load({ params }) {
} }
return { return {
post, post
}; };
} }

@ -29,18 +29,18 @@ export const GET = async ({ params, url }) => {
name: 'Overpass', name: 'Overpass',
data: Buffer.from(OverpassRegular), data: Buffer.from(OverpassRegular),
style: 'normal', style: 'normal',
weight: 400, weight: 400
}, }
], ],
height, height,
width, width
}); });
const resvg = new Resvg(svg, { const resvg = new Resvg(svg, {
fitTo: { fitTo: {
mode: 'width', mode: 'width',
value: width, value: width
}, }
}); });
const image = resvg.render(); const image = resvg.render();
@ -48,7 +48,7 @@ export const GET = async ({ params, url }) => {
return new Response(image.asPng(), { return new Response(image.asPng(), {
headers: { headers: {
'content-type': 'image/png', 'content-type': 'image/png',
'cache-control': 'public, max-age=600', // cache for 10 minutes 'cache-control': 'public, max-age=600' // cache for 10 minutes
}, }
}); });
}; };

@ -15,7 +15,7 @@ function escapeHTML(html) {
"'": '#39', "'": '#39',
'&': 'amp', '&': 'amp',
'<': 'lt', '<': 'lt',
'>': 'gt', '>': 'gt'
}; };
return html.replace(/["'&<>]/g, (c) => `&${chars[c]};`); return html.replace(/["'&<>]/g, (c) => `&${chars[c]};`);
@ -63,7 +63,7 @@ export async function GET() {
return new Response(get_rss(posts), { return new Response(get_rss(posts), {
headers: { headers: {
'Cache-Control': `max-age=${30 * 60 * 1e3}`, 'Cache-Control': `max-age=${30 * 60 * 1e3}`,
'Content-Type': 'application/rss+xml', 'Content-Type': 'application/rss+xml'
}, }
}); });
} }

@ -1,6 +1,6 @@
export function GET() { export function GET() {
return new Response(undefined, { return new Response(undefined, {
status: 302, status: 302,
headers: { Location: 'https://discord.gg/svelte' }, headers: { Location: 'https://discord.gg/svelte' }
}); });
} }

@ -6,6 +6,6 @@ export const prerender = true;
/** @type {import('./$types').RequestHandler} */ /** @type {import('./$types').RequestHandler} */
export function GET() { export function GET() {
return json({ return json({
blocks: content(), blocks: content()
}); });
} }

@ -12,14 +12,14 @@ const categories = [
label: null, label: null,
/** @param {string[]} parts */ /** @param {string[]} parts */
href: (parts) => href: (parts) =>
parts.length > 1 ? `/docs/${parts[0]}#${parts.slice(1).join('-')}` : `/docs/${parts[0]}`, parts.length > 1 ? `/docs/${parts[0]}#${parts.slice(1).join('-')}` : `/docs/${parts[0]}`
}, },
{ {
slug: 'faq', slug: 'faq',
label: 'FAQ', label: 'FAQ',
/** @param {string[]} parts */ /** @param {string[]} parts */
href: (parts) => `/faq#${parts.join('-')}`, href: (parts) => `/faq#${parts.join('-')}`
}, }
]; ];
export function content() { export function content() {
@ -50,7 +50,7 @@ export function content() {
breadcrumbs: [...breadcrumbs, removeMarkdown(metadata.title ?? '')], breadcrumbs: [...breadcrumbs, removeMarkdown(metadata.title ?? '')],
href: category.href([slug]), href: category.href([slug]),
content: plaintext(intro), content: plaintext(intro),
rank, rank
}); });
for (const section of sections) { for (const section of sections) {
@ -66,7 +66,7 @@ export function content() {
breadcrumbs: [...breadcrumbs, removeMarkdown(metadata.title), removeMarkdown(h3)], breadcrumbs: [...breadcrumbs, removeMarkdown(metadata.title), removeMarkdown(h3)],
href: category.href([slug, normalizeSlugify(h3)]), href: category.href([slug, normalizeSlugify(h3)]),
content: plaintext(intro), content: plaintext(intro),
rank, rank
}); });
for (const subsection of subsections) { for (const subsection of subsections) {
@ -78,11 +78,11 @@ export function content() {
...breadcrumbs, ...breadcrumbs,
removeMarkdown(metadata.title), removeMarkdown(metadata.title),
removeMarkdown(h3), removeMarkdown(h3),
removeMarkdown(h4), removeMarkdown(h4)
], ],
href: category.href([slug, normalizeSlugify(h3), normalizeSlugify(h4)]), href: category.href([slug, normalizeSlugify(h3), normalizeSlugify(h4)]),
content: plaintext(lines.join('\n').trim()), content: plaintext(lines.join('\n').trim()),
rank, rank
}); });
} }
} }
@ -122,7 +122,7 @@ function plaintext(markdown) {
del: inline, del: inline,
link: (href, title, text) => text, link: (href, title, text) => text,
image: (href, title, text) => text, image: (href, title, text) => text,
text: inline, text: inline
}) })
.replace(/&lt;/g, '<') .replace(/&lt;/g, '<')
.replace(/&gt;/g, '>') .replace(/&gt;/g, '>')

@ -13,11 +13,11 @@ export function load() {
return { return {
title, title,
path: `${base}/docs/${file.slice(3, -3)}`, path: `${base}/docs/${file.slice(3, -3)}`
}; };
}); });
return { return {
sections, sections
}; };
} }

@ -15,7 +15,7 @@ export async function load({ params }) {
for (const file of fs.readdirSync(`${base}`)) { for (const file of fs.readdirSync(`${base}`)) {
if (file.slice(3, -3) === params.slug) { if (file.slice(3, -3) === params.slug) {
return { return {
page: await read_file(file), page: await read_file(file)
}; };
} }
} }

@ -3,15 +3,15 @@ import { PUBLIC_API_BASE } from '$env/static/public';
/** @type {import('./$types').PageLoad} */ /** @type {import('./$types').PageLoad} */
export async function load({ fetch, params, setHeaders }) { export async function load({ fetch, params, setHeaders }) {
const example = await fetch(`${PUBLIC_API_BASE}/docs/svelte/examples/${params.slug}`, { const example = await fetch(`${PUBLIC_API_BASE}/docs/svelte/examples/${params.slug}`, {
credentials: 'omit', credentials: 'omit'
}); });
setHeaders({ setHeaders({
'cache-control': 'public, max-age=60', 'cache-control': 'public, max-age=60'
}); });
return { return {
example: await example.json(), example: await example.json(),
slug: params.slug, slug: params.slug
}; };
} }

@ -5,7 +5,7 @@ export async function load({ fetch, setHeaders }) {
const faqs = await fetch(`${PUBLIC_API_BASE}/docs/svelte/faq?content`).then((r) => r.json()); const faqs = await fetch(`${PUBLIC_API_BASE}/docs/svelte/faq?content`).then((r) => r.json());
setHeaders({ setHeaders({
'cache-control': 'public, max-age=60', 'cache-control': 'public, max-age=60'
}); });
return { faqs }; return { faqs };

@ -16,6 +16,6 @@ export async function load({ url, fetch }) {
return { return {
query, query,
results, results
}; };
} }

@ -10,7 +10,7 @@ export async function load({ fetch, params, setHeaders }) {
} }
setHeaders({ setHeaders({
'cache-control': 'public, max-age=60', 'cache-control': 'public, max-age=60'
}); });
return { tutorial: await tutorial.json(), slug: params.slug }; return { tutorial: await tutorial.json(), slug: params.slug };

@ -4,83 +4,83 @@ export async function GET() {
return json([ return json([
{ {
title: 'accusamus beatae ad facilis cum similique qui sunt', title: 'accusamus beatae ad facilis cum similique qui sunt',
thumbnailUrl: 'https://via.placeholder.com/150/92c952', thumbnailUrl: 'https://via.placeholder.com/150/92c952'
}, },
{ {
title: 'reprehenderit est deserunt velit ipsam', title: 'reprehenderit est deserunt velit ipsam',
thumbnailUrl: 'https://via.placeholder.com/150/771796', thumbnailUrl: 'https://via.placeholder.com/150/771796'
}, },
{ {
title: 'officia porro iure quia iusto qui ipsa ut modi', title: 'officia porro iure quia iusto qui ipsa ut modi',
thumbnailUrl: 'https://via.placeholder.com/150/24f355', thumbnailUrl: 'https://via.placeholder.com/150/24f355'
}, },
{ {
title: 'culpa odio esse rerum omnis laboriosam voluptate repudiandae', title: 'culpa odio esse rerum omnis laboriosam voluptate repudiandae',
thumbnailUrl: 'https://via.placeholder.com/150/d32776', thumbnailUrl: 'https://via.placeholder.com/150/d32776'
}, },
{ {
title: 'natus nisi omnis corporis facere molestiae rerum in', title: 'natus nisi omnis corporis facere molestiae rerum in',
thumbnailUrl: 'https://via.placeholder.com/150/f66b97', thumbnailUrl: 'https://via.placeholder.com/150/f66b97'
}, },
{ {
title: 'accusamus ea aliquid et amet sequi nemo', title: 'accusamus ea aliquid et amet sequi nemo',
thumbnailUrl: 'https://via.placeholder.com/150/56a8c2', thumbnailUrl: 'https://via.placeholder.com/150/56a8c2'
}, },
{ {
title: 'officia delectus consequatur vero aut veniam explicabo molestias', title: 'officia delectus consequatur vero aut veniam explicabo molestias',
thumbnailUrl: 'https://via.placeholder.com/150/b0f7cc', thumbnailUrl: 'https://via.placeholder.com/150/b0f7cc'
}, },
{ {
title: 'aut porro officiis laborum odit ea laudantium corporis', title: 'aut porro officiis laborum odit ea laudantium corporis',
thumbnailUrl: 'https://via.placeholder.com/150/54176f', thumbnailUrl: 'https://via.placeholder.com/150/54176f'
}, },
{ {
title: 'qui eius qui autem sed', title: 'qui eius qui autem sed',
thumbnailUrl: 'https://via.placeholder.com/150/51aa97', thumbnailUrl: 'https://via.placeholder.com/150/51aa97'
}, },
{ {
title: 'beatae et provident et ut vel', title: 'beatae et provident et ut vel',
thumbnailUrl: 'https://via.placeholder.com/150/810b14', thumbnailUrl: 'https://via.placeholder.com/150/810b14'
}, },
{ {
title: 'nihil at amet non hic quia qui', title: 'nihil at amet non hic quia qui',
thumbnailUrl: 'https://via.placeholder.com/150/1ee8a4', thumbnailUrl: 'https://via.placeholder.com/150/1ee8a4'
}, },
{ {
title: 'mollitia soluta ut rerum eos aliquam consequatur perspiciatis maiores', title: 'mollitia soluta ut rerum eos aliquam consequatur perspiciatis maiores',
thumbnailUrl: 'https://via.placeholder.com/150/66b7d2', thumbnailUrl: 'https://via.placeholder.com/150/66b7d2'
}, },
{ {
title: 'repudiandae iusto deleniti rerum', title: 'repudiandae iusto deleniti rerum',
thumbnailUrl: 'https://via.placeholder.com/150/197d29', thumbnailUrl: 'https://via.placeholder.com/150/197d29'
}, },
{ {
title: 'est necessitatibus architecto ut laborum', title: 'est necessitatibus architecto ut laborum',
thumbnailUrl: 'https://via.placeholder.com/150/61a65', thumbnailUrl: 'https://via.placeholder.com/150/61a65'
}, },
{ {
title: 'harum dicta similique quis dolore earum ex qui', title: 'harum dicta similique quis dolore earum ex qui',
thumbnailUrl: 'https://via.placeholder.com/150/f9cee5', thumbnailUrl: 'https://via.placeholder.com/150/f9cee5'
}, },
{ {
title: 'iusto sunt nobis quasi veritatis quas expedita voluptatum deserunt', title: 'iusto sunt nobis quasi veritatis quas expedita voluptatum deserunt',
thumbnailUrl: 'https://via.placeholder.com/150/fdf73e', thumbnailUrl: 'https://via.placeholder.com/150/fdf73e'
}, },
{ {
title: 'natus doloribus necessitatibus ipsa', title: 'natus doloribus necessitatibus ipsa',
thumbnailUrl: 'https://via.placeholder.com/150/9c184f', thumbnailUrl: 'https://via.placeholder.com/150/9c184f'
}, },
{ {
title: 'laboriosam odit nam necessitatibus et illum dolores reiciendis', title: 'laboriosam odit nam necessitatibus et illum dolores reiciendis',
thumbnailUrl: 'https://via.placeholder.com/150/1fe46f', thumbnailUrl: 'https://via.placeholder.com/150/1fe46f'
}, },
{ {
title: 'perferendis nesciunt eveniet et optio a', title: 'perferendis nesciunt eveniet et optio a',
thumbnailUrl: 'https://via.placeholder.com/150/56acb2', thumbnailUrl: 'https://via.placeholder.com/150/56acb2'
}, },
{ {
title: 'assumenda voluptatem laboriosam enim consequatur veniam placeat reiciendis error', title: 'assumenda voluptatem laboriosam enim consequatur veniam placeat reiciendis error',
thumbnailUrl: 'https://via.placeholder.com/150/8985dc', thumbnailUrl: 'https://via.placeholder.com/150/8985dc'
}, }
]); ]);
} }

@ -12,12 +12,12 @@ export async function GET(req) {
if (Math.random() < 0.333) { if (Math.random() < 0.333) {
return new Response(`Failed to generate random number. Please try again`, { return new Response(`Failed to generate random number. Please try again`, {
status: 400, status: 400,
headers: { 'Access-Control-Allow-Origin': '*' }, headers: { 'Access-Control-Allow-Origin': '*' }
}); });
} }
const num = min + Math.round(Math.random() * (max - min)); const num = min + Math.round(Math.random() * (max - min));
return new Response(String(num), { return new Response(String(num), {
headers: { 'Access-Control-Allow-Origin': '*' }, headers: { 'Access-Control-Allow-Origin': '*' }
}); });
} }

@ -3,6 +3,6 @@ import adapter from '@sveltejs/adapter-auto';
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
export default { export default {
kit: { kit: {
adapter: adapter(), adapter: adapter()
}, }
}; };

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save