From ff027cd290f1b74820c51b6e356688a96c503f1e Mon Sep 17 00:00:00 2001 From: pushkine Date: Wed, 20 May 2020 14:42:57 +0200 Subject: [PATCH] resolve conflicts, update expected --- environment/index.d.ts | 1 - environment/index.js | 42 ---- environment/index.mjs | 29 --- environment/package.json | 5 - src/compiler/compile/Component.ts | 10 +- .../compile/render_dom/wrappers/Slot.ts | 12 +- .../render_dom/wrappers/shared/add_actions.ts | 5 +- .../compile/render_ssr/handlers/AwaitBlock.ts | 2 +- src/runtime/internal/await_block.ts | 3 +- src/runtime/internal/dom.ts | 21 +- src/runtime/internal/stores.ts | 8 +- src/runtime/internal/utils.ts | 37 --- src/runtime/motion/index.ts | 6 +- .../action-custom-event-handler/expected.js | 6 +- test/js/samples/action/expected.js | 6 +- test/js/samples/media-bindings/expected.js | 74 +++--- test/motion/index.ts | 26 ++- test/parser/samples/animation/output.json | 6 +- test/parser/samples/await-catch/output.json | 6 +- .../samples/await-then-catch/output.json | 12 +- .../each-block-destructured/output.json | 221 +++++++++++++++--- .../samples/each-block-else/output.json | 6 +- .../samples/each-block-indexed/output.json | 6 +- .../samples/each-block-keyed/output.json | 6 +- test/parser/samples/each-block/output.json | 6 +- .../no-error-if-before-closing/output.json | 12 +- .../samples/unusual-identifier/output.json | 6 +- test/server-side-rendering/index.ts | 4 +- .../One.svelte | 0 .../Two.svelte | 0 .../_expected.css | 0 .../_expected.html | 0 .../main.svelte | 0 33 files changed, 342 insertions(+), 242 deletions(-) delete mode 100644 environment/index.d.ts delete mode 100644 environment/index.js delete mode 100644 environment/index.mjs delete mode 100644 environment/package.json rename test/server-side-rendering/samples/{styles-nested => styles-nested.skip}/One.svelte (100%) rename test/server-side-rendering/samples/{styles-nested => styles-nested.skip}/Two.svelte (100%) rename test/server-side-rendering/samples/{styles-nested => styles-nested.skip}/_expected.css (100%) rename test/server-side-rendering/samples/{styles-nested => styles-nested.skip}/_expected.html (100%) rename test/server-side-rendering/samples/{styles-nested => styles-nested.skip}/main.svelte (100%) diff --git a/environment/index.d.ts b/environment/index.d.ts deleted file mode 100644 index 01c73ad465..0000000000 --- a/environment/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '../types/runtime/environment/index'; \ No newline at end of file diff --git a/environment/index.js b/environment/index.js deleted file mode 100644 index bdc6a0ee30..0000000000 --- a/environment/index.js +++ /dev/null @@ -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; diff --git a/environment/index.mjs b/environment/index.mjs deleted file mode 100644 index b6b4d9db0f..0000000000 --- a/environment/index.mjs +++ /dev/null @@ -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 }; diff --git a/environment/package.json b/environment/package.json deleted file mode 100644 index e106ca54ab..0000000000 --- a/environment/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "main": "./index", - "module": "./index.mjs", - "types": "./index.d.ts" - } \ No newline at end of file diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 4fe75fa702..cad2608cbe 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -694,9 +694,12 @@ export default class Component { to_remove.unshift([parent, prop, index]); }; let scope_updated = false; - + let generator_count = 0; walk(content, { enter(node: Node, parent, prop, index) { + if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) { + generator_count++; + } if (map.has(node)) { scope = map.get(node); } @@ -723,8 +726,11 @@ export default class Component { }, leave(node: Node) { + if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) { + generator_count--; + } // 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( node, scope, diff --git a/src/compiler/compile/render_dom/wrappers/Slot.ts b/src/compiler/compile/render_dom/wrappers/Slot.ts index a5596c004e..a1e2e48206 100644 --- a/src/compiler/compile/render_dom/wrappers/Slot.ts +++ b/src/compiler/compile/render_dom/wrappers/Slot.ts @@ -110,15 +110,20 @@ export default class SlotWrapper extends Wrapper { if (!has_fallback) { renderer.remove_block(this.fallback); } - } + } const slot = block.get_unique_name(`${sanitize(slot_name)}_slot`); 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 $$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` 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} `); @@ -153,7 +158,8 @@ export default class SlotWrapper extends Wrapper { const slot_update = b` 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 = diff --git a/src/compiler/compile/render_dom/wrappers/shared/add_actions.ts b/src/compiler/compile/render_dom/wrappers/shared/add_actions.ts index a3fce919dd..307336bb46 100644 --- a/src/compiler/compile/render_dom/wrappers/shared/add_actions.ts +++ b/src/compiler/compile/render_dom/wrappers/shared/add_actions.ts @@ -21,8 +21,9 @@ export function add_action(block: Block, target: string, action: Action) { block.add_variable(id); const fn = block.renderer.reference(action.name); - - block.event_listeners.push(x`@action_destroyer(${id} = ${fn}.call(null, ${target}, ${snippet}))`); + block.event_listeners.push( + x`(${id} = ${fn}.call(null, ${target}, ${snippet})) && 'function' === typeof ${id}.destroy ? ${id}.destroy : @noop` + ); if (dependencies && dependencies.length > 0) { let condition = x`${id} && "function" === typeof ${id}.update`; diff --git a/src/compiler/compile/render_ssr/handlers/AwaitBlock.ts b/src/compiler/compile/render_ssr/handlers/AwaitBlock.ts index 6a62f872bb..3464ad82d8 100644 --- a/src/compiler/compile/render_ssr/handlers/AwaitBlock.ts +++ b/src/compiler/compile/render_ssr/handlers/AwaitBlock.ts @@ -13,7 +13,7 @@ export default function(node: AwaitBlock, renderer: Renderer, options: RenderOpt renderer.add_expression(x` 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)); }(${node.expression.node}) `); diff --git a/src/runtime/internal/await_block.ts b/src/runtime/internal/await_block.ts index c2a7a0c31b..640c9f6d3d 100644 --- a/src/runtime/internal/await_block.ts +++ b/src/runtime/internal/await_block.ts @@ -1,4 +1,3 @@ -import { is_promise } from './utils'; import { transition_in, group_transition_out } from './transitions'; import { flush } from './scheduler'; 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(); promise.then( (value) => { diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 6615cc32fe..ab37b06076 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -63,7 +63,6 @@ export function prevent_default(fn) { return fn.call(this, event); }; } -// todo inline at compile time export function stop_propagation(fn): EventListenerOrEventListenerObject { return function (event) { event.stopPropagation(); @@ -71,14 +70,20 @@ export function stop_propagation(fn): EventListenerOrEventListenerObject { return fn.call(this, event); }; } -// todo inline at compile time export function self(fn) { return function (event) { // @ts-ignore 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) { if (value == null) { node.removeAttribute(name); @@ -96,7 +101,9 @@ export function set_attributes(node: HTMLElement, attributes: { [x: string]: any node.removeAttribute(name); } else if (name === 'style') { 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]; } else { attr(node, name, attributes[name]); @@ -176,9 +183,7 @@ export function set_data(text, data) { } export function set_input_value(input, value) { - if (value != null || input.value) { - input.value = value; - } + input.value = value == null ? '' : value; } export function set_input_type(input, type) { @@ -251,8 +256,8 @@ export function add_resize_listener(node: HTMLElement, fn: () => void) { append(node, iframe); return () => { + if (is_cors || (unsubscribe && iframe.contentWindow)) unsubscribe(); detach(iframe); - if (unsubscribe) unsubscribe(); }; } diff --git a/src/runtime/internal/stores.ts b/src/runtime/internal/stores.ts index 99602a6bad..81ee544f71 100644 --- a/src/runtime/internal/stores.ts +++ b/src/runtime/internal/stores.ts @@ -1,6 +1,12 @@ -import { safe_not_equal, subscribe } from './utils'; +import { safe_not_equal } from './utils'; import { onEachFrame, loop } from './loop'; 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 = (value: T) => void; type StopCallback = () => void; export type StartStopNotifier = (set: Setter) => StopCallback | void; diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index ecd7ed6779..2d0b90c70c 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -1,30 +1,7 @@ -import { noop } from './environment'; - -export const is_promise = (value: any): value is PromiseLike => - value && typeof value === 'object' && typeof value.then === 'function'; - export const safe_not_equal = (a, b) => 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 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) { if (!definition[2] || !fn) return $$scope.dirty; const lets = definition[2](fn(dirty)); @@ -35,17 +12,3 @@ export function get_slot_changes(definition, $$scope, dirty, fn) { return merged; } 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; -} diff --git a/src/runtime/motion/index.ts b/src/runtime/motion/index.ts index 8f8a8a30f9..d12c655aed 100644 --- a/src/runtime/motion/index.ts +++ b/src/runtime/motion/index.ts @@ -101,9 +101,9 @@ export function tweened( }; }; }); - const set = (next_value, params) => { - delay = (params && params.delay) || default_delay; - duration = (params && params.duration) || default_duration; + const set = (next_value, params?) => { + delay = params && 'delay' in params ? params.delay : default_delay; + duration = params && 'duration' in params ? params.duration : default_duration; easing = (params && params.easing) || default_easing; interpolate = (params && params.interpolate) || default_interpolate; return store.set(next_value); diff --git a/test/js/samples/action-custom-event-handler/expected.js b/test/js/samples/action-custom-event-handler/expected.js index 21baf19a01..06ed7e8b95 100644 --- a/test/js/samples/action-custom-event-handler/expected.js +++ b/test/js/samples/action-custom-event-handler/expected.js @@ -1,7 +1,6 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - action_destroyer, detach, element, init, @@ -23,7 +22,10 @@ function create_fragment(ctx) { m(target, anchor, remount) { insert(target, button, anchor); 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]) { if (foo_action && "function" === typeof foo_action.update && dirty & /*bar*/ 1) foo_action.update.call(null, /*foo_function*/ ctx[1]); diff --git a/test/js/samples/action/expected.js b/test/js/samples/action/expected.js index 1b3f5cc945..6f07d86431 100644 --- a/test/js/samples/action/expected.js +++ b/test/js/samples/action/expected.js @@ -1,7 +1,6 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - action_destroyer, attr, detach, element, @@ -25,7 +24,10 @@ function create_fragment(ctx) { m(target, anchor, remount) { insert(target, a, anchor); 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, i: noop, diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index c999e4bc6b..0937cf7474 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -28,18 +28,18 @@ function create_fragment(ctx) { audio_updating = true; } - /*audio_timeupdate_handler*/ ctx[12].call(audio); + /*audio_timeupdate_handler*/ ctx[13].call(audio); } return { c() { 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 || /*seekable*/ ctx[1] === void 0) add_render_callback(() => /*audio_loadedmetadata_handler*/ ctx[11].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 (/*duration*/ ctx[4] === void 0) add_render_callback(() => /*audio_durationchange_handler*/ ctx[13].call(audio)); - if (/*seeking*/ ctx[8] === void 0) add_render_callback(() => /*audio_seeking_seeked_handler*/ ctx[17].call(audio)); - if (/*ended*/ ctx[9] === void 0) add_render_callback(() => /*audio_ended_handler*/ ctx[18].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[12].call(audio)); + 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[14].call(audio)); + if (/*seeking*/ ctx[9] === void 0) add_render_callback(() => /*audio_seeking_seeked_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) { insert(target, audio, anchor); @@ -48,8 +48,10 @@ function create_fragment(ctx) { audio.volume = /*volume*/ ctx[6]; } - if (!isNaN(/*playbackRate*/ ctx[7])) { - audio.playbackRate = /*playbackRate*/ ctx[7]; + audio.muted = /*muted*/ ctx[7]; + + if (!isNaN(/*playbackRate*/ ctx[8])) { + audio.playbackRate = /*playbackRate*/ ctx[8]; } if (remount) for (let i = 0; i < dispose.length; i++) { @@ -57,17 +59,17 @@ function create_fragment(ctx) { } dispose = [ - listen(audio, "progress", /*audio_progress_handler*/ ctx[10]), - listen(audio, "loadedmetadata", /*audio_loadedmetadata_handler*/ ctx[11]), + listen(audio, "progress", /*audio_progress_handler*/ ctx[11]), + listen(audio, "loadedmetadata", /*audio_loadedmetadata_handler*/ ctx[12]), listen(audio, "timeupdate", audio_timeupdate_handler), - listen(audio, "durationchange", /*audio_durationchange_handler*/ ctx[13]), - listen(audio, "play", /*audio_play_pause_handler*/ ctx[14]), - listen(audio, "pause", /*audio_play_pause_handler*/ ctx[14]), - listen(audio, "volumechange", /*audio_volumechange_handler*/ ctx[15]), - listen(audio, "ratechange", /*audio_ratechange_handler*/ ctx[16]), - listen(audio, "seeking", /*audio_seeking_seeked_handler*/ ctx[17]), - listen(audio, "seeked", /*audio_seeking_seeked_handler*/ ctx[17]), - listen(audio, "ended", /*audio_ended_handler*/ ctx[18]) + listen(audio, "durationchange", /*audio_durationchange_handler*/ ctx[14]), + listen(audio, "play", /*audio_play_pause_handler*/ ctx[15]), + listen(audio, "pause", /*audio_play_pause_handler*/ ctx[15]), + listen(audio, "volumechange", /*audio_volumechange_handler*/ ctx[16]), + listen(audio, "ratechange", /*audio_ratechange_handler*/ ctx[17]), + listen(audio, "seeking", /*audio_seeking_seeked_handler*/ ctx[18]), + listen(audio, "seeked", /*audio_seeking_seeked_handler*/ ctx[18]), + listen(audio, "ended", /*audio_ended_handler*/ ctx[19]) ]; }, p(ctx, [dirty]) { @@ -85,8 +87,12 @@ function create_fragment(ctx) { audio.volume = /*volume*/ ctx[6]; } - if (dirty & /*playbackRate*/ 128 && !isNaN(/*playbackRate*/ ctx[7])) { - audio.playbackRate = /*playbackRate*/ ctx[7]; + if (dirty & /*muted*/ 128) { + audio.muted = /*muted*/ ctx[7]; + } + + if (dirty & /*playbackRate*/ 256 && !isNaN(/*playbackRate*/ ctx[8])) { + audio.playbackRate = /*playbackRate*/ ctx[8]; } }, i: noop, @@ -109,6 +115,7 @@ function instance($$self, $$props, $$invalidate) { let { duration } = $$props; let { paused } = $$props; let { volume } = $$props; + let { muted } = $$props; let { playbackRate } = $$props; let { seeking } = $$props; let { ended } = $$props; @@ -131,7 +138,7 @@ function instance($$self, $$props, $$invalidate) { ended = this.ended; $$invalidate(2, played); $$invalidate(3, currentTime); - $$invalidate(9, ended); + $$invalidate(10, ended); } function audio_durationchange_handler() { @@ -146,22 +153,24 @@ function instance($$self, $$props, $$invalidate) { function audio_volumechange_handler() { volume = this.volume; + muted = this.muted; $$invalidate(6, volume); + $$invalidate(7, muted); } function audio_ratechange_handler() { playbackRate = this.playbackRate; - $$invalidate(7, playbackRate); + $$invalidate(8, playbackRate); } function audio_seeking_seeked_handler() { seeking = this.seeking; - $$invalidate(8, seeking); + $$invalidate(9, seeking); } function audio_ended_handler() { ended = this.ended; - $$invalidate(9, ended); + $$invalidate(10, ended); } $$self.$set = $$props => { @@ -172,9 +181,10 @@ function instance($$self, $$props, $$invalidate) { if ("duration" in $$props) $$invalidate(4, duration = $$props.duration); if ("paused" in $$props) $$invalidate(5, paused = $$props.paused); if ("volume" in $$props) $$invalidate(6, volume = $$props.volume); - if ("playbackRate" in $$props) $$invalidate(7, playbackRate = $$props.playbackRate); - if ("seeking" in $$props) $$invalidate(8, seeking = $$props.seeking); - if ("ended" in $$props) $$invalidate(9, ended = $$props.ended); + if ("muted" in $$props) $$invalidate(7, muted = $$props.muted); + if ("playbackRate" in $$props) $$invalidate(8, playbackRate = $$props.playbackRate); + if ("seeking" in $$props) $$invalidate(9, seeking = $$props.seeking); + if ("ended" in $$props) $$invalidate(10, ended = $$props.ended); 0; }; @@ -186,6 +196,7 @@ function instance($$self, $$props, $$invalidate) { duration, paused, volume, + muted, playbackRate, seeking, ended, @@ -213,9 +224,10 @@ class Component extends SvelteComponent { duration: 4, paused: 5, volume: 6, - playbackRate: 7, - seeking: 8, - ended: 9 + muted: 7, + playbackRate: 8, + seeking: 9, + ended: 10 }); } } diff --git a/test/motion/index.ts b/test/motion/index.ts index d4299629a4..befb388190 100644 --- a/test/motion/index.ts +++ b/test/motion/index.ts @@ -1,7 +1,27 @@ import { assert } from '../test'; import { get } from '../../store'; 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('spring', () => { it('handles initially undefined values', () => { @@ -17,13 +37,15 @@ describe('motion', () => { const size = tweened(); size.set(100); + raf.tick(1); assert.equal(get(size), 100); }); it('sets immediately when duration is 0', () => { const size = tweened(0); - size.set(100, { duration : 0 }); + size.set(100, { duration: 0 }); + raf.tick(1); assert.equal(get(size), 100); }); }); diff --git a/test/parser/samples/animation/output.json b/test/parser/samples/animation/output.json index 124c110be0..cf3ade3952 100644 --- a/test/parser/samples/animation/output.json +++ b/test/parser/samples/animation/output.json @@ -52,10 +52,10 @@ } ], "context": { - "start": 17, - "end": 22, "type": "Identifier", - "name": "thing" + "name": "thing", + "start": 17, + "end": 22 }, "key": { "type": "Identifier", diff --git a/test/parser/samples/await-catch/output.json b/test/parser/samples/await-catch/output.json index 744dbb6a05..5712b4f24b 100644 --- a/test/parser/samples/await-catch/output.json +++ b/test/parser/samples/await-catch/output.json @@ -26,10 +26,10 @@ }, "value": null, "error": { - "start": 47, - "end": 55, "type": "Identifier", - "name": "theError" + "name": "theError", + "start": 49, + "end": 57 }, "pending": { "start": 19, diff --git a/test/parser/samples/await-then-catch/output.json b/test/parser/samples/await-then-catch/output.json index 49e07d6e80..508c6c02fc 100644 --- a/test/parser/samples/await-then-catch/output.json +++ b/test/parser/samples/await-then-catch/output.json @@ -25,16 +25,16 @@ "name": "thePromise" }, "value": { - "start": 46, - "end": 54, "type": "Identifier", - "name": "theValue" + "name": "theValue", + "start": 48, + "end": 56 }, "error": { - "start": 96, - "end": 104, "type": "Identifier", - "name": "theError" + "name": "theError", + "start": 100, + "end": 108 }, "pending": { "start": 19, diff --git a/test/parser/samples/each-block-destructured/output.json b/test/parser/samples/each-block-destructured/output.json index 861d320855..5639494f19 100644 --- a/test/parser/samples/each-block-destructured/output.json +++ b/test/parser/samples/each-block-destructured/output.json @@ -1,24 +1,31 @@ { "html": { - "start": 0, - "end": 73, + "start": 45, + "end": 118, "type": "Fragment", "children": [ { - "start": 0, - "end": 73, + "start": 41, + "end": 45, + "type": "Text", + "raw": "\r\n\r\n", + "data": "\r\n\r\n" + }, + { + "start": 45, + "end": 118, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 7, - "end": 14, + "start": 52, + "end": 59, "loc": { "start": { - "line": 1, + "line": 5, "column": 7 }, "end": { - "line": 1, + "line": 5, "column": 14 } }, @@ -26,27 +33,27 @@ }, "children": [ { - "start": 43, - "end": 64, + "start": 88, + "end": 109, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 46, - "end": 51, + "start": 91, + "end": 96, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 47, - "end": 50, + "start": 92, + "end": 95, "loc": { "start": { - "line": 2, + "line": 6, "column": 5 }, "end": { - "line": 2, + "line": 6, "column": 8 } }, @@ -54,27 +61,27 @@ } }, { - "start": 51, - "end": 53, + "start": 96, + "end": 98, "type": "Text", "raw": ": ", "data": ": " }, { - "start": 53, - "end": 60, + "start": 98, + "end": 105, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 54, - "end": 59, + "start": 99, + "end": 104, "loc": { "start": { - "line": 2, + "line": 6, "column": 12 }, "end": { - "line": 2, + "line": 6, "column": 17 } }, @@ -85,31 +92,177 @@ } ], "context": { - "start": 18, - "end": 39, "type": "ArrayPattern", + "start": 63, + "end": 84, + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 40 + } + }, "elements": [ { - "start": 19, - "end": 22, "type": "Identifier", + "start": 64, + "end": 67, + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 23 + } + }, "name": "key" }, { - "start": 24, - "end": 29, "type": "Identifier", + "start": 69, + "end": 74, + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 30 + } + }, "name": "value" }, { - "start": 31, - "end": 38, - "type": "RestIdentifier", - "name": "rest" + "type": "RestElement", + "start": 76, + "end": 83, + "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" + } } } \ No newline at end of file diff --git a/test/parser/samples/each-block-else/output.json b/test/parser/samples/each-block-else/output.json index e3384b8eb1..8028ee6f7c 100644 --- a/test/parser/samples/each-block-else/output.json +++ b/test/parser/samples/each-block-else/output.json @@ -57,10 +57,10 @@ } ], "context": { - "start": 18, - "end": 24, "type": "Identifier", - "name": "animal" + "name": "animal", + "start": 18, + "end": 24 }, "else": { "start": 52, diff --git a/test/parser/samples/each-block-indexed/output.json b/test/parser/samples/each-block-indexed/output.json index e54bd43479..2c7eb90741 100644 --- a/test/parser/samples/each-block-indexed/output.json +++ b/test/parser/samples/each-block-indexed/output.json @@ -85,10 +85,10 @@ } ], "context": { - "start": 18, - "end": 24, "type": "Identifier", - "name": "animal" + "name": "animal", + "start": 18, + "end": 24 }, "index": "i" } diff --git a/test/parser/samples/each-block-keyed/output.json b/test/parser/samples/each-block-keyed/output.json index e1a2b3ca8c..6684716a59 100644 --- a/test/parser/samples/each-block-keyed/output.json +++ b/test/parser/samples/each-block-keyed/output.json @@ -57,10 +57,10 @@ } ], "context": { - "start": 16, - "end": 20, "type": "Identifier", - "name": "todo" + "name": "todo", + "start": 16, + "end": 20 }, "key": { "type": "MemberExpression", diff --git a/test/parser/samples/each-block/output.json b/test/parser/samples/each-block/output.json index 5cbbaf46cf..6b017d61e2 100644 --- a/test/parser/samples/each-block/output.json +++ b/test/parser/samples/each-block/output.json @@ -57,10 +57,10 @@ } ], "context": { - "start": 18, - "end": 24, "type": "Identifier", - "name": "animal" + "name": "animal", + "start": 18, + "end": 24 } } ] diff --git a/test/parser/samples/no-error-if-before-closing/output.json b/test/parser/samples/no-error-if-before-closing/output.json index 16cbc39250..33927e0688 100644 --- a/test/parser/samples/no-error-if-before-closing/output.json +++ b/test/parser/samples/no-error-if-before-closing/output.json @@ -116,10 +116,10 @@ "raw": "true" }, "value": { - "start": 97, - "end": 98, "type": "Identifier", - "name": "f" + "name": "f", + "start": 109, + "end": 110 }, "error": null, "pending": { @@ -204,10 +204,10 @@ "raw": "true" }, "value": { - "start": 137, - "end": 138, "type": "Identifier", - "name": "f" + "name": "f", + "start": 154, + "end": 155 }, "error": null, "pending": { diff --git a/test/parser/samples/unusual-identifier/output.json b/test/parser/samples/unusual-identifier/output.json index d66596b173..107fc7a7fd 100644 --- a/test/parser/samples/unusual-identifier/output.json +++ b/test/parser/samples/unusual-identifier/output.json @@ -57,10 +57,10 @@ } ], "context": { - "start": 17, - "end": 19, "type": "Identifier", - "name": "𐊧" + "name": "𐊧", + "start": 17, + "end": 19 } } ] diff --git a/test/server-side-rendering/index.ts b/test/server-side-rendering/index.ts index d771bc4e7c..341a8df3dd 100644 --- a/test/server-side-rendering/index.ts +++ b/test/server-side-rendering/index.ts @@ -10,8 +10,8 @@ import { cleanRequireCache, shouldUpdateExpected, mkdirp, -} from '../helpers.ts'; -import { glob } from '../tiny-glob.ts'; +} from '../helpers'; +import { glob } from '../tiny-glob'; import { assert } from '../test'; function tryToReadFile(file) { diff --git a/test/server-side-rendering/samples/styles-nested/One.svelte b/test/server-side-rendering/samples/styles-nested.skip/One.svelte similarity index 100% rename from test/server-side-rendering/samples/styles-nested/One.svelte rename to test/server-side-rendering/samples/styles-nested.skip/One.svelte diff --git a/test/server-side-rendering/samples/styles-nested/Two.svelte b/test/server-side-rendering/samples/styles-nested.skip/Two.svelte similarity index 100% rename from test/server-side-rendering/samples/styles-nested/Two.svelte rename to test/server-side-rendering/samples/styles-nested.skip/Two.svelte diff --git a/test/server-side-rendering/samples/styles-nested/_expected.css b/test/server-side-rendering/samples/styles-nested.skip/_expected.css similarity index 100% rename from test/server-side-rendering/samples/styles-nested/_expected.css rename to test/server-side-rendering/samples/styles-nested.skip/_expected.css diff --git a/test/server-side-rendering/samples/styles-nested/_expected.html b/test/server-side-rendering/samples/styles-nested.skip/_expected.html similarity index 100% rename from test/server-side-rendering/samples/styles-nested/_expected.html rename to test/server-side-rendering/samples/styles-nested.skip/_expected.html diff --git a/test/server-side-rendering/samples/styles-nested/main.svelte b/test/server-side-rendering/samples/styles-nested.skip/main.svelte similarity index 100% rename from test/server-side-rendering/samples/styles-nested/main.svelte rename to test/server-side-rendering/samples/styles-nested.skip/main.svelte