mirror of https://github.com/sveltejs/svelte
commit
ad949c5490
@ -0,0 +1 @@
|
|||||||
|
export * from '../types/runtime/action/index.js';
|
@ -0,0 +1,2 @@
|
|||||||
|
'use strict';
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"main": "./index",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"types": "./index.d.ts"
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
export * from '../types/runtime/animate/index.js';
|
@ -0,0 +1,33 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var easing = require('../easing/index.js');
|
||||||
|
var Component = require('../internal/Component-9c4b98a2.js');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Element} node
|
||||||
|
* @param {{ from: DOMRect; to: DOMRect }} fromTo
|
||||||
|
* @param {import('./public.js').FlipParams} params
|
||||||
|
* @returns {import('./public.js').AnimationConfig}
|
||||||
|
*/
|
||||||
|
function flip(node, { from, to }, params = {}) {
|
||||||
|
const style = getComputedStyle(node);
|
||||||
|
const transform = style.transform === 'none' ? '' : style.transform;
|
||||||
|
const [ox, oy] = style.transformOrigin.split(' ').map(parseFloat);
|
||||||
|
const dx = from.left + (from.width * ox) / to.width - (to.left + ox);
|
||||||
|
const dy = from.top + (from.height * oy) / to.height - (to.top + oy);
|
||||||
|
const { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing: easing$1 = easing.cubicOut } = params;
|
||||||
|
return {
|
||||||
|
delay,
|
||||||
|
duration: Component.is_function(duration) ? duration(Math.sqrt(dx * dx + dy * dy)) : duration,
|
||||||
|
easing: easing$1,
|
||||||
|
css: (t, u) => {
|
||||||
|
const x = u * dx;
|
||||||
|
const y = u * dy;
|
||||||
|
const sx = t + (u * from.width) / to.width;
|
||||||
|
const sy = t + (u * from.height) / to.height;
|
||||||
|
return `transform: ${transform} translate(${x}px, ${y}px) scale(${sx}, ${sy});`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.flip = flip;
|
@ -0,0 +1,31 @@
|
|||||||
|
import { cubicOut } from '../easing/index.mjs';
|
||||||
|
import { is_function } from '../internal/Component-cd97939e.mjs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Element} node
|
||||||
|
* @param {{ from: DOMRect; to: DOMRect }} fromTo
|
||||||
|
* @param {import('./public.js').FlipParams} params
|
||||||
|
* @returns {import('./public.js').AnimationConfig}
|
||||||
|
*/
|
||||||
|
function flip(node, { from, to }, params = {}) {
|
||||||
|
const style = getComputedStyle(node);
|
||||||
|
const transform = style.transform === 'none' ? '' : style.transform;
|
||||||
|
const [ox, oy] = style.transformOrigin.split(' ').map(parseFloat);
|
||||||
|
const dx = from.left + (from.width * ox) / to.width - (to.left + ox);
|
||||||
|
const dy = from.top + (from.height * oy) / to.height - (to.top + oy);
|
||||||
|
const { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut } = params;
|
||||||
|
return {
|
||||||
|
delay,
|
||||||
|
duration: is_function(duration) ? duration(Math.sqrt(dx * dx + dy * dy)) : duration,
|
||||||
|
easing,
|
||||||
|
css: (t, u) => {
|
||||||
|
const x = u * dx;
|
||||||
|
const y = u * dy;
|
||||||
|
const sx = t + (u * from.width) / to.width;
|
||||||
|
const sy = t + (u * from.height) / to.height;
|
||||||
|
return `transform: ${transform} translate(${x}px, ${y}px) scale(${sx}, ${sy});`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export { flip };
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"main": "./index",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"types": "./index.d.ts"
|
||||||
|
}
|
@ -1,4 +0,0 @@
|
|||||||
if (!process.env.PUBLISH) {
|
|
||||||
console.error('npm publish must be run with the PUBLISH environment variable set');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
import { existsSync, fstat, readFileSync, readdirSync, writeFileSync } from 'fs';
|
|
||||||
import { resolve } from 'path';
|
|
||||||
import { parse } from 'acorn';
|
|
||||||
import { walk } from 'estree-walker';
|
|
||||||
import { inspect } from 'util';
|
|
||||||
|
|
||||||
import { p, print } from 'code-red';
|
|
||||||
|
|
||||||
const samples = resolve(`vitest/runtime/runtime/samples`);
|
|
||||||
|
|
||||||
for (const dir of readdirSync(samples)) {
|
|
||||||
const cwd = resolve(samples, dir);
|
|
||||||
const file = resolve(cwd, '_config.js');
|
|
||||||
|
|
||||||
if (!existsSync(file)) continue;
|
|
||||||
const contents = readFileSync(file, 'utf-8');
|
|
||||||
const ast = parse(contents, {
|
|
||||||
sourceType: 'module',
|
|
||||||
ecmaVersion: 'latest',
|
|
||||||
sourceFile: file,
|
|
||||||
ranges: true
|
|
||||||
});
|
|
||||||
|
|
||||||
walk(ast, {
|
|
||||||
enter(node) {
|
|
||||||
if (
|
|
||||||
node.type === 'ExportDefaultDeclaration' &&
|
|
||||||
node.declaration.type === 'ObjectExpression'
|
|
||||||
) {
|
|
||||||
this.skip();
|
|
||||||
|
|
||||||
const props = node.declaration.properties.find((prop) => prop.key.name === 'props');
|
|
||||||
if (!props) return;
|
|
||||||
const { range } = props;
|
|
||||||
|
|
||||||
const [start, end] = range;
|
|
||||||
|
|
||||||
const code =
|
|
||||||
contents.slice(0, start) +
|
|
||||||
print(p`get ${props.key}() { return ${props.value}}`).code +
|
|
||||||
contents.slice(end);
|
|
||||||
|
|
||||||
writeFileSync(file, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
|||||||
|
export * from '../types/runtime/easing/index.js';
|
@ -0,0 +1,314 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Component = require('../internal/Component-9c4b98a2.js');
|
||||||
|
|
||||||
|
/*
|
||||||
|
Adapted from https://github.com/mattdesl
|
||||||
|
Distributed under MIT License https://github.com/mattdesl/eases/blob/master/LICENSE.md
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function backInOut(t) {
|
||||||
|
const s = 1.70158 * 1.525;
|
||||||
|
if ((t *= 2) < 1) return 0.5 * (t * t * ((s + 1) * t - s));
|
||||||
|
return 0.5 * ((t -= 2) * t * ((s + 1) * t + s) + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function backIn(t) {
|
||||||
|
const s = 1.70158;
|
||||||
|
return t * t * ((s + 1) * t - s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function backOut(t) {
|
||||||
|
const s = 1.70158;
|
||||||
|
return --t * t * ((s + 1) * t + s) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function bounceOut(t) {
|
||||||
|
const a = 4.0 / 11.0;
|
||||||
|
const b = 8.0 / 11.0;
|
||||||
|
const c = 9.0 / 10.0;
|
||||||
|
const ca = 4356.0 / 361.0;
|
||||||
|
const cb = 35442.0 / 1805.0;
|
||||||
|
const cc = 16061.0 / 1805.0;
|
||||||
|
const t2 = t * t;
|
||||||
|
return t < a
|
||||||
|
? 7.5625 * t2
|
||||||
|
: t < b
|
||||||
|
? 9.075 * t2 - 9.9 * t + 3.4
|
||||||
|
: t < c
|
||||||
|
? ca * t2 - cb * t + cc
|
||||||
|
: 10.8 * t * t - 20.52 * t + 10.72;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function bounceInOut(t) {
|
||||||
|
return t < 0.5 ? 0.5 * (1.0 - bounceOut(1.0 - t * 2.0)) : 0.5 * bounceOut(t * 2.0 - 1.0) + 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function bounceIn(t) {
|
||||||
|
return 1.0 - bounceOut(1.0 - t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function circInOut(t) {
|
||||||
|
if ((t *= 2) < 1) return -0.5 * (Math.sqrt(1 - t * t) - 1);
|
||||||
|
return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function circIn(t) {
|
||||||
|
return 1.0 - Math.sqrt(1.0 - t * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function circOut(t) {
|
||||||
|
return Math.sqrt(1 - --t * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function cubicInOut(t) {
|
||||||
|
return t < 0.5 ? 4.0 * t * t * t : 0.5 * Math.pow(2.0 * t - 2.0, 3.0) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function cubicIn(t) {
|
||||||
|
return t * t * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function cubicOut(t) {
|
||||||
|
const f = t - 1.0;
|
||||||
|
return f * f * f + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function elasticInOut(t) {
|
||||||
|
return t < 0.5
|
||||||
|
? 0.5 * Math.sin(((+13.0 * Math.PI) / 2) * 2.0 * t) * Math.pow(2.0, 10.0 * (2.0 * t - 1.0))
|
||||||
|
: 0.5 *
|
||||||
|
Math.sin(((-13.0 * Math.PI) / 2) * (2.0 * t - 1.0 + 1.0)) *
|
||||||
|
Math.pow(2.0, -10.0 * (2.0 * t - 1.0)) +
|
||||||
|
1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function elasticIn(t) {
|
||||||
|
return Math.sin((13.0 * t * Math.PI) / 2) * Math.pow(2.0, 10.0 * (t - 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function elasticOut(t) {
|
||||||
|
return Math.sin((-13.0 * (t + 1.0) * Math.PI) / 2) * Math.pow(2.0, -10.0 * t) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function expoInOut(t) {
|
||||||
|
return t === 0.0 || t === 1.0
|
||||||
|
? t
|
||||||
|
: t < 0.5
|
||||||
|
? +0.5 * Math.pow(2.0, 20.0 * t - 10.0)
|
||||||
|
: -0.5 * Math.pow(2.0, 10.0 - t * 20.0) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function expoIn(t) {
|
||||||
|
return t === 0.0 ? t : Math.pow(2.0, 10.0 * (t - 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function expoOut(t) {
|
||||||
|
return t === 1.0 ? t : 1.0 - Math.pow(2.0, -10.0 * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quadInOut(t) {
|
||||||
|
t /= 0.5;
|
||||||
|
if (t < 1) return 0.5 * t * t;
|
||||||
|
t--;
|
||||||
|
return -0.5 * (t * (t - 2) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quadIn(t) {
|
||||||
|
return t * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quadOut(t) {
|
||||||
|
return -t * (t - 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quartInOut(t) {
|
||||||
|
return t < 0.5 ? +8.0 * Math.pow(t, 4.0) : -8.0 * Math.pow(t - 1.0, 4.0) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quartIn(t) {
|
||||||
|
return Math.pow(t, 4.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quartOut(t) {
|
||||||
|
return Math.pow(t - 1.0, 3.0) * (1.0 - t) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quintInOut(t) {
|
||||||
|
if ((t *= 2) < 1) return 0.5 * t * t * t * t * t;
|
||||||
|
return 0.5 * ((t -= 2) * t * t * t * t + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quintIn(t) {
|
||||||
|
return t * t * t * t * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quintOut(t) {
|
||||||
|
return --t * t * t * t * t + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function sineInOut(t) {
|
||||||
|
return -0.5 * (Math.cos(Math.PI * t) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function sineIn(t) {
|
||||||
|
const v = Math.cos(t * Math.PI * 0.5);
|
||||||
|
if (Math.abs(v) < 1e-14) return 1;
|
||||||
|
else return 1 - v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function sineOut(t) {
|
||||||
|
return Math.sin((t * Math.PI) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.linear = Component.identity;
|
||||||
|
exports.backIn = backIn;
|
||||||
|
exports.backInOut = backInOut;
|
||||||
|
exports.backOut = backOut;
|
||||||
|
exports.bounceIn = bounceIn;
|
||||||
|
exports.bounceInOut = bounceInOut;
|
||||||
|
exports.bounceOut = bounceOut;
|
||||||
|
exports.circIn = circIn;
|
||||||
|
exports.circInOut = circInOut;
|
||||||
|
exports.circOut = circOut;
|
||||||
|
exports.cubicIn = cubicIn;
|
||||||
|
exports.cubicInOut = cubicInOut;
|
||||||
|
exports.cubicOut = cubicOut;
|
||||||
|
exports.elasticIn = elasticIn;
|
||||||
|
exports.elasticInOut = elasticInOut;
|
||||||
|
exports.elasticOut = elasticOut;
|
||||||
|
exports.expoIn = expoIn;
|
||||||
|
exports.expoInOut = expoInOut;
|
||||||
|
exports.expoOut = expoOut;
|
||||||
|
exports.quadIn = quadIn;
|
||||||
|
exports.quadInOut = quadInOut;
|
||||||
|
exports.quadOut = quadOut;
|
||||||
|
exports.quartIn = quartIn;
|
||||||
|
exports.quartInOut = quartInOut;
|
||||||
|
exports.quartOut = quartOut;
|
||||||
|
exports.quintIn = quintIn;
|
||||||
|
exports.quintInOut = quintInOut;
|
||||||
|
exports.quintOut = quintOut;
|
||||||
|
exports.sineIn = sineIn;
|
||||||
|
exports.sineInOut = sineInOut;
|
||||||
|
exports.sineOut = sineOut;
|
@ -0,0 +1,282 @@
|
|||||||
|
export { identity as linear } from '../internal/Component-cd97939e.mjs';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Adapted from https://github.com/mattdesl
|
||||||
|
Distributed under MIT License https://github.com/mattdesl/eases/blob/master/LICENSE.md
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function backInOut(t) {
|
||||||
|
const s = 1.70158 * 1.525;
|
||||||
|
if ((t *= 2) < 1) return 0.5 * (t * t * ((s + 1) * t - s));
|
||||||
|
return 0.5 * ((t -= 2) * t * ((s + 1) * t + s) + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function backIn(t) {
|
||||||
|
const s = 1.70158;
|
||||||
|
return t * t * ((s + 1) * t - s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function backOut(t) {
|
||||||
|
const s = 1.70158;
|
||||||
|
return --t * t * ((s + 1) * t + s) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function bounceOut(t) {
|
||||||
|
const a = 4.0 / 11.0;
|
||||||
|
const b = 8.0 / 11.0;
|
||||||
|
const c = 9.0 / 10.0;
|
||||||
|
const ca = 4356.0 / 361.0;
|
||||||
|
const cb = 35442.0 / 1805.0;
|
||||||
|
const cc = 16061.0 / 1805.0;
|
||||||
|
const t2 = t * t;
|
||||||
|
return t < a
|
||||||
|
? 7.5625 * t2
|
||||||
|
: t < b
|
||||||
|
? 9.075 * t2 - 9.9 * t + 3.4
|
||||||
|
: t < c
|
||||||
|
? ca * t2 - cb * t + cc
|
||||||
|
: 10.8 * t * t - 20.52 * t + 10.72;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function bounceInOut(t) {
|
||||||
|
return t < 0.5 ? 0.5 * (1.0 - bounceOut(1.0 - t * 2.0)) : 0.5 * bounceOut(t * 2.0 - 1.0) + 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function bounceIn(t) {
|
||||||
|
return 1.0 - bounceOut(1.0 - t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function circInOut(t) {
|
||||||
|
if ((t *= 2) < 1) return -0.5 * (Math.sqrt(1 - t * t) - 1);
|
||||||
|
return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function circIn(t) {
|
||||||
|
return 1.0 - Math.sqrt(1.0 - t * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function circOut(t) {
|
||||||
|
return Math.sqrt(1 - --t * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function cubicInOut(t) {
|
||||||
|
return t < 0.5 ? 4.0 * t * t * t : 0.5 * Math.pow(2.0 * t - 2.0, 3.0) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function cubicIn(t) {
|
||||||
|
return t * t * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function cubicOut(t) {
|
||||||
|
const f = t - 1.0;
|
||||||
|
return f * f * f + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function elasticInOut(t) {
|
||||||
|
return t < 0.5
|
||||||
|
? 0.5 * Math.sin(((+13.0 * Math.PI) / 2) * 2.0 * t) * Math.pow(2.0, 10.0 * (2.0 * t - 1.0))
|
||||||
|
: 0.5 *
|
||||||
|
Math.sin(((-13.0 * Math.PI) / 2) * (2.0 * t - 1.0 + 1.0)) *
|
||||||
|
Math.pow(2.0, -10.0 * (2.0 * t - 1.0)) +
|
||||||
|
1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function elasticIn(t) {
|
||||||
|
return Math.sin((13.0 * t * Math.PI) / 2) * Math.pow(2.0, 10.0 * (t - 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function elasticOut(t) {
|
||||||
|
return Math.sin((-13.0 * (t + 1.0) * Math.PI) / 2) * Math.pow(2.0, -10.0 * t) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function expoInOut(t) {
|
||||||
|
return t === 0.0 || t === 1.0
|
||||||
|
? t
|
||||||
|
: t < 0.5
|
||||||
|
? +0.5 * Math.pow(2.0, 20.0 * t - 10.0)
|
||||||
|
: -0.5 * Math.pow(2.0, 10.0 - t * 20.0) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function expoIn(t) {
|
||||||
|
return t === 0.0 ? t : Math.pow(2.0, 10.0 * (t - 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function expoOut(t) {
|
||||||
|
return t === 1.0 ? t : 1.0 - Math.pow(2.0, -10.0 * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quadInOut(t) {
|
||||||
|
t /= 0.5;
|
||||||
|
if (t < 1) return 0.5 * t * t;
|
||||||
|
t--;
|
||||||
|
return -0.5 * (t * (t - 2) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quadIn(t) {
|
||||||
|
return t * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quadOut(t) {
|
||||||
|
return -t * (t - 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quartInOut(t) {
|
||||||
|
return t < 0.5 ? +8.0 * Math.pow(t, 4.0) : -8.0 * Math.pow(t - 1.0, 4.0) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quartIn(t) {
|
||||||
|
return Math.pow(t, 4.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quartOut(t) {
|
||||||
|
return Math.pow(t - 1.0, 3.0) * (1.0 - t) + 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quintInOut(t) {
|
||||||
|
if ((t *= 2) < 1) return 0.5 * t * t * t * t * t;
|
||||||
|
return 0.5 * ((t -= 2) * t * t * t * t + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quintIn(t) {
|
||||||
|
return t * t * t * t * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function quintOut(t) {
|
||||||
|
return --t * t * t * t * t + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function sineInOut(t) {
|
||||||
|
return -0.5 * (Math.cos(Math.PI * t) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function sineIn(t) {
|
||||||
|
const v = Math.cos(t * Math.PI * 0.5);
|
||||||
|
if (Math.abs(v) < 1e-14) return 1;
|
||||||
|
else return 1 - v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} t
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
function sineOut(t) {
|
||||||
|
return Math.sin((t * Math.PI) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { backIn, backInOut, backOut, bounceIn, bounceInOut, bounceOut, circIn, circInOut, circOut, cubicIn, cubicInOut, cubicOut, elasticIn, elasticInOut, elasticOut, expoIn, expoInOut, expoOut, quadIn, quadInOut, quadOut, quartIn, quartInOut, quartOut, quintIn, quintInOut, quintOut, sineIn, sineInOut, sineOut };
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"main": "./index",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"types": "./index.d.ts"
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"types": "./index.d.ts"
|
|
||||||
}
|
|
@ -0,0 +1,19 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Component = require('./internal/Component-9c4b98a2.js');
|
||||||
|
var dev = require('./internal/dev-1537023e.js');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.afterUpdate = Component.afterUpdate;
|
||||||
|
exports.beforeUpdate = Component.beforeUpdate;
|
||||||
|
exports.createEventDispatcher = Component.createEventDispatcher;
|
||||||
|
exports.getAllContexts = Component.getAllContexts;
|
||||||
|
exports.getContext = Component.getContext;
|
||||||
|
exports.hasContext = Component.hasContext;
|
||||||
|
exports.onDestroy = Component.onDestroy;
|
||||||
|
exports.onMount = Component.onMount;
|
||||||
|
exports.setContext = Component.setContext;
|
||||||
|
exports.tick = Component.tick;
|
||||||
|
exports.SvelteComponent = dev.SvelteComponentDev;
|
||||||
|
exports.SvelteComponentTyped = dev.SvelteComponentTyped;
|
@ -0,0 +1,2 @@
|
|||||||
|
export { afterUpdate, beforeUpdate, createEventDispatcher, getAllContexts, getContext, hasContext, onDestroy, onMount, setContext, tick } from './internal/Component-cd97939e.mjs';
|
||||||
|
export { SvelteComponentDev as SvelteComponent, SvelteComponentTyped } from './internal/dev-89102382.mjs';
|
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
@ -0,0 +1,394 @@
|
|||||||
|
'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;
|
@ -0,0 +1,356 @@
|
|||||||
|
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 };
|
@ -0,0 +1,368 @@
|
|||||||
|
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 };
|
@ -0,0 +1,382 @@
|
|||||||
|
'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;
|
@ -0,0 +1 @@
|
|||||||
|
export * from '../types/runtime/internal/index.js';
|
@ -0,0 +1,813 @@
|
|||||||
|
'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;
|
@ -0,0 +1,601 @@
|
|||||||
|
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 };
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"main": "./index",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"types": "./index.d.ts"
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
export * from '../types/runtime/motion/index.js';
|
@ -0,0 +1,252 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var store = require('../store/index.js');
|
||||||
|
var Component = require('../internal/Component-9c4b98a2.js');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} obj
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
function is_date(obj) {
|
||||||
|
return Object.prototype.toString.call(obj) === '[object Date]';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param {import('./private.js').TickContext<T>} ctx
|
||||||
|
* @param {T} last_value
|
||||||
|
* @param {T} current_value
|
||||||
|
* @param {T} target_value
|
||||||
|
* @returns {T}
|
||||||
|
*/
|
||||||
|
function tick_spring(ctx, last_value, current_value, target_value) {
|
||||||
|
if (typeof current_value === 'number' || is_date(current_value)) {
|
||||||
|
// @ts-ignore
|
||||||
|
const delta = target_value - current_value;
|
||||||
|
// @ts-ignore
|
||||||
|
const velocity = (current_value - last_value) / (ctx.dt || 1 / 60); // guard div by 0
|
||||||
|
const spring = ctx.opts.stiffness * delta;
|
||||||
|
const damper = ctx.opts.damping * velocity;
|
||||||
|
const acceleration = (spring - damper) * ctx.inv_mass;
|
||||||
|
const d = (velocity + acceleration) * ctx.dt;
|
||||||
|
if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {
|
||||||
|
return target_value; // settled
|
||||||
|
} else {
|
||||||
|
ctx.settled = false; // signal loop to keep ticking
|
||||||
|
// @ts-ignore
|
||||||
|
return is_date(current_value) ? new Date(current_value.getTime() + d) : current_value + d;
|
||||||
|
}
|
||||||
|
} else if (Array.isArray(current_value)) {
|
||||||
|
// @ts-ignore
|
||||||
|
return current_value.map((_, i) =>
|
||||||
|
tick_spring(ctx, last_value[i], current_value[i], target_value[i])
|
||||||
|
);
|
||||||
|
} else if (typeof current_value === 'object') {
|
||||||
|
const next_value = {};
|
||||||
|
for (const k in current_value) {
|
||||||
|
// @ts-ignore
|
||||||
|
next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
return next_value;
|
||||||
|
} else {
|
||||||
|
throw new Error(`Cannot spring ${typeof current_value} values`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param {T} [value]
|
||||||
|
* @param {import('./private.js').SpringOpts} [opts]
|
||||||
|
* @returns {import('./public.js').Spring<T>}
|
||||||
|
*/
|
||||||
|
function spring(value, opts = {}) {
|
||||||
|
const store$1 = store.writable(value);
|
||||||
|
const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;
|
||||||
|
/** @type {number} */
|
||||||
|
let last_time;
|
||||||
|
/** @type {import('../internal/private.js').Task} */
|
||||||
|
let task;
|
||||||
|
/** @type {object} */
|
||||||
|
let current_token;
|
||||||
|
/** @type {T} */
|
||||||
|
let last_value = value;
|
||||||
|
/** @type {T} */
|
||||||
|
let target_value = value;
|
||||||
|
let inv_mass = 1;
|
||||||
|
let inv_mass_recovery_rate = 0;
|
||||||
|
let cancel_task = false;
|
||||||
|
/**
|
||||||
|
* @param {T} new_value
|
||||||
|
* @param {import('./private.js').SpringUpdateOpts} opts
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
function set(new_value, opts = {}) {
|
||||||
|
target_value = new_value;
|
||||||
|
const token = (current_token = {});
|
||||||
|
if (value == null || opts.hard || (spring.stiffness >= 1 && spring.damping >= 1)) {
|
||||||
|
cancel_task = true; // cancel any running animation
|
||||||
|
last_time = Component.now();
|
||||||
|
last_value = new_value;
|
||||||
|
store$1.set((value = target_value));
|
||||||
|
return Promise.resolve();
|
||||||
|
} else if (opts.soft) {
|
||||||
|
const rate = opts.soft === true ? 0.5 : +opts.soft;
|
||||||
|
inv_mass_recovery_rate = 1 / (rate * 60);
|
||||||
|
inv_mass = 0; // infinite mass, unaffected by spring forces
|
||||||
|
}
|
||||||
|
if (!task) {
|
||||||
|
last_time = Component.now();
|
||||||
|
cancel_task = false;
|
||||||
|
task = Component.loop((now) => {
|
||||||
|
if (cancel_task) {
|
||||||
|
cancel_task = false;
|
||||||
|
task = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);
|
||||||
|
const ctx = {
|
||||||
|
inv_mass,
|
||||||
|
opts: spring,
|
||||||
|
settled: true,
|
||||||
|
dt: ((now - last_time) * 60) / 1000
|
||||||
|
};
|
||||||
|
const next_value = tick_spring(ctx, last_value, value, target_value);
|
||||||
|
last_time = now;
|
||||||
|
last_value = value;
|
||||||
|
store$1.set((value = next_value));
|
||||||
|
if (ctx.settled) {
|
||||||
|
task = null;
|
||||||
|
}
|
||||||
|
return !ctx.settled;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return new Promise((fulfil) => {
|
||||||
|
task.promise.then(() => {
|
||||||
|
if (token === current_token) fulfil();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/** @type {import('./public.js').Spring<T>} */
|
||||||
|
const spring = {
|
||||||
|
set,
|
||||||
|
update: (fn, opts) => set(fn(target_value, value), opts),
|
||||||
|
subscribe: store$1.subscribe,
|
||||||
|
stiffness,
|
||||||
|
damping,
|
||||||
|
precision
|
||||||
|
};
|
||||||
|
return spring;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @returns {(t: any) => any} */
|
||||||
|
function get_interpolator(a, b) {
|
||||||
|
if (a === b || a !== a) return () => a;
|
||||||
|
const type = typeof a;
|
||||||
|
if (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) {
|
||||||
|
throw new Error('Cannot interpolate values of different type');
|
||||||
|
}
|
||||||
|
if (Array.isArray(a)) {
|
||||||
|
const arr = b.map((bi, i) => {
|
||||||
|
return get_interpolator(a[i], bi);
|
||||||
|
});
|
||||||
|
return (t) => arr.map((fn) => fn(t));
|
||||||
|
}
|
||||||
|
if (type === 'object') {
|
||||||
|
if (!a || !b) throw new Error('Object cannot be null');
|
||||||
|
if (is_date(a) && is_date(b)) {
|
||||||
|
a = a.getTime();
|
||||||
|
b = b.getTime();
|
||||||
|
const delta = b - a;
|
||||||
|
return (t) => new Date(a + t * delta);
|
||||||
|
}
|
||||||
|
const keys = Object.keys(b);
|
||||||
|
const interpolators = {};
|
||||||
|
keys.forEach((key) => {
|
||||||
|
interpolators[key] = get_interpolator(a[key], b[key]);
|
||||||
|
});
|
||||||
|
return (t) => {
|
||||||
|
const result = {};
|
||||||
|
keys.forEach((key) => {
|
||||||
|
result[key] = interpolators[key](t);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (type === 'number') {
|
||||||
|
const delta = b - a;
|
||||||
|
return (t) => a + t * delta;
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot interpolate ${type} values`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param {T} [value]
|
||||||
|
* @param {import('./private.js').TweenedOptions<T>} [defaults]
|
||||||
|
* @returns {import('./public.js').Tweened<T>}
|
||||||
|
*/
|
||||||
|
function tweened(value, defaults = {}) {
|
||||||
|
const store$1 = store.writable(value);
|
||||||
|
/** @type {import('../internal/private.js').Task} */
|
||||||
|
let task;
|
||||||
|
let target_value = value;
|
||||||
|
/**
|
||||||
|
* @param {T} new_value
|
||||||
|
* @param {import('./private.js').TweenedOptions<T>} opts
|
||||||
|
*/
|
||||||
|
function set(new_value, opts) {
|
||||||
|
if (value == null) {
|
||||||
|
store$1.set((value = new_value));
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
target_value = new_value;
|
||||||
|
let previous_task = task;
|
||||||
|
let started = false;
|
||||||
|
let {
|
||||||
|
delay = 0,
|
||||||
|
duration = 400,
|
||||||
|
easing = Component.identity,
|
||||||
|
interpolate = get_interpolator
|
||||||
|
} = Component.assign(Component.assign({}, defaults), opts);
|
||||||
|
if (duration === 0) {
|
||||||
|
if (previous_task) {
|
||||||
|
previous_task.abort();
|
||||||
|
previous_task = null;
|
||||||
|
}
|
||||||
|
store$1.set((value = target_value));
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
const start = Component.now() + delay;
|
||||||
|
let fn;
|
||||||
|
task = Component.loop((now) => {
|
||||||
|
if (now < start) return true;
|
||||||
|
if (!started) {
|
||||||
|
fn = interpolate(value, new_value);
|
||||||
|
if (typeof duration === 'function') duration = duration(value, new_value);
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
if (previous_task) {
|
||||||
|
previous_task.abort();
|
||||||
|
previous_task = null;
|
||||||
|
}
|
||||||
|
const elapsed = now - start;
|
||||||
|
if (elapsed > /** @type {number} */ (duration)) {
|
||||||
|
store$1.set((value = new_value));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
store$1.set((value = fn(easing(elapsed / duration))));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return task.promise;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
set,
|
||||||
|
update: (fn, opts) => set(fn(target_value, value), opts),
|
||||||
|
subscribe: store$1.subscribe
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.spring = spring;
|
||||||
|
exports.tweened = tweened;
|
@ -0,0 +1,249 @@
|
|||||||
|
import { writable } from '../store/index.mjs';
|
||||||
|
import { now, loop, assign, identity } from '../internal/Component-cd97939e.mjs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} obj
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
function is_date(obj) {
|
||||||
|
return Object.prototype.toString.call(obj) === '[object Date]';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param {import('./private.js').TickContext<T>} ctx
|
||||||
|
* @param {T} last_value
|
||||||
|
* @param {T} current_value
|
||||||
|
* @param {T} target_value
|
||||||
|
* @returns {T}
|
||||||
|
*/
|
||||||
|
function tick_spring(ctx, last_value, current_value, target_value) {
|
||||||
|
if (typeof current_value === 'number' || is_date(current_value)) {
|
||||||
|
// @ts-ignore
|
||||||
|
const delta = target_value - current_value;
|
||||||
|
// @ts-ignore
|
||||||
|
const velocity = (current_value - last_value) / (ctx.dt || 1 / 60); // guard div by 0
|
||||||
|
const spring = ctx.opts.stiffness * delta;
|
||||||
|
const damper = ctx.opts.damping * velocity;
|
||||||
|
const acceleration = (spring - damper) * ctx.inv_mass;
|
||||||
|
const d = (velocity + acceleration) * ctx.dt;
|
||||||
|
if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {
|
||||||
|
return target_value; // settled
|
||||||
|
} else {
|
||||||
|
ctx.settled = false; // signal loop to keep ticking
|
||||||
|
// @ts-ignore
|
||||||
|
return is_date(current_value) ? new Date(current_value.getTime() + d) : current_value + d;
|
||||||
|
}
|
||||||
|
} else if (Array.isArray(current_value)) {
|
||||||
|
// @ts-ignore
|
||||||
|
return current_value.map((_, i) =>
|
||||||
|
tick_spring(ctx, last_value[i], current_value[i], target_value[i])
|
||||||
|
);
|
||||||
|
} else if (typeof current_value === 'object') {
|
||||||
|
const next_value = {};
|
||||||
|
for (const k in current_value) {
|
||||||
|
// @ts-ignore
|
||||||
|
next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
return next_value;
|
||||||
|
} else {
|
||||||
|
throw new Error(`Cannot spring ${typeof current_value} values`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param {T} [value]
|
||||||
|
* @param {import('./private.js').SpringOpts} [opts]
|
||||||
|
* @returns {import('./public.js').Spring<T>}
|
||||||
|
*/
|
||||||
|
function spring(value, opts = {}) {
|
||||||
|
const store = writable(value);
|
||||||
|
const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;
|
||||||
|
/** @type {number} */
|
||||||
|
let last_time;
|
||||||
|
/** @type {import('../internal/private.js').Task} */
|
||||||
|
let task;
|
||||||
|
/** @type {object} */
|
||||||
|
let current_token;
|
||||||
|
/** @type {T} */
|
||||||
|
let last_value = value;
|
||||||
|
/** @type {T} */
|
||||||
|
let target_value = value;
|
||||||
|
let inv_mass = 1;
|
||||||
|
let inv_mass_recovery_rate = 0;
|
||||||
|
let cancel_task = false;
|
||||||
|
/**
|
||||||
|
* @param {T} new_value
|
||||||
|
* @param {import('./private.js').SpringUpdateOpts} opts
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
function set(new_value, opts = {}) {
|
||||||
|
target_value = new_value;
|
||||||
|
const token = (current_token = {});
|
||||||
|
if (value == null || opts.hard || (spring.stiffness >= 1 && spring.damping >= 1)) {
|
||||||
|
cancel_task = true; // cancel any running animation
|
||||||
|
last_time = now();
|
||||||
|
last_value = new_value;
|
||||||
|
store.set((value = target_value));
|
||||||
|
return Promise.resolve();
|
||||||
|
} else if (opts.soft) {
|
||||||
|
const rate = opts.soft === true ? 0.5 : +opts.soft;
|
||||||
|
inv_mass_recovery_rate = 1 / (rate * 60);
|
||||||
|
inv_mass = 0; // infinite mass, unaffected by spring forces
|
||||||
|
}
|
||||||
|
if (!task) {
|
||||||
|
last_time = now();
|
||||||
|
cancel_task = false;
|
||||||
|
task = loop((now) => {
|
||||||
|
if (cancel_task) {
|
||||||
|
cancel_task = false;
|
||||||
|
task = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);
|
||||||
|
const ctx = {
|
||||||
|
inv_mass,
|
||||||
|
opts: spring,
|
||||||
|
settled: true,
|
||||||
|
dt: ((now - last_time) * 60) / 1000
|
||||||
|
};
|
||||||
|
const next_value = tick_spring(ctx, last_value, value, target_value);
|
||||||
|
last_time = now;
|
||||||
|
last_value = value;
|
||||||
|
store.set((value = next_value));
|
||||||
|
if (ctx.settled) {
|
||||||
|
task = null;
|
||||||
|
}
|
||||||
|
return !ctx.settled;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return new Promise((fulfil) => {
|
||||||
|
task.promise.then(() => {
|
||||||
|
if (token === current_token) fulfil();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/** @type {import('./public.js').Spring<T>} */
|
||||||
|
const spring = {
|
||||||
|
set,
|
||||||
|
update: (fn, opts) => set(fn(target_value, value), opts),
|
||||||
|
subscribe: store.subscribe,
|
||||||
|
stiffness,
|
||||||
|
damping,
|
||||||
|
precision
|
||||||
|
};
|
||||||
|
return spring;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @returns {(t: any) => any} */
|
||||||
|
function get_interpolator(a, b) {
|
||||||
|
if (a === b || a !== a) return () => a;
|
||||||
|
const type = typeof a;
|
||||||
|
if (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) {
|
||||||
|
throw new Error('Cannot interpolate values of different type');
|
||||||
|
}
|
||||||
|
if (Array.isArray(a)) {
|
||||||
|
const arr = b.map((bi, i) => {
|
||||||
|
return get_interpolator(a[i], bi);
|
||||||
|
});
|
||||||
|
return (t) => arr.map((fn) => fn(t));
|
||||||
|
}
|
||||||
|
if (type === 'object') {
|
||||||
|
if (!a || !b) throw new Error('Object cannot be null');
|
||||||
|
if (is_date(a) && is_date(b)) {
|
||||||
|
a = a.getTime();
|
||||||
|
b = b.getTime();
|
||||||
|
const delta = b - a;
|
||||||
|
return (t) => new Date(a + t * delta);
|
||||||
|
}
|
||||||
|
const keys = Object.keys(b);
|
||||||
|
const interpolators = {};
|
||||||
|
keys.forEach((key) => {
|
||||||
|
interpolators[key] = get_interpolator(a[key], b[key]);
|
||||||
|
});
|
||||||
|
return (t) => {
|
||||||
|
const result = {};
|
||||||
|
keys.forEach((key) => {
|
||||||
|
result[key] = interpolators[key](t);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (type === 'number') {
|
||||||
|
const delta = b - a;
|
||||||
|
return (t) => a + t * delta;
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot interpolate ${type} values`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param {T} [value]
|
||||||
|
* @param {import('./private.js').TweenedOptions<T>} [defaults]
|
||||||
|
* @returns {import('./public.js').Tweened<T>}
|
||||||
|
*/
|
||||||
|
function tweened(value, defaults = {}) {
|
||||||
|
const store = writable(value);
|
||||||
|
/** @type {import('../internal/private.js').Task} */
|
||||||
|
let task;
|
||||||
|
let target_value = value;
|
||||||
|
/**
|
||||||
|
* @param {T} new_value
|
||||||
|
* @param {import('./private.js').TweenedOptions<T>} opts
|
||||||
|
*/
|
||||||
|
function set(new_value, opts) {
|
||||||
|
if (value == null) {
|
||||||
|
store.set((value = new_value));
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
target_value = new_value;
|
||||||
|
let previous_task = task;
|
||||||
|
let started = false;
|
||||||
|
let {
|
||||||
|
delay = 0,
|
||||||
|
duration = 400,
|
||||||
|
easing = identity,
|
||||||
|
interpolate = get_interpolator
|
||||||
|
} = assign(assign({}, defaults), opts);
|
||||||
|
if (duration === 0) {
|
||||||
|
if (previous_task) {
|
||||||
|
previous_task.abort();
|
||||||
|
previous_task = null;
|
||||||
|
}
|
||||||
|
store.set((value = target_value));
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
const start = now() + delay;
|
||||||
|
let fn;
|
||||||
|
task = loop((now) => {
|
||||||
|
if (now < start) return true;
|
||||||
|
if (!started) {
|
||||||
|
fn = interpolate(value, new_value);
|
||||||
|
if (typeof duration === 'function') duration = duration(value, new_value);
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
if (previous_task) {
|
||||||
|
previous_task.abort();
|
||||||
|
previous_task = null;
|
||||||
|
}
|
||||||
|
const elapsed = now - start;
|
||||||
|
if (elapsed > /** @type {number} */ (duration)) {
|
||||||
|
store.set((value = new_value));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
store.set((value = fn(easing(elapsed / duration))));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return task.promise;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
set,
|
||||||
|
update: (fn, opts) => set(fn(target_value, value), opts),
|
||||||
|
subscribe: store.subscribe
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export { spring, tweened };
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"main": "./index",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"types": "./index.d.ts"
|
||||||
|
}
|
@ -1,56 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const { compile } = require('./compiler.js');
|
|
||||||
|
|
||||||
const extensions = ['.svelte', '.html'];
|
|
||||||
let compileOptions = {};
|
|
||||||
|
|
||||||
function capitalise(name) {
|
|
||||||
return name[0].toUpperCase() + name.slice(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function register(options = {}) {
|
|
||||||
if (options.extensions) {
|
|
||||||
extensions.forEach(deregisterExtension);
|
|
||||||
options.extensions.forEach(registerExtension);
|
|
||||||
}
|
|
||||||
|
|
||||||
compileOptions = Object.assign({}, options);
|
|
||||||
delete compileOptions.extensions;
|
|
||||||
}
|
|
||||||
|
|
||||||
function deregisterExtension(extension) {
|
|
||||||
delete require.extensions[extension];
|
|
||||||
}
|
|
||||||
|
|
||||||
function registerExtension(extension) {
|
|
||||||
require.extensions[extension] = function(module, filename) {
|
|
||||||
const name = path.parse(filename).name
|
|
||||||
.replace(/^\d/, '_$&')
|
|
||||||
.replace(/[^a-zA-Z0-9_$]/g, '');
|
|
||||||
|
|
||||||
const options = Object.assign({}, compileOptions, {
|
|
||||||
filename,
|
|
||||||
name: capitalise(name),
|
|
||||||
generate: 'ssr',
|
|
||||||
format: 'cjs'
|
|
||||||
});
|
|
||||||
|
|
||||||
const { js, warnings } = compile(fs.readFileSync(filename, 'utf-8'), options);
|
|
||||||
|
|
||||||
if (options.dev) {
|
|
||||||
warnings.forEach(warning => {
|
|
||||||
console.warn(`\nSvelte Warning in ${warning.filename}:`);
|
|
||||||
console.warn(warning.message);
|
|
||||||
console.warn(warning.frame);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return module._compile(js.code, filename);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
registerExtension('.svelte');
|
|
||||||
registerExtension('.html');
|
|
||||||
|
|
||||||
module.exports = register;
|
|
@ -0,0 +1,82 @@
|
|||||||
|
import fs from 'node:fs';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
import replace from '@rollup/plugin-replace';
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
import json from '@rollup/plugin-json';
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
||||||
|
|
||||||
|
// Create auto-generated .js files
|
||||||
|
fs.writeFileSync(
|
||||||
|
'./src/shared/version.js',
|
||||||
|
`/** @type {string} */\nexport const VERSION = '${pkg.version}';`
|
||||||
|
);
|
||||||
|
|
||||||
|
const internal = await import('./src/runtime/internal/index.js');
|
||||||
|
fs.writeFileSync(
|
||||||
|
'src/compiler/compile/internal_exports.js',
|
||||||
|
`// This file is automatically generated\n` +
|
||||||
|
`export default new Set(${JSON.stringify(Object.keys(internal))});`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Generate d.ts files for runtime entrypoints so that TS can find it also without `"moduleResolution": "bundler"`
|
||||||
|
fs.readdirSync('src/runtime', { withFileTypes: true })
|
||||||
|
.filter((dirent) => dirent.isDirectory())
|
||||||
|
.forEach((dirent) =>
|
||||||
|
fs.writeFileSync(
|
||||||
|
`${dirent.name}.d.ts`,
|
||||||
|
`export * from './types/runtime/${dirent.name}/index.js';`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
fs.writeFileSync('./index.d.ts', `export * from './types/runtime/index.js';`);
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
'./compiler.d.ts',
|
||||||
|
`export { compile, parse, preprocess, walk, VERSION } from './types/compiler/index.js';`
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import("rollup").RollupOptions[]}
|
||||||
|
*/
|
||||||
|
export default [
|
||||||
|
// Generate UMD build of the compiler so that Eslint/Prettier (which need CJS) and REPL (which needs UMD because browser) can use it
|
||||||
|
{
|
||||||
|
input: 'src/compiler/index.js',
|
||||||
|
plugins: [
|
||||||
|
replace({
|
||||||
|
preventAssignment: true,
|
||||||
|
values: {
|
||||||
|
'process.env.NODE_DEBUG': false // appears inside the util package
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
resolveId(id) {
|
||||||
|
// util is a built-in module in Node.js, but we want a self-contained compiler bundle
|
||||||
|
// that also works in the browser, so we load its polyfill instead
|
||||||
|
if (id === 'util') {
|
||||||
|
return require.resolve('./node_modules/util'); // just 'utils' would resolve this to the built-in module
|
||||||
|
}
|
||||||
|
// Must import from the `css-tree` browser bundled distribution due to `createRequire` usage if importing from css-tree directly
|
||||||
|
if (id === 'css-tree') {
|
||||||
|
return require.resolve('./node_modules/css-tree/dist/csstree.esm.js');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
resolve(),
|
||||||
|
commonjs({
|
||||||
|
include: ['node_modules/**']
|
||||||
|
}),
|
||||||
|
json()
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
file: 'compiler.cjs',
|
||||||
|
format: 'umd',
|
||||||
|
name: 'svelte',
|
||||||
|
sourcemap: false
|
||||||
|
},
|
||||||
|
external: []
|
||||||
|
}
|
||||||
|
];
|
@ -1,150 +0,0 @@
|
|||||||
import fs from 'node:fs';
|
|
||||||
import { createRequire } from 'node:module';
|
|
||||||
import replace from '@rollup/plugin-replace';
|
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
|
||||||
import json from '@rollup/plugin-json';
|
|
||||||
import sucrase from '@rollup/plugin-sucrase';
|
|
||||||
import typescript from '@rollup/plugin-typescript';
|
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
||||||
|
|
||||||
const is_publish = !!process.env.PUBLISH;
|
|
||||||
|
|
||||||
const ts_plugin = is_publish
|
|
||||||
? typescript({
|
|
||||||
typescript: require('typescript'),
|
|
||||||
paths: {
|
|
||||||
'svelte/*': ['./src/runtime/*']
|
|
||||||
}
|
|
||||||
})
|
|
||||||
: sucrase({
|
|
||||||
transforms: ['typescript']
|
|
||||||
});
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
|
||||||
`./compiler.d.ts`,
|
|
||||||
`export { compile, parse, preprocess, walk, VERSION } from './types/compiler/index.js';`
|
|
||||||
);
|
|
||||||
|
|
||||||
const runtime_entrypoints = Object.fromEntries(
|
|
||||||
fs
|
|
||||||
.readdirSync('src/runtime', { withFileTypes: true })
|
|
||||||
.filter((dirent) => dirent.isDirectory())
|
|
||||||
.map((dirent) => [dirent.name, `src/runtime/${dirent.name}/index.js`])
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {import("rollup").RollupOptions[]}
|
|
||||||
*/
|
|
||||||
export default [
|
|
||||||
{
|
|
||||||
input: {
|
|
||||||
...runtime_entrypoints,
|
|
||||||
index: 'src/runtime/index.js',
|
|
||||||
ssr: 'src/runtime/ssr.js'
|
|
||||||
},
|
|
||||||
output: ['es', 'cjs'].map(
|
|
||||||
/** @returns {import('rollup').OutputOptions} */
|
|
||||||
(format) => {
|
|
||||||
const ext = format === 'es' ? 'mjs' : 'js';
|
|
||||||
return {
|
|
||||||
entryFileNames: (entry) => {
|
|
||||||
if (entry.isEntry) {
|
|
||||||
if (entry.name === 'index') return `index.${ext}`;
|
|
||||||
else if (entry.name === 'ssr') return `ssr.${ext}`;
|
|
||||||
|
|
||||||
return `${entry.name}/index.${ext}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
chunkFileNames: `internal/[name]-[hash].${ext}`,
|
|
||||||
format,
|
|
||||||
minifyInternalExports: false,
|
|
||||||
dir: '.',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
),
|
|
||||||
plugins: [
|
|
||||||
replace({
|
|
||||||
preventAssignment: true,
|
|
||||||
values: {
|
|
||||||
__VERSION__: pkg.version,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
ts_plugin,
|
|
||||||
{
|
|
||||||
writeBundle(options, bundle) {
|
|
||||||
if (options.format !== 'es') return;
|
|
||||||
|
|
||||||
for (const entry of Object.values(bundle)) {
|
|
||||||
const dir = entry.name;
|
|
||||||
if (!entry.isEntry || !runtime_entrypoints[dir]) continue;
|
|
||||||
|
|
||||||
if (dir === 'internal') {
|
|
||||||
const mod = bundle[`internal/index.mjs`];
|
|
||||||
if (mod) {
|
|
||||||
fs.writeFileSync(
|
|
||||||
'src/compiler/compile/internal_exports.js',
|
|
||||||
`// This file is automatically generated\n` +
|
|
||||||
`export default new Set(${JSON.stringify(mod.exports)});`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
|
||||||
`${dir}/index.d.ts`,
|
|
||||||
`export * from '../types/runtime/${dir}/index.js';`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
/* compiler.js */
|
|
||||||
{
|
|
||||||
input: 'src/compiler/index.js',
|
|
||||||
plugins: [
|
|
||||||
replace({
|
|
||||||
preventAssignment: true,
|
|
||||||
values: {
|
|
||||||
__VERSION__: pkg.version,
|
|
||||||
'process.env.NODE_DEBUG': false // appears inside the util package
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
resolveId(id) {
|
|
||||||
// util is a built-in module in Node.js, but we want a self-contained compiler bundle
|
|
||||||
// that also works in the browser, so we load its polyfill instead
|
|
||||||
if (id === 'util') {
|
|
||||||
return require.resolve('./node_modules/util'); // just 'utils' would resolve this to the built-in module
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
resolve(),
|
|
||||||
commonjs({
|
|
||||||
include: ['node_modules/**']
|
|
||||||
}),
|
|
||||||
json(),
|
|
||||||
ts_plugin
|
|
||||||
],
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: 'compiler.js',
|
|
||||||
format: is_publish ? 'umd' : 'cjs',
|
|
||||||
name: 'svelte',
|
|
||||||
sourcemap: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: 'compiler.mjs',
|
|
||||||
format: 'esm',
|
|
||||||
name: 'svelte',
|
|
||||||
sourcemap: true,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
external: is_publish
|
|
||||||
? []
|
|
||||||
: (id) =>
|
|
||||||
id === 'acorn' || id === 'magic-string' || id.startsWith('css-tree')
|
|
||||||
}
|
|
||||||
];
|
|
@ -1,2 +1,2 @@
|
|||||||
export type { CompileOptions, ModuleFormat, EnableSourcemap, CssHashGetter } from './interfaces';
|
export type { CompileOptions, EnableSourcemap, CssHashGetter } from './interfaces';
|
||||||
export type * from './preprocess/public.js';
|
export type * from './preprocess/public.js';
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Component = require('./internal/Component-9c4b98a2.js');
|
||||||
|
var dev = require('./internal/dev-1537023e.js');
|
||||||
|
|
||||||
|
/** @returns {void} */
|
||||||
|
function onMount() {}
|
||||||
|
|
||||||
|
/** @returns {void} */
|
||||||
|
function beforeUpdate() {}
|
||||||
|
|
||||||
|
/** @returns {void} */
|
||||||
|
function afterUpdate() {}
|
||||||
|
|
||||||
|
exports.createEventDispatcher = Component.createEventDispatcher;
|
||||||
|
exports.getAllContexts = Component.getAllContexts;
|
||||||
|
exports.getContext = Component.getContext;
|
||||||
|
exports.hasContext = Component.hasContext;
|
||||||
|
exports.onDestroy = Component.onDestroy;
|
||||||
|
exports.setContext = Component.setContext;
|
||||||
|
exports.tick = Component.tick;
|
||||||
|
exports.SvelteComponent = dev.SvelteComponentDev;
|
||||||
|
exports.SvelteComponentTyped = dev.SvelteComponentTyped;
|
||||||
|
exports.afterUpdate = afterUpdate;
|
||||||
|
exports.beforeUpdate = beforeUpdate;
|
||||||
|
exports.onMount = onMount;
|
@ -0,0 +1,13 @@
|
|||||||
|
export { createEventDispatcher, getAllContexts, getContext, hasContext, onDestroy, setContext, tick } from './internal/Component-cd97939e.mjs';
|
||||||
|
export { SvelteComponentDev as SvelteComponent, SvelteComponentTyped } from './internal/dev-89102382.mjs';
|
||||||
|
|
||||||
|
/** @returns {void} */
|
||||||
|
function onMount() {}
|
||||||
|
|
||||||
|
/** @returns {void} */
|
||||||
|
function beforeUpdate() {}
|
||||||
|
|
||||||
|
/** @returns {void} */
|
||||||
|
function afterUpdate() {}
|
||||||
|
|
||||||
|
export { afterUpdate, beforeUpdate, onMount };
|
@ -0,0 +1 @@
|
|||||||
|
export * from '../types/runtime/store/index.js';
|
@ -0,0 +1,189 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Component = require('../internal/Component-9c4b98a2.js');
|
||||||
|
|
||||||
|
const subscriber_queue = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a `Readable` store that allows reading by subscription.
|
||||||
|
* @template T
|
||||||
|
* @param {T} value initial value
|
||||||
|
* @param {import('./public.js').StartStopNotifier<T>} start
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
function readable(value, start) {
|
||||||
|
return {
|
||||||
|
subscribe: writable(value, start).subscribe
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a `Writable` store that allows both updating and reading by subscription.
|
||||||
|
* @template T
|
||||||
|
* @param {T} value initial value
|
||||||
|
* @param {import('./public.js').StartStopNotifier<T>} start
|
||||||
|
* @returns {import('./public.js').Writable<T>}
|
||||||
|
*/
|
||||||
|
function writable(value, start = Component.noop) {
|
||||||
|
/** @type {import('./public.js').Unsubscriber} */
|
||||||
|
let stop;
|
||||||
|
/** @type {Set<import('./private.js').SubscribeInvalidateTuple<T>>} */
|
||||||
|
const subscribers = new Set();
|
||||||
|
/** @param {T} new_value
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function set(new_value) {
|
||||||
|
if (Component.safe_not_equal(value, new_value)) {
|
||||||
|
value = new_value;
|
||||||
|
if (stop) {
|
||||||
|
// store is ready
|
||||||
|
const run_queue = !subscriber_queue.length;
|
||||||
|
for (const subscriber of subscribers) {
|
||||||
|
subscriber[1]();
|
||||||
|
subscriber_queue.push(subscriber, value);
|
||||||
|
}
|
||||||
|
if (run_queue) {
|
||||||
|
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
||||||
|
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
||||||
|
}
|
||||||
|
subscriber_queue.length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {import('./public.js').Updater<T>} fn
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function update(fn) {
|
||||||
|
set(fn(value));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {import('./public.js').Subscriber<T>} run
|
||||||
|
* @param {import('./private.js').Invalidator<T>} invalidate
|
||||||
|
* @returns {import('./public.js').Unsubscriber}
|
||||||
|
*/
|
||||||
|
function subscribe(run, invalidate = Component.noop) {
|
||||||
|
/** @type {import('./private.js').SubscribeInvalidateTuple<T>} */
|
||||||
|
const subscriber = [run, invalidate];
|
||||||
|
subscribers.add(subscriber);
|
||||||
|
if (subscribers.size === 1) {
|
||||||
|
stop = start(set, update) || Component.noop;
|
||||||
|
}
|
||||||
|
run(value);
|
||||||
|
return () => {
|
||||||
|
subscribers.delete(subscriber);
|
||||||
|
if (subscribers.size === 0 && stop) {
|
||||||
|
stop();
|
||||||
|
stop = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return { set, update, subscribe };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived value store by synchronizing one or more readable stores and
|
||||||
|
* applying an aggregation function over its input values.
|
||||||
|
*
|
||||||
|
* @template {import('./private.js').Stores} S
|
||||||
|
* @template T
|
||||||
|
* @overload
|
||||||
|
* @param {S} stores - input stores
|
||||||
|
* @param {(values: import('./public.js').StoresValues<S>, set: import('./public.js').Subscriber<T>, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values
|
||||||
|
* @param {T} [initial_value] - initial value
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived value store by synchronizing one or more readable stores and
|
||||||
|
* applying an aggregation function over its input values.
|
||||||
|
*
|
||||||
|
* @template {import('./private.js').Stores} S
|
||||||
|
* @template T
|
||||||
|
* @overload
|
||||||
|
* @param {S} stores - input stores
|
||||||
|
* @param {(values: import('./public.js').StoresValues<S>) => T} fn - function callback that aggregates the values
|
||||||
|
* @param {T} [initial_value] - initial value
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template {import('./private.js').Stores} S
|
||||||
|
* @template T
|
||||||
|
* @param {S} stores
|
||||||
|
* @param {Function} fn
|
||||||
|
* @param {T} [initial_value]
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
function derived(stores, fn, initial_value) {
|
||||||
|
const single = !Array.isArray(stores);
|
||||||
|
/** @type {Array<import('./public.js').Readable<any>>} */
|
||||||
|
const stores_array = single ? [stores] : stores;
|
||||||
|
if (!stores_array.every(Boolean)) {
|
||||||
|
throw new Error('derived() expects stores as input, got a falsy value');
|
||||||
|
}
|
||||||
|
const auto = fn.length < 2;
|
||||||
|
return readable(initial_value, (set, update) => {
|
||||||
|
let started = false;
|
||||||
|
const values = [];
|
||||||
|
let pending = 0;
|
||||||
|
let cleanup = Component.noop;
|
||||||
|
const sync = () => {
|
||||||
|
if (pending) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cleanup();
|
||||||
|
const result = fn(single ? values[0] : values, set, update);
|
||||||
|
if (auto) {
|
||||||
|
set(result);
|
||||||
|
} else {
|
||||||
|
cleanup = Component.is_function(result) ? result : Component.noop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const unsubscribers = stores_array.map((store, i) =>
|
||||||
|
Component.subscribe(
|
||||||
|
store,
|
||||||
|
(value) => {
|
||||||
|
values[i] = value;
|
||||||
|
pending &= ~(1 << i);
|
||||||
|
if (started) {
|
||||||
|
sync();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
pending |= 1 << i;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
started = true;
|
||||||
|
sync();
|
||||||
|
return function stop() {
|
||||||
|
Component.run_all(unsubscribers);
|
||||||
|
cleanup();
|
||||||
|
// We need to set this to false because callbacks can still happen despite having unsubscribed:
|
||||||
|
// Callbacks might already be placed in the queue which doesn't know it should no longer
|
||||||
|
// invoke this derived store.
|
||||||
|
started = false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a store and returns a new one derived from the old one that is readable.
|
||||||
|
*
|
||||||
|
* @template T
|
||||||
|
* @param {import('./public.js').Readable<T>} store - store to make readonly
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
function readonly(store) {
|
||||||
|
return {
|
||||||
|
subscribe: store.subscribe.bind(store)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.get = Component.get_store_value;
|
||||||
|
exports.derived = derived;
|
||||||
|
exports.readable = readable;
|
||||||
|
exports.readonly = readonly;
|
||||||
|
exports.writable = writable;
|
@ -0,0 +1,184 @@
|
|||||||
|
import { noop, subscribe, run_all, safe_not_equal, is_function } from '../internal/Component-cd97939e.mjs';
|
||||||
|
export { get_store_value as get } from '../internal/Component-cd97939e.mjs';
|
||||||
|
|
||||||
|
const subscriber_queue = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a `Readable` store that allows reading by subscription.
|
||||||
|
* @template T
|
||||||
|
* @param {T} value initial value
|
||||||
|
* @param {import('./public.js').StartStopNotifier<T>} start
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
function readable(value, start) {
|
||||||
|
return {
|
||||||
|
subscribe: writable(value, start).subscribe
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a `Writable` store that allows both updating and reading by subscription.
|
||||||
|
* @template T
|
||||||
|
* @param {T} value initial value
|
||||||
|
* @param {import('./public.js').StartStopNotifier<T>} start
|
||||||
|
* @returns {import('./public.js').Writable<T>}
|
||||||
|
*/
|
||||||
|
function writable(value, start = noop) {
|
||||||
|
/** @type {import('./public.js').Unsubscriber} */
|
||||||
|
let stop;
|
||||||
|
/** @type {Set<import('./private.js').SubscribeInvalidateTuple<T>>} */
|
||||||
|
const subscribers = new Set();
|
||||||
|
/** @param {T} new_value
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function set(new_value) {
|
||||||
|
if (safe_not_equal(value, new_value)) {
|
||||||
|
value = new_value;
|
||||||
|
if (stop) {
|
||||||
|
// store is ready
|
||||||
|
const run_queue = !subscriber_queue.length;
|
||||||
|
for (const subscriber of subscribers) {
|
||||||
|
subscriber[1]();
|
||||||
|
subscriber_queue.push(subscriber, value);
|
||||||
|
}
|
||||||
|
if (run_queue) {
|
||||||
|
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
||||||
|
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
||||||
|
}
|
||||||
|
subscriber_queue.length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {import('./public.js').Updater<T>} fn
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function update(fn) {
|
||||||
|
set(fn(value));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {import('./public.js').Subscriber<T>} run
|
||||||
|
* @param {import('./private.js').Invalidator<T>} invalidate
|
||||||
|
* @returns {import('./public.js').Unsubscriber}
|
||||||
|
*/
|
||||||
|
function subscribe(run, invalidate = noop) {
|
||||||
|
/** @type {import('./private.js').SubscribeInvalidateTuple<T>} */
|
||||||
|
const subscriber = [run, invalidate];
|
||||||
|
subscribers.add(subscriber);
|
||||||
|
if (subscribers.size === 1) {
|
||||||
|
stop = start(set, update) || noop;
|
||||||
|
}
|
||||||
|
run(value);
|
||||||
|
return () => {
|
||||||
|
subscribers.delete(subscriber);
|
||||||
|
if (subscribers.size === 0 && stop) {
|
||||||
|
stop();
|
||||||
|
stop = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return { set, update, subscribe };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived value store by synchronizing one or more readable stores and
|
||||||
|
* applying an aggregation function over its input values.
|
||||||
|
*
|
||||||
|
* @template {import('./private.js').Stores} S
|
||||||
|
* @template T
|
||||||
|
* @overload
|
||||||
|
* @param {S} stores - input stores
|
||||||
|
* @param {(values: import('./public.js').StoresValues<S>, set: import('./public.js').Subscriber<T>, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values
|
||||||
|
* @param {T} [initial_value] - initial value
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived value store by synchronizing one or more readable stores and
|
||||||
|
* applying an aggregation function over its input values.
|
||||||
|
*
|
||||||
|
* @template {import('./private.js').Stores} S
|
||||||
|
* @template T
|
||||||
|
* @overload
|
||||||
|
* @param {S} stores - input stores
|
||||||
|
* @param {(values: import('./public.js').StoresValues<S>) => T} fn - function callback that aggregates the values
|
||||||
|
* @param {T} [initial_value] - initial value
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template {import('./private.js').Stores} S
|
||||||
|
* @template T
|
||||||
|
* @param {S} stores
|
||||||
|
* @param {Function} fn
|
||||||
|
* @param {T} [initial_value]
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
function derived(stores, fn, initial_value) {
|
||||||
|
const single = !Array.isArray(stores);
|
||||||
|
/** @type {Array<import('./public.js').Readable<any>>} */
|
||||||
|
const stores_array = single ? [stores] : stores;
|
||||||
|
if (!stores_array.every(Boolean)) {
|
||||||
|
throw new Error('derived() expects stores as input, got a falsy value');
|
||||||
|
}
|
||||||
|
const auto = fn.length < 2;
|
||||||
|
return readable(initial_value, (set, update) => {
|
||||||
|
let started = false;
|
||||||
|
const values = [];
|
||||||
|
let pending = 0;
|
||||||
|
let cleanup = noop;
|
||||||
|
const sync = () => {
|
||||||
|
if (pending) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cleanup();
|
||||||
|
const result = fn(single ? values[0] : values, set, update);
|
||||||
|
if (auto) {
|
||||||
|
set(result);
|
||||||
|
} else {
|
||||||
|
cleanup = is_function(result) ? result : noop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const unsubscribers = stores_array.map((store, i) =>
|
||||||
|
subscribe(
|
||||||
|
store,
|
||||||
|
(value) => {
|
||||||
|
values[i] = value;
|
||||||
|
pending &= ~(1 << i);
|
||||||
|
if (started) {
|
||||||
|
sync();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
pending |= 1 << i;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
started = true;
|
||||||
|
sync();
|
||||||
|
return function stop() {
|
||||||
|
run_all(unsubscribers);
|
||||||
|
cleanup();
|
||||||
|
// We need to set this to false because callbacks can still happen despite having unsubscribed:
|
||||||
|
// Callbacks might already be placed in the queue which doesn't know it should no longer
|
||||||
|
// invoke this derived store.
|
||||||
|
started = false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a store and returns a new one derived from the old one that is readable.
|
||||||
|
*
|
||||||
|
* @template T
|
||||||
|
* @param {import('./public.js').Readable<T>} store - store to make readonly
|
||||||
|
* @returns {import('./public.js').Readable<T>}
|
||||||
|
*/
|
||||||
|
function readonly(store) {
|
||||||
|
return {
|
||||||
|
subscribe: store.subscribe.bind(store)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export { derived, readable, readonly, writable };
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"main": "./index",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"types": "./index.d.ts"
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
import * as fs from 'node:fs';
|
||||||
|
import * as path from 'node:path';
|
||||||
|
import { assert, describe, expect, it } from 'vitest';
|
||||||
|
import { compile } from 'svelte/compiler';
|
||||||
|
|
||||||
|
const configs = import.meta.glob('./samples/*/_config.js', { import: 'default', eager: true });
|
||||||
|
|
||||||
|
describe('compiler-errors', () => {
|
||||||
|
function run_test(dir) {
|
||||||
|
if (dir[0] === '.') return;
|
||||||
|
|
||||||
|
const config = configs[`./samples/${dir}/_config.js`];
|
||||||
|
|
||||||
|
assert.ok(config, `Missing config for ${dir}`);
|
||||||
|
|
||||||
|
const solo = config.solo || /\.solo/.test(dir);
|
||||||
|
|
||||||
|
const it_fn = config.skip ? it.skip : solo ? it.only : it;
|
||||||
|
|
||||||
|
it_fn(dir, () => {
|
||||||
|
const cwd = path.resolve(`${__dirname}/samples/${dir}`);
|
||||||
|
|
||||||
|
const compileOptions = Object.assign({}, config.compileOptions || {}, {
|
||||||
|
immutable: config.immutable,
|
||||||
|
accessors: 'accessors' in config ? config.accessors : true,
|
||||||
|
generate: 'dom'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
compile(fs.readFileSync(`${cwd}/main.svelte`, 'utf-8'), compileOptions);
|
||||||
|
} catch (error) {
|
||||||
|
if (typeof config.error === 'function') {
|
||||||
|
config.error(assert, error);
|
||||||
|
} else {
|
||||||
|
expect(error.message).toMatch(config.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.fail('Expected an error');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const samples = fs.readdirSync(`${__dirname}/samples`);
|
||||||
|
samples.forEach((sample) => run_test(sample));
|
||||||
|
});
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import Nested from './Nested.svelte';
|
import Nested from './irrelevant';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Nested>
|
<Nested>
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import Nested from './Nested.svelte';
|
import Nested from './irrelevant';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Nested>
|
<Nested>
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import Nested from './Nested.svelte';
|
import Nested from './irrelevant';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Nested>
|
<Nested>
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import Nested from './Nested.svelte';
|
import Nested from './irrelevant';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Nested>
|
<Nested>
|
@ -1,5 +1,4 @@
|
|||||||
export default {
|
export default {
|
||||||
error: [
|
error:
|
||||||
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
|
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
|
||||||
]
|
|
||||||
};
|
};
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import Nested from "./Nested.svelte";
|
import Nested from './irrelevant';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Nested>
|
<Nested>
|
@ -1,5 +1,4 @@
|
|||||||
export default {
|
export default {
|
||||||
error: [
|
error:
|
||||||
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
|
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
|
||||||
]
|
|
||||||
};
|
};
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import Nested from "./Nested.svelte";
|
import Nested from './irrelevant';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Nested>
|
<Nested>
|
@ -1,5 +1,4 @@
|
|||||||
export default {
|
export default {
|
||||||
error: [
|
error:
|
||||||
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
|
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
|
||||||
]
|
|
||||||
};
|
};
|
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import Nested from "./Nested.svelte";
|
import Nested from './irrelevant';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Nested>
|
<Nested>
|
@ -1,5 +1,5 @@
|
|||||||
<script context="module">
|
<script context="module">
|
||||||
import foo from './foo.js';
|
const foo = {};
|
||||||
const answer = $foo;
|
const answer = $foo;
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -1,6 +0,0 @@
|
|||||||
export default {
|
|
||||||
options: {
|
|
||||||
accessors: true,
|
|
||||||
format: 'cjs'
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,36 +0,0 @@
|
|||||||
/* generated by Svelte vX.Y.Z */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const { SvelteComponent, init, safe_not_equal } = require("svelte/internal");
|
|
||||||
const { f: f_1, g: g_1 } = require("./d");
|
|
||||||
const { h: h_1 } = require("./e");
|
|
||||||
const { i: j } = require("./f");
|
|
||||||
exports.e = require("./c").d;
|
|
||||||
exports.c = require("./b").c;
|
|
||||||
exports.a = require("./a").a;
|
|
||||||
exports.b = require("./a").b;
|
|
||||||
|
|
||||||
class Component extends SvelteComponent {
|
|
||||||
constructor(options) {
|
|
||||||
super();
|
|
||||||
init(this, options, null, null, safe_not_equal, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
get f() {
|
|
||||||
return f_1;
|
|
||||||
}
|
|
||||||
|
|
||||||
get g() {
|
|
||||||
return g_1;
|
|
||||||
}
|
|
||||||
|
|
||||||
get h() {
|
|
||||||
return h_1;
|
|
||||||
}
|
|
||||||
|
|
||||||
get j() {
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.default = Component;
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue