Skip to content

Commit 03b440d

Browse files
committed
Merge branch 'master' of github.com:sveltejs/svelte
2 parents b7f9c9c + e331599 commit 03b440d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+247
-186
lines changed

.gitignore

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
node_modules
55
*.map
66
/src/compile/internal-exports.ts
7-
/compiler.js
8-
/index.js
9-
/internal.*
10-
/store.*
11-
/easing.js
12-
/motion.*
13-
/transition.js
14-
/animate.js
7+
/compiler.*js
8+
/index.*js
9+
/internal.*js
10+
/store.*js
11+
/easing.*js
12+
/motion.*js
13+
/transition.*js
14+
/animate.*js
1515
/scratch/
1616
/coverage/
1717
/coverage.lcov/
@@ -21,6 +21,7 @@ node_modules
2121
/test/sourcemaps/samples/*/output.css.map
2222
/yarn-error.log
2323
_actual*.*
24+
/dist
2425

2526
/site/cypress/screenshots/
2627
/site/__sapper__/

animate.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/animate';

compiler.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/compiler';

easing.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/easing';

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/index';

index.mjs

Lines changed: 0 additions & 10 deletions
This file was deleted.

internal.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/internal';

motion.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './dist/motion';

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
"prepare": "npm run build && npm run tsd",
3131
"dev": "rollup -cw",
3232
"pretest": "npm run build",
33-
"posttest": "agadoo src/internal/index.js",
33+
"posttest": "agadoo internal.mjs",
3434
"prepublishOnly": "export PUBLISH=true && npm run lint && npm test",
35-
"tsd": "tsc -d src/store.ts --outDir .",
36-
"typecheck": "tsc --noEmit"
35+
"tsd": "tsc -p . --emitDeclarationOnly",
36+
"typecheck": "tsc -p . --noEmit"
3737
},
3838
"repository": {
3939
"type": "git",

rollup.config.js

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,19 @@ import pkg from './package.json';
99

1010
const is_publish = !!process.env.PUBLISH;
1111

12+
const tsPlugin = is_publish
13+
? typescript({
14+
include: 'src/**',
15+
typescript: require('typescript')
16+
})
17+
: sucrase({
18+
transforms: ['typescript']
19+
});
20+
1221
export default [
1322
/* internal.[m]js */
1423
{
15-
input: `src/internal/index.js`,
24+
input: `src/internal/index.ts`,
1625
output: [
1726
{
1827
file: `internal.mjs`,
@@ -26,19 +35,22 @@ export default [
2635
}
2736
],
2837
external: id => id.startsWith('svelte/'),
29-
plugins: [{
30-
generateBundle(options, bundle) {
31-
const mod = bundle['internal.mjs'];
32-
if (mod) {
33-
fs.writeFileSync('src/compile/internal-exports.ts', `// This file is automatically generated\nexport default new Set(${JSON.stringify(mod.exports)});`);
38+
39+
plugins: [
40+
tsPlugin,
41+
{
42+
generateBundle(options, bundle) {
43+
const mod = bundle['internal.mjs'];
44+
if (mod) {
45+
fs.writeFileSync('src/compile/internal-exports.ts', `// This file is automatically generated\nexport default new Set(${JSON.stringify(mod.exports)});`);
46+
}
3447
}
35-
}
36-
}]
48+
}]
3749
},
3850

3951
/* compiler.js */
4052
{
41-
input: 'src/index.ts',
53+
input: 'src/compiler.ts',
4254
plugins: [
4355
replace({
4456
__VERSION__: pkg.version
@@ -48,15 +60,7 @@ export default [
4860
include: ['node_modules/**']
4961
}),
5062
json(),
51-
is_publish
52-
? typescript({
53-
include: 'src/**',
54-
exclude: 'src/internal/**',
55-
typescript: require('typescript')
56-
})
57-
: sucrase({
58-
transforms: ['typescript']
59-
})
63+
tsPlugin
6064
],
6165
output: {
6266
file: 'compiler.js',
@@ -71,7 +75,7 @@ export default [
7175

7276
/* motion.mjs */
7377
{
74-
input: `src/motion/index.js`,
78+
input: `src/motion/index.ts`,
7579
output: [
7680
{
7781
file: `motion.mjs`,
@@ -84,46 +88,30 @@ export default [
8488
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
8589
}
8690
],
91+
plugins: [
92+
tsPlugin
93+
],
8794
external: id => id.startsWith('svelte/')
8895
},
8996

90-
/* store.mjs */
91-
{
92-
input: `src/store.ts`,
97+
// everything else
98+
...['index', 'easing', 'transition', 'animate', 'store'].map(name => ({
99+
input: `src/${name}.ts`,
93100
output: [
94101
{
95-
file: `store.mjs`,
102+
file: `${name}.mjs`,
96103
format: 'esm',
97104
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
98105
},
99106
{
100-
file: `store.js`,
107+
file: `${name}.js`,
101108
format: 'cjs',
102109
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
103110
}
104111
],
105112
plugins: [
106-
is_publish
107-
? typescript({
108-
include: 'src/**',
109-
exclude: 'src/internal/**',
110-
typescript: require('typescript')
111-
})
112-
: sucrase({
113-
transforms: ['typescript']
114-
})
113+
tsPlugin
115114
],
116115
external: id => id.startsWith('svelte/')
117-
},
118-
119-
// everything else
120-
...['index', 'easing', 'transition', 'animate'].map(name => ({
121-
input: `${name}.mjs`,
122-
output: {
123-
file: `${name}.js`,
124-
format: 'cjs',
125-
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
126-
},
127-
external: id => id !== `${name}.mjs`
128116
}))
129117
];

animate.mjs renamed to src/animate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { cubicOut } from './easing';
2-
import { is_function } from './internal';
1+
import { cubicOut } from 'svelte/easing';
2+
import { is_function } from 'svelte/internal';
33

44
export function flip(node, animation, params) {
55
const style = getComputedStyle(node);
@@ -22,4 +22,4 @@ export function flip(node, animation, params) {
2222
easing,
2323
css: (t, u) => `transform: ${transform} translate(${u * dx}px, ${u * dy}px);`
2424
};
25-
}
25+
}

src/compile/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assign } from '../internal';
1+
import { assign } from '../internal/index';
22
import Stats from '../Stats';
33
import parse from '../parse/index';
44
import render_dom from './render-dom/index';

src/compile/render-dom/wrappers/RawMustacheTag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Renderer from '../Renderer';
22
import Block from '../Block';
33
import Tag from './shared/Tag';
4-
import Wrapper from './shared/wrapper';
4+
import Wrapper from './shared/Wrapper';
55
import deindent from '../../utils/deindent';
66
import MustacheTag from '../../nodes/MustacheTag';
77
import RawMustacheTag from '../../nodes/RawMustacheTag';

src/compiler.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export { default as compile } from './compile/index';
2+
export { default as parse } from './parse/index';
3+
export { default as preprocess } from './preprocess/index';
4+
export { walk } from 'estree-walker';
5+
6+
export const VERSION = '__VERSION__';

easing.mjs renamed to src/easing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Adapted from https://github.com/mattdesl
33
Distributed under MIT License https://github.com/mattdesl/eases/blob/master/LICENSE.md
44
*/
55

6-
export { identity as linear } from './internal';
6+
export { identity as linear } from 'svelte/internal';
77

88
export function backInOut(t) {
99
const s = 1.70158 * 1.525;

src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
export { default as compile } from './compile/index';
2-
export { default as parse } from './parse/index';
3-
export { default as preprocess } from './preprocess/index';
4-
export { walk } from 'estree-walker';
5-
6-
export const VERSION = '__VERSION__';
1+
export {
2+
onMount,
3+
onDestroy,
4+
beforeUpdate,
5+
afterUpdate,
6+
setContext,
7+
getContext,
8+
tick,
9+
createEventDispatcher
10+
} from 'svelte/internal';

src/internal/Component.js renamed to src/internal/Component.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1-
import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler.js';
2-
import { current_component, set_current_component } from './lifecycle.js';
3-
import { blank_object, is_function, run, run_all, noop } from './utils.js';
4-
import { children } from './dom.js';
1+
import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler';
2+
import { current_component, set_current_component } from './lifecycle';
3+
import { blank_object, is_function, run, run_all, noop } from './utils';
4+
import { children } from './dom';
5+
6+
interface T$$ {
7+
dirty: null;
8+
ctx: null|any;
9+
bound: any;
10+
update: () => void;
11+
callbacks: any;
12+
after_render: any[];
13+
props: any;
14+
fragment: null|any;
15+
not_equal: any;
16+
before_render: any[];
17+
context: Map<any, any>;
18+
on_mount: any[];
19+
on_destroy: any[]
20+
}
521

622
export function bind(component, name, callback) {
723
if (component.$$.props.indexOf(name) === -1) return;
@@ -59,7 +75,7 @@ export function init(component, options, instance, create_fragment, not_equal, p
5975

6076
const props = options.props || {};
6177

62-
const $$ = component.$$ = {
78+
const $$: T$$ = component.$$ = {
6379
fragment: null,
6480
ctx: null,
6581

@@ -99,9 +115,9 @@ export function init(component, options, instance, create_fragment, not_equal, p
99115

100116
if (options.target) {
101117
if (options.hydrate) {
102-
$$.fragment.l(children(options.target));
118+
$$.fragment!.l(children(options.target));
103119
} else {
104-
$$.fragment.c();
120+
$$.fragment!.c();
105121
}
106122

107123
if (options.intro && component.$$.fragment.i) component.$$.fragment.i();
@@ -115,13 +131,16 @@ export function init(component, options, instance, create_fragment, not_equal, p
115131
export let SvelteElement;
116132
if (typeof HTMLElement !== 'undefined') {
117133
SvelteElement = class extends HTMLElement {
134+
$$: T$$;
118135
constructor() {
119136
super();
120137
this.attachShadow({ mode: 'open' });
121138
}
122139

123140
connectedCallback() {
141+
// @ts-ignore todo: improve typings
124142
for (const key in this.$$.slotted) {
143+
// @ts-ignore todo: improve typings
125144
this.appendChild(this.$$.slotted[key]);
126145
}
127146
}
@@ -153,6 +172,8 @@ if (typeof HTMLElement !== 'undefined') {
153172
}
154173

155174
export class SvelteComponent {
175+
$$: T$$;
176+
156177
$destroy() {
157178
destroy(this, true);
158179
this.$destroy = noop;

src/internal/animations.js renamed to src/internal/animations.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { identity as linear, noop, now } from './utils.js';
2-
import { loop } from './loop.js';
3-
import { create_rule, delete_rule } from './style_manager.js';
1+
import { identity as linear, noop, now } from './utils';
2+
import { loop } from './loop';
3+
import { create_rule, delete_rule } from './style_manager';
44

55
export function create_animation(node, from, fn, params) {
66
if (!from) return noop;
@@ -90,4 +90,4 @@ export function fix_position(node) {
9090
node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`;
9191
}
9292
}
93-
}
93+
}

src/internal/await-block.js renamed to src/internal/await-block.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { assign, is_promise } from './utils.js';
2-
import { check_outros, group_outros, on_outro } from './transitions.js';
3-
import { flush } from '../internal/scheduler.js';
1+
import { assign, is_promise } from './utils';
2+
import { check_outros, group_outros, on_outro } from './transitions';
3+
import { flush } from '../internal/scheduler';
44

55
export function handle_promise(promise, info) {
66
const token = info.token = {};
77

8-
function update(type, index, key, value) {
8+
function update(type, index, key?, value?) {
99
if (info.token !== token) return;
1010

1111
info.resolved = key && { [key]: value };
@@ -61,4 +61,4 @@ export function handle_promise(promise, info) {
6161

6262
info.resolved = { [info.value]: promise };
6363
}
64-
}
64+
}

0 commit comments

Comments
 (0)