mirror of
https://github.com/rxliuli/apps.apple.com.git
synced 2025-11-09 22:20:33 +00:00
init commit
This commit is contained in:
309
node_modules/svelte/src/runtime/easing/index.js
generated
vendored
Normal file
309
node_modules/svelte/src/runtime/easing/index.js
generated
vendored
Normal file
@@ -0,0 +1,309 @@
|
||||
/*
|
||||
Adapted from https://github.com/mattdesl
|
||||
Distributed under MIT License https://github.com/mattdesl/eases/blob/master/LICENSE.md
|
||||
*/
|
||||
export { identity as linear } from '../internal/index.js';
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function backInOut(t) {
|
||||
const s = 1.70158 * 1.525;
|
||||
if ((t *= 2) < 1) return 0.5 * (t * t * ((s + 1) * t - s));
|
||||
return 0.5 * ((t -= 2) * t * ((s + 1) * t + s) + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function backIn(t) {
|
||||
const s = 1.70158;
|
||||
return t * t * ((s + 1) * t - s);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function backOut(t) {
|
||||
const s = 1.70158;
|
||||
return --t * t * ((s + 1) * t + s) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function bounceOut(t) {
|
||||
const a = 4.0 / 11.0;
|
||||
const b = 8.0 / 11.0;
|
||||
const c = 9.0 / 10.0;
|
||||
const ca = 4356.0 / 361.0;
|
||||
const cb = 35442.0 / 1805.0;
|
||||
const cc = 16061.0 / 1805.0;
|
||||
const t2 = t * t;
|
||||
return t < a
|
||||
? 7.5625 * t2
|
||||
: t < b
|
||||
? 9.075 * t2 - 9.9 * t + 3.4
|
||||
: t < c
|
||||
? ca * t2 - cb * t + cc
|
||||
: 10.8 * t * t - 20.52 * t + 10.72;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function bounceInOut(t) {
|
||||
return t < 0.5 ? 0.5 * (1.0 - bounceOut(1.0 - t * 2.0)) : 0.5 * bounceOut(t * 2.0 - 1.0) + 0.5;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function bounceIn(t) {
|
||||
return 1.0 - bounceOut(1.0 - t);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function circInOut(t) {
|
||||
if ((t *= 2) < 1) return -0.5 * (Math.sqrt(1 - t * t) - 1);
|
||||
return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function circIn(t) {
|
||||
return 1.0 - Math.sqrt(1.0 - t * t);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function circOut(t) {
|
||||
return Math.sqrt(1 - --t * t);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function cubicInOut(t) {
|
||||
return t < 0.5 ? 4.0 * t * t * t : 0.5 * Math.pow(2.0 * t - 2.0, 3.0) + 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function cubicIn(t) {
|
||||
return t * t * t;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function cubicOut(t) {
|
||||
const f = t - 1.0;
|
||||
return f * f * f + 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function elasticInOut(t) {
|
||||
return t < 0.5
|
||||
? 0.5 * Math.sin(((+13.0 * Math.PI) / 2) * 2.0 * t) * Math.pow(2.0, 10.0 * (2.0 * t - 1.0))
|
||||
: 0.5 *
|
||||
Math.sin(((-13.0 * Math.PI) / 2) * (2.0 * t - 1.0 + 1.0)) *
|
||||
Math.pow(2.0, -10.0 * (2.0 * t - 1.0)) +
|
||||
1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function elasticIn(t) {
|
||||
return Math.sin((13.0 * t * Math.PI) / 2) * Math.pow(2.0, 10.0 * (t - 1.0));
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function elasticOut(t) {
|
||||
return Math.sin((-13.0 * (t + 1.0) * Math.PI) / 2) * Math.pow(2.0, -10.0 * t) + 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function expoInOut(t) {
|
||||
return t === 0.0 || t === 1.0
|
||||
? t
|
||||
: t < 0.5
|
||||
? +0.5 * Math.pow(2.0, 20.0 * t - 10.0)
|
||||
: -0.5 * Math.pow(2.0, 10.0 - t * 20.0) + 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function expoIn(t) {
|
||||
return t === 0.0 ? t : Math.pow(2.0, 10.0 * (t - 1.0));
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function expoOut(t) {
|
||||
return t === 1.0 ? t : 1.0 - Math.pow(2.0, -10.0 * t);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quadInOut(t) {
|
||||
t /= 0.5;
|
||||
if (t < 1) return 0.5 * t * t;
|
||||
t--;
|
||||
return -0.5 * (t * (t - 2) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quadIn(t) {
|
||||
return t * t;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quadOut(t) {
|
||||
return -t * (t - 2.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quartInOut(t) {
|
||||
return t < 0.5 ? +8.0 * Math.pow(t, 4.0) : -8.0 * Math.pow(t - 1.0, 4.0) + 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quartIn(t) {
|
||||
return Math.pow(t, 4.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quartOut(t) {
|
||||
return Math.pow(t - 1.0, 3.0) * (1.0 - t) + 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quintInOut(t) {
|
||||
if ((t *= 2) < 1) return 0.5 * t * t * t * t * t;
|
||||
return 0.5 * ((t -= 2) * t * t * t * t + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quintIn(t) {
|
||||
return t * t * t * t * t;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function quintOut(t) {
|
||||
return --t * t * t * t * t + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function sineInOut(t) {
|
||||
return -0.5 * (Math.cos(Math.PI * t) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function sineIn(t) {
|
||||
const v = Math.cos(t * Math.PI * 0.5);
|
||||
if (Math.abs(v) < 1e-14) return 1;
|
||||
else return 1 - v;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://svelte.dev/docs/svelte-easing
|
||||
* @param {number} t
|
||||
* @returns {number}
|
||||
*/
|
||||
export function sineOut(t) {
|
||||
return Math.sin((t * Math.PI) / 2);
|
||||
}
|
||||
524
node_modules/svelte/src/runtime/internal/Component.js
generated
vendored
Normal file
524
node_modules/svelte/src/runtime/internal/Component.js
generated
vendored
Normal file
@@ -0,0 +1,524 @@
|
||||
import {
|
||||
add_render_callback,
|
||||
flush,
|
||||
flush_render_callbacks,
|
||||
schedule_update,
|
||||
dirty_components
|
||||
} from './scheduler.js';
|
||||
import { current_component, set_current_component } from './lifecycle.js';
|
||||
import { blank_object, is_empty, is_function, run, run_all, noop } from './utils.js';
|
||||
import {
|
||||
children,
|
||||
detach,
|
||||
start_hydrating,
|
||||
end_hydrating,
|
||||
get_custom_elements_slots,
|
||||
insert,
|
||||
element,
|
||||
attr
|
||||
} from './dom.js';
|
||||
import { transition_in } from './transitions.js';
|
||||
|
||||
/** @returns {void} */
|
||||
export function bind(component, name, callback) {
|
||||
const index = component.$$.props[name];
|
||||
if (index !== undefined) {
|
||||
component.$$.bound[index] = callback;
|
||||
callback(component.$$.ctx[index]);
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function create_component(block) {
|
||||
block && block.c();
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function claim_component(block, parent_nodes) {
|
||||
block && block.l(parent_nodes);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function mount_component(component, target, anchor) {
|
||||
const { fragment, after_update } = component.$$;
|
||||
fragment && fragment.m(target, anchor);
|
||||
// onMount happens before the initial afterUpdate
|
||||
add_render_callback(() => {
|
||||
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
|
||||
// if the component was destroyed immediately
|
||||
// it will update the `$$.on_destroy` reference to `null`.
|
||||
// the destructured on_destroy may still reference to the old array
|
||||
if (component.$$.on_destroy) {
|
||||
component.$$.on_destroy.push(...new_on_destroy);
|
||||
} else {
|
||||
// Edge case - component was destroyed immediately,
|
||||
// most likely as a result of a binding initialising
|
||||
run_all(new_on_destroy);
|
||||
}
|
||||
component.$$.on_mount = [];
|
||||
});
|
||||
after_update.forEach(add_render_callback);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function destroy_component(component, detaching) {
|
||||
const $$ = component.$$;
|
||||
if ($$.fragment !== null) {
|
||||
flush_render_callbacks($$.after_update);
|
||||
run_all($$.on_destroy);
|
||||
$$.fragment && $$.fragment.d(detaching);
|
||||
// TODO null out other refs, including component.$$ (but need to
|
||||
// preserve final state?)
|
||||
$$.on_destroy = $$.fragment = null;
|
||||
$$.ctx = [];
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function make_dirty(component, i) {
|
||||
if (component.$$.dirty[0] === -1) {
|
||||
dirty_components.push(component);
|
||||
schedule_update();
|
||||
component.$$.dirty.fill(0);
|
||||
}
|
||||
component.$$.dirty[(i / 31) | 0] |= 1 << i % 31;
|
||||
}
|
||||
|
||||
// TODO: Document the other params
|
||||
/**
|
||||
* @param {SvelteComponent} component
|
||||
* @param {import('./public.js').ComponentConstructorOptions} options
|
||||
*
|
||||
* @param {import('./utils.js')['not_equal']} not_equal Used to compare props and state values.
|
||||
* @param {(target: Element | ShadowRoot) => void} [append_styles] Function that appends styles to the DOM when the component is first initialised.
|
||||
* This will be the `add_css` function from the compiled component.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function init(
|
||||
component,
|
||||
options,
|
||||
instance,
|
||||
create_fragment,
|
||||
not_equal,
|
||||
props,
|
||||
append_styles = null,
|
||||
dirty = [-1]
|
||||
) {
|
||||
const parent_component = current_component;
|
||||
set_current_component(component);
|
||||
/** @type {import('./private.js').T$$} */
|
||||
const $$ = (component.$$ = {
|
||||
fragment: null,
|
||||
ctx: [],
|
||||
// state
|
||||
props,
|
||||
update: noop,
|
||||
not_equal,
|
||||
bound: blank_object(),
|
||||
// lifecycle
|
||||
on_mount: [],
|
||||
on_destroy: [],
|
||||
on_disconnect: [],
|
||||
before_update: [],
|
||||
after_update: [],
|
||||
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
|
||||
// everything else
|
||||
callbacks: blank_object(),
|
||||
dirty,
|
||||
skip_bound: false,
|
||||
root: options.target || parent_component.$$.root
|
||||
});
|
||||
append_styles && append_styles($$.root);
|
||||
let ready = false;
|
||||
$$.ctx = instance
|
||||
? instance(component, options.props || {}, (i, ret, ...rest) => {
|
||||
const value = rest.length ? rest[0] : ret;
|
||||
if ($$.ctx && not_equal($$.ctx[i], ($$.ctx[i] = value))) {
|
||||
if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
|
||||
if (ready) make_dirty(component, i);
|
||||
}
|
||||
return ret;
|
||||
})
|
||||
: [];
|
||||
$$.update();
|
||||
ready = true;
|
||||
run_all($$.before_update);
|
||||
// `false` as a special case of no DOM component
|
||||
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
|
||||
if (options.target) {
|
||||
if (options.hydrate) {
|
||||
start_hydrating();
|
||||
// TODO: what is the correct type here?
|
||||
// @ts-expect-error
|
||||
const nodes = children(options.target);
|
||||
$$.fragment && $$.fragment.l(nodes);
|
||||
nodes.forEach(detach);
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
$$.fragment && $$.fragment.c();
|
||||
}
|
||||
if (options.intro) transition_in(component.$$.fragment);
|
||||
mount_component(component, options.target, options.anchor);
|
||||
end_hydrating();
|
||||
flush();
|
||||
}
|
||||
set_current_component(parent_component);
|
||||
}
|
||||
|
||||
export let SvelteElement;
|
||||
|
||||
if (typeof HTMLElement === 'function') {
|
||||
SvelteElement = class extends HTMLElement {
|
||||
/** The Svelte component constructor */
|
||||
$$ctor;
|
||||
/** Slots */
|
||||
$$s;
|
||||
/** The Svelte component instance */
|
||||
$$c;
|
||||
/** Whether or not the custom element is connected */
|
||||
$$cn = false;
|
||||
/** Component props data */
|
||||
$$d = {};
|
||||
/** `true` if currently in the process of reflecting component props back to attributes */
|
||||
$$r = false;
|
||||
/** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
|
||||
$$p_d = {};
|
||||
/** @type {Record<string, Function[]>} Event listeners */
|
||||
$$l = {};
|
||||
/** @type {Map<Function, Function>} Event listener unsubscribe functions */
|
||||
$$l_u = new Map();
|
||||
|
||||
constructor($$componentCtor, $$slots, use_shadow_dom) {
|
||||
super();
|
||||
this.$$ctor = $$componentCtor;
|
||||
this.$$s = $$slots;
|
||||
if (use_shadow_dom) {
|
||||
this.attachShadow({ mode: 'open' });
|
||||
}
|
||||
}
|
||||
|
||||
addEventListener(type, listener, options) {
|
||||
// We can't determine upfront if the event is a custom event or not, so we have to
|
||||
// listen to both. If someone uses a custom event with the same name as a regular
|
||||
// browser event, this fires twice - we can't avoid that.
|
||||
this.$$l[type] = this.$$l[type] || [];
|
||||
this.$$l[type].push(listener);
|
||||
if (this.$$c) {
|
||||
const unsub = this.$$c.$on(type, listener);
|
||||
this.$$l_u.set(listener, unsub);
|
||||
}
|
||||
super.addEventListener(type, listener, options);
|
||||
}
|
||||
|
||||
removeEventListener(type, listener, options) {
|
||||
super.removeEventListener(type, listener, options);
|
||||
if (this.$$c) {
|
||||
const unsub = this.$$l_u.get(listener);
|
||||
if (unsub) {
|
||||
unsub();
|
||||
this.$$l_u.delete(listener);
|
||||
}
|
||||
}
|
||||
if (this.$$l[type]) {
|
||||
const idx = this.$$l[type].indexOf(listener);
|
||||
if (idx >= 0) {
|
||||
this.$$l[type].splice(idx, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async connectedCallback() {
|
||||
this.$$cn = true;
|
||||
if (!this.$$c) {
|
||||
// We wait one tick to let possible child slot elements be created/mounted
|
||||
await Promise.resolve();
|
||||
if (!this.$$cn || this.$$c) {
|
||||
return;
|
||||
}
|
||||
function create_slot(name) {
|
||||
return () => {
|
||||
let node;
|
||||
const obj = {
|
||||
c: function create() {
|
||||
node = element('slot');
|
||||
if (name !== 'default') {
|
||||
attr(node, 'name', name);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {HTMLElement} target
|
||||
* @param {HTMLElement} [anchor]
|
||||
*/
|
||||
m: function mount(target, anchor) {
|
||||
insert(target, node, anchor);
|
||||
},
|
||||
d: function destroy(detaching) {
|
||||
if (detaching) {
|
||||
detach(node);
|
||||
}
|
||||
}
|
||||
};
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
const $$slots = {};
|
||||
const existing_slots = get_custom_elements_slots(this);
|
||||
for (const name of this.$$s) {
|
||||
if (name in existing_slots) {
|
||||
$$slots[name] = [create_slot(name)];
|
||||
}
|
||||
}
|
||||
for (const attribute of this.attributes) {
|
||||
// this.$$data takes precedence over this.attributes
|
||||
const name = this.$$g_p(attribute.name);
|
||||
if (!(name in this.$$d)) {
|
||||
this.$$d[name] = get_custom_element_value(name, attribute.value, this.$$p_d, 'toProp');
|
||||
}
|
||||
}
|
||||
// Port over props that were set programmatically before ce was initialized
|
||||
for (const key in this.$$p_d) {
|
||||
if (!(key in this.$$d) && this[key] !== undefined) {
|
||||
this.$$d[key] = this[key]; // don't transform, these were set through JavaScript
|
||||
delete this[key]; // remove the property that shadows the getter/setter
|
||||
}
|
||||
}
|
||||
this.$$c = new this.$$ctor({
|
||||
target: this.shadowRoot || this,
|
||||
props: {
|
||||
...this.$$d,
|
||||
$$slots,
|
||||
$$scope: {
|
||||
ctx: []
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Reflect component props as attributes
|
||||
const reflect_attributes = () => {
|
||||
this.$$r = true;
|
||||
for (const key in this.$$p_d) {
|
||||
this.$$d[key] = this.$$c.$$.ctx[this.$$c.$$.props[key]];
|
||||
if (this.$$p_d[key].reflect) {
|
||||
const attribute_value = get_custom_element_value(
|
||||
key,
|
||||
this.$$d[key],
|
||||
this.$$p_d,
|
||||
'toAttribute'
|
||||
);
|
||||
if (attribute_value == null) {
|
||||
this.removeAttribute(this.$$p_d[key].attribute || key);
|
||||
} else {
|
||||
this.setAttribute(this.$$p_d[key].attribute || key, attribute_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.$$r = false;
|
||||
};
|
||||
this.$$c.$$.after_update.push(reflect_attributes);
|
||||
reflect_attributes(); // once initially because after_update is added too late for first render
|
||||
|
||||
for (const type in this.$$l) {
|
||||
for (const listener of this.$$l[type]) {
|
||||
const unsub = this.$$c.$on(type, listener);
|
||||
this.$$l_u.set(listener, unsub);
|
||||
}
|
||||
}
|
||||
this.$$l = {};
|
||||
}
|
||||
}
|
||||
|
||||
// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
|
||||
// and setting attributes through setAttribute etc, this is helpful
|
||||
attributeChangedCallback(attr, _oldValue, newValue) {
|
||||
if (this.$$r) return;
|
||||
attr = this.$$g_p(attr);
|
||||
this.$$d[attr] = get_custom_element_value(attr, newValue, this.$$p_d, 'toProp');
|
||||
this.$$c?.$set({ [attr]: this.$$d[attr] });
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
this.$$cn = false;
|
||||
// In a microtask, because this could be a move within the DOM
|
||||
Promise.resolve().then(() => {
|
||||
if (!this.$$cn && this.$$c) {
|
||||
this.$$c.$destroy();
|
||||
this.$$c = undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$$g_p(attribute_name) {
|
||||
return (
|
||||
Object.keys(this.$$p_d).find(
|
||||
(key) =>
|
||||
this.$$p_d[key].attribute === attribute_name ||
|
||||
(!this.$$p_d[key].attribute && key.toLowerCase() === attribute_name)
|
||||
) || attribute_name
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} prop
|
||||
* @param {any} value
|
||||
* @param {Record<string, CustomElementPropDefinition>} props_definition
|
||||
* @param {'toAttribute' | 'toProp'} [transform]
|
||||
*/
|
||||
function get_custom_element_value(prop, value, props_definition, transform) {
|
||||
const type = props_definition[prop]?.type;
|
||||
value = type === 'Boolean' && typeof value !== 'boolean' ? value != null : value;
|
||||
if (!transform || !props_definition[prop]) {
|
||||
return value;
|
||||
} else if (transform === 'toAttribute') {
|
||||
switch (type) {
|
||||
case 'Object':
|
||||
case 'Array':
|
||||
return value == null ? null : JSON.stringify(value);
|
||||
case 'Boolean':
|
||||
return value ? '' : null;
|
||||
case 'Number':
|
||||
return value == null ? null : value;
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
} else {
|
||||
switch (type) {
|
||||
case 'Object':
|
||||
case 'Array':
|
||||
return value && JSON.parse(value);
|
||||
case 'Boolean':
|
||||
return value; // conversion already handled above
|
||||
case 'Number':
|
||||
return value != null ? +value : value;
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* Turn a Svelte component into a custom element.
|
||||
* @param {import('./public.js').ComponentType} Component A Svelte component constructor
|
||||
* @param {Record<string, CustomElementPropDefinition>} props_definition The props to observe
|
||||
* @param {string[]} slots The slots to create
|
||||
* @param {string[]} accessors Other accessors besides the ones for props the component has
|
||||
* @param {boolean} use_shadow_dom Whether to use shadow DOM
|
||||
* @param {(ce: new () => HTMLElement) => new () => HTMLElement} [extend]
|
||||
*/
|
||||
export function create_custom_element(
|
||||
Component,
|
||||
props_definition,
|
||||
slots,
|
||||
accessors,
|
||||
use_shadow_dom,
|
||||
extend
|
||||
) {
|
||||
let Class = class extends SvelteElement {
|
||||
constructor() {
|
||||
super(Component, slots, use_shadow_dom);
|
||||
this.$$p_d = props_definition;
|
||||
}
|
||||
static get observedAttributes() {
|
||||
return Object.keys(props_definition).map((key) =>
|
||||
(props_definition[key].attribute || key).toLowerCase()
|
||||
);
|
||||
}
|
||||
};
|
||||
Object.keys(props_definition).forEach((prop) => {
|
||||
Object.defineProperty(Class.prototype, prop, {
|
||||
get() {
|
||||
return this.$$c && prop in this.$$c ? this.$$c[prop] : this.$$d[prop];
|
||||
},
|
||||
set(value) {
|
||||
value = get_custom_element_value(prop, value, props_definition);
|
||||
this.$$d[prop] = value;
|
||||
this.$$c?.$set({ [prop]: value });
|
||||
}
|
||||
});
|
||||
});
|
||||
accessors.forEach((accessor) => {
|
||||
Object.defineProperty(Class.prototype, accessor, {
|
||||
get() {
|
||||
return this.$$c?.[accessor];
|
||||
}
|
||||
});
|
||||
});
|
||||
if (extend) {
|
||||
// @ts-expect-error - assigning here is fine
|
||||
Class = extend(Class);
|
||||
}
|
||||
Component.element = /** @type {any} */ (Class);
|
||||
return Class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for Svelte components. Used when dev=false.
|
||||
*
|
||||
* @template {Record<string, any>} [Props=any]
|
||||
* @template {Record<string, any>} [Events=any]
|
||||
*/
|
||||
export class SvelteComponent {
|
||||
/**
|
||||
* ### PRIVATE API
|
||||
*
|
||||
* Do not use, may change at any time
|
||||
*
|
||||
* @type {any}
|
||||
*/
|
||||
$$ = undefined;
|
||||
/**
|
||||
* ### PRIVATE API
|
||||
*
|
||||
* Do not use, may change at any time
|
||||
*
|
||||
* @type {any}
|
||||
*/
|
||||
$$set = undefined;
|
||||
|
||||
/** @returns {void} */
|
||||
$destroy() {
|
||||
destroy_component(this, 1);
|
||||
this.$destroy = noop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Extract<keyof Events, string>} K
|
||||
* @param {K} type
|
||||
* @param {((e: Events[K]) => void) | null | undefined} callback
|
||||
* @returns {() => void}
|
||||
*/
|
||||
$on(type, callback) {
|
||||
if (!is_function(callback)) {
|
||||
return noop;
|
||||
}
|
||||
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
|
||||
callbacks.push(callback);
|
||||
return () => {
|
||||
const index = callbacks.indexOf(callback);
|
||||
if (index !== -1) callbacks.splice(index, 1);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Partial<Props>} props
|
||||
* @returns {void}
|
||||
*/
|
||||
$set(props) {
|
||||
if (this.$$set && !is_empty(props)) {
|
||||
this.$$.skip_bound = true;
|
||||
this.$$set(props);
|
||||
this.$$.skip_bound = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} CustomElementPropDefinition
|
||||
* @property {string} [attribute]
|
||||
* @property {boolean} [reflect]
|
||||
* @property {'String'|'Boolean'|'Number'|'Array'|'Object'} [type]
|
||||
*/
|
||||
100
node_modules/svelte/src/runtime/internal/await_block.js
generated
vendored
Normal file
100
node_modules/svelte/src/runtime/internal/await_block.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
import { is_promise } from './utils.js';
|
||||
import { check_outros, group_outros, transition_in, transition_out } from './transitions.js';
|
||||
import { flush } from './scheduler.js';
|
||||
import { get_current_component, set_current_component } from './lifecycle.js';
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {Promise<T>} promise
|
||||
* @param {import('./private.js').PromiseInfo<T>} info
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function handle_promise(promise, info) {
|
||||
const token = (info.token = {});
|
||||
/**
|
||||
* @param {import('./private.js').FragmentFactory} type
|
||||
* @param {0 | 1 | 2} index
|
||||
* @param {number} [key]
|
||||
* @param {any} [value]
|
||||
* @returns {void}
|
||||
*/
|
||||
function update(type, index, key, value) {
|
||||
if (info.token !== token) return;
|
||||
info.resolved = value;
|
||||
let child_ctx = info.ctx;
|
||||
if (key !== undefined) {
|
||||
child_ctx = child_ctx.slice();
|
||||
child_ctx[key] = value;
|
||||
}
|
||||
const block = type && (info.current = type)(child_ctx);
|
||||
let needs_flush = false;
|
||||
if (info.block) {
|
||||
if (info.blocks) {
|
||||
info.blocks.forEach((block, i) => {
|
||||
if (i !== index && block) {
|
||||
group_outros();
|
||||
transition_out(block, 1, 1, () => {
|
||||
if (info.blocks[i] === block) {
|
||||
info.blocks[i] = null;
|
||||
}
|
||||
});
|
||||
check_outros();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
info.block.d(1);
|
||||
}
|
||||
block.c();
|
||||
transition_in(block, 1);
|
||||
block.m(info.mount(), info.anchor);
|
||||
needs_flush = true;
|
||||
}
|
||||
info.block = block;
|
||||
if (info.blocks) info.blocks[index] = block;
|
||||
if (needs_flush) {
|
||||
flush();
|
||||
}
|
||||
}
|
||||
if (is_promise(promise)) {
|
||||
const current_component = get_current_component();
|
||||
promise.then(
|
||||
(value) => {
|
||||
set_current_component(current_component);
|
||||
update(info.then, 1, info.value, value);
|
||||
set_current_component(null);
|
||||
},
|
||||
(error) => {
|
||||
set_current_component(current_component);
|
||||
update(info.catch, 2, info.error, error);
|
||||
set_current_component(null);
|
||||
if (!info.hasCatch) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
);
|
||||
// if we previously had a then/catch block, destroy it
|
||||
if (info.current !== info.pending) {
|
||||
update(info.pending, 0);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (info.current !== info.then) {
|
||||
update(info.then, 1, info.value, promise);
|
||||
return true;
|
||||
}
|
||||
info.resolved = /** @type {T} */ (promise);
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function update_await_block_branch(info, ctx, dirty) {
|
||||
const child_ctx = ctx.slice();
|
||||
const { resolved } = info;
|
||||
if (info.current === info.then) {
|
||||
child_ctx[info.value] = resolved;
|
||||
}
|
||||
if (info.current === info.catch) {
|
||||
child_ctx[info.error] = resolved;
|
||||
}
|
||||
info.block.p(child_ctx, dirty);
|
||||
}
|
||||
5
node_modules/svelte/src/runtime/internal/disclose-version/index.js
generated
vendored
Normal file
5
node_modules/svelte/src/runtime/internal/disclose-version/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { PUBLIC_VERSION } from '../../../shared/version.js';
|
||||
|
||||
if (typeof window !== 'undefined')
|
||||
// @ts-ignore
|
||||
(window.__svelte || (window.__svelte = { v: new Set() })).v.add(PUBLIC_VERSION);
|
||||
1251
node_modules/svelte/src/runtime/internal/dom.js
generated
vendored
Normal file
1251
node_modules/svelte/src/runtime/internal/dom.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
143
node_modules/svelte/src/runtime/internal/each.js
generated
vendored
Normal file
143
node_modules/svelte/src/runtime/internal/each.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
import { transition_in, transition_out } from './transitions.js';
|
||||
import { run_all } from './utils.js';
|
||||
|
||||
// general each functions:
|
||||
|
||||
export function ensure_array_like(array_like_or_iterator) {
|
||||
return array_like_or_iterator?.length !== undefined
|
||||
? array_like_or_iterator
|
||||
: Array.from(array_like_or_iterator);
|
||||
}
|
||||
|
||||
// keyed each functions:
|
||||
|
||||
/** @returns {void} */
|
||||
export function destroy_block(block, lookup) {
|
||||
block.d(1);
|
||||
lookup.delete(block.key);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function outro_and_destroy_block(block, lookup) {
|
||||
transition_out(block, 1, 1, () => {
|
||||
lookup.delete(block.key);
|
||||
});
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function fix_and_destroy_block(block, lookup) {
|
||||
block.f();
|
||||
destroy_block(block, lookup);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function fix_and_outro_and_destroy_block(block, lookup) {
|
||||
block.f();
|
||||
outro_and_destroy_block(block, lookup);
|
||||
}
|
||||
|
||||
/** @returns {any[]} */
|
||||
export function update_keyed_each(
|
||||
old_blocks,
|
||||
dirty,
|
||||
get_key,
|
||||
dynamic,
|
||||
ctx,
|
||||
list,
|
||||
lookup,
|
||||
node,
|
||||
destroy,
|
||||
create_each_block,
|
||||
next,
|
||||
get_context
|
||||
) {
|
||||
let o = old_blocks.length;
|
||||
let n = list.length;
|
||||
let i = o;
|
||||
const old_indexes = {};
|
||||
while (i--) old_indexes[old_blocks[i].key] = i;
|
||||
const new_blocks = [];
|
||||
const new_lookup = new Map();
|
||||
const deltas = new Map();
|
||||
const updates = [];
|
||||
i = n;
|
||||
while (i--) {
|
||||
const child_ctx = get_context(ctx, list, i);
|
||||
const key = get_key(child_ctx);
|
||||
let block = lookup.get(key);
|
||||
if (!block) {
|
||||
block = create_each_block(key, child_ctx);
|
||||
block.c();
|
||||
} else if (dynamic) {
|
||||
// defer updates until all the DOM shuffling is done
|
||||
updates.push(() => block.p(child_ctx, dirty));
|
||||
}
|
||||
new_lookup.set(key, (new_blocks[i] = block));
|
||||
if (key in old_indexes) deltas.set(key, Math.abs(i - old_indexes[key]));
|
||||
}
|
||||
const will_move = new Set();
|
||||
const did_move = new Set();
|
||||
/** @returns {void} */
|
||||
function insert(block) {
|
||||
transition_in(block, 1);
|
||||
block.m(node, next);
|
||||
lookup.set(block.key, block);
|
||||
next = block.first;
|
||||
n--;
|
||||
}
|
||||
while (o && n) {
|
||||
const new_block = new_blocks[n - 1];
|
||||
const old_block = old_blocks[o - 1];
|
||||
const new_key = new_block.key;
|
||||
const old_key = old_block.key;
|
||||
if (new_block === old_block) {
|
||||
// do nothing
|
||||
next = new_block.first;
|
||||
o--;
|
||||
n--;
|
||||
} else if (!new_lookup.has(old_key)) {
|
||||
// remove old block
|
||||
destroy(old_block, lookup);
|
||||
o--;
|
||||
} else if (!lookup.has(new_key) || will_move.has(new_key)) {
|
||||
insert(new_block);
|
||||
} else if (did_move.has(old_key)) {
|
||||
o--;
|
||||
} else if (deltas.get(new_key) > deltas.get(old_key)) {
|
||||
did_move.add(new_key);
|
||||
insert(new_block);
|
||||
} else {
|
||||
will_move.add(old_key);
|
||||
o--;
|
||||
}
|
||||
}
|
||||
while (o--) {
|
||||
const old_block = old_blocks[o];
|
||||
if (!new_lookup.has(old_block.key)) destroy(old_block, lookup);
|
||||
}
|
||||
while (n) insert(new_blocks[n - 1]);
|
||||
run_all(updates);
|
||||
return new_blocks;
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function validate_each_keys(ctx, list, get_context, get_key) {
|
||||
const keys = new Map();
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const key = get_key(get_context(ctx, list, i));
|
||||
if (keys.has(key)) {
|
||||
let value = '';
|
||||
try {
|
||||
value = `with value '${String(key)}' `;
|
||||
} catch (e) {
|
||||
// can't stringify
|
||||
}
|
||||
throw new Error(
|
||||
`Cannot have duplicate keys in a keyed each: Keys at index ${keys.get(
|
||||
key
|
||||
)} and ${i} ${value}are duplicates`
|
||||
);
|
||||
}
|
||||
keys.set(key, i);
|
||||
}
|
||||
}
|
||||
19
node_modules/svelte/src/runtime/internal/environment.js
generated
vendored
Normal file
19
node_modules/svelte/src/runtime/internal/environment.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { noop } from './utils.js';
|
||||
|
||||
export const is_client = typeof window !== 'undefined';
|
||||
|
||||
/** @type {() => number} */
|
||||
export let now = is_client ? () => window.performance.now() : () => Date.now();
|
||||
|
||||
export let raf = is_client ? (cb) => requestAnimationFrame(cb) : noop;
|
||||
|
||||
// used internally for testing
|
||||
/** @returns {void} */
|
||||
export function set_now(fn) {
|
||||
now = fn;
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function set_raf(fn) {
|
||||
raf = fn;
|
||||
}
|
||||
8
node_modules/svelte/src/runtime/internal/globals.js
generated
vendored
Normal file
8
node_modules/svelte/src/runtime/internal/globals.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/** @type {typeof globalThis} */
|
||||
export const globals =
|
||||
typeof window !== 'undefined'
|
||||
? window
|
||||
: typeof globalThis !== 'undefined'
|
||||
? globalThis
|
||||
: // @ts-ignore Node typings have this
|
||||
global;
|
||||
183
node_modules/svelte/src/runtime/internal/lifecycle.js
generated
vendored
Normal file
183
node_modules/svelte/src/runtime/internal/lifecycle.js
generated
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
import { custom_event } from './dom.js';
|
||||
|
||||
export let current_component;
|
||||
|
||||
/** @returns {void} */
|
||||
export function set_current_component(component) {
|
||||
current_component = component;
|
||||
}
|
||||
|
||||
export function get_current_component() {
|
||||
if (!current_component) throw new Error('Function called outside component initialization');
|
||||
return current_component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a callback to run immediately before the component is updated after any state change.
|
||||
*
|
||||
* The first time the callback runs will be before the initial `onMount`
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#beforeupdate
|
||||
* @param {() => any} fn
|
||||
* @returns {void}
|
||||
*/
|
||||
export function beforeUpdate(fn) {
|
||||
get_current_component().$$.before_update.push(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
|
||||
* It must be called during the component's initialisation (but doesn't need to live *inside* the component;
|
||||
* it can be called from an external module).
|
||||
*
|
||||
* If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted.
|
||||
*
|
||||
* `onMount` does not run inside a [server-side component](https://svelte.dev/docs#run-time-server-side-component-api).
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#onmount
|
||||
* @template T
|
||||
* @param {() => import('./private.js').NotFunction<T> | Promise<import('./private.js').NotFunction<T>> | (() => any)} fn
|
||||
* @returns {void}
|
||||
*/
|
||||
export function onMount(fn) {
|
||||
get_current_component().$$.on_mount.push(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a callback to run immediately after the component has been updated.
|
||||
*
|
||||
* The first time the callback runs will be after the initial `onMount`
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#afterupdate
|
||||
* @param {() => any} fn
|
||||
* @returns {void}
|
||||
*/
|
||||
export function afterUpdate(fn) {
|
||||
get_current_component().$$.after_update.push(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a callback to run immediately before the component is unmounted.
|
||||
*
|
||||
* Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the
|
||||
* only one that runs inside a server-side component.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#ondestroy
|
||||
* @param {() => any} fn
|
||||
* @returns {void}
|
||||
*/
|
||||
export function onDestroy(fn) {
|
||||
get_current_component().$$.on_destroy.push(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs#template-syntax-component-directives-on-eventname).
|
||||
* Event dispatchers are functions that can take two arguments: `name` and `detail`.
|
||||
*
|
||||
* Component events created with `createEventDispatcher` create a
|
||||
* [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent).
|
||||
* These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture).
|
||||
* The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail)
|
||||
* property and can contain any type of data.
|
||||
*
|
||||
* The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument:
|
||||
* ```ts
|
||||
* const dispatch = createEventDispatcher<{
|
||||
* loaded: never; // does not take a detail argument
|
||||
* change: string; // takes a detail argument of type string, which is required
|
||||
* optional: number | null; // takes an optional detail argument of type number
|
||||
* }>();
|
||||
* ```
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#createeventdispatcher
|
||||
* @template {Record<string, any>} [EventMap=any]
|
||||
* @returns {import('./public.js').EventDispatcher<EventMap>}
|
||||
*/
|
||||
export function createEventDispatcher() {
|
||||
const component = get_current_component();
|
||||
return (type, detail, { cancelable = false } = {}) => {
|
||||
const callbacks = component.$$.callbacks[type];
|
||||
if (callbacks) {
|
||||
// TODO are there situations where events could be dispatched
|
||||
// in a server (non-DOM) environment?
|
||||
const event = custom_event(/** @type {string} */ (type), detail, { cancelable });
|
||||
callbacks.slice().forEach((fn) => {
|
||||
fn.call(component, event);
|
||||
});
|
||||
return !event.defaultPrevented;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Associates an arbitrary `context` object with the current component and the specified `key`
|
||||
* and returns that object. The context is then available to children of the component
|
||||
* (including slotted content) with `getContext`.
|
||||
*
|
||||
* Like lifecycle functions, this must be called during component initialisation.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#setcontext
|
||||
* @template T
|
||||
* @param {any} key
|
||||
* @param {T} context
|
||||
* @returns {T}
|
||||
*/
|
||||
export function setContext(key, context) {
|
||||
get_current_component().$$.context.set(key, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the context that belongs to the closest parent component with the specified `key`.
|
||||
* Must be called during component initialisation.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#getcontext
|
||||
* @template T
|
||||
* @param {any} key
|
||||
* @returns {T}
|
||||
*/
|
||||
export function getContext(key) {
|
||||
return get_current_component().$$.context.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the whole context map that belongs to the closest parent component.
|
||||
* Must be called during component initialisation. Useful, for example, if you
|
||||
* programmatically create a component and want to pass the existing context to it.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#getallcontexts
|
||||
* @template {Map<any, any>} [T=Map<any, any>]
|
||||
* @returns {T}
|
||||
*/
|
||||
export function getAllContexts() {
|
||||
return get_current_component().$$.context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given `key` has been set in the context of a parent component.
|
||||
* Must be called during component initialisation.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte#hascontext
|
||||
* @param {any} key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function hasContext(key) {
|
||||
return get_current_component().$$.context.has(key);
|
||||
}
|
||||
|
||||
// TODO figure out if we still want to support
|
||||
// shorthand events, or if we want to implement
|
||||
// a real bubbling mechanism
|
||||
/**
|
||||
* @param component
|
||||
* @param event
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bubble(component, event) {
|
||||
const callbacks = component.$$.callbacks[event.type];
|
||||
if (callbacks) {
|
||||
// @ts-ignore
|
||||
callbacks.slice().forEach((fn) => fn.call(this, event));
|
||||
}
|
||||
}
|
||||
45
node_modules/svelte/src/runtime/internal/loop.js
generated
vendored
Normal file
45
node_modules/svelte/src/runtime/internal/loop.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import { raf } from './environment.js';
|
||||
|
||||
const tasks = new Set();
|
||||
|
||||
/**
|
||||
* @param {number} now
|
||||
* @returns {void}
|
||||
*/
|
||||
function run_tasks(now) {
|
||||
tasks.forEach((task) => {
|
||||
if (!task.c(now)) {
|
||||
tasks.delete(task);
|
||||
task.f();
|
||||
}
|
||||
});
|
||||
if (tasks.size !== 0) raf(run_tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* For testing purposes only!
|
||||
* @returns {void}
|
||||
*/
|
||||
export function clear_loops() {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new task that runs on each raf frame
|
||||
* until it returns a falsy value or is aborted
|
||||
* @param {import('./private.js').TaskCallback} callback
|
||||
* @returns {import('./private.js').Task}
|
||||
*/
|
||||
export function loop(callback) {
|
||||
/** @type {import('./private.js').TaskEntry} */
|
||||
let task;
|
||||
if (tasks.size === 0) raf(run_tasks);
|
||||
return {
|
||||
promise: new Promise((fulfill) => {
|
||||
tasks.add((task = { c: callback, f: fulfill }));
|
||||
}),
|
||||
abort() {
|
||||
tasks.delete(task);
|
||||
}
|
||||
};
|
||||
}
|
||||
135
node_modules/svelte/src/runtime/internal/scheduler.js
generated
vendored
Normal file
135
node_modules/svelte/src/runtime/internal/scheduler.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
import { run_all } from './utils.js';
|
||||
import { current_component, set_current_component } from './lifecycle.js';
|
||||
|
||||
export const dirty_components = [];
|
||||
export const intros = { enabled: false };
|
||||
export const binding_callbacks = [];
|
||||
|
||||
let render_callbacks = [];
|
||||
|
||||
const flush_callbacks = [];
|
||||
|
||||
const resolved_promise = /* @__PURE__ */ Promise.resolve();
|
||||
|
||||
let update_scheduled = false;
|
||||
|
||||
/** @returns {void} */
|
||||
export function schedule_update() {
|
||||
if (!update_scheduled) {
|
||||
update_scheduled = true;
|
||||
resolved_promise.then(flush);
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {Promise<void>} */
|
||||
export function tick() {
|
||||
schedule_update();
|
||||
return resolved_promise;
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function add_render_callback(fn) {
|
||||
render_callbacks.push(fn);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function add_flush_callback(fn) {
|
||||
flush_callbacks.push(fn);
|
||||
}
|
||||
|
||||
// flush() calls callbacks in this order:
|
||||
// 1. All beforeUpdate callbacks, in order: parents before children
|
||||
// 2. All bind:this callbacks, in reverse order: children before parents.
|
||||
// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
|
||||
// for afterUpdates called during the initial onMount, which are called in
|
||||
// reverse order: children before parents.
|
||||
// Since callbacks might update component values, which could trigger another
|
||||
// call to flush(), the following steps guard against this:
|
||||
// 1. During beforeUpdate, any updated components will be added to the
|
||||
// dirty_components array and will cause a reentrant call to flush(). Because
|
||||
// the flush index is kept outside the function, the reentrant call will pick
|
||||
// up where the earlier call left off and go through all dirty components. The
|
||||
// current_component value is saved and restored so that the reentrant call will
|
||||
// not interfere with the "parent" flush() call.
|
||||
// 2. bind:this callbacks cannot trigger new flush() calls.
|
||||
// 3. During afterUpdate, any updated components will NOT have their afterUpdate
|
||||
// callback called a second time; the seen_callbacks set, outside the flush()
|
||||
// function, guarantees this behavior.
|
||||
const seen_callbacks = new Set();
|
||||
|
||||
let flushidx = 0; // Do *not* move this inside the flush() function
|
||||
|
||||
/** @returns {void} */
|
||||
export function flush() {
|
||||
// Do not reenter flush while dirty components are updated, as this can
|
||||
// result in an infinite loop. Instead, let the inner flush handle it.
|
||||
// Reentrancy is ok afterwards for bindings etc.
|
||||
if (flushidx !== 0) {
|
||||
return;
|
||||
}
|
||||
const saved_component = current_component;
|
||||
do {
|
||||
// first, call beforeUpdate functions
|
||||
// and update components
|
||||
try {
|
||||
while (flushidx < dirty_components.length) {
|
||||
const component = dirty_components[flushidx];
|
||||
flushidx++;
|
||||
set_current_component(component);
|
||||
update(component.$$);
|
||||
}
|
||||
} catch (e) {
|
||||
// reset dirty state to not end up in a deadlocked state and then rethrow
|
||||
dirty_components.length = 0;
|
||||
flushidx = 0;
|
||||
throw e;
|
||||
}
|
||||
set_current_component(null);
|
||||
dirty_components.length = 0;
|
||||
flushidx = 0;
|
||||
while (binding_callbacks.length) binding_callbacks.pop()();
|
||||
// then, once components are updated, call
|
||||
// afterUpdate functions. This may cause
|
||||
// subsequent updates...
|
||||
for (let i = 0; i < render_callbacks.length; i += 1) {
|
||||
const callback = render_callbacks[i];
|
||||
if (!seen_callbacks.has(callback)) {
|
||||
// ...so guard against infinite loops
|
||||
seen_callbacks.add(callback);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
render_callbacks.length = 0;
|
||||
} while (dirty_components.length);
|
||||
while (flush_callbacks.length) {
|
||||
flush_callbacks.pop()();
|
||||
}
|
||||
update_scheduled = false;
|
||||
seen_callbacks.clear();
|
||||
set_current_component(saved_component);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function update($$) {
|
||||
if ($$.fragment !== null) {
|
||||
$$.update();
|
||||
run_all($$.before_update);
|
||||
const dirty = $$.dirty;
|
||||
$$.dirty = [-1];
|
||||
$$.fragment && $$.fragment.p($$.ctx, dirty);
|
||||
$$.after_update.forEach(add_render_callback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`.
|
||||
* @param {Function[]} fns
|
||||
* @returns {void}
|
||||
*/
|
||||
export function flush_render_callbacks(fns) {
|
||||
const filtered = [];
|
||||
const targets = [];
|
||||
render_callbacks.forEach((c) => (fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)));
|
||||
targets.forEach((c) => c());
|
||||
render_callbacks = filtered;
|
||||
}
|
||||
35
node_modules/svelte/src/runtime/internal/spread.js
generated
vendored
Normal file
35
node_modules/svelte/src/runtime/internal/spread.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/** @returns {{}} */
|
||||
export function get_spread_update(levels, updates) {
|
||||
const update = {};
|
||||
const to_null_out = {};
|
||||
const accounted_for = { $$scope: 1 };
|
||||
let i = levels.length;
|
||||
while (i--) {
|
||||
const o = levels[i];
|
||||
const n = updates[i];
|
||||
if (n) {
|
||||
for (const key in o) {
|
||||
if (!(key in n)) to_null_out[key] = 1;
|
||||
}
|
||||
for (const key in n) {
|
||||
if (!accounted_for[key]) {
|
||||
update[key] = n[key];
|
||||
accounted_for[key] = 1;
|
||||
}
|
||||
}
|
||||
levels[i] = n;
|
||||
} else {
|
||||
for (const key in o) {
|
||||
accounted_for[key] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const key in to_null_out) {
|
||||
if (!(key in update)) update[key] = undefined;
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
export function get_spread_object(spread_props) {
|
||||
return typeof spread_props === 'object' && spread_props !== null ? spread_props : {};
|
||||
}
|
||||
99
node_modules/svelte/src/runtime/internal/style_manager.js
generated
vendored
Normal file
99
node_modules/svelte/src/runtime/internal/style_manager.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
import { append_empty_stylesheet, detach, get_root_for_style } from './dom.js';
|
||||
import { raf } from './environment.js';
|
||||
|
||||
// we need to store the information for multiple documents because a Svelte application could also contain iframes
|
||||
// https://github.com/sveltejs/svelte/issues/3624
|
||||
/** @type {Map<Document | ShadowRoot, import('./private.d.ts').StyleInformation>} */
|
||||
const managed_styles = new Map();
|
||||
|
||||
let active = 0;
|
||||
|
||||
// https://github.com/darkskyapp/string-hash/blob/master/index.js
|
||||
/**
|
||||
* @param {string} str
|
||||
* @returns {number}
|
||||
*/
|
||||
function hash(str) {
|
||||
let hash = 5381;
|
||||
let i = str.length;
|
||||
while (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
|
||||
return hash >>> 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Document | ShadowRoot} doc
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @returns {{ stylesheet: any; rules: {}; }}
|
||||
*/
|
||||
function create_style_information(doc, node) {
|
||||
const info = { stylesheet: append_empty_stylesheet(node), rules: {} };
|
||||
managed_styles.set(doc, info);
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @param {number} duration
|
||||
* @param {number} delay
|
||||
* @param {(t: number) => number} ease
|
||||
* @param {(t: number, u: number) => string} fn
|
||||
* @param {number} uid
|
||||
* @returns {string}
|
||||
*/
|
||||
export function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
|
||||
const step = 16.666 / duration;
|
||||
let keyframes = '{\n';
|
||||
for (let p = 0; p <= 1; p += step) {
|
||||
const t = a + (b - a) * ease(p);
|
||||
keyframes += p * 100 + `%{${fn(t, 1 - t)}}\n`;
|
||||
}
|
||||
const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
|
||||
const name = `__svelte_${hash(rule)}_${uid}`;
|
||||
const doc = get_root_for_style(node);
|
||||
const { stylesheet, rules } = managed_styles.get(doc) || create_style_information(doc, node);
|
||||
if (!rules[name]) {
|
||||
rules[name] = true;
|
||||
stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
|
||||
}
|
||||
const animation = node.style.animation || '';
|
||||
node.style.animation = `${
|
||||
animation ? `${animation}, ` : ''
|
||||
}${name} ${duration}ms linear ${delay}ms 1 both`;
|
||||
active += 1;
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {string} [name]
|
||||
* @returns {void}
|
||||
*/
|
||||
export function delete_rule(node, name) {
|
||||
const previous = (node.style.animation || '').split(', ');
|
||||
const next = previous.filter(
|
||||
name
|
||||
? (anim) => anim.indexOf(name) < 0 // remove specific animation
|
||||
: (anim) => anim.indexOf('__svelte') === -1 // remove all Svelte animations
|
||||
);
|
||||
const deleted = previous.length - next.length;
|
||||
if (deleted) {
|
||||
node.style.animation = next.join(', ');
|
||||
active -= deleted;
|
||||
if (!active) clear_rules();
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function clear_rules() {
|
||||
raf(() => {
|
||||
if (active) return;
|
||||
managed_styles.forEach((info) => {
|
||||
const { ownerNode } = info.stylesheet;
|
||||
// there is no ownerNode if it runs on jsdom.
|
||||
if (ownerNode) detach(ownerNode);
|
||||
});
|
||||
managed_styles.clear();
|
||||
});
|
||||
}
|
||||
461
node_modules/svelte/src/runtime/internal/transitions.js
generated
vendored
Normal file
461
node_modules/svelte/src/runtime/internal/transitions.js
generated
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
import { identity as linear, is_function, noop, run_all } from './utils.js';
|
||||
import { now } from './environment.js';
|
||||
import { loop } from './loop.js';
|
||||
import { create_rule, delete_rule } from './style_manager.js';
|
||||
import { custom_event } from './dom.js';
|
||||
import { add_render_callback } from './scheduler.js';
|
||||
|
||||
/**
|
||||
* @type {Promise<void> | null}
|
||||
*/
|
||||
let promise;
|
||||
|
||||
/**
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
function wait() {
|
||||
if (!promise) {
|
||||
promise = Promise.resolve();
|
||||
promise.then(() => {
|
||||
promise = null;
|
||||
});
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} node
|
||||
* @param {INTRO | OUTRO | boolean} direction
|
||||
* @param {'start' | 'end'} kind
|
||||
* @returns {void}
|
||||
*/
|
||||
function dispatch(node, direction, kind) {
|
||||
node.dispatchEvent(custom_event(`${direction ? 'intro' : 'outro'}${kind}`));
|
||||
}
|
||||
|
||||
const outroing = new Set();
|
||||
|
||||
/**
|
||||
* @type {Outro}
|
||||
*/
|
||||
let outros;
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
export function group_outros() {
|
||||
outros = {
|
||||
r: 0,
|
||||
c: [],
|
||||
p: outros // parent group
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
export function check_outros() {
|
||||
if (!outros.r) {
|
||||
run_all(outros.c);
|
||||
}
|
||||
outros = outros.p;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./private.js').Fragment} block
|
||||
* @param {0 | 1} [local]
|
||||
* @returns {void}
|
||||
*/
|
||||
export function transition_in(block, local) {
|
||||
if (block && block.i) {
|
||||
outroing.delete(block);
|
||||
block.i(local);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./private.js').Fragment} block
|
||||
* @param {0 | 1} local
|
||||
* @param {0 | 1} [detach]
|
||||
* @param {() => void} [callback]
|
||||
* @returns {void}
|
||||
*/
|
||||
export function transition_out(block, local, detach, callback) {
|
||||
if (block && block.o) {
|
||||
if (outroing.has(block)) return;
|
||||
outroing.add(block);
|
||||
outros.c.push(() => {
|
||||
outroing.delete(block);
|
||||
if (callback) {
|
||||
if (detach) block.d(1);
|
||||
callback();
|
||||
}
|
||||
});
|
||||
block.o(local);
|
||||
} else if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import('../transition/public.js').TransitionConfig}
|
||||
*/
|
||||
const null_transition = { duration: 0 };
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {TransitionFn} fn
|
||||
* @param {any} params
|
||||
* @returns {{ start(): void; invalidate(): void; end(): void; }}
|
||||
*/
|
||||
export function create_in_transition(node, fn, params) {
|
||||
/**
|
||||
* @type {TransitionOptions} */
|
||||
const options = { direction: 'in' };
|
||||
let config = fn(node, params, options);
|
||||
let running = false;
|
||||
let animation_name;
|
||||
let task;
|
||||
let uid = 0;
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
function cleanup() {
|
||||
if (animation_name) delete_rule(node, animation_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
function go() {
|
||||
const {
|
||||
delay = 0,
|
||||
duration = 300,
|
||||
easing = linear,
|
||||
tick = noop,
|
||||
css
|
||||
} = config || null_transition;
|
||||
if (css) animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++);
|
||||
tick(0, 1);
|
||||
const start_time = now() + delay;
|
||||
const end_time = start_time + duration;
|
||||
if (task) task.abort();
|
||||
running = true;
|
||||
add_render_callback(() => dispatch(node, true, 'start'));
|
||||
task = loop((now) => {
|
||||
if (running) {
|
||||
if (now >= end_time) {
|
||||
tick(1, 0);
|
||||
dispatch(node, true, 'end');
|
||||
cleanup();
|
||||
return (running = false);
|
||||
}
|
||||
if (now >= start_time) {
|
||||
const t = easing((now - start_time) / duration);
|
||||
tick(t, 1 - t);
|
||||
}
|
||||
}
|
||||
return running;
|
||||
});
|
||||
}
|
||||
let started = false;
|
||||
return {
|
||||
start() {
|
||||
if (started) return;
|
||||
started = true;
|
||||
delete_rule(node);
|
||||
if (is_function(config)) {
|
||||
config = config(options);
|
||||
wait().then(go);
|
||||
} else {
|
||||
go();
|
||||
}
|
||||
},
|
||||
invalidate() {
|
||||
started = false;
|
||||
},
|
||||
end() {
|
||||
if (running) {
|
||||
cleanup();
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {TransitionFn} fn
|
||||
* @param {any} params
|
||||
* @returns {{ end(reset: any): void; }}
|
||||
*/
|
||||
export function create_out_transition(node, fn, params) {
|
||||
/** @type {TransitionOptions} */
|
||||
const options = { direction: 'out' };
|
||||
let config = fn(node, params, options);
|
||||
let running = true;
|
||||
let animation_name;
|
||||
const group = outros;
|
||||
group.r += 1;
|
||||
/** @type {boolean} */
|
||||
let original_inert_value;
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
function go() {
|
||||
const {
|
||||
delay = 0,
|
||||
duration = 300,
|
||||
easing = linear,
|
||||
tick = noop,
|
||||
css
|
||||
} = config || null_transition;
|
||||
|
||||
if (css) animation_name = create_rule(node, 1, 0, duration, delay, easing, css);
|
||||
|
||||
const start_time = now() + delay;
|
||||
const end_time = start_time + duration;
|
||||
add_render_callback(() => dispatch(node, false, 'start'));
|
||||
|
||||
if ('inert' in node) {
|
||||
original_inert_value = /** @type {HTMLElement} */ (node).inert;
|
||||
node.inert = true;
|
||||
}
|
||||
|
||||
loop((now) => {
|
||||
if (running) {
|
||||
if (now >= end_time) {
|
||||
tick(0, 1);
|
||||
dispatch(node, false, 'end');
|
||||
if (!--group.r) {
|
||||
// this will result in `end()` being called,
|
||||
// so we don't need to clean up here
|
||||
run_all(group.c);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (now >= start_time) {
|
||||
const t = easing((now - start_time) / duration);
|
||||
tick(1 - t, t);
|
||||
}
|
||||
}
|
||||
return running;
|
||||
});
|
||||
}
|
||||
|
||||
if (is_function(config)) {
|
||||
wait().then(() => {
|
||||
// @ts-ignore
|
||||
config = config(options);
|
||||
go();
|
||||
});
|
||||
} else {
|
||||
go();
|
||||
}
|
||||
|
||||
return {
|
||||
end(reset) {
|
||||
if (reset && 'inert' in node) {
|
||||
node.inert = original_inert_value;
|
||||
}
|
||||
if (reset && config.tick) {
|
||||
config.tick(1, 0);
|
||||
}
|
||||
if (running) {
|
||||
if (animation_name) delete_rule(node, animation_name);
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {TransitionFn} fn
|
||||
* @param {any} params
|
||||
* @param {boolean} intro
|
||||
* @returns {{ run(b: 0 | 1): void; end(): void; }}
|
||||
*/
|
||||
export function create_bidirectional_transition(node, fn, params, intro) {
|
||||
/**
|
||||
* @type {TransitionOptions} */
|
||||
const options = { direction: 'both' };
|
||||
let config = fn(node, params, options);
|
||||
let t = intro ? 0 : 1;
|
||||
|
||||
/**
|
||||
* @type {Program | null} */
|
||||
let running_program = null;
|
||||
|
||||
/**
|
||||
* @type {PendingProgram | null} */
|
||||
let pending_program = null;
|
||||
let animation_name = null;
|
||||
|
||||
/** @type {boolean} */
|
||||
let original_inert_value;
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
function clear_animation() {
|
||||
if (animation_name) delete_rule(node, animation_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PendingProgram} program
|
||||
* @param {number} duration
|
||||
* @returns {Program}
|
||||
*/
|
||||
function init(program, duration) {
|
||||
const d = /** @type {Program['d']} */ (program.b - t);
|
||||
duration *= Math.abs(d);
|
||||
return {
|
||||
a: t,
|
||||
b: program.b,
|
||||
d,
|
||||
duration,
|
||||
start: program.start,
|
||||
end: program.start + duration,
|
||||
group: program.group
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {INTRO | OUTRO} b
|
||||
* @returns {void}
|
||||
*/
|
||||
function go(b) {
|
||||
const {
|
||||
delay = 0,
|
||||
duration = 300,
|
||||
easing = linear,
|
||||
tick = noop,
|
||||
css
|
||||
} = config || null_transition;
|
||||
|
||||
/**
|
||||
* @type {PendingProgram} */
|
||||
const program = {
|
||||
start: now() + delay,
|
||||
b
|
||||
};
|
||||
|
||||
if (!b) {
|
||||
// @ts-ignore todo: improve typings
|
||||
program.group = outros;
|
||||
outros.r += 1;
|
||||
}
|
||||
|
||||
if ('inert' in node) {
|
||||
if (b) {
|
||||
if (original_inert_value !== undefined) {
|
||||
// aborted/reversed outro — restore previous inert value
|
||||
node.inert = original_inert_value;
|
||||
}
|
||||
} else {
|
||||
original_inert_value = /** @type {HTMLElement} */ (node).inert;
|
||||
node.inert = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (running_program || pending_program) {
|
||||
pending_program = program;
|
||||
} else {
|
||||
// if this is an intro, and there's a delay, we need to do
|
||||
// an initial tick and/or apply CSS animation immediately
|
||||
if (css) {
|
||||
clear_animation();
|
||||
animation_name = create_rule(node, t, b, duration, delay, easing, css);
|
||||
}
|
||||
if (b) tick(0, 1);
|
||||
running_program = init(program, duration);
|
||||
add_render_callback(() => dispatch(node, b, 'start'));
|
||||
loop((now) => {
|
||||
if (pending_program && now > pending_program.start) {
|
||||
running_program = init(pending_program, duration);
|
||||
pending_program = null;
|
||||
dispatch(node, running_program.b, 'start');
|
||||
if (css) {
|
||||
clear_animation();
|
||||
animation_name = create_rule(
|
||||
node,
|
||||
t,
|
||||
running_program.b,
|
||||
running_program.duration,
|
||||
0,
|
||||
easing,
|
||||
config.css
|
||||
);
|
||||
}
|
||||
}
|
||||
if (running_program) {
|
||||
if (now >= running_program.end) {
|
||||
tick((t = running_program.b), 1 - t);
|
||||
dispatch(node, running_program.b, 'end');
|
||||
if (!pending_program) {
|
||||
// we're done
|
||||
if (running_program.b) {
|
||||
// intro — we can tidy up immediately
|
||||
clear_animation();
|
||||
} else {
|
||||
// outro — needs to be coordinated
|
||||
if (!--running_program.group.r) run_all(running_program.group.c);
|
||||
}
|
||||
}
|
||||
running_program = null;
|
||||
} else if (now >= running_program.start) {
|
||||
const p = now - running_program.start;
|
||||
t = running_program.a + running_program.d * easing(p / running_program.duration);
|
||||
tick(t, 1 - t);
|
||||
}
|
||||
}
|
||||
return !!(running_program || pending_program);
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
run(b) {
|
||||
if (is_function(config)) {
|
||||
wait().then(() => {
|
||||
const opts = { direction: b ? 'in' : 'out' };
|
||||
// @ts-ignore
|
||||
config = config(opts);
|
||||
go(b);
|
||||
});
|
||||
} else {
|
||||
go(b);
|
||||
}
|
||||
},
|
||||
end() {
|
||||
clear_animation();
|
||||
running_program = pending_program = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** @typedef {1} INTRO */
|
||||
/** @typedef {0} OUTRO */
|
||||
/** @typedef {{ direction: 'in' | 'out' | 'both' }} TransitionOptions */
|
||||
/** @typedef {(node: Element, params: any, options: TransitionOptions) => import('../transition/public.js').TransitionConfig} TransitionFn */
|
||||
|
||||
/**
|
||||
* @typedef {Object} Outro
|
||||
* @property {number} r
|
||||
* @property {Function[]} c
|
||||
* @property {Object} p
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} PendingProgram
|
||||
* @property {number} start
|
||||
* @property {INTRO|OUTRO} b
|
||||
* @property {Outro} [group]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} Program
|
||||
* @property {number} a
|
||||
* @property {INTRO|OUTRO} b
|
||||
* @property {1|-1} d
|
||||
* @property {number} duration
|
||||
* @property {number} start
|
||||
* @property {number} end
|
||||
* @property {Outro} [group]
|
||||
*/
|
||||
291
node_modules/svelte/src/runtime/internal/utils.js
generated
vendored
Normal file
291
node_modules/svelte/src/runtime/internal/utils.js
generated
vendored
Normal file
@@ -0,0 +1,291 @@
|
||||
/** @returns {void} */
|
||||
export function noop() {}
|
||||
|
||||
export const identity = (x) => x;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template S
|
||||
* @param {T} tar
|
||||
* @param {S} src
|
||||
* @returns {T & S}
|
||||
*/
|
||||
export function assign(tar, src) {
|
||||
// @ts-ignore
|
||||
for (const k in src) tar[k] = src[k];
|
||||
return /** @type {T & S} */ (tar);
|
||||
}
|
||||
|
||||
// Adapted from https://github.com/then/is-promise/blob/master/index.js
|
||||
// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE
|
||||
/**
|
||||
* @param {any} value
|
||||
* @returns {value is PromiseLike<any>}
|
||||
*/
|
||||
export function is_promise(value) {
|
||||
return (
|
||||
!!value &&
|
||||
(typeof value === 'object' || typeof value === 'function') &&
|
||||
typeof (/** @type {any} */ (value).then) === 'function'
|
||||
);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function add_location(element, file, line, column, char) {
|
||||
element.__svelte_meta = {
|
||||
loc: { file, line, column, char }
|
||||
};
|
||||
}
|
||||
|
||||
export function run(fn) {
|
||||
return fn();
|
||||
}
|
||||
|
||||
export function blank_object() {
|
||||
return Object.create(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function[]} fns
|
||||
* @returns {void}
|
||||
*/
|
||||
export function run_all(fns) {
|
||||
fns.forEach(run);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} thing
|
||||
* @returns {thing is Function}
|
||||
*/
|
||||
export function is_function(thing) {
|
||||
return typeof thing === 'function';
|
||||
}
|
||||
|
||||
/** @returns {boolean} */
|
||||
export function safe_not_equal(a, b) {
|
||||
return a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';
|
||||
}
|
||||
|
||||
let src_url_equal_anchor;
|
||||
|
||||
/**
|
||||
* @param {string} element_src
|
||||
* @param {string} url
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function src_url_equal(element_src, url) {
|
||||
if (element_src === url) return true;
|
||||
if (!src_url_equal_anchor) {
|
||||
src_url_equal_anchor = document.createElement('a');
|
||||
}
|
||||
// This is actually faster than doing URL(..).href
|
||||
src_url_equal_anchor.href = url;
|
||||
return element_src === src_url_equal_anchor.href;
|
||||
}
|
||||
|
||||
/** @param {string} srcset */
|
||||
function split_srcset(srcset) {
|
||||
return srcset.split(',').map((src) => src.trim().split(' ').filter(Boolean));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLSourceElement | HTMLImageElement} element_srcset
|
||||
* @param {string | undefined | null} srcset
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function srcset_url_equal(element_srcset, srcset) {
|
||||
const element_urls = split_srcset(element_srcset.srcset);
|
||||
const urls = split_srcset(srcset || '');
|
||||
|
||||
return (
|
||||
urls.length === element_urls.length &&
|
||||
urls.every(
|
||||
([url, width], i) =>
|
||||
width === element_urls[i][1] &&
|
||||
// We need to test both ways because Vite will create an a full URL with
|
||||
// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the
|
||||
// relative URLs inside srcset are not automatically resolved to absolute URLs by
|
||||
// browsers (in contrast to img.src). This means both SSR and DOM code could
|
||||
// contain relative or absolute URLs.
|
||||
(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** @returns {boolean} */
|
||||
export function not_equal(a, b) {
|
||||
return a != a ? b == b : a !== b;
|
||||
}
|
||||
|
||||
/** @returns {boolean} */
|
||||
export function is_empty(obj) {
|
||||
return Object.keys(obj).length === 0;
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function validate_store(store, name) {
|
||||
if (store != null && typeof store.subscribe !== 'function') {
|
||||
throw new Error(`'${name}' is not a store with a 'subscribe' method`);
|
||||
}
|
||||
}
|
||||
|
||||
export function subscribe(store, ...callbacks) {
|
||||
if (store == null) {
|
||||
for (const callback of callbacks) {
|
||||
callback(undefined);
|
||||
}
|
||||
return noop;
|
||||
}
|
||||
const unsub = store.subscribe(...callbacks);
|
||||
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value from a store by subscribing and immediately unsubscribing.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-store#get
|
||||
* @template T
|
||||
* @param {import('../store/public.js').Readable<T>} store
|
||||
* @returns {T}
|
||||
*/
|
||||
export function get_store_value(store) {
|
||||
let value;
|
||||
subscribe(store, (_) => (value = _))();
|
||||
return value;
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function component_subscribe(component, store, callback) {
|
||||
component.$$.on_destroy.push(subscribe(store, callback));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function get_slot_context(definition, ctx, $$scope, fn) {
|
||||
return definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;
|
||||
}
|
||||
|
||||
export function get_slot_changes(definition, $$scope, dirty, fn) {
|
||||
if (definition[2] && fn) {
|
||||
const lets = definition[2](fn(dirty));
|
||||
if ($$scope.dirty === undefined) {
|
||||
return lets;
|
||||
}
|
||||
if (typeof lets === 'object') {
|
||||
const merged = [];
|
||||
const len = Math.max($$scope.dirty.length, lets.length);
|
||||
for (let i = 0; i < len; i += 1) {
|
||||
merged[i] = $$scope.dirty[i] | lets[i];
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
return $$scope.dirty | lets;
|
||||
}
|
||||
return $$scope.dirty;
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function update_slot_base(
|
||||
slot,
|
||||
slot_definition,
|
||||
ctx,
|
||||
$$scope,
|
||||
slot_changes,
|
||||
get_slot_context_fn
|
||||
) {
|
||||
if (slot_changes) {
|
||||
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
|
||||
slot.p(slot_context, slot_changes);
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
export function update_slot(
|
||||
slot,
|
||||
slot_definition,
|
||||
ctx,
|
||||
$$scope,
|
||||
dirty,
|
||||
get_slot_changes_fn,
|
||||
get_slot_context_fn
|
||||
) {
|
||||
const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);
|
||||
update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);
|
||||
}
|
||||
|
||||
/** @returns {any[] | -1} */
|
||||
export function get_all_dirty_from_scope($$scope) {
|
||||
if ($$scope.ctx.length > 32) {
|
||||
const dirty = [];
|
||||
const length = $$scope.ctx.length / 32;
|
||||
for (let i = 0; i < length; i++) {
|
||||
dirty[i] = -1;
|
||||
}
|
||||
return dirty;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
export function exclude_internal_props(props) {
|
||||
const result = {};
|
||||
for (const k in props) if (k[0] !== '$') result[k] = props[k];
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
export function compute_rest_props(props, keys) {
|
||||
const rest = {};
|
||||
keys = new Set(keys);
|
||||
for (const k in props) if (!keys.has(k) && k[0] !== '$') rest[k] = props[k];
|
||||
return rest;
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
export function compute_slots(slots) {
|
||||
const result = {};
|
||||
for (const key in slots) {
|
||||
result[key] = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @returns {(this: any, ...args: any[]) => void} */
|
||||
export function once(fn) {
|
||||
let ran = false;
|
||||
return function (...args) {
|
||||
if (ran) return;
|
||||
ran = true;
|
||||
fn.call(this, ...args);
|
||||
};
|
||||
}
|
||||
|
||||
export function null_to_empty(value) {
|
||||
return value == null ? '' : value;
|
||||
}
|
||||
|
||||
export function set_store_value(store, ret, value) {
|
||||
store.set(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
export const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
|
||||
export function action_destroyer(action_result) {
|
||||
return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;
|
||||
}
|
||||
|
||||
/** @param {number | string} value
|
||||
* @returns {[number, string]}
|
||||
*/
|
||||
export function split_css_unit(value) {
|
||||
const split = typeof value === 'string' && value.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);
|
||||
return split ? [parseFloat(split[1]), split[2] || 'px'] : [/** @type {number} */ (value), 'px'];
|
||||
}
|
||||
|
||||
export const contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];
|
||||
199
node_modules/svelte/src/runtime/store/index.js
generated
vendored
Normal file
199
node_modules/svelte/src/runtime/store/index.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
import {
|
||||
run_all,
|
||||
subscribe,
|
||||
noop,
|
||||
safe_not_equal,
|
||||
is_function,
|
||||
get_store_value
|
||||
} from '../internal/index.js';
|
||||
|
||||
const subscriber_queue = [];
|
||||
|
||||
/**
|
||||
* Creates a `Readable` store that allows reading by subscription.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-store#readable
|
||||
* @template T
|
||||
* @param {T} [value] initial value
|
||||
* @param {import('./public.js').StartStopNotifier<T>} [start]
|
||||
* @returns {import('./public.js').Readable<T>}
|
||||
*/
|
||||
export function readable(value, start) {
|
||||
return {
|
||||
subscribe: writable(value, start).subscribe
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a `Writable` store that allows both updating and reading by subscription.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-store#writable
|
||||
* @template T
|
||||
* @param {T} [value] initial value
|
||||
* @param {import('./public.js').StartStopNotifier<T>} [start]
|
||||
* @returns {import('./public.js').Writable<T>}
|
||||
*/
|
||||
export function writable(value, start = noop) {
|
||||
/** @type {import('./public.js').Unsubscriber} */
|
||||
let stop;
|
||||
/** @type {Set<import('./private.js').SubscribeInvalidateTuple<T>>} */
|
||||
const subscribers = new Set();
|
||||
/** @param {T} new_value
|
||||
* @returns {void}
|
||||
*/
|
||||
function set(new_value) {
|
||||
if (safe_not_equal(value, new_value)) {
|
||||
value = new_value;
|
||||
if (stop) {
|
||||
// store is ready
|
||||
const run_queue = !subscriber_queue.length;
|
||||
for (const subscriber of subscribers) {
|
||||
subscriber[1]();
|
||||
subscriber_queue.push(subscriber, value);
|
||||
}
|
||||
if (run_queue) {
|
||||
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
||||
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
||||
}
|
||||
subscriber_queue.length = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./public.js').Updater<T>} fn
|
||||
* @returns {void}
|
||||
*/
|
||||
function update(fn) {
|
||||
set(fn(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./public.js').Subscriber<T>} run
|
||||
* @param {import('./private.js').Invalidator<T>} [invalidate]
|
||||
* @returns {import('./public.js').Unsubscriber}
|
||||
*/
|
||||
function subscribe(run, invalidate = noop) {
|
||||
/** @type {import('./private.js').SubscribeInvalidateTuple<T>} */
|
||||
const subscriber = [run, invalidate];
|
||||
subscribers.add(subscriber);
|
||||
if (subscribers.size === 1) {
|
||||
stop = start(set, update) || noop;
|
||||
}
|
||||
run(value);
|
||||
return () => {
|
||||
subscribers.delete(subscriber);
|
||||
if (subscribers.size === 0 && stop) {
|
||||
stop();
|
||||
stop = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return { set, update, subscribe };
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived value store by synchronizing one or more readable stores and
|
||||
* applying an aggregation function over its input values.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-store#derived
|
||||
* @template {import('./private.js').Stores} S
|
||||
* @template T
|
||||
* @overload
|
||||
* @param {S} stores - input stores
|
||||
* @param {(values: import('./private.js').StoresValues<S>, set: (value: T) => void, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values
|
||||
* @param {T} [initial_value] - initial value
|
||||
* @returns {import('./public.js').Readable<T>}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Derived value store by synchronizing one or more readable stores and
|
||||
* applying an aggregation function over its input values.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-store#derived
|
||||
* @template {import('./private.js').Stores} S
|
||||
* @template T
|
||||
* @overload
|
||||
* @param {S} stores - input stores
|
||||
* @param {(values: import('./private.js').StoresValues<S>) => T} fn - function callback that aggregates the values
|
||||
* @param {T} [initial_value] - initial value
|
||||
* @returns {import('./public.js').Readable<T>}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {import('./private.js').Stores} S
|
||||
* @template T
|
||||
* @param {S} stores
|
||||
* @param {Function} fn
|
||||
* @param {T} [initial_value]
|
||||
* @returns {import('./public.js').Readable<T>}
|
||||
*/
|
||||
export function derived(stores, fn, initial_value) {
|
||||
const single = !Array.isArray(stores);
|
||||
/** @type {Array<import('./public.js').Readable<any>>} */
|
||||
const stores_array = single ? [stores] : stores;
|
||||
if (!stores_array.every(Boolean)) {
|
||||
throw new Error('derived() expects stores as input, got a falsy value');
|
||||
}
|
||||
const auto = fn.length < 2;
|
||||
return readable(initial_value, (set, update) => {
|
||||
let started = false;
|
||||
const values = [];
|
||||
let pending = 0;
|
||||
let cleanup = noop;
|
||||
const sync = () => {
|
||||
if (pending) {
|
||||
return;
|
||||
}
|
||||
cleanup();
|
||||
const result = fn(single ? values[0] : values, set, update);
|
||||
if (auto) {
|
||||
set(result);
|
||||
} else {
|
||||
cleanup = is_function(result) ? result : noop;
|
||||
}
|
||||
};
|
||||
const unsubscribers = stores_array.map((store, i) =>
|
||||
subscribe(
|
||||
store,
|
||||
(value) => {
|
||||
values[i] = value;
|
||||
pending &= ~(1 << i);
|
||||
if (started) {
|
||||
sync();
|
||||
}
|
||||
},
|
||||
() => {
|
||||
pending |= 1 << i;
|
||||
}
|
||||
)
|
||||
);
|
||||
started = true;
|
||||
sync();
|
||||
return function stop() {
|
||||
run_all(unsubscribers);
|
||||
cleanup();
|
||||
// We need to set this to false because callbacks can still happen despite having unsubscribed:
|
||||
// Callbacks might already be placed in the queue which doesn't know it should no longer
|
||||
// invoke this derived store.
|
||||
started = false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a store and returns a new one derived from the old one that is readable.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-store#readonly
|
||||
* @template T
|
||||
* @param {import('./public.js').Readable<T>} store - store to make readonly
|
||||
* @returns {import('./public.js').Readable<T>}
|
||||
*/
|
||||
export function readonly(store) {
|
||||
return {
|
||||
subscribe: store.subscribe.bind(store)
|
||||
};
|
||||
}
|
||||
|
||||
export { get_store_value as get };
|
||||
255
node_modules/svelte/src/runtime/transition/index.js
generated
vendored
Normal file
255
node_modules/svelte/src/runtime/transition/index.js
generated
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
import { cubicOut, cubicInOut, linear } from '../easing/index.js';
|
||||
import { assign, split_css_unit, is_function } from '../internal/index.js';
|
||||
|
||||
/**
|
||||
* Animates a `blur` filter alongside an element's opacity.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-transition#blur
|
||||
* @param {Element} node
|
||||
* @param {import('./public').BlurParams} [params]
|
||||
* @returns {import('./public').TransitionConfig}
|
||||
*/
|
||||
export function blur(
|
||||
node,
|
||||
{ delay = 0, duration = 400, easing = cubicInOut, amount = 5, opacity = 0 } = {}
|
||||
) {
|
||||
const style = getComputedStyle(node);
|
||||
const target_opacity = +style.opacity;
|
||||
const f = style.filter === 'none' ? '' : style.filter;
|
||||
const od = target_opacity * (1 - opacity);
|
||||
const [value, unit] = split_css_unit(amount);
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (_t, u) => `opacity: ${target_opacity - od * u}; filter: ${f} blur(${u * value}${unit});`
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the opacity of an element from 0 to the current opacity for `in` transitions and from the current opacity to 0 for `out` transitions.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-transition#fade
|
||||
* @param {Element} node
|
||||
* @param {import('./public').FadeParams} [params]
|
||||
* @returns {import('./public').TransitionConfig}
|
||||
*/
|
||||
export function fade(node, { delay = 0, duration = 400, easing = linear } = {}) {
|
||||
const o = +getComputedStyle(node).opacity;
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (t) => `opacity: ${t * o}`
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the x and y positions and the opacity of an element. `in` transitions animate from the provided values, passed as parameters to the element's default values. `out` transitions animate from the element's default values to the provided values.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-transition#fly
|
||||
* @param {Element} node
|
||||
* @param {import('./public').FlyParams} [params]
|
||||
* @returns {import('./public').TransitionConfig}
|
||||
*/
|
||||
export function fly(
|
||||
node,
|
||||
{ delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0 } = {}
|
||||
) {
|
||||
const style = getComputedStyle(node);
|
||||
const target_opacity = +style.opacity;
|
||||
const transform = style.transform === 'none' ? '' : style.transform;
|
||||
const od = target_opacity * (1 - opacity);
|
||||
const [xValue, xUnit] = split_css_unit(x);
|
||||
const [yValue, yUnit] = split_css_unit(y);
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (t, u) => `
|
||||
transform: ${transform} translate(${(1 - t) * xValue}${xUnit}, ${(1 - t) * yValue}${yUnit});
|
||||
opacity: ${target_opacity - od * u}`
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Slides an element in and out.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-transition#slide
|
||||
* @param {Element} node
|
||||
* @param {import('./public').SlideParams} [params]
|
||||
* @returns {import('./public').TransitionConfig}
|
||||
*/
|
||||
export function slide(node, { delay = 0, duration = 400, easing = cubicOut, axis = 'y' } = {}) {
|
||||
const style = getComputedStyle(node);
|
||||
const opacity = +style.opacity;
|
||||
const primary_property = axis === 'y' ? 'height' : 'width';
|
||||
const primary_property_value = parseFloat(style[primary_property]);
|
||||
const secondary_properties = axis === 'y' ? ['top', 'bottom'] : ['left', 'right'];
|
||||
const capitalized_secondary_properties = secondary_properties.map(
|
||||
(e) => `${e[0].toUpperCase()}${e.slice(1)}`
|
||||
);
|
||||
const padding_start_value = parseFloat(style[`padding${capitalized_secondary_properties[0]}`]);
|
||||
const padding_end_value = parseFloat(style[`padding${capitalized_secondary_properties[1]}`]);
|
||||
const margin_start_value = parseFloat(style[`margin${capitalized_secondary_properties[0]}`]);
|
||||
const margin_end_value = parseFloat(style[`margin${capitalized_secondary_properties[1]}`]);
|
||||
const border_width_start_value = parseFloat(
|
||||
style[`border${capitalized_secondary_properties[0]}Width`]
|
||||
);
|
||||
const border_width_end_value = parseFloat(
|
||||
style[`border${capitalized_secondary_properties[1]}Width`]
|
||||
);
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (t) =>
|
||||
'overflow: hidden;' +
|
||||
`opacity: ${Math.min(t * 20, 1) * opacity};` +
|
||||
`${primary_property}: ${t * primary_property_value}px;` +
|
||||
`padding-${secondary_properties[0]}: ${t * padding_start_value}px;` +
|
||||
`padding-${secondary_properties[1]}: ${t * padding_end_value}px;` +
|
||||
`margin-${secondary_properties[0]}: ${t * margin_start_value}px;` +
|
||||
`margin-${secondary_properties[1]}: ${t * margin_end_value}px;` +
|
||||
`border-${secondary_properties[0]}-width: ${t * border_width_start_value}px;` +
|
||||
`border-${secondary_properties[1]}-width: ${t * border_width_end_value}px;`
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the opacity and scale of an element. `in` transitions animate from an element's current (default) values to the provided values, passed as parameters. `out` transitions animate from the provided values to an element's default values.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-transition#scale
|
||||
* @param {Element} node
|
||||
* @param {import('./public').ScaleParams} [params]
|
||||
* @returns {import('./public').TransitionConfig}
|
||||
*/
|
||||
export function scale(
|
||||
node,
|
||||
{ delay = 0, duration = 400, easing = cubicOut, start = 0, opacity = 0 } = {}
|
||||
) {
|
||||
const style = getComputedStyle(node);
|
||||
const target_opacity = +style.opacity;
|
||||
const transform = style.transform === 'none' ? '' : style.transform;
|
||||
const sd = 1 - start;
|
||||
const od = target_opacity * (1 - opacity);
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (_t, u) => `
|
||||
transform: ${transform} scale(${1 - sd * u});
|
||||
opacity: ${target_opacity - od * u}
|
||||
`
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the stroke of an SVG element, like a snake in a tube. `in` transitions begin with the path invisible and draw the path to the screen over time. `out` transitions start in a visible state and gradually erase the path. `draw` only works with elements that have a `getTotalLength` method, like `<path>` and `<polyline>`.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-transition#draw
|
||||
* @param {SVGElement & { getTotalLength(): number }} node
|
||||
* @param {import('./public').DrawParams} [params]
|
||||
* @returns {import('./public').TransitionConfig}
|
||||
*/
|
||||
export function draw(node, { delay = 0, speed, duration, easing = cubicInOut } = {}) {
|
||||
let len = node.getTotalLength();
|
||||
const style = getComputedStyle(node);
|
||||
if (style.strokeLinecap !== 'butt') {
|
||||
len += parseInt(style.strokeWidth);
|
||||
}
|
||||
if (duration === undefined) {
|
||||
if (speed === undefined) {
|
||||
duration = 800;
|
||||
} else {
|
||||
duration = len / speed;
|
||||
}
|
||||
} else if (typeof duration === 'function') {
|
||||
duration = duration(len);
|
||||
}
|
||||
return {
|
||||
delay,
|
||||
duration,
|
||||
easing,
|
||||
css: (_, u) => `
|
||||
stroke-dasharray: ${len};
|
||||
stroke-dashoffset: ${u * len};
|
||||
`
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The `crossfade` function creates a pair of [transitions](https://svelte.dev/docs#template-syntax-element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-transition#crossfade
|
||||
* @param {import('./public').CrossfadeParams & {
|
||||
* fallback?: (node: Element, params: import('./public').CrossfadeParams, intro: boolean) => import('./public').TransitionConfig;
|
||||
* }} params
|
||||
* @returns {[(node: any, params: import('./public').CrossfadeParams & { key: any; }) => () => import('./public').TransitionConfig, (node: any, params: import('./public').CrossfadeParams & { key: any; }) => () => import('./public').TransitionConfig]}
|
||||
*/
|
||||
export function crossfade({ fallback, ...defaults }) {
|
||||
/** @type {Map<any, Element>} */
|
||||
const to_receive = new Map();
|
||||
/** @type {Map<any, Element>} */
|
||||
const to_send = new Map();
|
||||
/**
|
||||
* @param {Element} from_node
|
||||
* @param {Element} node
|
||||
* @param {import('./public').CrossfadeParams} params
|
||||
* @returns {import('./public').TransitionConfig}
|
||||
*/
|
||||
function crossfade(from_node, node, params) {
|
||||
const {
|
||||
delay = 0,
|
||||
duration = (d) => Math.sqrt(d) * 30,
|
||||
easing = cubicOut
|
||||
} = assign(assign({}, defaults), params);
|
||||
const from = from_node.getBoundingClientRect();
|
||||
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);
|
||||
const transform = style.transform === 'none' ? '' : style.transform;
|
||||
const opacity = +style.opacity;
|
||||
return {
|
||||
delay,
|
||||
duration: is_function(duration) ? duration(d) : duration,
|
||||
easing,
|
||||
css: (t, u) => `
|
||||
opacity: ${t * opacity};
|
||||
transform-origin: top left;
|
||||
transform: ${transform} translate(${u * dx}px,${u * dy}px) scale(${t + (1 - t) * dw}, ${
|
||||
t + (1 - t) * dh
|
||||
});
|
||||
`
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Map<any, Element>} items
|
||||
* @param {Map<any, Element>} counterparts
|
||||
* @param {boolean} intro
|
||||
* @returns {(node: any, params: import('./public').CrossfadeParams & { key: any; }) => () => import('./public').TransitionConfig}
|
||||
*/
|
||||
function transition(items, counterparts, intro) {
|
||||
return (node, params) => {
|
||||
items.set(params.key, node);
|
||||
return () => {
|
||||
if (counterparts.has(params.key)) {
|
||||
const other_node = counterparts.get(params.key);
|
||||
counterparts.delete(params.key);
|
||||
return crossfade(other_node, node, params);
|
||||
}
|
||||
// if the node is disappearing altogether
|
||||
// (i.e. wasn't claimed by the other list)
|
||||
// then we need to supply an outro
|
||||
items.delete(params.key);
|
||||
return fallback && fallback(node, params, intro);
|
||||
};
|
||||
};
|
||||
}
|
||||
return [transition(to_send, to_receive, false), transition(to_receive, to_send, true)];
|
||||
}
|
||||
10
node_modules/svelte/src/shared/version.js
generated
vendored
Normal file
10
node_modules/svelte/src/shared/version.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// generated during release, do not modify
|
||||
|
||||
/**
|
||||
* The current version, as set in package.json.
|
||||
*
|
||||
* https://svelte.dev/docs/svelte-compiler#svelte-version
|
||||
* @type {string}
|
||||
*/
|
||||
export const VERSION = '4.2.20';
|
||||
export const PUBLIC_VERSION = '4';
|
||||
Reference in New Issue
Block a user