4401 lines
430 KiB
JavaScript
4401 lines
430 KiB
JavaScript
|
function noop() { }
|
||
|
function assign(tar, src) {
|
||
|
// @ts-ignore
|
||
|
for (const k in src)
|
||
|
tar[k] = src[k];
|
||
|
return tar;
|
||
|
}
|
||
|
function add_location(element, file, line, column, char) {
|
||
|
element.__svelte_meta = {
|
||
|
loc: { file, line, column, char }
|
||
|
};
|
||
|
}
|
||
|
function run(fn) {
|
||
|
return fn();
|
||
|
}
|
||
|
function blank_object() {
|
||
|
return Object.create(null);
|
||
|
}
|
||
|
function run_all(fns) {
|
||
|
fns.forEach(run);
|
||
|
}
|
||
|
function is_function(thing) {
|
||
|
return typeof thing === 'function';
|
||
|
}
|
||
|
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;
|
||
|
function src_url_equal(element_src, url) {
|
||
|
if (!src_url_equal_anchor) {
|
||
|
src_url_equal_anchor = document.createElement('a');
|
||
|
}
|
||
|
src_url_equal_anchor.href = url;
|
||
|
return element_src === src_url_equal_anchor.href;
|
||
|
}
|
||
|
function is_empty(obj) {
|
||
|
return Object.keys(obj).length === 0;
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM
|
||
|
// at the end of hydration without touching the remaining nodes.
|
||
|
let is_hydrating = false;
|
||
|
function start_hydrating() {
|
||
|
is_hydrating = true;
|
||
|
}
|
||
|
function end_hydrating() {
|
||
|
is_hydrating = false;
|
||
|
}
|
||
|
function upper_bound(low, high, key, value) {
|
||
|
// Return first index of value larger than input value in the range [low, high)
|
||
|
while (low < high) {
|
||
|
const mid = low + ((high - low) >> 1);
|
||
|
if (key(mid) <= value) {
|
||
|
low = mid + 1;
|
||
|
}
|
||
|
else {
|
||
|
high = mid;
|
||
|
}
|
||
|
}
|
||
|
return low;
|
||
|
}
|
||
|
function init_hydrate(target) {
|
||
|
if (target.hydrate_init)
|
||
|
return;
|
||
|
target.hydrate_init = true;
|
||
|
// We know that all children have claim_order values since the unclaimed have been detached if target is not <head>
|
||
|
let children = target.childNodes;
|
||
|
// If target is <head>, there may be children without claim_order
|
||
|
if (target.nodeName === 'HEAD') {
|
||
|
const myChildren = [];
|
||
|
for (let i = 0; i < children.length; i++) {
|
||
|
const node = children[i];
|
||
|
if (node.claim_order !== undefined) {
|
||
|
myChildren.push(node);
|
||
|
}
|
||
|
}
|
||
|
children = myChildren;
|
||
|
}
|
||
|
/*
|
||
|
* Reorder claimed children optimally.
|
||
|
* We can reorder claimed children optimally by finding the longest subsequence of
|
||
|
* nodes that are already claimed in order and only moving the rest. The longest
|
||
|
* subsequence subsequence of nodes that are claimed in order can be found by
|
||
|
* computing the longest increasing subsequence of .claim_order values.
|
||
|
*
|
||
|
* This algorithm is optimal in generating the least amount of reorder operations
|
||
|
* possible.
|
||
|
*
|
||
|
* Proof:
|
||
|
* We know that, given a set of reordering operations, the nodes that do not move
|
||
|
* always form an increasing subsequence, since they do not move among each other
|
||
|
* meaning that they must be already ordered among each other. Thus, the maximal
|
||
|
* set of nodes that do not move form a longest increasing subsequence.
|
||
|
*/
|
||
|
// Compute longest increasing subsequence
|
||
|
// m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j
|
||
|
const m = new Int32Array(children.length + 1);
|
||
|
// Predecessor indices + 1
|
||
|
const p = new Int32Array(children.length);
|
||
|
m[0] = -1;
|
||
|
let longest = 0;
|
||
|
for (let i = 0; i < children.length; i++) {
|
||
|
const current = children[i].claim_order;
|
||
|
// Find the largest subsequence length such that it ends in a value less than our current value
|
||
|
// upper_bound returns first greater value, so we subtract one
|
||
|
// with fast path for when we are on the current longest subsequence
|
||
|
const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;
|
||
|
p[i] = m[seqLen] + 1;
|
||
|
const newLen = seqLen + 1;
|
||
|
// We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.
|
||
|
m[newLen] = i;
|
||
|
longest = Math.max(newLen, longest);
|
||
|
}
|
||
|
// The longest increasing subsequence of nodes (initially reversed)
|
||
|
const lis = [];
|
||
|
// The rest of the nodes, nodes that will be moved
|
||
|
const toMove = [];
|
||
|
let last = children.length - 1;
|
||
|
for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {
|
||
|
lis.push(children[cur - 1]);
|
||
|
for (; last >= cur; last--) {
|
||
|
toMove.push(children[last]);
|
||
|
}
|
||
|
last--;
|
||
|
}
|
||
|
for (; last >= 0; last--) {
|
||
|
toMove.push(children[last]);
|
||
|
}
|
||
|
lis.reverse();
|
||
|
// We sort the nodes being moved to guarantee that their insertion order matches the claim order
|
||
|
toMove.sort((a, b) => a.claim_order - b.claim_order);
|
||
|
// Finally, we move the nodes
|
||
|
for (let i = 0, j = 0; i < toMove.length; i++) {
|
||
|
while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {
|
||
|
j++;
|
||
|
}
|
||
|
const anchor = j < lis.length ? lis[j] : null;
|
||
|
target.insertBefore(toMove[i], anchor);
|
||
|
}
|
||
|
}
|
||
|
function append_hydration(target, node) {
|
||
|
if (is_hydrating) {
|
||
|
init_hydrate(target);
|
||
|
if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentElement !== target))) {
|
||
|
target.actual_end_child = target.firstChild;
|
||
|
}
|
||
|
// Skip nodes of undefined ordering
|
||
|
while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {
|
||
|
target.actual_end_child = target.actual_end_child.nextSibling;
|
||
|
}
|
||
|
if (node !== target.actual_end_child) {
|
||
|
// We only insert if the ordering of this node should be modified or the parent node is not target
|
||
|
if (node.claim_order !== undefined || node.parentNode !== target) {
|
||
|
target.insertBefore(node, target.actual_end_child);
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
target.actual_end_child = node.nextSibling;
|
||
|
}
|
||
|
}
|
||
|
else if (node.parentNode !== target || node.nextSibling !== null) {
|
||
|
target.appendChild(node);
|
||
|
}
|
||
|
}
|
||
|
function insert_hydration(target, node, anchor) {
|
||
|
if (is_hydrating && !anchor) {
|
||
|
append_hydration(target, node);
|
||
|
}
|
||
|
else if (node.parentNode !== target || node.nextSibling != anchor) {
|
||
|
target.insertBefore(node, anchor || null);
|
||
|
}
|
||
|
}
|
||
|
function detach(node) {
|
||
|
node.parentNode.removeChild(node);
|
||
|
}
|
||
|
function element(name) {
|
||
|
return document.createElement(name);
|
||
|
}
|
||
|
function svg_element(name) {
|
||
|
return document.createElementNS('http://www.w3.org/2000/svg', name);
|
||
|
}
|
||
|
function text(data) {
|
||
|
return document.createTextNode(data);
|
||
|
}
|
||
|
function space() {
|
||
|
return text(' ');
|
||
|
}
|
||
|
function empty() {
|
||
|
return text('');
|
||
|
}
|
||
|
function listen(node, event, handler, options) {
|
||
|
node.addEventListener(event, handler, options);
|
||
|
return () => node.removeEventListener(event, handler, options);
|
||
|
}
|
||
|
function attr(node, attribute, value) {
|
||
|
if (value == null)
|
||
|
node.removeAttribute(attribute);
|
||
|
else if (node.getAttribute(attribute) !== value)
|
||
|
node.setAttribute(attribute, value);
|
||
|
}
|
||
|
function children(element) {
|
||
|
return Array.from(element.childNodes);
|
||
|
}
|
||
|
function init_claim_info(nodes) {
|
||
|
if (nodes.claim_info === undefined) {
|
||
|
nodes.claim_info = { last_index: 0, total_claimed: 0 };
|
||
|
}
|
||
|
}
|
||
|
function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {
|
||
|
// Try to find nodes in an order such that we lengthen the longest increasing subsequence
|
||
|
init_claim_info(nodes);
|
||
|
const resultNode = (() => {
|
||
|
// We first try to find an element after the previous one
|
||
|
for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {
|
||
|
const node = nodes[i];
|
||
|
if (predicate(node)) {
|
||
|
const replacement = processNode(node);
|
||
|
if (replacement === undefined) {
|
||
|
nodes.splice(i, 1);
|
||
|
}
|
||
|
else {
|
||
|
nodes[i] = replacement;
|
||
|
}
|
||
|
if (!dontUpdateLastIndex) {
|
||
|
nodes.claim_info.last_index = i;
|
||
|
}
|
||
|
return node;
|
||
|
}
|
||
|
}
|
||
|
// Otherwise, we try to find one before
|
||
|
// We iterate in reverse so that we don't go too far back
|
||
|
for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {
|
||
|
const node = nodes[i];
|
||
|
if (predicate(node)) {
|
||
|
const replacement = processNode(node);
|
||
|
if (replacement === undefined) {
|
||
|
nodes.splice(i, 1);
|
||
|
}
|
||
|
else {
|
||
|
nodes[i] = replacement;
|
||
|
}
|
||
|
if (!dontUpdateLastIndex) {
|
||
|
nodes.claim_info.last_index = i;
|
||
|
}
|
||
|
else if (replacement === undefined) {
|
||
|
// Since we spliced before the last_index, we decrease it
|
||
|
nodes.claim_info.last_index--;
|
||
|
}
|
||
|
return node;
|
||
|
}
|
||
|
}
|
||
|
// If we can't find any matching node, we create a new one
|
||
|
return createNode();
|
||
|
})();
|
||
|
resultNode.claim_order = nodes.claim_info.total_claimed;
|
||
|
nodes.claim_info.total_claimed += 1;
|
||
|
return resultNode;
|
||
|
}
|
||
|
function claim_element(nodes, name, attributes, svg) {
|
||
|
return claim_node(nodes, (node) => node.nodeName === name, (node) => {
|
||
|
const remove = [];
|
||
|
for (let j = 0; j < node.attributes.length; j++) {
|
||
|
const attribute = node.attributes[j];
|
||
|
if (!attributes[attribute.name]) {
|
||
|
remove.push(attribute.name);
|
||
|
}
|
||
|
}
|
||
|
remove.forEach(v => node.removeAttribute(v));
|
||
|
return undefined;
|
||
|
}, () => svg ? svg_element(name) : element(name));
|
||
|
}
|
||
|
function claim_text(nodes, data) {
|
||
|
return claim_node(nodes, (node) => node.nodeType === 3, (node) => {
|
||
|
const dataStr = '' + data;
|
||
|
if (node.data.startsWith(dataStr)) {
|
||
|
if (node.data.length !== dataStr.length) {
|
||
|
return node.splitText(dataStr.length);
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
node.data = dataStr;
|
||
|
}
|
||
|
}, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements
|
||
|
);
|
||
|
}
|
||
|
function claim_space(nodes) {
|
||
|
return claim_text(nodes, ' ');
|
||
|
}
|
||
|
function custom_event(type, detail, bubbles = false) {
|
||
|
const e = document.createEvent('CustomEvent');
|
||
|
e.initCustomEvent(type, bubbles, false, detail);
|
||
|
return e;
|
||
|
}
|
||
|
function query_selector_all(selector, parent = document.body) {
|
||
|
return Array.from(parent.querySelectorAll(selector));
|
||
|
}
|
||
|
|
||
|
let current_component;
|
||
|
function set_current_component(component) {
|
||
|
current_component = component;
|
||
|
}
|
||
|
function get_current_component() {
|
||
|
if (!current_component)
|
||
|
throw new Error('Function called outside component initialization');
|
||
|
return current_component;
|
||
|
}
|
||
|
function onMount(fn) {
|
||
|
get_current_component().$$.on_mount.push(fn);
|
||
|
}
|
||
|
function afterUpdate(fn) {
|
||
|
get_current_component().$$.after_update.push(fn);
|
||
|
}
|
||
|
function createEventDispatcher() {
|
||
|
const component = get_current_component();
|
||
|
return (type, detail) => {
|
||
|
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, detail);
|
||
|
callbacks.slice().forEach(fn => {
|
||
|
fn.call(component, event);
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
function setContext(key, context) {
|
||
|
get_current_component().$$.context.set(key, context);
|
||
|
}
|
||
|
|
||
|
const dirty_components = [];
|
||
|
const binding_callbacks = [];
|
||
|
const render_callbacks = [];
|
||
|
const flush_callbacks = [];
|
||
|
const resolved_promise = Promise.resolve();
|
||
|
let update_scheduled = false;
|
||
|
function schedule_update() {
|
||
|
if (!update_scheduled) {
|
||
|
update_scheduled = true;
|
||
|
resolved_promise.then(flush);
|
||
|
}
|
||
|
}
|
||
|
function add_render_callback(fn) {
|
||
|
render_callbacks.push(fn);
|
||
|
}
|
||
|
let flushing = false;
|
||
|
const seen_callbacks = new Set();
|
||
|
function flush() {
|
||
|
if (flushing)
|
||
|
return;
|
||
|
flushing = true;
|
||
|
do {
|
||
|
// first, call beforeUpdate functions
|
||
|
// and update components
|
||
|
for (let i = 0; i < dirty_components.length; i += 1) {
|
||
|
const component = dirty_components[i];
|
||
|
set_current_component(component);
|
||
|
update(component.$$);
|
||
|
}
|
||
|
set_current_component(null);
|
||
|
dirty_components.length = 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;
|
||
|
flushing = false;
|
||
|
seen_callbacks.clear();
|
||
|
}
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
const outroing = new Set();
|
||
|
let outros;
|
||
|
function group_outros() {
|
||
|
outros = {
|
||
|
r: 0,
|
||
|
c: [],
|
||
|
p: outros // parent group
|
||
|
};
|
||
|
}
|
||
|
function check_outros() {
|
||
|
if (!outros.r) {
|
||
|
run_all(outros.c);
|
||
|
}
|
||
|
outros = outros.p;
|
||
|
}
|
||
|
function transition_in(block, local) {
|
||
|
if (block && block.i) {
|
||
|
outroing.delete(block);
|
||
|
block.i(local);
|
||
|
}
|
||
|
}
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const globals = (typeof window !== 'undefined'
|
||
|
? window
|
||
|
: typeof globalThis !== 'undefined'
|
||
|
? globalThis
|
||
|
: global);
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
function get_spread_object(spread_props) {
|
||
|
return typeof spread_props === 'object' && spread_props !== null ? spread_props : {};
|
||
|
}
|
||
|
function create_component(block) {
|
||
|
block && block.c();
|
||
|
}
|
||
|
function claim_component(block, parent_nodes) {
|
||
|
block && block.l(parent_nodes);
|
||
|
}
|
||
|
function mount_component(component, target, anchor, customElement) {
|
||
|
const { fragment, on_mount, on_destroy, after_update } = component.$$;
|
||
|
fragment && fragment.m(target, anchor);
|
||
|
if (!customElement) {
|
||
|
// onMount happens before the initial afterUpdate
|
||
|
add_render_callback(() => {
|
||
|
const new_on_destroy = on_mount.map(run).filter(is_function);
|
||
|
if (on_destroy) {
|
||
|
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);
|
||
|
}
|
||
|
function destroy_component(component, detaching) {
|
||
|
const $$ = component.$$;
|
||
|
if ($$.fragment !== null) {
|
||
|
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 = [];
|
||
|
}
|
||
|
}
|
||
|
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));
|
||
|
}
|
||
|
function init$1(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {
|
||
|
const parent_component = current_component;
|
||
|
set_current_component(component);
|
||
|
const $$ = component.$$ = {
|
||
|
fragment: null,
|
||
|
ctx: null,
|
||
|
// state
|
||
|
props,
|
||
|
update: noop,
|
||
|
not_equal,
|
||
|
bound: blank_object(),
|
||
|
// lifecycle
|
||
|
on_mount: [],
|
||
|
on_destroy: [],
|
||
|
on_disconnect: [],
|
||
|
before_update: [],
|
||
|
after_update: [],
|
||
|
context: new Map(parent_component ? parent_component.$$.context : options.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();
|
||
|
const nodes = children(options.target);
|
||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||
|
$$.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, options.customElement);
|
||
|
end_hydrating();
|
||
|
flush();
|
||
|
}
|
||
|
set_current_component(parent_component);
|
||
|
}
|
||
|
/**
|
||
|
* Base class for Svelte components. Used when dev=false.
|
||
|
*/
|
||
|
class SvelteComponent {
|
||
|
$destroy() {
|
||
|
destroy_component(this, 1);
|
||
|
this.$destroy = noop;
|
||
|
}
|
||
|
$on(type, callback) {
|
||
|
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
|
||
|
callbacks.push(callback);
|
||
|
return () => {
|
||
|
const index = callbacks.indexOf(callback);
|
||
|
if (index !== -1)
|
||
|
callbacks.splice(index, 1);
|
||
|
};
|
||
|
}
|
||
|
$set($$props) {
|
||
|
if (this.$$set && !is_empty($$props)) {
|
||
|
this.$$.skip_bound = true;
|
||
|
this.$$set($$props);
|
||
|
this.$$.skip_bound = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function dispatch_dev(type, detail) {
|
||
|
document.dispatchEvent(custom_event(type, Object.assign({ version: '3.42.1' }, detail), true));
|
||
|
}
|
||
|
function append_hydration_dev(target, node) {
|
||
|
dispatch_dev('SvelteDOMInsert', { target, node });
|
||
|
append_hydration(target, node);
|
||
|
}
|
||
|
function insert_hydration_dev(target, node, anchor) {
|
||
|
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
||
|
insert_hydration(target, node, anchor);
|
||
|
}
|
||
|
function detach_dev(node) {
|
||
|
dispatch_dev('SvelteDOMRemove', { node });
|
||
|
detach(node);
|
||
|
}
|
||
|
function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {
|
||
|
const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : [];
|
||
|
if (has_prevent_default)
|
||
|
modifiers.push('preventDefault');
|
||
|
if (has_stop_propagation)
|
||
|
modifiers.push('stopPropagation');
|
||
|
dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers });
|
||
|
const dispose = listen(node, event, handler, options);
|
||
|
return () => {
|
||
|
dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers });
|
||
|
dispose();
|
||
|
};
|
||
|
}
|
||
|
function attr_dev(node, attribute, value) {
|
||
|
attr(node, attribute, value);
|
||
|
if (value == null)
|
||
|
dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
|
||
|
else
|
||
|
dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
|
||
|
}
|
||
|
function set_data_dev(text, data) {
|
||
|
data = '' + data;
|
||
|
if (text.wholeText === data)
|
||
|
return;
|
||
|
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||
|
text.data = data;
|
||
|
}
|
||
|
function validate_slots(name, slot, keys) {
|
||
|
for (const slot_key of Object.keys(slot)) {
|
||
|
if (!~keys.indexOf(slot_key)) {
|
||
|
console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
/**
|
||
|
* Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
|
||
|
*/
|
||
|
class SvelteComponentDev extends SvelteComponent {
|
||
|
constructor(options) {
|
||
|
if (!options || (!options.target && !options.$$inline)) {
|
||
|
throw new Error("'target' is a required option");
|
||
|
}
|
||
|
super();
|
||
|
}
|
||
|
$destroy() {
|
||
|
super.$destroy();
|
||
|
this.$destroy = () => {
|
||
|
console.warn('Component was already destroyed'); // eslint-disable-line no-console
|
||
|
};
|
||
|
}
|
||
|
$capture_state() { }
|
||
|
$inject_state() { }
|
||
|
}
|
||
|
|
||
|
const subscriber_queue = [];
|
||
|
/**
|
||
|
* Create a `Writable` store that allows both updating and reading by subscription.
|
||
|
* @param {*=}value initial value
|
||
|
* @param {StartStopNotifier=}start start and stop notifications for subscriptions
|
||
|
*/
|
||
|
function writable(value, start = noop) {
|
||
|
let stop;
|
||
|
const subscribers = new Set();
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function update(fn) {
|
||
|
set(fn(value));
|
||
|
}
|
||
|
function subscribe(run, invalidate = noop) {
|
||
|
const subscriber = [run, invalidate];
|
||
|
subscribers.add(subscriber);
|
||
|
if (subscribers.size === 1) {
|
||
|
stop = start(set) || noop;
|
||
|
}
|
||
|
run(value);
|
||
|
return () => {
|
||
|
subscribers.delete(subscriber);
|
||
|
if (subscribers.size === 0) {
|
||
|
stop();
|
||
|
stop = null;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
return { set, update, subscribe };
|
||
|
}
|
||
|
|
||
|
const CONTEXT_KEY = {};
|
||
|
|
||
|
/* src/components/Button.svelte generated by Svelte v3.42.1 */
|
||
|
const file$4 = "src/components/Button.svelte";
|
||
|
|
||
|
function create_fragment$5(ctx) {
|
||
|
let button;
|
||
|
let t;
|
||
|
let button_class_value;
|
||
|
let mounted;
|
||
|
let dispose;
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
button = element("button");
|
||
|
t = text(/*label*/ ctx[1]);
|
||
|
this.h();
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
button = claim_element(nodes, "BUTTON", { type: true, class: true, style: true });
|
||
|
var button_nodes = children(button);
|
||
|
t = claim_text(button_nodes, /*label*/ ctx[1]);
|
||
|
button_nodes.forEach(detach_dev);
|
||
|
this.h();
|
||
|
},
|
||
|
h: function hydrate() {
|
||
|
attr_dev(button, "type", "button");
|
||
|
|
||
|
attr_dev(button, "class", button_class_value = [
|
||
|
'storybook-button',
|
||
|
`storybook-button--${/*size*/ ctx[0]}`,
|
||
|
/*mode*/ ctx[2]
|
||
|
].join(' '));
|
||
|
|
||
|
attr_dev(button, "style", /*style*/ ctx[3]);
|
||
|
add_location(button, file$4, 35, 0, 717);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
insert_hydration_dev(target, button, anchor);
|
||
|
append_hydration_dev(button, t);
|
||
|
|
||
|
if (!mounted) {
|
||
|
dispose = listen_dev(button, "click", /*onClick*/ ctx[4], false, false, false);
|
||
|
mounted = true;
|
||
|
}
|
||
|
},
|
||
|
p: function update(ctx, [dirty]) {
|
||
|
if (dirty & /*label*/ 2) set_data_dev(t, /*label*/ ctx[1]);
|
||
|
|
||
|
if (dirty & /*size*/ 1 && button_class_value !== (button_class_value = [
|
||
|
'storybook-button',
|
||
|
`storybook-button--${/*size*/ ctx[0]}`,
|
||
|
/*mode*/ ctx[2]
|
||
|
].join(' '))) {
|
||
|
attr_dev(button, "class", button_class_value);
|
||
|
}
|
||
|
},
|
||
|
i: noop,
|
||
|
o: noop,
|
||
|
d: function destroy(detaching) {
|
||
|
if (detaching) detach_dev(button);
|
||
|
mounted = false;
|
||
|
dispose();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_fragment$5.name,
|
||
|
type: "component",
|
||
|
source: "",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function instance$5($$self, $$props, $$invalidate) {
|
||
|
let { $$slots: slots = {}, $$scope } = $$props;
|
||
|
validate_slots('Button', slots, []);
|
||
|
let { primary = false } = $$props;
|
||
|
let { backgroundColor } = $$props;
|
||
|
let { size = 'medium' } = $$props;
|
||
|
let { label = '' } = $$props;
|
||
|
|
||
|
let mode = primary
|
||
|
? 'storybook-button--primary'
|
||
|
: 'storybook-button--secondary';
|
||
|
|
||
|
let style = backgroundColor
|
||
|
? `background-color: ${backgroundColor}`
|
||
|
: '';
|
||
|
|
||
|
const dispatch = createEventDispatcher();
|
||
|
|
||
|
/**
|
||
|
* Optional click handler
|
||
|
*/
|
||
|
function onClick(event) {
|
||
|
dispatch('click', event);
|
||
|
}
|
||
|
|
||
|
const writable_props = ['primary', 'backgroundColor', 'size', 'label'];
|
||
|
|
||
|
Object.keys($$props).forEach(key => {
|
||
|
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<Button> was created with unknown prop '${key}'`);
|
||
|
});
|
||
|
|
||
|
$$self.$$set = $$props => {
|
||
|
if ('primary' in $$props) $$invalidate(5, primary = $$props.primary);
|
||
|
if ('backgroundColor' in $$props) $$invalidate(6, backgroundColor = $$props.backgroundColor);
|
||
|
if ('size' in $$props) $$invalidate(0, size = $$props.size);
|
||
|
if ('label' in $$props) $$invalidate(1, label = $$props.label);
|
||
|
};
|
||
|
|
||
|
$$self.$capture_state = () => ({
|
||
|
createEventDispatcher,
|
||
|
primary,
|
||
|
backgroundColor,
|
||
|
size,
|
||
|
label,
|
||
|
mode,
|
||
|
style,
|
||
|
dispatch,
|
||
|
onClick
|
||
|
});
|
||
|
|
||
|
$$self.$inject_state = $$props => {
|
||
|
if ('primary' in $$props) $$invalidate(5, primary = $$props.primary);
|
||
|
if ('backgroundColor' in $$props) $$invalidate(6, backgroundColor = $$props.backgroundColor);
|
||
|
if ('size' in $$props) $$invalidate(0, size = $$props.size);
|
||
|
if ('label' in $$props) $$invalidate(1, label = $$props.label);
|
||
|
if ('mode' in $$props) $$invalidate(2, mode = $$props.mode);
|
||
|
if ('style' in $$props) $$invalidate(3, style = $$props.style);
|
||
|
};
|
||
|
|
||
|
if ($$props && "$$inject" in $$props) {
|
||
|
$$self.$inject_state($$props.$$inject);
|
||
|
}
|
||
|
|
||
|
return [size, label, mode, style, onClick, primary, backgroundColor];
|
||
|
}
|
||
|
|
||
|
class Button extends SvelteComponentDev {
|
||
|
constructor(options) {
|
||
|
super(options);
|
||
|
|
||
|
init$1(this, options, instance$5, create_fragment$5, safe_not_equal, {
|
||
|
primary: 5,
|
||
|
backgroundColor: 6,
|
||
|
size: 0,
|
||
|
label: 1
|
||
|
});
|
||
|
|
||
|
dispatch_dev("SvelteRegisterComponent", {
|
||
|
component: this,
|
||
|
tagName: "Button",
|
||
|
options,
|
||
|
id: create_fragment$5.name
|
||
|
});
|
||
|
|
||
|
const { ctx } = this.$$;
|
||
|
const props = options.props || {};
|
||
|
|
||
|
if (/*backgroundColor*/ ctx[6] === undefined && !('backgroundColor' in props)) {
|
||
|
console.warn("<Button> was created without expected prop 'backgroundColor'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
get primary() {
|
||
|
throw new Error("<Button>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set primary(value) {
|
||
|
throw new Error("<Button>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get backgroundColor() {
|
||
|
throw new Error("<Button>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set backgroundColor(value) {
|
||
|
throw new Error("<Button>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get size() {
|
||
|
throw new Error("<Button>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set size(value) {
|
||
|
throw new Error("<Button>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get label() {
|
||
|
throw new Error("<Button>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set label(value) {
|
||
|
throw new Error("<Button>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* src/components/Image.svelte generated by Svelte v3.42.1 */
|
||
|
const file$3 = "src/components/Image.svelte";
|
||
|
|
||
|
function create_fragment$4(ctx) {
|
||
|
let img;
|
||
|
let img_class_value;
|
||
|
let img_src_value;
|
||
|
let mounted;
|
||
|
let dispose;
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
img = element("img");
|
||
|
this.h();
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
img = claim_element(nodes, "IMG", {
|
||
|
type: true,
|
||
|
class: true,
|
||
|
style: true,
|
||
|
src: true,
|
||
|
alt: true
|
||
|
});
|
||
|
|
||
|
this.h();
|
||
|
},
|
||
|
h: function hydrate() {
|
||
|
attr_dev(img, "type", "button");
|
||
|
attr_dev(img, "class", img_class_value = ['storybook-icon', `storybook-icon--${/*size*/ ctx[0]}`].join(' '));
|
||
|
attr_dev(img, "style", /*style*/ ctx[3]);
|
||
|
if (!src_url_equal(img.src, img_src_value = /*src*/ ctx[1])) attr_dev(img, "src", img_src_value);
|
||
|
attr_dev(img, "alt", /*alt*/ ctx[2]);
|
||
|
add_location(img, file$3, 25, 0, 473);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
insert_hydration_dev(target, img, anchor);
|
||
|
|
||
|
if (!mounted) {
|
||
|
dispose = listen_dev(img, "click", /*onClick*/ ctx[4], false, false, false);
|
||
|
mounted = true;
|
||
|
}
|
||
|
},
|
||
|
p: function update(ctx, [dirty]) {
|
||
|
if (dirty & /*size*/ 1 && img_class_value !== (img_class_value = ['storybook-icon', `storybook-icon--${/*size*/ ctx[0]}`].join(' '))) {
|
||
|
attr_dev(img, "class", img_class_value);
|
||
|
}
|
||
|
|
||
|
if (dirty & /*src*/ 2 && !src_url_equal(img.src, img_src_value = /*src*/ ctx[1])) {
|
||
|
attr_dev(img, "src", img_src_value);
|
||
|
}
|
||
|
|
||
|
if (dirty & /*alt*/ 4) {
|
||
|
attr_dev(img, "alt", /*alt*/ ctx[2]);
|
||
|
}
|
||
|
},
|
||
|
i: noop,
|
||
|
o: noop,
|
||
|
d: function destroy(detaching) {
|
||
|
if (detaching) detach_dev(img);
|
||
|
mounted = false;
|
||
|
dispose();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_fragment$4.name,
|
||
|
type: "component",
|
||
|
source: "",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function instance$4($$self, $$props, $$invalidate) {
|
||
|
let { $$slots: slots = {}, $$scope } = $$props;
|
||
|
validate_slots('Image', slots, []);
|
||
|
let { backgroundColor } = $$props;
|
||
|
let { size = 'small' } = $$props;
|
||
|
let { src = '' } = $$props;
|
||
|
let { alt = '' } = $$props;
|
||
|
|
||
|
let style = backgroundColor
|
||
|
? `background-color: ${backgroundColor}`
|
||
|
: '';
|
||
|
|
||
|
const dispatch = createEventDispatcher();
|
||
|
|
||
|
/**
|
||
|
* Optional click handler
|
||
|
*/
|
||
|
function onClick(event) {
|
||
|
dispatch('click', event);
|
||
|
}
|
||
|
|
||
|
const writable_props = ['backgroundColor', 'size', 'src', 'alt'];
|
||
|
|
||
|
Object.keys($$props).forEach(key => {
|
||
|
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<Image> was created with unknown prop '${key}'`);
|
||
|
});
|
||
|
|
||
|
$$self.$$set = $$props => {
|
||
|
if ('backgroundColor' in $$props) $$invalidate(5, backgroundColor = $$props.backgroundColor);
|
||
|
if ('size' in $$props) $$invalidate(0, size = $$props.size);
|
||
|
if ('src' in $$props) $$invalidate(1, src = $$props.src);
|
||
|
if ('alt' in $$props) $$invalidate(2, alt = $$props.alt);
|
||
|
};
|
||
|
|
||
|
$$self.$capture_state = () => ({
|
||
|
createEventDispatcher,
|
||
|
backgroundColor,
|
||
|
size,
|
||
|
src,
|
||
|
alt,
|
||
|
style,
|
||
|
dispatch,
|
||
|
onClick
|
||
|
});
|
||
|
|
||
|
$$self.$inject_state = $$props => {
|
||
|
if ('backgroundColor' in $$props) $$invalidate(5, backgroundColor = $$props.backgroundColor);
|
||
|
if ('size' in $$props) $$invalidate(0, size = $$props.size);
|
||
|
if ('src' in $$props) $$invalidate(1, src = $$props.src);
|
||
|
if ('alt' in $$props) $$invalidate(2, alt = $$props.alt);
|
||
|
if ('style' in $$props) $$invalidate(3, style = $$props.style);
|
||
|
};
|
||
|
|
||
|
if ($$props && "$$inject" in $$props) {
|
||
|
$$self.$inject_state($$props.$$inject);
|
||
|
}
|
||
|
|
||
|
return [size, src, alt, style, onClick, backgroundColor];
|
||
|
}
|
||
|
|
||
|
class Image extends SvelteComponentDev {
|
||
|
constructor(options) {
|
||
|
super(options);
|
||
|
|
||
|
init$1(this, options, instance$4, create_fragment$4, safe_not_equal, {
|
||
|
backgroundColor: 5,
|
||
|
size: 0,
|
||
|
src: 1,
|
||
|
alt: 2
|
||
|
});
|
||
|
|
||
|
dispatch_dev("SvelteRegisterComponent", {
|
||
|
component: this,
|
||
|
tagName: "Image",
|
||
|
options,
|
||
|
id: create_fragment$4.name
|
||
|
});
|
||
|
|
||
|
const { ctx } = this.$$;
|
||
|
const props = options.props || {};
|
||
|
|
||
|
if (/*backgroundColor*/ ctx[5] === undefined && !('backgroundColor' in props)) {
|
||
|
console.warn("<Image> was created without expected prop 'backgroundColor'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
get backgroundColor() {
|
||
|
throw new Error("<Image>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set backgroundColor(value) {
|
||
|
throw new Error("<Image>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get size() {
|
||
|
throw new Error("<Image>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set size(value) {
|
||
|
throw new Error("<Image>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get src() {
|
||
|
throw new Error("<Image>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set src(value) {
|
||
|
throw new Error("<Image>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get alt() {
|
||
|
throw new Error("<Image>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set alt(value) {
|
||
|
throw new Error("<Image>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var bind = function bind(fn, thisArg) {
|
||
|
return function wrap() {
|
||
|
var args = new Array(arguments.length);
|
||
|
for (var i = 0; i < args.length; i++) {
|
||
|
args[i] = arguments[i];
|
||
|
}
|
||
|
return fn.apply(thisArg, args);
|
||
|
};
|
||
|
};
|
||
|
|
||
|
/*global toString:true*/
|
||
|
|
||
|
// utils is a library of generic helper functions non-specific to axios
|
||
|
|
||
|
var toString = Object.prototype.toString;
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is an Array
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is an Array, otherwise false
|
||
|
*/
|
||
|
function isArray(val) {
|
||
|
return toString.call(val) === '[object Array]';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is undefined
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if the value is undefined, otherwise false
|
||
|
*/
|
||
|
function isUndefined(val) {
|
||
|
return typeof val === 'undefined';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a Buffer
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a Buffer, otherwise false
|
||
|
*/
|
||
|
function isBuffer(val) {
|
||
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
||
|
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is an ArrayBuffer
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
||
|
*/
|
||
|
function isArrayBuffer(val) {
|
||
|
return toString.call(val) === '[object ArrayBuffer]';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a FormData
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is an FormData, otherwise false
|
||
|
*/
|
||
|
function isFormData(val) {
|
||
|
return (typeof FormData !== 'undefined') && (val instanceof FormData);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a view on an ArrayBuffer
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
||
|
*/
|
||
|
function isArrayBufferView(val) {
|
||
|
var result;
|
||
|
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
||
|
result = ArrayBuffer.isView(val);
|
||
|
} else {
|
||
|
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a String
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a String, otherwise false
|
||
|
*/
|
||
|
function isString(val) {
|
||
|
return typeof val === 'string';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a Number
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a Number, otherwise false
|
||
|
*/
|
||
|
function isNumber(val) {
|
||
|
return typeof val === 'number';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is an Object
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is an Object, otherwise false
|
||
|
*/
|
||
|
function isObject(val) {
|
||
|
return val !== null && typeof val === 'object';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a plain Object
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @return {boolean} True if value is a plain Object, otherwise false
|
||
|
*/
|
||
|
function isPlainObject(val) {
|
||
|
if (toString.call(val) !== '[object Object]') {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var prototype = Object.getPrototypeOf(val);
|
||
|
return prototype === null || prototype === Object.prototype;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a Date
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a Date, otherwise false
|
||
|
*/
|
||
|
function isDate(val) {
|
||
|
return toString.call(val) === '[object Date]';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a File
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a File, otherwise false
|
||
|
*/
|
||
|
function isFile(val) {
|
||
|
return toString.call(val) === '[object File]';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a Blob
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a Blob, otherwise false
|
||
|
*/
|
||
|
function isBlob(val) {
|
||
|
return toString.call(val) === '[object Blob]';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a Function
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a Function, otherwise false
|
||
|
*/
|
||
|
function isFunction(val) {
|
||
|
return toString.call(val) === '[object Function]';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a Stream
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a Stream, otherwise false
|
||
|
*/
|
||
|
function isStream(val) {
|
||
|
return isObject(val) && isFunction(val.pipe);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if a value is a URLSearchParams object
|
||
|
*
|
||
|
* @param {Object} val The value to test
|
||
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
||
|
*/
|
||
|
function isURLSearchParams(val) {
|
||
|
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Trim excess whitespace off the beginning and end of a string
|
||
|
*
|
||
|
* @param {String} str The String to trim
|
||
|
* @returns {String} The String freed of excess whitespace
|
||
|
*/
|
||
|
function trim(str) {
|
||
|
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Determine if we're running in a standard browser environment
|
||
|
*
|
||
|
* This allows axios to run in a web worker, and react-native.
|
||
|
* Both environments support XMLHttpRequest, but not fully standard globals.
|
||
|
*
|
||
|
* web workers:
|
||
|
* typeof window -> undefined
|
||
|
* typeof document -> undefined
|
||
|
*
|
||
|
* react-native:
|
||
|
* navigator.product -> 'ReactNative'
|
||
|
* nativescript
|
||
|
* navigator.product -> 'NativeScript' or 'NS'
|
||
|
*/
|
||
|
function isStandardBrowserEnv() {
|
||
|
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
|
||
|
navigator.product === 'NativeScript' ||
|
||
|
navigator.product === 'NS')) {
|
||
|
return false;
|
||
|
}
|
||
|
return (
|
||
|
typeof window !== 'undefined' &&
|
||
|
typeof document !== 'undefined'
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Iterate over an Array or an Object invoking a function for each item.
|
||
|
*
|
||
|
* If `obj` is an Array callback will be called passing
|
||
|
* the value, index, and complete array for each item.
|
||
|
*
|
||
|
* If 'obj' is an Object callback will be called passing
|
||
|
* the value, key, and complete object for each property.
|
||
|
*
|
||
|
* @param {Object|Array} obj The object to iterate
|
||
|
* @param {Function} fn The callback to invoke for each item
|
||
|
*/
|
||
|
function forEach(obj, fn) {
|
||
|
// Don't bother if no value provided
|
||
|
if (obj === null || typeof obj === 'undefined') {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// Force an array if not already something iterable
|
||
|
if (typeof obj !== 'object') {
|
||
|
/*eslint no-param-reassign:0*/
|
||
|
obj = [obj];
|
||
|
}
|
||
|
|
||
|
if (isArray(obj)) {
|
||
|
// Iterate over array values
|
||
|
for (var i = 0, l = obj.length; i < l; i++) {
|
||
|
fn.call(null, obj[i], i, obj);
|
||
|
}
|
||
|
} else {
|
||
|
// Iterate over object keys
|
||
|
for (var key in obj) {
|
||
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||
|
fn.call(null, obj[key], key, obj);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Accepts varargs expecting each argument to be an object, then
|
||
|
* immutably merges the properties of each object and returns result.
|
||
|
*
|
||
|
* When multiple objects contain the same key the later object in
|
||
|
* the arguments list will take precedence.
|
||
|
*
|
||
|
* Example:
|
||
|
*
|
||
|
* ```js
|
||
|
* var result = merge({foo: 123}, {foo: 456});
|
||
|
* console.log(result.foo); // outputs 456
|
||
|
* ```
|
||
|
*
|
||
|
* @param {Object} obj1 Object to merge
|
||
|
* @returns {Object} Result of all merge properties
|
||
|
*/
|
||
|
function merge(/* obj1, obj2, obj3, ... */) {
|
||
|
var result = {};
|
||
|
function assignValue(val, key) {
|
||
|
if (isPlainObject(result[key]) && isPlainObject(val)) {
|
||
|
result[key] = merge(result[key], val);
|
||
|
} else if (isPlainObject(val)) {
|
||
|
result[key] = merge({}, val);
|
||
|
} else if (isArray(val)) {
|
||
|
result[key] = val.slice();
|
||
|
} else {
|
||
|
result[key] = val;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for (var i = 0, l = arguments.length; i < l; i++) {
|
||
|
forEach(arguments[i], assignValue);
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Extends object a by mutably adding to it the properties of object b.
|
||
|
*
|
||
|
* @param {Object} a The object to be extended
|
||
|
* @param {Object} b The object to copy properties from
|
||
|
* @param {Object} thisArg The object to bind function to
|
||
|
* @return {Object} The resulting value of object a
|
||
|
*/
|
||
|
function extend(a, b, thisArg) {
|
||
|
forEach(b, function assignValue(val, key) {
|
||
|
if (thisArg && typeof val === 'function') {
|
||
|
a[key] = bind(val, thisArg);
|
||
|
} else {
|
||
|
a[key] = val;
|
||
|
}
|
||
|
});
|
||
|
return a;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
||
|
*
|
||
|
* @param {string} content with BOM
|
||
|
* @return {string} content value without BOM
|
||
|
*/
|
||
|
function stripBOM(content) {
|
||
|
if (content.charCodeAt(0) === 0xFEFF) {
|
||
|
content = content.slice(1);
|
||
|
}
|
||
|
return content;
|
||
|
}
|
||
|
|
||
|
var utils = {
|
||
|
isArray: isArray,
|
||
|
isArrayBuffer: isArrayBuffer,
|
||
|
isBuffer: isBuffer,
|
||
|
isFormData: isFormData,
|
||
|
isArrayBufferView: isArrayBufferView,
|
||
|
isString: isString,
|
||
|
isNumber: isNumber,
|
||
|
isObject: isObject,
|
||
|
isPlainObject: isPlainObject,
|
||
|
isUndefined: isUndefined,
|
||
|
isDate: isDate,
|
||
|
isFile: isFile,
|
||
|
isBlob: isBlob,
|
||
|
isFunction: isFunction,
|
||
|
isStream: isStream,
|
||
|
isURLSearchParams: isURLSearchParams,
|
||
|
isStandardBrowserEnv: isStandardBrowserEnv,
|
||
|
forEach: forEach,
|
||
|
merge: merge,
|
||
|
extend: extend,
|
||
|
trim: trim,
|
||
|
stripBOM: stripBOM
|
||
|
};
|
||
|
|
||
|
function encode(val) {
|
||
|
return encodeURIComponent(val).
|
||
|
replace(/%3A/gi, ':').
|
||
|
replace(/%24/g, '$').
|
||
|
replace(/%2C/gi, ',').
|
||
|
replace(/%20/g, '+').
|
||
|
replace(/%5B/gi, '[').
|
||
|
replace(/%5D/gi, ']');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Build a URL by appending params to the end
|
||
|
*
|
||
|
* @param {string} url The base of the url (e.g., http://www.google.com)
|
||
|
* @param {object} [params] The params to be appended
|
||
|
* @returns {string} The formatted url
|
||
|
*/
|
||
|
var buildURL = function buildURL(url, params, paramsSerializer) {
|
||
|
/*eslint no-param-reassign:0*/
|
||
|
if (!params) {
|
||
|
return url;
|
||
|
}
|
||
|
|
||
|
var serializedParams;
|
||
|
if (paramsSerializer) {
|
||
|
serializedParams = paramsSerializer(params);
|
||
|
} else if (utils.isURLSearchParams(params)) {
|
||
|
serializedParams = params.toString();
|
||
|
} else {
|
||
|
var parts = [];
|
||
|
|
||
|
utils.forEach(params, function serialize(val, key) {
|
||
|
if (val === null || typeof val === 'undefined') {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (utils.isArray(val)) {
|
||
|
key = key + '[]';
|
||
|
} else {
|
||
|
val = [val];
|
||
|
}
|
||
|
|
||
|
utils.forEach(val, function parseValue(v) {
|
||
|
if (utils.isDate(v)) {
|
||
|
v = v.toISOString();
|
||
|
} else if (utils.isObject(v)) {
|
||
|
v = JSON.stringify(v);
|
||
|
}
|
||
|
parts.push(encode(key) + '=' + encode(v));
|
||
|
});
|
||
|
});
|
||
|
|
||
|
serializedParams = parts.join('&');
|
||
|
}
|
||
|
|
||
|
if (serializedParams) {
|
||
|
var hashmarkIndex = url.indexOf('#');
|
||
|
if (hashmarkIndex !== -1) {
|
||
|
url = url.slice(0, hashmarkIndex);
|
||
|
}
|
||
|
|
||
|
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
||
|
}
|
||
|
|
||
|
return url;
|
||
|
};
|
||
|
|
||
|
function InterceptorManager() {
|
||
|
this.handlers = [];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Add a new interceptor to the stack
|
||
|
*
|
||
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
||
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
||
|
*
|
||
|
* @return {Number} An ID used to remove interceptor later
|
||
|
*/
|
||
|
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
||
|
this.handlers.push({
|
||
|
fulfilled: fulfilled,
|
||
|
rejected: rejected
|
||
|
});
|
||
|
return this.handlers.length - 1;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Remove an interceptor from the stack
|
||
|
*
|
||
|
* @param {Number} id The ID that was returned by `use`
|
||
|
*/
|
||
|
InterceptorManager.prototype.eject = function eject(id) {
|
||
|
if (this.handlers[id]) {
|
||
|
this.handlers[id] = null;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Iterate over all the registered interceptors
|
||
|
*
|
||
|
* This method is particularly useful for skipping over any
|
||
|
* interceptors that may have become `null` calling `eject`.
|
||
|
*
|
||
|
* @param {Function} fn The function to call for each interceptor
|
||
|
*/
|
||
|
InterceptorManager.prototype.forEach = function forEach(fn) {
|
||
|
utils.forEach(this.handlers, function forEachHandler(h) {
|
||
|
if (h !== null) {
|
||
|
fn(h);
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var InterceptorManager_1 = InterceptorManager;
|
||
|
|
||
|
/**
|
||
|
* Transform the data for a request or a response
|
||
|
*
|
||
|
* @param {Object|String} data The data to be transformed
|
||
|
* @param {Array} headers The headers for the request or response
|
||
|
* @param {Array|Function} fns A single function or Array of functions
|
||
|
* @returns {*} The resulting transformed data
|
||
|
*/
|
||
|
var transformData = function transformData(data, headers, fns) {
|
||
|
/*eslint no-param-reassign:0*/
|
||
|
utils.forEach(fns, function transform(fn) {
|
||
|
data = fn(data, headers);
|
||
|
});
|
||
|
|
||
|
return data;
|
||
|
};
|
||
|
|
||
|
var isCancel = function isCancel(value) {
|
||
|
return !!(value && value.__CANCEL__);
|
||
|
};
|
||
|
|
||
|
var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
|
||
|
utils.forEach(headers, function processHeader(value, name) {
|
||
|
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
||
|
headers[normalizedName] = value;
|
||
|
delete headers[name];
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Update an Error with the specified config, error code, and response.
|
||
|
*
|
||
|
* @param {Error} error The error to update.
|
||
|
* @param {Object} config The config.
|
||
|
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
||
|
* @param {Object} [request] The request.
|
||
|
* @param {Object} [response] The response.
|
||
|
* @returns {Error} The error.
|
||
|
*/
|
||
|
var enhanceError = function enhanceError(error, config, code, request, response) {
|
||
|
error.config = config;
|
||
|
if (code) {
|
||
|
error.code = code;
|
||
|
}
|
||
|
|
||
|
error.request = request;
|
||
|
error.response = response;
|
||
|
error.isAxiosError = true;
|
||
|
|
||
|
error.toJSON = function toJSON() {
|
||
|
return {
|
||
|
// Standard
|
||
|
message: this.message,
|
||
|
name: this.name,
|
||
|
// Microsoft
|
||
|
description: this.description,
|
||
|
number: this.number,
|
||
|
// Mozilla
|
||
|
fileName: this.fileName,
|
||
|
lineNumber: this.lineNumber,
|
||
|
columnNumber: this.columnNumber,
|
||
|
stack: this.stack,
|
||
|
// Axios
|
||
|
config: this.config,
|
||
|
code: this.code
|
||
|
};
|
||
|
};
|
||
|
return error;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Create an Error with the specified message, config, error code, request and response.
|
||
|
*
|
||
|
* @param {string} message The error message.
|
||
|
* @param {Object} config The config.
|
||
|
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
||
|
* @param {Object} [request] The request.
|
||
|
* @param {Object} [response] The response.
|
||
|
* @returns {Error} The created error.
|
||
|
*/
|
||
|
var createError = function createError(message, config, code, request, response) {
|
||
|
var error = new Error(message);
|
||
|
return enhanceError(error, config, code, request, response);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Resolve or reject a Promise based on response status.
|
||
|
*
|
||
|
* @param {Function} resolve A function that resolves the promise.
|
||
|
* @param {Function} reject A function that rejects the promise.
|
||
|
* @param {object} response The response.
|
||
|
*/
|
||
|
var settle = function settle(resolve, reject, response) {
|
||
|
var validateStatus = response.config.validateStatus;
|
||
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
||
|
resolve(response);
|
||
|
} else {
|
||
|
reject(createError(
|
||
|
'Request failed with status code ' + response.status,
|
||
|
response.config,
|
||
|
null,
|
||
|
response.request,
|
||
|
response
|
||
|
));
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var cookies = (
|
||
|
utils.isStandardBrowserEnv() ?
|
||
|
|
||
|
// Standard browser envs support document.cookie
|
||
|
(function standardBrowserEnv() {
|
||
|
return {
|
||
|
write: function write(name, value, expires, path, domain, secure) {
|
||
|
var cookie = [];
|
||
|
cookie.push(name + '=' + encodeURIComponent(value));
|
||
|
|
||
|
if (utils.isNumber(expires)) {
|
||
|
cookie.push('expires=' + new Date(expires).toGMTString());
|
||
|
}
|
||
|
|
||
|
if (utils.isString(path)) {
|
||
|
cookie.push('path=' + path);
|
||
|
}
|
||
|
|
||
|
if (utils.isString(domain)) {
|
||
|
cookie.push('domain=' + domain);
|
||
|
}
|
||
|
|
||
|
if (secure === true) {
|
||
|
cookie.push('secure');
|
||
|
}
|
||
|
|
||
|
document.cookie = cookie.join('; ');
|
||
|
},
|
||
|
|
||
|
read: function read(name) {
|
||
|
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||
|
return (match ? decodeURIComponent(match[3]) : null);
|
||
|
},
|
||
|
|
||
|
remove: function remove(name) {
|
||
|
this.write(name, '', Date.now() - 86400000);
|
||
|
}
|
||
|
};
|
||
|
})() :
|
||
|
|
||
|
// Non standard browser env (web workers, react-native) lack needed support.
|
||
|
(function nonStandardBrowserEnv() {
|
||
|
return {
|
||
|
write: function write() {},
|
||
|
read: function read() { return null; },
|
||
|
remove: function remove() {}
|
||
|
};
|
||
|
})()
|
||
|
);
|
||
|
|
||
|
/**
|
||
|
* Determines whether the specified URL is absolute
|
||
|
*
|
||
|
* @param {string} url The URL to test
|
||
|
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
||
|
*/
|
||
|
var isAbsoluteURL = function isAbsoluteURL(url) {
|
||
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
||
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
||
|
// by any combination of letters, digits, plus, period, or hyphen.
|
||
|
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Creates a new URL by combining the specified URLs
|
||
|
*
|
||
|
* @param {string} baseURL The base URL
|
||
|
* @param {string} relativeURL The relative URL
|
||
|
* @returns {string} The combined URL
|
||
|
*/
|
||
|
var combineURLs = function combineURLs(baseURL, relativeURL) {
|
||
|
return relativeURL
|
||
|
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
||
|
: baseURL;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
||
|
* only when the requestedURL is not already an absolute URL.
|
||
|
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
||
|
*
|
||
|
* @param {string} baseURL The base URL
|
||
|
* @param {string} requestedURL Absolute or relative URL to combine
|
||
|
* @returns {string} The combined full path
|
||
|
*/
|
||
|
var buildFullPath = function buildFullPath(baseURL, requestedURL) {
|
||
|
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||
|
return combineURLs(baseURL, requestedURL);
|
||
|
}
|
||
|
return requestedURL;
|
||
|
};
|
||
|
|
||
|
// Headers whose duplicates are ignored by node
|
||
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||
|
var ignoreDuplicateOf = [
|
||
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
||
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
||
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
||
|
'referer', 'retry-after', 'user-agent'
|
||
|
];
|
||
|
|
||
|
/**
|
||
|
* Parse headers into an object
|
||
|
*
|
||
|
* ```
|
||
|
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
||
|
* Content-Type: application/json
|
||
|
* Connection: keep-alive
|
||
|
* Transfer-Encoding: chunked
|
||
|
* ```
|
||
|
*
|
||
|
* @param {String} headers Headers needing to be parsed
|
||
|
* @returns {Object} Headers parsed into an object
|
||
|
*/
|
||
|
var parseHeaders = function parseHeaders(headers) {
|
||
|
var parsed = {};
|
||
|
var key;
|
||
|
var val;
|
||
|
var i;
|
||
|
|
||
|
if (!headers) { return parsed; }
|
||
|
|
||
|
utils.forEach(headers.split('\n'), function parser(line) {
|
||
|
i = line.indexOf(':');
|
||
|
key = utils.trim(line.substr(0, i)).toLowerCase();
|
||
|
val = utils.trim(line.substr(i + 1));
|
||
|
|
||
|
if (key) {
|
||
|
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
||
|
return;
|
||
|
}
|
||
|
if (key === 'set-cookie') {
|
||
|
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
||
|
} else {
|
||
|
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return parsed;
|
||
|
};
|
||
|
|
||
|
var isURLSameOrigin = (
|
||
|
utils.isStandardBrowserEnv() ?
|
||
|
|
||
|
// Standard browser envs have full support of the APIs needed to test
|
||
|
// whether the request URL is of the same origin as current location.
|
||
|
(function standardBrowserEnv() {
|
||
|
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
||
|
var urlParsingNode = document.createElement('a');
|
||
|
var originURL;
|
||
|
|
||
|
/**
|
||
|
* Parse a URL to discover it's components
|
||
|
*
|
||
|
* @param {String} url The URL to be parsed
|
||
|
* @returns {Object}
|
||
|
*/
|
||
|
function resolveURL(url) {
|
||
|
var href = url;
|
||
|
|
||
|
if (msie) {
|
||
|
// IE needs attribute set twice to normalize properties
|
||
|
urlParsingNode.setAttribute('href', href);
|
||
|
href = urlParsingNode.href;
|
||
|
}
|
||
|
|
||
|
urlParsingNode.setAttribute('href', href);
|
||
|
|
||
|
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||
|
return {
|
||
|
href: urlParsingNode.href,
|
||
|
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||
|
host: urlParsingNode.host,
|
||
|
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||
|
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||
|
hostname: urlParsingNode.hostname,
|
||
|
port: urlParsingNode.port,
|
||
|
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
||
|
urlParsingNode.pathname :
|
||
|
'/' + urlParsingNode.pathname
|
||
|
};
|
||
|
}
|
||
|
|
||
|
originURL = resolveURL(window.location.href);
|
||
|
|
||
|
/**
|
||
|
* Determine if a URL shares the same origin as the current location
|
||
|
*
|
||
|
* @param {String} requestURL The URL to test
|
||
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||
|
*/
|
||
|
return function isURLSameOrigin(requestURL) {
|
||
|
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
||
|
return (parsed.protocol === originURL.protocol &&
|
||
|
parsed.host === originURL.host);
|
||
|
};
|
||
|
})() :
|
||
|
|
||
|
// Non standard browser envs (web workers, react-native) lack needed support.
|
||
|
(function nonStandardBrowserEnv() {
|
||
|
return function isURLSameOrigin() {
|
||
|
return true;
|
||
|
};
|
||
|
})()
|
||
|
);
|
||
|
|
||
|
var xhr = function xhrAdapter(config) {
|
||
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||
|
var requestData = config.data;
|
||
|
var requestHeaders = config.headers;
|
||
|
|
||
|
if (utils.isFormData(requestData)) {
|
||
|
delete requestHeaders['Content-Type']; // Let the browser set it
|
||
|
}
|
||
|
|
||
|
var request = new XMLHttpRequest();
|
||
|
|
||
|
// HTTP basic authentication
|
||
|
if (config.auth) {
|
||
|
var username = config.auth.username || '';
|
||
|
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
||
|
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
||
|
}
|
||
|
|
||
|
var fullPath = buildFullPath(config.baseURL, config.url);
|
||
|
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
||
|
|
||
|
// Set the request timeout in MS
|
||
|
request.timeout = config.timeout;
|
||
|
|
||
|
// Listen for ready state
|
||
|
request.onreadystatechange = function handleLoad() {
|
||
|
if (!request || request.readyState !== 4) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// The request errored out and we didn't get a response, this will be
|
||
|
// handled by onerror instead
|
||
|
// With one exception: request that using file: protocol, most browsers
|
||
|
// will return status as 0 even though it's a successful request
|
||
|
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// Prepare the response
|
||
|
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
||
|
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
||
|
var response = {
|
||
|
data: responseData,
|
||
|
status: request.status,
|
||
|
statusText: request.statusText,
|
||
|
headers: responseHeaders,
|
||
|
config: config,
|
||
|
request: request
|
||
|
};
|
||
|
|
||
|
settle(resolve, reject, response);
|
||
|
|
||
|
// Clean up request
|
||
|
request = null;
|
||
|
};
|
||
|
|
||
|
// Handle browser request cancellation (as opposed to a manual cancellation)
|
||
|
request.onabort = function handleAbort() {
|
||
|
if (!request) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
reject(createError('Request aborted', config, 'ECONNABORTED', request));
|
||
|
|
||
|
// Clean up request
|
||
|
request = null;
|
||
|
};
|
||
|
|
||
|
// Handle low level network errors
|
||
|
request.onerror = function handleError() {
|
||
|
// Real errors are hidden from us by the browser
|
||
|
// onerror should only fire if it's a network error
|
||
|
reject(createError('Network Error', config, null, request));
|
||
|
|
||
|
// Clean up request
|
||
|
request = null;
|
||
|
};
|
||
|
|
||
|
// Handle timeout
|
||
|
request.ontimeout = function handleTimeout() {
|
||
|
var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
|
||
|
if (config.timeoutErrorMessage) {
|
||
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
||
|
}
|
||
|
reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
|
||
|
request));
|
||
|
|
||
|
// Clean up request
|
||
|
request = null;
|
||
|
};
|
||
|
|
||
|
// Add xsrf header
|
||
|
// This is only done if running in a standard browser environment.
|
||
|
// Specifically not if we're in a web worker, or react-native.
|
||
|
if (utils.isStandardBrowserEnv()) {
|
||
|
// Add xsrf header
|
||
|
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
|
||
|
cookies.read(config.xsrfCookieName) :
|
||
|
undefined;
|
||
|
|
||
|
if (xsrfValue) {
|
||
|
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Add headers to the request
|
||
|
if ('setRequestHeader' in request) {
|
||
|
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
||
|
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
|
||
|
// Remove Content-Type if data is undefined
|
||
|
delete requestHeaders[key];
|
||
|
} else {
|
||
|
// Otherwise add header to the request
|
||
|
request.setRequestHeader(key, val);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// Add withCredentials to request if needed
|
||
|
if (!utils.isUndefined(config.withCredentials)) {
|
||
|
request.withCredentials = !!config.withCredentials;
|
||
|
}
|
||
|
|
||
|
// Add responseType to request if needed
|
||
|
if (config.responseType) {
|
||
|
try {
|
||
|
request.responseType = config.responseType;
|
||
|
} catch (e) {
|
||
|
// Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
|
||
|
// But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
|
||
|
if (config.responseType !== 'json') {
|
||
|
throw e;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Handle progress if needed
|
||
|
if (typeof config.onDownloadProgress === 'function') {
|
||
|
request.addEventListener('progress', config.onDownloadProgress);
|
||
|
}
|
||
|
|
||
|
// Not all browsers support upload events
|
||
|
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
||
|
request.upload.addEventListener('progress', config.onUploadProgress);
|
||
|
}
|
||
|
|
||
|
if (config.cancelToken) {
|
||
|
// Handle cancellation
|
||
|
config.cancelToken.promise.then(function onCanceled(cancel) {
|
||
|
if (!request) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
request.abort();
|
||
|
reject(cancel);
|
||
|
// Clean up request
|
||
|
request = null;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if (!requestData) {
|
||
|
requestData = null;
|
||
|
}
|
||
|
|
||
|
// Send the request
|
||
|
request.send(requestData);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var DEFAULT_CONTENT_TYPE = {
|
||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||
|
};
|
||
|
|
||
|
function setContentTypeIfUnset(headers, value) {
|
||
|
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
||
|
headers['Content-Type'] = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getDefaultAdapter() {
|
||
|
var adapter;
|
||
|
if (typeof XMLHttpRequest !== 'undefined') {
|
||
|
// For browsers use XHR adapter
|
||
|
adapter = xhr;
|
||
|
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
|
||
|
// For node use HTTP adapter
|
||
|
adapter = xhr;
|
||
|
}
|
||
|
return adapter;
|
||
|
}
|
||
|
|
||
|
var defaults = {
|
||
|
adapter: getDefaultAdapter(),
|
||
|
|
||
|
transformRequest: [function transformRequest(data, headers) {
|
||
|
normalizeHeaderName(headers, 'Accept');
|
||
|
normalizeHeaderName(headers, 'Content-Type');
|
||
|
if (utils.isFormData(data) ||
|
||
|
utils.isArrayBuffer(data) ||
|
||
|
utils.isBuffer(data) ||
|
||
|
utils.isStream(data) ||
|
||
|
utils.isFile(data) ||
|
||
|
utils.isBlob(data)
|
||
|
) {
|
||
|
return data;
|
||
|
}
|
||
|
if (utils.isArrayBufferView(data)) {
|
||
|
return data.buffer;
|
||
|
}
|
||
|
if (utils.isURLSearchParams(data)) {
|
||
|
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
||
|
return data.toString();
|
||
|
}
|
||
|
if (utils.isObject(data)) {
|
||
|
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
|
||
|
return JSON.stringify(data);
|
||
|
}
|
||
|
return data;
|
||
|
}],
|
||
|
|
||
|
transformResponse: [function transformResponse(data) {
|
||
|
/*eslint no-param-reassign:0*/
|
||
|
if (typeof data === 'string') {
|
||
|
try {
|
||
|
data = JSON.parse(data);
|
||
|
} catch (e) { /* Ignore */ }
|
||
|
}
|
||
|
return data;
|
||
|
}],
|
||
|
|
||
|
/**
|
||
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||
|
* timeout is not created.
|
||
|
*/
|
||
|
timeout: 0,
|
||
|
|
||
|
xsrfCookieName: 'XSRF-TOKEN',
|
||
|
xsrfHeaderName: 'X-XSRF-TOKEN',
|
||
|
|
||
|
maxContentLength: -1,
|
||
|
maxBodyLength: -1,
|
||
|
|
||
|
validateStatus: function validateStatus(status) {
|
||
|
return status >= 200 && status < 300;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
defaults.headers = {
|
||
|
common: {
|
||
|
'Accept': 'application/json, text/plain, */*'
|
||
|
}
|
||
|
};
|
||
|
|
||
|
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
||
|
defaults.headers[method] = {};
|
||
|
});
|
||
|
|
||
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||
|
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
||
|
});
|
||
|
|
||
|
var defaults_1 = defaults;
|
||
|
|
||
|
/**
|
||
|
* Throws a `Cancel` if cancellation has been requested.
|
||
|
*/
|
||
|
function throwIfCancellationRequested(config) {
|
||
|
if (config.cancelToken) {
|
||
|
config.cancelToken.throwIfRequested();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Dispatch a request to the server using the configured adapter.
|
||
|
*
|
||
|
* @param {object} config The config that is to be used for the request
|
||
|
* @returns {Promise} The Promise to be fulfilled
|
||
|
*/
|
||
|
var dispatchRequest = function dispatchRequest(config) {
|
||
|
throwIfCancellationRequested(config);
|
||
|
|
||
|
// Ensure headers exist
|
||
|
config.headers = config.headers || {};
|
||
|
|
||
|
// Transform request data
|
||
|
config.data = transformData(
|
||
|
config.data,
|
||
|
config.headers,
|
||
|
config.transformRequest
|
||
|
);
|
||
|
|
||
|
// Flatten headers
|
||
|
config.headers = utils.merge(
|
||
|
config.headers.common || {},
|
||
|
config.headers[config.method] || {},
|
||
|
config.headers
|
||
|
);
|
||
|
|
||
|
utils.forEach(
|
||
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
||
|
function cleanHeaderConfig(method) {
|
||
|
delete config.headers[method];
|
||
|
}
|
||
|
);
|
||
|
|
||
|
var adapter = config.adapter || defaults_1.adapter;
|
||
|
|
||
|
return adapter(config).then(function onAdapterResolution(response) {
|
||
|
throwIfCancellationRequested(config);
|
||
|
|
||
|
// Transform response data
|
||
|
response.data = transformData(
|
||
|
response.data,
|
||
|
response.headers,
|
||
|
config.transformResponse
|
||
|
);
|
||
|
|
||
|
return response;
|
||
|
}, function onAdapterRejection(reason) {
|
||
|
if (!isCancel(reason)) {
|
||
|
throwIfCancellationRequested(config);
|
||
|
|
||
|
// Transform response data
|
||
|
if (reason && reason.response) {
|
||
|
reason.response.data = transformData(
|
||
|
reason.response.data,
|
||
|
reason.response.headers,
|
||
|
config.transformResponse
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return Promise.reject(reason);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Config-specific merge-function which creates a new config-object
|
||
|
* by merging two configuration objects together.
|
||
|
*
|
||
|
* @param {Object} config1
|
||
|
* @param {Object} config2
|
||
|
* @returns {Object} New object resulting from merging config2 to config1
|
||
|
*/
|
||
|
var mergeConfig = function mergeConfig(config1, config2) {
|
||
|
// eslint-disable-next-line no-param-reassign
|
||
|
config2 = config2 || {};
|
||
|
var config = {};
|
||
|
|
||
|
var valueFromConfig2Keys = ['url', 'method', 'data'];
|
||
|
var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
|
||
|
var defaultToConfig2Keys = [
|
||
|
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
|
||
|
'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
|
||
|
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
|
||
|
'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
|
||
|
'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
|
||
|
];
|
||
|
var directMergeKeys = ['validateStatus'];
|
||
|
|
||
|
function getMergedValue(target, source) {
|
||
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
||
|
return utils.merge(target, source);
|
||
|
} else if (utils.isPlainObject(source)) {
|
||
|
return utils.merge({}, source);
|
||
|
} else if (utils.isArray(source)) {
|
||
|
return source.slice();
|
||
|
}
|
||
|
return source;
|
||
|
}
|
||
|
|
||
|
function mergeDeepProperties(prop) {
|
||
|
if (!utils.isUndefined(config2[prop])) {
|
||
|
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
||
|
} else if (!utils.isUndefined(config1[prop])) {
|
||
|
config[prop] = getMergedValue(undefined, config1[prop]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
|
||
|
if (!utils.isUndefined(config2[prop])) {
|
||
|
config[prop] = getMergedValue(undefined, config2[prop]);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
|
||
|
|
||
|
utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
|
||
|
if (!utils.isUndefined(config2[prop])) {
|
||
|
config[prop] = getMergedValue(undefined, config2[prop]);
|
||
|
} else if (!utils.isUndefined(config1[prop])) {
|
||
|
config[prop] = getMergedValue(undefined, config1[prop]);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
utils.forEach(directMergeKeys, function merge(prop) {
|
||
|
if (prop in config2) {
|
||
|
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
||
|
} else if (prop in config1) {
|
||
|
config[prop] = getMergedValue(undefined, config1[prop]);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var axiosKeys = valueFromConfig2Keys
|
||
|
.concat(mergeDeepPropertiesKeys)
|
||
|
.concat(defaultToConfig2Keys)
|
||
|
.concat(directMergeKeys);
|
||
|
|
||
|
var otherKeys = Object
|
||
|
.keys(config1)
|
||
|
.concat(Object.keys(config2))
|
||
|
.filter(function filterAxiosKeys(key) {
|
||
|
return axiosKeys.indexOf(key) === -1;
|
||
|
});
|
||
|
|
||
|
utils.forEach(otherKeys, mergeDeepProperties);
|
||
|
|
||
|
return config;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Create a new instance of Axios
|
||
|
*
|
||
|
* @param {Object} instanceConfig The default config for the instance
|
||
|
*/
|
||
|
function Axios(instanceConfig) {
|
||
|
this.defaults = instanceConfig;
|
||
|
this.interceptors = {
|
||
|
request: new InterceptorManager_1(),
|
||
|
response: new InterceptorManager_1()
|
||
|
};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Dispatch a request
|
||
|
*
|
||
|
* @param {Object} config The config specific for this request (merged with this.defaults)
|
||
|
*/
|
||
|
Axios.prototype.request = function request(config) {
|
||
|
/*eslint no-param-reassign:0*/
|
||
|
// Allow for axios('example/url'[, config]) a la fetch API
|
||
|
if (typeof config === 'string') {
|
||
|
config = arguments[1] || {};
|
||
|
config.url = arguments[0];
|
||
|
} else {
|
||
|
config = config || {};
|
||
|
}
|
||
|
|
||
|
config = mergeConfig(this.defaults, config);
|
||
|
|
||
|
// Set config.method
|
||
|
if (config.method) {
|
||
|
config.method = config.method.toLowerCase();
|
||
|
} else if (this.defaults.method) {
|
||
|
config.method = this.defaults.method.toLowerCase();
|
||
|
} else {
|
||
|
config.method = 'get';
|
||
|
}
|
||
|
|
||
|
// Hook up interceptors middleware
|
||
|
var chain = [dispatchRequest, undefined];
|
||
|
var promise = Promise.resolve(config);
|
||
|
|
||
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
||
|
chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
||
|
});
|
||
|
|
||
|
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
||
|
chain.push(interceptor.fulfilled, interceptor.rejected);
|
||
|
});
|
||
|
|
||
|
while (chain.length) {
|
||
|
promise = promise.then(chain.shift(), chain.shift());
|
||
|
}
|
||
|
|
||
|
return promise;
|
||
|
};
|
||
|
|
||
|
Axios.prototype.getUri = function getUri(config) {
|
||
|
config = mergeConfig(this.defaults, config);
|
||
|
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
|
||
|
};
|
||
|
|
||
|
// Provide aliases for supported request methods
|
||
|
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
||
|
/*eslint func-names:0*/
|
||
|
Axios.prototype[method] = function(url, config) {
|
||
|
return this.request(mergeConfig(config || {}, {
|
||
|
method: method,
|
||
|
url: url,
|
||
|
data: (config || {}).data
|
||
|
}));
|
||
|
};
|
||
|
});
|
||
|
|
||
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||
|
/*eslint func-names:0*/
|
||
|
Axios.prototype[method] = function(url, data, config) {
|
||
|
return this.request(mergeConfig(config || {}, {
|
||
|
method: method,
|
||
|
url: url,
|
||
|
data: data
|
||
|
}));
|
||
|
};
|
||
|
});
|
||
|
|
||
|
var Axios_1 = Axios;
|
||
|
|
||
|
/**
|
||
|
* A `Cancel` is an object that is thrown when an operation is canceled.
|
||
|
*
|
||
|
* @class
|
||
|
* @param {string=} message The message.
|
||
|
*/
|
||
|
function Cancel(message) {
|
||
|
this.message = message;
|
||
|
}
|
||
|
|
||
|
Cancel.prototype.toString = function toString() {
|
||
|
return 'Cancel' + (this.message ? ': ' + this.message : '');
|
||
|
};
|
||
|
|
||
|
Cancel.prototype.__CANCEL__ = true;
|
||
|
|
||
|
var Cancel_1 = Cancel;
|
||
|
|
||
|
/**
|
||
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
||
|
*
|
||
|
* @class
|
||
|
* @param {Function} executor The executor function.
|
||
|
*/
|
||
|
function CancelToken(executor) {
|
||
|
if (typeof executor !== 'function') {
|
||
|
throw new TypeError('executor must be a function.');
|
||
|
}
|
||
|
|
||
|
var resolvePromise;
|
||
|
this.promise = new Promise(function promiseExecutor(resolve) {
|
||
|
resolvePromise = resolve;
|
||
|
});
|
||
|
|
||
|
var token = this;
|
||
|
executor(function cancel(message) {
|
||
|
if (token.reason) {
|
||
|
// Cancellation has already been requested
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
token.reason = new Cancel_1(message);
|
||
|
resolvePromise(token.reason);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Throws a `Cancel` if cancellation has been requested.
|
||
|
*/
|
||
|
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
||
|
if (this.reason) {
|
||
|
throw this.reason;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
||
|
* cancels the `CancelToken`.
|
||
|
*/
|
||
|
CancelToken.source = function source() {
|
||
|
var cancel;
|
||
|
var token = new CancelToken(function executor(c) {
|
||
|
cancel = c;
|
||
|
});
|
||
|
return {
|
||
|
token: token,
|
||
|
cancel: cancel
|
||
|
};
|
||
|
};
|
||
|
|
||
|
var CancelToken_1 = CancelToken;
|
||
|
|
||
|
/**
|
||
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
||
|
*
|
||
|
* Common use case would be to use `Function.prototype.apply`.
|
||
|
*
|
||
|
* ```js
|
||
|
* function f(x, y, z) {}
|
||
|
* var args = [1, 2, 3];
|
||
|
* f.apply(null, args);
|
||
|
* ```
|
||
|
*
|
||
|
* With `spread` this example can be re-written.
|
||
|
*
|
||
|
* ```js
|
||
|
* spread(function(x, y, z) {})([1, 2, 3]);
|
||
|
* ```
|
||
|
*
|
||
|
* @param {Function} callback
|
||
|
* @returns {Function}
|
||
|
*/
|
||
|
var spread = function spread(callback) {
|
||
|
return function wrap(arr) {
|
||
|
return callback.apply(null, arr);
|
||
|
};
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Determines whether the payload is an error thrown by Axios
|
||
|
*
|
||
|
* @param {*} payload The value to test
|
||
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
||
|
*/
|
||
|
var isAxiosError = function isAxiosError(payload) {
|
||
|
return (typeof payload === 'object') && (payload.isAxiosError === true);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Create an instance of Axios
|
||
|
*
|
||
|
* @param {Object} defaultConfig The default config for the instance
|
||
|
* @return {Axios} A new instance of Axios
|
||
|
*/
|
||
|
function createInstance(defaultConfig) {
|
||
|
var context = new Axios_1(defaultConfig);
|
||
|
var instance = bind(Axios_1.prototype.request, context);
|
||
|
|
||
|
// Copy axios.prototype to instance
|
||
|
utils.extend(instance, Axios_1.prototype, context);
|
||
|
|
||
|
// Copy context to instance
|
||
|
utils.extend(instance, context);
|
||
|
|
||
|
return instance;
|
||
|
}
|
||
|
|
||
|
// Create the default instance to be exported
|
||
|
var axios = createInstance(defaults_1);
|
||
|
|
||
|
// Expose Axios class to allow class inheritance
|
||
|
axios.Axios = Axios_1;
|
||
|
|
||
|
// Factory for creating new instances
|
||
|
axios.create = function create(instanceConfig) {
|
||
|
return createInstance(mergeConfig(axios.defaults, instanceConfig));
|
||
|
};
|
||
|
|
||
|
// Expose Cancel & CancelToken
|
||
|
axios.Cancel = Cancel_1;
|
||
|
axios.CancelToken = CancelToken_1;
|
||
|
axios.isCancel = isCancel;
|
||
|
|
||
|
// Expose all/spread
|
||
|
axios.all = function all(promises) {
|
||
|
return Promise.all(promises);
|
||
|
};
|
||
|
axios.spread = spread;
|
||
|
|
||
|
// Expose isAxiosError
|
||
|
axios.isAxiosError = isAxiosError;
|
||
|
|
||
|
var axios_1 = axios;
|
||
|
|
||
|
// Allow use of default import syntax in TypeScript
|
||
|
var _default = axios;
|
||
|
axios_1.default = _default;
|
||
|
|
||
|
const hasSession = () => {
|
||
|
return getCookie('SESSION') != null;
|
||
|
};
|
||
|
|
||
|
function getCookie(name) {
|
||
|
if (!window.document) {
|
||
|
return null;
|
||
|
}
|
||
|
var dc = window.document.cookie;
|
||
|
var prefix = name + '=';
|
||
|
var begin = dc.indexOf('; ' + prefix);
|
||
|
if (begin == -1) {
|
||
|
begin = dc.indexOf(prefix);
|
||
|
if (begin != 0) return null;
|
||
|
} else {
|
||
|
begin += 2;
|
||
|
var end = window.document.cookie.indexOf(';', begin);
|
||
|
if (end == -1) {
|
||
|
end = dc.length;
|
||
|
}
|
||
|
}
|
||
|
// because unescape has been deprecated, replaced with decodeURI
|
||
|
//return unescape(dc.substring(begin + prefix.length, end));
|
||
|
return decodeURI(dc.substring(begin + prefix.length, end));
|
||
|
}
|
||
|
|
||
|
/* src/components/Header.svelte generated by Svelte v3.42.1 */
|
||
|
const file$2 = "src/components/Header.svelte";
|
||
|
|
||
|
// (38:6) {#if user}
|
||
|
function create_if_block_1(ctx) {
|
||
|
let image;
|
||
|
let t;
|
||
|
let button;
|
||
|
let current;
|
||
|
|
||
|
image = new Image({
|
||
|
props: {
|
||
|
src: avatarUrl,
|
||
|
alt: "user profile picture"
|
||
|
},
|
||
|
$$inline: true
|
||
|
});
|
||
|
|
||
|
image.$on("click", redirect('/settings'));
|
||
|
|
||
|
button = new Button({
|
||
|
props: { size: "small", label: "Log out" },
|
||
|
$$inline: true
|
||
|
});
|
||
|
|
||
|
button.$on("click", /*onLogout*/ ctx[2]);
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
create_component(image.$$.fragment);
|
||
|
t = space();
|
||
|
create_component(button.$$.fragment);
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
claim_component(image.$$.fragment, nodes);
|
||
|
t = claim_space(nodes);
|
||
|
claim_component(button.$$.fragment, nodes);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
mount_component(image, target, anchor);
|
||
|
insert_hydration_dev(target, t, anchor);
|
||
|
mount_component(button, target, anchor);
|
||
|
current = true;
|
||
|
},
|
||
|
p: noop,
|
||
|
i: function intro(local) {
|
||
|
if (current) return;
|
||
|
transition_in(image.$$.fragment, local);
|
||
|
transition_in(button.$$.fragment, local);
|
||
|
current = true;
|
||
|
},
|
||
|
o: function outro(local) {
|
||
|
transition_out(image.$$.fragment, local);
|
||
|
transition_out(button.$$.fragment, local);
|
||
|
current = false;
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
destroy_component(image, detaching);
|
||
|
if (detaching) detach_dev(t);
|
||
|
destroy_component(button, detaching);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_if_block_1.name,
|
||
|
type: "if",
|
||
|
source: "(38:6) {#if user}",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
// (42:6) {#if !user}
|
||
|
function create_if_block$2(ctx) {
|
||
|
let button;
|
||
|
let current;
|
||
|
|
||
|
button = new Button({
|
||
|
props: { size: "small", label: "Log in" },
|
||
|
$$inline: true
|
||
|
});
|
||
|
|
||
|
button.$on("click", /*onLogin*/ ctx[1]);
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
create_component(button.$$.fragment);
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
claim_component(button.$$.fragment, nodes);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
mount_component(button, target, anchor);
|
||
|
current = true;
|
||
|
},
|
||
|
p: noop,
|
||
|
i: function intro(local) {
|
||
|
if (current) return;
|
||
|
transition_in(button.$$.fragment, local);
|
||
|
current = true;
|
||
|
},
|
||
|
o: function outro(local) {
|
||
|
transition_out(button.$$.fragment, local);
|
||
|
current = false;
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
destroy_component(button, detaching);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_if_block$2.name,
|
||
|
type: "if",
|
||
|
source: "(42:6) {#if !user}",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function create_fragment$3(ctx) {
|
||
|
let header;
|
||
|
let div2;
|
||
|
let div0;
|
||
|
let image;
|
||
|
let t0;
|
||
|
let h1;
|
||
|
let t1;
|
||
|
let t2;
|
||
|
let div1;
|
||
|
let t3;
|
||
|
let current;
|
||
|
|
||
|
image = new Image({
|
||
|
props: { src: "./clipboard.svg" },
|
||
|
$$inline: true
|
||
|
});
|
||
|
|
||
|
image.$on("click", redirect('/'));
|
||
|
let if_block0 = /*user*/ ctx[0] && create_if_block_1(ctx);
|
||
|
let if_block1 = !/*user*/ ctx[0] && create_if_block$2(ctx);
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
header = element("header");
|
||
|
div2 = element("div");
|
||
|
div0 = element("div");
|
||
|
create_component(image.$$.fragment);
|
||
|
t0 = space();
|
||
|
h1 = element("h1");
|
||
|
t1 = text("Todo");
|
||
|
t2 = space();
|
||
|
div1 = element("div");
|
||
|
if (if_block0) if_block0.c();
|
||
|
t3 = space();
|
||
|
if (if_block1) if_block1.c();
|
||
|
this.h();
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
header = claim_element(nodes, "HEADER", {});
|
||
|
var header_nodes = children(header);
|
||
|
div2 = claim_element(header_nodes, "DIV", { class: true });
|
||
|
var div2_nodes = children(div2);
|
||
|
div0 = claim_element(div2_nodes, "DIV", {});
|
||
|
var div0_nodes = children(div0);
|
||
|
claim_component(image.$$.fragment, div0_nodes);
|
||
|
t0 = claim_space(div0_nodes);
|
||
|
h1 = claim_element(div0_nodes, "H1", {});
|
||
|
var h1_nodes = children(h1);
|
||
|
t1 = claim_text(h1_nodes, "Todo");
|
||
|
h1_nodes.forEach(detach_dev);
|
||
|
div0_nodes.forEach(detach_dev);
|
||
|
t2 = claim_space(div2_nodes);
|
||
|
div1 = claim_element(div2_nodes, "DIV", {});
|
||
|
var div1_nodes = children(div1);
|
||
|
if (if_block0) if_block0.l(div1_nodes);
|
||
|
t3 = claim_space(div1_nodes);
|
||
|
if (if_block1) if_block1.l(div1_nodes);
|
||
|
div1_nodes.forEach(detach_dev);
|
||
|
div2_nodes.forEach(detach_dev);
|
||
|
header_nodes.forEach(detach_dev);
|
||
|
this.h();
|
||
|
},
|
||
|
h: function hydrate() {
|
||
|
add_location(h1, file$2, 34, 6, 716);
|
||
|
add_location(div0, file$2, 32, 4, 641);
|
||
|
add_location(div1, file$2, 36, 4, 745);
|
||
|
attr_dev(div2, "class", "wrapper");
|
||
|
add_location(div2, file$2, 31, 2, 615);
|
||
|
add_location(header, file$2, 30, 0, 604);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
insert_hydration_dev(target, header, anchor);
|
||
|
append_hydration_dev(header, div2);
|
||
|
append_hydration_dev(div2, div0);
|
||
|
mount_component(image, div0, null);
|
||
|
append_hydration_dev(div0, t0);
|
||
|
append_hydration_dev(div0, h1);
|
||
|
append_hydration_dev(h1, t1);
|
||
|
append_hydration_dev(div2, t2);
|
||
|
append_hydration_dev(div2, div1);
|
||
|
if (if_block0) if_block0.m(div1, null);
|
||
|
append_hydration_dev(div1, t3);
|
||
|
if (if_block1) if_block1.m(div1, null);
|
||
|
current = true;
|
||
|
},
|
||
|
p: function update(ctx, [dirty]) {
|
||
|
if (/*user*/ ctx[0]) {
|
||
|
if (if_block0) {
|
||
|
if_block0.p(ctx, dirty);
|
||
|
|
||
|
if (dirty & /*user*/ 1) {
|
||
|
transition_in(if_block0, 1);
|
||
|
}
|
||
|
} else {
|
||
|
if_block0 = create_if_block_1(ctx);
|
||
|
if_block0.c();
|
||
|
transition_in(if_block0, 1);
|
||
|
if_block0.m(div1, t3);
|
||
|
}
|
||
|
} else if (if_block0) {
|
||
|
group_outros();
|
||
|
|
||
|
transition_out(if_block0, 1, 1, () => {
|
||
|
if_block0 = null;
|
||
|
});
|
||
|
|
||
|
check_outros();
|
||
|
}
|
||
|
|
||
|
if (!/*user*/ ctx[0]) {
|
||
|
if (if_block1) {
|
||
|
if_block1.p(ctx, dirty);
|
||
|
|
||
|
if (dirty & /*user*/ 1) {
|
||
|
transition_in(if_block1, 1);
|
||
|
}
|
||
|
} else {
|
||
|
if_block1 = create_if_block$2(ctx);
|
||
|
if_block1.c();
|
||
|
transition_in(if_block1, 1);
|
||
|
if_block1.m(div1, null);
|
||
|
}
|
||
|
} else if (if_block1) {
|
||
|
group_outros();
|
||
|
|
||
|
transition_out(if_block1, 1, 1, () => {
|
||
|
if_block1 = null;
|
||
|
});
|
||
|
|
||
|
check_outros();
|
||
|
}
|
||
|
},
|
||
|
i: function intro(local) {
|
||
|
if (current) return;
|
||
|
transition_in(image.$$.fragment, local);
|
||
|
transition_in(if_block0);
|
||
|
transition_in(if_block1);
|
||
|
current = true;
|
||
|
},
|
||
|
o: function outro(local) {
|
||
|
transition_out(image.$$.fragment, local);
|
||
|
transition_out(if_block0);
|
||
|
transition_out(if_block1);
|
||
|
current = false;
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
if (detaching) detach_dev(header);
|
||
|
destroy_component(image);
|
||
|
if (if_block0) if_block0.d();
|
||
|
if (if_block1) if_block1.d();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_fragment$3.name,
|
||
|
type: "component",
|
||
|
source: "",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function redirect(url) {
|
||
|
return () => {
|
||
|
window.location.pathname = url;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function instance$3($$self, $$props, $$invalidate) {
|
||
|
let { $$slots: slots = {}, $$scope } = $$props;
|
||
|
validate_slots('Header', slots, []);
|
||
|
let user = null;
|
||
|
|
||
|
onMount(async () => {
|
||
|
$$invalidate(0, user = hasSession());
|
||
|
});
|
||
|
|
||
|
const dispatch = createEventDispatcher();
|
||
|
|
||
|
function onLogin(event) {
|
||
|
dispatch('login', event);
|
||
|
}
|
||
|
|
||
|
function onLogout(event) {
|
||
|
dispatch('logout', event);
|
||
|
}
|
||
|
|
||
|
const writable_props = [];
|
||
|
|
||
|
Object.keys($$props).forEach(key => {
|
||
|
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<Header> was created with unknown prop '${key}'`);
|
||
|
});
|
||
|
|
||
|
$$self.$capture_state = () => ({
|
||
|
Button,
|
||
|
Image,
|
||
|
hasSession,
|
||
|
onMount,
|
||
|
createEventDispatcher,
|
||
|
user,
|
||
|
dispatch,
|
||
|
onLogin,
|
||
|
onLogout,
|
||
|
redirect
|
||
|
});
|
||
|
|
||
|
$$self.$inject_state = $$props => {
|
||
|
if ('user' in $$props) $$invalidate(0, user = $$props.user);
|
||
|
};
|
||
|
|
||
|
if ($$props && "$$inject" in $$props) {
|
||
|
$$self.$inject_state($$props.$$inject);
|
||
|
}
|
||
|
|
||
|
return [user, onLogin, onLogout];
|
||
|
}
|
||
|
|
||
|
class Header extends SvelteComponentDev {
|
||
|
constructor(options) {
|
||
|
super(options);
|
||
|
init$1(this, options, instance$3, create_fragment$3, safe_not_equal, {});
|
||
|
|
||
|
dispatch_dev("SvelteRegisterComponent", {
|
||
|
component: this,
|
||
|
tagName: "Header",
|
||
|
options,
|
||
|
id: create_fragment$3.name
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* src/routes/_layout.svelte generated by Svelte v3.42.1 */
|
||
|
const file$1 = "src/routes/_layout.svelte";
|
||
|
|
||
|
function create_fragment$2(ctx) {
|
||
|
let header;
|
||
|
let t;
|
||
|
let main;
|
||
|
let current;
|
||
|
header = new Header({ $$inline: true });
|
||
|
const default_slot_template = /*#slots*/ ctx[1].default;
|
||
|
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[0], null);
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
create_component(header.$$.fragment);
|
||
|
t = space();
|
||
|
main = element("main");
|
||
|
if (default_slot) default_slot.c();
|
||
|
this.h();
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
claim_component(header.$$.fragment, nodes);
|
||
|
t = claim_space(nodes);
|
||
|
main = claim_element(nodes, "MAIN", { class: true });
|
||
|
var main_nodes = children(main);
|
||
|
if (default_slot) default_slot.l(main_nodes);
|
||
|
main_nodes.forEach(detach_dev);
|
||
|
this.h();
|
||
|
},
|
||
|
h: function hydrate() {
|
||
|
attr_dev(main, "class", "svelte-1uhnsl8");
|
||
|
add_location(main, file$1, 21, 0, 339);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
mount_component(header, target, anchor);
|
||
|
insert_hydration_dev(target, t, anchor);
|
||
|
insert_hydration_dev(target, main, anchor);
|
||
|
|
||
|
if (default_slot) {
|
||
|
default_slot.m(main, null);
|
||
|
}
|
||
|
|
||
|
current = true;
|
||
|
},
|
||
|
p: function update(ctx, [dirty]) {
|
||
|
if (default_slot) {
|
||
|
if (default_slot.p && (!current || dirty & /*$$scope*/ 1)) {
|
||
|
update_slot_base(
|
||
|
default_slot,
|
||
|
default_slot_template,
|
||
|
ctx,
|
||
|
/*$$scope*/ ctx[0],
|
||
|
!current
|
||
|
? get_all_dirty_from_scope(/*$$scope*/ ctx[0])
|
||
|
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[0], dirty, null),
|
||
|
null
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
i: function intro(local) {
|
||
|
if (current) return;
|
||
|
transition_in(header.$$.fragment, local);
|
||
|
transition_in(default_slot, local);
|
||
|
current = true;
|
||
|
},
|
||
|
o: function outro(local) {
|
||
|
transition_out(header.$$.fragment, local);
|
||
|
transition_out(default_slot, local);
|
||
|
current = false;
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
destroy_component(header, detaching);
|
||
|
if (detaching) detach_dev(t);
|
||
|
if (detaching) detach_dev(main);
|
||
|
if (default_slot) default_slot.d(detaching);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_fragment$2.name,
|
||
|
type: "component",
|
||
|
source: "",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function instance$2($$self, $$props, $$invalidate) {
|
||
|
let { $$slots: slots = {}, $$scope } = $$props;
|
||
|
validate_slots('Layout', slots, ['default']);
|
||
|
const writable_props = [];
|
||
|
|
||
|
Object.keys($$props).forEach(key => {
|
||
|
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<Layout> was created with unknown prop '${key}'`);
|
||
|
});
|
||
|
|
||
|
$$self.$$set = $$props => {
|
||
|
if ('$$scope' in $$props) $$invalidate(0, $$scope = $$props.$$scope);
|
||
|
};
|
||
|
|
||
|
$$self.$capture_state = () => ({ Header });
|
||
|
return [$$scope, slots];
|
||
|
}
|
||
|
|
||
|
class Layout extends SvelteComponentDev {
|
||
|
constructor(options) {
|
||
|
super(options);
|
||
|
init$1(this, options, instance$2, create_fragment$2, safe_not_equal, {});
|
||
|
|
||
|
dispatch_dev("SvelteRegisterComponent", {
|
||
|
component: this,
|
||
|
tagName: "Layout",
|
||
|
options,
|
||
|
id: create_fragment$2.name
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* src/routes/_error.svelte generated by Svelte v3.42.1 */
|
||
|
|
||
|
const { Error: Error_1$1 } = globals;
|
||
|
const file = "src/routes/_error.svelte";
|
||
|
|
||
|
// (38:0) {#if dev && error.stack}
|
||
|
function create_if_block$1(ctx) {
|
||
|
let pre;
|
||
|
let t_value = /*error*/ ctx[1].stack + "";
|
||
|
let t;
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
pre = element("pre");
|
||
|
t = text(t_value);
|
||
|
this.h();
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
pre = claim_element(nodes, "PRE", {});
|
||
|
var pre_nodes = children(pre);
|
||
|
t = claim_text(pre_nodes, t_value);
|
||
|
pre_nodes.forEach(detach_dev);
|
||
|
this.h();
|
||
|
},
|
||
|
h: function hydrate() {
|
||
|
add_location(pre, file, 38, 1, 443);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
insert_hydration_dev(target, pre, anchor);
|
||
|
append_hydration_dev(pre, t);
|
||
|
},
|
||
|
p: function update(ctx, dirty) {
|
||
|
if (dirty & /*error*/ 2 && t_value !== (t_value = /*error*/ ctx[1].stack + "")) set_data_dev(t, t_value);
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
if (detaching) detach_dev(pre);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_if_block$1.name,
|
||
|
type: "if",
|
||
|
source: "(38:0) {#if dev && error.stack}",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function create_fragment$1(ctx) {
|
||
|
let title_value;
|
||
|
let t0;
|
||
|
let h1;
|
||
|
let t1;
|
||
|
let t2;
|
||
|
let p;
|
||
|
let t3_value = /*error*/ ctx[1].message + "";
|
||
|
let t3;
|
||
|
let t4;
|
||
|
let if_block_anchor;
|
||
|
document.title = title_value = /*status*/ ctx[0];
|
||
|
let if_block = /*dev*/ ctx[2] && /*error*/ ctx[1].stack && create_if_block$1(ctx);
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
t0 = space();
|
||
|
h1 = element("h1");
|
||
|
t1 = text(/*status*/ ctx[0]);
|
||
|
t2 = space();
|
||
|
p = element("p");
|
||
|
t3 = text(t3_value);
|
||
|
t4 = space();
|
||
|
if (if_block) if_block.c();
|
||
|
if_block_anchor = empty();
|
||
|
this.h();
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
const head_nodes = query_selector_all('[data-svelte=\"svelte-1o9r2ue\"]', document.head);
|
||
|
head_nodes.forEach(detach_dev);
|
||
|
t0 = claim_space(nodes);
|
||
|
h1 = claim_element(nodes, "H1", { class: true });
|
||
|
var h1_nodes = children(h1);
|
||
|
t1 = claim_text(h1_nodes, /*status*/ ctx[0]);
|
||
|
h1_nodes.forEach(detach_dev);
|
||
|
t2 = claim_space(nodes);
|
||
|
p = claim_element(nodes, "P", { class: true });
|
||
|
var p_nodes = children(p);
|
||
|
t3 = claim_text(p_nodes, t3_value);
|
||
|
p_nodes.forEach(detach_dev);
|
||
|
t4 = claim_space(nodes);
|
||
|
if (if_block) if_block.l(nodes);
|
||
|
if_block_anchor = empty();
|
||
|
this.h();
|
||
|
},
|
||
|
h: function hydrate() {
|
||
|
attr_dev(h1, "class", "svelte-8od9u6");
|
||
|
add_location(h1, file, 33, 0, 374);
|
||
|
attr_dev(p, "class", "svelte-8od9u6");
|
||
|
add_location(p, file, 35, 0, 393);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
insert_hydration_dev(target, t0, anchor);
|
||
|
insert_hydration_dev(target, h1, anchor);
|
||
|
append_hydration_dev(h1, t1);
|
||
|
insert_hydration_dev(target, t2, anchor);
|
||
|
insert_hydration_dev(target, p, anchor);
|
||
|
append_hydration_dev(p, t3);
|
||
|
insert_hydration_dev(target, t4, anchor);
|
||
|
if (if_block) if_block.m(target, anchor);
|
||
|
insert_hydration_dev(target, if_block_anchor, anchor);
|
||
|
},
|
||
|
p: function update(ctx, [dirty]) {
|
||
|
if (dirty & /*status*/ 1 && title_value !== (title_value = /*status*/ ctx[0])) {
|
||
|
document.title = title_value;
|
||
|
}
|
||
|
|
||
|
if (dirty & /*status*/ 1) set_data_dev(t1, /*status*/ ctx[0]);
|
||
|
if (dirty & /*error*/ 2 && t3_value !== (t3_value = /*error*/ ctx[1].message + "")) set_data_dev(t3, t3_value);
|
||
|
|
||
|
if (/*dev*/ ctx[2] && /*error*/ ctx[1].stack) {
|
||
|
if (if_block) {
|
||
|
if_block.p(ctx, dirty);
|
||
|
} else {
|
||
|
if_block = create_if_block$1(ctx);
|
||
|
if_block.c();
|
||
|
if_block.m(if_block_anchor.parentNode, if_block_anchor);
|
||
|
}
|
||
|
} else if (if_block) {
|
||
|
if_block.d(1);
|
||
|
if_block = null;
|
||
|
}
|
||
|
},
|
||
|
i: noop,
|
||
|
o: noop,
|
||
|
d: function destroy(detaching) {
|
||
|
if (detaching) detach_dev(t0);
|
||
|
if (detaching) detach_dev(h1);
|
||
|
if (detaching) detach_dev(t2);
|
||
|
if (detaching) detach_dev(p);
|
||
|
if (detaching) detach_dev(t4);
|
||
|
if (if_block) if_block.d(detaching);
|
||
|
if (detaching) detach_dev(if_block_anchor);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_fragment$1.name,
|
||
|
type: "component",
|
||
|
source: "",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function instance$1($$self, $$props, $$invalidate) {
|
||
|
let { $$slots: slots = {}, $$scope } = $$props;
|
||
|
validate_slots('Error', slots, []);
|
||
|
let { status } = $$props;
|
||
|
let { error } = $$props;
|
||
|
const dev = "development" === 'development';
|
||
|
const writable_props = ['status', 'error'];
|
||
|
|
||
|
Object.keys($$props).forEach(key => {
|
||
|
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<Error> was created with unknown prop '${key}'`);
|
||
|
});
|
||
|
|
||
|
$$self.$$set = $$props => {
|
||
|
if ('status' in $$props) $$invalidate(0, status = $$props.status);
|
||
|
if ('error' in $$props) $$invalidate(1, error = $$props.error);
|
||
|
};
|
||
|
|
||
|
$$self.$capture_state = () => ({ status, error, dev });
|
||
|
|
||
|
$$self.$inject_state = $$props => {
|
||
|
if ('status' in $$props) $$invalidate(0, status = $$props.status);
|
||
|
if ('error' in $$props) $$invalidate(1, error = $$props.error);
|
||
|
};
|
||
|
|
||
|
if ($$props && "$$inject" in $$props) {
|
||
|
$$self.$inject_state($$props.$$inject);
|
||
|
}
|
||
|
|
||
|
return [status, error, dev];
|
||
|
}
|
||
|
|
||
|
class Error$1 extends SvelteComponentDev {
|
||
|
constructor(options) {
|
||
|
super(options);
|
||
|
init$1(this, options, instance$1, create_fragment$1, safe_not_equal, { status: 0, error: 1 });
|
||
|
|
||
|
dispatch_dev("SvelteRegisterComponent", {
|
||
|
component: this,
|
||
|
tagName: "Error",
|
||
|
options,
|
||
|
id: create_fragment$1.name
|
||
|
});
|
||
|
|
||
|
const { ctx } = this.$$;
|
||
|
const props = options.props || {};
|
||
|
|
||
|
if (/*status*/ ctx[0] === undefined && !('status' in props)) {
|
||
|
console.warn("<Error> was created without expected prop 'status'");
|
||
|
}
|
||
|
|
||
|
if (/*error*/ ctx[1] === undefined && !('error' in props)) {
|
||
|
console.warn("<Error> was created without expected prop 'error'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
get status() {
|
||
|
throw new Error_1$1("<Error>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set status(value) {
|
||
|
throw new Error_1$1("<Error>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get error() {
|
||
|
throw new Error_1$1("<Error>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set error(value) {
|
||
|
throw new Error_1$1("<Error>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* src/node_modules/@sapper/internal/App.svelte generated by Svelte v3.42.1 */
|
||
|
|
||
|
const { Error: Error_1 } = globals;
|
||
|
|
||
|
// (23:1) {:else}
|
||
|
function create_else_block(ctx) {
|
||
|
let switch_instance;
|
||
|
let switch_instance_anchor;
|
||
|
let current;
|
||
|
const switch_instance_spread_levels = [/*level1*/ ctx[4].props];
|
||
|
var switch_value = /*level1*/ ctx[4].component;
|
||
|
|
||
|
function switch_props(ctx) {
|
||
|
let switch_instance_props = {};
|
||
|
|
||
|
for (let i = 0; i < switch_instance_spread_levels.length; i += 1) {
|
||
|
switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]);
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
props: switch_instance_props,
|
||
|
$$inline: true
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (switch_value) {
|
||
|
switch_instance = new switch_value(switch_props());
|
||
|
}
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
if (switch_instance) create_component(switch_instance.$$.fragment);
|
||
|
switch_instance_anchor = empty();
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
if (switch_instance) claim_component(switch_instance.$$.fragment, nodes);
|
||
|
switch_instance_anchor = empty();
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
if (switch_instance) {
|
||
|
mount_component(switch_instance, target, anchor);
|
||
|
}
|
||
|
|
||
|
insert_hydration_dev(target, switch_instance_anchor, anchor);
|
||
|
current = true;
|
||
|
},
|
||
|
p: function update(ctx, dirty) {
|
||
|
const switch_instance_changes = (dirty & /*level1*/ 16)
|
||
|
? get_spread_update(switch_instance_spread_levels, [get_spread_object(/*level1*/ ctx[4].props)])
|
||
|
: {};
|
||
|
|
||
|
if (switch_value !== (switch_value = /*level1*/ ctx[4].component)) {
|
||
|
if (switch_instance) {
|
||
|
group_outros();
|
||
|
const old_component = switch_instance;
|
||
|
|
||
|
transition_out(old_component.$$.fragment, 1, 0, () => {
|
||
|
destroy_component(old_component, 1);
|
||
|
});
|
||
|
|
||
|
check_outros();
|
||
|
}
|
||
|
|
||
|
if (switch_value) {
|
||
|
switch_instance = new switch_value(switch_props());
|
||
|
create_component(switch_instance.$$.fragment);
|
||
|
transition_in(switch_instance.$$.fragment, 1);
|
||
|
mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
|
||
|
} else {
|
||
|
switch_instance = null;
|
||
|
}
|
||
|
} else if (switch_value) {
|
||
|
switch_instance.$set(switch_instance_changes);
|
||
|
}
|
||
|
},
|
||
|
i: function intro(local) {
|
||
|
if (current) return;
|
||
|
if (switch_instance) transition_in(switch_instance.$$.fragment, local);
|
||
|
current = true;
|
||
|
},
|
||
|
o: function outro(local) {
|
||
|
if (switch_instance) transition_out(switch_instance.$$.fragment, local);
|
||
|
current = false;
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
if (detaching) detach_dev(switch_instance_anchor);
|
||
|
if (switch_instance) destroy_component(switch_instance, detaching);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_else_block.name,
|
||
|
type: "else",
|
||
|
source: "(23:1) {:else}",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
// (21:1) {#if error}
|
||
|
function create_if_block(ctx) {
|
||
|
let error_1;
|
||
|
let current;
|
||
|
|
||
|
error_1 = new Error$1({
|
||
|
props: {
|
||
|
error: /*error*/ ctx[0],
|
||
|
status: /*status*/ ctx[1]
|
||
|
},
|
||
|
$$inline: true
|
||
|
});
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
create_component(error_1.$$.fragment);
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
claim_component(error_1.$$.fragment, nodes);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
mount_component(error_1, target, anchor);
|
||
|
current = true;
|
||
|
},
|
||
|
p: function update(ctx, dirty) {
|
||
|
const error_1_changes = {};
|
||
|
if (dirty & /*error*/ 1) error_1_changes.error = /*error*/ ctx[0];
|
||
|
if (dirty & /*status*/ 2) error_1_changes.status = /*status*/ ctx[1];
|
||
|
error_1.$set(error_1_changes);
|
||
|
},
|
||
|
i: function intro(local) {
|
||
|
if (current) return;
|
||
|
transition_in(error_1.$$.fragment, local);
|
||
|
current = true;
|
||
|
},
|
||
|
o: function outro(local) {
|
||
|
transition_out(error_1.$$.fragment, local);
|
||
|
current = false;
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
destroy_component(error_1, detaching);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_if_block.name,
|
||
|
type: "if",
|
||
|
source: "(21:1) {#if error}",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
// (20:0) <Layout segment="{segments[0]}" {...level0.props}>
|
||
|
function create_default_slot(ctx) {
|
||
|
let current_block_type_index;
|
||
|
let if_block;
|
||
|
let if_block_anchor;
|
||
|
let current;
|
||
|
const if_block_creators = [create_if_block, create_else_block];
|
||
|
const if_blocks = [];
|
||
|
|
||
|
function select_block_type(ctx, dirty) {
|
||
|
if (/*error*/ ctx[0]) return 0;
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
current_block_type_index = select_block_type(ctx);
|
||
|
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
if_block.c();
|
||
|
if_block_anchor = empty();
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
if_block.l(nodes);
|
||
|
if_block_anchor = empty();
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
if_blocks[current_block_type_index].m(target, anchor);
|
||
|
insert_hydration_dev(target, if_block_anchor, anchor);
|
||
|
current = true;
|
||
|
},
|
||
|
p: function update(ctx, dirty) {
|
||
|
let previous_block_index = current_block_type_index;
|
||
|
current_block_type_index = select_block_type(ctx);
|
||
|
|
||
|
if (current_block_type_index === previous_block_index) {
|
||
|
if_blocks[current_block_type_index].p(ctx, dirty);
|
||
|
} else {
|
||
|
group_outros();
|
||
|
|
||
|
transition_out(if_blocks[previous_block_index], 1, 1, () => {
|
||
|
if_blocks[previous_block_index] = null;
|
||
|
});
|
||
|
|
||
|
check_outros();
|
||
|
if_block = if_blocks[current_block_type_index];
|
||
|
|
||
|
if (!if_block) {
|
||
|
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
||
|
if_block.c();
|
||
|
} else {
|
||
|
if_block.p(ctx, dirty);
|
||
|
}
|
||
|
|
||
|
transition_in(if_block, 1);
|
||
|
if_block.m(if_block_anchor.parentNode, if_block_anchor);
|
||
|
}
|
||
|
},
|
||
|
i: function intro(local) {
|
||
|
if (current) return;
|
||
|
transition_in(if_block);
|
||
|
current = true;
|
||
|
},
|
||
|
o: function outro(local) {
|
||
|
transition_out(if_block);
|
||
|
current = false;
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
if_blocks[current_block_type_index].d(detaching);
|
||
|
if (detaching) detach_dev(if_block_anchor);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_default_slot.name,
|
||
|
type: "slot",
|
||
|
source: "(20:0) <Layout segment=\\\"{segments[0]}\\\" {...level0.props}>",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function create_fragment(ctx) {
|
||
|
let layout;
|
||
|
let current;
|
||
|
const layout_spread_levels = [{ segment: /*segments*/ ctx[2][0] }, /*level0*/ ctx[3].props];
|
||
|
|
||
|
let layout_props = {
|
||
|
$$slots: { default: [create_default_slot] },
|
||
|
$$scope: { ctx }
|
||
|
};
|
||
|
|
||
|
for (let i = 0; i < layout_spread_levels.length; i += 1) {
|
||
|
layout_props = assign(layout_props, layout_spread_levels[i]);
|
||
|
}
|
||
|
|
||
|
layout = new Layout({ props: layout_props, $$inline: true });
|
||
|
|
||
|
const block = {
|
||
|
c: function create() {
|
||
|
create_component(layout.$$.fragment);
|
||
|
},
|
||
|
l: function claim(nodes) {
|
||
|
claim_component(layout.$$.fragment, nodes);
|
||
|
},
|
||
|
m: function mount(target, anchor) {
|
||
|
mount_component(layout, target, anchor);
|
||
|
current = true;
|
||
|
},
|
||
|
p: function update(ctx, [dirty]) {
|
||
|
const layout_changes = (dirty & /*segments, level0*/ 12)
|
||
|
? get_spread_update(layout_spread_levels, [
|
||
|
dirty & /*segments*/ 4 && { segment: /*segments*/ ctx[2][0] },
|
||
|
dirty & /*level0*/ 8 && get_spread_object(/*level0*/ ctx[3].props)
|
||
|
])
|
||
|
: {};
|
||
|
|
||
|
if (dirty & /*$$scope, error, status, level1*/ 147) {
|
||
|
layout_changes.$$scope = { dirty, ctx };
|
||
|
}
|
||
|
|
||
|
layout.$set(layout_changes);
|
||
|
},
|
||
|
i: function intro(local) {
|
||
|
if (current) return;
|
||
|
transition_in(layout.$$.fragment, local);
|
||
|
current = true;
|
||
|
},
|
||
|
o: function outro(local) {
|
||
|
transition_out(layout.$$.fragment, local);
|
||
|
current = false;
|
||
|
},
|
||
|
d: function destroy(detaching) {
|
||
|
destroy_component(layout, detaching);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
dispatch_dev("SvelteRegisterBlock", {
|
||
|
block,
|
||
|
id: create_fragment.name,
|
||
|
type: "component",
|
||
|
source: "",
|
||
|
ctx
|
||
|
});
|
||
|
|
||
|
return block;
|
||
|
}
|
||
|
|
||
|
function instance($$self, $$props, $$invalidate) {
|
||
|
let { $$slots: slots = {}, $$scope } = $$props;
|
||
|
validate_slots('App', slots, []);
|
||
|
let { stores } = $$props;
|
||
|
let { error } = $$props;
|
||
|
let { status } = $$props;
|
||
|
let { segments } = $$props;
|
||
|
let { level0 } = $$props;
|
||
|
let { level1 = null } = $$props;
|
||
|
let { notify } = $$props;
|
||
|
afterUpdate(notify);
|
||
|
setContext(CONTEXT_KEY, stores);
|
||
|
const writable_props = ['stores', 'error', 'status', 'segments', 'level0', 'level1', 'notify'];
|
||
|
|
||
|
Object.keys($$props).forEach(key => {
|
||
|
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<App> was created with unknown prop '${key}'`);
|
||
|
});
|
||
|
|
||
|
$$self.$$set = $$props => {
|
||
|
if ('stores' in $$props) $$invalidate(5, stores = $$props.stores);
|
||
|
if ('error' in $$props) $$invalidate(0, error = $$props.error);
|
||
|
if ('status' in $$props) $$invalidate(1, status = $$props.status);
|
||
|
if ('segments' in $$props) $$invalidate(2, segments = $$props.segments);
|
||
|
if ('level0' in $$props) $$invalidate(3, level0 = $$props.level0);
|
||
|
if ('level1' in $$props) $$invalidate(4, level1 = $$props.level1);
|
||
|
if ('notify' in $$props) $$invalidate(6, notify = $$props.notify);
|
||
|
};
|
||
|
|
||
|
$$self.$capture_state = () => ({
|
||
|
setContext,
|
||
|
afterUpdate,
|
||
|
CONTEXT_KEY,
|
||
|
Layout,
|
||
|
Error: Error$1,
|
||
|
stores,
|
||
|
error,
|
||
|
status,
|
||
|
segments,
|
||
|
level0,
|
||
|
level1,
|
||
|
notify
|
||
|
});
|
||
|
|
||
|
$$self.$inject_state = $$props => {
|
||
|
if ('stores' in $$props) $$invalidate(5, stores = $$props.stores);
|
||
|
if ('error' in $$props) $$invalidate(0, error = $$props.error);
|
||
|
if ('status' in $$props) $$invalidate(1, status = $$props.status);
|
||
|
if ('segments' in $$props) $$invalidate(2, segments = $$props.segments);
|
||
|
if ('level0' in $$props) $$invalidate(3, level0 = $$props.level0);
|
||
|
if ('level1' in $$props) $$invalidate(4, level1 = $$props.level1);
|
||
|
if ('notify' in $$props) $$invalidate(6, notify = $$props.notify);
|
||
|
};
|
||
|
|
||
|
if ($$props && "$$inject" in $$props) {
|
||
|
$$self.$inject_state($$props.$$inject);
|
||
|
}
|
||
|
|
||
|
return [error, status, segments, level0, level1, stores, notify];
|
||
|
}
|
||
|
|
||
|
class App extends SvelteComponentDev {
|
||
|
constructor(options) {
|
||
|
super(options);
|
||
|
|
||
|
init$1(this, options, instance, create_fragment, safe_not_equal, {
|
||
|
stores: 5,
|
||
|
error: 0,
|
||
|
status: 1,
|
||
|
segments: 2,
|
||
|
level0: 3,
|
||
|
level1: 4,
|
||
|
notify: 6
|
||
|
});
|
||
|
|
||
|
dispatch_dev("SvelteRegisterComponent", {
|
||
|
component: this,
|
||
|
tagName: "App",
|
||
|
options,
|
||
|
id: create_fragment.name
|
||
|
});
|
||
|
|
||
|
const { ctx } = this.$$;
|
||
|
const props = options.props || {};
|
||
|
|
||
|
if (/*stores*/ ctx[5] === undefined && !('stores' in props)) {
|
||
|
console.warn("<App> was created without expected prop 'stores'");
|
||
|
}
|
||
|
|
||
|
if (/*error*/ ctx[0] === undefined && !('error' in props)) {
|
||
|
console.warn("<App> was created without expected prop 'error'");
|
||
|
}
|
||
|
|
||
|
if (/*status*/ ctx[1] === undefined && !('status' in props)) {
|
||
|
console.warn("<App> was created without expected prop 'status'");
|
||
|
}
|
||
|
|
||
|
if (/*segments*/ ctx[2] === undefined && !('segments' in props)) {
|
||
|
console.warn("<App> was created without expected prop 'segments'");
|
||
|
}
|
||
|
|
||
|
if (/*level0*/ ctx[3] === undefined && !('level0' in props)) {
|
||
|
console.warn("<App> was created without expected prop 'level0'");
|
||
|
}
|
||
|
|
||
|
if (/*notify*/ ctx[6] === undefined && !('notify' in props)) {
|
||
|
console.warn("<App> was created without expected prop 'notify'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
get stores() {
|
||
|
throw new Error_1("<App>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set stores(value) {
|
||
|
throw new Error_1("<App>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get error() {
|
||
|
throw new Error_1("<App>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set error(value) {
|
||
|
throw new Error_1("<App>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get status() {
|
||
|
throw new Error_1("<App>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set status(value) {
|
||
|
throw new Error_1("<App>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get segments() {
|
||
|
throw new Error_1("<App>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set segments(value) {
|
||
|
throw new Error_1("<App>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get level0() {
|
||
|
throw new Error_1("<App>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set level0(value) {
|
||
|
throw new Error_1("<App>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get level1() {
|
||
|
throw new Error_1("<App>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set level1(value) {
|
||
|
throw new Error_1("<App>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
get notify() {
|
||
|
throw new Error_1("<App>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
|
||
|
set notify(value) {
|
||
|
throw new Error_1("<App>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// This file is generated by Sapper — do not edit it!
|
||
|
|
||
|
const ignore = [];
|
||
|
|
||
|
const components = [
|
||
|
{
|
||
|
js: () => Promise.all([import('./index.e032c4f2.js'), __inject_styles(["client-7bc0b3e2.css"])]).then(function(x) { return x[0]; })
|
||
|
},
|
||
|
{
|
||
|
js: () => Promise.all([import('./settings.df845f1b.js'), __inject_styles(["client-7bc0b3e2.css"])]).then(function(x) { return x[0]; })
|
||
|
},
|
||
|
{
|
||
|
js: () => Promise.all([import('./about.1b796c84.js'), __inject_styles(["client-7bc0b3e2.css"])]).then(function(x) { return x[0]; })
|
||
|
}
|
||
|
];
|
||
|
|
||
|
const routes = [
|
||
|
{
|
||
|
// index.svelte
|
||
|
pattern: /^\/$/,
|
||
|
parts: [
|
||
|
{ i: 0 }
|
||
|
]
|
||
|
},
|
||
|
|
||
|
{
|
||
|
// settings.svelte
|
||
|
pattern: /^\/settings\/?$/,
|
||
|
parts: [
|
||
|
{ i: 1 }
|
||
|
]
|
||
|
},
|
||
|
|
||
|
{
|
||
|
// about.svelte
|
||
|
pattern: /^\/about\/?$/,
|
||
|
parts: [
|
||
|
{ i: 2 }
|
||
|
]
|
||
|
}
|
||
|
];
|
||
|
|
||
|
if (typeof window !== 'undefined') {
|
||
|
Promise.all([import('./sapper-dev-client.146c9185.js'), ]).then(function(x) { return x[0]; }).then(client => {
|
||
|
client.connect(10000);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/*! *****************************************************************************
|
||
|
Copyright (c) Microsoft Corporation.
|
||
|
|
||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||
|
purpose with or without fee is hereby granted.
|
||
|
|
||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||
|
PERFORMANCE OF THIS SOFTWARE.
|
||
|
***************************************************************************** */
|
||
|
|
||
|
function __awaiter(thisArg, _arguments, P, generator) {
|
||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function find_anchor(node) {
|
||
|
while (node && node.nodeName.toUpperCase() !== 'A')
|
||
|
node = node.parentNode; // SVG <a> elements have a lowercase name
|
||
|
return node;
|
||
|
}
|
||
|
|
||
|
let uid = 1;
|
||
|
function set_uid(n) {
|
||
|
uid = n;
|
||
|
}
|
||
|
let cid;
|
||
|
function set_cid(n) {
|
||
|
cid = n;
|
||
|
}
|
||
|
const _history = typeof history !== 'undefined' ? history : {
|
||
|
pushState: () => { },
|
||
|
replaceState: () => { },
|
||
|
scrollRestoration: 'auto'
|
||
|
};
|
||
|
const scroll_history = {};
|
||
|
function load_current_page() {
|
||
|
return Promise.resolve().then(() => {
|
||
|
const { hash, href } = location;
|
||
|
_history.replaceState({ id: uid }, '', href);
|
||
|
const target = select_target(new URL(location.href));
|
||
|
if (target)
|
||
|
return navigate(target, uid, true, hash);
|
||
|
});
|
||
|
}
|
||
|
let base_url;
|
||
|
let handle_target;
|
||
|
function init(base, handler) {
|
||
|
base_url = base;
|
||
|
handle_target = handler;
|
||
|
if ('scrollRestoration' in _history) {
|
||
|
_history.scrollRestoration = 'manual';
|
||
|
}
|
||
|
// Adopted from Nuxt.js
|
||
|
// Reset scrollRestoration to auto when leaving page, allowing page reload
|
||
|
// and back-navigation from other pages to use the browser to restore the
|
||
|
// scrolling position.
|
||
|
addEventListener('beforeunload', () => {
|
||
|
_history.scrollRestoration = 'auto';
|
||
|
});
|
||
|
// Setting scrollRestoration to manual again when returning to this page.
|
||
|
addEventListener('load', () => {
|
||
|
_history.scrollRestoration = 'manual';
|
||
|
});
|
||
|
addEventListener('click', handle_click);
|
||
|
addEventListener('popstate', handle_popstate);
|
||
|
}
|
||
|
function extract_query(search) {
|
||
|
const query = Object.create(null);
|
||
|
if (search.length > 0) {
|
||
|
search.slice(1).split('&').forEach(searchParam => {
|
||
|
const [, key, value = ''] = /([^=]*)(?:=(.*))?/.exec(decodeURIComponent(searchParam.replace(/\+/g, ' ')));
|
||
|
if (typeof query[key] === 'string')
|
||
|
query[key] = [query[key]];
|
||
|
if (typeof query[key] === 'object')
|
||
|
query[key].push(value);
|
||
|
else
|
||
|
query[key] = value;
|
||
|
});
|
||
|
}
|
||
|
return query;
|
||
|
}
|
||
|
function select_target(url) {
|
||
|
if (url.origin !== location.origin)
|
||
|
return null;
|
||
|
if (!url.pathname.startsWith(base_url))
|
||
|
return null;
|
||
|
let path = url.pathname.slice(base_url.length);
|
||
|
if (path === '') {
|
||
|
path = '/';
|
||
|
}
|
||
|
// avoid accidental clashes between server routes and page routes
|
||
|
if (ignore.some(pattern => pattern.test(path)))
|
||
|
return;
|
||
|
for (let i = 0; i < routes.length; i += 1) {
|
||
|
const route = routes[i];
|
||
|
const match = route.pattern.exec(path);
|
||
|
if (match) {
|
||
|
const query = extract_query(url.search);
|
||
|
const part = route.parts[route.parts.length - 1];
|
||
|
const params = part.params ? part.params(match) : {};
|
||
|
const page = { host: location.host, path, query, params };
|
||
|
return { href: url.href, route, match, page };
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function handle_click(event) {
|
||
|
// Adapted from https://github.com/visionmedia/page.js
|
||
|
// MIT license https://github.com/visionmedia/page.js#license
|
||
|
if (which(event) !== 1)
|
||
|
return;
|
||
|
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
|
||
|
return;
|
||
|
if (event.defaultPrevented)
|
||
|
return;
|
||
|
const a = find_anchor(event.target);
|
||
|
if (!a)
|
||
|
return;
|
||
|
if (!a.href)
|
||
|
return;
|
||
|
// check if link is inside an svg
|
||
|
// in this case, both href and target are always inside an object
|
||
|
const svg = typeof a.href === 'object' && a.href.constructor.name === 'SVGAnimatedString';
|
||
|
const href = String(svg ? a.href.baseVal : a.href);
|
||
|
if (href === location.href) {
|
||
|
if (!location.hash)
|
||
|
event.preventDefault();
|
||
|
return;
|
||
|
}
|
||
|
// Ignore if tag has
|
||
|
// 1. 'download' attribute
|
||
|
// 2. rel='external' attribute
|
||
|
if (a.hasAttribute('download') || a.getAttribute('rel') === 'external')
|
||
|
return;
|
||
|
// Ignore if <a> has a target
|
||
|
if (svg ? a.target.baseVal : a.target)
|
||
|
return;
|
||
|
const url = new URL(href);
|
||
|
// Don't handle hash changes
|
||
|
if (url.pathname === location.pathname && url.search === location.search)
|
||
|
return;
|
||
|
const target = select_target(url);
|
||
|
if (target) {
|
||
|
const noscroll = a.hasAttribute('sapper:noscroll');
|
||
|
navigate(target, null, noscroll, url.hash);
|
||
|
event.preventDefault();
|
||
|
_history.pushState({ id: cid }, '', url.href);
|
||
|
}
|
||
|
}
|
||
|
function which(event) {
|
||
|
return event.which === null ? event.button : event.which;
|
||
|
}
|
||
|
function scroll_state() {
|
||
|
return {
|
||
|
x: pageXOffset,
|
||
|
y: pageYOffset
|
||
|
};
|
||
|
}
|
||
|
function handle_popstate(event) {
|
||
|
scroll_history[cid] = scroll_state();
|
||
|
if (event.state) {
|
||
|
const url = new URL(location.href);
|
||
|
const target = select_target(url);
|
||
|
if (target) {
|
||
|
navigate(target, event.state.id);
|
||
|
}
|
||
|
else {
|
||
|
// eslint-disable-next-line
|
||
|
location.href = location.href; // nosonar
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
// hashchange
|
||
|
set_uid(uid + 1);
|
||
|
set_cid(uid);
|
||
|
_history.replaceState({ id: cid }, '', location.href);
|
||
|
}
|
||
|
}
|
||
|
function navigate(dest, id, noscroll, hash) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
const popstate = !!id;
|
||
|
if (popstate) {
|
||
|
cid = id;
|
||
|
}
|
||
|
else {
|
||
|
const current_scroll = scroll_state();
|
||
|
// clicked on a link. preserve scroll state
|
||
|
scroll_history[cid] = current_scroll;
|
||
|
cid = id = ++uid;
|
||
|
scroll_history[cid] = noscroll ? current_scroll : { x: 0, y: 0 };
|
||
|
}
|
||
|
yield handle_target(dest);
|
||
|
if (document.activeElement && (document.activeElement instanceof HTMLElement))
|
||
|
document.activeElement.blur();
|
||
|
if (!noscroll) {
|
||
|
let scroll = scroll_history[id];
|
||
|
let deep_linked;
|
||
|
if (hash) {
|
||
|
// scroll is an element id (from a hash), we need to compute y.
|
||
|
deep_linked = document.getElementById(hash.slice(1));
|
||
|
if (deep_linked) {
|
||
|
scroll = {
|
||
|
x: 0,
|
||
|
y: deep_linked.getBoundingClientRect().top + scrollY
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
scroll_history[cid] = scroll;
|
||
|
if (popstate || deep_linked) {
|
||
|
scrollTo(scroll.x, scroll.y);
|
||
|
}
|
||
|
else {
|
||
|
scrollTo(0, 0);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function get_base_uri(window_document) {
|
||
|
let baseURI = window_document.baseURI;
|
||
|
if (!baseURI) {
|
||
|
const baseTags = window_document.getElementsByTagName('base');
|
||
|
baseURI = baseTags.length ? baseTags[0].href : window_document.URL;
|
||
|
}
|
||
|
return baseURI;
|
||
|
}
|
||
|
|
||
|
let prefetching = null;
|
||
|
let mousemove_timeout;
|
||
|
function start() {
|
||
|
addEventListener('touchstart', trigger_prefetch);
|
||
|
addEventListener('mousemove', handle_mousemove);
|
||
|
}
|
||
|
function prefetch(href) {
|
||
|
const target = select_target(new URL(href, get_base_uri(document)));
|
||
|
if (target) {
|
||
|
if (!prefetching || href !== prefetching.href) {
|
||
|
prefetching = { href, promise: hydrate_target(target) };
|
||
|
}
|
||
|
return prefetching.promise;
|
||
|
}
|
||
|
}
|
||
|
function get_prefetched(target) {
|
||
|
if (prefetching && prefetching.href === target.href) {
|
||
|
return prefetching.promise;
|
||
|
}
|
||
|
else {
|
||
|
return hydrate_target(target);
|
||
|
}
|
||
|
}
|
||
|
function trigger_prefetch(event) {
|
||
|
const a = find_anchor(event.target);
|
||
|
if (a && a.rel === 'prefetch') {
|
||
|
prefetch(a.href);
|
||
|
}
|
||
|
}
|
||
|
function handle_mousemove(event) {
|
||
|
clearTimeout(mousemove_timeout);
|
||
|
mousemove_timeout = setTimeout(() => {
|
||
|
trigger_prefetch(event);
|
||
|
}, 20);
|
||
|
}
|
||
|
|
||
|
function goto(href, opts = { noscroll: false, replaceState: false }) {
|
||
|
const target = select_target(new URL(href, get_base_uri(document)));
|
||
|
if (target) {
|
||
|
_history[opts.replaceState ? 'replaceState' : 'pushState']({ id: cid }, '', href);
|
||
|
return navigate(target, null, opts.noscroll);
|
||
|
}
|
||
|
location.href = href;
|
||
|
return new Promise(() => {
|
||
|
/* never resolves */
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function page_store(value) {
|
||
|
const store = writable(value);
|
||
|
let ready = true;
|
||
|
function notify() {
|
||
|
ready = true;
|
||
|
store.update(val => val);
|
||
|
}
|
||
|
function set(new_value) {
|
||
|
ready = false;
|
||
|
store.set(new_value);
|
||
|
}
|
||
|
function subscribe(run) {
|
||
|
let old_value;
|
||
|
return store.subscribe((new_value) => {
|
||
|
if (old_value === undefined || (ready && new_value !== old_value)) {
|
||
|
run(old_value = new_value);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
return { notify, set, subscribe };
|
||
|
}
|
||
|
|
||
|
const initial_data = typeof __SAPPER__ !== 'undefined' && __SAPPER__;
|
||
|
let ready = false;
|
||
|
let root_component;
|
||
|
let current_token;
|
||
|
let root_preloaded;
|
||
|
let current_branch = [];
|
||
|
let current_query = '{}';
|
||
|
const stores = {
|
||
|
page: page_store({}),
|
||
|
preloading: writable(null),
|
||
|
session: writable(initial_data && initial_data.session)
|
||
|
};
|
||
|
let $session;
|
||
|
let session_dirty;
|
||
|
stores.session.subscribe((value) => __awaiter(void 0, void 0, void 0, function* () {
|
||
|
$session = value;
|
||
|
if (!ready)
|
||
|
return;
|
||
|
session_dirty = true;
|
||
|
const dest = select_target(new URL(location.href));
|
||
|
const token = current_token = {};
|
||
|
const { redirect, props, branch } = yield hydrate_target(dest);
|
||
|
if (token !== current_token)
|
||
|
return; // a secondary navigation happened while we were loading
|
||
|
if (redirect) {
|
||
|
yield goto(redirect.location, { replaceState: true });
|
||
|
}
|
||
|
else {
|
||
|
yield render(branch, props, buildPageContext(props, dest.page));
|
||
|
}
|
||
|
}));
|
||
|
let target;
|
||
|
function set_target(node) {
|
||
|
target = node;
|
||
|
}
|
||
|
function start$1(opts) {
|
||
|
set_target(opts.target);
|
||
|
init(initial_data.baseUrl, handle_target$1);
|
||
|
start();
|
||
|
if (initial_data.error) {
|
||
|
return Promise.resolve().then(() => {
|
||
|
return handle_error();
|
||
|
});
|
||
|
}
|
||
|
return load_current_page();
|
||
|
}
|
||
|
function handle_error() {
|
||
|
const { host, pathname, search } = location;
|
||
|
const { session, preloaded, status, error } = initial_data;
|
||
|
if (!root_preloaded) {
|
||
|
root_preloaded = preloaded && preloaded[0];
|
||
|
}
|
||
|
const props = {
|
||
|
error,
|
||
|
status,
|
||
|
session,
|
||
|
level0: {
|
||
|
props: root_preloaded
|
||
|
},
|
||
|
level1: {
|
||
|
props: {
|
||
|
status,
|
||
|
error
|
||
|
},
|
||
|
component: Error$1
|
||
|
},
|
||
|
segments: preloaded
|
||
|
};
|
||
|
const query = extract_query(search);
|
||
|
render([], props, { host, path: pathname, query, params: {}, error });
|
||
|
}
|
||
|
function buildPageContext(props, page) {
|
||
|
const { error } = props;
|
||
|
return Object.assign({ error }, page);
|
||
|
}
|
||
|
function handle_target$1(dest) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
if (root_component)
|
||
|
stores.preloading.set(true);
|
||
|
const hydrating = get_prefetched(dest);
|
||
|
const token = current_token = {};
|
||
|
const hydrated_target = yield hydrating;
|
||
|
const { redirect } = hydrated_target;
|
||
|
if (token !== current_token)
|
||
|
return; // a secondary navigation happened while we were loading
|
||
|
if (redirect) {
|
||
|
yield goto(redirect.location, { replaceState: true });
|
||
|
}
|
||
|
else {
|
||
|
const { props, branch } = hydrated_target;
|
||
|
yield render(branch, props, buildPageContext(props, dest.page));
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
function render(branch, props, page) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
stores.page.set(page);
|
||
|
stores.preloading.set(false);
|
||
|
if (root_component) {
|
||
|
root_component.$set(props);
|
||
|
}
|
||
|
else {
|
||
|
props.stores = {
|
||
|
page: { subscribe: stores.page.subscribe },
|
||
|
preloading: { subscribe: stores.preloading.subscribe },
|
||
|
session: stores.session
|
||
|
};
|
||
|
props.level0 = {
|
||
|
props: yield root_preloaded
|
||
|
};
|
||
|
props.notify = stores.page.notify;
|
||
|
root_component = new App({
|
||
|
target,
|
||
|
props,
|
||
|
hydrate: true
|
||
|
});
|
||
|
}
|
||
|
current_branch = branch;
|
||
|
current_query = JSON.stringify(page.query);
|
||
|
ready = true;
|
||
|
session_dirty = false;
|
||
|
});
|
||
|
}
|
||
|
function part_changed(i, segment, match, stringified_query) {
|
||
|
// TODO only check query string changes for preload functions
|
||
|
// that do in fact depend on it (using static analysis or
|
||
|
// runtime instrumentation)
|
||
|
if (stringified_query !== current_query)
|
||
|
return true;
|
||
|
const previous = current_branch[i];
|
||
|
if (!previous)
|
||
|
return false;
|
||
|
if (segment !== previous.segment)
|
||
|
return true;
|
||
|
if (previous.match) {
|
||
|
if (JSON.stringify(previous.match.slice(1, i + 2)) !== JSON.stringify(match.slice(1, i + 2))) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
function hydrate_target(dest) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
const { route, page } = dest;
|
||
|
const segments = page.path.split('/').filter(Boolean);
|
||
|
let redirect = null;
|
||
|
const props = { error: null, status: 200, segments: [segments[0]] };
|
||
|
const preload_context = {
|
||
|
fetch: (url, opts) => fetch(url, opts),
|
||
|
redirect: (statusCode, location) => {
|
||
|
if (redirect && (redirect.statusCode !== statusCode || redirect.location !== location)) {
|
||
|
throw new Error('Conflicting redirects');
|
||
|
}
|
||
|
redirect = { statusCode, location };
|
||
|
},
|
||
|
error: (status, error) => {
|
||
|
props.error = typeof error === 'string' ? new Error(error) : error;
|
||
|
props.status = status;
|
||
|
}
|
||
|
};
|
||
|
if (!root_preloaded) {
|
||
|
const root_preload = undefined || (() => ({}));
|
||
|
root_preloaded = initial_data.preloaded[0] || root_preload.call(preload_context, {
|
||
|
host: page.host,
|
||
|
path: page.path,
|
||
|
query: page.query,
|
||
|
params: {}
|
||
|
}, $session);
|
||
|
}
|
||
|
let branch;
|
||
|
let l = 1;
|
||
|
try {
|
||
|
const stringified_query = JSON.stringify(page.query);
|
||
|
const match = route.pattern.exec(page.path);
|
||
|
let segment_dirty = false;
|
||
|
branch = yield Promise.all(route.parts.map((part, i) => __awaiter(this, void 0, void 0, function* () {
|
||
|
const segment = segments[i];
|
||
|
if (part_changed(i, segment, match, stringified_query))
|
||
|
segment_dirty = true;
|
||
|
props.segments[l] = segments[i + 1]; // TODO make this less confusing
|
||
|
if (!part)
|
||
|
return { segment };
|
||
|
const j = l++;
|
||
|
if (!session_dirty && !segment_dirty && current_branch[i] && current_branch[i].part === part.i) {
|
||
|
return current_branch[i];
|
||
|
}
|
||
|
segment_dirty = false;
|
||
|
const { default: component, preload } = yield components[part.i].js();
|
||
|
let preloaded;
|
||
|
if (ready || !initial_data.preloaded[i + 1]) {
|
||
|
preloaded = preload
|
||
|
? yield preload.call(preload_context, {
|
||
|
host: page.host,
|
||
|
path: page.path,
|
||
|
query: page.query,
|
||
|
params: part.params ? part.params(dest.match) : {}
|
||
|
}, $session)
|
||
|
: {};
|
||
|
}
|
||
|
else {
|
||
|
preloaded = initial_data.preloaded[i + 1];
|
||
|
}
|
||
|
return (props[`level${j}`] = { component, props: preloaded, segment, match, part: part.i });
|
||
|
})));
|
||
|
}
|
||
|
catch (error) {
|
||
|
props.error = error;
|
||
|
props.status = 500;
|
||
|
branch = [];
|
||
|
}
|
||
|
return { redirect, props, branch };
|
||
|
});
|
||
|
}
|
||
|
|
||
|
start$1({
|
||
|
target: document.querySelector('#sapper')
|
||
|
});
|
||
|
|
||
|
export { SvelteComponentDev as S, detach_dev as a, space as b, claim_space as c, dispatch_dev as d, element as e, claim_element as f, children as g, claim_text as h, init$1 as i, add_location as j, insert_hydration_dev as k, append_hydration_dev as l, noop as n, query_selector_all as q, safe_not_equal as s, text as t, validate_slots as v };
|
||
|
|
||
|
import __inject_styles from './inject_styles.5607aec6.js';//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50LjQwOWUwMjJjLmpzIiwic291cmNlcyI6WyIuLi8uLi8uLi9ub2RlX21vZHVsZXMvLnBucG0vc3ZlbHRlQDMuNDIuMS9ub2RlX21vZHVsZXMvc3ZlbHRlL2ludGVybmFsL2luZGV4Lm1qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9zdmVsdGVAMy40Mi4xL25vZGVfbW9kdWxlcy9zdmVsdGUvc3RvcmUvaW5kZXgubWpzIiwiLi4vLi4vLi4vc3JjL25vZGVfbW9kdWxlcy9Ac2FwcGVyL2ludGVybmFsL3NoYXJlZC5tanMiLCIuLi8uLi8uLi9zcmMvY29tcG9uZW50cy9CdXR0b24uc3ZlbHRlIiwiLi4vLi4vLi4vc3JjL2NvbXBvbmVudHMvSW1hZ2Uuc3ZlbHRlIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2hlbHBlcnMvYmluZC5qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9heGlvc0AwLjIxLjEvbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi91dGlscy5qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9heGlvc0AwLjIxLjEvbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9oZWxwZXJzL2J1aWxkVVJMLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvSW50ZXJjZXB0b3JNYW5hZ2VyLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvdHJhbnNmb3JtRGF0YS5qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9heGlvc0AwLjIxLjEvbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9jYW5jZWwvaXNDYW5jZWwuanMiLCIuLi8uLi8uLi9ub2RlX21vZHVsZXMvLnBucG0vYXhpb3NAMC4yMS4xL25vZGVfbW9kdWxlcy9heGlvcy9saWIvaGVscGVycy9ub3JtYWxpemVIZWFkZXJOYW1lLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvZW5oYW5jZUVycm9yLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvY3JlYXRlRXJyb3IuanMiLCIuLi8uLi8uLi9ub2RlX21vZHVsZXMvLnBucG0vYXhpb3NAMC4yMS4xL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY29yZS9zZXR0bGUuanMiLCIuLi8uLi8uLi9ub2RlX21vZHVsZXMvLnBucG0vYXhpb3NAMC4yMS4xL25vZGVfbW9kdWxlcy9heGlvcy9saWIvaGVscGVycy9jb29raWVzLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2hlbHBlcnMvaXNBYnNvbHV0ZVVSTC5qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9heGlvc0AwLjIxLjEvbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9oZWxwZXJzL2NvbWJpbmVVUkxzLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NvcmUvYnVpbGRGdWxsUGF0aC5qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9heGlvc0AwLjIxLjEvbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9oZWxwZXJzL3BhcnNlSGVhZGVycy5qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9heGlvc0AwLjIxLjEvbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9oZWxwZXJzL2lzVVJMU2FtZU9yaWdpbi5qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9heGlvc0AwLjIxLjEvbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9hZGFwdGVycy94aHIuanMiLCIuLi8uLi8uLi9ub2RlX21vZHVsZXMvLnBucG0vYXhpb3NAMC4yMS4xL25vZGVfbW9kdWxlcy9heGlvcy9saWIvZGVmYXVsdHMuanMiLCIuLi8uLi8uLi9ub2RlX21vZHVsZXMvLnBucG0vYXhpb3NAMC4yMS4xL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY29yZS9kaXNwYXRjaFJlcXVlc3QuanMiLCIuLi8uLi8uLi9ub2RlX21vZHVsZXMvLnBucG0vYXhpb3NAMC4yMS4xL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY29yZS9tZXJnZUNvbmZpZy5qcyIsIi4uLy4uLy4uL25vZGVfbW9kdWxlcy8ucG5wbS9heGlvc0AwLjIxLjEvbm9kZV9tb2R1bGVzL2F4aW9zL2xpYi9jb3JlL0F4aW9zLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2NhbmNlbC9DYW5jZWwuanMiLCIuLi8uLi8uLi9ub2RlX21vZHVsZXMvLnBucG0vYXhpb3NAMC4yMS4xL25vZGVfbW9kdWxlcy9heGlvcy9saWIvY2FuY2VsL0NhbmNlbFRva2VuLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2hlbHBlcnMvc3ByZWFkLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2hlbHBlcnMvaXNBeGlvc0Vycm9yLmpzIiwiLi4vLi4vLi4vbm9kZV9tb2R1bGVzLy5wbnBtL2F4aW9zQDAuMjEuMS9ub2RlX21vZHVsZXMvYXhpb3MvbGliL2F4aW9zLmpzIiwiLi4vLi4vLi4vc3JjL3V0aWxzL3N0b3Jlcy5qcyIsIi4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0hlYWRlci5zdmVsdGUiLCIuLi8uLi8uLi9zcmMvcm91dGVzL19sYXlvdXQuc3ZlbHRlIiwiLi4vLi4vLi4vc3JjL3JvdXRlcy9fZXJyb3Iuc3ZlbHRlIiwiLi4vLi4vLi4vc3JjL25vZGVfbW9kdWxlcy9Ac2FwcGVyL2ludGVybmFsL0FwcC5zdmVsdGUiLCIuLi8uLi8uLi9zcmMvbm9kZV9tb2R1bGVzL0BzYXBwZXIvaW50ZXJuYWwvbWFuaWZlc3QtY2xpZW50Lm1qcyIsIi4uLy4uLy4uL3NyYy9ub2RlX21vZHVsZXMvQHNhcHBlci9hcHAubWpzIiwiLi4vLi4vLi4vc3JjL2NsaWVudC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJmdW5jdGlvbiBub29wKCkgeyB9XG5jb25zdCBpZGVudGl0eSA9IHggPT4ge
|