Skip to content

Commit 7e3b91e

Browse files
committed
Merge branch 'master' into folder-structure
2 parents 6dce281 + 9ac8c66 commit 7e3b91e

File tree

25 files changed

+214
-87
lines changed

25 files changed

+214
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ _actual*.*
2929
/site/.sessions
3030
/site/static/svelte-app.json
3131
/site/static/contributors.jpg
32+
/site/static/workers
3233
/site/scripts/svelte-app
3334
/site/src/routes/_contributors.js

package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "index",
77
"files": [
88
"types",
9-
"compiler.js",
9+
"compiler.*",
1010
"register.js",
1111
"index.*",
1212
"internal",
@@ -63,7 +63,7 @@
6363
"c8": "^3.4.0",
6464
"codecov": "^3.0.0",
6565
"css-tree": "1.0.0-alpha22",
66-
"estree-walker": "^0.6.0",
66+
"estree-walker": "^0.6.1",
6767
"is-reference": "^1.1.1",
6868
"jsdom": "^12.2.0",
6969
"kleur": "^3.0.0",

site/content/examples/06-lifecycle/02-update/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import Eliza from 'elizanode';
2+
import Eliza from 'elizabot';
33
import { beforeUpdate, afterUpdate } from 'svelte';
44
55
let div;

site/content/tutorial/07-lifecycle/03-update/app-a/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import Eliza from 'elizanode';
2+
import Eliza from 'elizabot';
33
import { beforeUpdate, afterUpdate } from 'svelte';
44
55
let div;

site/content/tutorial/07-lifecycle/03-update/app-b/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import Eliza from 'elizanode';
2+
import Eliza from 'elizabot';
33
import { beforeUpdate, afterUpdate } from 'svelte';
44
55
let div;

site/package-lock.json

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"version": "1.0.0",
44
"description": "Docs and examples for Svelte",
55
"scripts": {
6-
"dev": "sapper dev",
6+
"dev": "npm run copy-workers && sapper dev",
7+
"copy-workers": "rm -rf static/workers && cp -r node_modules/@sveltejs/svelte-repl/workers static",
78
"migrate": "node-pg-migrate -r dotenv/config",
8-
"sapper": "sapper build --legacy",
9+
"sapper": "npm run copy-workers && sapper build --legacy",
910
"update_shimport": "cp node_modules/shimport/index.js __sapper__/build/client/[email protected]",
1011
"update": "node scripts/update_template.js && node scripts/get-contributors.js",
1112
"start": "node __sapper__/build",
@@ -38,7 +39,7 @@
3839
"@babel/runtime": "^7.4.4",
3940
"@sindresorhus/slugify": "^0.9.1",
4041
"@sveltejs/site-kit": "^1.0.4",
41-
"@sveltejs/svelte-repl": "0.0.11",
42+
"@sveltejs/svelte-repl": "^0.1.2",
4243
"degit": "^2.1.3",
4344
"dotenv": "^8.0.0",
4445
"eslint-plugin-svelte3": "^1.0.0",

site/src/components/Repl/ReplWidget.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
{#if process.browser}
117117
<Repl
118118
bind:this={repl}
119+
workersUrl="workers"
119120
fixed={mobile}
120121
{svelteUrl}
121122
{rollupUrl}

site/src/routes/examples/index.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
<div class="repl-container" class:loading={isLoading}>
103103
<Repl
104104
bind:this={repl}
105+
workersUrl="workers"
105106
{svelteUrl}
106107
{rollupUrl}
107108
orientation={replOrientation}

site/src/routes/repl/[id]/index.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
<div class="viewport" class:offset={checked}>
207207
<Repl
208208
bind:this={repl}
209+
workersUrl="workers"
209210
{svelteUrl}
210211
{rollupUrl}
211212
{relaxed}

site/src/routes/tutorial/[slug]/index.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
<div class="tutorial-repl">
303303
<Repl
304304
bind:this={repl}
305+
workersUrl="workers"
305306
{svelteUrl}
306307
{rollupUrl}
307308
orientation={mobile ? 'columns' : 'rows'}

site/src/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import sirv from 'sirv';
22
import * as sapper from '@sapper/server';
33
import { API } from './backend/auth';
44

5-
const { PORT=3000 } = process.env;
5+
const { PORT = 3000 } = process.env;
66

77
API()
88
.use(
99
sirv('static', {
10+
dev: process.env.NODE_ENV === 'development',
1011
setHeaders(res) {
1112
res.setHeader('Access-Control-Allow-Origin', '*');
1213
res.hasHeader('Cache-Control') || res.setHeader('Cache-Control', 'max-age=600'); // 10min default

src/runtime/animate/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
import { cubicOut } from 'svelte/easing';
22
import { is_function } from 'svelte/internal';
33

4-
export function flip(node, animation, params) {
4+
// todo: same as Transition, should it be shared?
5+
export interface AnimationConfig {
6+
delay?: number,
7+
duration?: number,
8+
easing?: (t: number) => number,
9+
css?: (t: number, u: number) => string,
10+
tick?: (t: number, u: number) => void
11+
}
12+
13+
interface FlipParams {
14+
delay: number;
15+
duration: number | ((len: number) => number);
16+
easing: (t: number) => number,
17+
}
18+
19+
export function flip(node: Element, animation: { from: DOMRect, to: DOMRect }, params: FlipParams): AnimationConfig {
520
const style = getComputedStyle(node);
621
const transform = style.transform === 'none' ? '' : style.transform;
722

src/runtime/internal/animations.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
import { identity as linear, noop, now } from './utils';
22
import { loop } from './loop';
33
import { create_rule, delete_rule } from './style_manager';
4+
import { AnimationConfig } from '../animate';
45

5-
export function create_animation(node, from, fn, params) {
6+
7+
//todo: documentation says it is DOMRect, but in IE it would be ClientRect
8+
type PositionRect = DOMRect|ClientRect;
9+
10+
type AnimationFn = (node: Element, { from, to }: { from: PositionRect, to: PositionRect }, params: any) => AnimationConfig;
11+
12+
export function create_animation(node: Element & ElementCSSInlineStyle, from: PositionRect, fn: AnimationFn, params) {
613
if (!from) return noop;
714

815
const to = node.getBoundingClientRect();
916
if (from.left === to.left && from.right === to.right && from.top === to.top && from.bottom === to.bottom) return noop;
1017

18+
1119
const {
1220
delay = 0,
1321
duration = 300,
1422
easing = linear,
23+
// @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation?
1524
start: start_time = now() + delay,
25+
// @ts-ignore todo:
1626
end = start_time + duration,
1727
tick = noop,
1828
css
@@ -67,7 +77,7 @@ export function create_animation(node, from, fn, params) {
6777
return stop;
6878
}
6979

70-
export function fix_position(node) {
80+
export function fix_position(node: Element & ElementCSSInlineStyle) {
7181
const style = getComputedStyle(node);
7282

7383
if (style.position !== 'absolute' && style.position !== 'fixed') {

src/runtime/internal/dom.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export function object_without_properties<T,K extends keyof T>(obj:T, exclude: K
5353
return target;
5454
}
5555

56-
export function svg_element(name:string):SVGElement {
57-
return document.createElementNS('http://www.w3.org/2000/svg', name);
56+
export function svg_element<K extends keyof SVGElementTagNameMap>(name:K):SVGElement {
57+
return document.createElementNS<K>('http://www.w3.org/2000/svg', name);
5858
}
5959

6060
export function text(data:string) {
@@ -95,7 +95,7 @@ export function attr(node: Element, attribute: string, value?: string) {
9595
else node.setAttribute(attribute, value);
9696
}
9797

98-
export function set_attributes(node: HTMLElement, attributes: { [x: string]: string; }) {
98+
export function set_attributes(node: Element & ElementCSSInlineStyle, attributes: { [x: string]: string; }) {
9999
for (const key in attributes) {
100100
if (key === 'style') {
101101
node.style.cssText = attributes[key];

src/runtime/internal/loop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { now, raf } from './utils';
22

3-
export interface Task { abort(): void; promise: Promise<undefined> }
3+
export interface Task { abort(): void; promise: Promise<void> }
44

55
const tasks = new Set();
66
let running = false;
@@ -32,7 +32,7 @@ export function loop(fn: (number)=>void): Task {
3232
}
3333

3434
return {
35-
promise: new Promise<undefined>(fulfil => {
35+
promise: new Promise<void>(fulfil => {
3636
tasks.add(task = [fn, fulfil]);
3737
}),
3838
abort() {

src/runtime/internal/ssr.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { set_current_component, current_component } from './lifecycle';
22
import { run_all, blank_object } from './utils';
3+
import { Readable } from 'svelte/store';
34

45
export const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
56
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
@@ -113,7 +114,7 @@ export function create_ssr_component(fn) {
113114
};
114115
}
115116

116-
export function get_store_value(store) {
117+
export function get_store_value<T>(store: Readable<T>): T | undefined {
117118
let value;
118119
store.subscribe(_ => value = _)();
119120
return value;

src/runtime/internal/style_manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ let active = 0;
66
let current_rules = {};
77

88
// https://github.com/darkskyapp/string-hash/blob/master/index.js
9-
function hash(str) {
9+
function hash(str: string) {
1010
let hash = 5381;
1111
let i = str.length;
1212

1313
while (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
1414
return hash >>> 0;
1515
}
1616

17-
export function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
17+
export function create_rule(node: Element & ElementCSSInlineStyle, a: number, b: number, duration: number, delay: number, ease: (t: number) => number, fn: (t: number, u: number) => string, uid: number = 0) {
1818
const step = 16.666 / duration;
1919
let keyframes = '{\n';
2020

@@ -44,7 +44,7 @@ export function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
4444
return name;
4545
}
4646

47-
export function delete_rule(node, name?) {
47+
export function delete_rule(node: Element & ElementCSSInlineStyle, name?: string) {
4848
node.style.animation = (node.style.animation || '')
4949
.split(', ')
5050
.filter(name

0 commit comments

Comments
 (0)