Merge branch 'master' into gh-3113

pull/3172/head
Rich Harris 5 years ago
commit af0d9ed1d3

@ -0,0 +1,99 @@
module.exports = {
root: true,
rules: {
indent: 'off',
'no-unused-vars': 'off',
semi: [2, 'always'],
'keyword-spacing': [2, { before: true, after: true }],
'space-before-blocks': [2, 'always'],
'no-mixed-spaces-and-tabs': [2, 'smart-tabs'],
'no-cond-assign': 0,
'object-shorthand': [2, 'always'],
'no-const-assign': 2,
'no-class-assign': 2,
'no-this-before-super': 2,
'no-var': 2,
'no-unreachable': 2,
'valid-typeof': 2,
'quote-props': [2, 'as-needed'],
'one-var': [2, 'never'],
'prefer-arrow-callback': 2,
'prefer-const': [2, { destructuring: 'all' }],
'arrow-spacing': 2,
'no-inner-declarations': 0,
'require-atomic-updates': 'off',
'@typescript-eslint/indent': [
'error',
'tab',
{
SwitchCase: 1,
ignoredNodes: ['TemplateLiteral']
}
],
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/array-type': ['error', 'array-simple'],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-object-literal-type-assertion': [
'error',
{
allowAsParameter: true
}
],
'@typescript-eslint/no-unused-vars': 'off'
},
globals: {
globalThis: false
},
env: {
es6: true,
browser: true,
node: true,
mocha: true
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended'
],
parserOptions: {
ecmaVersion: 9,
sourceType: 'module'
},
plugins: ['svelte3'],
settings: {
'import/core-modules': [
'svelte',
'svelte/internal',
'svelte/store',
'svelte/easing',
'estree'
],
'svelte3/compiler': require('./compiler')
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
},
{
files: ['*.svelte'],
processor: 'svelte3/svelte3',
rules: {
'@typescript-eslint/indent': 'off'
}
}
]
};

@ -1,80 +0,0 @@
{
"root": true,
"rules": {
"indent": "off",
"no-unused-vars": "off",
"semi": [2, "always"],
"keyword-spacing": [2, { "before": true, "after": true }],
"space-before-blocks": [2, "always"],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-cond-assign": 0,
"object-shorthand": [2, "always"],
"no-const-assign": 2,
"no-class-assign": 2,
"no-this-before-super": 2,
"no-var": 2,
"no-unreachable": 2,
"valid-typeof": 2,
"quote-props": [2, "as-needed"],
"one-var": [2, "never"],
"prefer-arrow-callback": 2,
"prefer-const": [2, { "destructuring": "all" }],
"arrow-spacing": 2,
"no-inner-declarations": 0,
"require-atomic-updates": "off",
"@typescript-eslint/indent": ["error", "tab", {
"SwitchCase": 1,
"ignoredNodes": ["TemplateLiteral"]
}],
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/array-type": ["error", "array-simple"],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_"
}],
"@typescript-eslint/no-object-literal-type-assertion": ["error", {
"allowAsParameter": true
}],
"@typescript-eslint/no-unused-vars": "off"
},
"globals": {
"globalThis": false
},
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module"
},
"settings": {
"import/core-modules": [
"svelte",
"svelte/internal",
"svelte/store",
"svelte/easing",
"estree"
]
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}

@ -1,5 +1,12 @@
# Svelte changelog
## 3.6.5
* Handle RxJS-style observables with `get` ([#3153](https://github.com/sveltejs/svelte/issues/3153))
* Pass `let` values to bindings ([#3140](https://github.com/sveltejs/svelte/issues/3140))
* Escape `@` symbols in props ([#3173](https://github.com/sveltejs/svelte/issues/3173))
* Scale crossfaded elements ([#3175](https://github.com/sveltejs/svelte/pull/3175))
## 3.6.4
* Run `onMount` functions in correct order, and before initial `afterUpdate` functions ([#2281](https://github.com/sveltejs/svelte/issues/2281))

3298
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
{
"name": "svelte",
"version": "3.6.4",
"version": "3.6.5",
"description": "Cybernetically enhanced web apps",
"module": "index.mjs",
"main": "index",
@ -56,40 +56,41 @@
},
"homepage": "https://github.com/sveltejs/svelte#README",
"devDependencies": {
"@types/mocha": "^5.2.0",
"@types/node": "=8",
"@types/mocha": "^5.2.7",
"@types/node": "=12",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"acorn": "^6.1.1",
"acorn": "^6.2.0",
"acorn-dynamic-import": "^4.0.0",
"agadoo": "^1.0.1",
"c8": "^3.4.0",
"codecov": "^3.0.0",
"c8": "^5.0.1",
"codecov": "^3.5.0",
"css-tree": "1.0.0-alpha22",
"eslint": "^6.0.1",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-svelte3": "^2.6.0",
"estree-walker": "^0.6.1",
"is-reference": "^1.1.1",
"jsdom": "^12.2.0",
"kleur": "^3.0.0",
"is-reference": "^1.1.3",
"jsdom": "^15.1.1",
"kleur": "^3.0.3",
"locate-character": "^2.0.5",
"magic-string": "^0.25.2",
"mocha": "^5.2.0",
"puppeteer": "^1.13.0",
"rollup": "^1.1.2",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-json": "^3.0.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.0.0",
"magic-string": "^0.25.3",
"mocha": "^6.1.4",
"puppeteer": "^1.18.1",
"rollup": "^1.16.6",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-sucrase": "^2.1.0",
"rollup-plugin-typescript": "^1.0.0",
"rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-virtual": "^1.0.1",
"source-map": "0.6",
"source-map-support": "^0.5.4",
"tiny-glob": "^0.2.1",
"ts-node": "^8.0.2",
"tslib": "^1.8.0",
"typescript": "^3.4.0"
"source-map": "^0.6.1",
"source-map-support": "^0.5.12",
"tiny-glob": "^0.2.6",
"ts-node": "^8.3.0",
"tslib": "^1.10.0",
"typescript": "^3.5.2"
},
"nyc": {
"include": [

@ -0,0 +1,52 @@
module.exports = {
root: true,
rules: {
indent: [2, 'tab', { SwitchCase: 1 }],
semi: [2, 'always'],
'keyword-spacing': [2, { before: true, after: true }],
'space-before-blocks': [2, 'always'],
'no-mixed-spaces-and-tabs': [2, 'smart-tabs'],
'no-cond-assign': 0,
'no-unused-vars': 2,
'object-shorthand': [2, 'always'],
'no-const-assign': 2,
'no-class-assign': 2,
'no-this-before-super': 2,
'no-var': 2,
'no-unreachable': 2,
'valid-typeof': 2,
'quote-props': [2, 'as-needed'],
'one-var': [2, 'never'],
'prefer-arrow-callback': 2,
'prefer-const': [2, { destructuring: 'all' }],
'arrow-spacing': 2,
'no-inner-declarations': 0,
'require-atomic-updates': 0
},
env: {
es6: true,
browser: true,
node: true,
mocha: true
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings'
],
plugins: ['svelte3'],
overrides: [
{
files: ['*.svelte'],
processor: 'svelte3/svelte3'
}
],
parserOptions: {
ecmaVersion: 9,
sourceType: 'module'
},
settings: {
'import/core-modules': ['svelte'],
'svelte3/compiler': require('svelte/compiler')
}
};

@ -1,51 +0,0 @@
{
"root": true,
"rules": {
"indent": [2, "tab", { "SwitchCase": 1 }],
"semi": [2, "always"],
"keyword-spacing": [2, { "before": true, "after": true }],
"space-before-blocks": [2, "always"],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-cond-assign": 0,
"no-unused-vars": 2,
"object-shorthand": [2, "always"],
"no-const-assign": 2,
"no-class-assign": 2,
"no-this-before-super": 2,
"no-var": 2,
"no-unreachable": 2,
"valid-typeof": 2,
"quote-props": [2, "as-needed"],
"one-var": [2, "never"],
"prefer-arrow-callback": 2,
"prefer-const": [2, { "destructuring": "all" }],
"arrow-spacing": 2,
"no-inner-declarations": 0,
"require-atomic-updates": 0
},
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"plugins": ["svelte3"],
"overrides": [
{
"files": "*.svelte",
"processor": "svelte3/svelte3"
}
],
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module"
},
"settings": {
"import/core-modules": ["svelte"]
}
}

@ -2124,12 +2124,6 @@
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
},
"eslint-plugin-svelte3": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-svelte3/-/eslint-plugin-svelte3-2.5.0.tgz",
"integrity": "sha512-oFRl4fbI/b1+Wp0igAssyTSkGwTv3iVaZVFSQl+k+4J9vKQ1T0niAM35EMfZ/nm9747Um3Vr032RMtqw3M8GmA==",
"dev": true
},
"esm": {
"version": "3.2.22",
"resolved": "https://registry.npmjs.org/esm/-/esm-3.2.22.tgz",

@ -38,7 +38,6 @@
"@sveltejs/svelte-repl": "^0.1.8",
"degit": "^2.1.3",
"dotenv": "^8.0.0",
"eslint-plugin-svelte3": "^2.5.0",
"esm": "^3.2.22",
"jimp": "^0.6.0",
"mocha": "^6.1.3",

@ -220,7 +220,7 @@
.show {
background: rgba(0,0,0,.4);
padding: .2em .7em .3em;
padding: .3em .7em;
border-radius: var(--border-r);
top: .1em;
position: relative;

@ -138,7 +138,8 @@ export default class Expression {
}
if (template_scope.is_let(name)) {
if (!function_expression) {
if (!function_expression) { // TODO should this be `!lazy` ?
contextual_dependencies.add(name);
dependencies.add(name);
}
} else if (template_scope.names.has(name)) {
@ -237,7 +238,7 @@ export default class Expression {
const { code } = component;
let function_expression;
let pending_assignments = new Set();
let pending_assignments: Set<string> = new Set();
let dependencies: Set<string>;
let contextual_dependencies: Set<string>;

@ -2,6 +2,7 @@ import CodeBuilder from '../utils/CodeBuilder';
import deindent from '../utils/deindent';
import Renderer from './Renderer';
import Wrapper from './wrappers/shared/Wrapper';
import { escape } from '../utils/stringify';
export interface BlockOptions {
parent?: Block;
@ -408,7 +409,7 @@ export default class Block {
const local_key = this.key && this.get_unique_name('key');
return deindent`
${this.comment && `// ${this.comment}`}
${this.comment && `// ${escape(this.comment, { only_escape_at_symbol: true })}`}
function ${this.name}(${this.key ? `${local_key}, ` : ''}ctx) {
${this.get_contents(local_key)}
}

@ -238,7 +238,12 @@ function get_event_handler(
block: Block,
name: string,
snippet: string
) {
): {
uses_context: boolean;
mutation: string;
contextual_dependencies: Set<string>;
snippet?: string;
} {
const value = get_value_from_dom(renderer, binding.parent, binding);
const store = binding.object[0] === '$' ? binding.object.slice(1) : null;

@ -84,7 +84,7 @@ export default class InlineComponentWrapper extends Wrapper {
});
this.fragment = new FragmentWrapper(renderer, default_slot, node.children, this, strip_whitespace, next_sibling);
const dependencies = new Set();
const dependencies: Set<string> = new Set();
// TODO is this filtering necessary? (I *think* so)
default_slot.dependencies.forEach(name => {

@ -185,7 +185,7 @@ export default function tag(parser: Parser) {
}
}
const unique_names = new Set();
const unique_names: Set<string> = new Set();
let attribute;
while ((attribute = read_attribute(parser, unique_names))) {

@ -95,7 +95,14 @@ export function create_ssr_component(fn) {
render: (props = {}, options = {}) => {
on_destroy = [];
const result = { head: '', css: new Set() };
const result: {
head: string;
css: Set<{
map: null;
code: string;
}>;
} = { head: '', css: new Set() };
const html = $$render(result, props, {}, options);
run_all(on_destroy);
@ -114,9 +121,15 @@ export function create_ssr_component(fn) {
};
}
/**
* Get the current value from a store by subscribing and immediately unsubscribing.
* @param store readable
*/
export function get_store_value<T>(store: Readable<T>): T | undefined {
let value;
store.subscribe(_ => value = _)();
const unsubscribe: any = store.subscribe(_ => value = _);
if (unsubscribe.unsubscribe) unsubscribe.unsubscribe();
else unsubscribe();
return value;
}

@ -1,4 +1,5 @@
import { run_all, noop, safe_not_equal, is_function } from 'svelte/internal';
export { get_store_value as get } from 'svelte/internal';
/** Callback to inform of a value updates. */
type Subscriber<T> = (value: T) => void;
@ -188,14 +189,4 @@ export function derived<T, S extends Stores>(
};
}
};
}
/**
* Get the current value from a store by subscribing and immediately unsubscribing.
* @param store readable
*/
export function get<T>(store: Readable<T>): T {
let value: T | undefined;
store.subscribe((_: T) => value = _)();
return value as T;
}
}

@ -188,6 +188,8 @@ export function crossfade({ fallback, ...defaults }: CrossfadeParams & {
const to = node.getBoundingClientRect();
const dx = from.left - to.left;
const dy = from.top - to.top;
const dw = from.width / to.width;
const dh = from.height / to.height;
const d = Math.sqrt(dx * dx + dy * dy);
const style = getComputedStyle(node);
@ -200,7 +202,8 @@ export function crossfade({ fallback, ...defaults }: CrossfadeParams & {
easing,
css: (t, u) => `
opacity: ${t * opacity};
transform: ${transform} translate(${u * dx}px,${u * dy}px);
transform-origin: top left;
transform: ${transform} translate(${u * dx}px,${u * dy}px) scale(${t + (1-t) * dw}, ${t + (1-t) * dh});
`
};
}

@ -17,8 +17,8 @@ export default {
<div>e</div>
`,
test({ assert, component, target, window, raf }) {
let divs = document.querySelectorAll('div');
test({ assert, component, target, raf }) {
let divs = target.querySelectorAll('div');
divs.forEach(div => {
div.getBoundingClientRect = function() {
const index = [...this.parentNode.children].indexOf(this);
@ -41,11 +41,11 @@ export default {
{ id: 1, name: 'a' }
];
divs = document.querySelectorAll('div');
divs = target.querySelectorAll('div');
assert.ok(~divs[0].style.animation.indexOf('__svelte'));
assert.equal(divs[1].style.animation, undefined);
assert.equal(divs[2].style.animation, undefined);
assert.equal(divs[3].style.animation, undefined);
assert.equal(divs[1].style.animation, '');
assert.equal(divs[2].style.animation, '');
assert.equal(divs[3].style.animation, '');
assert.ok(~divs[4].style.animation.indexOf('__svelte'));
raf.tick(100);

@ -0,0 +1,9 @@
<script>
export let items;
</script>
<div>
{#each items as item, index}
<slot {index}/>
{/each}
</div>

@ -0,0 +1,26 @@
export default {
html: `
<div>
<label>1: <input></label>
<label>2: <input></label>
<label>3: <input></label>
</div>
`,
ssrHtml: `
<div>
<label>1: <input value="a"></label>
<label>2: <input value="b"></label>
<label>3: <input value="c"></label>
</div>
`,
async test({ assert, component, target, window }) {
const inputs = target.querySelectorAll('input');
inputs[2].value = 'd';
await inputs[2].dispatchEvent(new window.Event('input'));
assert.deepEqual(component.letters, ['a', 'b', 'd']);
}
};

@ -0,0 +1,11 @@
<script>
import Nested from './Nested.svelte';
export let letters = ['a', 'b', 'c'];
</script>
<Nested items={letters} let:index>
<label>
{index + 1}: <input bind:value={letters[index]}>
</label>
</Nested>

@ -329,5 +329,18 @@ describe('store', () => {
const store = readable(42, () => { });
assert.equal(get(store), 42);
});
it('works with RxJS-style observables', () => {
const observable = {
subscribe(fn) {
fn(42);
return {
unsubscribe: () => {}
};
}
};
assert.equal(get(observable), 42);
});
});
});

Loading…
Cancel
Save