mirror of https://github.com/sveltejs/svelte
parent
cf0d815b73
commit
9f0fe3070f
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,394 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var Component = require('./Component-9c4b98a2.js');
|
||||
|
||||
/** regex of all html void element names */
|
||||
const void_element_names =
|
||||
/^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/;
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function is_void(name) {
|
||||
return void_element_names.test(name) || name.toLowerCase() === '!doctype';
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} type
|
||||
* @param {T} detail
|
||||
* @returns {void}
|
||||
*/
|
||||
function dispatch_dev(type, detail) {
|
||||
document.dispatchEvent(
|
||||
Component.custom_event(type, { version: '4.0.0-next.0', ...detail }, { bubbles: true })
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} target
|
||||
* @param {Node} node
|
||||
* @returns {void}
|
||||
*/
|
||||
function append_dev(target, node) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node });
|
||||
Component.append(target, node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} target
|
||||
* @param {Node} node
|
||||
* @returns {void}
|
||||
*/
|
||||
function append_hydration_dev(target, node) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node });
|
||||
Component.append_hydration(target, node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} target
|
||||
* @param {Node} node
|
||||
* @param {Node} anchor
|
||||
* @returns {void}
|
||||
*/
|
||||
function insert_dev(target, node, anchor) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
||||
Component.insert(target, node, anchor);
|
||||
}
|
||||
|
||||
/** @param {Node} target
|
||||
* @param {Node} node
|
||||
* @param {Node} anchor
|
||||
* @returns {void}
|
||||
*/
|
||||
function insert_hydration_dev(target, node, anchor) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
||||
Component.insert_hydration(target, node, anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @returns {void}
|
||||
*/
|
||||
function detach_dev(node) {
|
||||
dispatch_dev('SvelteDOMRemove', { node });
|
||||
Component.detach(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} before
|
||||
* @param {Node} after
|
||||
* @returns {void}
|
||||
*/
|
||||
function detach_between_dev(before, after) {
|
||||
while (before.nextSibling && before.nextSibling !== after) {
|
||||
detach_dev(before.nextSibling);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} after
|
||||
* @returns {void}
|
||||
*/
|
||||
function detach_before_dev(after) {
|
||||
while (after.previousSibling) {
|
||||
detach_dev(after.previousSibling);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} before
|
||||
* @returns {void}
|
||||
*/
|
||||
function detach_after_dev(before) {
|
||||
while (before.nextSibling) {
|
||||
detach_dev(before.nextSibling);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @param {string} event
|
||||
* @param {EventListenerOrEventListenerObject} handler
|
||||
* @param {boolean | AddEventListenerOptions | EventListenerOptions} options
|
||||
* @param {boolean} has_prevent_default
|
||||
* @param {boolean} has_stop_propagation
|
||||
* @param {boolean} has_stop_immediate_propagation
|
||||
* @returns {() => void}
|
||||
*/
|
||||
function listen_dev(
|
||||
node,
|
||||
event,
|
||||
handler,
|
||||
options,
|
||||
has_prevent_default,
|
||||
has_stop_propagation,
|
||||
has_stop_immediate_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');
|
||||
if (has_stop_immediate_propagation) modifiers.push('stopImmediatePropagation');
|
||||
dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers });
|
||||
const dispose = Component.listen(node, event, handler, options);
|
||||
return () => {
|
||||
dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers });
|
||||
dispose();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} node
|
||||
* @param {string} attribute
|
||||
* @param {string} value
|
||||
* @returns {void}
|
||||
*/
|
||||
function attr_dev(node, attribute, value) {
|
||||
Component.attr(node, attribute, value);
|
||||
if (value == null) dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
|
||||
else dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} node
|
||||
* @param {string} property
|
||||
* @param {any} value
|
||||
* @returns {void}
|
||||
*/
|
||||
function prop_dev(node, property, value) {
|
||||
node[property] = value;
|
||||
dispatch_dev('SvelteDOMSetProperty', { node, property, value });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} node
|
||||
* @param {string} property
|
||||
* @param {any} value
|
||||
* @returns {void}
|
||||
*/
|
||||
function dataset_dev(node, property, value) {
|
||||
node.dataset[property] = value;
|
||||
dispatch_dev('SvelteDOMSetDataset', { node, property, value });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Text} text
|
||||
* @param {unknown} data
|
||||
* @returns {void}
|
||||
*/
|
||||
function set_data_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.data === data) return;
|
||||
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||||
text.data = /** @type {string} */ (data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Text} text
|
||||
* @param {unknown} data
|
||||
* @returns {void}
|
||||
*/
|
||||
function set_data_contenteditable_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.wholeText === data) return;
|
||||
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||||
text.data = /** @type {string} */ (data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Text} text
|
||||
* @param {unknown} data
|
||||
* @param {string} attr_value
|
||||
* @returns {void}
|
||||
*/
|
||||
function set_data_maybe_contenteditable_dev(text, data, attr_value) {
|
||||
if (~Component.contenteditable_truthy_values.indexOf(attr_value)) {
|
||||
set_data_contenteditable_dev(text, data);
|
||||
} else {
|
||||
set_data_dev(text, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
function validate_each_argument(arg) {
|
||||
if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) {
|
||||
let msg = '{#each} only iterates over array-like objects.';
|
||||
if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) {
|
||||
msg += ' You can use a spread to convert this iterable into an array.';
|
||||
}
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
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}".`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {unknown} tag
|
||||
* @returns {void}
|
||||
*/
|
||||
function validate_dynamic_element(tag) {
|
||||
const is_string = typeof tag === 'string';
|
||||
if (tag && !is_string) {
|
||||
throw new Error('<svelte:element> expects "this" attribute to be a string.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {undefined | string} tag
|
||||
* @returns {void}
|
||||
*/
|
||||
function validate_void_dynamic_element(tag) {
|
||||
if (tag && is_void(tag)) {
|
||||
console.warn(`<svelte:element this="${tag}"> is self-closing and cannot have content.`);
|
||||
}
|
||||
}
|
||||
|
||||
function construct_svelte_component_dev(component, props) {
|
||||
const error_message = 'this={...} of <svelte:component> should specify a Svelte component.';
|
||||
try {
|
||||
const instance = new component(props);
|
||||
if (!instance.$$ || !instance.$set || !instance.$on || !instance.$destroy) {
|
||||
throw new Error(error_message);
|
||||
}
|
||||
return instance;
|
||||
} catch (err) {
|
||||
const { message } = err;
|
||||
if (typeof message === 'string' && message.indexOf('is not a constructor') !== -1) {
|
||||
throw new Error(error_message);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
|
||||
*
|
||||
* Can be used to create strongly typed Svelte components.
|
||||
*
|
||||
* ### Example:
|
||||
*
|
||||
* You have component library on npm called `component-library`, from which
|
||||
* you export a component called `MyComponent`. For Svelte+TypeScript users,
|
||||
* you want to provide typings. Therefore you create a `index.d.ts`:
|
||||
* ```ts
|
||||
* import { SvelteComponent } from "svelte";
|
||||
* export class MyComponent extends SvelteComponent<{foo: string}> {}
|
||||
* ```
|
||||
* Typing this makes it possible for IDEs like VS Code with the Svelte extension
|
||||
* to provide intellisense and to use the component like this in a Svelte file
|
||||
* with TypeScript:
|
||||
* ```svelte
|
||||
* <script lang="ts">
|
||||
* import { MyComponent } from "component-library";
|
||||
* </script>
|
||||
* <MyComponent foo={'bar'} />
|
||||
* ```
|
||||
* @template {Record<string, any>} [Props=any]
|
||||
* @template {Record<string, any>} [Events=any]
|
||||
* @template {Record<string, any>} [Slots=any]
|
||||
* @extends SvelteComponent<Props, Events>
|
||||
*/
|
||||
class SvelteComponentDev extends Component.SvelteComponent {
|
||||
/**
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*
|
||||
* @type {Props}
|
||||
*/
|
||||
|
||||
/**
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*
|
||||
* @type {Events}
|
||||
*/
|
||||
|
||||
/**
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*
|
||||
* @type {Slots}
|
||||
*/
|
||||
|
||||
|
||||
/** @param {import('./public.js').ComponentConstructorOptions<Props>} options */
|
||||
constructor(options) {
|
||||
if (!options || (!options.target && !options.$$inline)) {
|
||||
throw new Error("'target' is a required option");
|
||||
}
|
||||
super();
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
$destroy() {
|
||||
super.$destroy();
|
||||
this.$destroy = () => {
|
||||
console.warn('Component was already destroyed'); // eslint-disable-line no-console
|
||||
};
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
$capture_state() {}
|
||||
|
||||
/** @returns {void} */
|
||||
$inject_state() {}
|
||||
}
|
||||
/**
|
||||
* @template {Record<string, any>} [Props=any]
|
||||
* @template {Record<string, any>} [Events=any]
|
||||
* @template {Record<string, any>} [Slots=any]
|
||||
* @deprecated Use `SvelteComponent` instead. See PR for more information: https://github.com/sveltejs/svelte/pull/8512
|
||||
* @extends SvelteComponentDev<Props, Events, Slots>
|
||||
*/
|
||||
class SvelteComponentTyped extends SvelteComponentDev {}
|
||||
|
||||
/** @returns {() => void} */
|
||||
function loop_guard(timeout) {
|
||||
const start = Date.now();
|
||||
return () => {
|
||||
if (Date.now() - start > timeout) {
|
||||
throw new Error('Infinite loop detected');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.SvelteComponentDev = SvelteComponentDev;
|
||||
exports.SvelteComponentTyped = SvelteComponentTyped;
|
||||
exports.append_dev = append_dev;
|
||||
exports.append_hydration_dev = append_hydration_dev;
|
||||
exports.attr_dev = attr_dev;
|
||||
exports.construct_svelte_component_dev = construct_svelte_component_dev;
|
||||
exports.dataset_dev = dataset_dev;
|
||||
exports.detach_after_dev = detach_after_dev;
|
||||
exports.detach_before_dev = detach_before_dev;
|
||||
exports.detach_between_dev = detach_between_dev;
|
||||
exports.detach_dev = detach_dev;
|
||||
exports.dispatch_dev = dispatch_dev;
|
||||
exports.insert_dev = insert_dev;
|
||||
exports.insert_hydration_dev = insert_hydration_dev;
|
||||
exports.is_void = is_void;
|
||||
exports.listen_dev = listen_dev;
|
||||
exports.loop_guard = loop_guard;
|
||||
exports.prop_dev = prop_dev;
|
||||
exports.set_data_contenteditable_dev = set_data_contenteditable_dev;
|
||||
exports.set_data_dev = set_data_dev;
|
||||
exports.set_data_maybe_contenteditable_dev = set_data_maybe_contenteditable_dev;
|
||||
exports.validate_dynamic_element = validate_dynamic_element;
|
||||
exports.validate_each_argument = validate_each_argument;
|
||||
exports.validate_slots = validate_slots;
|
||||
exports.validate_void_dynamic_element = validate_void_dynamic_element;
|
@ -1,356 +0,0 @@
|
||||
import { custom_event, append, append_hydration, insert, insert_hydration, detach, listen, attr, contenteditable_truthy_values, SvelteComponent } from './Component-b90cf812.mjs';
|
||||
|
||||
/** regex of all html void element names */
|
||||
const void_element_names =
|
||||
/^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/;
|
||||
|
||||
function is_void(name) {
|
||||
return void_element_names.test(name) || name.toLowerCase() === '!doctype';
|
||||
}
|
||||
|
||||
function dispatch_dev(type, detail) {
|
||||
document.dispatchEvent(
|
||||
custom_event(type, { version: '4.0.0-next.0', ...detail }, { bubbles: true })
|
||||
);
|
||||
}
|
||||
|
||||
function append_dev(target, node) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node });
|
||||
append(target, node);
|
||||
}
|
||||
|
||||
function append_hydration_dev(target, node) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node });
|
||||
append_hydration(target, node);
|
||||
}
|
||||
|
||||
function insert_dev(target, node, anchor) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
||||
insert(target, node, anchor);
|
||||
}
|
||||
|
||||
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 detach_between_dev(before, after) {
|
||||
while (before.nextSibling && before.nextSibling !== after) {
|
||||
detach_dev(before.nextSibling);
|
||||
}
|
||||
}
|
||||
|
||||
function detach_before_dev(after) {
|
||||
while (after.previousSibling) {
|
||||
detach_dev(after.previousSibling);
|
||||
}
|
||||
}
|
||||
|
||||
function detach_after_dev(before) {
|
||||
while (before.nextSibling) {
|
||||
detach_dev(before.nextSibling);
|
||||
}
|
||||
}
|
||||
|
||||
function listen_dev(
|
||||
node,
|
||||
event,
|
||||
handler,
|
||||
options,
|
||||
has_prevent_default,
|
||||
has_stop_propagation,
|
||||
has_stop_immediate_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');
|
||||
if (has_stop_immediate_propagation) modifiers.push('stopImmediatePropagation');
|
||||
|
||||
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 prop_dev(node, property, value) {
|
||||
node[property] = value;
|
||||
|
||||
dispatch_dev('SvelteDOMSetProperty', { node, property, value });
|
||||
}
|
||||
|
||||
function dataset_dev(node, property, value) {
|
||||
node.dataset[property] = value;
|
||||
|
||||
dispatch_dev('SvelteDOMSetDataset', { node, property, value });
|
||||
}
|
||||
|
||||
function set_data_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.data === data) return;
|
||||
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||||
text.data = data ;
|
||||
}
|
||||
|
||||
function set_data_contenteditable_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.wholeText === data) return;
|
||||
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||||
text.data = data ;
|
||||
}
|
||||
|
||||
function set_data_maybe_contenteditable_dev(text, data, attr_value) {
|
||||
if (~contenteditable_truthy_values.indexOf(attr_value)) {
|
||||
set_data_contenteditable_dev(text, data);
|
||||
} else {
|
||||
set_data_dev(text, data);
|
||||
}
|
||||
}
|
||||
|
||||
function validate_each_argument(arg) {
|
||||
if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) {
|
||||
let msg = '{#each} only iterates over array-like objects.';
|
||||
if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) {
|
||||
msg += ' You can use a spread to convert this iterable into an array.';
|
||||
}
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
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}".`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validate_dynamic_element(tag) {
|
||||
const is_string = typeof tag === 'string';
|
||||
if (tag && !is_string) {
|
||||
throw new Error('<svelte:element> expects "this" attribute to be a string.');
|
||||
}
|
||||
}
|
||||
|
||||
function validate_void_dynamic_element(tag) {
|
||||
if (tag && is_void(tag)) {
|
||||
console.warn(`<svelte:element this="${tag}"> is self-closing and cannot have content.`);
|
||||
}
|
||||
}
|
||||
|
||||
function construct_svelte_component_dev(component, props) {
|
||||
const error_message = 'this={...} of <svelte:component> should specify a Svelte component.';
|
||||
try {
|
||||
const instance = new component(props);
|
||||
if (!instance.$$ || !instance.$set || !instance.$on || !instance.$destroy) {
|
||||
throw new Error(error_message);
|
||||
}
|
||||
return instance;
|
||||
} catch (err) {
|
||||
const { message } = err;
|
||||
if (typeof message === 'string' && message.indexOf('is not a constructor') !== -1) {
|
||||
throw new Error(error_message);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
|
||||
*
|
||||
* Can be used to create strongly typed Svelte components.
|
||||
*
|
||||
* ### Example:
|
||||
*
|
||||
* You have component library on npm called `component-library`, from which
|
||||
* you export a component called `MyComponent`. For Svelte+TypeScript users,
|
||||
* you want to provide typings. Therefore you create a `index.d.ts`:
|
||||
* ```ts
|
||||
* import { SvelteComponent } from "svelte";
|
||||
* export class MyComponent extends SvelteComponent<{foo: string}> {}
|
||||
* ```
|
||||
* Typing this makes it possible for IDEs like VS Code with the Svelte extension
|
||||
* to provide intellisense and to use the component like this in a Svelte file
|
||||
* with TypeScript:
|
||||
* ```svelte
|
||||
* <script lang="ts">
|
||||
* import { MyComponent } from "component-library";
|
||||
* </script>
|
||||
* <MyComponent foo={'bar'} />
|
||||
* ```
|
||||
*/
|
||||
class SvelteComponentDev
|
||||
|
||||
|
||||
|
||||
extends SvelteComponent {
|
||||
/**
|
||||
* @private
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*/
|
||||
|
||||
/**
|
||||
* @private
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*/
|
||||
|
||||
/**
|
||||
* @private
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*/
|
||||
|
||||
|
||||
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() {}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use `SvelteComponent` instead. See PR for more information: https://github.com/sveltejs/svelte/pull/8512
|
||||
*/
|
||||
class SvelteComponentTyped
|
||||
|
||||
|
||||
|
||||
extends SvelteComponentDev {}
|
||||
|
||||
/**
|
||||
* Convenience type to get the type of a Svelte component. Useful for example in combination with
|
||||
* dynamic components using `<svelte:component>`.
|
||||
*
|
||||
* Example:
|
||||
* ```svelte
|
||||
* <script lang="ts">
|
||||
* import type { ComponentType, SvelteComponent } from 'svelte';
|
||||
* import Component1 from './Component1.svelte';
|
||||
* import Component2 from './Component2.svelte';
|
||||
*
|
||||
* const component: ComponentType = someLogic() ? Component1 : Component2;
|
||||
* const componentOfCertainSubType: ComponentType<SvelteComponent<{ needsThisProp: string }>> = someLogic() ? Component1 : Component2;
|
||||
* </script>
|
||||
*
|
||||
* <svelte:component this={component} />
|
||||
* <svelte:component this={componentOfCertainSubType} needsThisProp="hello" />
|
||||
* ```
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function loop_guard(timeout) {
|
||||
const start = Date.now();
|
||||
return () => {
|
||||
if (Date.now() - start > timeout) {
|
||||
throw new Error('Infinite loop detected');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { SvelteComponentDev, SvelteComponentTyped, append_dev, append_hydration_dev, attr_dev, construct_svelte_component_dev, dataset_dev, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dispatch_dev, insert_dev, insert_hydration_dev, is_void, listen_dev, loop_guard, prop_dev, set_data_contenteditable_dev, set_data_dev, set_data_maybe_contenteditable_dev, validate_dynamic_element, validate_each_argument, validate_slots, validate_void_dynamic_element };
|
@ -1,368 +0,0 @@
|
||||
import { custom_event, append, append_hydration, insert, insert_hydration, detach, listen, attr, contenteditable_truthy_values, SvelteComponent } from './Component-cd97939e.mjs';
|
||||
|
||||
/** regex of all html void element names */
|
||||
const void_element_names =
|
||||
/^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/;
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function is_void(name) {
|
||||
return void_element_names.test(name) || name.toLowerCase() === '!doctype';
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} type
|
||||
* @param {T} detail
|
||||
* @returns {void}
|
||||
*/
|
||||
function dispatch_dev(type, detail) {
|
||||
document.dispatchEvent(
|
||||
custom_event(type, { version: '4.0.0-next.0', ...detail }, { bubbles: true })
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} target
|
||||
* @param {Node} node
|
||||
* @returns {void}
|
||||
*/
|
||||
function append_dev(target, node) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node });
|
||||
append(target, node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} target
|
||||
* @param {Node} node
|
||||
* @returns {void}
|
||||
*/
|
||||
function append_hydration_dev(target, node) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node });
|
||||
append_hydration(target, node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} target
|
||||
* @param {Node} node
|
||||
* @param {Node} anchor
|
||||
* @returns {void}
|
||||
*/
|
||||
function insert_dev(target, node, anchor) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
||||
insert(target, node, anchor);
|
||||
}
|
||||
|
||||
/** @param {Node} target
|
||||
* @param {Node} node
|
||||
* @param {Node} anchor
|
||||
* @returns {void}
|
||||
*/
|
||||
function insert_hydration_dev(target, node, anchor) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
||||
insert_hydration(target, node, anchor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @returns {void}
|
||||
*/
|
||||
function detach_dev(node) {
|
||||
dispatch_dev('SvelteDOMRemove', { node });
|
||||
detach(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} before
|
||||
* @param {Node} after
|
||||
* @returns {void}
|
||||
*/
|
||||
function detach_between_dev(before, after) {
|
||||
while (before.nextSibling && before.nextSibling !== after) {
|
||||
detach_dev(before.nextSibling);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} after
|
||||
* @returns {void}
|
||||
*/
|
||||
function detach_before_dev(after) {
|
||||
while (after.previousSibling) {
|
||||
detach_dev(after.previousSibling);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} before
|
||||
* @returns {void}
|
||||
*/
|
||||
function detach_after_dev(before) {
|
||||
while (before.nextSibling) {
|
||||
detach_dev(before.nextSibling);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @param {string} event
|
||||
* @param {EventListenerOrEventListenerObject} handler
|
||||
* @param {boolean | AddEventListenerOptions | EventListenerOptions} options
|
||||
* @param {boolean} has_prevent_default
|
||||
* @param {boolean} has_stop_propagation
|
||||
* @param {boolean} has_stop_immediate_propagation
|
||||
* @returns {() => void}
|
||||
*/
|
||||
function listen_dev(
|
||||
node,
|
||||
event,
|
||||
handler,
|
||||
options,
|
||||
has_prevent_default,
|
||||
has_stop_propagation,
|
||||
has_stop_immediate_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');
|
||||
if (has_stop_immediate_propagation) modifiers.push('stopImmediatePropagation');
|
||||
dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers });
|
||||
const dispose = listen(node, event, handler, options);
|
||||
return () => {
|
||||
dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers });
|
||||
dispose();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} node
|
||||
* @param {string} attribute
|
||||
* @param {string} value
|
||||
* @returns {void}
|
||||
*/
|
||||
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 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} node
|
||||
* @param {string} property
|
||||
* @param {any} value
|
||||
* @returns {void}
|
||||
*/
|
||||
function prop_dev(node, property, value) {
|
||||
node[property] = value;
|
||||
dispatch_dev('SvelteDOMSetProperty', { node, property, value });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} node
|
||||
* @param {string} property
|
||||
* @param {any} value
|
||||
* @returns {void}
|
||||
*/
|
||||
function dataset_dev(node, property, value) {
|
||||
node.dataset[property] = value;
|
||||
dispatch_dev('SvelteDOMSetDataset', { node, property, value });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Text} text
|
||||
* @param {unknown} data
|
||||
* @returns {void}
|
||||
*/
|
||||
function set_data_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.data === data) return;
|
||||
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||||
text.data = /** @type {string} */ (data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Text} text
|
||||
* @param {unknown} data
|
||||
* @returns {void}
|
||||
*/
|
||||
function set_data_contenteditable_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.wholeText === data) return;
|
||||
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||||
text.data = /** @type {string} */ (data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Text} text
|
||||
* @param {unknown} data
|
||||
* @param {string} attr_value
|
||||
* @returns {void}
|
||||
*/
|
||||
function set_data_maybe_contenteditable_dev(text, data, attr_value) {
|
||||
if (~contenteditable_truthy_values.indexOf(attr_value)) {
|
||||
set_data_contenteditable_dev(text, data);
|
||||
} else {
|
||||
set_data_dev(text, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
function validate_each_argument(arg) {
|
||||
if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) {
|
||||
let msg = '{#each} only iterates over array-like objects.';
|
||||
if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) {
|
||||
msg += ' You can use a spread to convert this iterable into an array.';
|
||||
}
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void} */
|
||||
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}".`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {unknown} tag
|
||||
* @returns {void}
|
||||
*/
|
||||
function validate_dynamic_element(tag) {
|
||||
const is_string = typeof tag === 'string';
|
||||
if (tag && !is_string) {
|
||||
throw new Error('<svelte:element> expects "this" attribute to be a string.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {undefined | string} tag
|
||||
* @returns {void}
|
||||
*/
|
||||
function validate_void_dynamic_element(tag) {
|
||||
if (tag && is_void(tag)) {
|
||||
console.warn(`<svelte:element this="${tag}"> is self-closing and cannot have content.`);
|
||||
}
|
||||
}
|
||||
|
||||
function construct_svelte_component_dev(component, props) {
|
||||
const error_message = 'this={...} of <svelte:component> should specify a Svelte component.';
|
||||
try {
|
||||
const instance = new component(props);
|
||||
if (!instance.$$ || !instance.$set || !instance.$on || !instance.$destroy) {
|
||||
throw new Error(error_message);
|
||||
}
|
||||
return instance;
|
||||
} catch (err) {
|
||||
const { message } = err;
|
||||
if (typeof message === 'string' && message.indexOf('is not a constructor') !== -1) {
|
||||
throw new Error(error_message);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
|
||||
*
|
||||
* Can be used to create strongly typed Svelte components.
|
||||
*
|
||||
* ### Example:
|
||||
*
|
||||
* You have component library on npm called `component-library`, from which
|
||||
* you export a component called `MyComponent`. For Svelte+TypeScript users,
|
||||
* you want to provide typings. Therefore you create a `index.d.ts`:
|
||||
* ```ts
|
||||
* import { SvelteComponent } from "svelte";
|
||||
* export class MyComponent extends SvelteComponent<{foo: string}> {}
|
||||
* ```
|
||||
* Typing this makes it possible for IDEs like VS Code with the Svelte extension
|
||||
* to provide intellisense and to use the component like this in a Svelte file
|
||||
* with TypeScript:
|
||||
* ```svelte
|
||||
* <script lang="ts">
|
||||
* import { MyComponent } from "component-library";
|
||||
* </script>
|
||||
* <MyComponent foo={'bar'} />
|
||||
* ```
|
||||
* @template {Record<string, any>} [Props=any]
|
||||
* @template {Record<string, any>} [Events=any]
|
||||
* @template {Record<string, any>} [Slots=any]
|
||||
* @extends SvelteComponent<Props, Events>
|
||||
*/
|
||||
class SvelteComponentDev extends SvelteComponent {
|
||||
/**
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*
|
||||
* @type {Props}
|
||||
*/
|
||||
|
||||
/**
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*
|
||||
* @type {Events}
|
||||
*/
|
||||
|
||||
/**
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*
|
||||
* @type {Slots}
|
||||
*/
|
||||
|
||||
|
||||
/** @param {import('./public.js').ComponentConstructorOptions<Props>} options */
|
||||
constructor(options) {
|
||||
if (!options || (!options.target && !options.$$inline)) {
|
||||
throw new Error("'target' is a required option");
|
||||
}
|
||||
super();
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
$destroy() {
|
||||
super.$destroy();
|
||||
this.$destroy = () => {
|
||||
console.warn('Component was already destroyed'); // eslint-disable-line no-console
|
||||
};
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
$capture_state() {}
|
||||
|
||||
/** @returns {void} */
|
||||
$inject_state() {}
|
||||
}
|
||||
/**
|
||||
* @template {Record<string, any>} [Props=any]
|
||||
* @template {Record<string, any>} [Events=any]
|
||||
* @template {Record<string, any>} [Slots=any]
|
||||
* @deprecated Use `SvelteComponent` instead. See PR for more information: https://github.com/sveltejs/svelte/pull/8512
|
||||
* @extends SvelteComponentDev<Props, Events, Slots>
|
||||
*/
|
||||
class SvelteComponentTyped extends SvelteComponentDev {}
|
||||
|
||||
/** @returns {() => void} */
|
||||
function loop_guard(timeout) {
|
||||
const start = Date.now();
|
||||
return () => {
|
||||
if (Date.now() - start > timeout) {
|
||||
throw new Error('Infinite loop detected');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { SvelteComponentDev, SvelteComponentTyped, append_dev, append_hydration_dev, attr_dev, construct_svelte_component_dev, dataset_dev, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dispatch_dev, insert_dev, insert_hydration_dev, is_void, listen_dev, loop_guard, prop_dev, set_data_contenteditable_dev, set_data_dev, set_data_maybe_contenteditable_dev, validate_dynamic_element, validate_each_argument, validate_slots, validate_void_dynamic_element };
|
@ -1,382 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var Component = require('./Component-d02c1ae2.js');
|
||||
|
||||
/** regex of all html void element names */
|
||||
const void_element_names =
|
||||
/^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/;
|
||||
|
||||
function is_void(name) {
|
||||
return void_element_names.test(name) || name.toLowerCase() === '!doctype';
|
||||
}
|
||||
|
||||
function dispatch_dev(type, detail) {
|
||||
document.dispatchEvent(
|
||||
Component.custom_event(type, { version: '4.0.0-next.0', ...detail }, { bubbles: true })
|
||||
);
|
||||
}
|
||||
|
||||
function append_dev(target, node) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node });
|
||||
Component.append(target, node);
|
||||
}
|
||||
|
||||
function append_hydration_dev(target, node) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node });
|
||||
Component.append_hydration(target, node);
|
||||
}
|
||||
|
||||
function insert_dev(target, node, anchor) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
||||
Component.insert(target, node, anchor);
|
||||
}
|
||||
|
||||
function insert_hydration_dev(target, node, anchor) {
|
||||
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
||||
Component.insert_hydration(target, node, anchor);
|
||||
}
|
||||
|
||||
function detach_dev(node) {
|
||||
dispatch_dev('SvelteDOMRemove', { node });
|
||||
Component.detach(node);
|
||||
}
|
||||
|
||||
function detach_between_dev(before, after) {
|
||||
while (before.nextSibling && before.nextSibling !== after) {
|
||||
detach_dev(before.nextSibling);
|
||||
}
|
||||
}
|
||||
|
||||
function detach_before_dev(after) {
|
||||
while (after.previousSibling) {
|
||||
detach_dev(after.previousSibling);
|
||||
}
|
||||
}
|
||||
|
||||
function detach_after_dev(before) {
|
||||
while (before.nextSibling) {
|
||||
detach_dev(before.nextSibling);
|
||||
}
|
||||
}
|
||||
|
||||
function listen_dev(
|
||||
node,
|
||||
event,
|
||||
handler,
|
||||
options,
|
||||
has_prevent_default,
|
||||
has_stop_propagation,
|
||||
has_stop_immediate_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');
|
||||
if (has_stop_immediate_propagation) modifiers.push('stopImmediatePropagation');
|
||||
|
||||
dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers });
|
||||
|
||||
const dispose = Component.listen(node, event, handler, options);
|
||||
return () => {
|
||||
dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers });
|
||||
dispose();
|
||||
};
|
||||
}
|
||||
|
||||
function attr_dev(node, attribute, value) {
|
||||
Component.attr(node, attribute, value);
|
||||
|
||||
if (value == null) dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
|
||||
else dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
|
||||
}
|
||||
|
||||
function prop_dev(node, property, value) {
|
||||
node[property] = value;
|
||||
|
||||
dispatch_dev('SvelteDOMSetProperty', { node, property, value });
|
||||
}
|
||||
|
||||
function dataset_dev(node, property, value) {
|
||||
node.dataset[property] = value;
|
||||
|
||||
dispatch_dev('SvelteDOMSetDataset', { node, property, value });
|
||||
}
|
||||
|
||||
function set_data_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.data === data) return;
|
||||
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||||
text.data = data ;
|
||||
}
|
||||
|
||||
function set_data_contenteditable_dev(text, data) {
|
||||
data = '' + data;
|
||||
if (text.wholeText === data) return;
|
||||
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
||||
text.data = data ;
|
||||
}
|
||||
|
||||
function set_data_maybe_contenteditable_dev(text, data, attr_value) {
|
||||
if (~Component.contenteditable_truthy_values.indexOf(attr_value)) {
|
||||
set_data_contenteditable_dev(text, data);
|
||||
} else {
|
||||
set_data_dev(text, data);
|
||||
}
|
||||
}
|
||||
|
||||
function validate_each_argument(arg) {
|
||||
if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) {
|
||||
let msg = '{#each} only iterates over array-like objects.';
|
||||
if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) {
|
||||
msg += ' You can use a spread to convert this iterable into an array.';
|
||||
}
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
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}".`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validate_dynamic_element(tag) {
|
||||
const is_string = typeof tag === 'string';
|
||||
if (tag && !is_string) {
|
||||
throw new Error('<svelte:element> expects "this" attribute to be a string.');
|
||||
}
|
||||
}
|
||||
|
||||
function validate_void_dynamic_element(tag) {
|
||||
if (tag && is_void(tag)) {
|
||||
console.warn(`<svelte:element this="${tag}"> is self-closing and cannot have content.`);
|
||||
}
|
||||
}
|
||||
|
||||
function construct_svelte_component_dev(component, props) {
|
||||
const error_message = 'this={...} of <svelte:component> should specify a Svelte component.';
|
||||
try {
|
||||
const instance = new component(props);
|
||||
if (!instance.$$ || !instance.$set || !instance.$on || !instance.$destroy) {
|
||||
throw new Error(error_message);
|
||||
}
|
||||
return instance;
|
||||
} catch (err) {
|
||||
const { message } = err;
|
||||
if (typeof message === 'string' && message.indexOf('is not a constructor') !== -1) {
|
||||
throw new Error(error_message);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
|
||||
*
|
||||
* Can be used to create strongly typed Svelte components.
|
||||
*
|
||||
* ### Example:
|
||||
*
|
||||
* You have component library on npm called `component-library`, from which
|
||||
* you export a component called `MyComponent`. For Svelte+TypeScript users,
|
||||
* you want to provide typings. Therefore you create a `index.d.ts`:
|
||||
* ```ts
|
||||
* import { SvelteComponent } from "svelte";
|
||||
* export class MyComponent extends SvelteComponent<{foo: string}> {}
|
||||
* ```
|
||||
* Typing this makes it possible for IDEs like VS Code with the Svelte extension
|
||||
* to provide intellisense and to use the component like this in a Svelte file
|
||||
* with TypeScript:
|
||||
* ```svelte
|
||||
* <script lang="ts">
|
||||
* import { MyComponent } from "component-library";
|
||||
* </script>
|
||||
* <MyComponent foo={'bar'} />
|
||||
* ```
|
||||
*/
|
||||
class SvelteComponentDev
|
||||
|
||||
|
||||
|
||||
extends Component.SvelteComponent {
|
||||
/**
|
||||
* @private
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*/
|
||||
|
||||
/**
|
||||
* @private
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*/
|
||||
|
||||
/**
|
||||
* @private
|
||||
* For type checking capabilities only.
|
||||
* Does not exist at runtime.
|
||||
* ### DO NOT USE!
|
||||
*/
|
||||
|
||||
|
||||
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() {}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use `SvelteComponent` instead. See PR for more information: https://github.com/sveltejs/svelte/pull/8512
|
||||
*/
|
||||
class SvelteComponentTyped
|
||||
|
||||
|
||||
|
||||
extends SvelteComponentDev {}
|
||||
|
||||
/**
|
||||
* Convenience type to get the type of a Svelte component. Useful for example in combination with
|
||||
* dynamic components using `<svelte:component>`.
|
||||
*
|
||||
* Example:
|
||||
* ```svelte
|
||||
* <script lang="ts">
|
||||
* import type { ComponentType, SvelteComponent } from 'svelte';
|
||||
* import Component1 from './Component1.svelte';
|
||||
* import Component2 from './Component2.svelte';
|
||||
*
|
||||
* const component: ComponentType = someLogic() ? Component1 : Component2;
|
||||
* const componentOfCertainSubType: ComponentType<SvelteComponent<{ needsThisProp: string }>> = someLogic() ? Component1 : Component2;
|
||||
* </script>
|
||||
*
|
||||
* <svelte:component this={component} />
|
||||
* <svelte:component this={componentOfCertainSubType} needsThisProp="hello" />
|
||||
* ```
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function loop_guard(timeout) {
|
||||
const start = Date.now();
|
||||
return () => {
|
||||
if (Date.now() - start > timeout) {
|
||||
throw new Error('Infinite loop detected');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.SvelteComponentDev = SvelteComponentDev;
|
||||
exports.SvelteComponentTyped = SvelteComponentTyped;
|
||||
exports.append_dev = append_dev;
|
||||
exports.append_hydration_dev = append_hydration_dev;
|
||||
exports.attr_dev = attr_dev;
|
||||
exports.construct_svelte_component_dev = construct_svelte_component_dev;
|
||||
exports.dataset_dev = dataset_dev;
|
||||
exports.detach_after_dev = detach_after_dev;
|
||||
exports.detach_before_dev = detach_before_dev;
|
||||
exports.detach_between_dev = detach_between_dev;
|
||||
exports.detach_dev = detach_dev;
|
||||
exports.dispatch_dev = dispatch_dev;
|
||||
exports.insert_dev = insert_dev;
|
||||
exports.insert_hydration_dev = insert_hydration_dev;
|
||||
exports.is_void = is_void;
|
||||
exports.listen_dev = listen_dev;
|
||||
exports.loop_guard = loop_guard;
|
||||
exports.prop_dev = prop_dev;
|
||||
exports.set_data_contenteditable_dev = set_data_contenteditable_dev;
|
||||
exports.set_data_dev = set_data_dev;
|
||||
exports.set_data_maybe_contenteditable_dev = set_data_maybe_contenteditable_dev;
|
||||
exports.validate_dynamic_element = validate_dynamic_element;
|
||||
exports.validate_each_argument = validate_each_argument;
|
||||
exports.validate_slots = validate_slots;
|
||||
exports.validate_void_dynamic_element = validate_void_dynamic_element;
|
@ -1 +0,0 @@
|
||||
export * from '../types/runtime/internal/index.js';
|
@ -1,813 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var Component = require('./Component-9c4b98a2.js');
|
||||
var dev = require('./dev-1537023e.js');
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {import('./private.js').PositionRect} from
|
||||
* @param {import('./private.js').AnimationFn} fn
|
||||
*/
|
||||
function create_animation(node, from, fn, params) {
|
||||
if (!from) return Component.noop;
|
||||
const to = node.getBoundingClientRect();
|
||||
if (
|
||||
from.left === to.left &&
|
||||
from.right === to.right &&
|
||||
from.top === to.top &&
|
||||
from.bottom === to.bottom
|
||||
)
|
||||
return Component.noop;
|
||||
const {
|
||||
delay = 0,
|
||||
duration = 300,
|
||||
easing = Component.identity,
|
||||
// @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation?
|
||||
start: start_time = Component.now() + delay,
|
||||
// @ts-ignore todo:
|
||||
end = start_time + duration,
|
||||
tick = Component.noop,
|
||||
css
|
||||
} = fn(node, { from, to }, params);
|
||||
let running = true;
|
||||
let started = false;
|
||||
let name;
|
||||
/** @returns {void} */
|
||||
function start() {
|
||||
if (css) {
|
||||
name = Component.create_rule(node, 0, 1, duration, delay, easing, css);
|
||||
}
|
||||
if (!delay) {
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
/** @returns {void} */
|
||||
function stop() {
|
||||
if (css) Component.delete_rule(node, name);
|
||||
running = false;
|
||||
}
|
||||
Component.loop((now) => {
|
||||
if (!started && now >= start_time) {
|
||||
started = true;
|
||||
}
|
||||
if (started && now >= end) {
|
||||
tick(1, 0);
|
||||
stop();
|
||||
}
|
||||
if (!running) {
|
||||
return false;
|
||||
}
|
||||
if (started) {
|
||||
const p = now - start_time;
|
||||
const t = 0 + 1 * easing(p / duration);
|
||||
tick(t, 1 - t);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
start();
|
||||
tick(0, 1);
|
||||
return stop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @returns {void}
|
||||
*/
|
||||
function fix_position(node) {
|
||||
const style = getComputedStyle(node);
|
||||
if (style.position !== 'absolute' && style.position !== 'fixed') {
|
||||
const { width, height } = style;
|
||||
const a = node.getBoundingClientRect();
|
||||
node.style.position = 'absolute';
|
||||
node.style.width = width;
|
||||
node.style.height = height;
|
||||
add_transform(node, a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {import('./private.js').PositionRect} a
|
||||
* @returns {void}
|
||||
*/
|
||||
function add_transform(node, a) {
|
||||
const b = node.getBoundingClientRect();
|
||||
if (a.left !== b.left || a.top !== b.top) {
|
||||
const style = getComputedStyle(node);
|
||||
const transform = style.transform === 'none' ? '' : style.transform;
|
||||
node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {Promise<T>} promise
|
||||
* @param {import('./private.js').PromiseInfo<T>} info
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function handle_promise(promise, info) {
|
||||
const token = (info.token = {});
|
||||
/**
|
||||
* @param {import('./private.js').FragmentFactory} type
|
||||
* @param {0 | 1 | 2} index
|
||||
* @param {number} [key]
|
||||
* @param {any} [value]
|
||||
* @returns {void}
|
||||
*/
|
||||
function update(type, index, key, value) {
|
||||
if (info.token !== token) return;
|
||||
info.resolved = value;
|
||||
let child_ctx = info.ctx;
|
||||
if (key !== undefined) {
|
||||
child_ctx = child_ctx.slice();
|
||||
child_ctx[key] = value;
|
||||
}
|
||||
const block = type && (info.current = type)(child_ctx);
|
||||
let needs_flush = false;
|
||||
if (info.block) {
|
||||
if (info.blocks) {
|
||||
info.blocks.forEach((block, i) => {
|
||||
if (i !== index && block) {
|
||||
Component.group_outros();
|
||||
Component.transition_out(block, 1, 1, () => {
|
||||
if (info.blocks[i] === block) {
|
||||
info.blocks[i] = null;
|
||||
}
|
||||
});
|
||||
Component.check_outros();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
info.block.d(1);
|
||||
}
|
||||
block.c();
|
||||
Component.transition_in(block, 1);
|
||||
block.m(info.mount(), info.anchor);
|
||||
needs_flush = true;
|
||||
}
|
||||
info.block = block;
|
||||
if (info.blocks) info.blocks[index] = block;
|
||||
if (needs_flush) {
|
||||
Component.flush();
|
||||
}
|
||||
}
|
||||
if (Component.is_promise(promise)) {
|
||||
const current_component = Component.get_current_component();
|
||||
promise.then(
|
||||
(value) => {
|
||||
Component.set_current_component(current_component);
|
||||
update(info.then, 1, info.value, value);
|
||||
Component.set_current_component(null);
|
||||
},
|
||||
(error) => {
|
||||
Component.set_current_component(current_component);
|
||||
update(info.catch, 2, info.error, error);
|
||||
Component.set_current_component(null);
|
||||
if (!info.hasCatch) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
);
|
||||
// if we previously had a then/catch block, destroy it
|
||||
if (info.current !== info.pending) {
|
||||
update(info.pending, 0);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (info.current !== info.then) {
|
||||
update(info.then, 1, info.value, promise);
|
||||
return true;
|
||||
}
|
||||
info.resolved = /** @type {T} */ (promise);
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function update_await_block_branch(info, ctx, dirty) {
|
||||
const child_ctx = ctx.slice();
|
||||
const { resolved } = info;
|
||||
if (info.current === info.then) {
|
||||
child_ctx[info.value] = resolved;
|
||||
}
|
||||
if (info.current === info.catch) {
|
||||
child_ctx[info.error] = resolved;
|
||||
}
|
||||
info.block.p(child_ctx, dirty);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function destroy_block(block, lookup) {
|
||||
block.d(1);
|
||||
lookup.delete(block.key);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function outro_and_destroy_block(block, lookup) {
|
||||
Component.transition_out(block, 1, 1, () => {
|
||||
lookup.delete(block.key);
|
||||
});
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function fix_and_destroy_block(block, lookup) {
|
||||
block.f();
|
||||
destroy_block(block, lookup);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function fix_and_outro_and_destroy_block(block, lookup) {
|
||||
block.f();
|
||||
outro_and_destroy_block(block, lookup);
|
||||
}
|
||||
|
||||
/** @returns {any[]} */
|
||||
function update_keyed_each(
|
||||
old_blocks,
|
||||
dirty,
|
||||
get_key,
|
||||
dynamic,
|
||||
ctx,
|
||||
list,
|
||||
lookup,
|
||||
node,
|
||||
destroy,
|
||||
create_each_block,
|
||||
next,
|
||||
get_context
|
||||
) {
|
||||
let o = old_blocks.length;
|
||||
let n = list.length;
|
||||
let i = o;
|
||||
const old_indexes = {};
|
||||
while (i--) old_indexes[old_blocks[i].key] = i;
|
||||
const new_blocks = [];
|
||||
const new_lookup = new Map();
|
||||
const deltas = new Map();
|
||||
const updates = [];
|
||||
i = n;
|
||||
while (i--) {
|
||||
const child_ctx = get_context(ctx, list, i);
|
||||
const key = get_key(child_ctx);
|
||||
let block = lookup.get(key);
|
||||
if (!block) {
|
||||
block = create_each_block(key, child_ctx);
|
||||
block.c();
|
||||
} else if (dynamic) {
|
||||
// defer updates until all the DOM shuffling is done
|
||||
updates.push(() => block.p(child_ctx, dirty));
|
||||
}
|
||||
new_lookup.set(key, (new_blocks[i] = block));
|
||||
if (key in old_indexes) deltas.set(key, Math.abs(i - old_indexes[key]));
|
||||
}
|
||||
const will_move = new Set();
|
||||
const did_move = new Set();
|
||||
/** @returns {void} */
|
||||
function insert(block) {
|
||||
Component.transition_in(block, 1);
|
||||
block.m(node, next);
|
||||
lookup.set(block.key, block);
|
||||
next = block.first;
|
||||
n--;
|
||||
}
|
||||
while (o && n) {
|
||||
const new_block = new_blocks[n - 1];
|
||||
const old_block = old_blocks[o - 1];
|
||||
const new_key = new_block.key;
|
||||
const old_key = old_block.key;
|
||||
if (new_block === old_block) {
|
||||
// do nothing
|
||||
next = new_block.first;
|
||||
o--;
|
||||
n--;
|
||||
} else if (!new_lookup.has(old_key)) {
|
||||
// remove old block
|
||||
destroy(old_block, lookup);
|
||||
o--;
|
||||
} else if (!lookup.has(new_key) || will_move.has(new_key)) {
|
||||
insert(new_block);
|
||||
} else if (did_move.has(old_key)) {
|
||||
o--;
|
||||
} else if (deltas.get(new_key) > deltas.get(old_key)) {
|
||||
did_move.add(new_key);
|
||||
insert(new_block);
|
||||
} else {
|
||||
will_move.add(old_key);
|
||||
o--;
|
||||
}
|
||||
}
|
||||
while (o--) {
|
||||
const old_block = old_blocks[o];
|
||||
if (!new_lookup.has(old_block.key)) destroy(old_block, lookup);
|
||||
}
|
||||
while (n) insert(new_blocks[n - 1]);
|
||||
Component.run_all(updates);
|
||||
return new_blocks;
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function validate_each_keys(ctx, list, get_context, get_key) {
|
||||
const keys = new Map();
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const key = get_key(get_context(ctx, list, i));
|
||||
if (keys.has(key)) {
|
||||
let value = '';
|
||||
try {
|
||||
value = `with value '${String(key)}' `;
|
||||
} catch (e) {
|
||||
// can't stringify
|
||||
}
|
||||
throw new Error(
|
||||
`Cannot have duplicate keys in a keyed each: Keys at index ${keys.get(
|
||||
key
|
||||
)} and ${i} ${value}are duplicates`
|
||||
);
|
||||
}
|
||||
keys.set(key, i);
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
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 : {};
|
||||
}
|
||||
|
||||
const _boolean_attributes = /** @type {const} */ ([
|
||||
'allowfullscreen',
|
||||
'allowpaymentrequest',
|
||||
'async',
|
||||
'autofocus',
|
||||
'autoplay',
|
||||
'checked',
|
||||
'controls',
|
||||
'default',
|
||||
'defer',
|
||||
'disabled',
|
||||
'formnovalidate',
|
||||
'hidden',
|
||||
'inert',
|
||||
'ismap',
|
||||
'loop',
|
||||
'multiple',
|
||||
'muted',
|
||||
'nomodule',
|
||||
'novalidate',
|
||||
'open',
|
||||
'playsinline',
|
||||
'readonly',
|
||||
'required',
|
||||
'reversed',
|
||||
'selected'
|
||||
]);
|
||||
|
||||
/**
|
||||
* List of HTML boolean attributes (e.g. `<input disabled>`).
|
||||
* Source: https://html.spec.whatwg.org/multipage/indices.html
|
||||
*
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
const boolean_attributes = new Set([..._boolean_attributes]);
|
||||
|
||||
/** @typedef {typeof _boolean_attributes[number]} BooleanAttributes */
|
||||
|
||||
const invalid_attribute_name_character =
|
||||
/[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
|
||||
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
||||
// https://infra.spec.whatwg.org/#noncharacter
|
||||
|
||||
/** @returns {string} */
|
||||
function spread(args, attrs_to_add) {
|
||||
const attributes = Object.assign({}, ...args);
|
||||
if (attrs_to_add) {
|
||||
const classes_to_add = attrs_to_add.classes;
|
||||
const styles_to_add = attrs_to_add.styles;
|
||||
if (classes_to_add) {
|
||||
if (attributes.class == null) {
|
||||
attributes.class = classes_to_add;
|
||||
} else {
|
||||
attributes.class += ' ' + classes_to_add;
|
||||
}
|
||||
}
|
||||
if (styles_to_add) {
|
||||
if (attributes.style == null) {
|
||||
attributes.style = style_object_to_string(styles_to_add);
|
||||
} else {
|
||||
attributes.style = style_object_to_string(
|
||||
merge_ssr_styles(attributes.style, styles_to_add)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
let str = '';
|
||||
Object.keys(attributes).forEach((name) => {
|
||||
if (invalid_attribute_name_character.test(name)) return;
|
||||
const value = attributes[name];
|
||||
if (value === true) str += ' ' + name;
|
||||
else if (boolean_attributes.has(name.toLowerCase())) {
|
||||
if (value) str += ' ' + name;
|
||||
} else if (value != null) {
|
||||
str += ` ${name}="${value}"`;
|
||||
}
|
||||
});
|
||||
return str;
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
function merge_ssr_styles(style_attribute, style_directive) {
|
||||
const style_object = {};
|
||||
for (const individual_style of style_attribute.split(';')) {
|
||||
const colon_index = individual_style.indexOf(':');
|
||||
const name = individual_style.slice(0, colon_index).trim();
|
||||
const value = individual_style.slice(colon_index + 1).trim();
|
||||
if (!name) continue;
|
||||
style_object[name] = value;
|
||||
}
|
||||
for (const name in style_directive) {
|
||||
const value = style_directive[name];
|
||||
if (value) {
|
||||
style_object[name] = value;
|
||||
} else {
|
||||
delete style_object[name];
|
||||
}
|
||||
}
|
||||
return style_object;
|
||||
}
|
||||
|
||||
const ATTR_REGEX = /[&"]/g;
|
||||
const CONTENT_REGEX = /[&<]/g;
|
||||
|
||||
/**
|
||||
* Note: this method is performance sensitive and has been optimized
|
||||
* https://github.com/sveltejs/svelte/pull/5701
|
||||
* @param {unknown} value
|
||||
* @returns {string}
|
||||
*/
|
||||
function escape(value, is_attr = false) {
|
||||
const str = String(value);
|
||||
const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
|
||||
pattern.lastIndex = 0;
|
||||
let escaped = '';
|
||||
let last = 0;
|
||||
while (pattern.test(str)) {
|
||||
const i = pattern.lastIndex - 1;
|
||||
const ch = str[i];
|
||||
escaped += str.substring(last, i) + (ch === '&' ? '&' : ch === '"' ? '"' : '<');
|
||||
last = i + 1;
|
||||
}
|
||||
return escaped + str.substring(last);
|
||||
}
|
||||
|
||||
function escape_attribute_value(value) {
|
||||
// keep booleans, null, and undefined for the sake of `spread`
|
||||
const should_escape = typeof value === 'string' || (value && typeof value === 'object');
|
||||
return should_escape ? escape(value, true) : value;
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
function escape_object(obj) {
|
||||
const result = {};
|
||||
for (const key in obj) {
|
||||
result[key] = escape_attribute_value(obj[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function each(items, fn) {
|
||||
let str = '';
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
str += fn(items[i], i);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const missing_component = {
|
||||
$$render: () => ''
|
||||
};
|
||||
|
||||
function validate_component(component, name) {
|
||||
if (!component || !component.$$render) {
|
||||
if (name === 'svelte:component') name += ' this={...}';
|
||||
throw new Error(
|
||||
`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <${name}>.`
|
||||
);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function debug(file, line, column, values) {
|
||||
console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); // eslint-disable-line no-console
|
||||
console.log(values); // eslint-disable-line no-console
|
||||
return '';
|
||||
}
|
||||
|
||||
let on_destroy;
|
||||
|
||||
/** @returns {{ render: (props?: {}, { $$slots, context }?: { $$slots?: {}; context?: Map<any, any>; }) => { html: any; css: { code: string; map: any; }; head: string; }; $$render: (result: any, props: any, bindings: any, slots: any, context: any) => any; }} */
|
||||
function create_ssr_component(fn) {
|
||||
function $$render(result, props, bindings, slots, context) {
|
||||
const parent_component = Component.current_component;
|
||||
const $$ = {
|
||||
on_destroy,
|
||||
context: new Map(context || (parent_component ? parent_component.$$.context : [])),
|
||||
// these will be immediately discarded
|
||||
on_mount: [],
|
||||
before_update: [],
|
||||
after_update: [],
|
||||
callbacks: Component.blank_object()
|
||||
};
|
||||
Component.set_current_component({ $$ });
|
||||
const html = fn(result, props, bindings, slots);
|
||||
Component.set_current_component(parent_component);
|
||||
return html;
|
||||
}
|
||||
return {
|
||||
render: (props = {}, { $$slots = {}, context = new Map() } = {}) => {
|
||||
on_destroy = [];
|
||||
const result = { title: '', head: '', css: new Set() };
|
||||
const html = $$render(result, props, {}, $$slots, context);
|
||||
Component.run_all(on_destroy);
|
||||
return {
|
||||
html,
|
||||
css: {
|
||||
code: Array.from(result.css)
|
||||
.map((css) => css.code)
|
||||
.join('\n'),
|
||||
map: null // TODO
|
||||
},
|
||||
head: result.title + result.head
|
||||
};
|
||||
},
|
||||
$$render
|
||||
};
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function add_attribute(name, value, boolean) {
|
||||
if (value == null || (boolean && !value)) return '';
|
||||
const assignment = boolean && value === true ? '' : `="${escape(value, true)}"`;
|
||||
return ` ${name}${assignment}`;
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function add_classes(classes) {
|
||||
return classes ? ` class="${classes}"` : '';
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function style_object_to_string(style_object) {
|
||||
return Object.keys(style_object)
|
||||
.filter((key) => style_object[key])
|
||||
.map((key) => `${key}: ${escape_attribute_value(style_object[key])};`)
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function add_styles(style_object) {
|
||||
const styles = style_object_to_string(style_object);
|
||||
return styles ? ` style="${styles}"` : '';
|
||||
}
|
||||
|
||||
exports.HtmlTag = Component.HtmlTag;
|
||||
exports.HtmlTagHydration = Component.HtmlTagHydration;
|
||||
exports.ResizeObserverSingleton = Component.ResizeObserverSingleton;
|
||||
exports.SvelteComponent = Component.SvelteComponent;
|
||||
Object.defineProperty(exports, 'SvelteElement', {
|
||||
enumerable: true,
|
||||
get: function () { return Component.SvelteElement; }
|
||||
});
|
||||
exports.action_destroyer = Component.action_destroyer;
|
||||
exports.add_flush_callback = Component.add_flush_callback;
|
||||
exports.add_iframe_resize_listener = Component.add_iframe_resize_listener;
|
||||
exports.add_location = Component.add_location;
|
||||
exports.add_render_callback = Component.add_render_callback;
|
||||
exports.afterUpdate = Component.afterUpdate;
|
||||
exports.append = Component.append;
|
||||
exports.append_empty_stylesheet = Component.append_empty_stylesheet;
|
||||
exports.append_hydration = Component.append_hydration;
|
||||
exports.append_styles = Component.append_styles;
|
||||
exports.assign = Component.assign;
|
||||
exports.attr = Component.attr;
|
||||
exports.attribute_to_object = Component.attribute_to_object;
|
||||
exports.beforeUpdate = Component.beforeUpdate;
|
||||
exports.bind = Component.bind;
|
||||
exports.binding_callbacks = Component.binding_callbacks;
|
||||
exports.blank_object = Component.blank_object;
|
||||
exports.bubble = Component.bubble;
|
||||
exports.check_outros = Component.check_outros;
|
||||
exports.children = Component.children;
|
||||
exports.claim_comment = Component.claim_comment;
|
||||
exports.claim_component = Component.claim_component;
|
||||
exports.claim_element = Component.claim_element;
|
||||
exports.claim_html_tag = Component.claim_html_tag;
|
||||
exports.claim_space = Component.claim_space;
|
||||
exports.claim_svg_element = Component.claim_svg_element;
|
||||
exports.claim_text = Component.claim_text;
|
||||
exports.clear_loops = Component.clear_loops;
|
||||
exports.comment = Component.comment;
|
||||
exports.component_subscribe = Component.component_subscribe;
|
||||
exports.compute_rest_props = Component.compute_rest_props;
|
||||
exports.compute_slots = Component.compute_slots;
|
||||
exports.construct_svelte_component = Component.construct_svelte_component;
|
||||
exports.contenteditable_truthy_values = Component.contenteditable_truthy_values;
|
||||
exports.createEventDispatcher = Component.createEventDispatcher;
|
||||
exports.create_bidirectional_transition = Component.create_bidirectional_transition;
|
||||
exports.create_component = Component.create_component;
|
||||
exports.create_custom_element = Component.create_custom_element;
|
||||
exports.create_in_transition = Component.create_in_transition;
|
||||
exports.create_out_transition = Component.create_out_transition;
|
||||
exports.create_slot = Component.create_slot;
|
||||
Object.defineProperty(exports, 'current_component', {
|
||||
enumerable: true,
|
||||
get: function () { return Component.current_component; }
|
||||
});
|
||||
exports.custom_event = Component.custom_event;
|
||||
exports.destroy_component = Component.destroy_component;
|
||||
exports.destroy_each = Component.destroy_each;
|
||||
exports.detach = Component.detach;
|
||||
exports.dirty_components = Component.dirty_components;
|
||||
exports.element = Component.element;
|
||||
exports.element_is = Component.element_is;
|
||||
exports.empty = Component.empty;
|
||||
exports.end_hydrating = Component.end_hydrating;
|
||||
exports.exclude_internal_props = Component.exclude_internal_props;
|
||||
exports.flush = Component.flush;
|
||||
exports.flush_render_callbacks = Component.flush_render_callbacks;
|
||||
exports.getAllContexts = Component.getAllContexts;
|
||||
exports.getContext = Component.getContext;
|
||||
exports.get_all_dirty_from_scope = Component.get_all_dirty_from_scope;
|
||||
exports.get_binding_group_value = Component.get_binding_group_value;
|
||||
exports.get_current_component = Component.get_current_component;
|
||||
exports.get_custom_elements_slots = Component.get_custom_elements_slots;
|
||||
exports.get_root_for_style = Component.get_root_for_style;
|
||||
exports.get_slot_changes = Component.get_slot_changes;
|
||||
exports.get_store_value = Component.get_store_value;
|
||||
exports.get_svelte_dataset = Component.get_svelte_dataset;
|
||||
exports.globals = Component.globals;
|
||||
exports.group_outros = Component.group_outros;
|
||||
exports.hasContext = Component.hasContext;
|
||||
exports.has_prop = Component.has_prop;
|
||||
exports.head_selector = Component.head_selector;
|
||||
exports.identity = Component.identity;
|
||||
exports.init = Component.init;
|
||||
exports.init_binding_group = Component.init_binding_group;
|
||||
exports.init_binding_group_dynamic = Component.init_binding_group_dynamic;
|
||||
exports.insert = Component.insert;
|
||||
exports.insert_hydration = Component.insert_hydration;
|
||||
exports.intros = Component.intros;
|
||||
exports.is_client = Component.is_client;
|
||||
exports.is_crossorigin = Component.is_crossorigin;
|
||||
exports.is_empty = Component.is_empty;
|
||||
exports.is_function = Component.is_function;
|
||||
exports.is_promise = Component.is_promise;
|
||||
exports.listen = Component.listen;
|
||||
exports.loop = Component.loop;
|
||||
exports.mount_component = Component.mount_component;
|
||||
exports.noop = Component.noop;
|
||||
exports.not_equal = Component.not_equal;
|
||||
Object.defineProperty(exports, 'now', {
|
||||
enumerable: true,
|
||||
get: function () { return Component.now; }
|
||||
});
|
||||
exports.null_to_empty = Component.null_to_empty;
|
||||
exports.object_without_properties = Component.object_without_properties;
|
||||
exports.onDestroy = Component.onDestroy;
|
||||
exports.onMount = Component.onMount;
|
||||
exports.once = Component.once;
|
||||
exports.prevent_default = Component.prevent_default;
|
||||
exports.query_selector_all = Component.query_selector_all;
|
||||
Object.defineProperty(exports, 'raf', {
|
||||
enumerable: true,
|
||||
get: function () { return Component.raf; }
|
||||
});
|
||||
exports.resize_observer_border_box = Component.resize_observer_border_box;
|
||||
exports.resize_observer_content_box = Component.resize_observer_content_box;
|
||||
exports.resize_observer_device_pixel_content_box = Component.resize_observer_device_pixel_content_box;
|
||||
exports.run = Component.run;
|
||||
exports.run_all = Component.run_all;
|
||||
exports.safe_not_equal = Component.safe_not_equal;
|
||||
exports.schedule_update = Component.schedule_update;
|
||||
exports.select_multiple_value = Component.select_multiple_value;
|
||||
exports.select_option = Component.select_option;
|
||||
exports.select_options = Component.select_options;
|
||||
exports.select_value = Component.select_value;
|
||||
exports.self = Component.self;
|
||||
exports.setContext = Component.setContext;
|
||||
exports.set_attributes = Component.set_attributes;
|
||||
exports.set_current_component = Component.set_current_component;
|
||||
exports.set_custom_element_data = Component.set_custom_element_data;
|
||||
exports.set_custom_element_data_map = Component.set_custom_element_data_map;
|
||||
exports.set_data = Component.set_data;
|
||||
exports.set_data_contenteditable = Component.set_data_contenteditable;
|
||||
exports.set_data_maybe_contenteditable = Component.set_data_maybe_contenteditable;
|
||||
exports.set_dynamic_element_data = Component.set_dynamic_element_data;
|
||||
exports.set_input_type = Component.set_input_type;
|
||||
exports.set_input_value = Component.set_input_value;
|
||||
exports.set_now = Component.set_now;
|
||||
exports.set_raf = Component.set_raf;
|
||||
exports.set_store_value = Component.set_store_value;
|
||||
exports.set_style = Component.set_style;
|
||||
exports.set_svg_attributes = Component.set_svg_attributes;
|
||||
exports.space = Component.space;
|
||||
exports.split_css_unit = Component.split_css_unit;
|
||||
exports.src_url_equal = Component.src_url_equal;
|
||||
exports.start_hydrating = Component.start_hydrating;
|
||||
exports.stop_immediate_propagation = Component.stop_immediate_propagation;
|
||||
exports.stop_propagation = Component.stop_propagation;
|
||||
exports.subscribe = Component.subscribe;
|
||||
exports.svg_element = Component.svg_element;
|
||||
exports.text = Component.text;
|
||||
exports.tick = Component.tick;
|
||||
exports.time_ranges_to_array = Component.time_ranges_to_array;
|
||||
exports.to_number = Component.to_number;
|
||||
exports.toggle_class = Component.toggle_class;
|
||||
exports.transition_in = Component.transition_in;
|
||||
exports.transition_out = Component.transition_out;
|
||||
exports.trusted = Component.trusted;
|
||||
exports.update_slot = Component.update_slot;
|
||||
exports.update_slot_base = Component.update_slot_base;
|
||||
exports.validate_store = Component.validate_store;
|
||||
exports.xlink_attr = Component.xlink_attr;
|
||||
exports.SvelteComponentDev = dev.SvelteComponentDev;
|
||||
exports.SvelteComponentTyped = dev.SvelteComponentTyped;
|
||||
exports.append_dev = dev.append_dev;
|
||||
exports.append_hydration_dev = dev.append_hydration_dev;
|
||||
exports.attr_dev = dev.attr_dev;
|
||||
exports.construct_svelte_component_dev = dev.construct_svelte_component_dev;
|
||||
exports.dataset_dev = dev.dataset_dev;
|
||||
exports.detach_after_dev = dev.detach_after_dev;
|
||||
exports.detach_before_dev = dev.detach_before_dev;
|
||||
exports.detach_between_dev = dev.detach_between_dev;
|
||||
exports.detach_dev = dev.detach_dev;
|
||||
exports.dispatch_dev = dev.dispatch_dev;
|
||||
exports.insert_dev = dev.insert_dev;
|
||||
exports.insert_hydration_dev = dev.insert_hydration_dev;
|
||||
exports.is_void = dev.is_void;
|
||||
exports.listen_dev = dev.listen_dev;
|
||||
exports.loop_guard = dev.loop_guard;
|
||||
exports.prop_dev = dev.prop_dev;
|
||||
exports.set_data_contenteditable_dev = dev.set_data_contenteditable_dev;
|
||||
exports.set_data_dev = dev.set_data_dev;
|
||||
exports.set_data_maybe_contenteditable_dev = dev.set_data_maybe_contenteditable_dev;
|
||||
exports.validate_dynamic_element = dev.validate_dynamic_element;
|
||||
exports.validate_each_argument = dev.validate_each_argument;
|
||||
exports.validate_slots = dev.validate_slots;
|
||||
exports.validate_void_dynamic_element = dev.validate_void_dynamic_element;
|
||||
exports.add_attribute = add_attribute;
|
||||
exports.add_classes = add_classes;
|
||||
exports.add_styles = add_styles;
|
||||
exports.add_transform = add_transform;
|
||||
exports.create_animation = create_animation;
|
||||
exports.create_ssr_component = create_ssr_component;
|
||||
exports.debug = debug;
|
||||
exports.destroy_block = destroy_block;
|
||||
exports.each = each;
|
||||
exports.escape = escape;
|
||||
exports.escape_attribute_value = escape_attribute_value;
|
||||
exports.escape_object = escape_object;
|
||||
exports.fix_and_destroy_block = fix_and_destroy_block;
|
||||
exports.fix_and_outro_and_destroy_block = fix_and_outro_and_destroy_block;
|
||||
exports.fix_position = fix_position;
|
||||
exports.get_spread_object = get_spread_object;
|
||||
exports.get_spread_update = get_spread_update;
|
||||
exports.handle_promise = handle_promise;
|
||||
exports.invalid_attribute_name_character = invalid_attribute_name_character;
|
||||
exports.merge_ssr_styles = merge_ssr_styles;
|
||||
exports.missing_component = missing_component;
|
||||
exports.outro_and_destroy_block = outro_and_destroy_block;
|
||||
exports.spread = spread;
|
||||
exports.update_await_block_branch = update_await_block_branch;
|
||||
exports.update_keyed_each = update_keyed_each;
|
||||
exports.validate_component = validate_component;
|
||||
exports.validate_each_keys = validate_each_keys;
|
@ -1,601 +0,0 @@
|
||||
import { noop, identity, now, loop, create_rule, delete_rule, is_promise, get_current_component, set_current_component, group_outros, transition_out, check_outros, transition_in, flush, run_all, blank_object, current_component } from './Component-cd97939e.mjs';
|
||||
export { HtmlTag, HtmlTagHydration, ResizeObserverSingleton, SvelteComponent, SvelteElement, action_destroyer, add_flush_callback, add_iframe_resize_listener, add_location, add_render_callback, afterUpdate, append, append_empty_stylesheet, append_hydration, append_styles, assign, attr, attribute_to_object, beforeUpdate, bind, binding_callbacks, bubble, children, claim_comment, claim_component, claim_element, claim_html_tag, claim_space, claim_svg_element, claim_text, clear_loops, comment, component_subscribe, compute_rest_props, compute_slots, construct_svelte_component, contenteditable_truthy_values, createEventDispatcher, create_bidirectional_transition, create_component, create_custom_element, create_in_transition, create_out_transition, create_slot, custom_event, destroy_component, destroy_each, detach, dirty_components, element, element_is, empty, end_hydrating, exclude_internal_props, flush_render_callbacks, getAllContexts, getContext, get_all_dirty_from_scope, get_binding_group_value, get_custom_elements_slots, get_root_for_style, get_slot_changes, get_store_value, get_svelte_dataset, globals, hasContext, has_prop, head_selector, init, init_binding_group, init_binding_group_dynamic, insert, insert_hydration, intros, is_client, is_crossorigin, is_empty, is_function, listen, mount_component, not_equal, null_to_empty, object_without_properties, onDestroy, onMount, once, prevent_default, query_selector_all, raf, resize_observer_border_box, resize_observer_content_box, resize_observer_device_pixel_content_box, run, safe_not_equal, schedule_update, select_multiple_value, select_option, select_options, select_value, self, setContext, set_attributes, set_custom_element_data, set_custom_element_data_map, set_data, set_data_contenteditable, set_data_maybe_contenteditable, set_dynamic_element_data, set_input_type, set_input_value, set_now, set_raf, set_store_value, set_style, set_svg_attributes, space, split_css_unit, src_url_equal, start_hydrating, stop_immediate_propagation, stop_propagation, subscribe, svg_element, text, tick, time_ranges_to_array, to_number, toggle_class, trusted, update_slot, update_slot_base, validate_store, xlink_attr } from './Component-cd97939e.mjs';
|
||||
export { SvelteComponentDev, SvelteComponentTyped, append_dev, append_hydration_dev, attr_dev, construct_svelte_component_dev, dataset_dev, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dispatch_dev, insert_dev, insert_hydration_dev, is_void, listen_dev, loop_guard, prop_dev, set_data_contenteditable_dev, set_data_dev, set_data_maybe_contenteditable_dev, validate_dynamic_element, validate_each_argument, validate_slots, validate_void_dynamic_element } from './dev-89102382.mjs';
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {import('./private.js').PositionRect} from
|
||||
* @param {import('./private.js').AnimationFn} fn
|
||||
*/
|
||||
function create_animation(node, from, fn, params) {
|
||||
if (!from) return noop;
|
||||
const to = node.getBoundingClientRect();
|
||||
if (
|
||||
from.left === to.left &&
|
||||
from.right === to.right &&
|
||||
from.top === to.top &&
|
||||
from.bottom === to.bottom
|
||||
)
|
||||
return noop;
|
||||
const {
|
||||
delay = 0,
|
||||
duration = 300,
|
||||
easing = identity,
|
||||
// @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation?
|
||||
start: start_time = now() + delay,
|
||||
// @ts-ignore todo:
|
||||
end = start_time + duration,
|
||||
tick = noop,
|
||||
css
|
||||
} = fn(node, { from, to }, params);
|
||||
let running = true;
|
||||
let started = false;
|
||||
let name;
|
||||
/** @returns {void} */
|
||||
function start() {
|
||||
if (css) {
|
||||
name = create_rule(node, 0, 1, duration, delay, easing, css);
|
||||
}
|
||||
if (!delay) {
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
/** @returns {void} */
|
||||
function stop() {
|
||||
if (css) delete_rule(node, name);
|
||||
running = false;
|
||||
}
|
||||
loop((now) => {
|
||||
if (!started && now >= start_time) {
|
||||
started = true;
|
||||
}
|
||||
if (started && now >= end) {
|
||||
tick(1, 0);
|
||||
stop();
|
||||
}
|
||||
if (!running) {
|
||||
return false;
|
||||
}
|
||||
if (started) {
|
||||
const p = now - start_time;
|
||||
const t = 0 + 1 * easing(p / duration);
|
||||
tick(t, 1 - t);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
start();
|
||||
tick(0, 1);
|
||||
return stop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @returns {void}
|
||||
*/
|
||||
function fix_position(node) {
|
||||
const style = getComputedStyle(node);
|
||||
if (style.position !== 'absolute' && style.position !== 'fixed') {
|
||||
const { width, height } = style;
|
||||
const a = node.getBoundingClientRect();
|
||||
node.style.position = 'absolute';
|
||||
node.style.width = width;
|
||||
node.style.height = height;
|
||||
add_transform(node, a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element & ElementCSSInlineStyle} node
|
||||
* @param {import('./private.js').PositionRect} a
|
||||
* @returns {void}
|
||||
*/
|
||||
function add_transform(node, a) {
|
||||
const b = node.getBoundingClientRect();
|
||||
if (a.left !== b.left || a.top !== b.top) {
|
||||
const style = getComputedStyle(node);
|
||||
const transform = style.transform === 'none' ? '' : style.transform;
|
||||
node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {Promise<T>} promise
|
||||
* @param {import('./private.js').PromiseInfo<T>} info
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function handle_promise(promise, info) {
|
||||
const token = (info.token = {});
|
||||
/**
|
||||
* @param {import('./private.js').FragmentFactory} type
|
||||
* @param {0 | 1 | 2} index
|
||||
* @param {number} [key]
|
||||
* @param {any} [value]
|
||||
* @returns {void}
|
||||
*/
|
||||
function update(type, index, key, value) {
|
||||
if (info.token !== token) return;
|
||||
info.resolved = value;
|
||||
let child_ctx = info.ctx;
|
||||
if (key !== undefined) {
|
||||
child_ctx = child_ctx.slice();
|
||||
child_ctx[key] = value;
|
||||
}
|
||||
const block = type && (info.current = type)(child_ctx);
|
||||
let needs_flush = false;
|
||||
if (info.block) {
|
||||
if (info.blocks) {
|
||||
info.blocks.forEach((block, i) => {
|
||||
if (i !== index && block) {
|
||||
group_outros();
|
||||
transition_out(block, 1, 1, () => {
|
||||
if (info.blocks[i] === block) {
|
||||
info.blocks[i] = null;
|
||||
}
|
||||
});
|
||||
check_outros();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
info.block.d(1);
|
||||
}
|
||||
block.c();
|
||||
transition_in(block, 1);
|
||||
block.m(info.mount(), info.anchor);
|
||||
needs_flush = true;
|
||||
}
|
||||
info.block = block;
|
||||
if (info.blocks) info.blocks[index] = block;
|
||||
if (needs_flush) {
|
||||
flush();
|
||||
}
|
||||
}
|
||||
if (is_promise(promise)) {
|
||||
const current_component = get_current_component();
|
||||
promise.then(
|
||||
(value) => {
|
||||
set_current_component(current_component);
|
||||
update(info.then, 1, info.value, value);
|
||||
set_current_component(null);
|
||||
},
|
||||
(error) => {
|
||||
set_current_component(current_component);
|
||||
update(info.catch, 2, info.error, error);
|
||||
set_current_component(null);
|
||||
if (!info.hasCatch) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
);
|
||||
// if we previously had a then/catch block, destroy it
|
||||
if (info.current !== info.pending) {
|
||||
update(info.pending, 0);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (info.current !== info.then) {
|
||||
update(info.then, 1, info.value, promise);
|
||||
return true;
|
||||
}
|
||||
info.resolved = /** @type {T} */ (promise);
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function update_await_block_branch(info, ctx, dirty) {
|
||||
const child_ctx = ctx.slice();
|
||||
const { resolved } = info;
|
||||
if (info.current === info.then) {
|
||||
child_ctx[info.value] = resolved;
|
||||
}
|
||||
if (info.current === info.catch) {
|
||||
child_ctx[info.error] = resolved;
|
||||
}
|
||||
info.block.p(child_ctx, dirty);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function destroy_block(block, lookup) {
|
||||
block.d(1);
|
||||
lookup.delete(block.key);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function outro_and_destroy_block(block, lookup) {
|
||||
transition_out(block, 1, 1, () => {
|
||||
lookup.delete(block.key);
|
||||
});
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function fix_and_destroy_block(block, lookup) {
|
||||
block.f();
|
||||
destroy_block(block, lookup);
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function fix_and_outro_and_destroy_block(block, lookup) {
|
||||
block.f();
|
||||
outro_and_destroy_block(block, lookup);
|
||||
}
|
||||
|
||||
/** @returns {any[]} */
|
||||
function update_keyed_each(
|
||||
old_blocks,
|
||||
dirty,
|
||||
get_key,
|
||||
dynamic,
|
||||
ctx,
|
||||
list,
|
||||
lookup,
|
||||
node,
|
||||
destroy,
|
||||
create_each_block,
|
||||
next,
|
||||
get_context
|
||||
) {
|
||||
let o = old_blocks.length;
|
||||
let n = list.length;
|
||||
let i = o;
|
||||
const old_indexes = {};
|
||||
while (i--) old_indexes[old_blocks[i].key] = i;
|
||||
const new_blocks = [];
|
||||
const new_lookup = new Map();
|
||||
const deltas = new Map();
|
||||
const updates = [];
|
||||
i = n;
|
||||
while (i--) {
|
||||
const child_ctx = get_context(ctx, list, i);
|
||||
const key = get_key(child_ctx);
|
||||
let block = lookup.get(key);
|
||||
if (!block) {
|
||||
block = create_each_block(key, child_ctx);
|
||||
block.c();
|
||||
} else if (dynamic) {
|
||||
// defer updates until all the DOM shuffling is done
|
||||
updates.push(() => block.p(child_ctx, dirty));
|
||||
}
|
||||
new_lookup.set(key, (new_blocks[i] = block));
|
||||
if (key in old_indexes) deltas.set(key, Math.abs(i - old_indexes[key]));
|
||||
}
|
||||
const will_move = new Set();
|
||||
const did_move = new Set();
|
||||
/** @returns {void} */
|
||||
function insert(block) {
|
||||
transition_in(block, 1);
|
||||
block.m(node, next);
|
||||
lookup.set(block.key, block);
|
||||
next = block.first;
|
||||
n--;
|
||||
}
|
||||
while (o && n) {
|
||||
const new_block = new_blocks[n - 1];
|
||||
const old_block = old_blocks[o - 1];
|
||||
const new_key = new_block.key;
|
||||
const old_key = old_block.key;
|
||||
if (new_block === old_block) {
|
||||
// do nothing
|
||||
next = new_block.first;
|
||||
o--;
|
||||
n--;
|
||||
} else if (!new_lookup.has(old_key)) {
|
||||
// remove old block
|
||||
destroy(old_block, lookup);
|
||||
o--;
|
||||
} else if (!lookup.has(new_key) || will_move.has(new_key)) {
|
||||
insert(new_block);
|
||||
} else if (did_move.has(old_key)) {
|
||||
o--;
|
||||
} else if (deltas.get(new_key) > deltas.get(old_key)) {
|
||||
did_move.add(new_key);
|
||||
insert(new_block);
|
||||
} else {
|
||||
will_move.add(old_key);
|
||||
o--;
|
||||
}
|
||||
}
|
||||
while (o--) {
|
||||
const old_block = old_blocks[o];
|
||||
if (!new_lookup.has(old_block.key)) destroy(old_block, lookup);
|
||||
}
|
||||
while (n) insert(new_blocks[n - 1]);
|
||||
run_all(updates);
|
||||
return new_blocks;
|
||||
}
|
||||
|
||||
/** @returns {void} */
|
||||
function validate_each_keys(ctx, list, get_context, get_key) {
|
||||
const keys = new Map();
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const key = get_key(get_context(ctx, list, i));
|
||||
if (keys.has(key)) {
|
||||
let value = '';
|
||||
try {
|
||||
value = `with value '${String(key)}' `;
|
||||
} catch (e) {
|
||||
// can't stringify
|
||||
}
|
||||
throw new Error(
|
||||
`Cannot have duplicate keys in a keyed each: Keys at index ${keys.get(
|
||||
key
|
||||
)} and ${i} ${value}are duplicates`
|
||||
);
|
||||
}
|
||||
keys.set(key, i);
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
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 : {};
|
||||
}
|
||||
|
||||
const _boolean_attributes = /** @type {const} */ ([
|
||||
'allowfullscreen',
|
||||
'allowpaymentrequest',
|
||||
'async',
|
||||
'autofocus',
|
||||
'autoplay',
|
||||
'checked',
|
||||
'controls',
|
||||
'default',
|
||||
'defer',
|
||||
'disabled',
|
||||
'formnovalidate',
|
||||
'hidden',
|
||||
'inert',
|
||||
'ismap',
|
||||
'loop',
|
||||
'multiple',
|
||||
'muted',
|
||||
'nomodule',
|
||||
'novalidate',
|
||||
'open',
|
||||
'playsinline',
|
||||
'readonly',
|
||||
'required',
|
||||
'reversed',
|
||||
'selected'
|
||||
]);
|
||||
|
||||
/**
|
||||
* List of HTML boolean attributes (e.g. `<input disabled>`).
|
||||
* Source: https://html.spec.whatwg.org/multipage/indices.html
|
||||
*
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
const boolean_attributes = new Set([..._boolean_attributes]);
|
||||
|
||||
/** @typedef {typeof _boolean_attributes[number]} BooleanAttributes */
|
||||
|
||||
const invalid_attribute_name_character =
|
||||
/[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
|
||||
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
||||
// https://infra.spec.whatwg.org/#noncharacter
|
||||
|
||||
/** @returns {string} */
|
||||
function spread(args, attrs_to_add) {
|
||||
const attributes = Object.assign({}, ...args);
|
||||
if (attrs_to_add) {
|
||||
const classes_to_add = attrs_to_add.classes;
|
||||
const styles_to_add = attrs_to_add.styles;
|
||||
if (classes_to_add) {
|
||||
if (attributes.class == null) {
|
||||
attributes.class = classes_to_add;
|
||||
} else {
|
||||
attributes.class += ' ' + classes_to_add;
|
||||
}
|
||||
}
|
||||
if (styles_to_add) {
|
||||
if (attributes.style == null) {
|
||||
attributes.style = style_object_to_string(styles_to_add);
|
||||
} else {
|
||||
attributes.style = style_object_to_string(
|
||||
merge_ssr_styles(attributes.style, styles_to_add)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
let str = '';
|
||||
Object.keys(attributes).forEach((name) => {
|
||||
if (invalid_attribute_name_character.test(name)) return;
|
||||
const value = attributes[name];
|
||||
if (value === true) str += ' ' + name;
|
||||
else if (boolean_attributes.has(name.toLowerCase())) {
|
||||
if (value) str += ' ' + name;
|
||||
} else if (value != null) {
|
||||
str += ` ${name}="${value}"`;
|
||||
}
|
||||
});
|
||||
return str;
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
function merge_ssr_styles(style_attribute, style_directive) {
|
||||
const style_object = {};
|
||||
for (const individual_style of style_attribute.split(';')) {
|
||||
const colon_index = individual_style.indexOf(':');
|
||||
const name = individual_style.slice(0, colon_index).trim();
|
||||
const value = individual_style.slice(colon_index + 1).trim();
|
||||
if (!name) continue;
|
||||
style_object[name] = value;
|
||||
}
|
||||
for (const name in style_directive) {
|
||||
const value = style_directive[name];
|
||||
if (value) {
|
||||
style_object[name] = value;
|
||||
} else {
|
||||
delete style_object[name];
|
||||
}
|
||||
}
|
||||
return style_object;
|
||||
}
|
||||
|
||||
const ATTR_REGEX = /[&"]/g;
|
||||
const CONTENT_REGEX = /[&<]/g;
|
||||
|
||||
/**
|
||||
* Note: this method is performance sensitive and has been optimized
|
||||
* https://github.com/sveltejs/svelte/pull/5701
|
||||
* @param {unknown} value
|
||||
* @returns {string}
|
||||
*/
|
||||
function escape(value, is_attr = false) {
|
||||
const str = String(value);
|
||||
const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
|
||||
pattern.lastIndex = 0;
|
||||
let escaped = '';
|
||||
let last = 0;
|
||||
while (pattern.test(str)) {
|
||||
const i = pattern.lastIndex - 1;
|
||||
const ch = str[i];
|
||||
escaped += str.substring(last, i) + (ch === '&' ? '&' : ch === '"' ? '"' : '<');
|
||||
last = i + 1;
|
||||
}
|
||||
return escaped + str.substring(last);
|
||||
}
|
||||
|
||||
function escape_attribute_value(value) {
|
||||
// keep booleans, null, and undefined for the sake of `spread`
|
||||
const should_escape = typeof value === 'string' || (value && typeof value === 'object');
|
||||
return should_escape ? escape(value, true) : value;
|
||||
}
|
||||
|
||||
/** @returns {{}} */
|
||||
function escape_object(obj) {
|
||||
const result = {};
|
||||
for (const key in obj) {
|
||||
result[key] = escape_attribute_value(obj[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function each(items, fn) {
|
||||
let str = '';
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
str += fn(items[i], i);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const missing_component = {
|
||||
$$render: () => ''
|
||||
};
|
||||
|
||||
function validate_component(component, name) {
|
||||
if (!component || !component.$$render) {
|
||||
if (name === 'svelte:component') name += ' this={...}';
|
||||
throw new Error(
|
||||
`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <${name}>.`
|
||||
);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function debug(file, line, column, values) {
|
||||
console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); // eslint-disable-line no-console
|
||||
console.log(values); // eslint-disable-line no-console
|
||||
return '';
|
||||
}
|
||||
|
||||
let on_destroy;
|
||||
|
||||
/** @returns {{ render: (props?: {}, { $$slots, context }?: { $$slots?: {}; context?: Map<any, any>; }) => { html: any; css: { code: string; map: any; }; head: string; }; $$render: (result: any, props: any, bindings: any, slots: any, context: any) => any; }} */
|
||||
function create_ssr_component(fn) {
|
||||
function $$render(result, props, bindings, slots, context) {
|
||||
const parent_component = current_component;
|
||||
const $$ = {
|
||||
on_destroy,
|
||||
context: new Map(context || (parent_component ? parent_component.$$.context : [])),
|
||||
// these will be immediately discarded
|
||||
on_mount: [],
|
||||
before_update: [],
|
||||
after_update: [],
|
||||
callbacks: blank_object()
|
||||
};
|
||||
set_current_component({ $$ });
|
||||
const html = fn(result, props, bindings, slots);
|
||||
set_current_component(parent_component);
|
||||
return html;
|
||||
}
|
||||
return {
|
||||
render: (props = {}, { $$slots = {}, context = new Map() } = {}) => {
|
||||
on_destroy = [];
|
||||
const result = { title: '', head: '', css: new Set() };
|
||||
const html = $$render(result, props, {}, $$slots, context);
|
||||
run_all(on_destroy);
|
||||
return {
|
||||
html,
|
||||
css: {
|
||||
code: Array.from(result.css)
|
||||
.map((css) => css.code)
|
||||
.join('\n'),
|
||||
map: null // TODO
|
||||
},
|
||||
head: result.title + result.head
|
||||
};
|
||||
},
|
||||
$$render
|
||||
};
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function add_attribute(name, value, boolean) {
|
||||
if (value == null || (boolean && !value)) return '';
|
||||
const assignment = boolean && value === true ? '' : `="${escape(value, true)}"`;
|
||||
return ` ${name}${assignment}`;
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function add_classes(classes) {
|
||||
return classes ? ` class="${classes}"` : '';
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function style_object_to_string(style_object) {
|
||||
return Object.keys(style_object)
|
||||
.filter((key) => style_object[key])
|
||||
.map((key) => `${key}: ${escape_attribute_value(style_object[key])};`)
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
/** @returns {string} */
|
||||
function add_styles(style_object) {
|
||||
const styles = style_object_to_string(style_object);
|
||||
return styles ? ` style="${styles}"` : '';
|
||||
}
|
||||
|
||||
export { add_attribute, add_classes, add_styles, add_transform, blank_object, check_outros, create_animation, create_ssr_component, current_component, debug, destroy_block, each, escape, escape_attribute_value, escape_object, fix_and_destroy_block, fix_and_outro_and_destroy_block, fix_position, flush, get_current_component, get_spread_object, get_spread_update, group_outros, handle_promise, identity, invalid_attribute_name_character, is_promise, loop, merge_ssr_styles, missing_component, noop, now, outro_and_destroy_block, run_all, set_current_component, spread, transition_in, transition_out, update_await_block_branch, update_keyed_each, validate_component, validate_each_keys };
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"main": "./index",
|
||||
"module": "./index.mjs",
|
||||
"types": "./index.d.ts"
|
||||
}
|
Loading…
Reference in new issue