chore: update map

This commit is contained in:
2026-02-19 08:55:45 +01:00
parent 3308adf1ea
commit 900c54c20b
1845 changed files with 3677 additions and 84269 deletions
+57 -6
View File
@@ -1,10 +1,61 @@
'use strict';
export { ReanimatedFlatList as FlatList } from './component/FlatList';
export { AnimatedImage as Image } from './component/Image';
export { AnimatedScrollView as ScrollView } from './component/ScrollView';
export { AnimatedText as Text } from './component/Text';
export { AnimatedView as View } from './component/View';
export { addWhitelistedNativeProps, addWhitelistedUIProps } from './ConfigHelper';
export { createAnimatedComponent } from './createAnimatedComponent';
export { AnimatedText as Text } from './reanimated2/component/Text';
export { AnimatedView as View } from './reanimated2/component/View';
export { AnimatedScrollView as ScrollView } from './reanimated2/component/ScrollView';
export { AnimatedImage as Image } from './reanimated2/component/Image';
export { ReanimatedFlatList as FlatList } from './reanimated2/component/FlatList';
export { addWhitelistedNativeProps, addWhitelistedUIProps } from './ConfigHelper';
/**
* @deprecated Please import `Extrapolate` directly from `react-native-reanimated` instead of `Animated` namespace.
*/
/**
* @deprecated Please import `SharedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
*/
/**
* @deprecated Please import `DerivedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
*/
/**
* @deprecated Please import `Adaptable` directly from `react-native-reanimated` instead of `Animated` namespace.
*/
/**
* @deprecated Please import `TransformStyleTypes` directly from `react-native-reanimated` instead of `Animated` namespace.
* */
/**
* @deprecated Please import `AdaptTransforms` directly from `react-native-reanimated` instead of `Animated` namespace.
* */
/**
* @deprecated Please import `AnimatedTransform` directly from `react-native-reanimated` instead of `Animated` namespace.
*/
/**
* @deprecated Please import `AnimateStyle` directly from `react-native-reanimated` instead of `Animated` namespace.
* */
/**
* @deprecated Please import `StylesOrDefault` directly from `react-native-reanimated` instead of `Animated` namespace.
* */
/**
* @deprecated Please import `AnimateProps` directly from `react-native-reanimated` instead of `Animated` namespace.
* */
/**
* @deprecated Please import `EasingFunction` directly from `react-native-reanimated` instead of `Animated` namespace.
* */
/**
* @deprecated Please import `AnimatedScrollViewProps` directly from `react-native-reanimated` instead of `Animated` namespace.
* */
/**
* @deprecated Please import `FlatListPropsWithLayout` directly from `react-native-reanimated` instead of `Animated` namespace.
* */
//# sourceMappingURL=Animated.js.map
@@ -1 +1 @@
{"version":3,"names":["ReanimatedFlatList","FlatList","AnimatedImage","Image","AnimatedScrollView","ScrollView","AnimatedText","Text","AnimatedView","View","addWhitelistedNativeProps","addWhitelistedUIProps","createAnimatedComponent"],"sourceRoot":"../../src","sources":["Animated.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,kBAAkB,IAAIC,QAAQ,QAAQ,sBAAsB;AACrE,SAASC,aAAa,IAAIC,KAAK,QAAQ,mBAAmB;AAC1D,SAASC,kBAAkB,IAAIC,UAAU,QAAQ,wBAAwB;AACzE,SAASC,YAAY,IAAIC,IAAI,QAAQ,kBAAkB;AACvD,SAASC,YAAY,IAAIC,IAAI,QAAQ,kBAAkB;AACvD,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,gBAAgB;AACvB,SAASC,uBAAuB,QAAQ,2BAA2B","ignoreList":[]}
{"version":3,"names":["createAnimatedComponent","AnimatedText","Text","AnimatedView","View","AnimatedScrollView","ScrollView","AnimatedImage","Image","ReanimatedFlatList","FlatList","addWhitelistedNativeProps","addWhitelistedUIProps"],"sources":["Animated.ts"],"sourcesContent":["'use strict';\nimport type { Extrapolate as _Extrapolate } from './reanimated2/interpolateColor';\nimport type { SharedValue as _SharedValue } from './reanimated2/commonTypes';\nimport type { DerivedValue as _DerivedValue } from './reanimated2/hook/useDerivedValue';\nimport type {\n TransformStyleTypes as _TransformStyleTypes,\n Adaptable as _Adaptable,\n AdaptTransforms as _AdaptTransforms,\n AnimatedTransform as _AnimatedTransform,\n AnimateStyle as _AnimateStyle,\n StylesOrDefault as _StylesOrDefault,\n AnimateProps as _AnimateProps,\n} from './reanimated2/helperTypes';\nimport type { EasingFunction as _EasingFunction } from './reanimated2/Easing';\n\nimport type { AnimatedScrollViewProps as _AnimatedScrollViewProps } from './reanimated2/component/ScrollView';\nimport type { FlatListPropsWithLayout as _FlatListPropsWithLayout } from './reanimated2/component/FlatList';\n\nexport { createAnimatedComponent } from './createAnimatedComponent';\nexport { AnimatedText as Text } from './reanimated2/component/Text';\nexport { AnimatedView as View } from './reanimated2/component/View';\nexport { AnimatedScrollView as ScrollView } from './reanimated2/component/ScrollView';\nexport { AnimatedImage as Image } from './reanimated2/component/Image';\nexport { ReanimatedFlatList as FlatList } from './reanimated2/component/FlatList';\nexport {\n addWhitelistedNativeProps,\n addWhitelistedUIProps,\n} from './ConfigHelper';\n/**\n * @deprecated Please import `Extrapolate` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\nexport type Extrapolate = typeof _Extrapolate;\n/**\n * @deprecated Please import `SharedValue` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\n\nexport type SharedValue<T> = _SharedValue<T>;\n/**\n * @deprecated Please import `DerivedValue` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\nexport type DerivedValue<T> = _DerivedValue<T>;\n/**\n * @deprecated Please import `Adaptable` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\nexport type Adaptable<T> = _Adaptable<T>;\n/**\n * @deprecated Please import `TransformStyleTypes` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type TransformStyleTypes = _TransformStyleTypes;\n/**\n * @deprecated Please import `AdaptTransforms` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type AdaptTransforms<T> = _AdaptTransforms<T>;\n/**\n * @deprecated Please import `AnimatedTransform` directly from `react-native-reanimated` instead of `Animated` namespace.\n */\nexport type AnimatedTransform = _AnimatedTransform;\n/**\n * @deprecated Please import `AnimateStyle` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type AnimateStyle<S> = _AnimateStyle<S>;\n/**\n * @deprecated Please import `StylesOrDefault` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type StylesOrDefault<S> = _StylesOrDefault<S>;\n/**\n * @deprecated Please import `AnimateProps` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type AnimateProps<P extends object> = _AnimateProps<P>;\n/**\n * @deprecated Please import `EasingFunction` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type EasingFunction = _EasingFunction;\n/**\n * @deprecated Please import `AnimatedScrollViewProps` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type AnimatedScrollViewProps = _AnimatedScrollViewProps;\n/**\n * @deprecated Please import `FlatListPropsWithLayout` directly from `react-native-reanimated` instead of `Animated` namespace.\n * */\nexport type FlatListPropsWithLayout<T> = _FlatListPropsWithLayout<T>;\n"],"mappings":"AAAA,YAAY;;AAkBZ,SAASA,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,YAAY,IAAIC,IAAI,QAAQ,8BAA8B;AACnE,SAASC,YAAY,IAAIC,IAAI,QAAQ,8BAA8B;AACnE,SAASC,kBAAkB,IAAIC,UAAU,QAAQ,oCAAoC;AACrF,SAASC,aAAa,IAAIC,KAAK,QAAQ,+BAA+B;AACtE,SAASC,kBAAkB,IAAIC,QAAQ,QAAQ,kCAAkC;AACjF,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,gBAAgB;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA"}
@@ -1,136 +0,0 @@
'use strict';
import { ReanimatedError } from './common';
/**
* https://github.com/gre/bezier-easing BezierEasing - use bezier curve for
* transition easing function by Gaëtan Renaudeau 2014 - 2015 MIT License
*/
// These values are established by empiricism with tests (tradeoff: performance VS precision)
const NEWTON_ITERATIONS = 4;
const NEWTON_MIN_SLOPE = 0.001;
const SUBDIVISION_PRECISION = 0.0000001;
const SUBDIVISION_MAX_ITERATIONS = 10;
const kSplineTableSize = 11;
const kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
function A(aA1, aA2) {
'worklet';
return 1.0 - 3.0 * aA2 + 3.0 * aA1;
}
function B(aA1, aA2) {
'worklet';
return 3.0 * aA2 - 6.0 * aA1;
}
function C(aA1) {
'worklet';
return 3.0 * aA1;
}
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
function calcBezier(aT, aA1, aA2) {
'worklet';
return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
}
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
function getSlope(aT, aA1, aA2) {
'worklet';
return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
}
function binarySubdivide(aX, aA, aB, mX1, mX2) {
'worklet';
let currentX;
let currentT;
let i = 0;
do {
currentT = aA + (aB - aA) / 2.0;
currentX = calcBezier(currentT, mX1, mX2) - aX;
if (currentX > 0.0) {
aB = currentT;
} else {
aA = currentT;
}
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
return currentT;
}
function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
'worklet';
for (let i = 0; i < NEWTON_ITERATIONS; ++i) {
const currentSlope = getSlope(aGuessT, mX1, mX2);
if (currentSlope === 0.0) {
return aGuessT;
}
const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
aGuessT -= currentX / currentSlope;
}
return aGuessT;
}
export function Bezier(mX1, mY1, mX2, mY2) {
'worklet';
function LinearEasing(x) {
'worklet';
return x;
}
if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) {
throw new ReanimatedError('Bezier x values must be in [0, 1] range.');
}
if (mX1 === mY1 && mX2 === mY2) {
return LinearEasing;
}
const sampleValues = new Array(kSplineTableSize);
// Precompute samples table
for (let i = 0; i < kSplineTableSize; ++i) {
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
}
function getTForX(aX) {
'worklet';
let intervalStart = 0.0;
let currentSample = 1;
const lastSample = kSplineTableSize - 1;
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
intervalStart += kSampleStepSize;
}
--currentSample;
// Interpolate to provide an initial guess for t
const dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
const guessForT = intervalStart + dist * kSampleStepSize;
const initialSlope = getSlope(guessForT, mX1, mX2);
if (initialSlope >= NEWTON_MIN_SLOPE) {
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
} else if (initialSlope === 0.0) {
return guessForT;
} else {
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
}
}
return function BezierEasing(x) {
'worklet';
if (mX1 === mY1 && mX2 === mY2) {
return x; // linear
}
// Because JavaScript number are imprecise, we should guarantee the extremes are right.
if (x === 0) {
return 0;
}
if (x === 1) {
return 1;
}
return calcBezier(getTForX(x), mY1, mY2);
};
}
//# sourceMappingURL=Bezier.js.map
@@ -1 +0,0 @@
{"version":3,"names":["ReanimatedError","NEWTON_ITERATIONS","NEWTON_MIN_SLOPE","SUBDIVISION_PRECISION","SUBDIVISION_MAX_ITERATIONS","kSplineTableSize","kSampleStepSize","A","aA1","aA2","B","C","calcBezier","aT","getSlope","binarySubdivide","aX","aA","aB","mX1","mX2","currentX","currentT","i","Math","abs","newtonRaphsonIterate","aGuessT","currentSlope","Bezier","mY1","mY2","LinearEasing","x","sampleValues","Array","getTForX","intervalStart","currentSample","lastSample","dist","guessForT","initialSlope","BezierEasing"],"sourceRoot":"../../src","sources":["Bezier.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,eAAe,QAAQ,UAAU;;AAE1C;AACA;AACA;AACA;;AAEA;;AAEA,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,gBAAgB,GAAG,KAAK;AAC9B,MAAMC,qBAAqB,GAAG,SAAS;AACvC,MA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GAAG/B,eAAe,EAC/Ba,GAAG,EACHC,GACF,CAAC;IACH;EACF;EAEA,OAAO,SAASuB,YAAYA,CAACV,CAAC,EAAE;IAC9B,SAAS;;IACT,IAAId,GAAG,KAAKW,GAAG,IAAIV,GAAG,KAAKW,GAAG,EAAE;MAC9B,OAAOE,CAAC,CAAC,CAAC;IACZ;IACA;IACA,IAAIA,CAAC,KAAK,CAAC,EAAE;MACX,OAAO,CAAC;IACV;IACA,IAAIA,CAAC,KAAK,CAAC,EAAE;MACX,OAAO,CAAC;IACV;IACA,OAAOrB,UAAU,CAACwB,QAAQ,CAACH,CAAC,CAAC,EAAEH,GAAG,EAAEC,GAAG,CAAC;EAC1C,CAAC;AACH","ignoreList":[]}
@@ -1,593 +0,0 @@
'use strict';
/**
* Copied from: react-native/Libraries/StyleSheet/normalizeColor.js
* react-native/Libraries/StyleSheet/processColor.js
* https://github.com/wcandillon/react-native-redash/blob/master/src/Colors.ts
*/
/* eslint no-bitwise: 0 */
const NUMBER = '[-+]?\\d*\\.?\\d+';
const PERCENTAGE = NUMBER + '%';
function call(...args) {
return '\\(\\s*(' + args.join(')\\s*,?\\s*(') + ')\\s*\\)';
}
function callWithSlashSeparator(...args) {
return '\\(\\s*(' + args.slice(0, args.length - 1).join(')\\s*,?\\s*(') + ')\\s*/\\s*(' + args[args.length - 1] + ')\\s*\\)';
}
function commaSeparatedCall(...args) {
return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
}
const MATCHERS = {
rgb: new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER)),
rgba: new RegExp('rgba(' + commaSeparatedCall(NUMBER, NUMBER, NUMBER, NUMBER) + '|' + callWithSlashSeparator(NUMBER, NUMBER, NUMBER, NUMBER) + ')'),
hsl: new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE)),
hsla: new RegExp('hsla(' + commaSeparatedCall(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER) + '|' + callWithSlashSeparator(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER) + ')'),
hwb: new RegExp('hwb' + call(NUMBER, PERCENTAGE, PERCENTAGE)),
hex3: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex4: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^#([0-9a-fA-F]{6})$/,
hex8: /^#([0-9a-fA-F]{8})$/
};
function hue2rgb(p, q, t) {
'worklet';
if (t < 0) {
t += 1;
}
if (t > 1) {
t -= 1;
}
if (t < 1 / 6) {
return p + (q - p) * 6 * t;
}
if (t < 1 / 2) {
return q;
}
if (t < 2 / 3) {
return p + (q - p) * (2 / 3 - t) * 6;
}
return p;
}
function hslToRgb(h, s, l) {
'worklet';
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
const p = 2 * l - q;
const r = hue2rgb(p, q, h + 1 / 3);
const g = hue2rgb(p, q, h);
const b = hue2rgb(p, q, h - 1 / 3);
return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
}
function hwbToRgb(h, w, b) {
'worklet';
if (w + b >= 1) {
const gray = Math.round(w * 255 / (w + b));
return gray << 24 | gray << 16 | gray << 8;
}
const red = hue2rgb(0, 1, h + 1 / 3) * (1 - w - b) + w;
const green = hue2rgb(0, 1, h) * (1 - w - b) + w;
const blue = hue2rgb(0, 1, h - 1 / 3) * (1 - w - b) + w;
return Math.round(red * 255) << 24 | Math.round(green * 255) << 16 | Math.round(blue * 255) << 8;
}
function parse255(str) {
'worklet';
const int = Number.parseInt(str, 10);
if (int < 0) {
return 0;
}
if (int > 255) {
return 255;
}
return int;
}
function parse360(str) {
'worklet';
const int = Number.parseFloat(str);
return (int % 360 + 360) % 360 / 360;
}
function parse1(str) {
'worklet';
const num = Number.parseFloat(str);
if (num < 0) {
return 0;
}
if (num > 1) {
return 255;
}
return Math.round(num * 255);
}
function parsePercentage(str) {
'worklet';
// parseFloat conveniently ignores the final %
const int = Number.parseFloat(str);
if (int < 0) {
return 0;
}
if (int > 100) {
return 1;
}
return int / 100;
}
export function clampRGBA(RGBA) {
'worklet';
for (let i = 0; i < 4; i++) {
RGBA[i] = Math.max(0, Math.min(RGBA[i], 1));
}
}
const names = {
transparent: undefined,
/* spell-checker: disable */
// http://www.w3.org/TR/css3-color/#svg-color
aliceblue: 0xf0f8ffff,
antiquewhite: 0xfaebd7ff,
aqua: 0x00ffffff,
aquamarine: 0x7fffd4ff,
azure: 0xf0ffffff,
beige: 0xf5f5dcff,
bisque: 0xffe4c4ff,
black: 0x000000ff,
blanchedalmond: 0xffebcdff,
blue: 0x0000ffff,
blueviolet: 0x8a2be2ff,
brown: 0xa52a2aff,
burlywood: 0xdeb887ff,
burntsienna: 0xea7e5dff,
cadetblue: 0x5f9ea0ff,
chartreuse: 0x7fff00ff,
chocolate: 0xd2691eff,
coral: 0xff7f50ff,
cornflowerblue: 0x6495edff,
cornsilk: 0xfff8dcff,
crimson: 0xdc143cff,
cyan: 0x00ffffff,
darkblue: 0x00008bff,
darkcyan: 0x008b8bff,
darkgoldenrod: 0xb8860bff,
darkgray: 0xa9a9a9ff,
darkgreen: 0x006400ff,
darkgrey: 0xa9a9a9ff,
darkkhaki: 0xbdb76bff,
darkmagenta: 0x8b008bff,
darkolivegreen: 0x556b2fff,
darkorange: 0xff8c00ff,
darkorchid: 0x9932ccff,
darkred: 0x8b0000ff,
darksalmon: 0xe9967aff,
darkseagreen: 0x8fbc8fff,
darkslateblue: 0x483d8bff,
darkslategray: 0x2f4f4fff,
darkslategrey: 0x2f4f4fff,
darkturquoise: 0x00ced1ff,
darkviolet: 0x9400d3ff,
deeppink: 0xff1493ff,
deepskyblue: 0x00bfffff,
dimgray: 0x696969ff,
dimgrey: 0x696969ff,
dodgerblue: 0x1e90ffff,
firebrick: 0xb22222ff,
floralwhite: 0xfffaf0ff,
forestgreen: 0x228b22ff,
fuchsia: 0xff00ffff,
gainsboro: 0xdcdcdcff,
ghostwhite: 0xf8f8ffff,
gold: 0xffd700ff,
goldenrod: 0xdaa520ff,
gray: 0x808080ff,
green: 0x008000ff,
greenyellow: 0xadff2fff,
grey: 0x808080ff,
honeydew: 0xf0fff0ff,
hotpink: 0xff69b4ff,
indianred: 0xcd5c5cff,
indigo: 0x4b0082ff,
ivory: 0xfffff0ff,
khaki: 0xf0e68cff,
lavender: 0xe6e6faff,
lavenderblush: 0xfff0f5ff,
lawngreen: 0x7cfc00ff,
lemonchiffon: 0xfffacdff,
lightblue: 0xadd8e6ff,
lightcoral: 0xf08080ff,
lightcyan: 0xe0ffffff,
lightgoldenrodyellow: 0xfafad2ff,
lightgray: 0xd3d3d3ff,
lightgreen: 0x90ee90ff,
lightgrey: 0xd3d3d3ff,
lightpink: 0xffb6c1ff,
lightsalmon: 0xffa07aff,
lightseagreen: 0x20b2aaff,
lightskyblue: 0x87cefaff,
lightslategray: 0x778899ff,
lightslategrey: 0x778899ff,
lightsteelblue: 0xb0c4deff,
lightyellow: 0xffffe0ff,
lime: 0x00ff00ff,
limegreen: 0x32cd32ff,
linen: 0xfaf0e6ff,
magenta: 0xff00ffff,
maroon: 0x800000ff,
mediumaquamarine: 0x66cdaaff,
mediumblue: 0x0000cdff,
mediumorchid: 0xba55d3ff,
mediumpurple: 0x9370dbff,
mediumseagreen: 0x3cb371ff,
mediumslateblue: 0x7b68eeff,
mediumspringgreen: 0x00fa9aff,
mediumturquoise: 0x48d1ccff,
mediumvioletred: 0xc71585ff,
midnightblue: 0x191970ff,
mintcream: 0xf5fffaff,
mistyrose: 0xffe4e1ff,
moccasin: 0xffe4b5ff,
navajowhite: 0xffdeadff,
navy: 0x000080ff,
oldlace: 0xfdf5e6ff,
olive: 0x808000ff,
olivedrab: 0x6b8e23ff,
orange: 0xffa500ff,
orangered: 0xff4500ff,
orchid: 0xda70d6ff,
palegoldenrod: 0xeee8aaff,
palegreen: 0x98fb98ff,
paleturquoise: 0xafeeeeff,
palevioletred: 0xdb7093ff,
papayawhip: 0xffefd5ff,
peachpuff: 0xffdab9ff,
peru: 0xcd853fff,
pink: 0xffc0cbff,
plum: 0xdda0ddff,
powderblue: 0xb0e0e6ff,
purple: 0x800080ff,
rebeccapurple: 0x663399ff,
red: 0xff0000ff,
rosybrown: 0xbc8f8fff,
royalblue: 0x4169e1ff,
saddlebrown: 0x8b4513ff,
salmon: 0xfa8072ff,
sandybrown: 0xf4a460ff,
seagreen: 0x2e8b57ff,
seashell: 0xfff5eeff,
sienna: 0xa0522dff,
silver: 0xc0c0c0ff,
skyblue: 0x87ceebff,
slateblue: 0x6a5acdff,
slategray: 0x708090ff,
slategrey: 0x708090ff,
snow: 0xfffafaff,
springgreen: 0x00ff7fff,
steelblue: 0x4682b4ff,
tan: 0xd2b48cff,
teal: 0x008080ff,
thistle: 0xd8bfd8ff,
tomato: 0xff6347ff,
turquoise: 0x40e0d0ff,
violet: 0xee82eeff,
wheat: 0xf5deb3ff,
white: 0xffffffff,
whitesmoke: 0xf5f5f5ff,
yellow: 0xffff00ff,
yellowgreen: 0x9acd32ff
/* spell-checker: enable */
};
// copied from react-native/Libraries/Components/View/ReactNativeStyleAttributes
export const ColorProperties = ['backgroundColor', 'borderBottomColor', 'borderColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'borderStartColor', 'borderEndColor', 'borderBlockColor', 'borderBlockEndColor', 'borderBlockStartColor', 'color', 'outlineColor', 'placeholderTextColor', 'shadowColor', 'textDecorationColor', 'tintColor', 'textShadowColor', 'overlayColor',
// SVG color properties
'fill', 'floodColor', 'lightingColor', 'stopColor', 'stroke'];
export function normalizeColor(color) {
'worklet';
if (typeof color === 'number') {
if (color >>> 0 === color && color >= 0 && color <= 0xffffffff) {
return color;
}
return null;
}
if (typeof color !== 'string') {
return null;
}
let match;
// Ordered based on occurrences on Facebook codebase
if (match = MATCHERS.hex6.exec(color)) {
return Number.parseInt(match[1] + 'ff', 16) >>> 0;
}
if (color in names) {
return names[color];
}
if (match = MATCHERS.rgb.exec(color)) {
return (
// b
(parse255(match[1]) << 24 |
// r
parse255(match[2]) << 16 |
// g
parse255(match[3]) << 8 | 0x000000ff) >>>
// a
0
);
}
if (match = MATCHERS.rgba.exec(color)) {
// rgba(R G B / A) notation
if (match[6] !== undefined) {
return (parse255(match[6]) << 24 |
// r
parse255(match[7]) << 16 |
// g
parse255(match[8]) << 8 |
// b
parse1(match[9])) >>>
// a
0;
}
// rgba(R, G, B, A) notation
return (parse255(match[2]) << 24 |
// r
parse255(match[3]) << 16 |
// g
parse255(match[4]) << 8 |
// b
parse1(match[5])) >>>
// a
0;
}
if (match = MATCHERS.hex3.exec(color)) {
return Number.parseInt(match[1] + match[1] +
// r
match[2] + match[2] +
// g
match[3] + match[3] +
// b
'ff',
// a
16) >>> 0;
}
// https://drafts.csswg.org/css-color-4/#hex-notation
if (match = MATCHERS.hex8.exec(color)) {
return Number.parseInt(match[1], 16) >>> 0;
}
if (match = MATCHERS.hex4.exec(color)) {
return Number.parseInt(match[1] + match[1] +
// r
match[2] + match[2] +
// g
match[3] + match[3] +
// b
match[4] + match[4],
// a
16) >>> 0;
}
if (match = MATCHERS.hsl.exec(color)) {
return (hslToRgb(parse360(match[1]),
// h
parsePercentage(match[2]),
// s
parsePercentage(match[3]) // l
) | 0x000000ff) >>>
// a
0;
}
if (match = MATCHERS.hsla.exec(color)) {
// hsla(H S L / A) notation
if (match[6] !== undefined) {
return (hslToRgb(parse360(match[6]),
// h
parsePercentage(match[7]),
// s
parsePercentage(match[8]) // l
) | parse1(match[9])) >>>
// a
0;
}
// hsla(H, S, L, A) notation
return (hslToRgb(parse360(match[2]),
// h
parsePercentage(match[3]),
// s
parsePercentage(match[4]) // l
) | parse1(match[5])) >>>
// a
0;
}
if (match = MATCHERS.hwb.exec(color)) {
return (hwbToRgb(parse360(match[1]),
// h
parsePercentage(match[2]),
// w
parsePercentage(match[3]) // b
) | 0x000000ff) >>>
// a
0;
}
return null;
}
export const opacity = c => {
'worklet';
return (c >> 24 & 255) / 255;
};
export const red = c => {
'worklet';
return c >> 16 & 255;
};
export const green = c => {
'worklet';
return c >> 8 & 255;
};
export const blue = c => {
'worklet';
return c & 255;
};
export const rgbaColor = (r, g, b, alpha = 1) => {
'worklet';
// Round alpha to 3 decimal places to avoid floating point precision issues
const safeAlpha = Math.round(alpha * 1000) / 1000;
return `rgba(${r}, ${g}, ${b}, ${safeAlpha})`;
};
/**
* @param r - Red value (0-255)
* @param g - Green value (0-255)
* @param b - Blue value (0-255)
* @returns `{h: hue (0-1), s: saturation (0-1), v: value (0-1)}`
*/
export function RGBtoHSV(r, g, b) {
'worklet';
const max = Math.max(r, g, b);
const min = Math.min(r, g, b);
const d = max - min;
const s = max === 0 ? 0 : d / max;
const v = max / 255;
let h = 0;
switch (max) {
case min:
break;
case r:
h = g - b + d * (g < b ? 6 : 0);
h /= 6 * d;
break;
case g:
h = b - r + d * 2;
h /= 6 * d;
break;
case b:
h = r - g + d * 4;
h /= 6 * d;
break;
}
return {
h,
s,
v
};
}
/**
* @param h - Hue (0-1)
* @param s - Saturation (0-1)
* @param v - Value (0-1)
* @returns `{r: red (0-255), g: green (0-255), b: blue (0-255)}`
*/
function HSVtoRGB(h, s, v) {
'worklet';
let r, g, b;
const i = Math.floor(h * 6);
const f = h * 6 - i;
const p = v * (1 - s);
const q = v * (1 - f * s);
const t = v * (1 - (1 - f) * s);
switch (i % 6) {
case 0:
[r, g, b] = [v, t, p];
break;
case 1:
[r, g, b] = [q, v, p];
break;
case 2:
[r, g, b] = [p, v, t];
break;
case 3:
[r, g, b] = [p, q, v];
break;
case 4:
[r, g, b] = [t, p, v];
break;
case 5:
[r, g, b] = [v, p, q];
break;
}
return {
r: Math.round(r * 255),
g: Math.round(g * 255),
b: Math.round(b * 255)
};
}
export const hsvToColor = (h, s, v, a) => {
'worklet';
const {
r,
g,
b
} = HSVtoRGB(h, s, v);
return rgbaColor(r, g, b, a);
};
export function processColorInitially(color) {
'worklet';
if (color === null || color === undefined) {
return color;
}
let colorNumber;
if (typeof color === 'number') {
colorNumber = color;
} else {
const normalizedColor = normalizeColor(color);
if (typeof normalizedColor !== 'number') {
return normalizedColor;
}
colorNumber = normalizedColor;
}
return (colorNumber << 24 | colorNumber >>> 8) >>> 0; // alpha rgb
}
export function isColor(value) {
'worklet';
if (typeof value !== 'string') {
return false;
}
return processColorInitially(value) != null;
}
export function convertToRGBA(color) {
'worklet';
const processedColor = processColorInitially(color); // alpha rgb;
const a = (processedColor >>> 24) / 255;
const r = (processedColor << 8 >>> 24) / 255;
const g = (processedColor << 16 >>> 24) / 255;
const b = (processedColor << 24 >>> 24) / 255;
return [r, g, b, a];
}
export function rgbaArrayToRGBAColor(RGBA) {
'worklet';
const alpha = RGBA[3] < 0.001 ? 0 : RGBA[3];
return `rgba(${Math.round(RGBA[0] * 255)}, ${Math.round(RGBA[1] * 255)}, ${Math.round(RGBA[2] * 255)}, ${alpha})`;
}
export function toLinearSpace(RGBA, gamma = 2.2) {
'worklet';
const res = [];
for (let i = 0; i < 3; ++i) {
res.push(Math.pow(RGBA[i], gamma));
}
res.push(RGBA[3]);
return res;
}
export function toGammaSpace(RGBA, gamma = 2.2) {
'worklet';
const res = [];
for (let i = 0; i < 3; ++i) {
res.push(Math.pow(RGBA[i], 1 / gamma));
}
res.push(RGBA[3]);
return res;
}
//# sourceMappingURL=Colors.js.map
File diff suppressed because one or more lines are too long
@@ -1,35 +1,61 @@
'use strict';
import { executeOnUIRuntimeSync } from 'react-native-worklets';
import { getLoggerConfig, SHOULD_BE_USE_WEB, updateLoggerConfig } from './common';
/** @deprecated This function is a no-op in Reanimated 4. */
export function addWhitelistedNativeProps(_props) {
// Do nothing. This is just for backward compatibility.
}
/** @deprecated This function is a no-op in Reanimated 4. */
export function addWhitelistedUIProps(_props) {
// Do nothing. This is just for backward compatibility.
}
/**
* Updates Reanimated logger config with the user-provided configuration. Will
* affect Reanimated code executed after call to this function so it should be
* called before any Reanimated code is executed to take effect. Each call to
* this function will override the previous configuration (it's recommended to
* call it only once).
*
* @param config - The new logger configuration to apply.
*/
export function configureReanimatedLogger(config) {
// Get the current config from the React runtime (to have a single source of truth)
const currentConfig = getLoggerConfig();
// Update the configuration object in the React runtime
updateLoggerConfig(currentConfig, config);
// Register the updated configuration in the UI runtime
if (!SHOULD_BE_USE_WEB) {
executeOnUIRuntimeSync(updateLoggerConfig)(currentConfig, config);
import { PropsAllowlists } from './propsAllowlists';
import { jsiConfigureProps } from './reanimated2/core';
function assertNoOverlapInLists() {
for (const key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) {
if (key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST) {
throw new Error(`[Reanimated] Property \`${key}\` was whitelisted both as UI and native prop. Please remove it from one of the lists.`);
}
}
}
function configureProps() {
assertNoOverlapInLists();
jsiConfigureProps(Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST), Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST));
}
export function addWhitelistedNativeProps(props) {
const oldSize = Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST).length;
PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST = {
...PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST,
...props
};
if (oldSize !== Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST).length) {
configureProps();
}
}
export function addWhitelistedUIProps(props) {
const oldSize = Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length;
PropsAllowlists.UI_THREAD_PROPS_WHITELIST = {
...PropsAllowlists.UI_THREAD_PROPS_WHITELIST,
...props
};
if (oldSize !== Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length) {
configureProps();
}
}
const PROCESSED_VIEW_NAMES = new Set();
/**
* updates UI props whitelist for given view host instance
* this will work just once for every view name
*/
export function adaptViewConfig(viewConfig) {
const viewName = viewConfig.uiViewClassName;
const props = viewConfig.validAttributes;
// update whitelist of UI props for this view name only once
if (!PROCESSED_VIEW_NAMES.has(viewName)) {
const propsToAdd = {};
Object.keys(props).forEach(key => {
// we don't want to add native props as they affect layout
// we also skip props which repeat here
if (!(key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) && !(key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST)) {
propsToAdd[key] = true;
}
});
addWhitelistedUIProps(propsToAdd);
PROCESSED_VIEW_NAMES.add(viewName);
}
}
configureProps();
//# sourceMappingURL=ConfigHelper.js.map
@@ -1 +1 @@
{"version":3,"names":["executeOnUIRuntimeSync","getLoggerConfig","SHOULD_BE_USE_WEB","updateLoggerConfig","addWhitelistedNativeProps","_props","addWhitelistedUIProps","configureReanimatedLogger","config","currentConfig"],"sourceRoot":"../../src","sources":["ConfigHelper.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,sBAAsB,QAAQ,uBAAuB;AAG9D,SACEC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,QACb,UAAU;;AAEjB;AACA,OAAO,SAASC,yBAAyBA,CACvCC,MAA+B,EACzB;EACN;AAAA;;AAGF;AACA,OAAO,SAASC,qBAAqBA,CAACD,MAA+B,EAAQ;EAC3E;AAAA;;AAGF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,yBAAyBA,CAACC,MAAoB,EAAE;EAC9D;EACA,MAAMC,aAAa,GAAGR,eAAe,CAAC,CAAC;EACvC;EACAE,kBAAkB,CAACM,aAAa,EAAED,MAAM,CAAC;EACzC;EACA,IAAI,CAACN,iBAAiB,EAAE;IACtBF,sBAAsB,CAACG,kBAAkB,CAAC,CAACM,aAAa,EAAED,MAAM,CAAC;EACnE;AACF","ignoreList":[]}
{"version":3,"names":["PropsAllowlists","jsiConfigureProps","assertNoOverlapInLists","key","NATIVE_THREAD_PROPS_WHITELIST","UI_THREAD_PROPS_WHITELIST","Error","configureProps","Object","keys","addWhitelistedNativeProps","props","oldSize","length","addWhitelistedUIProps","PROCESSED_VIEW_NAMES","Set","adaptViewConfig","viewConfig","viewName","uiViewClassName","validAttributes","has","propsToAdd","forEach","add"],"sources":["ConfigHelper.ts"],"sourcesContent":["'use strict';\nimport { PropsAllowlists } from './propsAllowlists';\nimport { jsiConfigureProps } from './reanimated2/core';\nfunction assertNoOverlapInLists() {\n for (const key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) {\n if (key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST) {\n throw new Error(\n `[Reanimated] Property \\`${key}\\` was whitelisted both as UI and native prop. Please remove it from one of the lists.`\n );\n }\n }\n}\n\nfunction configureProps(): void {\n assertNoOverlapInLists();\n jsiConfigureProps(\n Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST),\n Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST)\n );\n}\n\nexport function addWhitelistedNativeProps(\n props: Record<string, boolean>\n): void {\n const oldSize = Object.keys(\n PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST\n ).length;\n PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST = {\n ...PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST,\n ...props,\n };\n if (\n oldSize !==\n Object.keys(PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST).length\n ) {\n configureProps();\n }\n}\n\nexport function addWhitelistedUIProps(props: Record<string, boolean>): void {\n const oldSize = Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length;\n PropsAllowlists.UI_THREAD_PROPS_WHITELIST = {\n ...PropsAllowlists.UI_THREAD_PROPS_WHITELIST,\n ...props,\n };\n if (\n oldSize !== Object.keys(PropsAllowlists.UI_THREAD_PROPS_WHITELIST).length\n ) {\n configureProps();\n }\n}\n\nconst PROCESSED_VIEW_NAMES = new Set();\n\nexport interface ViewConfig {\n uiViewClassName: string;\n validAttributes: Record<string, unknown>;\n}\n/**\n * updates UI props whitelist for given view host instance\n * this will work just once for every view name\n */\n\nexport function adaptViewConfig(viewConfig: ViewConfig): void {\n const viewName = viewConfig.uiViewClassName;\n const props = viewConfig.validAttributes;\n\n // update whitelist of UI props for this view name only once\n if (!PROCESSED_VIEW_NAMES.has(viewName)) {\n const propsToAdd: Record<string, boolean> = {};\n Object.keys(props).forEach((key) => {\n // we don't want to add native props as they affect layout\n // we also skip props which repeat here\n if (\n !(key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) &&\n !(key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST)\n ) {\n propsToAdd[key] = true;\n }\n });\n addWhitelistedUIProps(propsToAdd);\n\n PROCESSED_VIEW_NAMES.add(viewName);\n }\n}\n\nconfigureProps();\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,sBAAsBA,CAAA,EAAG;EAChC,KAAK,MAAMC,GAAG,IAAIH,eAAe,CAACI,6BAA6B,EAAE;IAC/D,IAAID,GAAG,IAAIH,eAAe,CAACK,yBAAyB,EAAE;MACpD,MAAM,IAAIC,KAAK,CACZ,2BAA0BH,GAAI,wFAAuF,CACvH;IACH;EACF;AACF;AAEA,SAASI,cAAcA,CAAA,EAAS;EAC9BL,sBAAsB,EAAE;EACxBD,iBAAiB,CACfO,MAAM,CAACC,IAAI,CAACT,eAAe,CAACK,yBAAyB,CAAC,EACtDG,MAAM,CAACC,IAAI,CAACT,eAAe,CAACI,6BAA6B,CAAC,CAC3D;AACH;AAEA,OAAO,SAASM,yBAAyBA,CACvCC,KAA8B,EACxB;EACN,MAAMC,OAAO,GAAGJ,MAAM,CAACC,IAAI,CACzBT,eAAe,CAACI,6BAA6B,CAC9C,CAACS,MAAM;EACRb,eAAe,CAACI,6BAA6B,GAAG;IAC9C,GAAGJ,eAAe,CAACI,6BAA6B;IAChD,GAAGO;EACL,CAAC;EACD,IACEC,OAAO,KACPJ,MAAM,CAACC,IAAI,CAACT,eAAe,CAACI,6BAA6B,CAAC,CAACS,MAAM,EACjE;IACAN,cAAc,EAAE;EAClB;AACF;AAEA,OAAO,SAASO,qBAAqBA,CAACH,KAA8B,EAAQ;EAC1E,MAAMC,OAAO,GAAGJ,MAAM,CAACC,IAAI,CAACT,eAAe,CAACK,yBAAyB,CAAC,CAACQ,MAAM;EAC7Eb,eAAe,CAACK,yBAAyB,GAAG;IAC1C,GAAGL,eAAe,CAACK,yBAAyB;IAC5C,GAAGM;EACL,CAAC;EACD,IACEC,OAAO,KAAKJ,MAAM,CAACC,IAAI,CAACT,eAAe,CAACK,yBAAyB,CAAC,CAACQ,MAAM,EACzE;IACAN,cAAc,EAAE;EAClB;AACF;AAEA,MAAMQ,oBAAoB,GAAG,IAAIC,GAAG,EAAE;AAMtC;AACA;AACA;AACA;;AAEA,OAAO,SAASC,eAAeA,CAACC,UAAsB,EAAQ;EAC5D,MAAMC,QAAQ,GAAGD,UAAU,CAACE,eAAe;EAC3C,MAAMT,KAAK,GAAGO,UAAU,CAACG,eAAe;;EAExC;EACA,IAAI,CAACN,oBAAoB,CAACO,GAAG,CAACH,QAAQ,CAAC,EAAE;IACvC,MAAMI,UAAmC,GAAG,CAAC,CAAC;IAC9Cf,MAAM,CAACC,IAAI,CAACE,KAAK,CAAC,CAACa,OAAO,CAAErB,GAAG,IAAK;MAClC;MACA;MACA,IACE,EAAEA,GAAG,IAAIH,eAAe,CAACI,6BAA6B,CAAC,IACvD,EAAED,GAAG,IAAIH,eAAe,CAACK,yBAAyB,CAAC,EACnD;QACAkB,UAAU,CAACpB,GAAG,CAAC,GAAG,IAAI;MACxB;IACF,CAAC,CAAC;IACFW,qBAAqB,CAACS,UAAU,CAAC;IAEjCR,oBAAoB,CAACU,GAAG,CAACN,QAAQ,CAAC;EACpC;AACF;AAEAZ,cAAc,EAAE"}
@@ -1,316 +0,0 @@
'use strict';
import { Bezier } from './Bezier';
/**
* The `Easing` module implements common easing functions. This module is used
* by [Animate.timing()](docs/animate.html#timing) to convey physically
* believable motion in animations.
*
* You can find a visualization of some common easing functions at
* http://easings.net/
*
* ### Predefined animations
*
* The `Easing` module provides several predefined animations through the
* following methods:
*
* - [`back`](docs/easing.html#back) provides a simple animation where the object
* goes slightly back before moving forward
* - [`bounce`](docs/easing.html#bounce) provides a bouncing animation
* - [`ease`](docs/easing.html#ease) provides a simple inertial animation
* - [`elastic`](docs/easing.html#elastic) provides a simple spring interaction
*
* ### Standard functions
*
* Three standard easing functions are provided:
*
* - [`linear`](docs/easing.html#linear)
* - [`quad`](docs/easing.html#quad)
* - [`cubic`](docs/easing.html#cubic)
*
* The [`poly`](docs/easing.html#poly) function can be used to implement
* quartic, quintic, and other higher power functions.
*
* ### Additional functions
*
* Additional mathematical functions are provided by the following methods:
*
* - [`bezier`](docs/easing.html#bezier) provides a cubic bezier curve
* - [`circle`](docs/easing.html#circle) provides a circular function
* - [`sin`](docs/easing.html#sin) provides a sinusoidal function
* - [`exp`](docs/easing.html#exp) provides an exponential function
*
* The following helpers are used to modify other easing functions.
*
* - [`in`](docs/easing.html#in) runs an easing function forwards
* - [`inOut`](docs/easing.html#inout) makes any easing function symmetrical
* - [`out`](docs/easing.html#out) runs an easing function backwards
*/
/**
* A linear function, `f(t) = t`. Position correlates to elapsed time one to
* one.
*
* http://cubic-bezier.com/#0,0,1,1
*/
function linear(t) {
'worklet';
return t;
}
/**
* A simple inertial interaction, similar to an object slowly accelerating to
* speed.
*
* http://cubic-bezier.com/#.42,0,1,1
*/
function ease(t) {
'worklet';
return Bezier(0.42, 0, 1, 1)(t);
}
/**
* A quadratic function, `f(t) = t * t`. Position equals the square of elapsed
* time.
*
* http://easings.net/#easeInQuad
*/
function quad(t) {
'worklet';
return t * t;
}
/**
* A cubic function, `f(t) = t * t * t`. Position equals the cube of elapsed
* time.
*
* http://easings.net/#easeInCubic
*/
function cubic(t) {
'worklet';
return t * t * t;
}
/**
* A power function. Position is equal to the Nth power of elapsed time.
*
* N = 4: http://easings.net/#easeInQuart n = 5: http://easings.net/#easeInQuint
*/
function poly(n) {
'worklet';
return t => {
'worklet';
return Math.pow(t, n);
};
}
/**
* A sinusoidal function.
*
* http://easings.net/#easeInSine
*/
function sin(t) {
'worklet';
return 1 - Math.cos(t * Math.PI / 2);
}
/**
* A circular function.
*
* http://easings.net/#easeInCirc
*/
function circle(t) {
'worklet';
return 1 - Math.sqrt(1 - t * t);
}
/**
* An exponential function.
*
* http://easings.net/#easeInExpo
*/
function exp(t) {
'worklet';
return Math.pow(2, 10 * (t - 1));
}
/**
* A simple elastic interaction, similar to a spring oscillating back and forth.
*
* Default bounciness is 1, which overshoots a little bit once. 0 bounciness
* doesn't overshoot at all, and bounciness of N `>` 1 will overshoot about N
* times.
*
* http://easings.net/#easeInElastic
*/
function elastic(bounciness = 1) {
'worklet';
const p = bounciness * Math.PI;
return t => {
'worklet';
return 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * p);
};
}
/**
* Use with `Animated.parallel()` to create a simple effect where the object
* animates back slightly as the animation starts.
*
* Wolfram Plot:
*
* - http://tiny.cc/back_default (s = 1.70158, default)
*/
function back(s = 1.70158) {
'worklet';
return t => {
'worklet';
return t * t * ((s + 1) * t - s);
};
}
/**
* Provides a simple bouncing effect.
*
* http://easings.net/#easeInBounce
*/
function bounce(t) {
'worklet';
if (t < 1 / 2.75) {
return 7.5625 * t * t;
}
if (t < 2 / 2.75) {
const t2 = t - 1.5 / 2.75;
return 7.5625 * t2 * t2 + 0.75;
}
if (t < 2.5 / 2.75) {
const t2 = t - 2.25 / 2.75;
return 7.5625 * t2 * t2 + 0.9375;
}
const t2 = t - 2.625 / 2.75;
return 7.5625 * t2 * t2 + 0.984375;
}
/**
* Provides a cubic bezier curve, equivalent to CSS Transitions'
* `transition-timing-function`.
*
* A useful tool to visualize cubic bezier curves can be found at
* http://cubic-bezier.com/
*/
function bezier(x1, y1, x2, y2) {
'worklet';
return {
factory: () => {
'worklet';
return Bezier(x1, y1, x2, y2);
}
};
}
function bezierFn(x1, y1, x2, y2) {
'worklet';
return Bezier(x1, y1, x2, y2);
}
/** Runs an easing function forwards. */
function in_(easing) {
'worklet';
return easing;
}
/** Runs an easing function backwards. */
function out(easing) {
'worklet';
return t => {
'worklet';
return 1 - easing(1 - t);
};
}
/**
* Makes any easing function symmetrical. The easing function will run forwards
* for half of the duration, then backwards for the rest of the duration.
*/
function inOut(easing) {
'worklet';
return t => {
'worklet';
if (t < 0.5) {
return easing(t * 2) / 2;
}
return 1 - easing((1 - t) * 2) / 2;
};
}
/**
* The `steps` easing function jumps between discrete values at regular
* intervals, creating a stepped animation effect. The `n` parameter determines
* the number of steps in the animation, and the `roundToNextStep` parameter
* determines whether the animation should start at the beginning or end of each
* step.
*/
function steps(n = 10, roundToNextStep = true) {
'worklet';
return t => {
'worklet';
const value = Math.min(Math.max(t, 0), 1) * n;
if (roundToNextStep) {
return Math.ceil(value) / n;
}
return Math.floor(value) / n;
};
}
const EasingObject = {
linear,
ease,
quad,
cubic,
poly,
sin,
circle,
exp,
elastic,
back,
bounce,
bezier,
bezierFn,
steps,
in: in_,
out,
inOut
};
export const EasingNameSymbol = Symbol('easingName');
for (const [easingName, easing] of Object.entries(EasingObject)) {
Object.defineProperty(easing, EasingNameSymbol, {
value: easingName,
configurable: false,
enumerable: false,
writable: false
});
}
export const Easing = EasingObject;
//# sourceMappingURL=Easing.js.map
@@ -1 +0,0 @@
{"version":3,"names":["Bezier","linear","t","ease","quad","cubic","poly","n","Math","pow","sin","cos","PI","circle","sqrt","exp","elastic","bounciness","p","back","s","bounce","t2","bezier","x1","y1","x2","y2","factory","bezierFn","in_","easing","out","inOut","steps","roundToNextStep","value","min","max","ceil","floor","EasingObject","in","EasingNameSymbol","Symbol","easingName","Object","entries","defineProperty","configurable","enumerable","writable","Easing"],"sourceRoot":"../../src","sources":["Easing.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,QAAQ,UAAU;;AAGjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,MAAMA,CAACC,CAAS,EAAU;EACjC,SAAS;;EACT,OAAOA,CAAC;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,IAAIA,CAACD,CAAS,EAAU;EAC/B,SAAS;;EACT,OAAOF,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAACE,CAAC,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,IAAIA,CAACF,CAAS,EAAU;EAC/B,SAAS;;EACT,OAAOA,CAAC,GAAGA,CAAC;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,KAAKA,CAACH,CAAS,EAAU;EAChC,SAAS;;EACT,OAAOA,CAAC,GAAGA,CAAC,GAAGA,CAAC;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASI,IAAIA,CAACC,CAAS,EAAkB;EACvC,SAAS;;EACT,OAAQL,CAAC,IAAK;IACZ,SAAS;;IACT,OAAOM,IAAI,CAACC,GAAG,CAACP,CAAC,EAAEK,CAAC,CAAC;EACvB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASG,GAAGA,CAACR,CAAS,EAAU;EAC9B,SAAS;;EACT,OAAO,CAAC,GAAGM,IAAI,CAACG,GAAG,CAAET,CAAC,GAAGM,IAAI,CAACI,EAAE,GAAI,CAAC,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,MAAMA,CAACX,CAAS,EAAU;EACjC,SAAS;;EACT,OAAO,CAAC,GAAGM,IAAI,CAACM,IAAI,CAAC,CAAC,GAAGZ,CAAC,GAAGA,CAAC,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASa,GAAGA,CAACb,CAAS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AC;EACpC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASgC,KAAKA,CAAC3B,CAAC,GAAG,EAAE,EAAE4B,eAAe,GAAG,IAAI,EAAkB;EAC7D,SAAS;;EACT,OAAQjC,CAAC,IAAK;IACZ,SAAS;;IACT,MAAMkC,KAAK,GAAG5B,IAAI,CAAC6B,GAAG,CAAC7B,IAAI,CAAC8B,GAAG,CAACpC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GAAGK,CAAC;IAC7C,IAAI4B,eAAe,EAAE;MACnB,OAAO3B,IAAI,CAAC+B,IAAI,CAACH,KAAK,CAAC,GAAG7B,CAAC;IAC7B;IACA,OAAOC,IAAI,CAACgC,KAAK,CAACJ,KAAK,CAAC,GAAG7B,CAAC;EAC9B,CAAC;AACH;AAEA,MAAMkC,YAAY,GAAG;EACnBxC,MAAM;EACNE,IAAI;EACJC,IAAI;EACJC,KAAK;EACLC,IAAI;EACJI,GAAG;EACHG,MAAM;EACNE,GAAG;EACHC,OAAO;EACPG,IAAI;EACJE,MAAM;EACNE,MAAM;EACNM,QAAQ;EACRK,KAAK;EACLQ,EAAE,EAAEZ,GAAG;EACPE,GAAG;EACHC;AACF,CAAC;AAED,OAAO,MAAMU,gBAAgB,GAAGC,MAAM,CAAC,YAAY,CAAC;AAEpD,KAAK,MAAM,CAACC,UAAU,EAAEd,MAAM,CAAC,IAAIe,MAAM,CAACC,OAAO,CAACN,YAAY,CAAC,EAAE;EAC/DK,MAAM,CAACE,cAAc,CAACjB,MAAM,EAAEY,gBAAgB,EAAE;IAC9CP,KAAK,EAAES,UAAU;IACjBI,YAAY,EAAE,KAAK;IACnBC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC,CAAC;AACJ;AAEA,OAAO,MAAMC,MAAM,GAAGX,YAAY","ignoreList":[]}
@@ -1,11 +0,0 @@
'use strict';
import { logger } from './common';
// @ts-expect-error This overload is required by our API.
export function createAnimatedPropAdapter(adapter, _nativeProps) {
logger.warn('`createAnimatedPropAdapter` is no longer necessary in Reanimated 4 and will be removed in next version. Please remove this call from your code and pass the adapter function directly.');
return adapter;
}
//# sourceMappingURL=PropAdapters.js.map
@@ -1 +0,0 @@
{"version":3,"names":["logger","createAnimatedPropAdapter","adapter","_nativeProps","warn"],"sourceRoot":"../../src","sources":["PropAdapters.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,MAAM,QAAQ,UAAU;;AAMjC;;AAMA,OAAO,SAASC,yBAAyBA,CACvCC,OAAoC,EACpCC,YAAuB,EACM;EAC7BH,MAAM,CAACI,IAAI,CACT,wLACF,CAAC;EACD,OAAOF,OAAO;AAChB","ignoreList":[]}
@@ -1,165 +0,0 @@
/* eslint-disable @typescript-eslint/no-empty-function */
'use strict';
import { executeOnUIRuntimeSync, WorkletsModule } from 'react-native-worklets';
import { ReanimatedError, registerReanimatedError, SHOULD_BE_USE_WEB } from '../common';
import { getShadowNodeWrapperFromRef } from '../fabricUtils';
import { checkCppVersion } from '../platform-specific/checkCppVersion';
import { jsVersion } from '../platform-specific/jsVersion';
import { assertWorkletsVersion } from '../platform-specific/workletsVersion';
import { ReanimatedTurboModule } from '../specs';
export function createNativeReanimatedModule() {
return new NativeReanimatedModule();
}
function assertSingleReanimatedInstance() {
if (global._REANIMATED_VERSION_JS !== undefined && global._REANIMATED_VERSION_JS !== jsVersion) {
throw new ReanimatedError(`Another instance of Reanimated was detected.
See \`https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#another-instance-of-reanimated-was-detected\` for more details. Previous: ${global._REANIMATED_VERSION_JS}, current: ${jsVersion}.`);
}
}
class NativeReanimatedModule {
/**
* We keep the instance of `WorkletsModule` here to keep correct coupling of
* the modules and initialization order.
*/
// eslint-disable-next-line no-unused-private-class-members
#workletsModule;
#reanimatedModuleProxy;
constructor() {
this.#workletsModule = WorkletsModule;
// These checks have to split since version checking depend on the execution order
if (__DEV__) {
assertSingleReanimatedInstance();
assertWorkletsVersion();
}
global._REANIMATED_VERSION_JS = jsVersion;
if (global.__reanimatedModuleProxy === undefined && ReanimatedTurboModule) {
if (!ReanimatedTurboModule.installTurboModule()) {
// This path means that React Native has failed on reload.
// We don't want to throw any errors to not mislead the users
// that the problem is related to Reanimated.
// We install a DummyReanimatedModuleProxy instead.
this.#reanimatedModuleProxy = new DummyReanimatedModuleProxy();
return;
}
}
if (global.__reanimatedModuleProxy === undefined) {
throw new ReanimatedError(`Native part of Reanimated doesn't seem to be initialized.
See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#native-part-of-reanimated-doesnt-seem-to-be-initialized for more details.`);
}
if (__DEV__ && !globalThis.RN$Bridgeless && !SHOULD_BE_USE_WEB) {
throw new ReanimatedError('Reanimated 4 supports only the React Native New Architecture and web.');
}
if (__DEV__) {
checkCppVersion();
}
this.#reanimatedModuleProxy = global.__reanimatedModuleProxy;
executeOnUIRuntimeSync(function initializeUI() {
'worklet';
registerReanimatedError();
})();
}
registerSensor(sensorType, interval, iosReferenceFrame, handler) {
return this.#reanimatedModuleProxy.registerSensor(sensorType, interval, iosReferenceFrame, handler);
}
unregisterSensor(sensorId) {
return this.#reanimatedModuleProxy.unregisterSensor(sensorId);
}
registerEventHandler(eventHandler, eventName, emitterReactTag) {
return this.#reanimatedModuleProxy.registerEventHandler(eventHandler, eventName, emitterReactTag);
}
unregisterEventHandler(id) {
return this.#reanimatedModuleProxy.unregisterEventHandler(id);
}
getViewProp(viewTag, propName, component,
// required on Fabric
callback) {
const shadowNodeWrapper = getShadowNodeWrapperFromRef(component);
return this.#reanimatedModuleProxy.getViewProp(shadowNodeWrapper, propName, callback);
}
configureLayoutAnimationBatch(layoutAnimationsBatch) {
this.#reanimatedModuleProxy.configureLayoutAnimationBatch(layoutAnimationsBatch);
}
setShouldAnimateExitingForTag(viewTag, shouldAnimate) {
this.#reanimatedModuleProxy.setShouldAnimateExitingForTag(viewTag, shouldAnimate);
}
getStaticFeatureFlag(name) {
return this.#reanimatedModuleProxy.getStaticFeatureFlag(name);
}
setDynamicFeatureFlag(name, value) {
this.#reanimatedModuleProxy.setDynamicFeatureFlag(name, value);
}
subscribeForKeyboardEvents(handler, isStatusBarTranslucent, isNavigationBarTranslucent) {
return this.#reanimatedModuleProxy.subscribeForKeyboardEvents(handler, isStatusBarTranslucent, isNavigationBarTranslucent);
}
unsubscribeFromKeyboardEvents(listenerId) {
this.#reanimatedModuleProxy.unsubscribeFromKeyboardEvents(listenerId);
}
setViewStyle(viewTag, style) {
this.#reanimatedModuleProxy.setViewStyle(viewTag, style);
}
markNodeAsRemovable(shadowNodeWrapper) {
this.#reanimatedModuleProxy.markNodeAsRemovable(shadowNodeWrapper);
}
unmarkNodeAsRemovable(viewTag) {
this.#reanimatedModuleProxy.unmarkNodeAsRemovable(viewTag);
}
registerCSSKeyframes(animationName, viewName, keyframesConfig) {
this.#reanimatedModuleProxy.registerCSSKeyframes(animationName, viewName, keyframesConfig);
}
unregisterCSSKeyframes(animationName, viewName) {
this.#reanimatedModuleProxy.unregisterCSSKeyframes(animationName, viewName);
}
applyCSSAnimations(shadowNodeWrapper, animationUpdates) {
this.#reanimatedModuleProxy.applyCSSAnimations(shadowNodeWrapper, animationUpdates);
}
unregisterCSSAnimations(viewTag) {
this.#reanimatedModuleProxy.unregisterCSSAnimations(viewTag);
}
registerCSSTransition(shadowNodeWrapper, transitionConfig) {
this.#reanimatedModuleProxy.registerCSSTransition(shadowNodeWrapper, transitionConfig);
}
updateCSSTransition(viewTag, configUpdates) {
this.#reanimatedModuleProxy.updateCSSTransition(viewTag, configUpdates);
}
unregisterCSSTransition(viewTag) {
this.#reanimatedModuleProxy.unregisterCSSTransition(viewTag);
}
}
class DummyReanimatedModuleProxy {
configureLayoutAnimationBatch() {}
setShouldAnimateExitingForTag() {}
getStaticFeatureFlag() {
return false;
}
setDynamicFeatureFlag() {}
subscribeForKeyboardEvents() {
return -1;
}
unsubscribeFromKeyboardEvents() {}
setViewStyle() {}
markNodeAsRemovable() {}
unmarkNodeAsRemovable() {}
registerCSSKeyframes() {}
unregisterCSSKeyframes() {}
applyCSSAnimations() {}
registerCSSAnimations() {}
updateCSSAnimations() {}
unregisterCSSAnimations() {}
registerCSSTransition() {}
updateCSSTransition() {}
unregisterCSSTransition() {}
registerSensor() {
return -1;
}
unregisterSensor() {}
registerEventHandler() {
return -1;
}
unregisterEventHandler() {}
getViewProp() {
return null;
}
}
//# sourceMappingURL=NativeReanimated.js.map
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
'use strict';
export { ReanimatedModule } from './reanimatedModuleInstance';
//# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
{"version":3,"names":["ReanimatedModule"],"sourceRoot":"../../../src","sources":["ReanimatedModule/index.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,gBAAgB,QAAQ,4BAA4B","ignoreList":[]}
@@ -1,6 +0,0 @@
'use strict';
// this file was created to prevent NativeReanimated from being included in the web bundle
import { createJSReanimatedModule } from './js-reanimated';
export const ReanimatedModule = createJSReanimatedModule();
//# sourceMappingURL=index.web.js.map
@@ -1 +0,0 @@
{"version":3,"names":["createJSReanimatedModule","ReanimatedModule"],"sourceRoot":"../../../src","sources":["ReanimatedModule/index.web.ts"],"mappings":"AAAA,YAAY;;AACZ;AACA,SAASA,wBAAwB,QAAQ,iBAAiB;AAE1D,OAAO,MAAMC,gBAAgB,GAAGD,wBAAwB,CAAC,CAAC","ignoreList":[]}
@@ -1,244 +0,0 @@
'use strict';
import { WorkletsModule } from 'react-native-worklets';
import { IS_JEST, IS_WEB, IS_WINDOW_AVAILABLE, logger, ReanimatedError } from '../../common';
import { SensorType } from '../../commonTypes';
import { assertWorkletsVersion } from '../../platform-specific/workletsVersion';
export function createJSReanimatedModule() {
return new JSReanimated();
}
class JSReanimated {
/**
* We keep the instance of `WorkletsModule` here to keep correct coupling of
* the modules and initialization order.
*/
// eslint-disable-next-line no-unused-private-class-members
#workletsModule = WorkletsModule;
nextSensorId = 0;
sensors = new Map();
platform = undefined;
constructor() {
if (__DEV__) {
assertWorkletsVersion();
}
}
registerEventHandler(_eventHandler, _eventName, _emitterReactTag) {
throw new ReanimatedError('registerEventHandler is not available in JSReanimated.');
}
unregisterEventHandler(_) {
throw new ReanimatedError('unregisterEventHandler is not available in JSReanimated.');
}
configureLayoutAnimationBatch() {
// no-op
}
setShouldAnimateExitingForTag() {
// no-op
}
registerSensor(sensorType, interval, _iosReferenceFrame, eventHandler) {
if (!IS_WINDOW_AVAILABLE) {
// the window object is unavailable when building the server portion of a site that uses SSG
// this check is here to ensure that the server build won't fail
return -1;
}
if (this.platform === undefined) {
this.detectPlatform();
}
if (!(this.getSensorName(sensorType) in window)) {
// https://w3c.github.io/sensors/#secure-context
logger.warn('Sensor is not available.' + (IS_WEB && location.protocol !== 'https:' ? ' Make sure you use secure origin with `npx expo start --web --https`.' : '') + (this.platform === Platform.WEB_IOS ? ' For iOS web, you will also have to also grant permission in the browser: https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2.' : ''));
return -1;
}
if (this.platform === undefined) {
this.detectPlatform();
}
const sensor = this.initializeSensor(sensorType, interval);
sensor.addEventListener('reading', this.getSensorCallback(sensor, sensorType, eventHandler));
sensor.start();
this.sensors.set(this.nextSensorId, sensor);
return this.nextSensorId++;
}
getSensorCallback = (sensor, sensorType, eventHandler) => {
switch (sensorType) {
case SensorType.ACCELEROMETER:
case SensorType.GRAVITY:
return () => {
let {
x,
y,
z
} = sensor;
// Web Android sensors have a different coordinate system than iOS
if (this.platform === Platform.WEB_ANDROID) {
[x, y, z] = [-x, -y, -z];
}
// TODO TYPESCRIPT on web SerializableRef is the value itself so we call it directly
eventHandler({
x,
y,
z,
interfaceOrientation: 0
});
};
case SensorType.GYROSCOPE:
case SensorType.MAGNETIC_FIELD:
return () => {
const {
x,
y,
z
} = sensor;
// TODO TYPESCRIPT on web SerializableRef is the value itself so we call it directly
eventHandler({
x,
y,
z,
interfaceOrientation: 0
});
};
case SensorType.ROTATION:
return () => {
const [qw, qx] = sensor.quaternion;
let [,, qy, qz] = sensor.quaternion;
// Android sensors have a different coordinate system than iOS
if (this.platform === Platform.WEB_ANDROID) {
[qy, qz] = [qz, -qy];
}
// reference: https://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion
const yaw = -Math.atan2(2.0 * (qy * qz + qw * qx), qw * qw - qx * qx - qy * qy + qz * qz);
const pitch = Math.sin(-2.0 * (qx * qz - qw * qy));
const roll = -Math.atan2(2.0 * (qx * qy + qw * qz), qw * qw + qx * qx - qy * qy - qz * qz);
// TODO TYPESCRIPT on web SerializableRef is the value itself so we call it directly
eventHandler({
qw,
qx,
qy,
qz,
yaw,
pitch,
roll,
interfaceOrientation: 0
});
};
}
};
unregisterSensor(id) {
const sensor = this.sensors.get(id);
if (sensor !== undefined) {
sensor.stop();
this.sensors.delete(id);
}
}
subscribeForKeyboardEvents(_) {
if (IS_WEB) {
logger.warn('useAnimatedKeyboard is not available on web yet.');
} else if (IS_JEST) {
logger.warn('useAnimatedKeyboard is not available when using Jest.');
} else {
logger.warn('useAnimatedKeyboard is not available on this configuration.');
}
return -1;
}
unsubscribeFromKeyboardEvents(_) {
// noop
}
initializeSensor(sensorType, interval) {
const config = interval <= 0 ? {
referenceFrame: 'device'
} : {
frequency: 1000 / interval
};
switch (sensorType) {
case SensorType.ACCELEROMETER:
return new window.Accelerometer(config);
case SensorType.GYROSCOPE:
return new window.Gyroscope(config);
case SensorType.GRAVITY:
return new window.GravitySensor(config);
case SensorType.MAGNETIC_FIELD:
return new window.Magnetometer(config);
case SensorType.ROTATION:
return new window.AbsoluteOrientationSensor(config);
}
}
getSensorName(sensorType) {
switch (sensorType) {
case SensorType.ACCELEROMETER:
return 'Accelerometer';
case SensorType.GRAVITY:
return 'GravitySensor';
case SensorType.GYROSCOPE:
return 'Gyroscope';
case SensorType.MAGNETIC_FIELD:
return 'Magnetometer';
case SensorType.ROTATION:
return 'AbsoluteOrientationSensor';
}
}
detectPlatform() {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (userAgent === undefined) {
this.platform = Platform.UNKNOWN;
} else if (/iPad|iPhone|iPod/.test(userAgent)) {
this.platform = Platform.WEB_IOS;
} else if (/android/i.test(userAgent)) {
this.platform = Platform.WEB_ANDROID;
} else {
this.platform = Platform.WEB;
}
}
getViewProp(_viewTag, _propName, _component, _callback) {
throw new ReanimatedError('getViewProp is not available in JSReanimated.');
}
getStaticFeatureFlag() {
// mock implementation
return false;
}
setDynamicFeatureFlag() {
// noop
}
setViewStyle(_viewTag, _style) {
throw new ReanimatedError('setViewStyle is not available in JSReanimated.');
}
markNodeAsRemovable(_shadowNodeWrapper) {
throw new ReanimatedError('markNodeAsRemovable is not available in JSReanimated.');
}
unmarkNodeAsRemovable(_viewTag) {
throw new ReanimatedError('unmarkNodeAsRemovable is not available in JSReanimated.');
}
registerCSSKeyframes(_animationName, _viewName, _keyframesConfig) {
throw new ReanimatedError('`registerCSSKeyframes` is not available in JSReanimated.');
}
unregisterCSSKeyframes(_animationName, _viewName) {
throw new ReanimatedError('`unregisterCSSKeyframes` is not available in JSReanimated.');
}
applyCSSAnimations(_shadowNodeWrapper, _animationUpdates) {
throw new ReanimatedError('`applyCSSAnimations` is not available in JSReanimated.');
}
unregisterCSSAnimations(_viewTag) {
throw new ReanimatedError('`unregisterCSSAnimations` is not available in JSReanimated.');
}
registerCSSTransition(_shadowNodeWrapper, _transitionConfig) {
throw new ReanimatedError('`registerCSSTransition` is not available in JSReanimated.');
}
updateCSSTransition(_viewTag, _settingsUpdates) {
throw new ReanimatedError('`updateCSSTransition` is not available in JSReanimated.');
}
unregisterCSSTransition(_viewTag) {
throw new ReanimatedError('`unregisterCSSTransition` is not available in JSReanimated.');
}
}
// Lack of this export breaks TypeScript generation since
// an enum transpiles into JavaScript code.
/** @knipIgnore */
export let Platform = /*#__PURE__*/function (Platform) {
Platform["WEB_IOS"] = "web iOS";
Platform["WEB_ANDROID"] = "web Android";
Platform["WEB"] = "web";
Platform["UNKNOWN"] = "unknown";
return Platform;
}({});
//# sourceMappingURL=JSReanimated.js.map
File diff suppressed because one or more lines are too long
@@ -1,2 +0,0 @@
'use strict';
//# sourceMappingURL=WebSensor.js.map
@@ -1 +0,0 @@
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["ReanimatedModule/js-reanimated/WebSensor.ts"],"mappings":"AAAA,YAAY","ignoreList":[]}
@@ -1,88 +0,0 @@
'use strict';
import { logger } from '../../common';
import { createReactDOMStyle, createTextShadowValue, createTransformValue } from './webUtils';
export { createJSReanimatedModule } from './JSReanimated';
// TODO: Move these functions outside of index file.
export const _updatePropsJS = (updates, viewRef, isAnimatedProps) => {
if (viewRef) {
const component = viewRef.getAnimatableRef ? viewRef.getAnimatableRef() : viewRef;
const [rawStyles] = Object.keys(updates).reduce((acc, key) => {
const value = updates[key];
const index = typeof value === 'function' ? 1 : 0;
acc[index][key] = value;
return acc;
}, [{}, {}]);
if (typeof component.setNativeProps === 'function') {
// This is the legacy way to update props on React Native Web <= 0.18.
// Also, some components (e.g. from react-native-svg) don't have styles
// and always provide setNativeProps function instead (even on React Native Web 0.19+).
setNativeProps(component, rawStyles, isAnimatedProps);
} else if (createReactDOMStyle !== undefined && component.style !== undefined) {
// React Native Web 0.19+ no longer provides setNativeProps function,
// so we need to update DOM nodes directly.
updatePropsDOM(component, rawStyles, isAnimatedProps);
} else if (Object.keys(component.props).length > 0) {
Object.keys(component.props).forEach(key => {
if (!rawStyles[key]) {
return;
}
const dashedKey = key.replace(/[A-Z]/g, m => '-' + m.toLowerCase());
component._touchableNode.setAttribute(dashedKey, rawStyles[key]);
});
} else {
const componentName = 'className' in component ? component?.className : '';
logger.warn(`It's not possible to manipulate the component ${componentName}`);
}
}
};
const setNativeProps = (component, newProps, isAnimatedProps) => {
if (isAnimatedProps) {
// Only update UI props directly on the component,
// other props can be updated as standard style props.
component.setNativeProps?.(newProps);
}
const previousStyle = component.previousStyle ? component.previousStyle : {};
const currentStyle = {
...previousStyle,
...newProps
};
component.previousStyle = currentStyle;
component.setNativeProps?.({
style: currentStyle
});
};
const updatePropsDOM = (component, style, isAnimatedProps) => {
const previousStyle = component.previousStyle ? component.previousStyle : {};
const currentStyle = {
...previousStyle,
...style
};
component.previousStyle = currentStyle;
const domStyle = createReactDOMStyle(currentStyle);
if (Array.isArray(domStyle.transform) && createTransformValue !== undefined) {
domStyle.transform = createTransformValue(domStyle.transform);
}
if (createTextShadowValue !== undefined && (domStyle.textShadowColor || domStyle.textShadowRadius || domStyle.textShadowOffset)) {
domStyle.textShadow = createTextShadowValue({
textShadowColor: domStyle.textShadowColor,
textShadowOffset: domStyle.textShadowOffset,
textShadowRadius: domStyle.textShadowRadius
});
}
for (const key in domStyle) {
if (isAnimatedProps) {
// We need to explicitly set the 'text' property on input component because React Native's
// internal _valueTracker (https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/client/inputValueTracking.js)
// prevents updates when only modifying attributes.
if (component.nodeName === 'INPUT' && key === 'text') {
component.value = domStyle[key];
} else {
component.setAttribute(key, domStyle[key]);
}
} else {
component.style[key] = domStyle[key];
}
}
};
//# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
{"version":3,"names":["logger","createReactDOMStyle","createTextShadowValue","createTransformValue","createJSReanimatedModule","_updatePropsJS","updates","viewRef","isAnimatedProps","component","getAnimatableRef","rawStyles","Object","keys","reduce","acc","key","value","index","setNativeProps","undefined","style","updatePropsDOM","props","length","forEach","dashedKey","replace","m","toLowerCase","_touchableNode","setAttribute","componentName","className","warn","newProps","previousStyle","currentStyle","domStyle","Array","isArray","transform","textShadowColor","textShadowRadius","textShadowOffset","textShadow","nodeName"],"sourceRoot":"../../../../src","sources":["ReanimatedModule/js-reanimated/index.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,QAAQ,cAAc;AAGrC,SACEC,mBAAmB,EACnBC,qBAAqB,EACrBC,oBAAoB,QACf,YAAY;AAEnB,SAASC,wBAAwB,QAAQ,gBAAgB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kB,QAAQ,CAACG,SAAS,GAAGtC,oBAAoB,CAACmC,QAAQ,CAACG,SAAS,CAAC;EAC/D;EAEA,IACEvC,qBAAqB,KAAKkB,SAAS,KAClCkB,QAAQ,CAACI,eAAe,IACvBJ,QAAQ,CAACK,gBAAgB,IACzBL,QAAQ,CAACM,gBAAgB,CAAC,EAC5B;IACAN,QAAQ,CAACO,UAAU,GAAG3C,qBAAqB,CAAC;MAC1CwC,eAAe,EAAEJ,QAAQ,CAACI,eAAe;MACzCE,gBAAgB,EAAEN,QAAQ,CAACM,gBAAgB;MAC3CD,gBAAgB,EAAEL,QAAQ,CAACK;IAC7B,CAAC,CAAC;EACJ;EAEA,KAAK,MAAM3B,GAAG,IAAIsB,QAAQ,EAAE;IAC1B,IAAI9B,eAAe,EAAE;MACnB;MACA;MACA;MACA,IAAKC,SAAS,CAAiBqC,QAAQ,KAAK,OAAO,IAAI9B,GAAG,KAAK,MAAM,EAAE;QACpEP,SAAS,CAAsBQ,KAAK,GAAGqB,QAAQ,CAACtB,GAAG,CAAW;MACjE,CAAC,MAAM;QACJP,SAAS,CAAiBsB,YAAY,CAACf,GAAG,EAAEsB,QAAQ,CAACtB,GAAG,CAAC,CAAC;MAC7D;IACF,CAAC,MAAM;MACJP,SAAS,CAACY,KAAK,CAAgBL,GAAG,CAAC,GAAGsB,QAAQ,CAACtB,GAAG,CAAC;IACtD;EACF;AACF,CAAC","ignoreList":[]}
@@ -1,2 +0,0 @@
'use strict';
//# sourceMappingURL=react-native-web.d.js.map
@@ -1 +0,0 @@
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["ReanimatedModule/js-reanimated/react-native-web.d.ts"],"mappings":"AAAA,YAAY","ignoreList":[]}
@@ -1,9 +0,0 @@
'use strict';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export let createReactDOMStyle;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export let createTransformValue;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export let createTextShadowValue;
//# sourceMappingURL=webUtils.js.map
@@ -1 +0,0 @@
{"version":3,"names":["createReactDOMStyle","createTransformValue","createTextShadowValue"],"sourceRoot":"../../../../src","sources":["ReanimatedModule/js-reanimated/webUtils.ts"],"mappings":"AAAA,YAAY;;AAEZ;AACA,OAAO,IAAIA,mBAAwC;AACnD;AACA,OAAO,IAAIC,oBAA6C;AACxD;AACA,OAAO,IAAIC,qBAAoD","ignoreList":[]}
@@ -1,25 +0,0 @@
'use strict';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export let createReactDOMStyle;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export let createTransformValue;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export let createTextShadowValue;
try {
createReactDOMStyle =
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
require('react-native-web/dist/exports/StyleSheet/compiler/createReactDOMStyle').default;
} catch (_e) {}
try {
// React Native Web 0.19+
createTransformValue =
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
require('react-native-web/dist/exports/StyleSheet/preprocess').createTransformValue;
} catch (_e) {}
try {
createTextShadowValue =
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
require('react-native-web/dist/exports/StyleSheet/preprocess').createTextShadowValue;
} catch (_e) {}
//# sourceMappingURL=webUtils.web.js.map
@@ -1 +0,0 @@
{"version":3,"names":["createReactDOMStyle","createTransformValue","createTextShadowValue","require","default","_e"],"sourceRoot":"../../../../src","sources":["ReanimatedModule/js-reanimated/webUtils.web.ts"],"mappings":"AAAA,YAAY;;AAEZ;AACA,OAAO,IAAIA,mBAAwC;AACnD;AACA,OAAO,IAAIC,oBAA6C;AACxD;AACA,OAAO,IAAIC,qBAAoD;AAE/D,IAAI;EACFF,mBAAmB;EACjB;EACAG,OAAO,CAAC,uEAAuE,CAAC,CAACC,OAAO;AAC5F,CAAC,CAAC,OAAOC,EAAE,EAAE,CAAC;AAEd,IAAI;EACF;EACAJ,oBAAoB;EAClB;EACAE,OAAO,CAAC,qDAAqD,CAAC,CAACF,oBAAoB;AACvF,CAAC,CAAC,OAAOI,EAAE,EAAE,CAAC;AAEd,IAAI;EACFH,qBAAqB;EACnB;EACAC,OAAO,CAAC,qDAAqD,CAAC,CAACD,qBAAqB;AACxF,CAAC,CAAC,OAAOG,EAAE,EAAE,CAAC","ignoreList":[]}
@@ -1,7 +0,0 @@
'use strict';
import { SHOULD_BE_USE_WEB } from '../common';
import { createJSReanimatedModule } from './js-reanimated';
import { createNativeReanimatedModule } from './NativeReanimated';
export const ReanimatedModule = SHOULD_BE_USE_WEB ? createJSReanimatedModule() : createNativeReanimatedModule();
//# sourceMappingURL=reanimatedModuleInstance.js.map
@@ -1 +0,0 @@
{"version":3,"names":["SHOULD_BE_USE_WEB","createJSReanimatedModule","createNativeReanimatedModule","ReanimatedModule"],"sourceRoot":"../../../src","sources":["ReanimatedModule/reanimatedModuleInstance.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,iBAAiB,QAAQ,WAAW;AAC7C,SAASC,wBAAwB,QAAQ,iBAAiB;AAC1D,SAASC,4BAA4B,QAAQ,oBAAoB;AAEjE,OAAO,MAAMC,gBAAgB,GAAGH,iBAAiB,GAC7CC,wBAAwB,CAAC,CAAC,GAC1BC,4BAA4B,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +0,0 @@
'use strict';
import { createJSReanimatedModule } from './js-reanimated';
export const ReanimatedModule = createJSReanimatedModule();
//# sourceMappingURL=reanimatedModuleInstance.web.js.map
@@ -1 +0,0 @@
{"version":3,"names":["createJSReanimatedModule","ReanimatedModule"],"sourceRoot":"../../../src","sources":["ReanimatedModule/reanimatedModuleInstance.web.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,wBAAwB,QAAQ,iBAAiB;AAE1D,OAAO,MAAMC,gBAAgB,GAAGD,wBAAwB,CAAC,CAAC","ignoreList":[]}
@@ -1,4 +0,0 @@
'use strict';
export {};
//# sourceMappingURL=reanimatedModuleProxy.js.map
@@ -1 +0,0 @@
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["ReanimatedModule/reanimatedModuleProxy.ts"],"mappings":"AAAA,YAAY;;AAAC","ignoreList":[]}
@@ -1,19 +0,0 @@
'use strict';
import { IS_WEB, IS_WINDOW_AVAILABLE } from './common';
import { makeMutable } from './mutables';
export function isReducedMotionEnabledInSystem() {
return IS_WEB ? IS_WINDOW_AVAILABLE ?
// @ts-ignore Fallback if `window` is undefined.
window.matchMedia('(prefers-reduced-motion: reduce)').matches : false : !!global._REANIMATED_IS_REDUCED_MOTION;
}
const IS_REDUCED_MOTION_ENABLED_IN_SYSTEM = isReducedMotionEnabledInSystem();
export const ReducedMotionManager = {
jsValue: IS_REDUCED_MOTION_ENABLED_IN_SYSTEM,
uiValue: makeMutable(IS_REDUCED_MOTION_ENABLED_IN_SYSTEM),
setEnabled(value) {
ReducedMotionManager.jsValue = value;
ReducedMotionManager.uiValue.value = value;
}
};
//# sourceMappingURL=ReducedMotion.js.map
@@ -1 +0,0 @@
{"version":3,"names":["IS_WEB","IS_WINDOW_AVAILABLE","makeMutable","isReducedMotionEnabledInSystem","window","matchMedia","matches","global","_REANIMATED_IS_REDUCED_MOTION","IS_REDUCED_MOTION_ENABLED_IN_SYSTEM","ReducedMotionManager","jsValue","uiValue","setEnabled","value"],"sourceRoot":"../../src","sources":["ReducedMotion.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,EAAEC,mBAAmB,QAAQ,UAAU;AACtD,SAASC,WAAW,QAAQ,YAAY;AAIxC,OAAO,SAASC,8BAA8BA,CAAA,EAAG;EAC/C,OAAOH,MAAM,GACTC,mBAAmB;EACjB;EACAG,MAAM,CAACC,UAAU,CAAC,kCAAkC,CAAC,CAACC,OAAO,GAC7D,KAAK,GACP,CAAC,CAAEC,MAAM,CAAiBC,6BAA6B;AAC7D;AAEA,MAAMC,mCAAmC,GAAGN,8BAA8B,CAAC,CAAC;AAE5E,OAAO,MAAMO,oBAAoB,GAAG;EAClCC,OAAO,EAAEF,mCAAmC;EAC5CG,OAAO,EAAEV,WAAW,CAACO,mCAAmC,CAAC;EACzDI,UAAUA,CAACC,KAAc,EAAE;IACzBJ,oBAAoB,CAACC,OAAO,GAAGG,KAAK;IACpCJ,oBAAoB,CAACE,OAAO,CAACE,KAAK,GAAGA,KAAK;EAC5C;AACF,CAAC","ignoreList":[]}
@@ -1,57 +0,0 @@
'use strict';
import { SensorType } from './commonTypes';
import { makeMutable } from './mutables';
import { ReanimatedModule } from './ReanimatedModule';
function initSensorData(sensorType) {
if (sensorType === SensorType.ROTATION) {
return makeMutable({
qw: 0,
qx: 0,
qy: 0,
qz: 0,
yaw: 0,
pitch: 0,
roll: 0,
interfaceOrientation: 0
});
} else {
return makeMutable({
x: 0,
y: 0,
z: 0,
interfaceOrientation: 0
});
}
}
export default class Sensor {
listenersNumber = 0;
sensorId = null;
constructor(sensorType, config) {
this.sensorType = sensorType;
this.config = config;
this.data = initSensorData(sensorType);
}
register(eventHandler) {
const config = this.config;
const sensorType = this.sensorType;
this.sensorId = ReanimatedModule.registerSensor(sensorType, config.interval === 'auto' ? -1 : config.interval, config.iosReferenceFrame, eventHandler);
return this.sensorId !== -1;
}
isRunning() {
return this.sensorId !== -1 && this.sensorId !== null;
}
isAvailable() {
return this.sensorId !== -1;
}
getSharedValue() {
return this.data;
}
unregister() {
if (this.sensorId !== null && this.sensorId !== -1) {
ReanimatedModule.unregisterSensor(this.sensorId);
}
this.sensorId = null;
}
}
//# sourceMappingURL=Sensor.js.map
@@ -1 +0,0 @@
{"version":3,"names":["SensorType","makeMutable","ReanimatedModule","initSensorData","sensorType","ROTATION","qw","qx","qy","qz","yaw","pitch","roll","interfaceOrientation","x","y","z","Sensor","listenersNumber","sensorId","constructor","config","data","register","eventHandler","registerSensor","interval","iosReferenceFrame","isRunning","isAvailable","getSharedValue","unregister","unregisterSensor"],"sourceRoot":"../../src","sources":["Sensor.ts"],"mappings":"AAAA,YAAY;;AASZ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AC,CAAC;EAC7B;EAEAS,SAASA,CAAA,EAAG;IACV,OAAO,IAAI,CAACT,QAAQ,KAAK,CAAC,CAAC,IAAI,IAAI,CAACA,QAAQ,KAAK,IAAI;EACvD;EAEAU,WAAWA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACV,QAAQ,KAAK,CAAC,CAAC;EAC7B;EAEAW,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAACR,IAAI;EAClB;EAEAS,UAAUA,CAAA,EAAG;IACX,IAAI,IAAI,CAACZ,QAAQ,KAAK,IAAI,IAAI,IAAI,CAACA,QAAQ,KAAK,CAAC,CAAC,EAAE;MAClDjB,gBAAgB,CAAC8B,gBAAgB,CAAC,IAAI,CAACb,QAAQ,CAAC;IAClD;IACA,IAAI,CAACA,QAAQ,GAAG,IAAI;EACtB;AACF","ignoreList":[]}
@@ -1,42 +0,0 @@
'use strict';
import Sensor from './Sensor';
export class SensorContainer {
nativeSensors = new Map();
getSensorId(sensorType, config) {
return sensorType * 100 + config.iosReferenceFrame * 10 + Number(config.adjustToInterfaceOrientation);
}
initializeSensor(sensorType, config) {
const sensorId = this.getSensorId(sensorType, config);
if (!this.nativeSensors.has(sensorId)) {
const newSensor = new Sensor(sensorType, config);
this.nativeSensors.set(sensorId, newSensor);
}
const sensor = this.nativeSensors.get(sensorId);
return sensor.getSharedValue();
}
registerSensor(sensorType, config, handler) {
const sensorId = this.getSensorId(sensorType, config);
if (!this.nativeSensors.has(sensorId)) {
return -1;
}
const sensor = this.nativeSensors.get(sensorId);
if (sensor && sensor.isAvailable() && (sensor.isRunning() || sensor.register(handler))) {
sensor.listenersNumber++;
return sensorId;
}
return -1;
}
unregisterSensor(sensorId) {
if (this.nativeSensors.has(sensorId)) {
const sensor = this.nativeSensors.get(sensorId);
if (sensor && sensor.isRunning()) {
sensor.listenersNumber--;
if (sensor.listenersNumber === 0) {
sensor.unregister();
}
}
}
}
}
//# sourceMappingURL=SensorContainer.js.map
@@ -1 +0,0 @@
{"version":3,"names":["Sensor","SensorContainer","nativeSensors","Map","getSensorId","sensorType","config","iosReferenceFrame","Number","adjustToInterfaceOrientation","initializeSensor","sensorId","has","newSensor","set","sensor","get","getSharedValue","registerSensor","handler","isAvailable","isRunning","register","listenersNumber","unregisterSensor","unregister"],"sourceRoot":"../../src","sources":["SensorContainer.ts"],"mappings":"AAAA,YAAY;;AAUZ,OAAOA,MAAM,MAAM,UAAU;AAE7B,OAAO,MAAMC,eAAe,CAAC;EACnBC,aAAa,GAAwB,IAAIC,GAAG,CAAC,CAAC;EAEtDC,WAAWA,CAACC,UAAsB,EAAEC,MAAoB,EAAE;IACxD,OACED,UAAU,GAAG,GAAG,GAChBC,MAAM,CAACC,iBAAiB,GAAG,EAAE,GAC7BC,MAAM,CAACF,MAAM,CAACG,4BAA4B,CAAC;EAE/C;EAEAC,gBAAgBA,CACdL,UAAsB,EACtBC,MAAoB,EACkB;IACtC,MAAMK,QAAQ,GAAG,IAAI,CAACP,WAAW,CAACC,UAAU,EAAEC,MAAM,CAAC;IAErD,IAAI,CAAC,IAAI,CAACJ,aAAa,CAACU,GAAG,CAACD,QAAQ,CAAC,EAAE;MACrC,MAAME,SAAS,GAAG,IAAIb,MAAM,CAACK,UAAU,EAAEC,MAAM,CAAC;MAChD,IAAI,CAACJ,aAAa,CAACY,GAAG,CAACH,QAAQ,EAAEE,SAAS,CAAC;IAC7C;IAEA,MAAME,MAAM,GAAG,IAAI,CAACb,aAAa,CAACc,GAAG,CAACL,QAAQ,CAAC;IAC/C,OAAOI,MAAM,CAAEE,cAAc,CAAC,CAAC;EACjC;EAEAC,cAAcA,CACZb,UAAsB,EACtBC,MAAoB,EACpBa,OAAiE,EACzD;IACR,MAAMR,QAAQ,GAAG,IAAI,CAACP,WAAW,CAACC,UAAU,EAAEC,MAAM,CAAC;IAErD,IAAI,CAAC,IAAI,CAACJ,aAAa,CAACU,GAAG,CAACD,QAAQ,CAAC,EAAE;MACrC,OAAO,CAAC,CAAC;IACX;IAEA,MAAMI,MAAM,GAAG,IAAI,CAACb,aAAa,CAACc,GAAG,CAACL,QAAQ,CAAC;IAC/C,IACEI,MAAM,IACNA,MAAM,CAACK,WAAW,CAAC,CAAC,KACnBL,MAAM,CAACM,SAAS,CAAC,CAAC,IAAIN,MAAM,CAACO,QAAQ,CAACH,OAAO,CAAC,CAAC,EAChD;MACAJ,MAAM,CAACQ,eAAe,EAAE;MACxB,OAAOZ,QAAQ;IACjB;IACA,OAAO,CAAC,CAAC;EACX;EAEAa,gBAAgBA,CAACb,QAAgB,EAAE;IACjC,IAAI,IAAI,CAACT,aAAa,CAACU,GAAG,CAACD,QAAQ,CAAC,EAAE;MACpC,MAAMI,MAAM,GAAG,IAAI,CAACb,aAAa,CAACc,GAAG,CAACL,QAAQ,CAAC;MAC/C,IAAII,MAAM,IAAIA,MAAM,CAACM,SAAS,CAAC,CAAC,EAAE;QAChCN,MAAM,CAACQ,eAAe,EAAE;QACxB,IAAIR,MAAM,CAACQ,eAAe,KAAK,CAAC,EAAE;UAChCR,MAAM,CAACU,UAAU,CAAC,CAAC;QACrB;MACF;IACF;EACF;AACF","ignoreList":[]}
@@ -1,60 +0,0 @@
'use strict';
import { createSerializable } from 'react-native-worklets';
import { SHOULD_BE_USE_WEB } from './common';
import { configureLayoutAnimationBatch } from './core';
function createUpdateManager() {
const animations = [];
// When a stack is rerendered we reconfigure all the shared elements.
// To do that we want them to appear in our batch in the correct order,
// so we defer some of the updates to appear at the end of the batch.
const deferredAnimations = [];
return {
update(batchItem, isUnmounting) {
if (isUnmounting) {
deferredAnimations.push(batchItem);
} else {
animations.push(batchItem);
}
if (animations.length + deferredAnimations.length === 1) {
this.flush();
}
},
flush() {
configureLayoutAnimationBatch(animations.concat(deferredAnimations));
animations.length = 0;
deferredAnimations.length = 0;
}
};
}
/**
* Lets you update the current configuration of the layout animation or shared
* element transition for a given component. Configurations are batched and
* applied at the end of the current execution block, right before sending the
* response back to native.
*
* @param viewTag - The tag of the component you'd like to configure.
* @param type - The type of the animation you'd like to configure -
* {@link LayoutAnimationType}.
* @param config - The animation configuration - {@link LayoutAnimationFunction}
* or {@link Keyframe}. Passing `undefined` will remove the animation.
* @param isUnmounting - Determines whether the configuration should be included
* at the end of the batch, after all the non-deferred configurations (even
* those that were updated later). This is used to retain the correct ordering
* of shared elements. Defaults to `false`.
*/
export let updateLayoutAnimations;
if (SHOULD_BE_USE_WEB) {
updateLayoutAnimations = () => {
// no-op
};
} else {
const updateLayoutAnimationsManager = createUpdateManager();
updateLayoutAnimations = (viewTag, type, config, isUnmounting) => updateLayoutAnimationsManager.update({
viewTag,
type,
config: config ? createSerializable(config) : undefined
}, isUnmounting);
}
//# sourceMappingURL=UpdateLayoutAnimations.js.map
@@ -1 +0,0 @@
{"version":3,"names":["createSerializable","SHOULD_BE_USE_WEB","configureLayoutAnimationBatch","createUpdateManager","animations","deferredAnimations","update","batchItem","isUnmounting","push","length","flush","concat","updateLayoutAnimations","updateLayoutAnimationsManager","viewTag","type","config","undefined"],"sourceRoot":"../../src","sources":["UpdateLayoutAnimations.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,kBAAkB,QAAQ,uBAAuB;AAE1D,SAASC,iBAAiB,QAAQ,UAAU;AAM5C,SAASC,6BAA6B,QAAQ,QAAQ;AAEtD,SAASC,mBAAmBA,CAAA,EAAG;EAC7B,MAAMC,UAAsC,GAAG,EAAE;EACjD;EACA;EACA;EACA,MAAMC,kBAA8C,GAAG,EAAE;EAEzD,OAAO;IACLC,MAAMA,CAACC,SAAmC,EAAEC,YAAsB,EAAE;MAClE,IAAIA,YAAY,EAAE;QAChBH,kBAAkB,CAACI,IAAI,CAACF,SAAS,CAAC;MACpC,CAAC,MAAM;QACLH,UAAU,CAACK,IAAI,CAACF,SAAS,CAAC;MAC5B;MACA,IAAIH,UAAU,CAACM,MAAM,GAAGL,kBAAkB,CAACK,MAAM,KAAK,CAAC,EAAE;QACvD,IAAI,CAACC,KAAK,CAAC,CAAC;MACd;IACF,CAAC;IACDA,KAAKA,CAAA,EAAa;MAChBT,6BAA6B,CAACE,UAAU,CAACQ,MAAM,CAACP,kBAAkB,CAAC,CAAC;MACpED,UAAU,CAACM,MAAM,GAAG,CAAC;MACrBL,kBAAkB,CAACK,MAAM,GAAG,CAAC;IAC/B;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAIG,sBAKF;AAET,IAAIZ,iBAAiB,EAAE;EACrBY,sBAAsB,GAAGA,CAAA,KAAM;IAC7B;EAAA,CACD;AACH,CAAC,MAAM;EACL,MAAMC,6BAA6B,GAAGX,mBAAmB,CAAC,CAAC;EAC3DU,sBAAsB,GAAGA,CAACE,OAAO,EAAEC,IAAI,EAAEC,MAAM,EAAET,YAAY,KAC3DM,6BAA6B,CAACR,MAAM,CAClC;IACES,OAAO;IACPC,IAAI;IACJC,MAAM,EAAEA,MAAM,GAAGjB,kBAAkB,CAACiB,MAAM,CAAC,GAAGC;EAChD,CAAC,EACDV,YACF,CAAC;AACL","ignoreList":[]}
@@ -1,41 +0,0 @@
'use strict';
import { makeMutable } from './core';
export function makeViewDescriptorsSet() {
const shareableViewDescriptors = makeMutable([]);
const viewTags = new Set();
const data = {
shareableViewDescriptors,
add: (item, updaterContainer) => {
viewTags.add(item.tag);
const updater = updaterContainer?.current;
shareableViewDescriptors.modify(descriptors => {
'worklet';
const index = descriptors.findIndex(descriptor => descriptor.tag === item.tag);
if (index !== -1) {
descriptors[index] = item;
} else {
descriptors.push(item);
}
updater?.(true);
return descriptors;
}, false);
},
remove: viewTag => {
viewTags.delete(viewTag);
shareableViewDescriptors.modify(descriptors => {
'worklet';
const index = descriptors.findIndex(descriptor => descriptor.tag === viewTag);
if (index !== -1) {
descriptors.splice(index, 1);
}
return descriptors;
}, false);
},
has: viewTag => viewTags.has(viewTag)
};
return data;
}
//# sourceMappingURL=ViewDescriptorsSet.js.map
@@ -1 +0,0 @@
{"version":3,"names":["makeMutable","makeViewDescriptorsSet","shareableViewDescriptors","viewTags","Set","data","add","item","updaterContainer","tag","updater","current","modify","descriptors","index","findIndex","descriptor","push","remove","viewTag","delete","splice","has"],"sourceRoot":"../../src","sources":["ViewDescriptorsSet.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,WAAW,QAAQ,QAAQ;AAUpC,OAAO,SAASC,sBAAsBA,CAAA,EAAuB;EAC3D,MAAMC,wBAAwB,GAAGF,WAAW,CAAe,EAAE,CAAC;EAC9D,MAAMG,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAElC,MAAMC,IAAwB,GAAG;IAC/BH,wBAAwB;IACxBI,GAAG,EAAEA,CAACC,IAAgB,EAAEC,gBAAwC,KAAK;MACnEL,QAAQ,CAACG,GAAG,CAACC,IAAI,CAACE,GAAa,CAAC;MAChC,MAAMC,OAAO,GAAGF,gBAAgB,EAAEG,OAAO;MACzCT,wBAAwB,CAACU,MAAM,CAAEC,WAAW,IAAK;QAC/C,SAAS;;QACT,MAAMC,KAAK,GAAGD,WAAW,CAACE,SAAS,CAChCC,UAAU,IAAKA,UAAU,CAACP,GAAG,KAAKF,IAAI,CAACE,GAC1C,CAAC;QACD,IAAIK,KAAK,KAAK,CAAC,CAAC,EAAE;UAChBD,WAAW,CAACC,KAAK,CAAC,GAAGP,IAAI;QAC3B,CAAC,MAAM;UACLM,WAAW,CAACI,IAAI,CAACV,IAAI,CAAC;QACxB;QACAG,OAAO,GAAG,IAAI,CAAC;QACf,OAAOG,WAAW;MACpB,CAAC,EAAE,KAAK,CAAC;IACX,CAAC;IAEDK,MAAM,EAAGC,OAAe,IAAK;MAC3BhB,QAAQ,CAACiB,MAAM,CAACD,OAAO,CAAC;MACxBjB,wBAAwB,CAACU,MAAM,CAAEC,WAAW,IAAK;QAC/C,SAAS;;QACT,MAAMC,KAAK,GAAGD,WAAW,CAACE,SAAS,CAChCC,UAAU,IAAKA,UAAU,CAACP,GAAG,KAAKU,OACrC,CAAC;QACD,IAAIL,KAAK,KAAK,CAAC,CAAC,EAAE;UAChBD,WAAW,CAACQ,MAAM,CAACP,KAAK,EAAE,CAAC,CAAC;QAC9B;QACA,OAAOD,WAAW;MACpB,CAAC,EAAE,KAAK,CAAC;IACX,CAAC;IAEDS,GAAG,EAAGH,OAAe,IAAKhB,QAAQ,CAACmB,GAAG,CAACH,OAAO;EAChD,CAAC;EAED,OAAOd,IAAI;AACb","ignoreList":[]}
@@ -1,86 +0,0 @@
'use strict';
import { SHOULD_BE_USE_WEB } from './common';
import { registerEventHandler, unregisterEventHandler } from './core';
// In JS implementation (e.g. for web) we don't use Reanimated's
// event emitter, therefore we have to handle here
// the event that came from React Native and convert it.
function jsListener(eventName, handler) {
return evt => {
handler({
...evt.nativeEvent,
eventName
});
};
}
class WorkletEventHandlerNative {
#viewTags;
#registrations; // keys are viewTags, values are arrays of registration ID's for each viewTag
constructor(worklet, eventNames) {
this.worklet = worklet;
this.eventNames = eventNames;
this.#viewTags = new Set();
this.#registrations = new Map();
}
updateEventHandler(newWorklet, newEvents) {
// Update worklet and event names
this.worklet = newWorklet;
this.eventNames = newEvents;
// Detach all events
this.#registrations.forEach(registrationIDs => {
registrationIDs.forEach(id => unregisterEventHandler(id));
// No need to remove registrationIDs from map, since it gets overwritten when attaching
});
// Attach new events with new worklet
Array.from(this.#viewTags).forEach(tag => {
const newRegistrations = this.eventNames.map(eventName => registerEventHandler(this.worklet, eventName, tag));
this.#registrations.set(tag, newRegistrations);
});
}
registerForEvents(viewTag, fallbackEventName) {
this.#viewTags.add(viewTag);
const newRegistrations = this.eventNames.map(eventName => registerEventHandler(this.worklet, eventName, viewTag));
this.#registrations.set(viewTag, newRegistrations);
if (this.eventNames.length === 0 && fallbackEventName) {
const newRegistration = registerEventHandler(this.worklet, fallbackEventName, viewTag);
this.#registrations.set(viewTag, [newRegistration]);
}
}
unregisterFromEvents(viewTag) {
this.#viewTags.delete(viewTag);
this.#registrations.get(viewTag)?.forEach(id => {
unregisterEventHandler(id);
});
this.#registrations.delete(viewTag);
}
}
class WorkletEventHandlerWeb {
constructor(worklet, eventNames = []) {
this.worklet = worklet;
this.eventNames = eventNames;
this.listeners = {};
this.setupWebListeners();
}
setupWebListeners() {
this.listeners = {};
this.eventNames.forEach(eventName => {
this.listeners[eventName] = jsListener(eventName, this.worklet);
});
}
updateEventHandler(newWorklet, newEvents) {
// Update worklet and event names
this.worklet = newWorklet;
this.eventNames = newEvents;
this.setupWebListeners();
}
registerForEvents(_viewTag, _fallbackEventName) {
// noop
}
unregisterFromEvents(_viewTag) {
// noop
}
}
export const WorkletEventHandler = SHOULD_BE_USE_WEB ? WorkletEventHandlerWeb : WorkletEventHandlerNative;
//# sourceMappingURL=WorkletEventHandler.js.map
@@ -1 +0,0 @@
{"version":3,"names":["SHOULD_BE_USE_WEB","registerEventHandler","unregisterEventHandler","jsListener","eventName","handler","evt","nativeEvent","WorkletEventHandlerNative","viewTags","registrations","constructor","worklet","eventNames","Set","Map","updateEventHandler","newWorklet","newEvents","forEach","registrationIDs","id","Array","from","tag","newRegistrations","map","set","registerForEvents","viewTag","fallbackEventName","add","length","newRegistration","unregisterFromEvents","delete","get","WorkletEventHandlerWeb","listeners","setupWebListeners","_viewTag","_fallbackEventName","WorkletEventHandler"],"sourceRoot":"../../src","sources":["WorkletEventHandler.ts"],"mappings":"AAAA,YAAY;;AAGZ,SAASA,iBAAiB,QAAQ,UAAU;AAC5C,SAASC,oBAAoB,EAAEC,sBAAsB,QAAQ,QAAQ;AASrE;AACA;AACA;AACA,SAASC,UAAUA,CACjBC,SAAiB,EACjBC,OAAgD,EAChD;EACA,OAAQC,GAAmB,IAAK;IAC9BD,OAAO,CAAC;MAAE,GAAGC,GAAG,CAACC,WAAW;MAAEH;IAAU,CAA2B,CAAC;EACtE,CAAC;AACH;AAEA,MAAMI,yBAAyB,CAE/B;EAGE,CAACC,QAAQ;EACT,CAACC,aAAa,CAAwB,CAAC;EACvCC,WAAWA,CACTC,OAAgD,EAChDC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3B,IAAI,CAACqB,iBAAiB,CAAC,CAAC;EAC1B;EAEAX,iBAAiBA,CAACY,QAAgB,EAAEC,kBAA2B,EAAQ;IACrE;EAAA;EAGFP,oBAAoBA,CAACM,QAAgB,EAAQ;IAC3C;EAAA;AAEJ;AAEA,OAAO,MAAME,mBAAmB,GAAG1C,iBAAiB,GAChDqC,sBAAsB,GACtB7B,yBAAyB","ignoreList":[]}
@@ -1,67 +0,0 @@
'use strict';
import { logger } from '../common';
import { defineAnimation, getReduceMotionForAnimation, recognizePrefixSuffix } from './util';
export const withClamp = function (config, _animationToClamp) {
'worklet';
return defineAnimation(_animationToClamp, () => {
'worklet';
const animationToClamp = typeof _animationToClamp === 'function' ? _animationToClamp() : _animationToClamp;
const strippedMin = config.min === undefined ? undefined : recognizePrefixSuffix(config.min).strippedValue;
const strippedMax = config.max === undefined ? undefined : recognizePrefixSuffix(config.max).strippedValue;
function clampOnFrame(animation, now) {
const finished = animationToClamp.onFrame(animationToClamp, now);
if (animationToClamp.current === undefined) {
logger.warn("Error inside 'withClamp' animation, the inner animation has invalid current value");
return true;
} else {
const {
prefix,
strippedValue,
suffix
} = recognizePrefixSuffix(animationToClamp.current);
let newValue;
if (strippedMax !== undefined && strippedMax < strippedValue) {
newValue = strippedMax;
} else if (strippedMin !== undefined && strippedMin > strippedValue) {
newValue = strippedMin;
} else {
newValue = strippedValue;
}
animation.current = typeof animationToClamp.current === 'number' ? newValue : `${prefix === undefined ? '' : prefix}${newValue}${suffix === undefined ? '' : suffix}`;
}
return finished;
}
function onStart(animation, value, now, previousAnimation) {
animation.current = value;
animation.previousAnimation = animationToClamp;
const animationBeforeClamped = previousAnimation?.previousAnimation;
if (config.max !== undefined && config.min !== undefined && config.max < config.min) {
logger.warn('Wrong config was provided to withClamp. Min value is bigger than max');
}
animationToClamp.onStart(animationToClamp,
/**
* Provide the current value of the previous animation of the clamped
* animation so we can animate from the original "un-truncated" value
*/
animationBeforeClamped?.current || value, now, animationBeforeClamped);
}
const callback = finished => {
if (animationToClamp.callback) {
animationToClamp.callback(finished);
}
};
return {
isHigherOrder: true,
onFrame: clampOnFrame,
onStart,
current: animationToClamp.current,
callback,
previousAnimation: null,
reduceMotion: getReduceMotionForAnimation(config.reduceMotion)
};
});
};
//# sourceMappingURL=clamp.js.map
@@ -1 +0,0 @@
{"version":3,"names":["logger","defineAnimation","getReduceMotionForAnimation","recognizePrefixSuffix","withClamp","config","_animationToClamp","animationToClamp","strippedMin","min","undefined","strippedValue","strippedMax","max","clampOnFrame","animation","now","finished","onFrame","current","warn","prefix","suffix","newValue","onStart","value","previousAnimation","animationBeforeClamped","callback","isHigherOrder","reduceMotion"],"sourceRoot":"../../../src","sources":["animation/clamp.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,QAAQ,WAAW;AASlC,SACEC,eAAe,EACfC,2BAA2B,EAC3BC,qBAAqB,QAChB,QAAQ;AAUf,OAAO,MAAMC,SAAS,GAAG,SAAAA,CACvBC,MAAyD,EACzDC,iBAAkE,EACvC;EAC3B,SAAS;;EACT,OAAOL,eAAe,CACpBK,iBAAiB,EACjB,MAAsB;IACpB,SAAS;;IACT,MAAMC,gBAAgB,GACpB,OAAOD,iBAAiB,KAAK,UAAU,GACnCA,iBAAiB,CAAC,CAAC,GACnBA,iBAAiB;IAEvB,MAAME,WAAW,GACfH,MAAM,CAACI,GAAG,KAAKC,SAAS,GACpBA,SAAS,GACTP,qBAAqB,CAACE,MAAM,CAACI,GAAG,CAAC,CAACE,aAAa;IAErD,MAAMC,WAAW,GACfP,MAAM,CAACQ,GAAG,KAAKH,SAAS,GACpBA,SAAS,GACTP,qBAAqB,CAACE,MAAM,CAACQ,GAAG,CAAC,CAACF,aAAa;IAErD,SAASG,YAAYA,CACnBC,SAAyB,EACzBC,GAAc,EACL;MACT,MAAMC,QAAQ,GAAGV,gBAAgB,CAACW,OAAO,CAACX,gBAAgB,EAAES,GAAG,CAAC;MAEhE,IAAIT,gBAAgB,CAACY,OAAO,KAAKT,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EACxCT,GAAG,EACHW,sBACF,CAAC;IACH;IAEA,MAAMC,QAAQ,GAAIX,QAAkB,IAAW;MAC7C,IAAIV,gBAAgB,CAACqB,QAAQ,EAAE;QAC7BrB,gBAAgB,CAACqB,QAAQ,CAACX,QAAQ,CAAC;MACrC;IACF,CAAC;IAED,OAAO;MACLY,aAAa,EAAE,IAAI;MACnBX,OAAO,EAAEJ,YAAY;MACrBU,OAAO;MACPL,OAAO,EAAEZ,gBAAgB,CAACY,OAAQ;MAClCS,QAAQ;MACRF,iBAAiB,EAAE,IAAI;MACvBI,YAAY,EAAE5B,2BAA2B,CAACG,MAAM,CAACyB,YAAY;IAC/D,CAAC;EACH,CACF,CAAC;AACH,CAAkB","ignoreList":[]}
@@ -1,4 +0,0 @@
'use strict';
export {};
//# sourceMappingURL=commonTypes.js.map
@@ -1 +0,0 @@
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["animation/commonTypes.ts"],"mappings":"AAAA,YAAY;;AAAC","ignoreList":[]}
@@ -1,90 +0,0 @@
'use strict';
import { ReanimatedError } from '../../common';
import { defineAnimation, getReduceMotionForAnimation } from '../util';
import { rigidDecay } from './rigidDecay';
import { rubberBandDecay } from './rubberBandDecay';
import { isValidRubberBandConfig } from './utils';
// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
function validateConfig(config) {
'worklet';
if (config.clamp) {
if (!Array.isArray(config.clamp)) {
throw new ReanimatedError(`\`config.clamp\` must be an array but is ${typeof config.clamp}.`);
}
if (config.clamp.length !== 2) {
throw new ReanimatedError(`\`clamp array\` must contain 2 items but is given ${config.clamp.length}.`);
}
}
if (config.velocityFactor <= 0) {
throw new ReanimatedError(`\`config.velocityFactor\` must be greater then 0 but is ${config.velocityFactor}.`);
}
if (config.rubberBandEffect && !config.clamp) {
throw new ReanimatedError('You need to set `clamp` property when using `rubberBandEffect`.');
}
}
/**
* Lets you create animations that mimic objects in motion with friction.
*
* @param config - The decay animation configuration - {@link DecayConfig}.
* @param callback - A function called upon animation completion -
* {@link AnimationCallback}.
* @returns An [animation
* object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object)
* which holds the current state of the animation.
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay
*/
export const withDecay = function (userConfig, callback) {
'worklet';
return defineAnimation(0, () => {
'worklet';
const config = {
deceleration: 0.998,
velocityFactor: 1,
velocity: 0,
rubberBandFactor: 0.6
};
if (userConfig) {
Object.keys(userConfig).forEach(key => config[key] = userConfig[key]);
}
const decay = isValidRubberBandConfig(config) ? (animation, now) => rubberBandDecay(animation, now, config) : (animation, now) => rigidDecay(animation, now, config);
function onStart(animation, value, now) {
const initialVelocity = config.velocity;
animation.current = value;
animation.lastTimestamp = now;
animation.startTimestamp = now;
animation.initialVelocity = initialVelocity;
animation.velocity = initialVelocity;
validateConfig(config);
if (animation.reduceMotion && config.clamp) {
if (value < config.clamp[0]) {
animation.current = config.clamp[0];
} else if (value > config.clamp[1]) {
animation.current = config.clamp[1];
}
}
}
// To ensure the animation is correctly initialized and starts as expected
// we need to set its current value to undefined.
// Setting current to 0 breaks the animation.
return {
onFrame: decay,
onStart,
callback,
velocity: config.velocity ?? 0,
initialVelocity: 0,
current: undefined,
lastTimestamp: 0,
startTimestamp: 0,
reduceMotion: getReduceMotionForAnimation(config.reduceMotion)
};
});
};
//# sourceMappingURL=decay.js.map
@@ -1 +0,0 @@
{"version":3,"names":["ReanimatedError","defineAnimation","getReduceMotionForAnimation","rigidDecay","rubberBandDecay","isValidRubberBandConfig","validateConfig","config","clamp","Array","isArray","length","velocityFactor","rubberBandEffect","withDecay","userConfig","callback","deceleration","velocity","rubberBandFactor","Object","keys","forEach","key","decay","animation","now","onStart","value","initialVelocity","current","lastTimestamp","startTimestamp","reduceMotion","onFrame","undefined"],"sourceRoot":"../../../../src","sources":["animation/decay/decay.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,QAAQ,cAAc;AAM9C,SAASC,eAAe,EAAEC,2BAA2B,Q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EAAE,CAAC;MACjBC,YAAY,EAAE/B,2BAA2B,CAACK,MAAM,CAAC0B,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAA6B","ignoreList":[]}
@@ -1,4 +0,0 @@
'use strict';
export { withDecay } from './decay';
//# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
{"version":3,"names":["withDecay"],"sourceRoot":"../../../../src","sources":["animation/decay/index.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,QAAQ,SAAS","ignoreList":[]}
@@ -1,30 +0,0 @@
'use strict';
import { SLOPE_FACTOR, VELOCITY_EPS } from './utils';
export function rigidDecay(animation, now, config) {
'worklet';
const {
lastTimestamp,
startTimestamp,
initialVelocity,
current,
velocity
} = animation;
const deltaTime = Math.min(now - lastTimestamp, 64);
const v = velocity * Math.exp(-(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR);
animation.current = current + v * config.velocityFactor * deltaTime / 1000;
animation.velocity = v;
animation.lastTimestamp = now;
if (config.clamp) {
if (initialVelocity < 0 && animation.current <= config.clamp[0]) {
animation.current = config.clamp[0];
return true;
} else if (initialVelocity > 0 && animation.current >= config.clamp[1]) {
animation.current = config.clamp[1];
return true;
}
}
return Math.abs(v) < VELOCITY_EPS;
}
//# sourceMappingURL=rigidDecay.js.map
@@ -1 +0,0 @@
{"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","rigidDecay","animation","now","config","lastTimestamp","startTimestamp","initialVelocity","current","velocity","deltaTime","Math","min","v","exp","deceleration","velocityFactor","clamp","abs"],"sourceRoot":"../../../../src","sources":["animation/decay/rigidDecay.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAEpD,OAAO,SAASC,UAAUA,CACxBC,SAA8B,EAC9BC,GAAW,EACXC,MAA0B,EACjB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,eAAe;IAAEC,OAAO;IAAEC;EAAS,CAAC,GACzEP,SAAS;EAEX,MAAMQ,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACT,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMQ,CAAC,GACLJ,QAAQ,GACRE,IAAI,CAACG,GAAG,CACN,EAAE,CAAC,GAAGV,MAAM,CAACW,YAAY,CAAC,IAAIZ,GAAG,GAAGG,cAAc,CAAC,GAAGP,YACxD,CAAC;EACHG,SAAS,CAACM,OAAO,GAAGA,OAAO,GAAIK,CAAC,GAAGT,MAAM,CAACY,cAAc,GAAGN,SAAS,GAAI,IAAI;EAC5ER,SAAS,CAACO,QAAQ,GAAGI,CAAC;EACtBX,SAAS,CAACG,aAAa,GAAGF,GAAG;EAE7B,IAAIC,MAAM,CAACa,KAAK,EAAE;IAChB,IAAIV,eAAe,GAAG,CAAC,IAAIL,SAAS,CAACM,OAAO,IAAIJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;MAC/Df,SAAS,CAACM,OAAO,GAAGJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC;MACnC,OAAO,IAAI;IACb,CAAC,MAAM,IAAIV,eAAe,GAAG,CAAC,IAAIL,SAAS,CAACM,OAAO,IAAIJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;MACtEf,SAAS,CAACM,OAAO,GAAGJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC;MACnC,OAAO,IAAI;IACb;EACF;EACA,OAAON,IAAI,CAACO,GAAG,CAACL,CAAC,CAAC,GAAGb,YAAY;AACnC","ignoreList":[]}
@@ -1,34 +0,0 @@
'use strict';
import { SLOPE_FACTOR, VELOCITY_EPS } from './utils';
const DERIVATIVE_EPS = 0.1;
export function rubberBandDecay(animation, now, config) {
'worklet';
const {
lastTimestamp,
startTimestamp,
current,
velocity
} = animation;
const deltaTime = Math.min(now - lastTimestamp, 64);
const clampIndex = Math.abs(current - config.clamp[0]) < Math.abs(current - config.clamp[1]) ? 0 : 1;
let derivative = 0;
if (current < config.clamp[0] || current > config.clamp[1]) {
derivative = current - config.clamp[clampIndex];
}
const v = velocity * Math.exp(-(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR) - derivative * config.rubberBandFactor;
if (Math.abs(derivative) > DERIVATIVE_EPS) {
animation.springActive = true;
} else if (animation.springActive) {
animation.current = config.clamp[clampIndex];
return true;
} else if (Math.abs(v) < VELOCITY_EPS) {
return true;
}
animation.current = current + v * config.velocityFactor * deltaTime / 1000;
animation.velocity = v;
animation.lastTimestamp = now;
return false;
}
//# sourceMappingURL=rubberBandDecay.js.map
@@ -1 +0,0 @@
{"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","DERIVATIVE_EPS","rubberBandDecay","animation","now","config","lastTimestamp","startTimestamp","current","velocity","deltaTime","Math","min","clampIndex","abs","clamp","derivative","v","exp","deceleration","rubberBandFactor","springActive","velocityFactor"],"sourceRoot":"../../../../src","sources":["animation/decay/rubberBandDecay.ts"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAEpD,MAAMC,cAAc,GAAG,GAAG;AAE1B,OAAO,SAASC,eAAeA,CAC7BC,SAA8B,EAC9BC,GAAW,EACXC,MAA6B,EACpB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGN,SAAS;EAEtE,MAAMO,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACR,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMO,UAAU,GACdF,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GAAGJ,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GACrE,CAAC,GACD,CAAC;EAEP,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,IAAIP,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,EAAE;IAC1DC,UAAU,GAAGR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;EACjD;EAEA,MAAMI,CAAC,GACLR,QAAQ,GACNE,IAAI,CAACO,GAAG,CACN,EAAE,CAAC,GAAGb,MAAM,CAACc,YAAY,CAAC,IAAIf,GAAG,GAAGG,cAAc,CAAC,GAAGR,YACxD,CAAC,GACHiB,UAAU,GAAGX,MAAM,CAACe,gBAAgB;EAEtC,IAAIT,IAAI,CAACG,GAAG,CAACE,UAAU,CAAC,GAAGf,cAAc,EAAE;IACzCE,SAAS,CAACkB,YAAY,GAAG,IAAI;EAC/B,CAAC,MAAM,IAAIlB,SAAS,CAACkB,YAAY,EAAE;IACjClB,SAAS,CAACK,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;IAC5C,OAAO,IAAI;EACb,CAAC,MAAM,IAAIF,IAAI,CAACG,GAAG,CAACG,CAAC,CAAC,GAAGjB,YAAY,EAAE;IACrC,OAAO,IAAI;EACb;EAEAG,SAAS,CAACK,OAAO,GAAGA,OAAO,GAAIS,CAAC,GAAGZ,MAAM,CAACiB,cAAc,GAAGZ,SAAS,GAAI,IAAI;EAC5EP,SAAS,CAACM,QAAQ,GAAGQ,CAAC;EACtBd,SAAS,CAACG,aAAa,GAAGF,GAAG;EAC7B,OAAO,KAAK;AACd","ignoreList":[]}
@@ -1,33 +0,0 @@
'use strict';
import { IS_WEB } from '../../common';
export const VELOCITY_EPS = IS_WEB ? 1 / 20 : 1;
export const SLOPE_FACTOR = 0.1;
/**
* The decay animation configuration.
*
* @param velocity - Initial velocity of the animation. Defaults to 0.
* @param deceleration - The rate at which the velocity decreases over time.
* Defaults to 0.998.
* @param clamp - Array of two numbers which restricts animation's range.
* Defaults to [].
* @param velocityFactor - Velocity multiplier. Defaults to 1.
* @param rubberBandEffect - Makes the animation bounce over the limit specified
* in `clamp`. Defaults to `false`.
* @param rubberBandFactor - Strength of the rubber band effect. Defaults to
* 0.6.
* @param reduceMotion - Determines how the animation responds to the device's
* reduced motion accessibility setting. Default to `ReduceMotion.System` -
* {@link ReduceMotion}.
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay#config
*/
// If user wants to use rubber band decay animation we have to make sure he has provided clamp
export function isValidRubberBandConfig(config) {
'worklet';
return !!config.rubberBandEffect && Array.isArray(config.clamp) && config.clamp.length === 2;
}
//# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
{"version":3,"names":["IS_WEB","VELOCITY_EPS","SLOPE_FACTOR","isValidRubberBandConfig","config","rubberBandEffect","Array","isArray","clamp","length"],"sourceRoot":"../../../../src","sources":["animation/decay/utils.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,QAAQ,cAAc;AAUrC,OAAO,MAAMC,YAAY,GAAGD,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;AAC/C,OAAO,MAAME,YAAY,GAAG,GAAG;;AAiB/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;;AAMA,OAAO,SAASC,uBAAuBA,CACrCC,MAA0B,EACO;EACjC,SAAS;;EACT,OACE,CAAC,CAACA,MAAM,CAACC,gBAAgB,IACzBC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACI,KAAK,CAAC,IAC3BJ,MAAM,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC;AAE7B","ignoreList":[]}
@@ -1,86 +0,0 @@
'use strict';
import { defineAnimation, getReduceMotionForAnimation } from './util';
// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
/**
* An animation modifier that lets you start an animation with a delay.
*
* @param delayMs - Duration (in milliseconds) before the animation starts.
* @param nextAnimation - The animation to delay.
* @param reduceMotion - Determines how the animation responds to the device's
* reduced motion accessibility setting. Default to `ReduceMotion.System` -
* {@link ReduceMotion}.
* @returns An [animation
* object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object)
* which holds the current state of the animation.
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDelay
*/
export const withDelay = function (delayMs, _nextAnimation, reduceMotion) {
'worklet';
return defineAnimation(_nextAnimation, () => {
'worklet';
const nextAnimation = typeof _nextAnimation === 'function' ? _nextAnimation() : _nextAnimation;
function delay(animation, now) {
const {
startTime,
started,
previousAnimation
} = animation;
const current = animation.current;
if (now - startTime >= delayMs || animation.reduceMotion) {
if (!started) {
nextAnimation.onStart(nextAnimation, current, now, previousAnimation);
animation.previousAnimation = null;
animation.started = true;
}
const finished = nextAnimation.onFrame(nextAnimation, now);
animation.current = nextAnimation.current;
return finished;
} else if (previousAnimation) {
const finished = previousAnimation.finished || previousAnimation.onFrame(previousAnimation, now);
animation.current = previousAnimation.current;
if (finished) {
animation.previousAnimation = null;
}
}
return false;
}
function onStart(animation, value, now, previousAnimation) {
animation.startTime = now;
animation.started = false;
animation.current = value;
if (previousAnimation === animation) {
animation.previousAnimation = previousAnimation.previousAnimation;
} else {
animation.previousAnimation = previousAnimation;
}
// child animations inherit the setting, unless they already have it defined
// they will have it defined only if the user used the `reduceMotion` prop
if (nextAnimation.reduceMotion === undefined) {
nextAnimation.reduceMotion = animation.reduceMotion;
}
}
const callback = finished => {
if (nextAnimation.callback) {
nextAnimation.callback(finished);
}
};
return {
isHigherOrder: true,
onFrame: delay,
onStart,
current: nextAnimation.current,
callback,
previousAnimation: null,
startTime: 0,
started: false,
reduceMotion: getReduceMotionForAnimation(reduceMotion)
};
});
};
//# sourceMappingURL=delay.js.map
@@ -1 +0,0 @@
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withDelay","delayMs","_nextAnimation","reduceMotion","nextAnimation","delay","animation","now","startTime","started","previousAnimation","current","onStart","finished","onFrame","value","undefined","callback","isHigherOrder"],"sourceRoot":"../../../src","sources":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P,SAAS,CAACI,iBAAiB,GAAG,IAAI;QACpC;MACF;MACA,OAAO,KAAK;IACd;IAEA,SAASE,OAAOA,CACdN,SAAyB,EACzBS,KAAsB,EACtBR,GAAc,EACdG,iBAAwC,EAClC;MACNJ,SAAS,CAACE,SAAS,GAAGD,GAAG;MACzBD,SAAS,CAACG,OAAO,GAAG,KAAK;MACzBH,SAAS,CAACK,OAAO,GAAGI,KAAK;MACzB,IAAIL,iBAAiB,KAAKJ,SAAS,EAAE;QACnCA,SAAS,CAACI,iBAAiB,GAAGA,iBAAiB,CAACA,iBAAiB;MACnE,CAAC,MAAM;QACLJ,SAAS,CAACI,iBAAiB,GAAGA,iBAAiB;MACjD;;MAEA;MACA;MACA,IAAIN,aAAa,CAACD,YAAY,KAAKa,SAAS,EAAE;QAC5CZ,aAAa,CAACD,YAAY,GAAGG,SAAS,CAACH,YAAY;MACrD;IACF;IAEA,MAAMc,QAAQ,GAAIJ,QAAkB,IAAW;MAC7C,IAAIT,aAAa,CAACa,QAAQ,EAAE;QAC1Bb,aAAa,CAACa,QAAQ,CAACJ,QAAQ,CAAC;MAClC;IACF,CAAC;IAED,OAAO;MACLK,aAAa,EAAE,IAAI;MACnBJ,OAAO,EAAET,KAAK;MACdO,OAAO;MACPD,OAAO,EAAEP,aAAa,CAACO,OAAQ;MAC/BM,QAAQ;MACRP,iBAAiB,EAAE,IAAI;MACvBF,SAAS,EAAE,CAAC;MACZC,OAAO,EAAE,KAAK;MACdN,YAAY,EAAEJ,2BAA2B,CAACI,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH,CAAkB","ignoreList":[]}
@@ -1,12 +0,0 @@
'use strict';
export { withClamp } from './clamp';
export { withDecay } from './decay';
export { withDelay } from './delay';
export { withRepeat } from './repeat';
export { withSequence } from './sequence';
export { GentleSpringConfig, GentleSpringConfigWithDuration, Reanimated3DefaultSpringConfig, Reanimated3DefaultSpringConfigWithDuration, SnappySpringConfig, SnappySpringConfigWithDuration, WigglySpringConfig, WigglySpringConfigWithDuration, withSpring } from './spring';
export { withStyleAnimation } from './styleAnimation';
export { withTiming } from './timing';
export { cancelAnimation, defineAnimation, initialUpdaterRun } from './util';
//# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
{"version":3,"names":["withClamp","withDecay","withDelay","withRepeat","withSequence","GentleSpringConfig","GentleSpringConfigWithDuration","Reanimated3DefaultSpringConfig","Reanimated3DefaultSpringConfigWithDuration","SnappySpringConfig","SnappySpringConfigWithDuration","WigglySpringConfig","WigglySpringConfigWithDuration","withSpring","withStyleAnimation","withTiming","cancelAnimation","defineAnimation","initialUpdaterRun"],"sourceRoot":"../../../src","sources":["animation/index.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,QAAQ,SAAS;AAQnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,YAAY,QAAQ,YAAY;AAEzC,SACEC,kBAAkB,EAClBC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,0CAA0C,EAC1CC,kBAAkB,EAClBC,8BAA8B,EAC9BC,kBAAkB,EAClBC,8BAA8B,EAC9BC,UAAU,QACL,UAAU;AACjB,SAASC,kBAAkB,QAAQ,kBAAkB;AAErD,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,eAAe,EAAEC,eAAe,EAAEC,iBAAiB,QAAQ,QAAQ","ignoreList":[]}
@@ -1,94 +0,0 @@
'use strict';
import { defineAnimation, getReduceMotionForAnimation } from './util';
// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
/**
* Lets you repeat an animation given number of times or run it indefinitely.
*
* @param animation - An animation object you want to repeat.
* @param numberOfReps - The number of times the animation is going to be
* repeated. Defaults to 2.
* @param reverse - Whether the animation should run in reverse every other
* repetition. Defaults to false.
* @param callback - A function called on animation complete.
* @param reduceMotion - Determines how the animation responds to the device's
* reduced motion accessibility setting. Default to `ReduceMotion.System` -
* {@link ReduceMotion}.
* @returns An [animation
* object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object)
* which holds the current state of the animation.
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withRepeat
*/
export const withRepeat = function (_nextAnimation, numberOfReps = 2, reverse = false, callback, reduceMotion) {
'worklet';
return defineAnimation(_nextAnimation, () => {
'worklet';
const nextAnimation = typeof _nextAnimation === 'function' ? _nextAnimation() : _nextAnimation;
function repeat(animation, now) {
const finished = nextAnimation.onFrame(nextAnimation, now);
animation.current = nextAnimation.current;
if (finished) {
animation.reps += 1;
// call inner animation's callback on every repetition
// as the second argument the animation's current value is passed
if (nextAnimation.callback) {
nextAnimation.callback(true /* finished */, animation.current);
}
if (animation.reduceMotion || numberOfReps > 0 && animation.reps >= numberOfReps) {
return true;
}
const startValue = reverse ? nextAnimation.current : animation.startValue;
if (reverse) {
nextAnimation.toValue = animation.startValue;
animation.startValue = startValue;
}
nextAnimation.onStart(nextAnimation, startValue, now, nextAnimation.previousAnimation);
return false;
}
return false;
}
const repCallback = finished => {
if (callback) {
callback(finished);
}
// when cancelled call inner animation's callback
if (!finished && nextAnimation.callback) {
nextAnimation.callback(false /* finished */);
}
};
function onStart(animation, value, now, previousAnimation) {
animation.startValue = value;
animation.reps = 0;
// child animations inherit the setting, unless they already have it defined
// they will have it defined only if the user used the `reduceMotion` prop
if (nextAnimation.reduceMotion === undefined) {
nextAnimation.reduceMotion = animation.reduceMotion;
}
// don't start the animation if reduced motion is enabled and
// the animation would end at its starting point
if (animation.reduceMotion && reverse && (numberOfReps <= 0 || numberOfReps % 2 === 0)) {
animation.current = animation.startValue;
animation.onFrame = () => true;
} else {
nextAnimation.onStart(nextAnimation, value, now, previousAnimation);
}
}
return {
isHigherOrder: true,
onFrame: repeat,
onStart,
reps: 0,
current: nextAnimation.current,
callback: repCallback,
startValue: 0,
reduceMotion: getReduceMotionForAnimation(reduceMotion)
};
});
};
//# sourceMappingURL=repeat.js.map
@@ -1 +0,0 @@
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withRepeat","_nextAnimation","numberOfReps","reverse","callback","reduceMotion","nextAnimation","repeat","animation","now","finished","onFrame","current","reps","startValue","toValue","onStart","previousAnimation","repCallback","value","undefined","isHigherOrder"],"sourceRoot":"../../../src","sources":["animation/repeat.ts"],"mappings":"AAAA,YAAY;;AAUZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAErE;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,SAAAA,CACxBC,cAA6B,EAC7BC,YAAY,GAAG,CAAC,EAChBC,OAAO,GAAG,KAAK,EACfC,QAA4B,EAC5BC,YAA2B,EACC;EAC5B,SAAS;;EAET,OAAOP,eAAe,CACpBG,cAAc,EACd,MAAuB;IACrB,SAAS;;IAET,MAAMK,aAAa,GACjB,OAAOL,cAAc,KAAK,UAAU,GAChCA,cAAc,CAAC,CAAC,GAChBA,cAAc;IAEpB,SAASM,MAAMA,CAACC,SAA0B,EAAEC,GAAc,EAAW;MACnE,MAAMC,QAAQ,GAAGJ,aAAa,CAACK,OAAO,CAACL,aAAa,EAAEG,GAAG,CAAC;MAC1DD,SAAS,CAACI,OAAO,GAAGN,aAAa,CAACM,OAAO;MACzC,IAAIF,QAAQ,EAAE;QACZF,SAAS,CAACK,IAAI,IAAI,CAAC;QACnB;QACA;QACA,IAAIP,aAAa,CAACF,QAAQ,EAAE;UAC1BE,aAAa,CAACF,QAAQ,CAAC,IAAI,CAAC,gBAAgBI,SAAS,CAACI,OAAO,CAAC;QAChE;QACA,IACEJ,SAAS,CAACH,YAAY,IACrBH,YAAY,GAAG,CAAC,IAAIM,SAAS,CAACK,IAAI,IAAIX,YAAa,EACpD;UACA,OAAO,IAAI;QACb;QAEA,MAAMY,UAAU,GAAGX,OAAO,GACrBG,aAAa,CAACM,OAAO,GACtBJ,SAAS,CAACM,UAAU;Q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AAa,CAACM,OAAO;MAC9BR,QAAQ,EAAEc,WAAW;MACrBJ,UAAU,EAAE,CAAC;MACbT,YAAY,EAAEN,2BAA2B,CAACM,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH,CAAmB","ignoreList":[]}
@@ -1,125 +0,0 @@
'use strict';
import { logger } from '../common';
import { defineAnimation, getReduceMotionForAnimation } from './util';
/**
* Lets you run animations in a sequence.
*
* @param reduceMotion - Determines how the animation responds to the device's
* reduced motion accessibility setting. Default to `ReduceMotion.System` -
* {@link ReduceMotion}.
* @param animations - Any number of animation objects to be run in a sequence.
* @returns An [animation
* object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object)
* which holds the current state of the animation/
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSequence
*/
export function withSequence(_reduceMotionOrFirstAnimation, ..._animations) {
'worklet';
let reduceMotion;
// the first argument is either a config or an animation
// this is done to allow the reduce motion config prop to be optional
if (_reduceMotionOrFirstAnimation) {
if (typeof _reduceMotionOrFirstAnimation === 'string') {
reduceMotion = _reduceMotionOrFirstAnimation;
} else {
_animations.unshift(_reduceMotionOrFirstAnimation);
}
}
if (_animations.length === 0) {
logger.warn('No animation was provided for the sequence');
return defineAnimation(0, () => {
'worklet';
return {
onStart: (animation, value) => animation.current = value,
onFrame: () => true,
current: 0,
animationIndex: 0,
reduceMotion: getReduceMotionForAnimation(reduceMotion)
};
});
}
return defineAnimation(_animations[0], () => {
'worklet';
const animations = _animations.map(a => {
const result = typeof a === 'function' ? a() : a;
result.finished = false;
return result;
});
function findNextNonReducedMotionAnimationIndex(index) {
// the last animation is returned even if reduced motion is enabled,
// because we want the sequence to finish at the right spot
while (index < animations.length - 1 && animations[index].reduceMotion) {
if (typeof animations[index].callback === 'function') {
animations[index].callback?.(true);
}
index++;
}
return index;
}
const callback = finished => {
if (finished) {
// we want to call the callback after every single animation
// not after all of them
return;
}
// this is going to be called only if sequence has been cancelled
animations.forEach(animation => {
if (typeof animation.callback === 'function' && !animation.finished) {
animation.callback(finished);
}
});
};
function sequence(animation, now) {
const currentAnim = animations[animation.animationIndex];
const finished = currentAnim.onFrame(currentAnim, now);
animation.current = currentAnim.current;
if (finished) {
// we want to call the callback after every single animation
if (currentAnim.callback) {
currentAnim.callback(true /* finished */);
}
currentAnim.finished = true;
animation.animationIndex = findNextNonReducedMotionAnimationIndex(animation.animationIndex + 1);
if (animation.animationIndex < animations.length) {
const nextAnim = animations[animation.animationIndex];
nextAnim.onStart(nextAnim, currentAnim.current, now, currentAnim);
return false;
}
return true;
}
return false;
}
function onStart(animation, value, now, previousAnimation) {
// child animations inherit the setting, unless they already have it defined
// they will have it defined only if the user used the `reduceMotion` prop
animations.forEach(anim => {
if (anim.reduceMotion === undefined) {
anim.reduceMotion = animation.reduceMotion;
}
});
animation.animationIndex = findNextNonReducedMotionAnimationIndex(0);
if (previousAnimation === undefined) {
previousAnimation = animations[animations.length - 1];
}
const currentAnimation = animations[animation.animationIndex];
currentAnimation.onStart(currentAnimation, value, now, previousAnimation);
}
return {
isHigherOrder: true,
onFrame: sequence,
onStart,
animationIndex: 0,
current: animations[0].current,
callback,
reduceMotion: getReduceMotionForAnimation(reduceMotion)
};
});
}
//# sourceMappingURL=sequence.js.map
@@ -1 +0,0 @@
{"version":3,"names":["logger","defineAnimation","getReduceMotionForAnimation","withSequence","_reduceMotionOrFirstAnimation","_animations","reduceMotion","unshift","length","warn","onStart","animation","value","current","onFrame","animationIndex","animations","map","a","result","finished","findNextNonReducedMotionAnimationIndex","index","callback","forEach","sequence","now","currentAnim","nextAnim","previousAnimation","anim","undefined","currentAnimation","isHigherOrder"],"sourceRoot":"../../../src","sources":["animation/sequence.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,QAAQ,WAAW;AASlC,SAASC,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAO,SAASC,YAAYA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A4B,EAC5BC,KAAsB,EACtBc,GAAc,EACdG,iBAAoC,EAC9B;MACN;MACA;MACAb,UAAU,CAACQ,OAAO,CAAEM,IAAI,IAAK;QAC3B,IAAIA,IAAI,CAACxB,YAAY,KAAKyB,SAAS,EAAE;UACnCD,IAAI,CAACxB,YAAY,GAAGK,SAAS,CAACL,YAAY;QAC5C;MACF,CAAC,CAAC;MACFK,SAAS,CAACI,cAAc,GAAGM,sCAAsC,CAAC,CAAC,CAAC;MAEpE,IAAIQ,iBAAiB,KAAKE,SAAS,EAAE;QACnCF,iBAAiB,GAAGb,UAAU,CAC5BA,UAAU,CAACR,MAAM,GAAG,CAAC,CACD;MACxB;MAEA,MAAMwB,gBAAgB,GAAGhB,UAAU,CAACL,SAAS,CAACI,cAAc,CAAC;MAC7DiB,gBAAgB,CAACtB,OAAO,CACtBsB,gBAAgB,EAChBpB,KAAK,EACLc,GAAG,EACHG,iBACF,CAAC;IACH;IAEA,OAAO;MACLI,aAAa,EAAE,IAAI;MACnBnB,OAAO,EAAEW,QAAQ;MACjBf,OAAO;MACPK,cAAc,EAAE,CAAC;MACjBF,OAAO,EAAEG,UAAU,CAAC,CAAC,CAAC,CAACH,OAAO;MAC9BU,QAAQ;MACRjB,YAAY,EAAEJ,2BAA2B,CAACI,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH","ignoreList":[]}
@@ -1,6 +0,0 @@
'use strict';
export * from './spring';
export * from './springConfigs';
export * from './springUtils';
//# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["animation/spring/index.ts"],"mappings":"AAAA,YAAY;;AAEZ,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,eAAe","ignoreList":[]}
@@ -1,169 +0,0 @@
'use strict';
import { defineAnimation, getReduceMotionForAnimation } from '../util';
import { GentleSpringConfig, GentleSpringConfigWithDuration } from './springConfigs';
import { calculateNewStiffnessToMatchDuration, checkIfConfigIsValid, criticallyDampedSpringCalculations, getEnergy, initialCalculations, isAnimationTerminatingCalculation, safeMergeConfigs, scaleZetaToMatchClamps, underDampedSpringCalculations } from './springUtils';
// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
/**
* Lets you create spring-based animations.
*
* @param toValue - The value at which the animation will come to rest -
* {@link AnimatableValue}
* @param config - The spring animation configuration - {@link SpringConfig}.
* Defaults to {@link GentleSpringConfig}. You can use other predefined spring
* configurations, such as {@link WigglySpringConfig},
* {@link SnappySpringConfig}, {@link Reanimated3DefaultSpringConfig} or create
* your own.
* @param callback - A function called on animation complete -
* {@link AnimationCallback}
* @returns An [animation
* object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object)
* which holds the current state of the animation
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring
*/
export const withSpring = (toValue, userConfig, callback) => {
'worklet';
return defineAnimation(toValue, () => {
'worklet';
const defaultConfig = {
...GentleSpringConfig,
...GentleSpringConfigWithDuration,
overshootClamping: false,
energyThreshold: 6e-9,
velocity: 0,
reduceMotion: undefined,
clamp: undefined
};
const config = safeMergeConfigs({
...defaultConfig,
useDuration: !!(userConfig?.duration || userConfig?.dampingRatio),
skipAnimation: false
}, userConfig);
config.skipAnimation = !checkIfConfigIsValid(config);
if (config.duration === 0) {
config.skipAnimation = true;
}
function springOnFrame(animation, now) {
// eslint-disable-next-line @typescript-eslint/no-shadow
const {
toValue,
current
} = animation;
if (config.skipAnimation) {
animation.current = toValue;
animation.lastTimestamp = 0;
return true;
}
const {
lastTimestamp,
velocity
} = animation;
const deltaTime = Math.min(now - lastTimestamp, 64);
animation.lastTimestamp = now;
const t = deltaTime / 1000;
const v0 = velocity;
const x0 = current - toValue;
const {
zeta,
omega0,
omega1
} = animation;
const {
position: newPosition,
velocity: newVelocity
} = zeta < 1 ? underDampedSpringCalculations(animation, {
zeta,
v0,
x0,
omega0,
omega1,
t
}) : criticallyDampedSpringCalculations(animation, {
v0,
x0,
omega0,
t
});
animation.current = newPosition;
animation.velocity = newVelocity;
if (isAnimationTerminatingCalculation(animation, config)) {
animation.velocity = 0;
animation.current = toValue;
// clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one
animation.lastTimestamp = 0;
return true;
}
return false;
}
function isTriggeredTwice(previousAnimation, animation) {
return previousAnimation?.lastTimestamp && previousAnimation?.startTimestamp && previousAnimation?.toValue === animation.toValue && previousAnimation?.duration === animation.duration && previousAnimation?.dampingRatio === animation.dampingRatio;
}
function onStart(animation, value, now, previousAnimation) {
animation.current = value;
let stiffness = config.stiffness;
const triggeredTwice = isTriggeredTwice(previousAnimation, animation);
const duration = config.duration;
const x0 = triggeredTwice ?
// If animation is triggered twice we want to continue the previous animation
// form the previous starting point
previousAnimation?.startValue : value - animation.toValue;
animation.startValue = x0;
if (previousAnimation) {
animation.velocity = (triggeredTwice ? previousAnimation?.velocity : previousAnimation?.velocity + config.velocity) || 0;
} else {
animation.velocity = config.velocity || 0;
}
if (triggeredTwice) {
animation.zeta = previousAnimation?.zeta || 0;
animation.omega0 = previousAnimation?.omega0 || 0;
animation.omega1 = previousAnimation?.omega1 || 0;
} else {
if (config.useDuration) {
const actualDuration = triggeredTwice ?
// If animation is triggered twice we want to continue the previous animation
// so we need to include the time that already elapsed
duration - ((previousAnimation?.lastTimestamp || 0) - (previousAnimation?.startTimestamp || 0)) : duration;
config.duration = actualDuration;
stiffness = calculateNewStiffnessToMatchDuration(x0, config, animation.velocity);
config.stiffness = stiffness;
}
const {
zeta,
omega0,
omega1
} = initialCalculations(stiffness, config);
animation.zeta = zeta;
animation.omega0 = omega0;
animation.omega1 = omega1;
if (config.clamp !== undefined) {
animation.zeta = scaleZetaToMatchClamps(animation, config.clamp);
}
}
const initialEnergy = getEnergy(x0, config.velocity, config.stiffness, config.mass);
animation.initialEnergy = initialEnergy;
animation.lastTimestamp = previousAnimation?.lastTimestamp || now;
animation.startTimestamp = triggeredTwice ? previousAnimation?.startTimestamp || now : now;
}
return {
onFrame: springOnFrame,
onStart,
toValue,
velocity: config.velocity || 0,
current: toValue,
startValue: 0,
callback,
lastTimestamp: 0,
startTimestamp: 0,
zeta: 0,
omega0: 0,
omega1: 0,
initialEnergy: 0,
reduceMotion: getReduceMotionForAnimation(config.reduceMotion)
};
});
};
//# sourceMappingURL=spring.js.map
File diff suppressed because one or more lines are too long
@@ -1,68 +0,0 @@
'use strict';
export const Reanimated3DefaultSpringConfig = {
damping: 10,
mass: 1,
stiffness: 100
};
export const Reanimated3DefaultSpringConfigWithDuration = {
duration: 1333,
dampingRatio: 0.5
};
export const WigglySpringConfig = {
damping: 90,
mass: 4,
stiffness: 900
};
export const WigglySpringConfigWithDuration = {
duration: 550,
dampingRatio: 0.75
};
export const GentleSpringConfig = {
damping: 120,
mass: 4,
stiffness: 900
};
export const GentleSpringConfigWithDuration = {
duration: 550,
dampingRatio: 1
};
export const SnappySpringConfig = {
damping: 110,
mass: 4,
stiffness: 900,
overshootClamping: true
};
export const SnappySpringConfigWithDuration = {
duration: 550,
dampingRatio: 0.92,
overshootClamping: true
};
/**
* Spring animation configuration.
*
* @param mass - The weight of the spring. Reducing this value makes the
* animation faster. Defaults to 4.
* @param damping - How quickly a spring slows down. Higher damping means the
* spring will come to rest faster. Defaults to 120.
* @param stiffness - How bouncy the spring is. Defaults to 900.
* @param duration - Perceptual duration of the animation in milliseconds.
* Actual duration is 1.5 times the value of perceptual duration. Defaults to
* 550ms if `dampingRatio` is provided.
* @param dampingRatio - How damped the spring is. Value `1` means the spring is
* critically damped, value `<1` means the spring is underdamped and value
* `>1` means the spring is overdamped. Defaults to 1 if `duration` is
* provided.
* @param velocity - Initial velocity applied to the spring equation. Defaults
* to 0.
* @param overshootClamping - Whether a spring can bounce over the `toValue`.
* Defaults to false.
* @param energyThreshold - Relative energy threshold below which the spring
* will snap to `toValue` without further oscillations. Defaults to 6e-9.
* @param reduceMotion - Determines how the animation responds to the device's
* reduced motion accessibility setting. Default to `ReduceMotion.System` -
* {@link ReduceMotion}.
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring/#config-
*/
//# sourceMappingURL=springConfigs.js.map
@@ -1 +0,0 @@
{"version":3,"names":["Reanimated3DefaultSpringConfig","damping","mass","stiffness","Reanimated3DefaultSpringConfigWithDuration","duration","dampingRatio","WigglySpringConfig","WigglySpringConfigWithDuration","GentleSpringConfig","GentleSpringConfigWithDuration","SnappySpringConfig","overshootClamping","SnappySpringConfigWithDuration"],"sourceRoot":"../../../../src","sources":["animation/spring/springConfigs.ts"],"mappings":"AAAA,YAAY;;AAIZ,OAAO,MAAMA,8BAA8B,GAAG;EAC5CC,OAAO,EAAE,EAAE;EACXC,IAAI,EAAE,CAAC;EACPC,SAAS,EAAE;AACb,CAAiC;AAEjC,OAAO,MAAMC,0CAA0C,GAAG;EACxDC,QAAQ,EAAE,IAAI;EACdC,YAAY,EAAE;AAChB,CAAiC;AAEjC,OAAO,MAAMC,kBAAkB,GAAG;EAChCN,OAAO,EAAE,EAAE;EACXC,IAAI,EAAE,CAAC;EACPC,SAAS,EAAE;AACb,CAAiC;AAEjC,OAAO,MAAMK,8BAA8B,GAAG;EAC5CH,QAAQ,EAAE,GAAG;EACbC,YAAY,EAAE;AAChB,CAAiC;AAEjC,OAAO,MAAMG,kBAAkB,GAAG;EAChCR,OAAO,EAAE,GAAG;EACZC,IAAI,EAAE,CAAC;EACPC,SAAS,EAAE;AACb,CAAiC;AAEjC,OAAO,MAAMO,8BAA8B,GAAG;EAC5CL,QAAQ,EAAE,GAAG;EACbC,YAAY,EAAE;AAChB,CAAiC;AAEjC,OAAO,MAAMK,kBAAkB,GAAG;EAChCV,OAAO,EAAE,GAAG;EACZC,IAAI,EAAE,CAAC;EACPC,SAAS,EAAE,GAAG;EACdS,iBAAiB,EAAE;AACrB,CAAiC;AAEjC,OAAO,MAAMC,8BAA8B,GAAG;EAC5CR,QAAQ,EAAE,GAAG;EACbC,YAAY,EAAE,IAAI;EAClBM,iBAAiB,EAAE;AACrB,CAAiC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,286 +0,0 @@
'use strict';
import { logger } from '../../common';
// This type contains all the properties from SpringConfig, which are changed to be required,
// except for optional 'reduceMotion' and 'clamp'
export function checkIfConfigIsValid(config) {
'worklet';
let errorMessage = '';
['stiffness', 'damping', 'dampingRatio', 'mass', 'energyThreshold'].forEach(prop => {
const value = config[prop];
if (value <= 0) {
errorMessage += `, ${prop} must be grater than zero but got ${value}`;
}
});
if (config.duration < 0) {
errorMessage += `, duration can't be negative, got ${config.duration}`;
}
if (config.clamp?.min && config.clamp?.max && config.clamp.min > config.clamp.max) {
errorMessage += `, clamp.min should be lower than clamp.max, got clamp: {min: ${config.clamp.min}, max: ${config.clamp.max}} `;
}
if (errorMessage !== '') {
logger.warn('Invalid spring config' + errorMessage);
}
return errorMessage === '';
}
export function safeMergeConfigs(defaults, userConfig) {
'worklet';
if (!userConfig) {
return defaults;
}
const filtered = Object.fromEntries(Object.entries(userConfig).filter(([, v]) => v !== undefined));
return {
...defaults,
...filtered
};
}
function bisectRoot({
min,
max,
func,
precision,
maxIterations = 20
}) {
'worklet';
const direction = func(max) >= func(min) ? 1 : -1;
let idx = maxIterations;
let current = (max + min) / 2;
while (Math.abs(func(current)) > precision && idx > 0) {
idx -= 1;
if (func(current) * direction < 0) {
min = current;
} else {
max = current;
}
current = (min + max) / 2;
}
return current;
}
export function initialCalculations(stiffness = 0, config) {
'worklet';
if (config.skipAnimation) {
return {
zeta: 0,
omega0: 0,
omega1: 0
};
}
if (config.useDuration) {
const {
mass: m,
dampingRatio: zeta
} = config;
/**
* Omega0 and omega1 denote angular frequency and natural angular frequency,
* see this link for formulas:
* https://courses.lumenlearning.com/suny-osuniversityphysics/chapter/15-5-damped-oscillations/
*/
const omega0 = Math.sqrt(stiffness / m);
const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);
return {
zeta,
omega0,
omega1
};
} else {
const {
damping: c,
mass: m,
stiffness: k
} = config;
const zeta = c / (2 * Math.sqrt(k * m)); // damping ratio
const omega0 = Math.sqrt(k / m); // undamped angular frequency of the oscillator (rad/ms)
const omega1 = omega0 * Math.sqrt(1 - zeta ** 2); // exponential decay
return {
zeta,
omega0,
omega1
};
}
}
/**
* We make an assumption that we can manipulate zeta without changing duration
* of movement. According to theory this change is small and tests shows that we
* can indeed ignore it.
*/
export function scaleZetaToMatchClamps(animation, clamp) {
'worklet';
const {
zeta,
toValue,
startValue
} = animation;
const toValueNum = Number(toValue);
if (startValue === 0) {
return zeta;
}
const [firstBound, secondBound] = startValue <= 0 ? [clamp.min, clamp.max] : [clamp.max, clamp.min];
/**
* The extrema we get from equation below are relative (we obtain a ratio), To
* get absolute extrema we convert it as follows:
*
* AbsoluteExtremum = startValue ± RelativeExtremum * (toValue - startValue)
* Where ± denotes:
*
* - If extremum is over the target
* - Otherwise
*/
const relativeExtremum1 = secondBound !== undefined ? Math.abs((secondBound - toValueNum) / startValue) : undefined;
const relativeExtremum2 = firstBound !== undefined ? Math.abs((firstBound - toValueNum) / startValue) : undefined;
/**
* Use this formula http://hyperphysics.phy-astr.gsu.edu/hbase/oscda.html to
* calculate first two extrema. These extrema are located where cos = +- 1
*
* Therefore the first two extrema are:
*
* Math.exp(-zeta * Math.PI); (over the target)
* Math.exp(-zeta * 2 * Math.PI); (before the target)
*/
const newZeta1 = relativeExtremum1 !== undefined ? Math.abs(Math.log(relativeExtremum1) / Math.PI) : undefined;
const newZeta2 = relativeExtremum2 !== undefined ? Math.abs(Math.log(relativeExtremum2) / (2 * Math.PI)) : undefined;
const zetaSatisfyingClamp = [newZeta1, newZeta2].filter(x => x !== undefined);
// The bigger is zeta the smaller are bounces, we return the biggest one
// because it should satisfy all conditions
return Math.max(...zetaSatisfyingClamp, zeta);
}
export function getEnergy(displacement, velocity, stiffness, mass) {
'worklet';
const potentialEnergy = 0.5 * stiffness * displacement ** 2;
const kineticEnergy = 0.5 * mass * velocity ** 2;
return potentialEnergy + kineticEnergy;
}
/** Runs before initial */
export function calculateNewStiffnessToMatchDuration(x0, config, v0) {
'worklet';
if (config.skipAnimation) {
return 0;
}
/**
* Use this formula:
* https://phys.libretexts.org/Bookshelves/University_Physics/Book%3A_University_Physics_(OpenStax)/Book%3A_University_Physics_I_-_Mechanics_Sound_Oscillations_and_Waves_(OpenStax)/15%3A_Oscillations/15.06%3A_Damped_Oscillations
* to find the asymptote and estimate the damping that gives us the expected
* duration
*
* ⎛ ⎛ c⎞ ⎞
* ⎜-⎜──⎟ ⋅ duration⎟
* ⎝ ⎝2m⎠ ⎠
* A ⋅ e = threshold
*/
const {
dampingRatio: zeta,
energyThreshold: threshold,
mass: m,
duration: targetDuration
} = config;
const energyDiffForStiffness = stiffness => {
'worklet';
const perceptualCoefficient = 1.5;
const MILLISECONDS_IN_SECOND = 1000;
const settlingDuration = targetDuration * perceptualCoefficient / MILLISECONDS_IN_SECOND;
const omega0 = Math.sqrt(stiffness / m) * zeta;
const xtk = (x0 + (v0 + x0 * omega0) * settlingDuration) * Math.exp(-omega0 * settlingDuration);
const vtk = (x0 + (v0 + x0 * omega0) * settlingDuration) * Math.exp(-omega0 * settlingDuration) * -omega0 + (v0 + x0 * omega0) * Math.exp(-omega0 * settlingDuration);
const e0 = getEnergy(x0, v0, stiffness, m);
const etk = getEnergy(xtk, vtk, stiffness, m);
const energyFraction = etk / e0;
return energyFraction - threshold;
};
const precision = config.energyThreshold * 1e-3; // Experimentally seems to be good enough.
// Bisection turns out to be much faster than Newton's method in our case
return bisectRoot({
min: Number.EPSILON,
max: 8e3 /* Stiffness for 8ms animation doesn't exceed 2e3, we add some safety margin on top of that. */,
func: energyDiffForStiffness,
precision,
maxIterations: 100
});
}
export function criticallyDampedSpringCalculations(animation, precalculatedValues) {
'worklet';
const {
toValue
} = animation;
const {
v0,
x0,
omega0,
t
} = precalculatedValues;
const criticallyDampedEnvelope = Math.exp(-omega0 * t);
const criticallyDampedPosition = toValue + criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);
const criticallyDampedVelocity = criticallyDampedEnvelope * -omega0 * (x0 + (v0 + omega0 * x0) * t) + criticallyDampedEnvelope * (v0 + omega0 * x0);
return {
position: criticallyDampedPosition,
velocity: criticallyDampedVelocity
};
}
export function underDampedSpringCalculations(animation, precalculatedValues) {
'worklet';
const {
toValue
} = animation;
const {
zeta,
t,
omega0,
omega1,
x0,
v0
} = precalculatedValues;
const sin1 = Math.sin(omega1 * t);
const cos1 = Math.cos(omega1 * t);
// under damped
const underDampedEnvelope = Math.exp(-zeta * omega0 * t);
const underDampedFrag1 = underDampedEnvelope * (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);
const underDampedPosition = toValue + underDampedFrag1;
// This looks crazy -- it's actually just the derivative of the oscillation function
const underDampedVelocity = -zeta * omega0 * underDampedFrag1 + underDampedEnvelope * (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);
return {
position: underDampedPosition,
velocity: underDampedVelocity
};
}
export function isAnimationTerminatingCalculation(animation, config) {
'worklet';
const {
toValue,
velocity,
startValue,
current,
initialEnergy
} = animation;
if (config.overshootClamping) {
const leftBound = startValue >= 0 ? toValue : toValue + startValue;
const rightBound = leftBound + Math.abs(startValue);
if (current < leftBound || current > rightBound) {
return true;
}
}
const currentEnergy = getEnergy(toValue - current, velocity, config.stiffness, config.mass);
return initialEnergy === 0 || currentEnergy / initialEnergy <= config.energyThreshold;
}
//# sourceMappingURL=springUtils.js.map
File diff suppressed because one or more lines are too long
@@ -1,180 +0,0 @@
'use strict';
import { ColorProperties } from '../Colors';
import { logger, processColor } from '../common';
import { withTiming } from './timing';
import { defineAnimation, isValidLayoutAnimationProp } from './util';
// resolves path to value for nested objects
// if path cannot be resolved returns undefined
function resolvePath(obj, path) {
'worklet';
const keys = Array.isArray(path) ? path : [path];
return keys.reduce((acc, current) => {
if (Array.isArray(acc) && typeof current === 'number') {
return acc[current];
} else if (acc !== null && typeof acc === 'object' && current in acc) {
return acc[current];
}
return undefined;
}, obj);
}
// set value at given path
function setPath(obj, path, value) {
'worklet';
const keys = Array.isArray(path) ? path : [path];
let currObj = obj;
for (let i = 0; i < keys.length - 1; i++) {
// creates entry if there isn't one
currObj = currObj;
if (!(keys[i] in currObj)) {
// if next key is a number create an array
if (typeof keys[i + 1] === 'number') {
currObj[keys[i]] = [];
} else {
currObj[keys[i]] = {};
}
}
currObj = currObj[keys[i]];
}
currObj[keys[keys.length - 1]] = value;
}
export function withStyleAnimation(styleAnimations) {
'worklet';
return defineAnimation({}, () => {
'worklet';
const onFrame = (animation, now) => {
let stillGoing = false;
const entriesToCheck = [{
value: animation.styleAnimations,
path: []
}];
while (entriesToCheck.length > 0) {
const currentEntry = entriesToCheck.pop();
if (Array.isArray(currentEntry.value)) {
for (let index = 0; index < currentEntry.value.length; index++) {
entriesToCheck.push({
value: currentEntry.value[index],
path: currentEntry.path.concat(index)
});
}
} else if (typeof currentEntry.value === 'object' && currentEntry.value.onFrame === undefined) {
// nested object
for (const key of Object.keys(currentEntry.value)) {
entriesToCheck.push({
value: currentEntry.value[key],
path: currentEntry.path.concat(key)
});
}
} else {
const currentStyleAnimation = currentEntry.value;
if (currentStyleAnimation.finished) {
continue;
}
const finished = currentStyleAnimation.onFrame(currentStyleAnimation, now);
if (finished) {
currentStyleAnimation.finished = true;
if (currentStyleAnimation.callback) {
currentStyleAnimation.callback(true);
}
} else {
stillGoing = true;
}
// When working with animations changing colors, we need to make sure that each one of them begins with a rgba, not a processed number.
// Thus, we only set the path to a processed color, but currentStyleAnimation.current stays as rgba.
const isAnimatingColorProp = ColorProperties.includes(currentEntry.path[0]);
setPath(animation.current, currentEntry.path, isAnimatingColorProp ? processColor(currentStyleAnimation.current) : currentStyleAnimation.current);
}
}
return !stillGoing;
};
const onStart = (animation, value, now, previousAnimation) => {
const entriesToCheck = [{
value: styleAnimations,
path: []
}];
while (entriesToCheck.length > 0) {
const currentEntry = entriesToCheck.pop();
if (Array.isArray(currentEntry.value)) {
for (let index = 0; index < currentEntry.value.length; index++) {
entriesToCheck.push({
value: currentEntry.value[index],
path: currentEntry.path.concat(index)
});
}
} else if (typeof currentEntry.value === 'object' && currentEntry.value.onStart === undefined) {
for (const key of Object.keys(currentEntry.value)) {
entriesToCheck.push({
value: currentEntry.value[key],
path: currentEntry.path.concat(key)
});
}
} else {
const prevAnimation = resolvePath(previousAnimation?.styleAnimations, currentEntry.path);
let prevVal = resolvePath(value, currentEntry.path);
if (prevAnimation && !prevVal) {
prevVal = prevAnimation.current;
}
if (__DEV__) {
if (prevVal === undefined) {
logger.warn(`Initial values for animation are missing for property ${currentEntry.path.join('.')}`);
}
const propName = currentEntry.path[0];
if (typeof propName === 'string' && !isValidLayoutAnimationProp(propName.trim())) {
logger.warn(`'${propName}' property is not officially supported for layout animations. It may not work as expected.`);
}
}
setPath(animation.current, currentEntry.path, prevVal);
let currentAnimation;
if (typeof currentEntry.value !== 'object' || !currentEntry.value.onStart) {
currentAnimation = withTiming(currentEntry.value, {
duration: 0
}); // TODO TYPESCRIPT this temporary cast is to get rid of .d.ts file.
setPath(animation.styleAnimations, currentEntry.path, currentAnimation);
} else {
currentAnimation = currentEntry.value;
}
currentAnimation.onStart(currentAnimation, prevVal, now, prevAnimation);
}
}
};
const callback = finished => {
if (!finished) {
const animationsToCheck = [styleAnimations];
while (animationsToCheck.length > 0) {
const currentAnimation = animationsToCheck.pop();
if (Array.isArray(currentAnimation)) {
for (const element of currentAnimation) {
animationsToCheck.push(element);
}
} else if (typeof currentAnimation === 'object' && currentAnimation.onStart === undefined) {
for (const value of Object.values(currentAnimation)) {
animationsToCheck.push(value);
}
} else {
const currentStyleAnimation = currentAnimation;
if (!currentStyleAnimation.finished && currentStyleAnimation.callback) {
currentStyleAnimation.callback(false);
}
}
}
}
};
return {
isHigherOrder: true,
onFrame,
onStart,
current: {},
styleAnimations,
callback
};
});
}
//# sourceMappingURL=styleAnimation.js.map
File diff suppressed because one or more lines are too long
@@ -1,100 +0,0 @@
'use strict';
import { Easing } from '../Easing';
import { assertEasingIsWorklet, defineAnimation, getReduceMotionForAnimation } from './util';
/**
* The timing animation configuration.
*
* @param duration - Length of the animation (in milliseconds). Defaults to 300.
* @param easing - An easing function which defines the animation curve.
* Defaults to `Easing.inOut(Easing.quad)`.
* @param reduceMotion - Determines how the animation responds to the device's
* reduced motion accessibility setting. Default to `ReduceMotion.System` -
* {@link ReduceMotion}.
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming#config-
*/
// TODO TYPESCRIPT This is temporary type put in here to get rid of our .d.ts file
/**
* Lets you create an animation based on duration and easing.
*
* @param toValue - The value on which the animation will come at rest -
* {@link AnimatableValue}.
* @param config - The timing animation configuration - {@link TimingConfig}.
* @param callback - A function called on animation complete -
* {@link AnimationCallback}.
* @returns An [animation
* object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object)
* which holds the current state of the animation.
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming
*/
export const withTiming = function (toValue, userConfig, callback) {
'worklet';
if (__DEV__ && userConfig?.easing) {
assertEasingIsWorklet(userConfig.easing);
}
return defineAnimation(toValue, () => {
'worklet';
const config = {
duration: 300,
easing: Easing.inOut(Easing.quad)
};
if (userConfig) {
Object.keys(userConfig).forEach(key => config[key] = userConfig[key]);
}
function timing(animation, now) {
// eslint-disable-next-line @typescript-eslint/no-shadow
const {
toValue,
startTime,
startValue
} = animation;
const runtime = now - startTime;
if (runtime >= config.duration) {
// reset startTime to avoid reusing finished animation config in `start` method
animation.startTime = 0;
animation.current = toValue;
return true;
}
const progress = animation.easing(runtime / config.duration);
animation.current = startValue + (toValue - startValue) * progress;
return false;
}
function onStart(animation, value, now, previousAnimation) {
if (previousAnimation && previousAnimation.type === 'timing' && previousAnimation.toValue === toValue && previousAnimation.startTime) {
// to maintain continuity of timing animations we check if we are starting
// new timing over the old one with the same parameters. If so, we want
// to copy animation timeline properties
animation.startTime = previousAnimation.startTime;
animation.startValue = previousAnimation.startValue;
} else {
animation.startTime = now;
animation.startValue = value;
}
animation.current = value;
if (typeof config.easing === 'object') {
animation.easing = config.easing.factory();
} else {
animation.easing = config.easing;
}
}
return {
type: 'timing',
onFrame: timing,
onStart: onStart,
progress: 0,
toValue,
startValue: 0,
startTime: 0,
easing: () => 0,
current: toValue,
callback,
reduceMotion: getReduceMotionForAnimation(userConfig?.reduceMotion)
};
});
};
//# sourceMappingURL=timing.js.map
@@ -1 +0,0 @@
{"version":3,"names":["Easing","assertEasingIsWorklet","defineAnimation","getReduceMotionForAnimation","withTiming","toValue","userConfig","callback","__DEV__","easing","config","duration","inOut","quad","Object","keys","forEach","key","timing","animation","now","startTime","startValue","runtime","current","progress","onStart","value","previousAnimation","type","factory","onFrame","reduceMotion"],"sourceRoot":"../../../src","sources":["animation/timing.ts"],"mappings":"AAAA,YAAY;;AAUZ,SAASA,MAAM,QAAQ,WAAW;AAClC,SACEC,qBAAqB,EACrBC,eAAe,EACfC,2BAA2B,QACtB,QAAQ;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,SAAAA,CACxBC,OAAwB,EACxBC,UAAyB,EACzBC,QAA4B,EACA;EAC5B,SAAS;;EAET,IAAIC,OAAO,IAAIF,UAAU,EAAEG,MAAM,EAAE;IACjCR,qBAAqB,CAACK,UAAU,CAACG,MAAM,CAAC;EAC1C;EAEA,OAAOP,eAAe,CAAkBG,OAAO,EAAE,MAAM;IACrD,SAAS;;IACT,MAAMK,MAAoD,GAAG;MAC3DC,QAAQ,EAAE,GAAG;MACbF,MAAM,EAAET,MAAM,CAACY,KAAK,CAACZ,MAAM,CAACa,IAAI;IAClC,CAAC;IACD,IAAIP,UAAU,EAAE;MACdQ,MAAM,CAACC,IAAI,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MAAM,CAACD,MAAM,CAACqB,OAAO,CAAC,CAAC;MAC5C,CAAC,MAAM;QACLX,SAAS,CAACV,MAAM,GAAGC,MAAM,CAACD,MAAM;MAClC;IACF;IAEA,OAAO;MACLoB,IAAI,EAAE,QAAQ;MACdE,OAAO,EAAEb,MAAM;MACfQ,OAAO,EAAEA,OAA+D;MACxED,QAAQ,EAAE,CAAC;MACXpB,OAAO;MACPiB,UAAU,EAAE,CAAC;MACbD,SAAS,EAAE,CAAC;MACZZ,MAAM,EAAEA,CAAA,KAAM,CAAC;MACfe,OAAO,EAAEnB,OAAO;MAChBE,QAAQ;MACRyB,YAAY,EAAE7B,2BAA2B,CAACG,UAAU,EAAE0B,YAAY;IACpE,CAAC;EACH,CAAC,CAAC;AACJ,CAAmB","ignoreList":[]}
@@ -1,195 +0,0 @@
'use strict';
import { ReanimatedError } from '../../common';
export function isAffineMatrixFlat(x) {
'worklet';
return Array.isArray(x) && x.length === 16 && x.every(element => typeof element === 'number' && !isNaN(element));
}
export function isAffineMatrix(x) {
'worklet';
return Array.isArray(x) && x.length === 4 && x.every(row => Array.isArray(row) && row.length === 4 && row.every(element => typeof element === 'number' && !isNaN(element)));
}
export function flatten(matrix) {
'worklet';
return matrix.flat();
}
export function unflatten(m) {
'worklet';
return [[m[0], m[1], m[2], m[3]], [m[4], m[5], m[6], m[7]], [m[8], m[9], m[10], m[11]], [m[12], m[13], m[14], m[15]]];
}
function maybeFlattenMatrix(matrix) {
'worklet';
return isAffineMatrix(matrix) ? flatten(matrix) : matrix;
}
export function multiplyMatrices(a, b) {
'worklet';
return [[a[0][0] * b[0][0] + a[0][1] * b[1][0] + a[0][2] * b[2][0] + a[0][3] * b[3][0], a[0][0] * b[0][1] + a[0][1] * b[1][1] + a[0][2] * b[2][1] + a[0][3] * b[3][1], a[0][0] * b[0][2] + a[0][1] * b[1][2] + a[0][2] * b[2][2] + a[0][3] * b[3][2], a[0][0] * b[0][3] + a[0][1] * b[1][3] + a[0][2] * b[2][3] + a[0][3] * b[3][3]], [a[1][0] * b[0][0] + a[1][1] * b[1][0] + a[1][2] * b[2][0] + a[1][3] * b[3][0], a[1][0] * b[0][1] + a[1][1] * b[1][1] + a[1][2] * b[2][1] + a[1][3] * b[3][1], a[1][0] * b[0][2] + a[1][1] * b[1][2] + a[1][2] * b[2][2] + a[1][3] * b[3][2], a[1][0] * b[0][3] + a[1][1] * b[1][3] + a[1][2] * b[2][3] + a[1][3] * b[3][3]], [a[2][0] * b[0][0] + a[2][1] * b[1][0] + a[2][2] * b[2][0] + a[2][3] * b[3][0], a[2][0] * b[0][1] + a[2][1] * b[1][1] + a[2][2] * b[2][1] + a[2][3] * b[3][1], a[2][0] * b[0][2] + a[2][1] * b[1][2] + a[2][2] * b[2][2] + a[2][3] * b[3][2], a[2][0] * b[0][3] + a[2][1] * b[1][3] + a[2][2] * b[2][3] + a[2][3] * b[3][3]], [a[3][0] * b[0][0] + a[3][1] * b[1][0] + a[3][2] * b[2][0] + a[3][3] * b[3][0], a[3][0] * b[0][1] + a[3][1] * b[1][1] + a[3][2] * b[2][1] + a[3][3] * b[3][1], a[3][0] * b[0][2] + a[3][1] * b[1][2] + a[3][2] * b[2][2] + a[3][3] * b[3][2], a[3][0] * b[0][3] + a[3][1] * b[1][3] + a[3][2] * b[2][3] + a[3][3] * b[3][3]]];
}
export function subtractMatrices(maybeFlatA, maybeFlatB) {
'worklet';
const isFlatOnStart = isAffineMatrixFlat(maybeFlatA);
const a = maybeFlattenMatrix(maybeFlatA);
const b = maybeFlattenMatrix(maybeFlatB);
const c = a.map((_, i) => a[i] - b[i]);
return isFlatOnStart ? c : unflatten(c);
}
export function addMatrices(maybeFlatA, maybeFlatB) {
'worklet';
const isFlatOnStart = isAffineMatrixFlat(maybeFlatA);
const a = maybeFlattenMatrix(maybeFlatA);
const b = maybeFlattenMatrix(maybeFlatB);
const c = a.map((_, i) => a[i] + b[i]);
return isFlatOnStart ? c : unflatten(c);
}
export function scaleMatrix(maybeFlatA, scalar) {
'worklet';
const isFlatOnStart = isAffineMatrixFlat(maybeFlatA);
const a = maybeFlattenMatrix(maybeFlatA);
const b = a.map(x => x * scalar);
return isFlatOnStart ? b : unflatten(b);
}
export function getRotationMatrix(angle, axis = 'z') {
'worklet';
const cos = Math.cos(angle);
const sin = Math.sin(angle);
switch (axis) {
case 'z':
return [[cos, sin, 0, 0], [-sin, cos, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
case 'y':
return [[cos, 0, -sin, 0], [0, 1, 0, 0], [sin, 0, cos, 0], [0, 0, 0, 1]];
case 'x':
return [[1, 0, 0, 0], [0, cos, sin, 0], [0, -sin, cos, 0], [0, 0, 0, 1]];
}
}
function norm3d(x, y, z) {
'worklet';
return Math.sqrt(x * x + y * y + z * z);
}
function transposeMatrix(matrix) {
'worklet';
const m = flatten(matrix);
return [[m[0], m[4], m[8], m[12]], [m[1], m[5], m[9], m[13]], [m[2], m[6], m[10], m[14]], [m[3], m[7], m[11], m[15]]];
}
function assertVectorsHaveEqualLengths(a, b) {
'worklet';
if (__DEV__ && a.length !== b.length) {
throw new ReanimatedError(`Cannot calculate inner product of two vectors of different lengths. Length of ${a.toString()} is ${a.length} and length of ${b.toString()} is ${b.length}.`);
}
}
function innerProduct(a, b) {
'worklet';
assertVectorsHaveEqualLengths(a, b);
return a.reduce((acc, _, i) => acc + a[i] * b[i], 0);
}
function projection(u, a) {
'worklet';
assertVectorsHaveEqualLengths(u, a);
const s = innerProduct(u, a) / innerProduct(u, u);
return u.map(e => e * s);
}
function subtractVectors(a, b) {
'worklet';
assertVectorsHaveEqualLengths(a, b);
return a.map((_, i) => a[i] - b[i]);
}
function scaleVector(u, a) {
'worklet';
return u.map(e => e * a);
}
function gramSchmidtAlgorithm(matrix) {
// Gram-Schmidt orthogonalization decomposes any matrix with non-zero determinant into an orthogonal and a triangular matrix
// These matrices are equal to rotation and skew matrices respectively, because we apply it to transformation matrix
// That is expected to already have extracted the remaining transforms (scale & translation)
'worklet';
const [a0, a1, a2, a3] = matrix;
const u0 = a0;
const u1 = subtractVectors(a1, projection(u0, a1));
const u2 = subtractVectors(subtractVectors(a2, projection(u0, a2)), projection(u1, a2));
const u3 = subtractVectors(subtractVectors(subtractVectors(a3, projection(u0, a3)), projection(u1, a3)), projection(u2, a3));
const [e0, e1, e2, e3] = [u0, u1, u2, u3].map(u => scaleVector(u, 1 / Math.sqrt(innerProduct(u, u))));
const rotationMatrix = [[e0[0], e1[0], e2[0], e3[0]], [e0[1], e1[1], e2[1], e3[1]], [e0[2], e1[2], e2[2], e3[2]], [e0[3], e1[3], e2[3], e3[3]]];
const skewMatrix = [[innerProduct(e0, a0), innerProduct(e0, a1), innerProduct(e0, a2), innerProduct(e0, a3)], [0, innerProduct(e1, a1), innerProduct(e1, a2), innerProduct(e1, a3)], [0, 0, innerProduct(e2, a2), innerProduct(e2, a3)], [0, 0, 0, innerProduct(e3, a3)]];
return {
rotationMatrix: transposeMatrix(rotationMatrix),
skewMatrix: transposeMatrix(skewMatrix)
};
}
export function decomposeMatrix(unknownTypeMatrix) {
'worklet';
const matrix = maybeFlattenMatrix(unknownTypeMatrix);
// normalize matrix
if (matrix[15] === 0) {
throw new ReanimatedError('Invalid transform matrix.');
}
matrix.forEach((_, i) => matrix[i] /= matrix[15]);
const translationMatrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [matrix[12], matrix[13], matrix[14], 1]];
const sx = matrix[15] * norm3d(matrix[0], matrix[4], matrix[8]);
const sy = matrix[15] * norm3d(matrix[1], matrix[5], matrix[9]);
const sz = matrix[15] * norm3d(matrix[2], matrix[6], matrix[10]);
// eslint-disable-next-line @typescript-eslint/no-shadow
const scaleMatrix = [[sx, 0, 0, 0], [0, sy, 0, 0], [0, 0, sz, 0], [0, 0, 0, 1]];
const rotationAndSkewMatrix = [[matrix[0] / sx, matrix[1] / sx, matrix[2] / sx, 0], [matrix[4] / sy, matrix[5] / sy, matrix[6] / sy, 0], [matrix[8] / sz, matrix[9] / sz, matrix[10] / sz, 0], [0, 0, 0, 1]];
const {
rotationMatrix,
skewMatrix
} = gramSchmidtAlgorithm(rotationAndSkewMatrix);
return {
translationMatrix,
scaleMatrix,
rotationMatrix,
skewMatrix
};
}
export function decomposeMatrixIntoMatricesAndAngles(matrix) {
'worklet';
// eslint-disable-next-line @typescript-eslint/no-shadow
const {
scaleMatrix,
rotationMatrix,
translationMatrix,
skewMatrix
} = decomposeMatrix(matrix);
const sinRy = -rotationMatrix[0][2];
const ry = Math.asin(sinRy);
let rx;
let rz;
if (sinRy === 1 || sinRy === -1) {
rz = 0;
rx = Math.atan2(sinRy * rotationMatrix[0][1], sinRy * rotationMatrix[0][2]);
} else {
rz = Math.atan2(rotationMatrix[0][1], rotationMatrix[0][0]);
rx = Math.atan2(rotationMatrix[1][2], rotationMatrix[2][2]);
}
return {
scaleMatrix,
rotationMatrix,
translationMatrix,
skewMatrix,
rx: rx || 0,
ry: ry || 0,
rz: rz || 0
};
}
//# sourceMappingURL=matrixUtils.js.map
File diff suppressed because one or more lines are too long
@@ -1,396 +0,0 @@
/* eslint-disable @typescript-eslint/no-shadow */
'use strict';
import { createSerializable, isWorkletFunction, runOnUI, RuntimeKind, serializableMappingCache } from 'react-native-worklets';
import { clampRGBA, convertToRGBA, isColor, rgbaArrayToRGBAColor, toGammaSpace, toLinearSpace } from '../Colors';
import { logger, ReanimatedError, SHOULD_BE_USE_WEB } from '../common';
import { ReduceMotion } from '../commonTypes';
import { ReducedMotionManager } from '../ReducedMotion';
import { addMatrices, decomposeMatrixIntoMatricesAndAngles, flatten, getRotationMatrix, isAffineMatrixFlat, multiplyMatrices, scaleMatrix, subtractMatrices } from './transformationMatrix/matrixUtils';
/**
* This variable has to be an object, because it can't be changed for the
* worklets if it's a primitive value. We also have to bind it to a separate
* object to prevent from freezing it in development.
*/
const IN_STYLE_UPDATER = {
current: false
};
const IN_STYLE_UPDATER_UI = createSerializable({
current: false
});
serializableMappingCache.set(IN_STYLE_UPDATER, IN_STYLE_UPDATER_UI);
const LAYOUT_ANIMATION_SUPPORTED_PROPS = {
originX: true,
originY: true,
width: true,
height: true,
borderRadius: true,
globalOriginX: true,
globalOriginY: true,
opacity: true,
transform: true,
backgroundColor: true
};
export function isValidLayoutAnimationProp(prop) {
'worklet';
return prop in LAYOUT_ANIMATION_SUPPORTED_PROPS;
}
if (__DEV__ && ReducedMotionManager.jsValue) {
logger.warn(`Reduced motion setting is enabled on this device. This warning is visible only in the development mode. Some animations will be disabled by default. You can override the behavior for individual animations, see https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#reduced-motion-setting-is-enabled-on-this-device.`);
}
export function assertEasingIsWorklet(easing) {
'worklet';
if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
// If this is called on UI (for example from gesture handler with worklets), we don't get easing,
// but its bound copy, which is not a worklet. We don't want to throw any error then.
return;
}
if (SHOULD_BE_USE_WEB) {
// It is possible to run reanimated on web without plugin, so let's skip this check on web
return;
}
// @ts-ignore typescript wants us to use `in` instead, which doesn't work with host objects
if (easing?.factory) {
return;
}
if (!isWorkletFunction(easing)) {
throw new ReanimatedError('The easing function is not a worklet. Please make sure you import `Easing` from react-native-reanimated.');
}
}
export function initialUpdaterRun(updater) {
IN_STYLE_UPDATER.current = true;
const result = updater();
IN_STYLE_UPDATER.current = false;
return result;
}
export function recognizePrefixSuffix(value) {
'worklet';
if (typeof value === 'string') {
const match = value.match(/([A-Za-z]*)(-?\d*\.?\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/);
if (!match) {
throw new ReanimatedError("Couldn't parse animation value.");
}
const prefix = match[1];
const suffix = match[4];
// number with scientific notation
const number = match[2] + (match[3] ?? '');
return {
prefix,
suffix,
strippedValue: parseFloat(number)
};
} else {
return {
strippedValue: value
};
}
}
/**
* Returns whether the motion should be reduced for a specified config. By
* default returns the system setting.
*/
const isReduceMotionOnUI = ReducedMotionManager.uiValue;
export function getReduceMotionFromConfig(config) {
'worklet';
return !config || config === ReduceMotion.System ? isReduceMotionOnUI.value : config === ReduceMotion.Always;
}
/**
* Returns the value that should be assigned to `animation.reduceMotion` for a
* given config. If the config is not defined, `undefined` is returned.
*/
export function getReduceMotionForAnimation(config) {
'worklet';
// if the config is not defined, we want `reduceMotion` to be undefined,
// so the parent animation knows if it should overwrite it
if (!config) {
return undefined;
}
return getReduceMotionFromConfig(config);
}
function applyProgressToMatrix(progress, a, b) {
'worklet';
return addMatrices(a, scaleMatrix(subtractMatrices(b, a), progress));
}
function applyProgressToNumber(progress, a, b) {
'worklet';
return a + progress * (b - a);
}
function decorateAnimation(animation) {
'worklet';
const baseOnStart = animation.onStart;
const baseOnFrame = animation.onFrame;
if (animation.isHigherOrder) {
animation.onStart = (animation, value, timestamp, previousAnimation) => {
if (animation.reduceMotion === undefined) {
animation.reduceMotion = getReduceMotionFromConfig();
}
return baseOnStart(animation, value, timestamp, previousAnimation);
};
return;
}
const animationCopy = Object.assign({}, animation);
delete animationCopy.callback;
const prefNumberSuffOnStart = (animation, value, timestamp, previousAnimation) => {
// recognize prefix, suffix, and updates stripped value on animation start
const {
prefix,
suffix,
strippedValue
} = recognizePrefixSuffix(value);
animation.__prefix = prefix;
animation.__suffix = suffix;
animation.strippedCurrent = strippedValue;
const {
strippedValue: strippedToValue
} = recognizePrefixSuffix(animation.toValue);
animation.current = strippedValue;
animation.startValue = strippedValue;
animation.toValue = strippedToValue;
if (previousAnimation && previousAnimation !== animation) {
const {
prefix: paPrefix,
suffix: paSuffix,
strippedValue: paStrippedValue
} = recognizePrefixSuffix(previousAnimation.current);
previousAnimation.current = paStrippedValue;
previousAnimation.__prefix = paPrefix;
previousAnimation.__suffix = paSuffix;
}
baseOnStart(animation, strippedValue, timestamp, previousAnimation);
animation.current = (animation.__prefix ?? '') + animation.current + (animation.__suffix ?? '');
if (previousAnimation && previousAnimation !== animation) {
previousAnimation.current = (previousAnimation.__prefix ?? '') +
// FIXME
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands, @typescript-eslint/no-base-to-string
previousAnimation.current + (previousAnimation.__suffix ?? '');
}
};
const prefNumberSuffOnFrame = (animation, timestamp) => {
animation.current = animation.strippedCurrent;
const res = baseOnFrame(animation, timestamp);
animation.strippedCurrent = animation.current;
animation.current = (animation.__prefix ?? '') + animation.current + (animation.__suffix ?? '');
return res;
};
const tab = ['R', 'G', 'B', 'A'];
const colorOnStart = (animation, value, timestamp, previousAnimation) => {
let RGBAValue;
let RGBACurrent;
let RGBAToValue;
const res = [];
if (isColor(value)) {
RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
RGBAValue = toLinearSpace(convertToRGBA(value));
if (animation.toValue) {
RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));
}
}
tab.forEach((i, index) => {
animation[i] = Object.assign({}, animationCopy);
animation[i].current = RGBACurrent[index];
animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;
animation[i].onStart(animation[i], RGBAValue[index], timestamp, previousAnimation ? previousAnimation[i] : undefined);
res.push(animation[i].current);
});
animation.unroundedCurrent = res;
// We need to clamp the res values to make sure they are in the correct RGBA range
clampRGBA(res);
animation.current = rgbaArrayToRGBAColor(toGammaSpace(res));
};
const colorOnFrame = (animation, timestamp) => {
const res = [];
let finished = true;
// We must restore nonscale current to ever end the animation.
animation.current = animation.nonscaledCurrent;
tab.forEach(i => {
const result = animation[i].onFrame(animation[i], timestamp);
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
finished = finished && result;
res.push(animation[i].current);
});
// We need to clamp the res values to make sure they are in the correct RGBA range
clampRGBA(res);
animation.nonscaledCurrent = res;
animation.current = rgbaArrayToRGBAColor(toGammaSpace(res));
return finished;
};
const transformationMatrixOnStart = (animation, value, timestamp, previousAnimation) => {
const toValue = animation.toValue;
animation.startMatrices = decomposeMatrixIntoMatricesAndAngles(value);
animation.stopMatrices = decomposeMatrixIntoMatricesAndAngles(toValue);
// We create an animation copy to animate single value between 0 and 100
// We set limits from 0 to 100 (instead of 0-1) to make spring look good
// with default thresholds.
animation[0] = Object.assign({}, animationCopy);
animation[0].current = 0;
animation[0].toValue = 100;
animation[0].onStart(animation[0], 0, timestamp, previousAnimation ? previousAnimation[0] : undefined);
animation.current = value;
};
const transformationMatrixOnFrame = (animation, timestamp) => {
let finished = true;
const result = animation[0].onFrame(animation[0], timestamp);
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
finished = finished && result;
const progress = animation[0].current / 100;
const transforms = ['translationMatrix', 'scaleMatrix', 'skewMatrix'];
const mappedTransforms = [];
transforms.forEach((key, _) => mappedTransforms.push(applyProgressToMatrix(progress, animation.startMatrices[key], animation.stopMatrices[key])));
const [currentTranslation, currentScale, skewMatrix] = mappedTransforms;
const rotations = ['x', 'y', 'z'];
const mappedRotations = [];
rotations.forEach((key, _) => {
const angle = applyProgressToNumber(progress, animation.startMatrices['r' + key], animation.stopMatrices['r' + key]);
mappedRotations.push(getRotationMatrix(angle, key));
});
const [rotationMatrixX, rotationMatrixY, rotationMatrixZ] = mappedRotations;
const rotationMatrix = multiplyMatrices(rotationMatrixX, multiplyMatrices(rotationMatrixY, rotationMatrixZ));
const updated = flatten(multiplyMatrices(multiplyMatrices(currentScale, multiplyMatrices(skewMatrix, rotationMatrix)), currentTranslation));
animation.current = updated;
return finished;
};
const arrayOnStart = (animation, value, timestamp, previousAnimation) => {
value.forEach((v, i) => {
animation[i] = Object.assign({}, animationCopy);
animation[i].current = v;
animation[i].toValue = animation.toValue[i];
animation[i].onStart(animation[i], v, timestamp, previousAnimation ? previousAnimation[i] : undefined);
});
animation.current = [...value];
};
const arrayOnFrame = (animation, timestamp) => {
let finished = true;
animation.current.forEach((_, i) => {
const result = animation[i].onFrame(animation[i], timestamp);
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
finished = finished && result;
animation.current[i] = animation[i].current;
});
return finished;
};
const objectOnStart = (animation, value, timestamp, previousAnimation) => {
for (const key in value) {
animation[key] = Object.assign({}, animationCopy);
animation[key].onStart = animation.onStart;
animation[key].current = value[key];
animation[key].toValue = animation.toValue[key];
animation[key].onStart(animation[key], value[key], timestamp, previousAnimation ? previousAnimation[key] : undefined);
}
animation.current = value;
};
const objectOnFrame = (animation, timestamp) => {
let finished = true;
const newObject = {};
for (const key in animation.current) {
const result = animation[key].onFrame(animation[key], timestamp);
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
finished = finished && result;
newObject[key] = animation[key].current;
}
animation.current = newObject;
return finished;
};
animation.onStart = (animation, value, timestamp, previousAnimation) => {
if (animation.reduceMotion === undefined) {
animation.reduceMotion = getReduceMotionFromConfig();
}
if (animation.reduceMotion) {
if (animation.toValue !== undefined) {
animation.current = animation.toValue;
} else {
// if there is no `toValue`, then the base function is responsible for setting the current value
baseOnStart(animation, value, timestamp, previousAnimation);
}
animation.startTime = 0;
animation.onFrame = () => true;
return;
}
if (isColor(value)) {
colorOnStart(animation, value, timestamp, previousAnimation);
animation.onFrame = colorOnFrame;
return;
} else if (isAffineMatrixFlat(value)) {
transformationMatrixOnStart(animation, value, timestamp, previousAnimation);
animation.onFrame = transformationMatrixOnFrame;
return;
} else if (Array.isArray(value)) {
arrayOnStart(animation, value, timestamp, previousAnimation);
animation.onFrame = arrayOnFrame;
return;
} else if (typeof value === 'string') {
prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);
animation.onFrame = prefNumberSuffOnFrame;
return;
} else if (typeof value === 'object' && value !== null) {
objectOnStart(animation, value, timestamp, previousAnimation);
animation.onFrame = objectOnFrame;
return;
}
baseOnStart(animation, value, timestamp, previousAnimation);
};
}
export function defineAnimation(starting, factory) {
'worklet';
if (globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative && IN_STYLE_UPDATER.current) {
return starting;
}
const create = () => {
'worklet';
const animation = factory();
decorateAnimation(animation);
return animation;
};
if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative || SHOULD_BE_USE_WEB) {
return create();
}
create.__isAnimationDefinition = true;
// @ts-expect-error it's fine
return create;
}
function cancelAnimationNative(sharedValue) {
'worklet';
// setting the current value cancels the animation if one is currently running
if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign
} else {
runOnUI(() => {
'worklet';
sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign
})();
}
}
function cancelAnimationWeb(sharedValue) {
// setting the current value cancels the animation if one is currently running
sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign
}
/**
* Lets you cancel a running animation paired to a shared value. The
* cancellation is asynchronous.
*
* @param sharedValue - The shared value of a running animation that you want to
* cancel.
* @see https://docs.swmansion.com/react-native-reanimated/docs/core/cancelAnimation
*/
export const cancelAnimation = SHOULD_BE_USE_WEB ? cancelAnimationWeb : cancelAnimationNative;
//# sourceMappingURL=util.js.map
File diff suppressed because one or more lines are too long
@@ -1,6 +1,5 @@
'use strict';
import { logger } from './common';
const mockTargetValues = {
targetOriginX: 0,
targetOriginY: 0,
@@ -19,30 +18,18 @@ const mockTargetValues = {
currentGlobalOriginY: 0,
currentBorderRadius: 0
};
function getCommonProperties(layoutStyle, componentStyle) {
let componentStyleFlat = Array.isArray(componentStyle) ? componentStyle.flat() : [componentStyle];
componentStyleFlat = componentStyleFlat.filter(Boolean);
componentStyleFlat = componentStyleFlat.map(style => 'initial' in style ? style.initial.value // Include properties of animated style
: style);
const componentStylesKeys = componentStyleFlat.flatMap(style => Object.keys(style));
const commonKeys = Object.keys(layoutStyle).filter(key => componentStylesKeys.includes(key));
return commonKeys;
}
function maybeReportOverwrittenProperties(layoutAnimationStyle, style, displayName) {
const commonProperties = getCommonProperties(layoutAnimationStyle, style);
if (commonProperties.length > 0) {
logger.warn(`${commonProperties.length === 1 ? 'Property' : 'Properties'} "${commonProperties.join(', ')}" of ${displayName} may be overwritten by a layout animation. Please wrap your component with an animated view and apply the layout animation on the wrapper.`);
}
}
export function maybeBuild(layoutAnimationOrBuilder, style, displayName) {
const isAnimationBuilder = value => 'build' in layoutAnimationOrBuilder && typeof layoutAnimationOrBuilder.build === 'function';
if (isAnimationBuilder(layoutAnimationOrBuilder)) {
const animationFactory = layoutAnimationOrBuilder.build();
if (__DEV__ && style) {
const layoutAnimation = animationFactory(mockTargetValues);
maybeReportOverwrittenProperties(layoutAnimation.animations, style, displayName);
const layoutAnimation = animationFactory(mockTargetValues);
const animatedStyle = layoutAnimation.animations;
const getCommonProperties = (obj1, obj2) => Object.keys(obj1).filter(key => Object.prototype.hasOwnProperty.call(obj2, key));
const commonProperties = getCommonProperties(animatedStyle, style || {});
if (commonProperties.length > 0) {
console.warn(`[Reanimated] ${commonProperties.length === 1 ? 'Property' : 'Properties: '} "${commonProperties}" of ${displayName} may be overwritten with layout animation. Please create a wrapper with the layout animation you want to apply.`);
}
return animationFactory;
return layoutAnimationOrBuilder.build();
} else {
return layoutAnimationOrBuilder;
}
@@ -1 +1 @@
{"version":3,"names":["logger","mockTargetValues","targetOriginX","targetOriginY","targetWidth","targetHeight","targetGlobalOriginX","targetGlobalOriginY","targetBorderRadius","windowWidth","windowHeight","currentOriginX","currentOriginY","currentWidth","currentHeight","currentGlobalOriginX","currentGlobalOriginY","currentBorderRadius","getCommonProperties","layoutStyle","componentStyle","componentStyleFlat","Array","isArray","flat","filter","Boolean","map","style","initial","value","componentStylesKeys","flatMap","Object","keys","commonKeys","key","includes","maybeReportOverwrittenProperties","layoutAnimationStyle","displayName","commonProperties","length","warn","join","maybeBuild","layoutAnimationOrBuilder","isAnimationBuilder","build","animationFactory","__DEV__","layoutAnimation","animations"],"sourceRoot":"../../src","sources":["animationBuilder.tsx"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,QAAQ,UAAU;AASjC,MAAMC,gBAAuC,GAAG;EAC9CC,aAAa,EAAE,CAAC;EAChBC,aAAa,EAAE,CAAC;EAChBC,WAAW,EAAE,CAAC;EACdC,YAAY,EAAE,CAAC;EACfC,mBAAmB,EAAE,CAAC;EACtBC,mBAAmB,EAAE,CAAC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,KACtDD,gBAAgB,CAACG,IAAI,CACxB,IACF,CAAC,QAAQJ,WAAW,4IACtB,CAAC;EACH;AACF;AAEA,OAAO,SAASK,UAAUA,CACxBC,wBAGY,EACZlB,KAA0C,EAC1CY,WAAmB,EACiB;EACpC,MAAMO,kBAAkB,GACtBjB,KAAmE,IAEnE,OAAO,IAAIgB,wBAAwB,IACnC,OAAOA,wBAAwB,CAACE,KAAK,KAAK,UAAU;EAEtD,IAAID,kBAAkB,CAACD,wBAAwB,CAAC,EAAE;IAChD,MAAMG,gBAAgB,GAAGH,wBAAwB,CAACE,KAAK,CAAC,CAAC;IAEzD,IAAIE,OAAO,IAAItB,KAAK,EAAE;MACpB,MAAMuB,eAAe,GAAGF,gBAAgB,CAAChD,gBAAgB,CAAC;MAC1DqC,gCAAgC,CAC9Ba,eAAe,CAACC,UAAU,EAC1BxB,KAAK,EACLY,WACF,CAAC;IACH;IAEA,OAAOS,gBAAgB;EACzB,CAAC,MAAM;IACL,OAAOH,wBAAwB;EACjC;AACF","ignoreList":[]}
{"version":3,"names":["mockTargetValues","targetOriginX","targetOriginY","targetWidth","targetHeight","targetGlobalOriginX","targetGlobalOriginY","targetBorderRadius","windowWidth","windowHeight","currentOriginX","currentOriginY","currentWidth","currentHeight","currentGlobalOriginX","currentGlobalOriginY","currentBorderRadius","maybeBuild","layoutAnimationOrBuilder","style","displayName","isAnimationBuilder","value","build","animationFactory","layoutAnimation","animatedStyle","animations","getCommonProperties","obj1","obj2","Object","keys","filter","key","prototype","hasOwnProperty","call","commonProperties","length","console","warn"],"sources":["animationBuilder.tsx"],"sourcesContent":["'use strict';\nimport type {\n ILayoutAnimationBuilder,\n LayoutAnimationFunction,\n LayoutAnimationsValues,\n} from './reanimated2/layoutReanimation';\nimport type { StyleProps } from './reanimated2/commonTypes';\n\nconst mockTargetValues: LayoutAnimationsValues = {\n targetOriginX: 0,\n targetOriginY: 0,\n targetWidth: 0,\n targetHeight: 0,\n targetGlobalOriginX: 0,\n targetGlobalOriginY: 0,\n targetBorderRadius: 0,\n windowWidth: 0,\n windowHeight: 0,\n currentOriginX: 0,\n currentOriginY: 0,\n currentWidth: 0,\n currentHeight: 0,\n currentGlobalOriginX: 0,\n currentGlobalOriginY: 0,\n currentBorderRadius: 0,\n};\n\nexport function maybeBuild(\n layoutAnimationOrBuilder:\n | ILayoutAnimationBuilder\n | LayoutAnimationFunction\n | Keyframe,\n style: StyleProps | undefined,\n displayName: string\n): LayoutAnimationFunction | Keyframe {\n const isAnimationBuilder = (\n value: ILayoutAnimationBuilder | LayoutAnimationFunction | Keyframe\n ): value is ILayoutAnimationBuilder =>\n 'build' in layoutAnimationOrBuilder &&\n typeof layoutAnimationOrBuilder.build === 'function';\n\n if (isAnimationBuilder(layoutAnimationOrBuilder)) {\n const animationFactory = layoutAnimationOrBuilder.build();\n const layoutAnimation = animationFactory(mockTargetValues);\n const animatedStyle = layoutAnimation.animations;\n\n const getCommonProperties = (obj1: object, obj2: object) =>\n Object.keys(obj1).filter((key) =>\n Object.prototype.hasOwnProperty.call(obj2, key)\n );\n\n const commonProperties = getCommonProperties(animatedStyle, style || {});\n if (commonProperties.length > 0) {\n console.warn(\n `[Reanimated] ${\n commonProperties.length === 1 ? 'Property' : 'Properties: '\n } \"${commonProperties}\" of ${displayName} may be overwritten with layout animation. Please create a wrapper with the layout animation you want to apply.`\n );\n }\n\n return layoutAnimationOrBuilder.build();\n } else {\n return layoutAnimationOrBuilder;\n }\n}\n"],"mappings":"AAAA,YAAY;;AAQZ,MAAMA,gBAAwC,GAAG;EAC/CC,aAAa,EAAE,CAAC;EAChBC,aAAa,EAAE,CAAC;EAChBC,WAAW,EAAE,CAAC;EACdC,YAAY,EAAE,CAAC;EACfC,mBAAmB,EAAE,CAAC;EACtBC,mBAAmB,EAAE,CAAC;EACtBC,kBAAkB,EAAE,CAAC;EACrBC,WAAW,EAAE,CAAC;EACdC,YAAY,EAAE,CAAC;EACfC,cAAc,EAAE,CAAC;EACjBC,cAAc,EAAE,CAAC;EACjBC,YAAY,EAAE,CAAC;EACfC,aAAa,EAAE,CAAC;EAChBC,oBAAoB,EAAE,CAAC;EACvBC,oBAAoB,EAAE,CAAC;EACvBC,mBAAmB,EAAE;AACvB,CAAC;AAED,OAAO,SAASC,UAAUA,CACxBC,wBAGY,EACZC,KAA6B,EAC7BC,WAAmB,EACiB;EACpC,MAAMC,kBAAkB,GACtBC,KAAmE,IAEnE,OAAO,IAAIJ,wBAAwB,IACnC,OAAOA,wBAAwB,CAACK,KAAK,KAAK,UAAU;EAEtD,IAAIF,kBAAkB,CAACH,wBAAwB,CAAC,EAAE;IAChD,MAAMM,gBAAgB,GAAGN,wBAAwB,CAACK,KAAK,EAAE;IACzD,MAAME,eAAe,GAAGD,gBAAgB,CAACxB,gBAAgB,CAAC;IAC1D,MAAM0B,aAAa,GAAGD,eAAe,CAACE,UAAU;IAEhD,MAAMC,mBAAmB,GAAGA,CAACC,IAAY,EAAEC,IAAY,KACrDC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,MAAM,CAAEC,GAAG,IAC3BH,MAAM,CAACI,SAAS,CAACC,cAAc,CAACC,IAAI,CAACP,IAAI,EAAEI,GAAG,CAAC,CAChD;IAEH,MAAMI,gBAAgB,GAAGV,mBAAmB,CAACF,aAAa,EAAEP,KAAK,IAAI,CAAC,CAAC,CAAC;IACxE,IAAImB,gBAAgB,CAACC,MAAM,GAAG,CAAC,EAAE;MAC/BC,OAAO,CAACC,IAAI,CACT,gBACCH,gBAAgB,CAACC,MAAM,KAAK,CAAC,GAAG,UAAU,GAAG,cAC9C,KAAID,gBAAiB,QAAOlB,WAAY,iHAAgH,CAC1J;IACH;IAEA,OAAOF,wBAAwB,CAACK,KAAK,EAAE;EACzC,CAAC,MAAM;IACL,OAAOL,wBAAwB;EACjC;AACF"}
@@ -1,20 +0,0 @@
'use strict';
import { Platform } from 'react-native';
function isWindowAvailable() {
// the window object is unavailable when building the server portion of a site that uses SSG
// this function shouldn't be used to conditionally render components
// https://www.joshwcomeau.com/react/the-perils-of-rehydration/
// @ts-ignore Fallback if `window` is undefined.
return typeof window !== 'undefined';
}
export const IS_ANDROID = Platform.OS === 'android';
/** @knipIgnore */
export const IS_IOS = Platform.OS === 'ios';
export const IS_WEB = Platform.OS === 'web';
export const IS_JEST = !!process.env.JEST_WORKER_ID;
/** @knipIgnore */
export const IS_WINDOWS = Platform.OS === 'windows';
export const IS_WINDOW_AVAILABLE = isWindowAvailable();
export const SHOULD_BE_USE_WEB = IS_JEST || IS_WEB || IS_WINDOWS;
//# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
{"version":3,"names":["Platform","isWindowAvailable","window","IS_ANDROID","OS","IS_IOS","IS_WEB","IS_JEST","process","env","JEST_WORKER_ID","IS_WINDOWS","IS_WINDOW_AVAILABLE","SHOULD_BE_USE_WEB"],"sourceRoot":"../../../src","sources":["common/constants.ts"],"mappings":"AAAA,YAAY;;AACZ,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,iBAAiBA,CAAA,EAAG;EAC3B;EACA;EACA;EACA;EACA,OAAO,OAAOC,MAAM,KAAK,WAAW;AACtC;AAEA,OAAO,MAAMC,UAAmB,GAAGH,QAAQ,CAACI,EAAE,KAAK,SAAS;AAC5D;AACA,OAAO,MAAMC,MAAe,GAAGL,QAAQ,CAACI,EAAE,KAAK,KAAK;AACpD,OAAO,MAAME,MAAe,GAAGN,QAAQ,CAACI,EAAE,KAAK,KAAK;AACpD,OAAO,MAAMG,OAAgB,GAAG,CAAC,CAACC,OAAO,CAACC,GAAG,CAACC,cAAc;AAC5D;AACA,OAAO,MAAMC,UAAmB,GAAGX,QAAQ,CAACI,EAAE,KAAK,SAAS;AAE5D,OAAO,MAAMQ,mBAA4B,GAAGX,iBAAiB,CAAC,CAAC;AAE/D,OAAO,MAAMY,iBAAiB,GAAGN,OAAO,IAAID,MAAM,IAAIK,UAAU","ignoreList":[]}
@@ -1,28 +0,0 @@
/* eslint-disable reanimated/use-reanimated-error */
'use strict';
import { RuntimeKind } from 'react-native-worklets';
function ReanimatedErrorConstructor(message) {
'worklet';
const prefix = '[Reanimated]';
const errorInstance = new Error(message ? `${prefix} ${message}` : prefix);
errorInstance.name = 'ReanimatedError';
return errorInstance;
}
/**
* Registers ReanimatedError in the global scope. Register only for Worklet
* runtimes.
*/
export function registerReanimatedError() {
'worklet';
if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
globalThis.ReanimatedError = ReanimatedErrorConstructor;
}
}
export const ReanimatedError = ReanimatedErrorConstructor;
// signed type
//# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
{"version":3,"names":["RuntimeKind","ReanimatedErrorConstructor","message","prefix","errorInstance","Error","name","registerReanimatedError","globalThis","__RUNTIME_KIND","ReactNative","ReanimatedError"],"sourceRoot":"../../../src","sources":["common/errors.ts"],"mappings":"AAAA;AACA,YAAY;;AAEZ,SAASA,WAAW,QAAQ,uBAAuB;AAEnD,SAASC,0BAA0BA,CAACC,OAAe,EAAmB;EACpE,SAAS;;EACT,MAAMC,MAAM,GAAG,cAAc;EAC7B,MAAMC,aAAa,GAAG,IAAIC,KAAK,CAACH,OAAO,GAAG,GAAGC,MAAM,IAAID,OAAO,EAAE,GAAGC,MAAM,CAAC;EAC1EC,aAAa,CAACE,IAAI,GAAG,iBAAiB;EACtC,OAAOF,aAAa;AACtB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,uBAAuBA,CAAA,EAAG;EACxC,SAAS;;EACT,IAAIC,UAAU,CAACC,cAAc,KAAKT,WAAW,CAACU,WAAW,EAAE;IACzDF,UAAU,CAACG,eAAe,GACxBV,0BAAyD;EAC7D;AACF;AAEA,OAAO,MAAMU,eAAe,GAC1BV,0BAAyD;;AAQG","ignoreList":[]}
@@ -1,8 +0,0 @@
'use strict';
export * from './constants';
export * from './errors';
export * from './logger';
export * from './processors';
export * from './utils';
//# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["common/index.ts"],"mappings":"AAAA,YAAY;;AACZ,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,cAAc;AAE5B,cAAc,SAAS","ignoreList":[]}
@@ -1,96 +0,0 @@
/* eslint-disable reanimated/use-logger */
'use strict';
const PREFIX = '[Reanimated]';
const DOCS_URL = 'https://docs.swmansion.com/react-native-reanimated/docs/debugging/logger-configuration';
const DOCS_REFERENCE = `If you don't want to see this message, you can disable the \`strict\` mode. Refer to:\n${DOCS_URL} for more details.`;
export let ReanimatedLogLevel = /*#__PURE__*/function (ReanimatedLogLevel) {
ReanimatedLogLevel[ReanimatedLogLevel["warn"] = 1] = "warn";
ReanimatedLogLevel[ReanimatedLogLevel["error"] = 2] = "error";
return ReanimatedLogLevel;
}({});
function logToConsole(data) {
'worklet';
switch (data.level) {
case ReanimatedLogLevel.warn:
console.warn(data.message);
break;
case ReanimatedLogLevel.error:
console.error(data.message);
break;
}
}
const DEFAULT_LOGGER_CONFIG = {
logFunction: logToConsole,
level: ReanimatedLogLevel.warn,
strict: true
};
/**
* Current logger config getter.
*
* @returns The current logger configuration object.
*/
export function getLoggerConfig() {
'worklet';
if (!global.__reanimatedLoggerConfig) {
global.__reanimatedLoggerConfig = DEFAULT_LOGGER_CONFIG;
}
return global.__reanimatedLoggerConfig;
}
/**
* Updates logger configuration.
*
* @param currentConfig - The current logger configuration object.
* @param options - The new logger configuration to apply.
*
* - Level: The minimum log level to display.
* - Strict: Whether to log warnings and errors that are not strict. Defaults to
* false.
*/
export function updateLoggerConfig(currentConfig, options) {
'worklet';
global.__reanimatedLoggerConfig = {
...currentConfig,
// Don't reuse previous level and strict values from the current config
level: options?.level ?? DEFAULT_LOGGER_CONFIG.level,
strict: options?.strict ?? DEFAULT_LOGGER_CONFIG.strict
};
}
function handleLog(level, message, options) {
'worklet';
const config = getLoggerConfig();
if (
// Don't log if the log is marked as strict-only and the config doesn't
// enable strict logging
options.strict && !config.strict ||
// Don't log if the log level is below the minimum configured level
level < config.level) {
return;
}
if (options.strict) {
message += `\n\n${DOCS_REFERENCE}`;
}
config.logFunction({
level,
message: `${PREFIX} ${message}`
});
}
export const logger = {
warn(message, options = {}) {
'worklet';
handleLog(ReanimatedLogLevel.warn, message, options);
},
error(message, options = {}) {
'worklet';
handleLog(ReanimatedLogLevel.error, message, options);
}
};
//# sourceMappingURL=logger.js.map
@@ -1 +0,0 @@
{"version":3,"names":["PREFIX","DOCS_URL","DOCS_REFERENCE","ReanimatedLogLevel","logToConsole","data","level","warn","console","message","error","DEFAULT_LOGGER_CONFIG","logFunction","strict","getLoggerConfig","global","__reanimatedLoggerConfig","updateLoggerConfig","currentConfig","options","handleLog","config","logger"],"sourceRoot":"../../../src","sources":["common/logger.ts"],"mappings":"AAAA;AACA,YAAY;;AAEZ,MAAMA,MAAM,GAAG,cAAc;AAC7B,MAAMC,QAAQ,GACZ,wFAAwF;AAC1F,MAAMC,cAAc,GAAG,0FAA0FD,QAAQ,oBAAoB;AAE7I,WAAYE,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAqB9B,SAASC,YAAYA,CAACC,IAAa,EAAE;EACnC,SAAS;;EACT,QAAQA,IAAI,CAACC,KAAK;IAChB,KAAKH,kBAAkB,CAACI,IAAI;MAC1BC,OAAO,CAACD,IAAI,CAACF,IAAI,CAACI,OAAO,CAAC;MAC1B;IACF,KAAKN,kBAAkB,CAACO,KAAK;MAC3BF,OAAO,CAACE,KAAK,CAACL,IAAI,CAACI,OAAO,CAAC;MAC3B;EACJ;AACF;AAEA,MAAME,qBAA2C,GAAG;EAClDC,WAAW,EAAER,YAAY;EACzBE,KAAK,EAAEH,kBAAkB,CAACI,IAAI;EAC9BM,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAAA,EAAG;EAChC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AED,OAAO,EAAEU,OAAO,CAAC;EACvD;AACF,CAAC","ignoreList":[]}
@@ -1,31 +0,0 @@
'use strict';
'worklet';
import { ColorProperties, processColorInitially } from '../../Colors';
import { IS_ANDROID } from '../constants';
export function processColor(color) {
let normalizedColor = processColorInitially(color);
if (typeof normalizedColor !== 'number') {
return normalizedColor;
}
if (IS_ANDROID) {
// Android use 32 bit *signed* integer to represent the color
// We utilize the fact that bitwise operations in JS also operates on
// signed 32 bit integers, so that we can use those to convert from
// *unsigned* to *signed* 32bit int that way.
normalizedColor = normalizedColor | 0x0;
}
return normalizedColor;
}
export function processColorsInProps(props) {
for (const key in props) {
if (ColorProperties.includes(key)) {
if (Array.isArray(props[key])) {
props[key] = props[key].map(color => processColor(color));
} else {
props[key] = processColor(props[key]);
}
}
}
}
//# sourceMappingURL=colors.js.map
@@ -1 +0,0 @@
{"version":3,"names":["ColorProperties","processColorInitially","IS_ANDROID","processColor","color","normalizedColor","processColorsInProps","props","key","includes","Array","isArray","map"],"sourceRoot":"../../../../src","sources":["common/processors/colors.ts"],"mappings":"AAAA,YAAY;AACZ,SAAS;;AACT,SAASA,eAAe,EAAEC,qBAAqB,QAAQ,cAAc;AAErE,SAASC,UAAU,QAAQ,cAAc;AAEzC,OAAO,SAASC,YAAYA,CAACC,KAAc,EAA6B;EACtE,IAAIC,eAAe,GAAGJ,qBAAqB,CAACG,KAAK,CAAC;EAElD,IAAI,OAAOC,eAAe,KAAK,QAAQ,EAAE;IACvC,OAAOA,eAAe;EACxB;EAEA,IAAIH,UAAU,EAAE;IACd;IACA;IACA;IACA;IACAG,eAAe,GAAGA,eAAe,GAAG,GAAG;EACzC;EAEA,OAAOA,eAAe;AACxB;AAEA,OAAO,SAASC,oBAAoBA,CAACC,KAAiB,EAAE;EACtD,KAAK,MAAMC,GAAG,IAAID,KAAK,EAAE;IACvB,IAAIP,eAAe,CAACS,QAAQ,CAACD,GAAG,CAAC,EAAE;MACjC,IAAIE,KAAK,CAACC,OAAO,CAACJ,KAAK,CAACC,GAAG,CAAC,CAAC,EAAE;QAC7BD,KAAK,CAACC,GAAG,CAAC,GAAGD,KAAK,CAACC,GAAG,CAAC,CAACI,GAAG,CAAER,KAAc,IAAKD,YAAY,CAACC,KAAK,CAAC,CAAC;MACtE,CAAC,MAAM;QACLG,KAAK,CAACC,GAAG,CAAC,GAAGL,YAAY,CAACI,KAAK,CAACC,GAAG,CAAC,CAAC;MACvC;IACF;EACF;AACF","ignoreList":[]}
@@ -1,6 +0,0 @@
'use strict';
export * from './colors';
export * from './shadows';
export * from './transformOrigin';
//# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["common/processors/index.ts"],"mappings":"AAAA,YAAY;;AACZ,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,mBAAmB","ignoreList":[]}

Some files were not shown because too many files have changed in this diff Show More