resolve conflicts, update expected

pull/4742/head
pushkine 5 years ago
parent 0b34a0c2ba
commit ff027cd290

@ -1 +0,0 @@
export * from '../types/runtime/environment/index';

@ -1,42 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function noop() {}
const is_browser = typeof window !== 'undefined';
const is_iframe = is_browser && window.self !== window.top;
const is_cors =
is_iframe &&
/*#__PURE__*/ (() => {
try {
if (window.parent) void window.parent.document;
return false;
} catch (error) {
return true;
}
})();
const has_Symbol = typeof Symbol === 'function';
/* eslint-disable no-var */
const globals = is_browser ? window : typeof globalThis !== 'undefined' ? globalThis : global;
const resolved_promise = Promise.resolve();
exports.now = is_browser ? window.performance.now.bind(window.performance) : Date.now.bind(Date);
exports.raf = is_browser ? requestAnimationFrame : noop;
exports.framerate = 1000 / 60;
/* tests only */
const set_now = (v) => void (exports.now = v);
const set_raf = (fn) => void (exports.raf = fn);
const set_framerate = (v) => void (exports.framerate = v);
exports.globals = globals;
exports.has_Symbol = has_Symbol;
exports.is_browser = is_browser;
exports.is_cors = is_cors;
exports.is_iframe = is_iframe;
exports.noop = noop;
exports.resolved_promise = resolved_promise;
exports.set_framerate = set_framerate;
exports.set_now = set_now;
exports.set_raf = set_raf;

@ -1,29 +0,0 @@
function noop() {}
const is_browser = typeof window !== 'undefined';
const is_iframe = is_browser && window.self !== window.top;
const is_cors =
is_iframe &&
/*#__PURE__*/ (() => {
try {
if (window.parent) void window.parent.document;
return false;
} catch (error) {
return true;
}
})();
const has_Symbol = typeof Symbol === 'function';
/* eslint-disable no-var */
const globals = is_browser ? window : typeof globalThis !== 'undefined' ? globalThis : global;
const resolved_promise = Promise.resolve();
let now = is_browser ? window.performance.now.bind(window.performance) : Date.now.bind(Date);
let raf = is_browser ? requestAnimationFrame : noop;
let framerate = 1000 / 60;
/* tests only */
const set_now = (v) => void (now = v);
const set_raf = (fn) => void (raf = fn);
const set_framerate = (v) => void (framerate = v);
export { framerate, globals, has_Symbol, is_browser, is_cors, is_iframe, noop, now, raf, resolved_promise, set_framerate, set_now, set_raf };

@ -1,5 +0,0 @@
{
"main": "./index",
"module": "./index.mjs",
"types": "./index.d.ts"
}

@ -694,9 +694,12 @@ export default class Component {
to_remove.unshift([parent, prop, index]); to_remove.unshift([parent, prop, index]);
}; };
let scope_updated = false; let scope_updated = false;
let generator_count = 0;
walk(content, { walk(content, {
enter(node: Node, parent, prop, index) { enter(node: Node, parent, prop, index) {
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) {
generator_count++;
}
if (map.has(node)) { if (map.has(node)) {
scope = map.get(node); scope = map.get(node);
} }
@ -723,8 +726,11 @@ export default class Component {
}, },
leave(node: Node) { leave(node: Node) {
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) {
generator_count--;
}
// do it on leave, to prevent infinite loop // do it on leave, to prevent infinite loop
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0) { if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 && generator_count <= 0) {
const to_replace_for_loop_protect = component.loop_protect( const to_replace_for_loop_protect = component.loop_protect(
node, node,
scope, scope,

@ -110,15 +110,20 @@ export default class SlotWrapper extends Wrapper {
if (!has_fallback) { if (!has_fallback) {
renderer.remove_block(this.fallback); renderer.remove_block(this.fallback);
} }
} }
const slot = block.get_unique_name(`${sanitize(slot_name)}_slot`); const slot = block.get_unique_name(`${sanitize(slot_name)}_slot`);
const slot_definition = block.get_unique_name(`${sanitize(slot_name)}_slot_template`); const slot_definition = block.get_unique_name(`${sanitize(slot_name)}_slot_template`);
const slot_or_fallback = has_fallback ? block.get_unique_name(`${sanitize(slot_name)}_slot_or_fallback`) : slot; const slot_or_fallback = has_fallback ? block.get_unique_name(`${sanitize(slot_name)}_slot_or_fallback`) : slot;
const $$scope = renderer.reference('$$scope');
const context = x`
${slot_definition}[1] && ${get_slot_context_fn}
? Object.assign(${$$scope}.ctx.slice(), ${slot_definition}[1](${get_slot_context_fn}(#ctx)))
: ${$$scope}.ctx`;
block.chunks.init.push(b` block.chunks.init.push(b`
const ${slot_definition} = ${renderer.reference('$$slots')}.${slot_name}; const ${slot_definition} = ${renderer.reference('$$slots')}.${slot_name};
const ${slot} = @create_slot(${slot_definition}, #ctx, ${renderer.reference('$$scope')}, ${get_slot_context_fn}); const ${slot} = ${slot_definition} && ${slot_definition}[0](${context});
${has_fallback ? b`const ${slot_or_fallback} = ${slot} || ${this.fallback.name}(#ctx);` : null} ${has_fallback ? b`const ${slot_or_fallback} = ${slot} || ${this.fallback.name}(#ctx);` : null}
`); `);
@ -153,7 +158,8 @@ export default class SlotWrapper extends Wrapper {
const slot_update = b` const slot_update = b`
if (${slot}.p && ${renderer.dirty(dynamic_dependencies)}) { if (${slot}.p && ${renderer.dirty(dynamic_dependencies)}) {
@update_slot(${slot}, ${slot_definition}, #ctx, ${renderer.reference('$$scope')}, #dirty, ${get_slot_changes_fn}, ${get_slot_context_fn}); const #changes = @get_slot_changes(${slot_definition}, ${$$scope}, #dirty, ${get_slot_changes_fn})
if (#changes) ${slot}.p(${context}, #changes);
} }
`; `;
const fallback_update = const fallback_update =

@ -21,8 +21,9 @@ export function add_action(block: Block, target: string, action: Action) {
block.add_variable(id); block.add_variable(id);
const fn = block.renderer.reference(action.name); const fn = block.renderer.reference(action.name);
block.event_listeners.push(
block.event_listeners.push(x`@action_destroyer(${id} = ${fn}.call(null, ${target}, ${snippet}))`); x`(${id} = ${fn}.call(null, ${target}, ${snippet})) && 'function' === typeof ${id}.destroy ? ${id}.destroy : @noop`
);
if (dependencies && dependencies.length > 0) { if (dependencies && dependencies.length > 0) {
let condition = x`${id} && "function" === typeof ${id}.update`; let condition = x`${id} && "function" === typeof ${id}.update`;

@ -13,7 +13,7 @@ export default function(node: AwaitBlock, renderer: Renderer, options: RenderOpt
renderer.add_expression(x` renderer.add_expression(x`
function(__value) { function(__value) {
if (@is_promise(__value)) return ${pending}; if (__value && typeof __value === 'object' && typeof __value.then === 'function') return ${pending};
return (function(${node.then_node ? node.then_node : ''}) { return ${then}; }(__value)); return (function(${node.then_node ? node.then_node : ''}) { return ${then}; }(__value));
}(${node.expression.node}) }(${node.expression.node})
`); `);

@ -1,4 +1,3 @@
import { is_promise } from './utils';
import { transition_in, group_transition_out } from './transitions'; import { transition_in, group_transition_out } from './transitions';
import { flush } from './scheduler'; import { flush } from './scheduler';
import { get_current_component, set_current_component } from './lifecycle'; import { get_current_component, set_current_component } from './lifecycle';
@ -52,7 +51,7 @@ export function handle_promise(promise, info) {
} }
} }
if (is_promise(promise)) { if (promise && typeof promise === 'object' && typeof promise.then === 'function') {
const current_component = get_current_component(); const current_component = get_current_component();
promise.then( promise.then(
(value) => { (value) => {

@ -63,7 +63,6 @@ export function prevent_default(fn) {
return fn.call(this, event); return fn.call(this, event);
}; };
} }
// todo inline at compile time
export function stop_propagation(fn): EventListenerOrEventListenerObject { export function stop_propagation(fn): EventListenerOrEventListenerObject {
return function (event) { return function (event) {
event.stopPropagation(); event.stopPropagation();
@ -71,14 +70,20 @@ export function stop_propagation(fn): EventListenerOrEventListenerObject {
return fn.call(this, event); return fn.call(this, event);
}; };
} }
// todo inline at compile time
export function self(fn) { export function self(fn) {
return function (event) { return function (event) {
// @ts-ignore // @ts-ignore
if (event.target === this) fn.call(this, event); if (event.target === this) fn.call(this, event);
}; };
} }
export function once(fn) {
let ran = false;
return function (this: any, ...args) {
if (ran) return;
ran = true;
fn.call(this, ...args);
};
}
export function attr(node: Element, name: string, value?: any) { export function attr(node: Element, name: string, value?: any) {
if (value == null) { if (value == null) {
node.removeAttribute(name); node.removeAttribute(name);
@ -96,7 +101,9 @@ export function set_attributes(node: HTMLElement, attributes: { [x: string]: any
node.removeAttribute(name); node.removeAttribute(name);
} else if (name === 'style') { } else if (name === 'style') {
node.style.cssText = attributes[name]; node.style.cssText = attributes[name];
} else if (name === '__value' || (descriptors[name] && descriptors[name].set)) { } else if (name === '__value') {
(node as HTMLInputElement).value = node[name] = attributes[name];
} else if (descriptors[name] && descriptors[name].set) {
node[name] = attributes[name]; node[name] = attributes[name];
} else { } else {
attr(node, name, attributes[name]); attr(node, name, attributes[name]);
@ -176,9 +183,7 @@ export function set_data(text, data) {
} }
export function set_input_value(input, value) { export function set_input_value(input, value) {
if (value != null || input.value) { input.value = value == null ? '' : value;
input.value = value;
}
} }
export function set_input_type(input, type) { export function set_input_type(input, type) {
@ -251,8 +256,8 @@ export function add_resize_listener(node: HTMLElement, fn: () => void) {
append(node, iframe); append(node, iframe);
return () => { return () => {
if (is_cors || (unsubscribe && iframe.contentWindow)) unsubscribe();
detach(iframe); detach(iframe);
if (unsubscribe) unsubscribe();
}; };
} }

@ -1,6 +1,12 @@
import { safe_not_equal, subscribe } from './utils'; import { safe_not_equal } from './utils';
import { onEachFrame, loop } from './loop'; import { onEachFrame, loop } from './loop';
import { noop } from './environment'; import { noop } from './environment';
export const set_store_value = (store, ret, value) => (store.set(value || ret), ret);
export const subscribe = (store, subscriber, invalidator?) => {
if (store == null) return noop;
const unsub = store.subscribe(subscriber, invalidator);
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
};
type Setter<T> = (value: T) => void; type Setter<T> = (value: T) => void;
type StopCallback = () => void; type StopCallback = () => void;
export type StartStopNotifier<T> = (set: Setter<T>) => StopCallback | void; export type StartStopNotifier<T> = (set: Setter<T>) => StopCallback | void;

@ -1,30 +1,7 @@
import { noop } from './environment';
export const is_promise = <T = any>(value: any): value is PromiseLike<T> =>
value && typeof value === 'object' && typeof value.then === 'function';
export const safe_not_equal = (a, b) => export const safe_not_equal = (a, b) =>
a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function'; a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';
export const not_equal = (a, b) => (a != a ? b == b : a !== b); export const not_equal = (a, b) => (a != a ? b == b : a !== b);
export function subscribe(store, subscriber, invalidator?) {
if (store == null) return noop;
const unsub = store.subscribe(subscriber, invalidator);
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
}
export function create_slot(definition, ctx, $$scope, fn) {
if (definition) {
const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);
return definition[0](slot_ctx);
}
}
export function get_slot_context(definition, ctx, $$scope, fn) {
return definition[1] && fn ? Object.assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;
}
export function get_slot_changes(definition, $$scope, dirty, fn) { export function get_slot_changes(definition, $$scope, dirty, fn) {
if (!definition[2] || !fn) return $$scope.dirty; if (!definition[2] || !fn) return $$scope.dirty;
const lets = definition[2](fn(dirty)); const lets = definition[2](fn(dirty));
@ -35,17 +12,3 @@ export function get_slot_changes(definition, $$scope, dirty, fn) {
return merged; return merged;
} else return $$scope.dirty | lets; } else return $$scope.dirty | lets;
} }
export function once(fn) {
let ran = false;
return function (this: any, ...args) {
if (ran) return;
ran = true;
fn.call(this, ...args);
};
}
export const set_store_value = (store, ret, value) => (store.set(value || ret), ret);
export function action_destroyer(action_result) {
return action_result && 'function' === typeof action_result.destroy ? action_result.destroy : noop;
}

@ -101,9 +101,9 @@ export function tweened<T>(
}; };
}; };
}); });
const set = (next_value, params) => { const set = (next_value, params?) => {
delay = (params && params.delay) || default_delay; delay = params && 'delay' in params ? params.delay : default_delay;
duration = (params && params.duration) || default_duration; duration = params && 'duration' in params ? params.duration : default_duration;
easing = (params && params.easing) || default_easing; easing = (params && params.easing) || default_easing;
interpolate = (params && params.interpolate) || default_interpolate; interpolate = (params && params.interpolate) || default_interpolate;
return store.set(next_value); return store.set(next_value);

@ -1,7 +1,6 @@
/* generated by Svelte vX.Y.Z */ /* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
action_destroyer,
detach, detach,
element, element,
init, init,
@ -23,7 +22,10 @@ function create_fragment(ctx) {
m(target, anchor, remount) { m(target, anchor, remount) {
insert(target, button, anchor); insert(target, button, anchor);
if (remount) dispose(); if (remount) dispose();
dispose = action_destroyer(foo_action = foo.call(null, button, /*foo_function*/ ctx[1]));
dispose = (foo_action = foo.call(null, button, /*foo_function*/ ctx[1])) && "function" === typeof foo_action.destroy
? foo_action.destroy
: noop;
}, },
p(ctx, [dirty]) { p(ctx, [dirty]) {
if (foo_action && "function" === typeof foo_action.update && dirty & /*bar*/ 1) foo_action.update.call(null, /*foo_function*/ ctx[1]); if (foo_action && "function" === typeof foo_action.update && dirty & /*bar*/ 1) foo_action.update.call(null, /*foo_function*/ ctx[1]);

@ -1,7 +1,6 @@
/* generated by Svelte vX.Y.Z */ /* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
action_destroyer,
attr, attr,
detach, detach,
element, element,
@ -25,7 +24,10 @@ function create_fragment(ctx) {
m(target, anchor, remount) { m(target, anchor, remount) {
insert(target, a, anchor); insert(target, a, anchor);
if (remount) dispose(); if (remount) dispose();
dispose = action_destroyer(link_action = link.call(null, a));
dispose = (link_action = link.call(null, a)) && "function" === typeof link_action.destroy
? link_action.destroy
: noop;
}, },
p: noop, p: noop,
i: noop, i: noop,

@ -28,18 +28,18 @@ function create_fragment(ctx) {
audio_updating = true; audio_updating = true;
} }
/*audio_timeupdate_handler*/ ctx[12].call(audio); /*audio_timeupdate_handler*/ ctx[13].call(audio);
} }
return { return {
c() { c() {
audio = element("audio"); audio = element("audio");
if (/*buffered*/ ctx[0] === void 0) add_render_callback(() => /*audio_progress_handler*/ ctx[10].call(audio)); if (/*buffered*/ ctx[0] === void 0) add_render_callback(() => /*audio_progress_handler*/ ctx[11].call(audio));
if (/*buffered*/ ctx[0] === void 0 || /*seekable*/ ctx[1] === void 0) add_render_callback(() => /*audio_loadedmetadata_handler*/ ctx[11].call(audio)); if (/*buffered*/ ctx[0] === void 0 || /*seekable*/ ctx[1] === void 0) add_render_callback(() => /*audio_loadedmetadata_handler*/ ctx[12].call(audio));
if (/*played*/ ctx[2] === void 0 || /*currentTime*/ ctx[3] === void 0 || /*ended*/ ctx[9] === void 0) add_render_callback(audio_timeupdate_handler); if (/*played*/ ctx[2] === void 0 || /*currentTime*/ ctx[3] === void 0 || /*ended*/ ctx[10] === void 0) add_render_callback(audio_timeupdate_handler);
if (/*duration*/ ctx[4] === void 0) add_render_callback(() => /*audio_durationchange_handler*/ ctx[13].call(audio)); if (/*duration*/ ctx[4] === void 0) add_render_callback(() => /*audio_durationchange_handler*/ ctx[14].call(audio));
if (/*seeking*/ ctx[8] === void 0) add_render_callback(() => /*audio_seeking_seeked_handler*/ ctx[17].call(audio)); if (/*seeking*/ ctx[9] === void 0) add_render_callback(() => /*audio_seeking_seeked_handler*/ ctx[18].call(audio));
if (/*ended*/ ctx[9] === void 0) add_render_callback(() => /*audio_ended_handler*/ ctx[18].call(audio)); if (/*ended*/ ctx[10] === void 0) add_render_callback(() => /*audio_ended_handler*/ ctx[19].call(audio));
}, },
m(target, anchor, remount) { m(target, anchor, remount) {
insert(target, audio, anchor); insert(target, audio, anchor);
@ -48,8 +48,10 @@ function create_fragment(ctx) {
audio.volume = /*volume*/ ctx[6]; audio.volume = /*volume*/ ctx[6];
} }
if (!isNaN(/*playbackRate*/ ctx[7])) { audio.muted = /*muted*/ ctx[7];
audio.playbackRate = /*playbackRate*/ ctx[7];
if (!isNaN(/*playbackRate*/ ctx[8])) {
audio.playbackRate = /*playbackRate*/ ctx[8];
} }
if (remount) for (let i = 0; i < dispose.length; i++) { if (remount) for (let i = 0; i < dispose.length; i++) {
@ -57,17 +59,17 @@ function create_fragment(ctx) {
} }
dispose = [ dispose = [
listen(audio, "progress", /*audio_progress_handler*/ ctx[10]), listen(audio, "progress", /*audio_progress_handler*/ ctx[11]),
listen(audio, "loadedmetadata", /*audio_loadedmetadata_handler*/ ctx[11]), listen(audio, "loadedmetadata", /*audio_loadedmetadata_handler*/ ctx[12]),
listen(audio, "timeupdate", audio_timeupdate_handler), listen(audio, "timeupdate", audio_timeupdate_handler),
listen(audio, "durationchange", /*audio_durationchange_handler*/ ctx[13]), listen(audio, "durationchange", /*audio_durationchange_handler*/ ctx[14]),
listen(audio, "play", /*audio_play_pause_handler*/ ctx[14]), listen(audio, "play", /*audio_play_pause_handler*/ ctx[15]),
listen(audio, "pause", /*audio_play_pause_handler*/ ctx[14]), listen(audio, "pause", /*audio_play_pause_handler*/ ctx[15]),
listen(audio, "volumechange", /*audio_volumechange_handler*/ ctx[15]), listen(audio, "volumechange", /*audio_volumechange_handler*/ ctx[16]),
listen(audio, "ratechange", /*audio_ratechange_handler*/ ctx[16]), listen(audio, "ratechange", /*audio_ratechange_handler*/ ctx[17]),
listen(audio, "seeking", /*audio_seeking_seeked_handler*/ ctx[17]), listen(audio, "seeking", /*audio_seeking_seeked_handler*/ ctx[18]),
listen(audio, "seeked", /*audio_seeking_seeked_handler*/ ctx[17]), listen(audio, "seeked", /*audio_seeking_seeked_handler*/ ctx[18]),
listen(audio, "ended", /*audio_ended_handler*/ ctx[18]) listen(audio, "ended", /*audio_ended_handler*/ ctx[19])
]; ];
}, },
p(ctx, [dirty]) { p(ctx, [dirty]) {
@ -85,8 +87,12 @@ function create_fragment(ctx) {
audio.volume = /*volume*/ ctx[6]; audio.volume = /*volume*/ ctx[6];
} }
if (dirty & /*playbackRate*/ 128 && !isNaN(/*playbackRate*/ ctx[7])) { if (dirty & /*muted*/ 128) {
audio.playbackRate = /*playbackRate*/ ctx[7]; audio.muted = /*muted*/ ctx[7];
}
if (dirty & /*playbackRate*/ 256 && !isNaN(/*playbackRate*/ ctx[8])) {
audio.playbackRate = /*playbackRate*/ ctx[8];
} }
}, },
i: noop, i: noop,
@ -109,6 +115,7 @@ function instance($$self, $$props, $$invalidate) {
let { duration } = $$props; let { duration } = $$props;
let { paused } = $$props; let { paused } = $$props;
let { volume } = $$props; let { volume } = $$props;
let { muted } = $$props;
let { playbackRate } = $$props; let { playbackRate } = $$props;
let { seeking } = $$props; let { seeking } = $$props;
let { ended } = $$props; let { ended } = $$props;
@ -131,7 +138,7 @@ function instance($$self, $$props, $$invalidate) {
ended = this.ended; ended = this.ended;
$$invalidate(2, played); $$invalidate(2, played);
$$invalidate(3, currentTime); $$invalidate(3, currentTime);
$$invalidate(9, ended); $$invalidate(10, ended);
} }
function audio_durationchange_handler() { function audio_durationchange_handler() {
@ -146,22 +153,24 @@ function instance($$self, $$props, $$invalidate) {
function audio_volumechange_handler() { function audio_volumechange_handler() {
volume = this.volume; volume = this.volume;
muted = this.muted;
$$invalidate(6, volume); $$invalidate(6, volume);
$$invalidate(7, muted);
} }
function audio_ratechange_handler() { function audio_ratechange_handler() {
playbackRate = this.playbackRate; playbackRate = this.playbackRate;
$$invalidate(7, playbackRate); $$invalidate(8, playbackRate);
} }
function audio_seeking_seeked_handler() { function audio_seeking_seeked_handler() {
seeking = this.seeking; seeking = this.seeking;
$$invalidate(8, seeking); $$invalidate(9, seeking);
} }
function audio_ended_handler() { function audio_ended_handler() {
ended = this.ended; ended = this.ended;
$$invalidate(9, ended); $$invalidate(10, ended);
} }
$$self.$set = $$props => { $$self.$set = $$props => {
@ -172,9 +181,10 @@ function instance($$self, $$props, $$invalidate) {
if ("duration" in $$props) $$invalidate(4, duration = $$props.duration); if ("duration" in $$props) $$invalidate(4, duration = $$props.duration);
if ("paused" in $$props) $$invalidate(5, paused = $$props.paused); if ("paused" in $$props) $$invalidate(5, paused = $$props.paused);
if ("volume" in $$props) $$invalidate(6, volume = $$props.volume); if ("volume" in $$props) $$invalidate(6, volume = $$props.volume);
if ("playbackRate" in $$props) $$invalidate(7, playbackRate = $$props.playbackRate); if ("muted" in $$props) $$invalidate(7, muted = $$props.muted);
if ("seeking" in $$props) $$invalidate(8, seeking = $$props.seeking); if ("playbackRate" in $$props) $$invalidate(8, playbackRate = $$props.playbackRate);
if ("ended" in $$props) $$invalidate(9, ended = $$props.ended); if ("seeking" in $$props) $$invalidate(9, seeking = $$props.seeking);
if ("ended" in $$props) $$invalidate(10, ended = $$props.ended);
0; 0;
}; };
@ -186,6 +196,7 @@ function instance($$self, $$props, $$invalidate) {
duration, duration,
paused, paused,
volume, volume,
muted,
playbackRate, playbackRate,
seeking, seeking,
ended, ended,
@ -213,9 +224,10 @@ class Component extends SvelteComponent {
duration: 4, duration: 4,
paused: 5, paused: 5,
volume: 6, volume: 6,
playbackRate: 7, muted: 7,
seeking: 8, playbackRate: 8,
ended: 9 seeking: 9,
ended: 10
}); });
} }
} }

@ -1,7 +1,27 @@
import { assert } from '../test'; import { assert } from '../test';
import { get } from '../../store'; import { get } from '../../store';
import { spring, tweened } from '../../motion'; import { spring, tweened } from '../../motion';
import { set_framerate, set_now, set_raf, flush } from '../../internal';
let raf;
beforeEach(() => {
set_framerate(1);
raf = {
time: 0,
callback: null,
tick: (now) => {
raf.time = now;
if (raf.callback) raf.callback();
},
};
set_now(() => raf.time);
set_raf((cb) => {
raf.callback = () => {
raf.callback = null;
cb(raf.time);
flush();
};
});
});
describe('motion', () => { describe('motion', () => {
describe('spring', () => { describe('spring', () => {
it('handles initially undefined values', () => { it('handles initially undefined values', () => {
@ -17,13 +37,15 @@ describe('motion', () => {
const size = tweened(); const size = tweened();
size.set(100); size.set(100);
raf.tick(1);
assert.equal(get(size), 100); assert.equal(get(size), 100);
}); });
it('sets immediately when duration is 0', () => { it('sets immediately when duration is 0', () => {
const size = tweened(0); const size = tweened(0);
size.set(100, { duration : 0 }); size.set(100, { duration: 0 });
raf.tick(1);
assert.equal(get(size), 100); assert.equal(get(size), 100);
}); });
}); });

@ -52,10 +52,10 @@
} }
], ],
"context": { "context": {
"start": 17,
"end": 22,
"type": "Identifier", "type": "Identifier",
"name": "thing" "name": "thing",
"start": 17,
"end": 22
}, },
"key": { "key": {
"type": "Identifier", "type": "Identifier",

@ -26,10 +26,10 @@
}, },
"value": null, "value": null,
"error": { "error": {
"start": 47,
"end": 55,
"type": "Identifier", "type": "Identifier",
"name": "theError" "name": "theError",
"start": 49,
"end": 57
}, },
"pending": { "pending": {
"start": 19, "start": 19,

@ -25,16 +25,16 @@
"name": "thePromise" "name": "thePromise"
}, },
"value": { "value": {
"start": 46,
"end": 54,
"type": "Identifier", "type": "Identifier",
"name": "theValue" "name": "theValue",
"start": 48,
"end": 56
}, },
"error": { "error": {
"start": 96,
"end": 104,
"type": "Identifier", "type": "Identifier",
"name": "theError" "name": "theError",
"start": 100,
"end": 108
}, },
"pending": { "pending": {
"start": 19, "start": 19,

@ -1,24 +1,31 @@
{ {
"html": { "html": {
"start": 0, "start": 45,
"end": 73, "end": 118,
"type": "Fragment", "type": "Fragment",
"children": [ "children": [
{ {
"start": 0, "start": 41,
"end": 73, "end": 45,
"type": "Text",
"raw": "\r\n\r\n",
"data": "\r\n\r\n"
},
{
"start": 45,
"end": 118,
"type": "EachBlock", "type": "EachBlock",
"expression": { "expression": {
"type": "Identifier", "type": "Identifier",
"start": 7, "start": 52,
"end": 14, "end": 59,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 5,
"column": 7 "column": 7
}, },
"end": { "end": {
"line": 1, "line": 5,
"column": 14 "column": 14
} }
}, },
@ -26,27 +33,27 @@
}, },
"children": [ "children": [
{ {
"start": 43, "start": 88,
"end": 64, "end": 109,
"type": "Element", "type": "Element",
"name": "p", "name": "p",
"attributes": [], "attributes": [],
"children": [ "children": [
{ {
"start": 46, "start": 91,
"end": 51, "end": 96,
"type": "MustacheTag", "type": "MustacheTag",
"expression": { "expression": {
"type": "Identifier", "type": "Identifier",
"start": 47, "start": 92,
"end": 50, "end": 95,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 6,
"column": 5 "column": 5
}, },
"end": { "end": {
"line": 2, "line": 6,
"column": 8 "column": 8
} }
}, },
@ -54,27 +61,27 @@
} }
}, },
{ {
"start": 51, "start": 96,
"end": 53, "end": 98,
"type": "Text", "type": "Text",
"raw": ": ", "raw": ": ",
"data": ": " "data": ": "
}, },
{ {
"start": 53, "start": 98,
"end": 60, "end": 105,
"type": "MustacheTag", "type": "MustacheTag",
"expression": { "expression": {
"type": "Identifier", "type": "Identifier",
"start": 54, "start": 99,
"end": 59, "end": 104,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 6,
"column": 12 "column": 12
}, },
"end": { "end": {
"line": 2, "line": 6,
"column": 17 "column": 17
} }
}, },
@ -85,31 +92,177 @@
} }
], ],
"context": { "context": {
"start": 18,
"end": 39,
"type": "ArrayPattern", "type": "ArrayPattern",
"start": 63,
"end": 84,
"loc": {
"start": {
"line": 5,
"column": 19
},
"end": {
"line": 5,
"column": 40
}
},
"elements": [ "elements": [
{ {
"start": 19,
"end": 22,
"type": "Identifier", "type": "Identifier",
"start": 64,
"end": 67,
"loc": {
"start": {
"line": 5,
"column": 20
},
"end": {
"line": 5,
"column": 23
}
},
"name": "key" "name": "key"
}, },
{ {
"start": 24,
"end": 29,
"type": "Identifier", "type": "Identifier",
"start": 69,
"end": 74,
"loc": {
"start": {
"line": 5,
"column": 25
},
"end": {
"line": 5,
"column": 30
}
},
"name": "value" "name": "value"
}, },
{ {
"start": 31, "type": "RestElement",
"end": 38, "start": 76,
"type": "RestIdentifier", "end": 83,
"name": "rest" "loc": {
"start": {
"line": 5,
"column": 32
},
"end": {
"line": 5,
"column": 39
}
},
"argument": {
"type": "Identifier",
"start": 79,
"end": 83,
"loc": {
"start": {
"line": 5,
"column": 35
},
"end": {
"line": 5,
"column": 39
}
},
"name": "rest"
}
} }
] ]
} }
} }
] ]
},
"instance": {
"type": "Script",
"start": 0,
"end": 41,
"context": "default",
"content": {
"type": "Program",
"start": 8,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 0
}
},
"body": [
{
"type": "ExportNamedDeclaration",
"start": 11,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 1
},
"end": {
"line": 2,
"column": 20
}
},
"declaration": {
"type": "VariableDeclaration",
"start": 18,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 20
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 22,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 22,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 19
}
},
"name": "animals"
},
"init": null
}
],
"kind": "let"
},
"specifiers": [],
"source": null
}
],
"sourceType": "module"
}
} }
} }

@ -57,10 +57,10 @@
} }
], ],
"context": { "context": {
"start": 18,
"end": 24,
"type": "Identifier", "type": "Identifier",
"name": "animal" "name": "animal",
"start": 18,
"end": 24
}, },
"else": { "else": {
"start": 52, "start": 52,

@ -85,10 +85,10 @@
} }
], ],
"context": { "context": {
"start": 18,
"end": 24,
"type": "Identifier", "type": "Identifier",
"name": "animal" "name": "animal",
"start": 18,
"end": 24
}, },
"index": "i" "index": "i"
} }

@ -57,10 +57,10 @@
} }
], ],
"context": { "context": {
"start": 16,
"end": 20,
"type": "Identifier", "type": "Identifier",
"name": "todo" "name": "todo",
"start": 16,
"end": 20
}, },
"key": { "key": {
"type": "MemberExpression", "type": "MemberExpression",

@ -57,10 +57,10 @@
} }
], ],
"context": { "context": {
"start": 18,
"end": 24,
"type": "Identifier", "type": "Identifier",
"name": "animal" "name": "animal",
"start": 18,
"end": 24
} }
} }
] ]

@ -116,10 +116,10 @@
"raw": "true" "raw": "true"
}, },
"value": { "value": {
"start": 97,
"end": 98,
"type": "Identifier", "type": "Identifier",
"name": "f" "name": "f",
"start": 109,
"end": 110
}, },
"error": null, "error": null,
"pending": { "pending": {
@ -204,10 +204,10 @@
"raw": "true" "raw": "true"
}, },
"value": { "value": {
"start": 137,
"end": 138,
"type": "Identifier", "type": "Identifier",
"name": "f" "name": "f",
"start": 154,
"end": 155
}, },
"error": null, "error": null,
"pending": { "pending": {

@ -57,10 +57,10 @@
} }
], ],
"context": { "context": {
"start": 17,
"end": 19,
"type": "Identifier", "type": "Identifier",
"name": "𐊧" "name": "𐊧",
"start": 17,
"end": 19
} }
} }
] ]

@ -10,8 +10,8 @@ import {
cleanRequireCache, cleanRequireCache,
shouldUpdateExpected, shouldUpdateExpected,
mkdirp, mkdirp,
} from '../helpers.ts'; } from '../helpers';
import { glob } from '../tiny-glob.ts'; import { glob } from '../tiny-glob';
import { assert } from '../test'; import { assert } from '../test';
function tryToReadFile(file) { function tryToReadFile(file) {

Loading…
Cancel
Save