From ab0ee9f46956b197f6037146833db6403e4cca7d Mon Sep 17 00:00:00 2001 From: divy-work Date: Thu, 29 Oct 2020 13:19:31 +0530 Subject: [PATCH] port runtime --- .eslintignore | 17 --------------- .eslintrc.js | 14 ------------- .mocharc.js | 14 ------------- src/runtime/ambient.ts | 2 +- src/runtime/animate/index.ts | 4 ++-- src/runtime/easing/index.ts | 2 +- src/runtime/index.ts | 4 ++-- src/runtime/internal/Component.ts | 10 ++++----- src/runtime/internal/animations.ts | 10 ++++----- src/runtime/internal/await_block.ts | 8 +++---- src/runtime/internal/dev.ts | 4 ++-- src/runtime/internal/dom.ts | 2 +- src/runtime/internal/environment.ts | 2 +- src/runtime/internal/index.ts | 30 +++++++++++++-------------- src/runtime/internal/keyed_each.ts | 2 +- src/runtime/internal/lifecycle.ts | 2 +- src/runtime/internal/loop.ts | 2 +- src/runtime/internal/scheduler.ts | 4 ++-- src/runtime/internal/ssr.ts | 6 +++--- src/runtime/internal/style_manager.ts | 4 ++-- src/runtime/internal/transitions.ts | 14 ++++++------- src/runtime/internal/utils.ts | 2 +- src/runtime/motion/index.ts | 4 ++-- src/runtime/motion/spring.ts | 4 ++-- src/runtime/motion/tweened.ts | 8 +++---- src/runtime/store/index.ts | 2 +- src/runtime/transition/index.ts | 4 ++-- 27 files changed, 68 insertions(+), 113 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.js delete mode 100644 .mocharc.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index d123c10530..0000000000 --- a/.eslintignore +++ /dev/null @@ -1,17 +0,0 @@ -**/_actual.js -**/expected.js -_output -test/*/samples/*/output.js - -# automatically generated -internal_exports.ts - -# output files -animate/*.js -esing/*.js -internal/*.js -motion/*.js -store/*.js -transition/*.js -index.js -compiler.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index a093de610b..0000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - root: true, - extends: '@sveltejs', - settings: { - 'import/core-modules': [ - 'svelte', - 'svelte/internal', - 'svelte/store', - 'svelte/easing', - 'estree' - ], - 'svelte3/compiler': require('./compiler') - } -}; diff --git a/.mocharc.js b/.mocharc.js deleted file mode 100644 index e55f26099e..0000000000 --- a/.mocharc.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - file: [ - 'test/test.ts' - ], - require: [ - 'sucrase/register' - ] -}; - -// add coverage options when running 'npx c8 mocha' -if (process.env.NODE_V8_COVERAGE) { - module.exports.fullTrace = true; - module.exports.require.push('source-map-support/register'); -} diff --git a/src/runtime/ambient.ts b/src/runtime/ambient.ts index 09cd9b72f2..b585cbdc39 100644 --- a/src/runtime/ambient.ts +++ b/src/runtime/ambient.ts @@ -1,3 +1,3 @@ declare module '*.svelte' { - export { SvelteComponentDev as default } from 'svelte/internal'; + export { SvelteComponentDev as default } from './internal/index.ts'; } diff --git a/src/runtime/animate/index.ts b/src/runtime/animate/index.ts index 82ec0d5a5f..ef66d6bd06 100644 --- a/src/runtime/animate/index.ts +++ b/src/runtime/animate/index.ts @@ -1,5 +1,5 @@ -import { cubicOut } from 'svelte/easing'; -import { is_function } from 'svelte/internal'; +import { cubicOut } from '../easing/index.ts'; +import { is_function } from '../internal/index.ts'; // todo: same as Transition, should it be shared? export interface AnimationConfig { diff --git a/src/runtime/easing/index.ts b/src/runtime/easing/index.ts index c23019b320..c5412976a2 100644 --- a/src/runtime/easing/index.ts +++ b/src/runtime/easing/index.ts @@ -3,7 +3,7 @@ Adapted from https://github.com/mattdesl Distributed under MIT License https://github.com/mattdesl/eases/blob/master/LICENSE.md */ -export { identity as linear } from 'svelte/internal'; +export { identity as linear } from '../internal/index.ts'; export function backInOut(t: number) { const s = 1.70158 * 1.525; diff --git a/src/runtime/index.ts b/src/runtime/index.ts index e6c0c916f2..0d7490ebe2 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -1,4 +1,4 @@ -import './ambient'; +import './ambient.ts'; export { onMount, @@ -10,4 +10,4 @@ export { tick, createEventDispatcher, SvelteComponentDev as SvelteComponent -} from 'svelte/internal'; +} from './internal/index.ts'; diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 459a78031a..263974b212 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -1,8 +1,8 @@ -import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler'; -import { current_component, set_current_component } from './lifecycle'; -import { blank_object, is_empty, is_function, run, run_all, noop } from './utils'; -import { children, detach } from './dom'; -import { transition_in } from './transitions'; +import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler.ts'; +import { current_component, set_current_component } from './lifecycle.ts'; +import { blank_object, is_empty, is_function, run, run_all, noop } from './utils.ts'; +import { children, detach } from './dom.ts'; +import { transition_in } from './transitions.ts'; interface Fragment { key: string|null; diff --git a/src/runtime/internal/animations.ts b/src/runtime/internal/animations.ts index 6dc6a446f6..f95e1965ce 100644 --- a/src/runtime/internal/animations.ts +++ b/src/runtime/internal/animations.ts @@ -1,8 +1,8 @@ -import { identity as linear, noop } from './utils'; -import { now } from './environment'; -import { loop } from './loop'; -import { create_rule, delete_rule } from './style_manager'; -import { AnimationConfig } from '../animate'; +import { identity as linear, noop } from './utils.ts'; +import { now } from './environment.ts'; +import { loop } from './loop.ts'; +import { create_rule, delete_rule } from './style_manager.ts'; +import { AnimationConfig } from '../animate/index.ts'; //todo: documentation says it is DOMRect, but in IE it would be ClientRect diff --git a/src/runtime/internal/await_block.ts b/src/runtime/internal/await_block.ts index 4b7ca6fd21..0746d736cc 100644 --- a/src/runtime/internal/await_block.ts +++ b/src/runtime/internal/await_block.ts @@ -1,7 +1,7 @@ -import { is_promise } from './utils'; -import { check_outros, group_outros, transition_in, transition_out } from './transitions'; -import { flush } from './scheduler'; -import { get_current_component, set_current_component } from './lifecycle'; +import { is_promise } from './utils.ts'; +import { check_outros, group_outros, transition_in, transition_out } from './transitions.ts'; +import { flush } from './scheduler.ts'; +import { get_current_component, set_current_component } from './lifecycle.ts'; export function handle_promise(promise, info) { const token = info.token = {}; diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index 708b393601..015545951d 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -1,5 +1,5 @@ -import { custom_event, append, insert, detach, listen, attr } from './dom'; -import { SvelteComponent } from './Component'; +import { custom_event, append, insert, detach, listen, attr } from './dom.ts'; +import { SvelteComponent } from './Component.ts'; export function dispatch_dev(type: string, detail?: T) { document.dispatchEvent(custom_event(type, { version: '__VERSION__', ...detail })); diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 5380443fbc..62a72e36ed 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,4 +1,4 @@ -import { has_prop } from './utils'; +import { has_prop } from './utils.ts'; export function append(target: Node, node: Node) { target.appendChild(node); diff --git a/src/runtime/internal/environment.ts b/src/runtime/internal/environment.ts index 7123399180..4411ff29aa 100644 --- a/src/runtime/internal/environment.ts +++ b/src/runtime/internal/environment.ts @@ -1,4 +1,4 @@ -import { noop } from './utils'; +import { noop } from './utils.ts'; export const is_client = typeof window !== 'undefined'; diff --git a/src/runtime/internal/index.ts b/src/runtime/internal/index.ts index e1dd2a1fcf..292838768a 100644 --- a/src/runtime/internal/index.ts +++ b/src/runtime/internal/index.ts @@ -1,15 +1,15 @@ -export * from './animations'; -export * from './await_block'; -export * from './dom'; -export * from './environment'; -export * from './globals'; -export * from './keyed_each'; -export * from './lifecycle'; -export * from './loop'; -export * from './scheduler'; -export * from './spread'; -export * from './ssr'; -export * from './transitions'; -export * from './utils'; -export * from './Component'; -export * from './dev'; +export * from './animations.ts'; +export * from './await_block.ts'; +export * from './dom.ts'; +export * from './environment.ts'; +export * from './globals.ts'; +export * from './keyed_each.ts'; +export * from './lifecycle.ts'; +export * from './loop.ts'; +export * from './scheduler.ts'; +export * from './spread.ts'; +export * from './ssr.ts'; +export * from './transitions.ts'; +export * from './utils.ts'; +export * from './Component.ts'; +export * from './dev.ts'; diff --git a/src/runtime/internal/keyed_each.ts b/src/runtime/internal/keyed_each.ts index 6e333da1a4..41a7adbcaa 100644 --- a/src/runtime/internal/keyed_each.ts +++ b/src/runtime/internal/keyed_each.ts @@ -1,4 +1,4 @@ -import { transition_in, transition_out } from './transitions'; +import { transition_in, transition_out } from './transitions.ts'; export function destroy_block(block, lookup) { block.d(1); diff --git a/src/runtime/internal/lifecycle.ts b/src/runtime/internal/lifecycle.ts index 4a7616bdea..c9f0c57341 100644 --- a/src/runtime/internal/lifecycle.ts +++ b/src/runtime/internal/lifecycle.ts @@ -1,4 +1,4 @@ -import { custom_event } from './dom'; +import { custom_event } from './dom.ts'; export let current_component; diff --git a/src/runtime/internal/loop.ts b/src/runtime/internal/loop.ts index 33e519732f..ffc5f1aa39 100644 --- a/src/runtime/internal/loop.ts +++ b/src/runtime/internal/loop.ts @@ -1,4 +1,4 @@ -import { raf } from './environment'; +import { raf } from './environment.ts'; export interface Task { abort(): void; promise: Promise } diff --git a/src/runtime/internal/scheduler.ts b/src/runtime/internal/scheduler.ts index 568739e4f8..e7d9d0aab3 100644 --- a/src/runtime/internal/scheduler.ts +++ b/src/runtime/internal/scheduler.ts @@ -1,5 +1,5 @@ -import { run_all } from './utils'; -import { set_current_component } from './lifecycle'; +import { run_all } from './utils.ts'; +import { set_current_component } from './lifecycle.ts'; export const dirty_components = []; export const intros = { enabled: false }; diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts index 2d843abb2f..d88d59d332 100644 --- a/src/runtime/internal/ssr.ts +++ b/src/runtime/internal/ssr.ts @@ -1,6 +1,6 @@ -import { set_current_component, current_component } from './lifecycle'; -import { run_all, blank_object } from './utils'; -import { boolean_attributes } from '../../compiler/compile/render_ssr/handlers/shared/boolean_attributes'; +import { set_current_component, current_component } from './lifecycle.ts'; +import { run_all, blank_object } from './utils.ts'; +import { boolean_attributes } from '../../compiler/compile/render_ssr/handlers/shared/boolean_attributes.ts'; export const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u; // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 diff --git a/src/runtime/internal/style_manager.ts b/src/runtime/internal/style_manager.ts index 8060e65a5d..4a625f8683 100644 --- a/src/runtime/internal/style_manager.ts +++ b/src/runtime/internal/style_manager.ts @@ -1,5 +1,5 @@ -import { element } from './dom'; -import { raf } from './environment'; +import { element } from './dom.ts'; +import { raf } from './environment.ts'; interface ExtendedDoc extends Document { __svelte_stylesheet: CSSStyleSheet; diff --git a/src/runtime/internal/transitions.ts b/src/runtime/internal/transitions.ts index 343a8c82e4..517dc80a8c 100644 --- a/src/runtime/internal/transitions.ts +++ b/src/runtime/internal/transitions.ts @@ -1,10 +1,10 @@ -import { identity as linear, is_function, noop, run_all } from './utils'; -import { now } from './environment'; -import { loop } from './loop'; -import { create_rule, delete_rule } from './style_manager'; -import { custom_event } from './dom'; -import { add_render_callback } from './scheduler'; -import { TransitionConfig } from '../transition'; +import { identity as linear, is_function, noop, run_all } from './utils.ts'; +import { now } from './environment.ts'; +import { loop } from './loop.ts'; +import { create_rule, delete_rule } from './style_manager.ts'; +import { custom_event } from './dom.ts'; +import { add_render_callback } from './scheduler.ts'; +import { TransitionConfig } from '../transition/index.ts'; let promise: Promise|null; diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index 3b8815cb1d..6efbdc9e4a 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -1,4 +1,4 @@ -import { Readable } from 'svelte/store'; +import { Readable } from '../store/index.ts'; export function noop() {} diff --git a/src/runtime/motion/index.ts b/src/runtime/motion/index.ts index ea6c646dd9..5e0c420db6 100644 --- a/src/runtime/motion/index.ts +++ b/src/runtime/motion/index.ts @@ -1,2 +1,2 @@ -export * from './spring'; -export * from './tweened'; +export * from './spring.ts'; +export * from './tweened.ts'; diff --git a/src/runtime/motion/spring.ts b/src/runtime/motion/spring.ts index 8d2056256c..1663016002 100644 --- a/src/runtime/motion/spring.ts +++ b/src/runtime/motion/spring.ts @@ -1,5 +1,5 @@ -import { Readable, writable } from 'svelte/store'; -import { loop, now, Task } from 'svelte/internal'; +import { Readable, writable } from '../store/index.ts'; +import { loop, now, Task } from '../internal/index.ts'; import { is_date } from './utils'; interface TickContext { diff --git a/src/runtime/motion/tweened.ts b/src/runtime/motion/tweened.ts index 83434cdff6..be08889e43 100644 --- a/src/runtime/motion/tweened.ts +++ b/src/runtime/motion/tweened.ts @@ -1,7 +1,7 @@ -import { Readable, writable } from 'svelte/store'; -import { assign, loop, now, Task } from 'svelte/internal'; -import { linear } from 'svelte/easing'; -import { is_date } from './utils'; +import { Readable, writable } from '../store/index.ts'; +import { assign, loop, now, Task } from '../internal/index.ts'; +import { linear } from '../easing/index.ts'; +import { is_date } from './utils.ts'; function get_interpolator(a, b) { if (a === b || a !== a) return () => a; diff --git a/src/runtime/store/index.ts b/src/runtime/store/index.ts index 09040487f0..9c3f66f226 100644 --- a/src/runtime/store/index.ts +++ b/src/runtime/store/index.ts @@ -1,4 +1,4 @@ -import { run_all, subscribe, noop, safe_not_equal, is_function, get_store_value } from 'svelte/internal'; +import { run_all, subscribe, noop, safe_not_equal, is_function, get_store_value } from '../internal/index.ts'; /** Callback to inform of a value updates. */ type Subscriber = (value: T) => void; diff --git a/src/runtime/transition/index.ts b/src/runtime/transition/index.ts index 7e879cb941..eea522c183 100644 --- a/src/runtime/transition/index.ts +++ b/src/runtime/transition/index.ts @@ -1,5 +1,5 @@ -import { cubicOut, cubicInOut, linear } from 'svelte/easing'; -import { assign, is_function } from 'svelte/internal'; +import { cubicOut, cubicInOut, linear } from '../easing/index.ts'; +import { assign, is_function } from '../internal/index.ts'; type EasingFunction = (t: number) => number;