|
|
|
@ -4,6 +4,21 @@ import { blank_object, is_function, run, run_all, noop, has_prop } from './utils
|
|
|
|
|
import { children } from './dom';
|
|
|
|
|
import { transition_in } from './transitions';
|
|
|
|
|
|
|
|
|
|
interface Fragment {
|
|
|
|
|
key: string|null;
|
|
|
|
|
first: null;
|
|
|
|
|
/* create */ c: () => void;
|
|
|
|
|
/* claim */ l: (nodes: any) => void;
|
|
|
|
|
/* hydrate */ h: () => void;
|
|
|
|
|
/* mount */ m: (target: HTMLElement, anchor: any) => void;
|
|
|
|
|
/* update */ p: (changed: any, ctx: any) => void;
|
|
|
|
|
/* measure */ r: () => void;
|
|
|
|
|
/* fix */ f: () => void;
|
|
|
|
|
/* animate */ a: () => void;
|
|
|
|
|
/* intro */ i: (local: any) => void;
|
|
|
|
|
/* outro */ o: (local: any) => void;
|
|
|
|
|
/* destroy */ d: (detaching: 0|1) => void;
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/class-name-casing
|
|
|
|
|
interface T$$ {
|
|
|
|
|
dirty: null;
|
|
|
|
@ -13,7 +28,7 @@ interface T$$ {
|
|
|
|
|
callbacks: any;
|
|
|
|
|
after_update: any[];
|
|
|
|
|
props: Record<string, 0 | string>;
|
|
|
|
|
fragment: null|any;
|
|
|
|
|
fragment: null|false|Fragment;
|
|
|
|
|
not_equal: any;
|
|
|
|
|
before_update: any[];
|
|
|
|
|
context: Map<any, any>;
|
|
|
|
@ -29,10 +44,18 @@ export function bind(component, name, callback) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function create_component(block) {
|
|
|
|
|
block && block.c();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function claim_component(block, parent_nodes) {
|
|
|
|
|
block && block.l(parent_nodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function mount_component(component, target, anchor) {
|
|
|
|
|
const { fragment, on_mount, on_destroy, after_update } = component.$$;
|
|
|
|
|
|
|
|
|
|
fragment.m(target, anchor);
|
|
|
|
|
fragment && fragment.m(target, anchor);
|
|
|
|
|
|
|
|
|
|
// onMount happens before the initial afterUpdate
|
|
|
|
|
add_render_callback(() => {
|
|
|
|
@ -51,15 +74,16 @@ export function mount_component(component, target, anchor) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function destroy_component(component, detaching) {
|
|
|
|
|
if (component.$$.fragment) {
|
|
|
|
|
run_all(component.$$.on_destroy);
|
|
|
|
|
const $$ = component.$$;
|
|
|
|
|
if ($$.fragment !== null) {
|
|
|
|
|
run_all($$.on_destroy);
|
|
|
|
|
|
|
|
|
|
component.$$.fragment.d(detaching);
|
|
|
|
|
$$.fragment && $$.fragment.d(detaching);
|
|
|
|
|
|
|
|
|
|
// TODO null out other refs, including component.$$ (but need to
|
|
|
|
|
// preserve final state?)
|
|
|
|
|
component.$$.on_destroy = component.$$.fragment = null;
|
|
|
|
|
component.$$.ctx = {};
|
|
|
|
|
$$.on_destroy = $$.fragment = null;
|
|
|
|
|
$$.ctx = {};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -115,15 +139,17 @@ export function init(component, options, instance, create_fragment, not_equal, p
|
|
|
|
|
$$.update();
|
|
|
|
|
ready = true;
|
|
|
|
|
run_all($$.before_update);
|
|
|
|
|
$$.fragment = create_fragment($$.ctx);
|
|
|
|
|
|
|
|
|
|
// `false` as a special case of no DOM component
|
|
|
|
|
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
|
|
|
|
|
|
|
|
|
|
if (options.target) {
|
|
|
|
|
if (options.hydrate) {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
|
|
|
$$.fragment!.l(children(options.target));
|
|
|
|
|
$$.fragment && $$.fragment!.l(children(options.target));
|
|
|
|
|
} else {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
|
|
|
$$.fragment!.c();
|
|
|
|
|
$$.fragment && $$.fragment!.c();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.intro) transition_in(component.$$.fragment);
|
|
|
|
|