BOC v1.0: RS256 auth, Ledger integration, Prometheus metrics, CI/CD, backup
This commit is contained in:
+345
@@ -0,0 +1,345 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function addUniqueItem(arr, item) {
|
||||
if (arr.indexOf(item) === -1)
|
||||
arr.push(item);
|
||||
}
|
||||
function removeItem(arr, item) {
|
||||
const index = arr.indexOf(item);
|
||||
if (index > -1)
|
||||
arr.splice(index, 1);
|
||||
}
|
||||
// Adapted from array-move
|
||||
function moveItem([...arr], fromIndex, toIndex) {
|
||||
const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
|
||||
if (startIndex >= 0 && startIndex < arr.length) {
|
||||
const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
|
||||
const [item] = arr.splice(fromIndex, 1);
|
||||
arr.splice(endIndex, 0, item);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const clamp = (min, max, v) => {
|
||||
if (v > max)
|
||||
return max;
|
||||
if (v < min)
|
||||
return min;
|
||||
return v;
|
||||
};
|
||||
|
||||
function formatErrorMessage(message, errorCode) {
|
||||
return errorCode
|
||||
? `${message}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${errorCode}`
|
||||
: message;
|
||||
}
|
||||
|
||||
exports.warning = () => { };
|
||||
exports.invariant = () => { };
|
||||
if (typeof process !== "undefined" &&
|
||||
process.env?.NODE_ENV !== "production") {
|
||||
exports.warning = (check, message, errorCode) => {
|
||||
if (!check && typeof console !== "undefined") {
|
||||
console.warn(formatErrorMessage(message, errorCode));
|
||||
}
|
||||
};
|
||||
exports.invariant = (check, message, errorCode) => {
|
||||
if (!check) {
|
||||
throw new Error(formatErrorMessage(message, errorCode));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const MotionGlobalConfig = {};
|
||||
|
||||
/**
|
||||
* Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
|
||||
*/
|
||||
const isNumericalString = (v) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(v);
|
||||
|
||||
const isObject = (value) => typeof value === "object" && value !== null;
|
||||
|
||||
/**
|
||||
* Check if the value is a zero value string like "0px" or "0%"
|
||||
*/
|
||||
const isZeroValueString = (v) => /^0[^.\s]+$/u.test(v);
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function memo(callback) {
|
||||
let result;
|
||||
return () => {
|
||||
if (result === undefined)
|
||||
result = callback();
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const noop = (any) => any;
|
||||
|
||||
/**
|
||||
* Pipe
|
||||
* Compose other transformers to run linearily
|
||||
* pipe(min(20), max(40))
|
||||
* @param {...functions} transformers
|
||||
* @return {function}
|
||||
*/
|
||||
const pipe = (...transformers) => transformers.reduce((a, b) => (v) => b(a(v)));
|
||||
|
||||
/*
|
||||
Progress within given range
|
||||
|
||||
Given a lower limit and an upper limit, we return the progress
|
||||
(expressed as a number 0-1) represented by the given value, and
|
||||
limit that progress to within 0-1.
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const progress = (from, to, value) => {
|
||||
const range = to - from;
|
||||
return range ? (value - from) / range : 1;
|
||||
};
|
||||
|
||||
class SubscriptionManager {
|
||||
constructor() {
|
||||
this.subscriptions = [];
|
||||
}
|
||||
add(handler) {
|
||||
addUniqueItem(this.subscriptions, handler);
|
||||
return () => removeItem(this.subscriptions, handler);
|
||||
}
|
||||
notify(a, b, c) {
|
||||
const numSubscriptions = this.subscriptions.length;
|
||||
if (!numSubscriptions)
|
||||
return;
|
||||
if (numSubscriptions === 1) {
|
||||
/**
|
||||
* If there's only a single handler we can just call it without invoking a loop.
|
||||
*/
|
||||
this.subscriptions[0](a, b, c);
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < numSubscriptions; i++) {
|
||||
/**
|
||||
* Check whether the handler exists before firing as it's possible
|
||||
* the subscriptions were modified during this loop running.
|
||||
*/
|
||||
const handler = this.subscriptions[i];
|
||||
handler && handler(a, b, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
getSize() {
|
||||
return this.subscriptions.length;
|
||||
}
|
||||
clear() {
|
||||
this.subscriptions.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts seconds to milliseconds
|
||||
*
|
||||
* @param seconds - Time in seconds.
|
||||
* @return milliseconds - Converted time in milliseconds.
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const secondsToMilliseconds = (seconds) => seconds * 1000;
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const millisecondsToSeconds = (milliseconds) => milliseconds / 1000;
|
||||
|
||||
/*
|
||||
Convert velocity into velocity per second
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const velocityPerSecond = (velocity, frameDuration) => frameDuration ? velocity * (1000 / frameDuration) : 0;
|
||||
|
||||
const warned = new Set();
|
||||
function hasWarned(message) {
|
||||
return warned.has(message);
|
||||
}
|
||||
function warnOnce(condition, message, errorCode) {
|
||||
if (condition || warned.has(message))
|
||||
return;
|
||||
console.warn(formatErrorMessage(message, errorCode));
|
||||
warned.add(message);
|
||||
}
|
||||
|
||||
const wrap = (min, max, v) => {
|
||||
const rangeSize = max - min;
|
||||
return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
|
||||
};
|
||||
|
||||
/*
|
||||
Bezier function generator
|
||||
This has been modified from Gaëtan Renaudeau's BezierEasing
|
||||
https://github.com/gre/bezier-easing/blob/master/src/index.js
|
||||
https://github.com/gre/bezier-easing/blob/master/LICENSE
|
||||
|
||||
I've removed the newtonRaphsonIterate algo because in benchmarking it
|
||||
wasn't noticeably faster than binarySubdivision, indeed removing it
|
||||
usually improved times, depending on the curve.
|
||||
I also removed the lookup table, as for the added bundle size and loop we're
|
||||
only cutting ~4 or so subdivision iterations. I bumped the max iterations up
|
||||
to 12 to compensate and this still tended to be faster for no perceivable
|
||||
loss in accuracy.
|
||||
Usage
|
||||
const easeOut = cubicBezier(.17,.67,.83,.67);
|
||||
const x = easeOut(0.5); // returns 0.627...
|
||||
*/
|
||||
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
|
||||
const calcBezier = (t, a1, a2) => (((1.0 - 3.0 * a2 + 3.0 * a1) * t + (3.0 * a2 - 6.0 * a1)) * t + 3.0 * a1) *
|
||||
t;
|
||||
const subdivisionPrecision = 0.0000001;
|
||||
const subdivisionMaxIterations = 12;
|
||||
function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
|
||||
let currentX;
|
||||
let currentT;
|
||||
let i = 0;
|
||||
do {
|
||||
currentT = lowerBound + (upperBound - lowerBound) / 2.0;
|
||||
currentX = calcBezier(currentT, mX1, mX2) - x;
|
||||
if (currentX > 0.0) {
|
||||
upperBound = currentT;
|
||||
}
|
||||
else {
|
||||
lowerBound = currentT;
|
||||
}
|
||||
} while (Math.abs(currentX) > subdivisionPrecision &&
|
||||
++i < subdivisionMaxIterations);
|
||||
return currentT;
|
||||
}
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function cubicBezier(mX1, mY1, mX2, mY2) {
|
||||
// If this is a linear gradient, return linear easing
|
||||
if (mX1 === mY1 && mX2 === mY2)
|
||||
return noop;
|
||||
const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
|
||||
// If animation is at start/end, return t without easing
|
||||
return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
|
||||
}
|
||||
|
||||
// Accepts an easing function and returns a new one that outputs mirrored values for
|
||||
// the second half of the animation. Turns easeIn into easeInOut.
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const mirrorEasing = (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
|
||||
|
||||
// Accepts an easing function and returns a new one that outputs reversed values.
|
||||
// Turns easeIn into easeOut.
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const reverseEasing = (easing) => (p) => 1 - easing(1 - p);
|
||||
|
||||
const backOut = /*@__PURE__*/ cubicBezier(0.33, 1.53, 0.69, 0.99);
|
||||
const backIn = /*@__PURE__*/ reverseEasing(backOut);
|
||||
const backInOut = /*@__PURE__*/ mirrorEasing(backIn);
|
||||
|
||||
const anticipate = (p) => p >= 1
|
||||
? 1
|
||||
: (p *= 2) < 1
|
||||
? 0.5 * backIn(p)
|
||||
: 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
|
||||
|
||||
const circIn = (p) => 1 - Math.sin(Math.acos(p));
|
||||
const circOut = reverseEasing(circIn);
|
||||
const circInOut = mirrorEasing(circIn);
|
||||
|
||||
const easeIn = /*@__PURE__*/ cubicBezier(0.42, 0, 1, 1);
|
||||
const easeOut = /*@__PURE__*/ cubicBezier(0, 0, 0.58, 1);
|
||||
const easeInOut = /*@__PURE__*/ cubicBezier(0.42, 0, 0.58, 1);
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function steps(numSteps, direction = "end") {
|
||||
return (progress) => {
|
||||
progress =
|
||||
direction === "end"
|
||||
? Math.min(progress, 0.999)
|
||||
: Math.max(progress, 0.001);
|
||||
const expanded = progress * numSteps;
|
||||
const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
|
||||
return clamp(0, 1, rounded / numSteps);
|
||||
};
|
||||
}
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const isEasingArray = (ease) => {
|
||||
return Array.isArray(ease) && typeof ease[0] !== "number";
|
||||
};
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function getEasingForSegment(easing, i) {
|
||||
return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
|
||||
}
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
|
||||
|
||||
const easingLookup = {
|
||||
linear: noop,
|
||||
easeIn,
|
||||
easeInOut,
|
||||
easeOut,
|
||||
circIn,
|
||||
circInOut,
|
||||
circOut,
|
||||
backIn,
|
||||
backInOut,
|
||||
backOut,
|
||||
anticipate,
|
||||
};
|
||||
const isValidEasing = (easing) => {
|
||||
return typeof easing === "string";
|
||||
};
|
||||
const easingDefinitionToFunction = (definition) => {
|
||||
if (isBezierDefinition(definition)) {
|
||||
// If cubic bezier definition, create bezier curve
|
||||
exports.invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`, "cubic-bezier-length");
|
||||
const [x1, y1, x2, y2] = definition;
|
||||
return cubicBezier(x1, y1, x2, y2);
|
||||
}
|
||||
else if (isValidEasing(definition)) {
|
||||
// Else lookup from table
|
||||
exports.invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`, "invalid-easing-type");
|
||||
return easingLookup[definition];
|
||||
}
|
||||
return definition;
|
||||
};
|
||||
|
||||
exports.MotionGlobalConfig = MotionGlobalConfig;
|
||||
exports.SubscriptionManager = SubscriptionManager;
|
||||
exports.addUniqueItem = addUniqueItem;
|
||||
exports.anticipate = anticipate;
|
||||
exports.backIn = backIn;
|
||||
exports.backInOut = backInOut;
|
||||
exports.backOut = backOut;
|
||||
exports.circIn = circIn;
|
||||
exports.circInOut = circInOut;
|
||||
exports.circOut = circOut;
|
||||
exports.clamp = clamp;
|
||||
exports.cubicBezier = cubicBezier;
|
||||
exports.easeIn = easeIn;
|
||||
exports.easeInOut = easeInOut;
|
||||
exports.easeOut = easeOut;
|
||||
exports.easingDefinitionToFunction = easingDefinitionToFunction;
|
||||
exports.getEasingForSegment = getEasingForSegment;
|
||||
exports.hasWarned = hasWarned;
|
||||
exports.isBezierDefinition = isBezierDefinition;
|
||||
exports.isEasingArray = isEasingArray;
|
||||
exports.isNumericalString = isNumericalString;
|
||||
exports.isObject = isObject;
|
||||
exports.isZeroValueString = isZeroValueString;
|
||||
exports.memo = memo;
|
||||
exports.millisecondsToSeconds = millisecondsToSeconds;
|
||||
exports.mirrorEasing = mirrorEasing;
|
||||
exports.moveItem = moveItem;
|
||||
exports.noop = noop;
|
||||
exports.pipe = pipe;
|
||||
exports.progress = progress;
|
||||
exports.removeItem = removeItem;
|
||||
exports.reverseEasing = reverseEasing;
|
||||
exports.secondsToMilliseconds = secondsToMilliseconds;
|
||||
exports.steps = steps;
|
||||
exports.velocityPerSecond = velocityPerSecond;
|
||||
exports.warnOnce = warnOnce;
|
||||
exports.wrap = wrap;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+22
@@ -0,0 +1,22 @@
|
||||
function addUniqueItem(arr, item) {
|
||||
if (arr.indexOf(item) === -1)
|
||||
arr.push(item);
|
||||
}
|
||||
function removeItem(arr, item) {
|
||||
const index = arr.indexOf(item);
|
||||
if (index > -1)
|
||||
arr.splice(index, 1);
|
||||
}
|
||||
// Adapted from array-move
|
||||
function moveItem([...arr], fromIndex, toIndex) {
|
||||
const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
|
||||
if (startIndex >= 0 && startIndex < arr.length) {
|
||||
const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
|
||||
const [item] = arr.splice(fromIndex, 1);
|
||||
arr.splice(endIndex, 0, item);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
export { addUniqueItem, moveItem, removeItem };
|
||||
//# sourceMappingURL=array.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"array.mjs","sources":["../../src/array.ts"],"sourcesContent":["export function addUniqueItem<T>(arr: T[], item: T) {\n if (arr.indexOf(item) === -1) arr.push(item)\n}\n\nexport function removeItem<T>(arr: T[], item: T) {\n const index = arr.indexOf(item)\n if (index > -1) arr.splice(index, 1)\n}\n\n// Adapted from array-move\nexport function moveItem<T>([...arr]: T[], fromIndex: number, toIndex: number) {\n const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex\n\n if (startIndex >= 0 && startIndex < arr.length) {\n const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex\n\n const [item] = arr.splice(fromIndex, 1)\n arr.splice(endIndex, 0, item)\n }\n\n return arr\n}\n"],"names":[],"mappings":"AAAM,SAAU,aAAa,CAAI,GAAQ,EAAE,IAAO,EAAA;IAC9C,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE;AAAE,QAAA,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;AAChD;AAEM,SAAU,UAAU,CAAI,GAAQ,EAAE,IAAO,EAAA;IAC3C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;IAC/B,IAAI,KAAK,GAAG,EAAE;AAAE,QAAA,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AACxC;AAEA;AACM,SAAU,QAAQ,CAAI,CAAC,GAAG,GAAG,CAAM,EAAE,SAAiB,EAAE,OAAe,EAAA;AACzE,IAAA,MAAM,UAAU,GAAG,SAAS,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS;IAErE,IAAI,UAAU,IAAI,CAAC,IAAI,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE;AAC5C,QAAA,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,OAAO,GAAG,OAAO;AAE7D,QAAA,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QACvC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC;IACjC;AAEA,IAAA,OAAO,GAAG;AACd;;;;"}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
const clamp = (min, max, v) => {
|
||||
if (v > max)
|
||||
return max;
|
||||
if (v < min)
|
||||
return min;
|
||||
return v;
|
||||
};
|
||||
|
||||
export { clamp };
|
||||
//# sourceMappingURL=clamp.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"clamp.mjs","sources":["../../src/clamp.ts"],"sourcesContent":["export const clamp = (min: number, max: number, v: number) => {\n if (v > max) return max\n if (v < min) return min\n return v\n}\n"],"names":[],"mappings":"AAAO,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,CAAS,KAAI;IACzD,IAAI,CAAC,GAAG,GAAG;AAAE,QAAA,OAAO,GAAG;IACvB,IAAI,CAAC,GAAG,GAAG;AAAE,QAAA,OAAO,GAAG;AACvB,IAAA,OAAO,CAAC;AACZ;;;;"}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { backIn } from './back.mjs';
|
||||
|
||||
const anticipate = (p) => p >= 1
|
||||
? 1
|
||||
: (p *= 2) < 1
|
||||
? 0.5 * backIn(p)
|
||||
: 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
|
||||
|
||||
export { anticipate };
|
||||
//# sourceMappingURL=anticipate.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"anticipate.mjs","sources":["../../../src/easing/anticipate.ts"],"sourcesContent":["import { backIn } from \"./back\"\n\nexport const anticipate = (p: number) =>\n p >= 1\n ? 1\n : (p *= 2) < 1\n ? 0.5 * backIn(p)\n : 0.5 * (2 - Math.pow(2, -10 * (p - 1)))\n"],"names":[],"mappings":";;AAEO,MAAM,UAAU,GAAG,CAAC,CAAS,KAChC,CAAC,IAAI;AACD,MAAE;AACF,MAAE,CAAC,CAAC,IAAI,CAAC,IAAI;AACX,UAAE,GAAG,GAAG,MAAM,CAAC,CAAC;UACd,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;;;"}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { cubicBezier } from './cubic-bezier.mjs';
|
||||
import { mirrorEasing } from './modifiers/mirror.mjs';
|
||||
import { reverseEasing } from './modifiers/reverse.mjs';
|
||||
|
||||
const backOut = /*@__PURE__*/ cubicBezier(0.33, 1.53, 0.69, 0.99);
|
||||
const backIn = /*@__PURE__*/ reverseEasing(backOut);
|
||||
const backInOut = /*@__PURE__*/ mirrorEasing(backIn);
|
||||
|
||||
export { backIn, backInOut, backOut };
|
||||
//# sourceMappingURL=back.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"back.mjs","sources":["../../../src/easing/back.ts"],"sourcesContent":["import { cubicBezier } from \"./cubic-bezier\"\nimport { mirrorEasing } from \"./modifiers/mirror\"\nimport { reverseEasing } from \"./modifiers/reverse\"\n\nexport const backOut = /*@__PURE__*/ cubicBezier(0.33, 1.53, 0.69, 0.99)\nexport const backIn = /*@__PURE__*/ reverseEasing(backOut)\nexport const backInOut = /*@__PURE__*/ mirrorEasing(backIn)\n"],"names":[],"mappings":";;;;AAIO,MAAM,OAAO,iBAAiB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;AAChE,MAAM,MAAM,iBAAiB,aAAa,CAAC,OAAO;AAClD,MAAM,SAAS,iBAAiB,YAAY,CAAC,MAAM;;;;"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { mirrorEasing } from './modifiers/mirror.mjs';
|
||||
import { reverseEasing } from './modifiers/reverse.mjs';
|
||||
|
||||
const circIn = (p) => 1 - Math.sin(Math.acos(p));
|
||||
const circOut = reverseEasing(circIn);
|
||||
const circInOut = mirrorEasing(circIn);
|
||||
|
||||
export { circIn, circInOut, circOut };
|
||||
//# sourceMappingURL=circ.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"circ.mjs","sources":["../../../src/easing/circ.ts"],"sourcesContent":["import { mirrorEasing } from \"./modifiers/mirror\"\nimport { reverseEasing } from \"./modifiers/reverse\"\nimport { EasingFunction } from \"./types\"\n\nexport const circIn: EasingFunction = (p) => 1 - Math.sin(Math.acos(p))\nexport const circOut = reverseEasing(circIn)\nexport const circInOut = mirrorEasing(circIn)\n"],"names":[],"mappings":";;;MAIa,MAAM,GAAmB,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;MACzD,OAAO,GAAG,aAAa,CAAC,MAAM;MAC9B,SAAS,GAAG,YAAY,CAAC,MAAM;;;;"}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import { noop } from '../noop.mjs';
|
||||
|
||||
/*
|
||||
Bezier function generator
|
||||
This has been modified from Gaëtan Renaudeau's BezierEasing
|
||||
https://github.com/gre/bezier-easing/blob/master/src/index.js
|
||||
https://github.com/gre/bezier-easing/blob/master/LICENSE
|
||||
|
||||
I've removed the newtonRaphsonIterate algo because in benchmarking it
|
||||
wasn't noticeably faster than binarySubdivision, indeed removing it
|
||||
usually improved times, depending on the curve.
|
||||
I also removed the lookup table, as for the added bundle size and loop we're
|
||||
only cutting ~4 or so subdivision iterations. I bumped the max iterations up
|
||||
to 12 to compensate and this still tended to be faster for no perceivable
|
||||
loss in accuracy.
|
||||
Usage
|
||||
const easeOut = cubicBezier(.17,.67,.83,.67);
|
||||
const x = easeOut(0.5); // returns 0.627...
|
||||
*/
|
||||
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
|
||||
const calcBezier = (t, a1, a2) => (((1.0 - 3.0 * a2 + 3.0 * a1) * t + (3.0 * a2 - 6.0 * a1)) * t + 3.0 * a1) *
|
||||
t;
|
||||
const subdivisionPrecision = 0.0000001;
|
||||
const subdivisionMaxIterations = 12;
|
||||
function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
|
||||
let currentX;
|
||||
let currentT;
|
||||
let i = 0;
|
||||
do {
|
||||
currentT = lowerBound + (upperBound - lowerBound) / 2.0;
|
||||
currentX = calcBezier(currentT, mX1, mX2) - x;
|
||||
if (currentX > 0.0) {
|
||||
upperBound = currentT;
|
||||
}
|
||||
else {
|
||||
lowerBound = currentT;
|
||||
}
|
||||
} while (Math.abs(currentX) > subdivisionPrecision &&
|
||||
++i < subdivisionMaxIterations);
|
||||
return currentT;
|
||||
}
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function cubicBezier(mX1, mY1, mX2, mY2) {
|
||||
// If this is a linear gradient, return linear easing
|
||||
if (mX1 === mY1 && mX2 === mY2)
|
||||
return noop;
|
||||
const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
|
||||
// If animation is at start/end, return t without easing
|
||||
return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
|
||||
}
|
||||
|
||||
export { cubicBezier };
|
||||
//# sourceMappingURL=cubic-bezier.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cubic-bezier.mjs","sources":["../../../src/easing/cubic-bezier.ts"],"sourcesContent":["/*\n Bezier function generator\n This has been modified from Gaëtan Renaudeau's BezierEasing\n https://github.com/gre/bezier-easing/blob/master/src/index.js\n https://github.com/gre/bezier-easing/blob/master/LICENSE\n \n I've removed the newtonRaphsonIterate algo because in benchmarking it\n wasn't noticeably faster than binarySubdivision, indeed removing it\n usually improved times, depending on the curve.\n I also removed the lookup table, as for the added bundle size and loop we're\n only cutting ~4 or so subdivision iterations. I bumped the max iterations up\n to 12 to compensate and this still tended to be faster for no perceivable\n loss in accuracy.\n Usage\n const easeOut = cubicBezier(.17,.67,.83,.67);\n const x = easeOut(0.5); // returns 0.627...\n*/\n\nimport { noop } from \"../noop\"\n\n// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.\nconst calcBezier = (t: number, a1: number, a2: number) =>\n (((1.0 - 3.0 * a2 + 3.0 * a1) * t + (3.0 * a2 - 6.0 * a1)) * t + 3.0 * a1) *\n t\n\nconst subdivisionPrecision = 0.0000001\nconst subdivisionMaxIterations = 12\n\nfunction binarySubdivide(\n x: number,\n lowerBound: number,\n upperBound: number,\n mX1: number,\n mX2: number\n) {\n let currentX: number\n let currentT: number\n let i: number = 0\n\n do {\n currentT = lowerBound + (upperBound - lowerBound) / 2.0\n currentX = calcBezier(currentT, mX1, mX2) - x\n if (currentX > 0.0) {\n upperBound = currentT\n } else {\n lowerBound = currentT\n }\n } while (\n Math.abs(currentX) > subdivisionPrecision &&\n ++i < subdivisionMaxIterations\n )\n\n return currentT\n}\n\n/*#__NO_SIDE_EFFECTS__*/\nexport function cubicBezier(\n mX1: number,\n mY1: number,\n mX2: number,\n mY2: number\n) {\n // If this is a linear gradient, return linear easing\n if (mX1 === mY1 && mX2 === mY2) return noop\n\n const getTForX = (aX: number) => binarySubdivide(aX, 0, 1, mX1, mX2)\n\n // If animation is at start/end, return t without easing\n return (t: number) =>\n t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2)\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;AAgBE;AAIF;AACA,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU,KACjD,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,EAAE;AACzE,IAAA,CAAC;AAEL,MAAM,oBAAoB,GAAG,SAAS;AACtC,MAAM,wBAAwB,GAAG,EAAE;AAEnC,SAAS,eAAe,CACpB,CAAS,EACT,UAAkB,EAClB,UAAkB,EAClB,GAAW,EACX,GAAW,EAAA;AAEX,IAAA,IAAI,QAAgB;AACpB,IAAA,IAAI,QAAgB;IACpB,IAAI,CAAC,GAAW,CAAC;AAEjB,IAAA,GAAG;QACC,QAAQ,GAAG,UAAU,GAAG,CAAC,UAAU,GAAG,UAAU,IAAI,GAAG;QACvD,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AAC7C,QAAA,IAAI,QAAQ,GAAG,GAAG,EAAE;YAChB,UAAU,GAAG,QAAQ;QACzB;aAAO;YACH,UAAU,GAAG,QAAQ;QACzB;IACJ,CAAC,QACG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,oBAAoB;QACzC,EAAE,CAAC,GAAG,wBAAwB;AAGlC,IAAA,OAAO,QAAQ;AACnB;AAEA;AACM,SAAU,WAAW,CACvB,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EAAA;;AAGX,IAAA,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG;AAAE,QAAA,OAAO,IAAI;AAE3C,IAAA,MAAM,QAAQ,GAAG,CAAC,EAAU,KAAK,eAAe,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;;AAGpE,IAAA,OAAO,CAAC,CAAS,KACb,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;AAClE;;;;"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { cubicBezier } from './cubic-bezier.mjs';
|
||||
|
||||
const easeIn = /*@__PURE__*/ cubicBezier(0.42, 0, 1, 1);
|
||||
const easeOut = /*@__PURE__*/ cubicBezier(0, 0, 0.58, 1);
|
||||
const easeInOut = /*@__PURE__*/ cubicBezier(0.42, 0, 0.58, 1);
|
||||
|
||||
export { easeIn, easeInOut, easeOut };
|
||||
//# sourceMappingURL=ease.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ease.mjs","sources":["../../../src/easing/ease.ts"],"sourcesContent":["import { cubicBezier } from \"./cubic-bezier\"\n\nexport const easeIn = /*@__PURE__*/ cubicBezier(0.42, 0, 1, 1)\nexport const easeOut = /*@__PURE__*/ cubicBezier(0, 0, 0.58, 1)\nexport const easeInOut = /*@__PURE__*/ cubicBezier(0.42, 0, 0.58, 1)\n"],"names":[],"mappings":";;AAEO,MAAM,MAAM,iBAAiB,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACtD,MAAM,OAAO,iBAAiB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;AACvD,MAAM,SAAS,iBAAiB,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;;;;"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Accepts an easing function and returns a new one that outputs mirrored values for
|
||||
// the second half of the animation. Turns easeIn into easeInOut.
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const mirrorEasing = (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
|
||||
|
||||
export { mirrorEasing };
|
||||
//# sourceMappingURL=mirror.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mirror.mjs","sources":["../../../../src/easing/modifiers/mirror.ts"],"sourcesContent":["// Accepts an easing function and returns a new one that outputs mirrored values for\n\nimport { EasingModifier } from \"../types\"\n\n// the second half of the animation. Turns easeIn into easeInOut.\n/*#__NO_SIDE_EFFECTS__*/\nexport const mirrorEasing: EasingModifier = (easing) => (p) =>\n p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2\n"],"names":[],"mappings":"AAAA;AAIA;AACA;MACa,YAAY,GAAmB,CAAC,MAAM,KAAK,CAAC,CAAC,KACtD,CAAC,IAAI,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;;;;"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Accepts an easing function and returns a new one that outputs reversed values.
|
||||
// Turns easeIn into easeOut.
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const reverseEasing = (easing) => (p) => 1 - easing(1 - p);
|
||||
|
||||
export { reverseEasing };
|
||||
//# sourceMappingURL=reverse.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"reverse.mjs","sources":["../../../../src/easing/modifiers/reverse.ts"],"sourcesContent":["// Accepts an easing function and returns a new one that outputs reversed values.\n\nimport { EasingModifier } from \"../types\"\n\n// Turns easeIn into easeOut.\n/*#__NO_SIDE_EFFECTS__*/\nexport const reverseEasing: EasingModifier = (easing) => (p) =>\n 1 - easing(1 - p)\n"],"names":[],"mappings":"AAAA;AAIA;AACA;MACa,aAAa,GAAmB,CAAC,MAAM,KAAK,CAAC,CAAC,KACvD,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC;;;;"}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { clamp } from '../clamp.mjs';
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function steps(numSteps, direction = "end") {
|
||||
return (progress) => {
|
||||
progress =
|
||||
direction === "end"
|
||||
? Math.min(progress, 0.999)
|
||||
: Math.max(progress, 0.001);
|
||||
const expanded = progress * numSteps;
|
||||
const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
|
||||
return clamp(0, 1, rounded / numSteps);
|
||||
};
|
||||
}
|
||||
|
||||
export { steps };
|
||||
//# sourceMappingURL=steps.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"steps.mjs","sources":["../../../src/easing/steps.ts"],"sourcesContent":["import { clamp } from \"../clamp\"\nimport type { EasingFunction } from \"./types\"\n\n/*\n Create stepped version of 0-1 progress\n\n @param [int]: Number of steps\n @param [number]: Current value\n @return [number]: Stepped value\n*/\nexport type Direction = \"start\" | \"end\"\n\n/*#__NO_SIDE_EFFECTS__*/\nexport function steps(\n numSteps: number,\n direction: Direction = \"end\"\n): EasingFunction {\n return (progress: number) => {\n progress =\n direction === \"end\"\n ? Math.min(progress, 0.999)\n : Math.max(progress, 0.001)\n const expanded = progress * numSteps\n const rounded =\n direction === \"end\" ? Math.floor(expanded) : Math.ceil(expanded)\n\n return clamp(0, 1, rounded / numSteps)\n }\n}\n"],"names":[],"mappings":";;AAYA;SACgB,KAAK,CACjB,QAAgB,EAChB,YAAuB,KAAK,EAAA;IAE5B,OAAO,CAAC,QAAgB,KAAI;QACxB,QAAQ;AACJ,YAAA,SAAS,KAAK;kBACR,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK;kBACxB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC;AACnC,QAAA,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ;QACpC,MAAM,OAAO,GACT,SAAS,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QAEpE,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;AAC1C,IAAA,CAAC;AACL;;;;"}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { wrap } from '../../wrap.mjs';
|
||||
import { isEasingArray } from './is-easing-array.mjs';
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function getEasingForSegment(easing, i) {
|
||||
return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
|
||||
}
|
||||
|
||||
export { getEasingForSegment };
|
||||
//# sourceMappingURL=get-easing-for-segment.mjs.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"get-easing-for-segment.mjs","sources":["../../../../src/easing/utils/get-easing-for-segment.ts"],"sourcesContent":["import { wrap } from \"../../wrap\"\nimport { Easing } from \"../types\"\nimport { isEasingArray } from \"./is-easing-array\"\n\n/*#__NO_SIDE_EFFECTS__*/\nexport function getEasingForSegment(\n easing: Easing | Easing[],\n i: number\n): Easing {\n return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing\n}\n"],"names":[],"mappings":";;;AAIA;AACM,SAAU,mBAAmB,CAC/B,MAAyB,EACzB,CAAS,EAAA;IAET,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM;AAC7E;;;;"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
|
||||
|
||||
export { isBezierDefinition };
|
||||
//# sourceMappingURL=is-bezier-definition.mjs.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-bezier-definition.mjs","sources":["../../../../src/easing/utils/is-bezier-definition.ts"],"sourcesContent":["import { BezierDefinition, Easing } from \"../types\"\n\n/*#__NO_SIDE_EFFECTS__*/\nexport const isBezierDefinition = (\n easing: Easing | Easing[]\n): easing is BezierDefinition =>\n Array.isArray(easing) && typeof easing[0] === \"number\"\n"],"names":[],"mappings":"AAEA;MACa,kBAAkB,GAAG,CAC9B,MAAyB,KAEzB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK;;;;"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const isEasingArray = (ease) => {
|
||||
return Array.isArray(ease) && typeof ease[0] !== "number";
|
||||
};
|
||||
|
||||
export { isEasingArray };
|
||||
//# sourceMappingURL=is-easing-array.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-easing-array.mjs","sources":["../../../../src/easing/utils/is-easing-array.ts"],"sourcesContent":["import { Easing } from \"../types\"\n\n/*#__NO_SIDE_EFFECTS__*/\nexport const isEasingArray = (ease: any): ease is Easing[] => {\n return Array.isArray(ease) && typeof ease[0] !== \"number\"\n}\n"],"names":[],"mappings":"AAEA;AACO,MAAM,aAAa,GAAG,CAAC,IAAS,KAAsB;AACzD,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;AAC7D;;;;"}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import { invariant } from '../../errors.mjs';
|
||||
import { noop } from '../../noop.mjs';
|
||||
import { anticipate } from '../anticipate.mjs';
|
||||
import { backOut, backInOut, backIn } from '../back.mjs';
|
||||
import { circOut, circInOut, circIn } from '../circ.mjs';
|
||||
import { cubicBezier } from '../cubic-bezier.mjs';
|
||||
import { easeOut, easeInOut, easeIn } from '../ease.mjs';
|
||||
import { isBezierDefinition } from './is-bezier-definition.mjs';
|
||||
|
||||
const easingLookup = {
|
||||
linear: noop,
|
||||
easeIn,
|
||||
easeInOut,
|
||||
easeOut,
|
||||
circIn,
|
||||
circInOut,
|
||||
circOut,
|
||||
backIn,
|
||||
backInOut,
|
||||
backOut,
|
||||
anticipate,
|
||||
};
|
||||
const isValidEasing = (easing) => {
|
||||
return typeof easing === "string";
|
||||
};
|
||||
const easingDefinitionToFunction = (definition) => {
|
||||
if (isBezierDefinition(definition)) {
|
||||
// If cubic bezier definition, create bezier curve
|
||||
invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`, "cubic-bezier-length");
|
||||
const [x1, y1, x2, y2] = definition;
|
||||
return cubicBezier(x1, y1, x2, y2);
|
||||
}
|
||||
else if (isValidEasing(definition)) {
|
||||
// Else lookup from table
|
||||
invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`, "invalid-easing-type");
|
||||
return easingLookup[definition];
|
||||
}
|
||||
return definition;
|
||||
};
|
||||
|
||||
export { easingDefinitionToFunction };
|
||||
//# sourceMappingURL=map.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"map.mjs","sources":["../../../../src/easing/utils/map.ts"],"sourcesContent":["import { invariant } from \"../../errors\"\nimport { noop } from \"../../noop\"\nimport { anticipate } from \"../anticipate\"\nimport { backIn, backInOut, backOut } from \"../back\"\nimport { circIn, circInOut, circOut } from \"../circ\"\nimport { cubicBezier } from \"../cubic-bezier\"\nimport { easeIn, easeInOut, easeOut } from \"../ease\"\nimport { Easing, EasingFunction } from \"../types\"\nimport { isBezierDefinition } from \"./is-bezier-definition\"\n\nconst easingLookup = {\n linear: noop,\n easeIn,\n easeInOut,\n easeOut,\n circIn,\n circInOut,\n circOut,\n backIn,\n backInOut,\n backOut,\n anticipate,\n}\n\nconst isValidEasing = (easing: Easing): easing is keyof typeof easingLookup => {\n return typeof easing === \"string\"\n}\n\nexport const easingDefinitionToFunction = (\n definition: Easing\n): EasingFunction => {\n if (isBezierDefinition(definition)) {\n // If cubic bezier definition, create bezier curve\n invariant(\n definition.length === 4,\n `Cubic bezier arrays must contain four numerical values.`,\n \"cubic-bezier-length\"\n )\n\n const [x1, y1, x2, y2] = definition\n return cubicBezier(x1, y1, x2, y2)\n } else if (isValidEasing(definition)) {\n // Else lookup from table\n invariant(\n easingLookup[definition] !== undefined,\n `Invalid easing type '${definition}'`,\n \"invalid-easing-type\"\n )\n return easingLookup[definition]\n }\n\n return definition\n}\n"],"names":[],"mappings":";;;;;;;;;AAUA,MAAM,YAAY,GAAG;AACjB,IAAA,MAAM,EAAE,IAAI;IACZ,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,UAAU;CACb;AAED,MAAM,aAAa,GAAG,CAAC,MAAc,KAAyC;AAC1E,IAAA,OAAO,OAAO,MAAM,KAAK,QAAQ;AACrC,CAAC;AAEM,MAAM,0BAA0B,GAAG,CACtC,UAAkB,KACF;AAChB,IAAA,IAAI,kBAAkB,CAAC,UAAU,CAAC,EAAE;;QAEhC,SAAS,CACL,UAAU,CAAC,MAAM,KAAK,CAAC,EACvB,CAAA,uDAAA,CAAyD,EACzD,qBAAqB,CACxB;QAED,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU;QACnC,OAAO,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IACtC;AAAO,SAAA,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE;;AAElC,QAAA,SAAS,CACL,YAAY,CAAC,UAAU,CAAC,KAAK,SAAS,EACtC,CAAA,qBAAA,EAAwB,UAAU,CAAA,CAAA,CAAG,EACrC,qBAAqB,CACxB;AACD,QAAA,OAAO,YAAY,CAAC,UAAU,CAAC;IACnC;AAEA,IAAA,OAAO,UAAU;AACrB;;;;"}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { formatErrorMessage } from './format-error-message.mjs';
|
||||
|
||||
let warning = () => { };
|
||||
let invariant = () => { };
|
||||
if (typeof process !== "undefined" &&
|
||||
process.env?.NODE_ENV !== "production") {
|
||||
warning = (check, message, errorCode) => {
|
||||
if (!check && typeof console !== "undefined") {
|
||||
console.warn(formatErrorMessage(message, errorCode));
|
||||
}
|
||||
};
|
||||
invariant = (check, message, errorCode) => {
|
||||
if (!check) {
|
||||
throw new Error(formatErrorMessage(message, errorCode));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { invariant, warning };
|
||||
//# sourceMappingURL=errors.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.mjs","sources":["../../src/errors.ts"],"sourcesContent":["import { formatErrorMessage } from \"./format-error-message\"\n\nexport type DevMessage = (\n check: boolean,\n message: string,\n errorCode?: string\n) => void\n\nlet warning: DevMessage = () => {}\nlet invariant: DevMessage = () => {}\n\nif (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n) {\n warning = (check, message, errorCode) => {\n if (!check && typeof console !== \"undefined\") {\n console.warn(formatErrorMessage(message, errorCode))\n }\n }\n\n invariant = (check, message, errorCode) => {\n if (!check) {\n throw new Error(formatErrorMessage(message, errorCode))\n }\n }\n}\n\nexport { invariant, warning }\n"],"names":[],"mappings":";;AAQA,IAAI,OAAO,GAAe,MAAK,EAAE;AACjC,IAAI,SAAS,GAAe,MAAK,EAAE;AAEnC,IACI,OAAO,OAAO,KAAK,WAAW;AAC9B,IAAA,OAAO,CAAC,GAAG,EAAE,QAAQ,KAAK,YAAY,EACxC;IACE,OAAO,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,KAAI;QACpC,IAAI,CAAC,KAAK,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;YAC1C,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACxD;AACJ,IAAA,CAAC;IAED,SAAS,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,KAAI;QACtC,IAAI,CAAC,KAAK,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3D;AACJ,IAAA,CAAC;AACL;;;;"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
function formatErrorMessage(message, errorCode) {
|
||||
return errorCode
|
||||
? `${message}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${errorCode}`
|
||||
: message;
|
||||
}
|
||||
|
||||
export { formatErrorMessage };
|
||||
//# sourceMappingURL=format-error-message.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"format-error-message.mjs","sources":["../../src/format-error-message.ts"],"sourcesContent":["export function formatErrorMessage(message: string, errorCode?: string) {\n return errorCode\n ? `${message}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${errorCode}`\n : message\n}\n"],"names":[],"mappings":"AAAM,SAAU,kBAAkB,CAAC,OAAe,EAAE,SAAkB,EAAA;AAClE,IAAA,OAAO;AACH,UAAE,CAAA,EAAG,OAAO,CAAA,uFAAA,EAA0F,SAAS,CAAA;UAC7G,OAAO;AACjB;;;;"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
const MotionGlobalConfig = {};
|
||||
|
||||
export { MotionGlobalConfig };
|
||||
//# sourceMappingURL=global-config.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"global-config.mjs","sources":["../../src/global-config.ts"],"sourcesContent":["export const MotionGlobalConfig: {\n skipAnimations?: boolean\n instantAnimations?: boolean\n useManualTiming?: boolean\n WillChange?: any\n mix?: <T>(a: T, b: T) => (p: number) => T\n} = {}\n"],"names":[],"mappings":"AAAO,MAAM,kBAAkB,GAM3B;;;;"}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
export { addUniqueItem, moveItem, removeItem } from './array.mjs';
|
||||
export { clamp } from './clamp.mjs';
|
||||
export { invariant, warning } from './errors.mjs';
|
||||
export { MotionGlobalConfig } from './global-config.mjs';
|
||||
export { isNumericalString } from './is-numerical-string.mjs';
|
||||
export { isObject } from './is-object.mjs';
|
||||
export { isZeroValueString } from './is-zero-value-string.mjs';
|
||||
export { memo } from './memo.mjs';
|
||||
export { noop } from './noop.mjs';
|
||||
export { pipe } from './pipe.mjs';
|
||||
export { progress } from './progress.mjs';
|
||||
export { SubscriptionManager } from './subscription-manager.mjs';
|
||||
export { millisecondsToSeconds, secondsToMilliseconds } from './time-conversion.mjs';
|
||||
export { velocityPerSecond } from './velocity-per-second.mjs';
|
||||
export { hasWarned, warnOnce } from './warn-once.mjs';
|
||||
export { wrap } from './wrap.mjs';
|
||||
export { anticipate } from './easing/anticipate.mjs';
|
||||
export { backIn, backInOut, backOut } from './easing/back.mjs';
|
||||
export { circIn, circInOut, circOut } from './easing/circ.mjs';
|
||||
export { cubicBezier } from './easing/cubic-bezier.mjs';
|
||||
export { easeIn, easeInOut, easeOut } from './easing/ease.mjs';
|
||||
export { mirrorEasing } from './easing/modifiers/mirror.mjs';
|
||||
export { reverseEasing } from './easing/modifiers/reverse.mjs';
|
||||
export { steps } from './easing/steps.mjs';
|
||||
export { getEasingForSegment } from './easing/utils/get-easing-for-segment.mjs';
|
||||
export { isBezierDefinition } from './easing/utils/is-bezier-definition.mjs';
|
||||
export { isEasingArray } from './easing/utils/is-easing-array.mjs';
|
||||
export { easingDefinitionToFunction } from './easing/utils/map.mjs';
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
|
||||
*/
|
||||
const isNumericalString = (v) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(v);
|
||||
|
||||
export { isNumericalString };
|
||||
//# sourceMappingURL=is-numerical-string.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-numerical-string.mjs","sources":["../../src/is-numerical-string.ts"],"sourcesContent":["/**\n * Check if value is a numerical string, ie a string that is purely a number eg \"100\" or \"-100.1\"\n */\nexport const isNumericalString = (v: string) => /^-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)$/u.test(v)\n"],"names":[],"mappings":"AAAA;;AAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,CAAS,KAAK,8BAA8B,CAAC,IAAI,CAAC,CAAC;;;;"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
const isObject = (value) => typeof value === "object" && value !== null;
|
||||
|
||||
export { isObject };
|
||||
//# sourceMappingURL=is-object.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-object.mjs","sources":["../../src/is-object.ts"],"sourcesContent":["export const isObject = (value: unknown): value is object =>\n typeof value === \"object\" && value !== null\n"],"names":[],"mappings":"AAAO,MAAM,QAAQ,GAAG,CAAC,KAAc,KACnC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK;;;;"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Check if the value is a zero value string like "0px" or "0%"
|
||||
*/
|
||||
const isZeroValueString = (v) => /^0[^.\s]+$/u.test(v);
|
||||
|
||||
export { isZeroValueString };
|
||||
//# sourceMappingURL=is-zero-value-string.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-zero-value-string.mjs","sources":["../../src/is-zero-value-string.ts"],"sourcesContent":["/**\n * Check if the value is a zero value string like \"0px\" or \"0%\"\n */\nexport const isZeroValueString = (v: string) => /^0[^.\\s]+$/u.test(v)\n"],"names":[],"mappings":"AAAA;;AAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,CAAS,KAAK,aAAa,CAAC,IAAI,CAAC,CAAC;;;;"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function memo(callback) {
|
||||
let result;
|
||||
return () => {
|
||||
if (result === undefined)
|
||||
result = callback();
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
export { memo };
|
||||
//# sourceMappingURL=memo.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"memo.mjs","sources":["../../src/memo.ts"],"sourcesContent":["/*#__NO_SIDE_EFFECTS__*/\nexport function memo<T extends any>(callback: () => T) {\n let result: T | undefined\n\n return () => {\n if (result === undefined) result = callback()\n return result\n }\n}\n"],"names":[],"mappings":"AAAA;AACM,SAAU,IAAI,CAAgB,QAAiB,EAAA;AACjD,IAAA,IAAI,MAAqB;AAEzB,IAAA,OAAO,MAAK;QACR,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,GAAG,QAAQ,EAAE;AAC7C,QAAA,OAAO,MAAM;AACjB,IAAA,CAAC;AACL;;;;"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const noop = (any) => any;
|
||||
|
||||
export { noop };
|
||||
//# sourceMappingURL=noop.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"noop.mjs","sources":["../../src/noop.ts"],"sourcesContent":["/*#__NO_SIDE_EFFECTS__*/\nexport const noop = <T>(any: T): T => any\n"],"names":[],"mappings":"AAAA;AACO,MAAM,IAAI,GAAG,CAAI,GAAM,KAAQ;;;;"}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Pipe
|
||||
* Compose other transformers to run linearily
|
||||
* pipe(min(20), max(40))
|
||||
* @param {...functions} transformers
|
||||
* @return {function}
|
||||
*/
|
||||
const pipe = (...transformers) => transformers.reduce((a, b) => (v) => b(a(v)));
|
||||
|
||||
export { pipe };
|
||||
//# sourceMappingURL=pipe.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pipe.mjs","sources":["../../src/pipe.ts"],"sourcesContent":["/**\n * Pipe\n * Compose other transformers to run linearily\n * pipe(min(20), max(40))\n * @param {...functions} transformers\n * @return {function}\n */\nexport const pipe = (...transformers: Function[]) =>\n transformers.reduce((a, b) => (v: any) => b(a(v)))\n"],"names":[],"mappings":"AAAA;;;;;;AAMG;AACI,MAAM,IAAI,GAAG,CAAC,GAAG,YAAwB,KAC5C,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
Progress within given range
|
||||
|
||||
Given a lower limit and an upper limit, we return the progress
|
||||
(expressed as a number 0-1) represented by the given value, and
|
||||
limit that progress to within 0-1.
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const progress = (from, to, value) => {
|
||||
const range = to - from;
|
||||
return range ? (value - from) / range : 1;
|
||||
};
|
||||
|
||||
export { progress };
|
||||
//# sourceMappingURL=progress.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"progress.mjs","sources":["../../src/progress.ts"],"sourcesContent":["/*\n Progress within given range\n\n Given a lower limit and an upper limit, we return the progress\n (expressed as a number 0-1) represented by the given value, and\n limit that progress to within 0-1.\n*/\n/*#__NO_SIDE_EFFECTS__*/\nexport const progress = (from: number, to: number, value: number) => {\n const range = to - from\n return range ? (value - from) / range : 1\n}\n"],"names":[],"mappings":"AAAA;;;;;;AAME;AACF;AACO,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,KAAa,KAAI;AAChE,IAAA,MAAM,KAAK,GAAG,EAAE,GAAG,IAAI;AACvB,IAAA,OAAO,KAAK,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC;AAC7C;;;;"}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import { addUniqueItem, removeItem } from './array.mjs';
|
||||
|
||||
class SubscriptionManager {
|
||||
constructor() {
|
||||
this.subscriptions = [];
|
||||
}
|
||||
add(handler) {
|
||||
addUniqueItem(this.subscriptions, handler);
|
||||
return () => removeItem(this.subscriptions, handler);
|
||||
}
|
||||
notify(a, b, c) {
|
||||
const numSubscriptions = this.subscriptions.length;
|
||||
if (!numSubscriptions)
|
||||
return;
|
||||
if (numSubscriptions === 1) {
|
||||
/**
|
||||
* If there's only a single handler we can just call it without invoking a loop.
|
||||
*/
|
||||
this.subscriptions[0](a, b, c);
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < numSubscriptions; i++) {
|
||||
/**
|
||||
* Check whether the handler exists before firing as it's possible
|
||||
* the subscriptions were modified during this loop running.
|
||||
*/
|
||||
const handler = this.subscriptions[i];
|
||||
handler && handler(a, b, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
getSize() {
|
||||
return this.subscriptions.length;
|
||||
}
|
||||
clear() {
|
||||
this.subscriptions.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
export { SubscriptionManager };
|
||||
//# sourceMappingURL=subscription-manager.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subscription-manager.mjs","sources":["../../src/subscription-manager.ts"],"sourcesContent":["import { addUniqueItem, removeItem } from \"./array\"\n\ntype GenericHandler = (...args: any) => void\n\nexport class SubscriptionManager<Handler extends GenericHandler> {\n private subscriptions: Handler[] = []\n\n add(handler: Handler): VoidFunction {\n addUniqueItem(this.subscriptions, handler)\n return () => removeItem(this.subscriptions, handler)\n }\n\n notify(\n a?: Parameters<Handler>[0],\n b?: Parameters<Handler>[1],\n c?: Parameters<Handler>[2]\n ) {\n const numSubscriptions = this.subscriptions.length\n\n if (!numSubscriptions) return\n\n if (numSubscriptions === 1) {\n /**\n * If there's only a single handler we can just call it without invoking a loop.\n */\n this.subscriptions[0](a, b, c)\n } else {\n for (let i = 0; i < numSubscriptions; i++) {\n /**\n * Check whether the handler exists before firing as it's possible\n * the subscriptions were modified during this loop running.\n */\n const handler = this.subscriptions[i]\n handler && handler(a, b, c)\n }\n }\n }\n\n getSize() {\n return this.subscriptions.length\n }\n\n clear() {\n this.subscriptions.length = 0\n }\n}\n"],"names":[],"mappings":";;MAIa,mBAAmB,CAAA;AAAhC,IAAA,WAAA,GAAA;QACY,IAAA,CAAA,aAAa,GAAc,EAAE;IAwCzC;AAtCI,IAAA,GAAG,CAAC,OAAgB,EAAA;AAChB,QAAA,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;QAC1C,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;IACxD;AAEA,IAAA,MAAM,CACF,CAA0B,EAC1B,CAA0B,EAC1B,CAA0B,EAAA;AAE1B,QAAA,MAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM;AAElD,QAAA,IAAI,CAAC,gBAAgB;YAAE;AAEvB,QAAA,IAAI,gBAAgB,KAAK,CAAC,EAAE;AACxB;;AAEG;AACH,YAAA,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAClC;aAAO;AACH,YAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,CAAC,EAAE,EAAE;AACvC;;;AAGG;gBACH,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;gBACrC,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAC/B;QACJ;IACJ;IAEA,OAAO,GAAA;AACH,QAAA,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM;IACpC;IAEA,KAAK,GAAA;AACD,QAAA,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC;IACjC;AACH;;;;"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Converts seconds to milliseconds
|
||||
*
|
||||
* @param seconds - Time in seconds.
|
||||
* @return milliseconds - Converted time in milliseconds.
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const secondsToMilliseconds = (seconds) => seconds * 1000;
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const millisecondsToSeconds = (milliseconds) => milliseconds / 1000;
|
||||
|
||||
export { millisecondsToSeconds, secondsToMilliseconds };
|
||||
//# sourceMappingURL=time-conversion.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"time-conversion.mjs","sources":["../../src/time-conversion.ts"],"sourcesContent":["/**\n * Converts seconds to milliseconds\n *\n * @param seconds - Time in seconds.\n * @return milliseconds - Converted time in milliseconds.\n */\n\n/*#__NO_SIDE_EFFECTS__*/\nexport const secondsToMilliseconds = (seconds: number) => seconds * 1000\n\n/*#__NO_SIDE_EFFECTS__*/\nexport const millisecondsToSeconds = (milliseconds: number) =>\n milliseconds / 1000\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH;AACO,MAAM,qBAAqB,GAAG,CAAC,OAAe,KAAK,OAAO,GAAG;AAEpE;AACO,MAAM,qBAAqB,GAAG,CAAC,YAAoB,KACtD,YAAY,GAAG;;;;"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Convert velocity into velocity per second
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const velocityPerSecond = (velocity, frameDuration) => frameDuration ? velocity * (1000 / frameDuration) : 0;
|
||||
|
||||
export { velocityPerSecond };
|
||||
//# sourceMappingURL=velocity-per-second.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"velocity-per-second.mjs","sources":["../../src/velocity-per-second.ts"],"sourcesContent":["/*\n Convert velocity into velocity per second\n*/\n/*#__NO_SIDE_EFFECTS__*/\nexport const velocityPerSecond = (velocity: number, frameDuration: number) =>\n frameDuration ? velocity * (1000 / frameDuration) : 0\n"],"names":[],"mappings":"AAAA;;AAEE;AACF;AACO,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,aAAqB,KACrE,aAAa,GAAG,QAAQ,IAAI,IAAI,GAAG,aAAa,CAAC,GAAG;;;;"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { formatErrorMessage } from './format-error-message.mjs';
|
||||
|
||||
const warned = new Set();
|
||||
function hasWarned(message) {
|
||||
return warned.has(message);
|
||||
}
|
||||
function warnOnce(condition, message, errorCode) {
|
||||
if (condition || warned.has(message))
|
||||
return;
|
||||
console.warn(formatErrorMessage(message, errorCode));
|
||||
warned.add(message);
|
||||
}
|
||||
|
||||
export { hasWarned, warnOnce };
|
||||
//# sourceMappingURL=warn-once.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"warn-once.mjs","sources":["../../src/warn-once.ts"],"sourcesContent":["import { formatErrorMessage } from \"./format-error-message\"\n\nconst warned = new Set<string>()\n\nexport function hasWarned(message: string) {\n return warned.has(message)\n}\n\nexport function warnOnce(\n condition: boolean,\n message: string,\n errorCode?: string\n) {\n if (condition || warned.has(message)) return\n\n console.warn(formatErrorMessage(message, errorCode))\n warned.add(message)\n}\n"],"names":[],"mappings":";;AAEA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU;AAE1B,SAAU,SAAS,CAAC,OAAe,EAAA;AACrC,IAAA,OAAO,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;AAC9B;SAEgB,QAAQ,CACpB,SAAkB,EAClB,OAAe,EACf,SAAkB,EAAA;AAElB,IAAA,IAAI,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE;IAEtC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACpD,IAAA,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;AACvB;;;;"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
const wrap = (min, max, v) => {
|
||||
const rangeSize = max - min;
|
||||
return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
|
||||
};
|
||||
|
||||
export { wrap };
|
||||
//# sourceMappingURL=wrap.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"wrap.mjs","sources":["../../src/wrap.ts"],"sourcesContent":["export const wrap = (min: number, max: number, v: number) => {\n const rangeSize = max - min\n return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min\n}\n"],"names":[],"mappings":"AAAO,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,CAAS,KAAI;AACxD,IAAA,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG;AAC3B,IAAA,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,GAAG;AACpE;;;;"}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
declare function addUniqueItem<T>(arr: T[], item: T): void;
|
||||
declare function removeItem<T>(arr: T[], item: T): void;
|
||||
declare function moveItem<T>([...arr]: T[], fromIndex: number, toIndex: number): T[];
|
||||
|
||||
declare const clamp: (min: number, max: number, v: number) => number;
|
||||
|
||||
type DevMessage = (check: boolean, message: string, errorCode?: string) => void;
|
||||
declare let warning: DevMessage;
|
||||
declare let invariant: DevMessage;
|
||||
|
||||
declare const MotionGlobalConfig: {
|
||||
skipAnimations?: boolean;
|
||||
instantAnimations?: boolean;
|
||||
useManualTiming?: boolean;
|
||||
WillChange?: any;
|
||||
mix?: <T>(a: T, b: T) => (p: number) => T;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
|
||||
*/
|
||||
declare const isNumericalString: (v: string) => boolean;
|
||||
|
||||
declare const isObject: (value: unknown) => value is object;
|
||||
|
||||
/**
|
||||
* Check if the value is a zero value string like "0px" or "0%"
|
||||
*/
|
||||
declare const isZeroValueString: (v: string) => boolean;
|
||||
|
||||
declare function memo<T extends any>(callback: () => T): () => T;
|
||||
|
||||
declare const noop: <T>(any: T) => T;
|
||||
|
||||
/**
|
||||
* Pipe
|
||||
* Compose other transformers to run linearily
|
||||
* pipe(min(20), max(40))
|
||||
* @param {...functions} transformers
|
||||
* @return {function}
|
||||
*/
|
||||
declare const pipe: (...transformers: Function[]) => Function;
|
||||
|
||||
declare const progress: (from: number, to: number, value: number) => number;
|
||||
|
||||
type GenericHandler = (...args: any) => void;
|
||||
declare class SubscriptionManager<Handler extends GenericHandler> {
|
||||
private subscriptions;
|
||||
add(handler: Handler): VoidFunction;
|
||||
notify(a?: Parameters<Handler>[0], b?: Parameters<Handler>[1], c?: Parameters<Handler>[2]): void;
|
||||
getSize(): number;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts seconds to milliseconds
|
||||
*
|
||||
* @param seconds - Time in seconds.
|
||||
* @return milliseconds - Converted time in milliseconds.
|
||||
*/
|
||||
declare const secondsToMilliseconds: (seconds: number) => number;
|
||||
declare const millisecondsToSeconds: (milliseconds: number) => number;
|
||||
|
||||
declare const velocityPerSecond: (velocity: number, frameDuration: number) => number;
|
||||
|
||||
declare function hasWarned(message: string): boolean;
|
||||
declare function warnOnce(condition: boolean, message: string, errorCode?: string): void;
|
||||
|
||||
declare const wrap: (min: number, max: number, v: number) => number;
|
||||
|
||||
declare const anticipate: (p: number) => number;
|
||||
|
||||
declare const backOut: (t: number) => number;
|
||||
declare const backIn: EasingFunction;
|
||||
declare const backInOut: EasingFunction;
|
||||
|
||||
type EasingFunction = (v: number) => number;
|
||||
type EasingModifier = (easing: EasingFunction) => EasingFunction;
|
||||
type BezierDefinition = readonly [number, number, number, number];
|
||||
type EasingDefinition = BezierDefinition | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
|
||||
/**
|
||||
* The easing function to use. Set as one of:
|
||||
*
|
||||
* - The name of an in-built easing function.
|
||||
* - An array of four numbers to define a cubic bezier curve.
|
||||
* - An easing function, that accepts and returns a progress value between `0` and `1`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
type Easing = EasingDefinition | EasingFunction;
|
||||
|
||||
declare const circIn: EasingFunction;
|
||||
declare const circOut: EasingFunction;
|
||||
declare const circInOut: EasingFunction;
|
||||
|
||||
declare function cubicBezier(mX1: number, mY1: number, mX2: number, mY2: number): (t: number) => number;
|
||||
|
||||
declare const easeIn: (t: number) => number;
|
||||
declare const easeOut: (t: number) => number;
|
||||
declare const easeInOut: (t: number) => number;
|
||||
|
||||
declare const mirrorEasing: EasingModifier;
|
||||
|
||||
declare const reverseEasing: EasingModifier;
|
||||
|
||||
type Direction = "start" | "end";
|
||||
declare function steps(numSteps: number, direction?: Direction): EasingFunction;
|
||||
|
||||
declare function getEasingForSegment(easing: Easing | Easing[], i: number): Easing;
|
||||
|
||||
declare const isBezierDefinition: (easing: Easing | Easing[]) => easing is BezierDefinition;
|
||||
|
||||
declare const isEasingArray: (ease: any) => ease is Easing[];
|
||||
|
||||
declare const easingDefinitionToFunction: (definition: Easing) => EasingFunction;
|
||||
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
interface Axis {
|
||||
min: number;
|
||||
max: number;
|
||||
}
|
||||
interface Box {
|
||||
x: Axis;
|
||||
y: Axis;
|
||||
}
|
||||
interface BoundingBox {
|
||||
top: number;
|
||||
right: number;
|
||||
bottom: number;
|
||||
left: number;
|
||||
}
|
||||
interface AxisDelta {
|
||||
translate: number;
|
||||
scale: number;
|
||||
origin: number;
|
||||
originPoint: number;
|
||||
}
|
||||
interface Delta {
|
||||
x: AxisDelta;
|
||||
y: AxisDelta;
|
||||
}
|
||||
type TransformPoint = (point: Point) => Point;
|
||||
|
||||
export { type Axis, type AxisDelta, type BezierDefinition, type BoundingBox, type Box, type Delta, type DevMessage, type Direction, type Easing, type EasingDefinition, type EasingFunction, type EasingModifier, MotionGlobalConfig, type Point, SubscriptionManager, type TransformPoint, addUniqueItem, anticipate, backIn, backInOut, backOut, circIn, circInOut, circOut, clamp, cubicBezier, easeIn, easeInOut, easeOut, easingDefinitionToFunction, getEasingForSegment, hasWarned, invariant, isBezierDefinition, isEasingArray, isNumericalString, isObject, isZeroValueString, memo, millisecondsToSeconds, mirrorEasing, moveItem, noop, pipe, progress, removeItem, reverseEasing, secondsToMilliseconds, steps, velocityPerSecond, warnOnce, warning, wrap };
|
||||
+348
@@ -0,0 +1,348 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MotionUtils = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
function addUniqueItem(arr, item) {
|
||||
if (arr.indexOf(item) === -1)
|
||||
arr.push(item);
|
||||
}
|
||||
function removeItem(arr, item) {
|
||||
const index = arr.indexOf(item);
|
||||
if (index > -1)
|
||||
arr.splice(index, 1);
|
||||
}
|
||||
// Adapted from array-move
|
||||
function moveItem([...arr], fromIndex, toIndex) {
|
||||
const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
|
||||
if (startIndex >= 0 && startIndex < arr.length) {
|
||||
const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
|
||||
const [item] = arr.splice(fromIndex, 1);
|
||||
arr.splice(endIndex, 0, item);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const clamp = (min, max, v) => {
|
||||
if (v > max)
|
||||
return max;
|
||||
if (v < min)
|
||||
return min;
|
||||
return v;
|
||||
};
|
||||
|
||||
function formatErrorMessage(message, errorCode) {
|
||||
return errorCode
|
||||
? `${message}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${errorCode}`
|
||||
: message;
|
||||
}
|
||||
|
||||
exports.warning = () => { };
|
||||
exports.invariant = () => { };
|
||||
if (typeof process !== "undefined" &&
|
||||
process.env?.NODE_ENV !== "production") {
|
||||
exports.warning = (check, message, errorCode) => {
|
||||
if (!check && typeof console !== "undefined") {
|
||||
console.warn(formatErrorMessage(message, errorCode));
|
||||
}
|
||||
};
|
||||
exports.invariant = (check, message, errorCode) => {
|
||||
if (!check) {
|
||||
throw new Error(formatErrorMessage(message, errorCode));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const MotionGlobalConfig = {};
|
||||
|
||||
/**
|
||||
* Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
|
||||
*/
|
||||
const isNumericalString = (v) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(v);
|
||||
|
||||
const isObject = (value) => typeof value === "object" && value !== null;
|
||||
|
||||
/**
|
||||
* Check if the value is a zero value string like "0px" or "0%"
|
||||
*/
|
||||
const isZeroValueString = (v) => /^0[^.\s]+$/u.test(v);
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function memo(callback) {
|
||||
let result;
|
||||
return () => {
|
||||
if (result === undefined)
|
||||
result = callback();
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const noop = (any) => any;
|
||||
|
||||
/**
|
||||
* Pipe
|
||||
* Compose other transformers to run linearily
|
||||
* pipe(min(20), max(40))
|
||||
* @param {...functions} transformers
|
||||
* @return {function}
|
||||
*/
|
||||
const pipe = (...transformers) => transformers.reduce((a, b) => (v) => b(a(v)));
|
||||
|
||||
/*
|
||||
Progress within given range
|
||||
|
||||
Given a lower limit and an upper limit, we return the progress
|
||||
(expressed as a number 0-1) represented by the given value, and
|
||||
limit that progress to within 0-1.
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const progress = (from, to, value) => {
|
||||
const range = to - from;
|
||||
return range ? (value - from) / range : 1;
|
||||
};
|
||||
|
||||
class SubscriptionManager {
|
||||
constructor() {
|
||||
this.subscriptions = [];
|
||||
}
|
||||
add(handler) {
|
||||
addUniqueItem(this.subscriptions, handler);
|
||||
return () => removeItem(this.subscriptions, handler);
|
||||
}
|
||||
notify(a, b, c) {
|
||||
const numSubscriptions = this.subscriptions.length;
|
||||
if (!numSubscriptions)
|
||||
return;
|
||||
if (numSubscriptions === 1) {
|
||||
/**
|
||||
* If there's only a single handler we can just call it without invoking a loop.
|
||||
*/
|
||||
this.subscriptions[0](a, b, c);
|
||||
}
|
||||
else {
|
||||
for (let i = 0; i < numSubscriptions; i++) {
|
||||
/**
|
||||
* Check whether the handler exists before firing as it's possible
|
||||
* the subscriptions were modified during this loop running.
|
||||
*/
|
||||
const handler = this.subscriptions[i];
|
||||
handler && handler(a, b, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
getSize() {
|
||||
return this.subscriptions.length;
|
||||
}
|
||||
clear() {
|
||||
this.subscriptions.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts seconds to milliseconds
|
||||
*
|
||||
* @param seconds - Time in seconds.
|
||||
* @return milliseconds - Converted time in milliseconds.
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const secondsToMilliseconds = (seconds) => seconds * 1000;
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const millisecondsToSeconds = (milliseconds) => milliseconds / 1000;
|
||||
|
||||
/*
|
||||
Convert velocity into velocity per second
|
||||
*/
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const velocityPerSecond = (velocity, frameDuration) => frameDuration ? velocity * (1000 / frameDuration) : 0;
|
||||
|
||||
const warned = new Set();
|
||||
function hasWarned(message) {
|
||||
return warned.has(message);
|
||||
}
|
||||
function warnOnce(condition, message, errorCode) {
|
||||
if (condition || warned.has(message))
|
||||
return;
|
||||
console.warn(formatErrorMessage(message, errorCode));
|
||||
warned.add(message);
|
||||
}
|
||||
|
||||
const wrap = (min, max, v) => {
|
||||
const rangeSize = max - min;
|
||||
return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
|
||||
};
|
||||
|
||||
/*
|
||||
Bezier function generator
|
||||
This has been modified from Gaëtan Renaudeau's BezierEasing
|
||||
https://github.com/gre/bezier-easing/blob/master/src/index.js
|
||||
https://github.com/gre/bezier-easing/blob/master/LICENSE
|
||||
|
||||
I've removed the newtonRaphsonIterate algo because in benchmarking it
|
||||
wasn't noticeably faster than binarySubdivision, indeed removing it
|
||||
usually improved times, depending on the curve.
|
||||
I also removed the lookup table, as for the added bundle size and loop we're
|
||||
only cutting ~4 or so subdivision iterations. I bumped the max iterations up
|
||||
to 12 to compensate and this still tended to be faster for no perceivable
|
||||
loss in accuracy.
|
||||
Usage
|
||||
const easeOut = cubicBezier(.17,.67,.83,.67);
|
||||
const x = easeOut(0.5); // returns 0.627...
|
||||
*/
|
||||
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
|
||||
const calcBezier = (t, a1, a2) => (((1.0 - 3.0 * a2 + 3.0 * a1) * t + (3.0 * a2 - 6.0 * a1)) * t + 3.0 * a1) *
|
||||
t;
|
||||
const subdivisionPrecision = 0.0000001;
|
||||
const subdivisionMaxIterations = 12;
|
||||
function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
|
||||
let currentX;
|
||||
let currentT;
|
||||
let i = 0;
|
||||
do {
|
||||
currentT = lowerBound + (upperBound - lowerBound) / 2.0;
|
||||
currentX = calcBezier(currentT, mX1, mX2) - x;
|
||||
if (currentX > 0.0) {
|
||||
upperBound = currentT;
|
||||
}
|
||||
else {
|
||||
lowerBound = currentT;
|
||||
}
|
||||
} while (Math.abs(currentX) > subdivisionPrecision &&
|
||||
++i < subdivisionMaxIterations);
|
||||
return currentT;
|
||||
}
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function cubicBezier(mX1, mY1, mX2, mY2) {
|
||||
// If this is a linear gradient, return linear easing
|
||||
if (mX1 === mY1 && mX2 === mY2)
|
||||
return noop;
|
||||
const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
|
||||
// If animation is at start/end, return t without easing
|
||||
return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
|
||||
}
|
||||
|
||||
// Accepts an easing function and returns a new one that outputs mirrored values for
|
||||
// the second half of the animation. Turns easeIn into easeInOut.
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const mirrorEasing = (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
|
||||
|
||||
// Accepts an easing function and returns a new one that outputs reversed values.
|
||||
// Turns easeIn into easeOut.
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const reverseEasing = (easing) => (p) => 1 - easing(1 - p);
|
||||
|
||||
const backOut = /*@__PURE__*/ cubicBezier(0.33, 1.53, 0.69, 0.99);
|
||||
const backIn = /*@__PURE__*/ reverseEasing(backOut);
|
||||
const backInOut = /*@__PURE__*/ mirrorEasing(backIn);
|
||||
|
||||
const anticipate = (p) => p >= 1
|
||||
? 1
|
||||
: (p *= 2) < 1
|
||||
? 0.5 * backIn(p)
|
||||
: 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
|
||||
|
||||
const circIn = (p) => 1 - Math.sin(Math.acos(p));
|
||||
const circOut = reverseEasing(circIn);
|
||||
const circInOut = mirrorEasing(circIn);
|
||||
|
||||
const easeIn = /*@__PURE__*/ cubicBezier(0.42, 0, 1, 1);
|
||||
const easeOut = /*@__PURE__*/ cubicBezier(0, 0, 0.58, 1);
|
||||
const easeInOut = /*@__PURE__*/ cubicBezier(0.42, 0, 0.58, 1);
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function steps(numSteps, direction = "end") {
|
||||
return (progress) => {
|
||||
progress =
|
||||
direction === "end"
|
||||
? Math.min(progress, 0.999)
|
||||
: Math.max(progress, 0.001);
|
||||
const expanded = progress * numSteps;
|
||||
const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
|
||||
return clamp(0, 1, rounded / numSteps);
|
||||
};
|
||||
}
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const isEasingArray = (ease) => {
|
||||
return Array.isArray(ease) && typeof ease[0] !== "number";
|
||||
};
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
function getEasingForSegment(easing, i) {
|
||||
return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
|
||||
}
|
||||
|
||||
/*#__NO_SIDE_EFFECTS__*/
|
||||
const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
|
||||
|
||||
const easingLookup = {
|
||||
linear: noop,
|
||||
easeIn,
|
||||
easeInOut,
|
||||
easeOut,
|
||||
circIn,
|
||||
circInOut,
|
||||
circOut,
|
||||
backIn,
|
||||
backInOut,
|
||||
backOut,
|
||||
anticipate,
|
||||
};
|
||||
const isValidEasing = (easing) => {
|
||||
return typeof easing === "string";
|
||||
};
|
||||
const easingDefinitionToFunction = (definition) => {
|
||||
if (isBezierDefinition(definition)) {
|
||||
// If cubic bezier definition, create bezier curve
|
||||
exports.invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`, "cubic-bezier-length");
|
||||
const [x1, y1, x2, y2] = definition;
|
||||
return cubicBezier(x1, y1, x2, y2);
|
||||
}
|
||||
else if (isValidEasing(definition)) {
|
||||
// Else lookup from table
|
||||
exports.invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`, "invalid-easing-type");
|
||||
return easingLookup[definition];
|
||||
}
|
||||
return definition;
|
||||
};
|
||||
|
||||
exports.MotionGlobalConfig = MotionGlobalConfig;
|
||||
exports.SubscriptionManager = SubscriptionManager;
|
||||
exports.addUniqueItem = addUniqueItem;
|
||||
exports.anticipate = anticipate;
|
||||
exports.backIn = backIn;
|
||||
exports.backInOut = backInOut;
|
||||
exports.backOut = backOut;
|
||||
exports.circIn = circIn;
|
||||
exports.circInOut = circInOut;
|
||||
exports.circOut = circOut;
|
||||
exports.clamp = clamp;
|
||||
exports.cubicBezier = cubicBezier;
|
||||
exports.easeIn = easeIn;
|
||||
exports.easeInOut = easeInOut;
|
||||
exports.easeOut = easeOut;
|
||||
exports.easingDefinitionToFunction = easingDefinitionToFunction;
|
||||
exports.getEasingForSegment = getEasingForSegment;
|
||||
exports.hasWarned = hasWarned;
|
||||
exports.isBezierDefinition = isBezierDefinition;
|
||||
exports.isEasingArray = isEasingArray;
|
||||
exports.isNumericalString = isNumericalString;
|
||||
exports.isObject = isObject;
|
||||
exports.isZeroValueString = isZeroValueString;
|
||||
exports.memo = memo;
|
||||
exports.millisecondsToSeconds = millisecondsToSeconds;
|
||||
exports.mirrorEasing = mirrorEasing;
|
||||
exports.moveItem = moveItem;
|
||||
exports.noop = noop;
|
||||
exports.pipe = pipe;
|
||||
exports.progress = progress;
|
||||
exports.removeItem = removeItem;
|
||||
exports.reverseEasing = reverseEasing;
|
||||
exports.secondsToMilliseconds = secondsToMilliseconds;
|
||||
exports.steps = steps;
|
||||
exports.velocityPerSecond = velocityPerSecond;
|
||||
exports.warnOnce = warnOnce;
|
||||
exports.wrap = wrap;
|
||||
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).MotionUtils={})}(this,function(n){"use strict";function t(n,t){-1===n.indexOf(t)&&n.push(t)}function e(n,t){const e=n.indexOf(t);e>-1&&n.splice(e,1)}const i=(n,t,e)=>e>t?t:e<n?n:e;function s(n,t){return t?`${n}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:n}n.warning=()=>{},n.invariant=()=>{},"undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&(n.warning=(n,t,e)=>{n||"undefined"==typeof console||console.warn(s(t,e))},n.invariant=(n,t,e)=>{if(!n)throw new Error(s(t,e))});const o=n=>n;const r=new Set;const c=(n,t,e)=>{const i=t-n;return((e-n)%i+i)%i+n},a=(n,t,e)=>(((1-3*e+3*t)*n+(3*e-6*t))*n+3*t)*n;function u(n,t,e,i){if(n===t&&e===i)return o;const s=t=>function(n,t,e,i,s){let o,r,c=0;do{r=t+(e-t)/2,o=a(r,i,s)-n,o>0?e=r:t=r}while(Math.abs(o)>1e-7&&++c<12);return r}(t,0,1,n,e);return n=>0===n||1===n?n:a(s(n),t,i)}const l=n=>t=>t<=.5?n(2*t)/2:(2-n(2*(1-t)))/2,f=n=>t=>1-n(1-t),p=u(.33,1.53,.69,.99),d=f(p),h=l(d),g=n=>n>=1?1:(n*=2)<1?.5*d(n):.5*(2-Math.pow(2,-10*(n-1))),b=n=>1-Math.sin(Math.acos(n)),m=f(b),y=l(b),v=u(.42,0,1,1),O=u(0,0,.58,1),I=u(.42,0,.58,1);const M=n=>Array.isArray(n)&&"number"!=typeof n[0];const w=n=>Array.isArray(n)&&"number"==typeof n[0],S={linear:o,easeIn:v,easeInOut:I,easeOut:O,circIn:b,circInOut:y,circOut:m,backIn:d,backInOut:h,backOut:p,anticipate:g};n.MotionGlobalConfig={},n.SubscriptionManager=class{constructor(){this.subscriptions=[]}add(n){return t(this.subscriptions,n),()=>e(this.subscriptions,n)}notify(n,t,e){const i=this.subscriptions.length;if(i)if(1===i)this.subscriptions[0](n,t,e);else for(let s=0;s<i;s++){const i=this.subscriptions[s];i&&i(n,t,e)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},n.addUniqueItem=t,n.anticipate=g,n.backIn=d,n.backInOut=h,n.backOut=p,n.circIn=b,n.circInOut=y,n.circOut=m,n.clamp=i,n.cubicBezier=u,n.easeIn=v,n.easeInOut=I,n.easeOut=O,n.easingDefinitionToFunction=t=>{if(w(t)){n.invariant(4===t.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,i,s,o]=t;return u(e,i,s,o)}return"string"==typeof t?(n.invariant(void 0!==S[t],`Invalid easing type '${t}'`,"invalid-easing-type"),S[t]):t},n.getEasingForSegment=function(n,t){return M(n)?n[c(0,n.length,t)]:n},n.hasWarned=function(n){return r.has(n)},n.isBezierDefinition=w,n.isEasingArray=M,n.isNumericalString=n=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n),n.isObject=n=>"object"==typeof n&&null!==n,n.isZeroValueString=n=>/^0[^.\s]+$/u.test(n),n.memo=function(n){let t;return()=>(void 0===t&&(t=n()),t)},n.millisecondsToSeconds=n=>n/1e3,n.mirrorEasing=l,n.moveItem=function([...n],t,e){const i=t<0?n.length+t:t;if(i>=0&&i<n.length){const i=e<0?n.length+e:e,[s]=n.splice(t,1);n.splice(i,0,s)}return n},n.noop=o,n.pipe=(...n)=>n.reduce((n,t)=>e=>t(n(e))),n.progress=(n,t,e)=>{const i=t-n;return i?(e-n)/i:1},n.removeItem=e,n.reverseEasing=f,n.secondsToMilliseconds=n=>1e3*n,n.steps=function(n,t="end"){return e=>{const s=(e="end"===t?Math.min(e,.999):Math.max(e,.001))*n,o="end"===t?Math.floor(s):Math.ceil(s);return i(0,1,o/n)}},n.velocityPerSecond=(n,t)=>t?n*(1e3/t):0,n.warnOnce=function(n,t,e){n||r.has(t)||(console.warn(s(t,e)),r.add(t))},n.wrap=c});
|
||||
Reference in New Issue
Block a user