react-native-reanimated 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/Animated.js +60 -1
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +8 -0
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js +2 -2
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/animation/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +2 -2
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +6 -0
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +4 -19
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/core.js +16 -0
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +3 -1
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/helperTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +2 -27
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +1 -1
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +26 -0
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +0 -1
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +3 -0
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +0 -1
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/setAndForwardRef.js.map +1 -1
- package/lib/typescript/Animated.d.ts +68 -3
- package/lib/typescript/createAnimatedComponent.d.ts +1 -26
- package/lib/typescript/reanimated2/Easing.d.ts +17 -9
- package/lib/typescript/reanimated2/UpdateProps.d.ts +5 -5
- package/lib/typescript/reanimated2/animation/commonTypes.d.ts +4 -3
- package/lib/typescript/reanimated2/animation/decay.d.ts +2 -4
- package/lib/typescript/reanimated2/animation/index.d.ts +3 -3
- package/lib/typescript/reanimated2/animation/springUtils.d.ts +1 -0
- package/lib/typescript/reanimated2/animation/styleAnimation.d.ts +2 -6
- package/lib/typescript/reanimated2/animation/timing.d.ts +4 -7
- package/lib/typescript/reanimated2/animation/transformationMatrix/matrixUtils.d.ts +1 -1
- package/lib/typescript/reanimated2/animation/util.d.ts +2 -4
- package/lib/typescript/reanimated2/commonTypes.d.ts +0 -4
- package/lib/typescript/reanimated2/component/FlatList.d.ts +2 -1
- package/lib/typescript/reanimated2/component/ScrollView.d.ts +1 -1
- package/lib/typescript/reanimated2/core.d.ts +12 -0
- package/lib/typescript/reanimated2/helperTypes.d.ts +11 -7
- package/lib/typescript/reanimated2/hook/commonTypes.d.ts +2 -2
- package/lib/typescript/reanimated2/hook/index.d.ts +1 -1
- package/lib/typescript/reanimated2/hook/useAnimatedGestureHandler.d.ts +2 -2
- package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +4 -4
- package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +4 -5
- package/lib/typescript/reanimated2/hook/utils.d.ts +3 -11
- package/lib/typescript/reanimated2/index.d.ts +3 -1
- package/lib/typescript/reanimated2/interpolateColor.d.ts +2 -3
- package/lib/typescript/reanimated2/js-reanimated/commonTypes.d.ts +1 -43
- package/lib/typescript/reanimated2/js-reanimated/index.d.ts +3 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +4 -4
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -11
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +3 -3
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +13 -13
- package/lib/typescript/reanimated2/layoutReanimation/index.d.ts +1 -0
- package/lib/typescript/reanimated2/mappers.d.ts +0 -12
- package/lib/typescript/reanimated2/mock.d.ts +1 -76
- package/lib/typescript/reanimated2/mutables.d.ts +0 -1
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/reanimated2/valueSetter.d.ts +0 -1
- package/lib/typescript/setAndForwardRef.d.ts +1 -1
- package/package.json +3 -1
- package/src/Animated.ts +80 -6
- package/src/createAnimatedComponent.tsx +2 -2
- package/src/reanimated2/Easing.ts +18 -8
- package/src/reanimated2/UpdateProps.ts +13 -17
- package/src/reanimated2/animation/commonTypes.ts +3 -3
- package/src/reanimated2/animation/decay.ts +3 -1
- package/src/reanimated2/animation/index.ts +3 -3
- package/src/reanimated2/animation/springUtils.ts +2 -0
- package/src/reanimated2/animation/styleAnimation.ts +5 -5
- package/src/reanimated2/animation/timing.ts +6 -4
- package/src/reanimated2/animation/transformationMatrix/matrixUtils.tsx +4 -1
- package/src/reanimated2/animation/util.ts +5 -29
- package/src/reanimated2/commonTypes.ts +0 -25
- package/src/reanimated2/component/FlatList.tsx +3 -1
- package/src/reanimated2/component/ScrollView.tsx +1 -1
- package/src/reanimated2/core.ts +16 -0
- package/src/reanimated2/fabricUtils.ts +1 -0
- package/src/reanimated2/globals.d.ts +3 -3
- package/src/reanimated2/helperTypes.ts +17 -7
- package/src/reanimated2/hook/commonTypes.ts +2 -3
- package/src/reanimated2/hook/index.ts +4 -1
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +2 -2
- package/src/reanimated2/hook/useAnimatedRef.ts +13 -10
- package/src/reanimated2/hook/useAnimatedStyle.ts +27 -26
- package/src/reanimated2/hook/utils.ts +5 -31
- package/src/reanimated2/index.ts +13 -1
- package/src/reanimated2/interpolateColor.ts +2 -2
- package/src/reanimated2/js-reanimated/commonTypes.ts +3 -3
- package/src/reanimated2/js-reanimated/index.ts +4 -3
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -4
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +5 -5
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -3
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -13
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/mappers.ts +2 -2
- package/src/reanimated2/mock.ts +27 -0
- package/src/reanimated2/mutables.ts +0 -1
- package/src/reanimated2/platform-specific/checkCppVersion.ts +2 -0
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/valueSetter.ts +0 -1
- package/src/setAndForwardRef.ts +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +0 -69
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +0 -1
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +0 -109
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +0 -1
- package/lib/typescript/reanimated2/js-reanimated/Mapper.d.ts +0 -14
- package/lib/typescript/reanimated2/js-reanimated/MapperRegistry.d.ts +0 -14
- package/src/reanimated2/js-reanimated/Mapper.ts +0 -94
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +0 -133
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","interpolate","useSharedValue","Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","arguments","Error","ColorSpace","useInterpolateConfig","RGB","cache","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport type { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\ninterface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\ninterface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): string;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): number;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n}\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB,\n interpolateConfig.value.options\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV,\n interpolateConfig.value.options\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,OAAO,QACF,UAAU;AACjB,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,SAASC,cAAc,QAAQ,uBAAuB;AAEtD,OAAO,MAAMC,WAAW,GAAG;EACzBC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,QAAQ,EAAE;AACZ,CAAC;AAOD,MAAMC,oBAAoB,GAAGA,CAC3BC,KAAa,EACbC,UAA6B,EAC7BC,MAAsB,EACtBC,OAA6B,KAC1B;EACH,SAAS;;EACT,IAAIC,CAAC,GAAG,CAAC;EACT,MAAM;IAAEC,4BAA4B,GAAG;EAAK,CAAC,GAAGF,OAAO;EACvD,IAAIE,4BAA4B,EAAE;IAChC;IACA;IACA;IACA;IACA,MAAMC,mBAAmB,GAAG,CAACL,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAMM,SAAS,GAAGL,MAAM,CAACE,CAAC;IAC1B,MAAMI,UAAU,GAAG,CAACD,SAAS,CAAC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,EAClCC,MAAM,EACN6C,iBAAiB,CAAC/C,KAAK,CAACG,OAAO,CAChC;EACH;EACA,MAAM,IAAIsC,KAAK,CACZ,iCAAgCM,iBAAiB,CAAC/C,KAAK,CAACuC,UAAW,wCAAuC,CAC5G;AACH,CAAC"}
|
|
1
|
+
{"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","interpolate","useSharedValue","Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","arguments","Error","ColorSpace","useInterpolateConfig","RGB","cache","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport type { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\nexport interface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\nexport interface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): string;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): number;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n}\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB,\n interpolateConfig.value.options\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV,\n interpolateConfig.value.options\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAA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AM,GAAG6B,iBAAiB,CAACgB,iBAAiB,CAAC/C,KAAK,CAACsC,WAAW,CAAC;MAC/DS,iBAAiB,CAAC/C,KAAK,CAAC6C,KAAK,CAAC7C,KAAK,GAAGE,MAAM;IAC9C;IACA,OAAOsB,oBAAoB,CACzBxB,KAAK,EACL+C,iBAAiB,CAAC/C,KAAK,CAACC,UAAU,EAClCC,MAAM,EACN6C,iBAAiB,CAAC/C,KAAK,CAACG,OAAO,CAChC;EACH,CAAC,MAAM,IAAI4C,iBAAiB,CAAC/C,KAAK,CAACuC,UAAU,KAAKG,UAAU,CAACM,GAAG,EAAE;IAChE,IAAI,CAAC9C,MAAM,EAAE;MACXA,MAAM,GAAGiC,iBAAiB,CAACY,iBAAiB,CAAC/C,KAAK,CAACsC,WAAW,CAAC;MAC/DS,iBAAiB,CAAC/C,KAAK,CAAC6C,KAAK,CAAC7C,KAAK,GAAGE,MAAM;IAC9C;IACA,OAAOH,oBAAoB,CACzBC,KAAK,EACL+C,iBAAiB,CAAC/C,KAAK,CAACC,UAAU,EAClCC,MAAM,EACN6C,iBAAiB,CAAC/C,KAAK,CAACG,OAAO,CAChC;EACH;EACA,MAAM,IAAIsC,KAAK,CACZ,iCAAgCM,iBAAiB,CAAC/C,KAAK,CAACuC,UAAW,wCAAuC,CAC5G;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import type { Timestamp, NestedObjectValues } from '../commonTypes';\nimport type MutableValue from './MutableValue';\n\
|
|
1
|
+
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import type { Timestamp, NestedObjectValues } from '../commonTypes';\nimport type MutableValue from './MutableValue';\n\ninterface Mapper<T> {\n MAPPER_ID?: number;\n id: number;\n inputs: MutableValue<T>[];\n outputs: MutableValue<T>[];\n mapper: () => void;\n dirty: boolean;\n execute(): void;\n extractMutablesFromArray<T>(\n array: NestedObjectValues<MutableValue<T>>\n ): MutableValue<T>[];\n}\n\ninterface MapperRegistry<T> {\n sortedMappers: Mapper<T>[];\n mappers: Map<number, Mapper<T>>;\n _module: JSReanimated;\n updatedSinceLastExecute: boolean;\n startMapper(mapper: Mapper<T>): number;\n stopMapper(id: number): void;\n execute(): void;\n updateOrder(): void;\n}\n\ninterface JSReanimated {\n _valueSetter?: <T>(value: T) => void;\n _renderRequested: boolean;\n _mapperRegistry: MapperRegistry<any>;\n _frames: ((timestamp: Timestamp) => void)[];\n timeProvider: { now: () => number };\n pushFrame(frame: (timestamp: Timestamp) => void): void;\n maybeRequestRender(): void;\n _onRender(timestampMs: number): void;\n installCoreFunctions(valueSetter: <T>(value: T) => void): void;\n makeShareable<T>(value: T): T;\n makeMutable<T>(value: T): MutableValue<T>;\n makeRemote<T>(object: Record<string, any>): T;\n startMapper(\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<unknown>>[],\n outputs: NestedObjectValues<MutableValue<unknown>>[]\n ): number;\n stopMapper(mapperId: number): void;\n registerEventHandler<T>(_: string, __: (event: T) => void): string;\n unregisterEventHandler(_: string): void;\n enableLayoutAnimations(): void;\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["JSReanimated","isWeb","createReactDOMStyle","createTransformValue","require","default","e","reanimatedJS","global","_makeShareableClone","Error","_scheduleOnJS","_updatePropsJS","updates","viewRef","_component","component","rawStyles","Object","keys","reduce","acc","key","value","index","setNativeProps","undefined","style","updatePropsDOM","props","length","forEach","dashedKey","replace","m","toLowerCase","_touchableNode","setAttribute","console","warn","_component$setNativeP","previousStyle","currentStyle","call","domStyle","Array","isArray","transform"],"sources":["index.ts"],"sourcesContent":["import JSReanimated from './JSReanimated';\nimport type {
|
|
1
|
+
{"version":3,"names":["JSReanimated","isWeb","createReactDOMStyle","createTransformValue","require","default","e","reanimatedJS","global","_makeShareableClone","Error","_scheduleOnJS","_updatePropsJS","updates","viewRef","_component","component","rawStyles","Object","keys","reduce","acc","key","value","index","setNativeProps","undefined","style","updatePropsDOM","props","length","forEach","dashedKey","replace","m","toLowerCase","_touchableNode","setAttribute","console","warn","_component$setNativeP","previousStyle","currentStyle","call","domStyle","Array","isArray","transform"],"sources":["index.ts"],"sourcesContent":["import JSReanimated from './JSReanimated';\nimport type { StyleProps } from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\nimport { isWeb } from '../PlatformChecker';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet createReactDOMStyle: (style: any) => any;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet createTransformValue: (transform: any) => any;\n\nif (isWeb()) {\n try {\n createReactDOMStyle =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('react-native-web/dist/exports/StyleSheet/compiler/createReactDOMStyle').default;\n } catch (e) {}\n\n try {\n // React Native Web 0.19+\n createTransformValue =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('react-native-web/dist/exports/StyleSheet/preprocess').createTransformValue;\n } catch (e) {}\n}\n\nconst reanimatedJS = new JSReanimated();\n\nglobal._makeShareableClone = () => {\n throw new Error(\n '[Reanimated] _makeShareableClone should never be called in JSReanimated.'\n );\n};\n\nglobal._scheduleOnJS = () => {\n throw new Error(\n '[Reanimated] _scheduleOnJS should never be called in JSReanimated.'\n );\n};\n\ninterface JSReanimatedComponent {\n previousStyle: StyleProps;\n setNativeProps?: (style: StyleProps) => void;\n style?: StyleProps;\n props: Record<string, string | number>;\n _touchableNode: {\n setAttribute: (key: string, props: unknown) => void;\n };\n}\n\nexport const _updatePropsJS = (\n updates: StyleProps | AnimatedStyle<any>,\n viewRef: { _component?: JSReanimatedComponent }\n): void => {\n if (viewRef._component) {\n const component = viewRef._component;\n const [rawStyles] = Object.keys(updates).reduce(\n (acc: [StyleProps, AnimatedStyle<any>], key) => {\n const value = updates[key];\n const index = typeof value === 'function' ? 1 : 0;\n acc[index][key] = value;\n return acc;\n },\n [{}, {}]\n );\n\n if (typeof component.setNativeProps === 'function') {\n // This is the legacy way to update props on React Native Web <= 0.18.\n // Also, some components (e.g. from react-native-svg) don't have styles\n // and always provide setNativeProps function instead (even on React Native Web 0.19+).\n setNativeProps(component, rawStyles);\n } else if (\n createReactDOMStyle !== undefined &&\n component.style !== undefined\n ) {\n // React Native Web 0.19+ no longer provides setNativeProps function,\n // so we need to update DOM nodes directly.\n updatePropsDOM(component, rawStyles);\n } else if (Object.keys(component.props).length > 0) {\n Object.keys(component.props).forEach((key) => {\n if (!rawStyles[key]) {\n return;\n }\n const dashedKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n component._touchableNode.setAttribute(dashedKey, rawStyles[key]);\n });\n } else {\n console.warn('It is not possible to manipulate component');\n }\n }\n};\n\nconst setNativeProps = (\n component: JSReanimatedComponent,\n style: StyleProps\n): void => {\n const previousStyle = component.previousStyle ? component.previousStyle : {};\n const currentStyle = { ...previousStyle, ...style };\n component.previousStyle = currentStyle;\n component.setNativeProps?.({ style: currentStyle });\n};\n\nconst updatePropsDOM = (\n component: JSReanimatedComponent,\n style: StyleProps\n): void => {\n const previousStyle = component.previousStyle ? component.previousStyle : {};\n const currentStyle = { ...previousStyle, ...style };\n component.previousStyle = currentStyle;\n\n const domStyle = createReactDOMStyle(currentStyle);\n if (Array.isArray(domStyle.transform) && createTransformValue !== undefined) {\n domStyle.transform = createTransformValue(domStyle.transform);\n }\n for (const key in domStyle) {\n (component.style as StyleProps)[key] = domStyle[key];\n }\n};\n\nexport default reanimatedJS;\n"],"mappings":"AAAA,OAAOA,YAAY,MAAM,gBAAgB;AAGzC,SAASC,KAAK,QAAQ,oBAAoB;;AAE1C;AACA,IAAIC,mBAAwC;AAC5C;AACA,IAAIC,oBAA6C;AAEjD,IAAIF,KAAK,EAAE,EAAE;EACX,IAAI;IACFC,mBAAmB;IACjB;IACAE,OAAO,CAAC,uEAAuE,CAAC,CAACC,OAAO;EAC5F,CAAC,CAAC,OAAOC,CAAC,EAAE,CAAC;EAEb,IAAI;IACF;IACAH,o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YAAY,CAAC;EAClD,IAAIG,KAAK,CAACC,OAAO,CAACF,QAAQ,CAACG,SAAS,CAAC,IAAI5C,oBAAoB,KAAKuB,SAAS,EAAE;IAC3EkB,QAAQ,CAACG,SAAS,GAAG5C,oBAAoB,CAACyC,QAAQ,CAACG,SAAS,CAAC;EAC/D;EACA,KAAK,MAAMzB,GAAG,IAAIsB,QAAQ,EAAE;IACzB5B,SAAS,CAACW,KAAK,CAAgBL,GAAG,CAAC,GAAGsB,QAAQ,CAACtB,GAAG,CAAC;EACtD;AACF,CAAC;AAED,eAAef,YAAY"}
|
package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withTiming","withSpring","BaseAnimationBuilder","ComplexAnimationBuilder","constructor","arguments","_defineProperty","easing","easingFunction","instance","createInstance","easingV","rotate","degree","rotateV","springify","duration","durationV","type","dampingRatio","dampingRatioV","damping","dampingV","mass","massV","stiffness","stiffnessV","overshootClamping","overshootClampingV","restDisplacementThreshold","restDisplacementThresholdV","restSpeedThreshold","restSpeedThresholdV","withInitialValues","values","initialValues","getAnimationAndConfig","animation","config","maybeSetConfigValue","value","variableName","forEach","_ref"],"sources":["ComplexAnimationBuilder.ts"],"sourcesContent":["import { withTiming, withSpring } from '../../animation';\nimport type {\n AnimationFunction,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n} from './commonTypes';\nimport type { EasingFn } from '../../Easing';\nimport { BaseAnimationBuilder } from './BaseAnimationBuilder';\nimport type { StyleProps } from '../../commonTypes';\n\nexport class ComplexAnimationBuilder extends BaseAnimationBuilder {\n easingV?: EasingFn;\n rotateV?: string;\n type?: AnimationFunction;\n dampingV?: number;\n dampingRatioV?: number;\n massV?: number;\n stiffnessV?: number;\n overshootClampingV?: number;\n restDisplacementThresholdV?: number;\n restSpeedThresholdV?: number;\n initialValues?: StyleProps;\n\n static createInstance: <T extends typeof BaseAnimationBuilder>(\n this: T\n ) => InstanceType<T>;\n\n static easing<T extends typeof ComplexAnimationBuilder>(\n this: T,\n easingFunction: EasingFn\n ) {\n const instance = this.createInstance();\n return instance.easing(easingFunction);\n }\n\n easing(easingFunction: EasingFn): this {\n this.easingV = easingFunction;\n return this;\n }\n\n static rotate<T extends typeof ComplexAnimationBuilder>(\n this: T,\n degree: string\n ) {\n const instance = this.createInstance();\n return instance.rotate(degree);\n }\n\n rotate(degree: string): this {\n this.rotateV = degree;\n return this;\n }\n\n static springify<T extends typeof ComplexAnimationBuilder>(\n this: T,\n duration?: number\n ): ComplexAnimationBuilder {\n const instance = this.createInstance();\n return instance.springify(duration);\n }\n\n springify(duration?: number): this {\n this.durationV = duration;\n this.type = withSpring as AnimationFunction;\n return this;\n }\n\n static dampingRatio<T extends typeof ComplexAnimationBuilder>(\n this: T,\n dampingRatio: number\n ) {\n const instance = this.createInstance();\n return instance.dampingRatio(dampingRatio);\n }\n\n dampingRatio(dampingRatio: number): this {\n this.dampingRatioV = dampingRatio;\n return this;\n }\n\n static damping<T extends typeof ComplexAnimationBuilder>(\n this: T,\n damping: number\n ) {\n const instance = this.createInstance();\n return instance.damping(damping);\n }\n\n damping(damping: number): this {\n this.dampingV = damping;\n return this;\n }\n\n static mass<T extends typeof ComplexAnimationBuilder>(this: T, mass: number) {\n const instance = this.createInstance();\n return instance.mass(mass);\n }\n\n mass(mass: number): this {\n this.massV = mass;\n return this;\n }\n\n static stiffness<T extends typeof ComplexAnimationBuilder>(\n this: T,\n stiffness: number\n ) {\n const instance = this.createInstance();\n return instance.stiffness(stiffness);\n }\n\n stiffness(stiffness: number): this {\n this.stiffnessV = stiffness;\n return this;\n }\n\n static overshootClamping<T extends typeof ComplexAnimationBuilder>(\n this: T,\n overshootClamping: number\n ) {\n const instance = this.createInstance();\n return instance.overshootClamping(overshootClamping);\n }\n\n overshootClamping(overshootClamping: number): this {\n this.overshootClampingV = overshootClamping;\n return this;\n }\n\n static restDisplacementThreshold<T extends typeof ComplexAnimationBuilder>(\n this: T,\n restDisplacementThreshold: number\n ) {\n const instance = this.createInstance();\n return instance.restDisplacementThreshold(restDisplacementThreshold);\n }\n\n restDisplacementThreshold(restDisplacementThreshold: number) {\n this.restDisplacementThresholdV = restDisplacementThreshold;\n return this;\n }\n\n static restSpeedThreshold<T extends typeof ComplexAnimationBuilder>(\n this: T,\n restSpeedThreshold: number\n ) {\n const instance = this.createInstance();\n return instance.restSpeedThreshold(restSpeedThreshold);\n }\n\n restSpeedThreshold(restSpeedThreshold: number): this {\n this.restSpeedThresholdV = restSpeedThreshold;\n return this;\n }\n\n static withInitialValues<T extends typeof ComplexAnimationBuilder>(\n this: T,\n values: StyleProps\n ) {\n const instance = this.createInstance();\n return instance.withInitialValues(values);\n }\n\n withInitialValues(values: StyleProps): this {\n this.initialValues = values;\n return this;\n }\n\n getAnimationAndConfig(): LayoutAnimationAndConfig {\n const duration = this.durationV;\n const easing = this.easingV;\n const rotate = this.rotateV;\n const type = this.type ? this.type : (withTiming as AnimationFunction);\n const damping = this.dampingV;\n const dampingRatio = this.dampingRatioV;\n const mass = this.massV;\n const stiffness = this.stiffnessV;\n const overshootClamping = this.overshootClampingV;\n const restDisplacementThreshold = this.restDisplacementThresholdV;\n const restSpeedThreshold = this.restSpeedThresholdV;\n\n const animation = type;\n\n const config: BaseBuilderAnimationConfig = {};\n\n function maybeSetConfigValue<Key extends keyof BaseBuilderAnimationConfig>(\n value: BaseBuilderAnimationConfig[Key],\n variableName: Key\n ) {\n if (value) {\n config[variableName] = value;\n }\n }\n\n if (type === withTiming) {\n maybeSetConfigValue(easing, 'easing');\n }\n\n (\n [\n { variableName: 'damping', value: damping },\n { variableName: 'dampingRatio', value: dampingRatio },\n { variableName: 'mass', value: mass },\n { variableName: 'stiffness', value: stiffness },\n { variableName: 'overshootClamping', value: overshootClamping },\n {\n variableName: 'restDisplacementThreshold',\n value: restDisplacementThreshold,\n },\n { variableName: 'restSpeedThreshold', value: restSpeedThreshold },\n { variableName: 'duration', value: duration },\n { variableName: 'rotate', value: rotate },\n ] as const\n ).forEach(({ value, variableName }) =>\n maybeSetConfigValue(value, variableName)\n );\n\n return [animation, config];\n }\n}\n"],"mappings":";;;AAAA,SAASA,UAAU,EAAEC,UAAU,QAAQ,iBAAiB;AAOxD,SAASC,oBAAoB,QAAQ,wBAAwB;AAG7D,OAAO,MAAMC,uBAAuB,SAASD,oBAAoB,CAAC;EAAAE,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;EAAA;EAiBhE,OAAOC,MAAMA,CAEXC,cAAwB,EACxB;IACA,MAAMC,QAAQ,GAAG,IAAI,CAACC,cAAc,EAAE;IACtC,OAAOD,QAAQ,CAACF,MAAM,CAACC,cAAc,CAAC;EACxC;EAEAD,MAAMA,CAACC,cAAwB,EAAQ;IACrC,IAAI,CAACG,OAAO,GAAGH,cAAc;IAC7B,OAAO,IAAI;EACb;EAEA,OAAOI,MAAMA,CAEXC,MAAc,EACd;IACA,MAAMJ,QAAQ,GAAG,IAAI,CAACC,cAAc,EAAE;IACtC,OAAOD,QAAQ,CAACG,MAAM,CAACC,MAAM,CAAC;EAChC;EAEAD,MAAMA,CAACC,MAAc,EAAQ;IAC3B,IAAI,CAACC,OAAO,GAAGD,MAAM;IACrB,OAAO,IAAI;EACb;EAEA,OAAOE,SAASA,CAEdC,QAAiB,EACQ;IACzB,MAAMP,QAAQ,GAAG,IAAI,CAACC,cAAc,EAAE;IACtC,OAAOD,QAAQ,CAACM,SAAS,CAACC,QAAQ,CAAC;EACrC;EAEAD,SAASA,CAACC,QAAiB,EAAQ;IACjC,IAAI,CAACC,SAAS,GAAGD,QAAQ;IACzB,IAAI,CAACE,IAAI,GAAGjB,UAA+B;IAC3C,OAAO,IAAI;EACb;EAEA,OAAOkB,YAAYA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,CAjNYH,uBAAuB"}
|
|
1
|
+
{"version":3,"names":["withTiming","withSpring","BaseAnimationBuilder","ComplexAnimationBuilder","constructor","arguments","_defineProperty","easing","easingFunction","instance","createInstance","easingV","rotate","degree","rotateV","springify","duration","durationV","type","dampingRatio","dampingRatioV","damping","dampingV","mass","massV","stiffness","stiffnessV","overshootClamping","overshootClampingV","restDisplacementThreshold","restDisplacementThresholdV","restSpeedThreshold","restSpeedThresholdV","withInitialValues","values","initialValues","getAnimationAndConfig","animation","config","maybeSetConfigValue","value","variableName","forEach","_ref"],"sources":["ComplexAnimationBuilder.ts"],"sourcesContent":["import { withTiming, withSpring } from '../../animation';\nimport type {\n AnimationFunction,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n} from './commonTypes';\nimport type { EasingFunction } from '../../Easing';\nimport { BaseAnimationBuilder } from './BaseAnimationBuilder';\nimport type { StyleProps } from '../../commonTypes';\n\nexport class ComplexAnimationBuilder extends BaseAnimationBuilder {\n easingV?: EasingFunction;\n rotateV?: string;\n type?: AnimationFunction;\n dampingV?: number;\n dampingRatioV?: number;\n massV?: number;\n stiffnessV?: number;\n overshootClampingV?: number;\n restDisplacementThresholdV?: number;\n restSpeedThresholdV?: number;\n initialValues?: StyleProps;\n\n static createInstance: <T extends typeof BaseAnimationBuilder>(\n this: T\n ) => InstanceType<T>;\n\n static easing<T extends typeof ComplexAnimationBuilder>(\n this: T,\n easingFunction: EasingFunction\n ) {\n const instance = this.createInstance();\n return instance.easing(easingFunction);\n }\n\n easing(easingFunction: EasingFunction): this {\n this.easingV = easingFunction;\n return this;\n }\n\n static rotate<T extends typeof ComplexAnimationBuilder>(\n this: T,\n degree: string\n ) {\n const instance = this.createInstance();\n return instance.rotate(degree);\n }\n\n rotate(degree: string): this {\n this.rotateV = degree;\n return this;\n }\n\n static springify<T extends typeof ComplexAnimationBuilder>(\n this: T,\n duration?: number\n ): ComplexAnimationBuilder {\n const instance = this.createInstance();\n return instance.springify(duration);\n }\n\n springify(duration?: number): this {\n this.durationV = duration;\n this.type = withSpring as AnimationFunction;\n return this;\n }\n\n static dampingRatio<T extends typeof ComplexAnimationBuilder>(\n this: T,\n dampingRatio: number\n ) {\n const instance = this.createInstance();\n return instance.dampingRatio(dampingRatio);\n }\n\n dampingRatio(dampingRatio: number): this {\n this.dampingRatioV = dampingRatio;\n return this;\n }\n\n static damping<T extends typeof ComplexAnimationBuilder>(\n this: T,\n damping: number\n ) {\n const instance = this.createInstance();\n return instance.damping(damping);\n }\n\n damping(damping: number): this {\n this.dampingV = damping;\n return this;\n }\n\n static mass<T extends typeof ComplexAnimationBuilder>(this: T, mass: number) {\n const instance = this.createInstance();\n return instance.mass(mass);\n }\n\n mass(mass: number): this {\n this.massV = mass;\n return this;\n }\n\n static stiffness<T extends typeof ComplexAnimationBuilder>(\n this: T,\n stiffness: number\n ) {\n const instance = this.createInstance();\n return instance.stiffness(stiffness);\n }\n\n stiffness(stiffness: number): this {\n this.stiffnessV = stiffness;\n return this;\n }\n\n static overshootClamping<T extends typeof ComplexAnimationBuilder>(\n this: T,\n overshootClamping: number\n ) {\n const instance = this.createInstance();\n return instance.overshootClamping(overshootClamping);\n }\n\n overshootClamping(overshootClamping: number): this {\n this.overshootClampingV = overshootClamping;\n return this;\n }\n\n static restDisplacementThreshold<T extends typeof ComplexAnimationBuilder>(\n this: T,\n restDisplacementThreshold: number\n ) {\n const instance = this.createInstance();\n return instance.restDisplacementThreshold(restDisplacementThreshold);\n }\n\n restDisplacementThreshold(restDisplacementThreshold: number) {\n this.restDisplacementThresholdV = restDisplacementThreshold;\n return this;\n }\n\n static restSpeedThreshold<T extends typeof ComplexAnimationBuilder>(\n this: T,\n restSpeedThreshold: number\n ) {\n const instance = this.createInstance();\n return instance.restSpeedThreshold(restSpeedThreshold);\n }\n\n restSpeedThreshold(restSpeedThreshold: number): this {\n this.restSpeedThresholdV = restSpeedThreshold;\n return this;\n }\n\n static withInitialValues<T extends typeof ComplexAnimationBuilder>(\n this: T,\n values: StyleProps\n ) {\n const instance = this.createInstance();\n return instance.withInitialValues(values);\n }\n\n withInitialValues(values: StyleProps): this {\n this.initialValues = values;\n return this;\n }\n\n getAnimationAndConfig(): LayoutAnimationAndConfig {\n const duration = this.durationV;\n const easing = this.easingV;\n const rotate = this.rotateV;\n const type = this.type ? this.type : (withTiming as AnimationFunction);\n const damping = this.dampingV;\n const dampingRatio = this.dampingRatioV;\n const mass = this.massV;\n const stiffness = this.stiffnessV;\n const overshootClamping = this.overshootClampingV;\n const restDisplacementThreshold = this.restDisplacementThresholdV;\n const restSpeedThreshold = this.restSpeedThresholdV;\n\n const animation = type;\n\n const config: BaseBuilderAnimationConfig = {};\n\n function maybeSetConfigValue<Key extends keyof BaseBuilderAnimationConfig>(\n value: BaseBuilderAnimationConfig[Key],\n variableName: Key\n ) {\n if (value) {\n config[variableName] = value;\n }\n }\n\n if (type === withTiming) {\n maybeSetConfigValue(easing, 'easing');\n }\n\n (\n [\n { variableName: 'damping', value: damping },\n { variableName: 'dampingRatio', value: dampingRatio },\n { variableName: 'mass', value: mass },\n { variableName: 'stiffness', value: stiffness },\n { variableName: 'overshootClamping', value: overshootClamping },\n {\n variableName: 'restDisplacementThreshold',\n value: restDisplacementThreshold,\n },\n { variableName: 'restSpeedThreshold', value: restSpeedThreshold },\n { variableName: 'duration', value: duration },\n { variableName: 'rotate', value: rotate },\n ] as const\n ).forEach(({ value, variableName }) =>\n maybeSetConfigValue(value, variableName)\n );\n\n return [animation, config];\n }\n}\n"],"mappings":";;;AAAA,SAASA,UAAU,EAAEC,UAAU,QAAQ,iBAAiB;AAOxD,SAASC,oBAAoB,QAAQ,wBAAwB;AAG7D,OAAO,MAAMC,uBAAuB,SAASD,oBAAoB,CAAC;EAAAE,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAA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AGE,CACE;MAAEkC,YAAY,EAAE,SAAS;MAAED,KAAK,EAAEnB;IAAQ,CAAC,EAC3C;MAAEoB,YAAY,EAAE,cAAc;MAAED,KAAK,EAAErB;IAAa,CAAC,EACrD;MAAEsB,YAAY,EAAE,MAAM;MAAED,KAAK,EAAEjB;IAAK,CAAC,EACrC;MAAEkB,YAAY,EAAE,WAAW;MAAED,KAAK,EAAEf;IAAU,CAAC,EAC/C;MAAEgB,YAAY,EAAE,mBAAmB;MAAED,KAAK,EAAEb;IAAkB,CAAC,EAC/D;MACEc,YAAY,EAAE,2BAA2B;MACzCD,KAAK,EAAEX;IACT,CAAC,EACD;MAAEY,YAAY,EAAE,oBAAoB;MAAED,KAAK,EAAET;IAAmB,CAAC,EACjE;MAAEU,YAAY,EAAE,UAAU;MAAED,KAAK,EAAExB;IAAS,CAAC,EAC7C;MAAEyB,YAAY,EAAE,QAAQ;MAAED,KAAK,EAAE5B;IAAO,CAAC,CAC1C,CACD8B,OAAO,CAACC,IAAA;MAAA,IAAC;QAAEH,KAAK;QAAEC;MAAa,CAAC,GAAAE,IAAA;MAAA,OAChCJ,mBAAmB,CAACC,KAAK,EAAEC,YAAY,CAAC;IAAA,EACzC;IAED,OAAO,CAACJ,SAAS,EAAEC,MAAM,CAAC;EAC5B;AACF;AAAChC,eAAA,CAjNYH,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Easing","withDelay","withSequence","withTiming","InnerKeyframe","constructor","definitions","_defineProperty","delay","delayV","delayFunction","getDelayFunction","keyframes","initialValues","parseDefinitions","callback","callbackV","animations","addAnimation","key","keyframePoints","length","animation","value","duration","easing","linear","apply","map","keyframePoint","includes","_animations$transform","transform","push","split","Object","keys","forEach","transformProp","index","transformPropKey","toString","parsedKeyframes","from","Error","to","styleProp","_initialValues$styleP","transformStyle","durationV","animationKeyPoints","Array","getAnimationDuration","currentKeyPoint","maxDuration","currentDuration","reduce","acc","addKeyPoint","_ref","filter","parseInt","sort","a","b","keyPoint","keyframe","addKeyPointWith","_keyframe$key","durationMs","delayMs","withCallback","_","Keyframe"],"sources":["Keyframe.ts"],"sourcesContent":["import type { EasingFn } from '../../Easing';\nimport { Easing } from '../../Easing';\nimport { withDelay, withSequence, withTiming } from '../../animation';\nimport type {\n AnimationFunction,\n EntryExitAnimationFunction,\n IEntryExitAnimationBuilder,\n KeyframeProps,\n} from './commonTypes';\nimport type { TransformProperty, StyleProps } from '../../commonTypes';\nexport interface KeyframePoint {\n duration: number;\n value: number | string;\n easing?: EasingFn;\n}\nexport interface ParsedKeyframesDefinition {\n initialValues: StyleProps;\n keyframes: Record<string, KeyframePoint[]>;\n}\nclass InnerKeyframe implements IEntryExitAnimationBuilder {\n durationV?: number;\n delayV?: number;\n callbackV?: (finished: boolean) => void;\n definitions: Record<string, KeyframeProps>;\n\n /*\n Keyframe definition should be passed in the constructor as the map\n which keys are between range 0 - 100 (%) and correspond to the point in the animation progress.\n */\n constructor(definitions: Record<string, KeyframeProps>) {\n this.definitions = definitions;\n }\n\n private parseDefinitions(): ParsedKeyframesDefinition {\n /* \n Each style property contain an array with all their key points: \n value, duration of transition to that value, and optional easing function (defaults to Linear)\n */\n const parsedKeyframes: Record<string, KeyframePoint[]> = {};\n /*\n Parsing keyframes 'from' and 'to'.\n */\n if (this.definitions.from) {\n if (this.definitions['0']) {\n throw Error(\n \"You cannot provide both keyframe 0 and 'from' as they both specified initial values\"\n );\n }\n this.definitions['0'] = this.definitions.from;\n delete this.definitions.from;\n }\n if (this.definitions.to) {\n if (this.definitions['100']) {\n throw Error(\n \"You cannot provide both keyframe 100 and 'to' as they both specified values at the end of the animation.\"\n );\n }\n this.definitions['100'] = this.definitions.to;\n delete this.definitions.to;\n }\n /* \n One of the assumptions is that keyframe 0 is required to properly set initial values.\n Every other keyframe should contain properties from the set provided as initial values.\n */\n if (!this.definitions['0']) {\n throw Error(\n \"Please provide 0, or 'from' keyframe with initial state of your object.\"\n );\n }\n const initialValues: StyleProps = this.definitions['0'] as StyleProps;\n /*\n Initialize parsedKeyframes for properties provided in initial keyframe\n */\n Object.keys(initialValues).forEach((styleProp: string) => {\n if (styleProp === 'transform') {\n initialValues[styleProp]?.forEach((transformStyle, index) => {\n Object.keys(transformStyle).forEach((transformProp: string) => {\n parsedKeyframes[index.toString() + '_transform:' + transformProp] =\n [];\n });\n });\n } else {\n parsedKeyframes[styleProp] = [];\n }\n });\n\n const duration: number = this.durationV ? this.durationV : 500;\n const animationKeyPoints: Array<string> = Array.from(\n Object.keys(this.definitions)\n );\n\n const getAnimationDuration = (\n key: string,\n currentKeyPoint: number\n ): number => {\n const maxDuration = (currentKeyPoint / 100) * duration;\n const currentDuration = parsedKeyframes[key].reduce(\n (acc: number, value: KeyframePoint) => acc + value.duration,\n 0\n );\n return maxDuration - currentDuration;\n };\n\n /* \n Other keyframes can't contain properties that were not specified in initial keyframe.\n */\n const addKeyPoint = ({\n key,\n value,\n currentKeyPoint,\n easing,\n }: {\n key: string;\n value: string | number;\n currentKeyPoint: number;\n easing?: EasingFn;\n }): void => {\n if (!(key in parsedKeyframes)) {\n throw Error(\n \"Keyframe can contain only that set of properties that were provide with initial values (keyframe 0 or 'from')\"\n );\n }\n parsedKeyframes[key].push({\n duration: getAnimationDuration(key, currentKeyPoint),\n value: value,\n easing: easing,\n });\n };\n animationKeyPoints\n .filter((value: string) => parseInt(value) !== 0)\n .sort((a: string, b: string) => parseInt(a) - parseInt(b))\n .forEach((keyPoint: string) => {\n if (parseInt(keyPoint) < 0 || parseInt(keyPoint) > 100) {\n throw Error('Keyframe should be in between range 0 - 100.');\n }\n const keyframe: KeyframeProps = this.definitions[keyPoint];\n const easing = keyframe.easing;\n delete keyframe.easing;\n const addKeyPointWith = (key: string, value: string | number) =>\n addKeyPoint({\n key,\n value,\n currentKeyPoint: parseInt(keyPoint),\n easing,\n });\n Object.keys(keyframe).forEach((key: string) => {\n if (key === 'transform') {\n keyframe[key]?.forEach(\n (transformStyle: { [key: string]: any }, index) => {\n Object.keys(transformStyle).forEach((transformProp: string) => {\n addKeyPointWith(\n index.toString() + '_transform:' + transformProp,\n transformStyle[transformProp]\n );\n });\n }\n );\n } else {\n addKeyPointWith(key, keyframe[key]);\n }\n });\n });\n return { initialValues: initialValues, keyframes: parsedKeyframes };\n }\n\n duration(durationMs: number): InnerKeyframe {\n this.durationV = durationMs;\n return this;\n }\n\n delay(delayMs: number): InnerKeyframe {\n this.delayV = delayMs;\n return this;\n }\n\n withCallback(callback: (finsihed: boolean) => void): InnerKeyframe {\n this.callbackV = callback;\n return this;\n }\n\n private getDelayFunction(): AnimationFunction {\n const delay = this.delayV;\n return delay\n ? withDelay\n : (_, animation) => {\n 'worklet';\n return animation;\n };\n }\n\n build = (): EntryExitAnimationFunction => {\n const delay = this.delayV;\n const delayFunction = this.getDelayFunction();\n const { keyframes, initialValues } = this.parseDefinitions();\n const callback = this.callbackV;\n\n return () => {\n 'worklet';\n const animations: StyleProps = {};\n\n /* \n For each style property, an animations sequence is created that corresponds with its key points.\n Transform style properties require special handling because of their nested structure.\n */\n const addAnimation = (key: string) => {\n const keyframePoints = keyframes[key];\n // in case if property was only passed as initial value\n if (keyframePoints.length === 0) return;\n const animation = delayFunction(\n delay,\n keyframePoints.length === 1\n ? withTiming(keyframePoints[0].value, {\n duration: keyframePoints[0].duration,\n easing: keyframePoints[0].easing\n ? keyframePoints[0].easing\n : Easing.linear,\n })\n : withSequence.apply(\n this,\n keyframePoints.map((keyframePoint: KeyframePoint) =>\n withTiming(keyframePoint.value, {\n duration: keyframePoint.duration,\n easing: keyframePoint.easing\n ? keyframePoint.easing\n : Easing.linear,\n })\n )\n )\n );\n if (key.includes('transform')) {\n if (!('transform' in animations)) {\n animations.transform = [];\n }\n animations.transform?.push(<TransformProperty>{\n [key.split(':')[1]]: animation,\n });\n } else {\n animations[key] = animation;\n }\n };\n Object.keys(initialValues).forEach((key: string) => {\n if (key.includes('transform')) {\n initialValues[key].forEach(\n (transformProp: Record<string, number | string>, index: number) => {\n Object.keys(transformProp).forEach((transformPropKey: string) => {\n addAnimation(\n index.toString() + '_transform:' + transformPropKey\n );\n });\n }\n );\n } else {\n addAnimation(key);\n }\n });\n return {\n animations: animations,\n initialValues: initialValues,\n callback: callback,\n };\n };\n };\n}\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\nexport declare class ReanimatedKeyframe {\n constructor(definitions: Record<string, KeyframeProps>);\n duration(durationMs: number): ReanimatedKeyframe;\n delay(delayMs: number): ReanimatedKeyframe;\n withCallback(callback: (finished: boolean) => void): ReanimatedKeyframe;\n}\n\n// TODO TYPESCRIPT This temporary cast is to get rid of .d.ts file.\nexport const Keyframe = InnerKeyframe as unknown as typeof ReanimatedKeyframe;\n"],"mappings":";;;AACA,SAASA,MAAM,QAAQ,cAAc;AACrC,SAASC,SAAS,EAAEC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAiBrE,MAAMC,aAAa,CAAuC;EAMxD;AACF;AACA;AACA;EACEC,WAAWA,CAACC,WAA0C,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,gBAiKhD,MAAkC;MACxC,MAAMC,KAAK,GAAG,IAAI,CAACC,MAAM;MACzB,MAAMC,aAAa,GAAG,IAAI,CAACC,gBAAgB,EAAE;MAC7C,MAAM;QAAEC,SAAS;QAAEC;MAAc,CAAC,GAAG,IAAI,CAACC,gBAAgB,EAAE;MAC5D,MAAMC,QAAQ,GAAG,IAAI,CAACC,SAAS;MAE/B,OAAO,MAAM;QACX,SAAS;;QACT,MAAMC,UAAsB,GAAG,CAAC,CAAC;;QAEjC;AACN;AACA;AACA;QACM,MAAMC,YAAY,GAAIC,GAAW,IAAK;UACpC,MAAMC,cAAc,GAAGR,SAAS,CAACO,GAAG,CAAC;UACrC;UACA,IAAIC,cAAc,CAACC,MAAM,KAAK,CAAC,EAAE;UACjC,MAAMC,SAAS,GAAGZ,aAAa,CAC7BF,KAAK,EACLY,cAAc,CAACC,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,aAAA,GAAAF,QAAQ,CAAC/C,GAAG,CAAC,cAAAiD,aAAA,uBAAbA,aAAA,CAAe/B,OAAO,CACpB,CAACW,cAAsC,EAAET,KAAK,KAAK;YACjDJ,MAAM,CAACC,IAAI,CAACY,cAAc,CAAC,CAACX,OAAO,CAAEC,aAAqB,IAAK;cAC7D6B,eAAe,CACb5B,KAAK,CAACE,QAAQ,EAAE,GAAG,aAAa,GAAGH,aAAa,EAChDU,cAAc,CAACV,aAAa,CAAC,CAC9B;YACH,CAAC,CAAC;UACJ,CAAC,CACF;QACH,CAAC,MAAM;UACL6B,eAAe,CAAChD,GAAG,EAAE+C,QAAQ,CAAC/C,GAAG,CAAC,CAAC;QACrC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IACJ,OAAO;MAAEN,aAAa,EAAEA,aAAa;MAAED,SAAS,EAAE8B;IAAgB,CAAC;EACrE;EAEAlB,QAAQA,CAAC6C,UAAkB,EAAiB;IAC1C,IAAI,CAACpB,SAAS,GAAGoB,UAAU;IAC3B,OAAO,IAAI;EACb;EAEA7D,KAAKA,CAAC8D,OAAe,EAAiB;IACpC,IAAI,CAAC7D,MAAM,GAAG6D,OAAO;IACrB,OAAO,IAAI;EACb;EAEAC,YAAYA,CAACxD,QAAqC,EAAiB;IACjE,IAAI,CAACC,SAAS,GAAGD,QAAQ;IACzB,OAAO,IAAI;EACb;EAEQJ,gBAAgBA,CAAA,EAAsB;IAC5C,MAAMH,KAAK,GAAG,IAAI,CAACC,MAAM;IACzB,OAAOD,KAAK,GACRP,SAAS,GACT,CAACuE,CAAC,EAAElD,SAAS,KAAK;MAChB,SAAS;;MACT,OAAOA,SAAS;IAClB,CAAC;EACP;AA0EF;;AAEA;;AAQA;AACA,OAAO,MAAMmD,QAAQ,GAAGrE,aAAqD"}
|
|
1
|
+
{"version":3,"names":["Easing","withDelay","withSequence","withTiming","InnerKeyframe","constructor","definitions","_defineProperty","delay","delayV","delayFunction","getDelayFunction","keyframes","initialValues","parseDefinitions","callback","callbackV","animations","addAnimation","key","keyframePoints","length","animation","value","duration","easing","linear","apply","map","keyframePoint","includes","_animations$transform","transform","push","split","Object","keys","forEach","transformProp","index","transformPropKey","toString","parsedKeyframes","from","Error","to","styleProp","_initialValues$styleP","transformStyle","durationV","animationKeyPoints","Array","getAnimationDuration","currentKeyPoint","maxDuration","currentDuration","reduce","acc","addKeyPoint","_ref","filter","parseInt","sort","a","b","keyPoint","keyframe","addKeyPointWith","_keyframe$key","durationMs","delayMs","withCallback","_","Keyframe"],"sources":["Keyframe.ts"],"sourcesContent":["import type { EasingFunction } from '../../Easing';\nimport { Easing } from '../../Easing';\nimport { withDelay, withSequence, withTiming } from '../../animation';\nimport type {\n AnimationFunction,\n EntryExitAnimationFunction,\n IEntryExitAnimationBuilder,\n KeyframeProps,\n} from './commonTypes';\nimport type { TransformProperty, StyleProps } from '../../commonTypes';\ninterface KeyframePoint {\n duration: number;\n value: number | string;\n easing?: EasingFunction;\n}\ninterface ParsedKeyframesDefinition {\n initialValues: StyleProps;\n keyframes: Record<string, KeyframePoint[]>;\n}\nclass InnerKeyframe implements IEntryExitAnimationBuilder {\n durationV?: number;\n delayV?: number;\n callbackV?: (finished: boolean) => void;\n definitions: Record<string, KeyframeProps>;\n\n /*\n Keyframe definition should be passed in the constructor as the map\n which keys are between range 0 - 100 (%) and correspond to the point in the animation progress.\n */\n constructor(definitions: Record<string, KeyframeProps>) {\n this.definitions = definitions;\n }\n\n private parseDefinitions(): ParsedKeyframesDefinition {\n /* \n Each style property contain an array with all their key points: \n value, duration of transition to that value, and optional easing function (defaults to Linear)\n */\n const parsedKeyframes: Record<string, KeyframePoint[]> = {};\n /*\n Parsing keyframes 'from' and 'to'.\n */\n if (this.definitions.from) {\n if (this.definitions['0']) {\n throw Error(\n \"You cannot provide both keyframe 0 and 'from' as they both specified initial values\"\n );\n }\n this.definitions['0'] = this.definitions.from;\n delete this.definitions.from;\n }\n if (this.definitions.to) {\n if (this.definitions['100']) {\n throw Error(\n \"You cannot provide both keyframe 100 and 'to' as they both specified values at the end of the animation.\"\n );\n }\n this.definitions['100'] = this.definitions.to;\n delete this.definitions.to;\n }\n /* \n One of the assumptions is that keyframe 0 is required to properly set initial values.\n Every other keyframe should contain properties from the set provided as initial values.\n */\n if (!this.definitions['0']) {\n throw Error(\n \"Please provide 0, or 'from' keyframe with initial state of your object.\"\n );\n }\n const initialValues: StyleProps = this.definitions['0'] as StyleProps;\n /*\n Initialize parsedKeyframes for properties provided in initial keyframe\n */\n Object.keys(initialValues).forEach((styleProp: string) => {\n if (styleProp === 'transform') {\n initialValues[styleProp]?.forEach((transformStyle, index) => {\n Object.keys(transformStyle).forEach((transformProp: string) => {\n parsedKeyframes[index.toString() + '_transform:' + transformProp] =\n [];\n });\n });\n } else {\n parsedKeyframes[styleProp] = [];\n }\n });\n\n const duration: number = this.durationV ? this.durationV : 500;\n const animationKeyPoints: Array<string> = Array.from(\n Object.keys(this.definitions)\n );\n\n const getAnimationDuration = (\n key: string,\n currentKeyPoint: number\n ): number => {\n const maxDuration = (currentKeyPoint / 100) * duration;\n const currentDuration = parsedKeyframes[key].reduce(\n (acc: number, value: KeyframePoint) => acc + value.duration,\n 0\n );\n return maxDuration - currentDuration;\n };\n\n /* \n Other keyframes can't contain properties that were not specified in initial keyframe.\n */\n const addKeyPoint = ({\n key,\n value,\n currentKeyPoint,\n easing,\n }: {\n key: string;\n value: string | number;\n currentKeyPoint: number;\n easing?: EasingFunction;\n }): void => {\n if (!(key in parsedKeyframes)) {\n throw Error(\n \"Keyframe can contain only that set of properties that were provide with initial values (keyframe 0 or 'from')\"\n );\n }\n parsedKeyframes[key].push({\n duration: getAnimationDuration(key, currentKeyPoint),\n value: value,\n easing: easing,\n });\n };\n animationKeyPoints\n .filter((value: string) => parseInt(value) !== 0)\n .sort((a: string, b: string) => parseInt(a) - parseInt(b))\n .forEach((keyPoint: string) => {\n if (parseInt(keyPoint) < 0 || parseInt(keyPoint) > 100) {\n throw Error('Keyframe should be in between range 0 - 100.');\n }\n const keyframe: KeyframeProps = this.definitions[keyPoint];\n const easing = keyframe.easing;\n delete keyframe.easing;\n const addKeyPointWith = (key: string, value: string | number) =>\n addKeyPoint({\n key,\n value,\n currentKeyPoint: parseInt(keyPoint),\n easing,\n });\n Object.keys(keyframe).forEach((key: string) => {\n if (key === 'transform') {\n keyframe[key]?.forEach(\n (transformStyle: { [key: string]: any }, index) => {\n Object.keys(transformStyle).forEach((transformProp: string) => {\n addKeyPointWith(\n index.toString() + '_transform:' + transformProp,\n transformStyle[transformProp]\n );\n });\n }\n );\n } else {\n addKeyPointWith(key, keyframe[key]);\n }\n });\n });\n return { initialValues: initialValues, keyframes: parsedKeyframes };\n }\n\n duration(durationMs: number): InnerKeyframe {\n this.durationV = durationMs;\n return this;\n }\n\n delay(delayMs: number): InnerKeyframe {\n this.delayV = delayMs;\n return this;\n }\n\n withCallback(callback: (finsihed: boolean) => void): InnerKeyframe {\n this.callbackV = callback;\n return this;\n }\n\n private getDelayFunction(): AnimationFunction {\n const delay = this.delayV;\n return delay\n ? withDelay\n : (_, animation) => {\n 'worklet';\n return animation;\n };\n }\n\n build = (): EntryExitAnimationFunction => {\n const delay = this.delayV;\n const delayFunction = this.getDelayFunction();\n const { keyframes, initialValues } = this.parseDefinitions();\n const callback = this.callbackV;\n\n return () => {\n 'worklet';\n const animations: StyleProps = {};\n\n /* \n For each style property, an animations sequence is created that corresponds with its key points.\n Transform style properties require special handling because of their nested structure.\n */\n const addAnimation = (key: string) => {\n const keyframePoints = keyframes[key];\n // in case if property was only passed as initial value\n if (keyframePoints.length === 0) return;\n const animation = delayFunction(\n delay,\n keyframePoints.length === 1\n ? withTiming(keyframePoints[0].value, {\n duration: keyframePoints[0].duration,\n easing: keyframePoints[0].easing\n ? keyframePoints[0].easing\n : Easing.linear,\n })\n : withSequence.apply(\n this,\n keyframePoints.map((keyframePoint: KeyframePoint) =>\n withTiming(keyframePoint.value, {\n duration: keyframePoint.duration,\n easing: keyframePoint.easing\n ? keyframePoint.easing\n : Easing.linear,\n })\n )\n )\n );\n if (key.includes('transform')) {\n if (!('transform' in animations)) {\n animations.transform = [];\n }\n animations.transform?.push(<TransformProperty>{\n [key.split(':')[1]]: animation,\n });\n } else {\n animations[key] = animation;\n }\n };\n Object.keys(initialValues).forEach((key: string) => {\n if (key.includes('transform')) {\n initialValues[key].forEach(\n (transformProp: Record<string, number | string>, index: number) => {\n Object.keys(transformProp).forEach((transformPropKey: string) => {\n addAnimation(\n index.toString() + '_transform:' + transformPropKey\n );\n });\n }\n );\n } else {\n addAnimation(key);\n }\n });\n return {\n animations: animations,\n initialValues: initialValues,\n callback: callback,\n };\n };\n };\n}\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\nexport declare class ReanimatedKeyframe {\n constructor(definitions: Record<string, KeyframeProps>);\n duration(durationMs: number): ReanimatedKeyframe;\n delay(delayMs: number): ReanimatedKeyframe;\n withCallback(callback: (finished: boolean) => void): ReanimatedKeyframe;\n}\n\n// TODO TYPESCRIPT This temporary cast is to get rid of .d.ts file.\nexport const Keyframe = InnerKeyframe as unknown as typeof ReanimatedKeyframe;\n"],"mappings":";;;AACA,SAASA,MAAM,QAAQ,cAAc;AACrC,SAASC,SAAS,EAAEC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAiBrE,MAAMC,aAAa,CAAuC;EAMxD;AACF;AACA;AACA;EACEC,WAAWA,CAACC,WAA0C,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,gBAiKhD,MAAkC;MACxC,MAAMC,KAAK,GAAG,IAAI,CAACC,MAAM;MACzB,MAAMC,aAAa,GAAG,IAAI,CAACC,gBAAgB,EAAE;MAC7C,MAAM;QAAEC,SAAS;QAAEC;MAAc,CAAC,GAAG,IAAI,CAACC,gBAAgB,EAAE;MAC5D,MAAMC,QAAQ,GAAG,IAAI,CAACC,SAAS;MAE/B,OAAO,MAAM;QACX,SAAS;;QACT,MAAMC,U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EAAElD,SAAS,KAAK;MAChB,SAAS;;MACT,OAAOA,SAAS;IAClB,CAAC;EACP;AA0EF;;AAEA;;AAQA;AACA,OAAO,MAAMmD,QAAQ,GAAGrE,aAAqD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LayoutAnimationType","SharedTransitionType"],"sources":["commonTypes.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["LayoutAnimationType","SharedTransitionType"],"sources":["commonTypes.ts"],"sourcesContent":["import type { EasingFunction } from '../../Easing';\nimport type { StyleProps } from '../../commonTypes';\n\nexport interface KeyframeProps extends StyleProps {\n easing?: EasingFunction;\n [key: string]: any;\n}\n\nexport type LayoutAnimation = {\n initialValues: StyleProps;\n animations: StyleProps;\n callback?: (finished: boolean) => void;\n};\n\nexport type AnimationFunction = (a?: any, b?: any, c?: any) => any; // this is just a temporary mock\n\nexport interface EntryAnimationsValues {\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport interface ExitAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport type EntryExitAnimationFunction =\n | ((targetValues: EntryAnimationsValues) => LayoutAnimation)\n | ((targetValues: ExitAnimationsValues) => LayoutAnimation)\n | (() => LayoutAnimation);\n\nexport type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;\n\nexport interface LayoutAnimationsValues {\n [key: string]: number | number[];\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport interface SharedTransitionAnimationsValues\n extends LayoutAnimationsValues {\n currentTransformMatrix: number[];\n targetTransformMatrix: number[];\n}\n\nexport type SharedTransitionAnimationsFunction = (\n values: SharedTransitionAnimationsValues\n) => LayoutAnimation;\n\nexport enum LayoutAnimationType {\n ENTERING = 1,\n EXITING = 2,\n LAYOUT = 3,\n SHARED_ELEMENT_TRANSITION = 4,\n SHARED_ELEMENT_TRANSITION_PROGRESS = 5,\n}\n\nexport type LayoutAnimationFunction = (\n targetValues: LayoutAnimationsValues\n) => LayoutAnimation;\n\nexport type LayoutAnimationStartFunction = (\n tag: number,\n type: LayoutAnimationType,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n) => void;\n\nexport interface ILayoutAnimationBuilder {\n build: () => LayoutAnimationFunction;\n}\n\nexport interface BaseLayoutAnimationConfig {\n duration?: number;\n easing?: EasingFunction;\n type?: AnimationFunction;\n damping?: number;\n dampingRatio?: number;\n mass?: number;\n stiffness?: number;\n overshootClamping?: number;\n restDisplacementThreshold?: number;\n restSpeedThreshold?: number;\n}\n\nexport interface BaseBuilderAnimationConfig extends BaseLayoutAnimationConfig {\n rotate?: number | string;\n}\n\nexport type LayoutAnimationAndConfig = [\n AnimationFunction,\n BaseBuilderAnimationConfig\n];\n\nexport interface IEntryExitAnimationBuilder {\n build: () => EntryExitAnimationFunction;\n}\n\nexport interface IEntryAnimationBuilder {\n build: () => AnimationConfigFunction<EntryAnimationsValues>;\n}\n\nexport interface IExitAnimationBuilder {\n build: () => AnimationConfigFunction<ExitAnimationsValues>;\n}\n\nexport type ProgressAnimationCallback = (\n viewTag: number,\n progress: number\n) => void;\n\nexport type ProgressAnimation = (\n viewTag: number,\n values: SharedTransitionAnimationsValues,\n progress: number\n) => void;\n\nexport type CustomProgressAnimation = (\n values: SharedTransitionAnimationsValues,\n progress: number\n) => StyleProps;\n\nexport enum SharedTransitionType {\n ANIMATION = 'animation',\n PROGRESS_ANIMATION = 'progressAnimation',\n}\n\nexport type EntryExitAnimationsValues =\n | EntryAnimationsValues\n | ExitAnimationsValues;\n"],"mappings":"AAcoE;;AA2DpE,WAAYA,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;AAyE/B,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BaseAnimationBuilder","Easing","withTiming","CurvedTransition","constructor","arguments","_defineProperty","in","ease","out","exp","delayFunction","getDelayFunction","callback","callbackV","delay","getDelay","duration","durationV","easing","easingX","easingXV","easingY","easingYV","easingWidth","easingWidthV","easingHeight","easingHeightV","values","initialValues","originX","currentOriginX","originY","currentOriginY","width","currentWidth","height","currentHeight","animations","targetOriginX","targetOriginY","targetWidth","targetHeight","createInstance","instance"],"sources":["CurvedTransition.ts"],"sourcesContent":["import type {\n ILayoutAnimationBuilder,\n LayoutAnimationFunction,\n} from '../animationBuilder/commonTypes';\nimport { BaseAnimationBuilder } from '../animationBuilder';\nimport type {
|
|
1
|
+
{"version":3,"names":["BaseAnimationBuilder","Easing","withTiming","CurvedTransition","constructor","arguments","_defineProperty","in","ease","out","exp","delayFunction","getDelayFunction","callback","callbackV","delay","getDelay","duration","durationV","easing","easingX","easingXV","easingY","easingYV","easingWidth","easingWidthV","easingHeight","easingHeightV","values","initialValues","originX","currentOriginX","originY","currentOriginY","width","currentWidth","height","currentHeight","animations","targetOriginX","targetOriginY","targetWidth","targetHeight","createInstance","instance"],"sources":["CurvedTransition.ts"],"sourcesContent":["import type {\n ILayoutAnimationBuilder,\n LayoutAnimationFunction,\n} from '../animationBuilder/commonTypes';\nimport { BaseAnimationBuilder } from '../animationBuilder';\nimport type { EasingFunction } from '../../Easing';\nimport { Easing } from '../../Easing';\nimport { withTiming } from '../../animation';\n\nexport class CurvedTransition\n extends BaseAnimationBuilder\n implements ILayoutAnimationBuilder\n{\n easingXV: EasingFunction = Easing.in(Easing.ease);\n easingYV: EasingFunction = Easing.out(Easing.ease);\n easingWidthV: EasingFunction = Easing.in(Easing.exp);\n easingHeightV: EasingFunction = Easing.out(Easing.exp);\n\n static createInstance<T extends typeof BaseAnimationBuilder>(\n this: T\n ): InstanceType<T> {\n return new CurvedTransition() as InstanceType<T>;\n }\n\n static easingX(easing: EasingFunction): CurvedTransition {\n const instance = this.createInstance();\n return instance.easingX(easing);\n }\n\n easingX(easing: EasingFunction): CurvedTransition {\n this.easingXV = easing;\n return this;\n }\n\n static easingY(easing: EasingFunction): CurvedTransition {\n const instance = this.createInstance();\n return instance.easingY(easing);\n }\n\n easingY(easing: EasingFunction): CurvedTransition {\n this.easingYV = easing;\n return this;\n }\n\n static easingWidth(easing: EasingFunction): CurvedTransition {\n const instance = this.createInstance();\n return instance.easingWidth(easing);\n }\n\n easingWidth(easing: EasingFunction): CurvedTransition {\n this.easingWidthV = easing;\n return this;\n }\n\n static easingHeight(easing: EasingFunction): CurvedTransition {\n const instance = this.createInstance();\n return instance.easingHeight(easing);\n }\n\n easingHeight(easing: EasingFunction): CurvedTransition {\n this.easingHeightV = easing;\n return this;\n }\n\n build = (): LayoutAnimationFunction => {\n const delayFunction = this.getDelayFunction();\n const callback = this.callbackV;\n const delay = this.getDelay();\n const duration = this.durationV ?? 300;\n const easing = {\n easingX: this.easingXV,\n easingY: this.easingYV,\n easingWidth: this.easingWidthV,\n easingHeight: this.easingHeightV,\n };\n\n return (values) => {\n 'worklet';\n\n return {\n initialValues: {\n originX: values.currentOriginX,\n originY: values.currentOriginY,\n width: values.currentWidth,\n height: values.currentHeight,\n },\n animations: {\n originX: delayFunction(\n delay,\n withTiming(values.targetOriginX, {\n duration,\n easing: easing.easingX,\n })\n ),\n originY: delayFunction(\n delay,\n withTiming(values.targetOriginY, {\n duration,\n easing: easing.easingY,\n })\n ),\n width: delayFunction(\n delay,\n withTiming(values.targetWidth, {\n duration,\n easing: easing.easingWidth,\n })\n ),\n height: delayFunction(\n delay,\n withTiming(values.targetHeight, {\n duration,\n easing: easing.easingHeight,\n })\n ),\n },\n callback: callback,\n };\n };\n };\n}\n"],"mappings":";;;AAIA,SAASA,oBAAoB,QAAQ,qBAAqB;AAE1D,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,MAAMC,gBAAgB,SACnBH,oBAAoB,CAE9B;EAAAI,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA,mBAC6BL,MAAM,CAACM,EAAE,CAACN,MAAM,CAACO,IAAI,CAAC;IAAAF,eAAA,mBACtBL,MAAM,CAACQ,GAAG,CAACR,MAAM,CAACO,IAAI,CAAC;IAAAF,eAAA,uBACnBL,MAAM,CAACM,EAAE,CAACN,MAAM,CAACS,GAAG,CAAC;IAAAJ,eAAA,wBACpBL,MAAM,CAACQ,GAAG,CAACR,MAAM,CAACS,GAAG,CAAC;IAAAJ,eAAA,gBAgD9C,MAA+B;MACrC,MAAMK,aAAa,GAAG,IAAI,CAACC,gBAAgB,EAAE;MAC7C,MAAMC,QAAQ,GAAG,IAAI,CAACC,SAAS;MAC/B,MAAMC,KAAK,GAAG,IAAI,CAACC,QAAQ,EAAE;MAC7B,MAAMC,QAAQ,GAAG,IAAI,CAACC,SAAS,IAAI,GAAG;MACtC,MAAMC,MAAM,GAAG;QACbC,OAAO,EAAE,IAAI,CAACC,QAAQ;QACtBC,OAAO,EAAE,IAAI,CAACC,QAAQ;QACtBC,WAAW,EAAE,IAAI,CAACC,YAAY;QAC9BC,YAAY,EAAE,IAAI,CAACC;MACrB,CAAC;MAED,OAAQC,MAAM,IAAK;QACjB,SAAS;;QAET,OAAO;UACLC,aAAa,EAAE;YACbC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,MAAMyB,QAAQ,GAAG,IAAI,CAACD,cAAc,EAAE;IACtC,OAAOC,QAAQ,CAACtB,OAAO,CAACH,MAAM,CAAC;EACjC;EAEAG,OAAOA,CAACH,MAAsB,EAAoB;IAChD,IAAI,CAACI,QAAQ,GAAGJ,MAAM;IACtB,OAAO,IAAI;EACb;EAEA,OAAOK,WAAWA,CAACL,MAAsB,EAAoB;IAC3D,MAAMyB,QAAQ,GAAG,IAAI,CAACD,cAAc,EAAE;IACtC,OAAOC,QAAQ,CAACpB,WAAW,CAACL,MAAM,CAAC;EACrC;EAEAK,WAAWA,CAACL,MAAsB,EAAoB;IACpD,IAAI,CAACM,YAAY,GAAGN,MAAM;IAC1B,OAAO,IAAI;EACb;EAEA,OAAOO,YAAYA,CAACP,MAAsB,EAAoB;IAC5D,MAAMyB,QAAQ,GAAG,IAAI,CAACD,cAAc,EAAE;IACtC,OAAOC,QAAQ,CAAClB,YAAY,CAACP,MAAM,CAAC;EACtC;EAEAO,YAAYA,CAACP,MAAsB,EAAoB;IACrD,IAAI,CAACQ,aAAa,GAAGR,MAAM;IAC3B,OAAO,IAAI;EACb;AA0DF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './animationsManager';\nexport * from './animationBuilder';\nexport * from './defaultAnimations';\nexport * from './defaultTransitions';\nexport * from './sharedTransitions';\n"],"mappings":"AAAA,OAAO,qBAAqB;AAC5B,cAAc,oBAAoB;AAClC,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,qBAAqB"}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './animationsManager';\nexport * from './animationBuilder';\nexport * from './defaultAnimations';\nexport * from './defaultTransitions';\nexport * from './sharedTransitions';\nexport type { KeyframeProps } from './animationBuilder/commonTypes';\n"],"mappings":"AAAA,OAAO,qBAAqB;AAC5B,cAAc,oBAAoB;AAClC,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,qBAAqB"}
|
|
@@ -2,7 +2,7 @@ import { isJest } from './PlatformChecker';
|
|
|
2
2
|
import { runOnUI } from './threads';
|
|
3
3
|
import { isSharedValue } from './utils';
|
|
4
4
|
const IS_JEST = isJest();
|
|
5
|
-
|
|
5
|
+
function createMapperRegistry() {
|
|
6
6
|
'worklet';
|
|
7
7
|
|
|
8
8
|
const mappers = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isJest","runOnUI","isSharedValue","IS_JEST","createMapperRegistry","mappers","Map","sortedMappers","runRequested","processingMappers","updateMappersOrder","pre","forEach","mapper","outputs","output","preMappers","get","undefined","set","push","visited","Set","newOrder","dfs","add","input","inputs","preMapper","has","mapperRun","size","length","dirty","worklet","maybeRequestUpdates","requestAnimationFrame","queueMicrotask","extractInputs","resultArray","Array","isArray","Object","getPrototypeOf","prototype","element","values","start","mapperID","id","sv","addListener","stop","delete","removeListener","MAPPER_ID","startMapper","arguments","mapperRegistry","global","__mapperRegistry","stopMapper"],"sources":["mappers.ts"],"sourcesContent":["import type { SharedValue } from './commonTypes';\nimport { isJest } from './PlatformChecker';\nimport { runOnUI } from './threads';\nimport { isSharedValue } from './utils';\n\nconst IS_JEST = isJest();\n\nexport type Mapper = {\n id: number;\n dirty: boolean;\n worklet: () => void;\n inputs: SharedValue<any>[];\n outputs?: SharedValue<any>[];\n};\n\nexport function createMapperRegistry() {\n 'worklet';\n const mappers = new Map();\n let sortedMappers: Mapper[] = [];\n\n let runRequested = false;\n let processingMappers = false;\n\n function updateMappersOrder() {\n // sort mappers topologically\n // the algorithm here takes adventage of a fact that the topological order\n // of a transposed graph is a reverse topological order of the original graph\n // The graph in our case consists of mappers and an edge between two mappers\n // A and B exists if there is a shared value that's on A's output lists and on\n // B's input list.\n //\n // We don't need however to calculate that graph as it is easier to work with\n // the transposed version of it that can be calculated ad-hoc. For the transposed\n // version to be traversed we use \"pre\" map that maps share value to mappers that\n // output that shared value. Then we can infer all the outgoing edges for a given\n // mapper simply by scanning it's input list and checking if any of the shared values\n // from that list exists in the \"pre\" map. If they do, then we have an edge between\n // that mapper and the mappers from the \"pre\" list for the given shared value.\n //\n // For topological sorting we use a dfs-based approach that requires the graph to\n // be traversed in dfs order and each node after being processed lands at the\n // beginning of the topological order list. Since we traverse a transposed graph,\n // instead of reversing that order we can use a normal array and push processed\n // mappers to the end. There is no need to reverse that array after we are done.\n const pre = new Map(); // map from sv -> mapper that outputs that sv\n mappers.forEach((mapper) => {\n if (mapper.outputs) {\n for (const output of mapper.outputs) {\n const preMappers = pre.get(output);\n if (preMappers === undefined) {\n pre.set(output, [mapper]);\n } else {\n preMappers.push(mapper);\n }\n }\n }\n });\n const visited = new Set();\n const newOrder: Mapper[] = [];\n function dfs(mapper: Mapper) {\n visited.add(mapper);\n for (const input of mapper.inputs) {\n const preMappers = pre.get(input);\n if (preMappers) {\n for (const preMapper of preMappers) {\n if (!visited.has(preMapper)) {\n dfs(preMapper);\n }\n }\n }\n }\n newOrder.push(mapper);\n }\n mappers.forEach((mapper) => {\n if (!visited.has(mapper)) {\n dfs(mapper);\n }\n });\n sortedMappers = newOrder;\n }\n\n function mapperRun() {\n runRequested = false;\n if (processingMappers) {\n return;\n }\n processingMappers = true;\n if (mappers.size !== sortedMappers.length) {\n updateMappersOrder();\n }\n for (const mapper of sortedMappers) {\n if (mapper.dirty) {\n mapper.dirty = false;\n mapper.worklet();\n }\n }\n processingMappers = false;\n }\n\n function maybeRequestUpdates() {\n if (IS_JEST) {\n // On Jest environment we avoid using queueMicrotask as that'd require test\n // to advance the clock manually. This on other hand would require tests\n // to know how many times mappers need to run. As we don't want tests to\n // make any assumptions on that number it is easier to execute mappers\n // immediately for testing purposes and only expect test to advance timers\n // if they want to make any assertions on the effects of animations being run.\n mapperRun();\n } else if (!runRequested) {\n if (processingMappers) {\n // In general, we should avoid having mappers trigger updates as this may\n // result in unpredictable behavior. Specifically, the updated value can\n // be read by mappers that run later in the same frame but previous mappers\n // would access the old value. Updating mappers during the mapper-run phase\n // breaks the order in which we should execute the mappers. However, doing\n // that is still a possibility and there are some instances where people use\n // the API in that way, hence we need to prevent mapper-run phase falling into\n // an infinite loop. We do that by detecting when mapper-run is requested while\n // we are already in mapper-run phase, and in that case we use `requestAnimationFrame`\n // instead of `queueMicrotask` which will schedule mapper run for the next\n // frame instead of queuing another set of updates in the same frame.\n requestAnimationFrame(mapperRun);\n } else {\n queueMicrotask(mapperRun);\n }\n runRequested = true;\n }\n }\n\n function extractInputs(\n inputs: any,\n resultArray: SharedValue<any>[]\n ): SharedValue<any>[] {\n if (Array.isArray(inputs)) {\n for (const input of inputs) {\n input && extractInputs(input, resultArray);\n }\n } else if (isSharedValue(inputs)) {\n resultArray.push(inputs);\n } else if (Object.getPrototypeOf(inputs) === Object.prototype) {\n // we only extract inputs recursively from \"plain\" objects here, if object\n // is of a derivative class (e.g. HostObject on web, or Map) we don't scan\n // it recursively\n for (const element of Object.values(inputs)) {\n element && extractInputs(element, resultArray);\n }\n }\n return resultArray;\n }\n\n return {\n start: (\n mapperID: number,\n worklet: () => void,\n inputs: SharedValue<any>[],\n outputs?: SharedValue<any>[]\n ) => {\n const mapper = {\n id: mapperID,\n dirty: true,\n worklet,\n inputs: extractInputs(inputs, []),\n outputs,\n };\n mappers.set(mapper.id, mapper);\n sortedMappers = [];\n for (const sv of mapper.inputs) {\n sv.addListener(mapper.id, () => {\n mapper.dirty = true;\n maybeRequestUpdates();\n });\n }\n maybeRequestUpdates();\n },\n stop: (mapperID: number) => {\n const mapper = mappers.get(mapperID);\n if (mapper) {\n mappers.delete(mapper.id);\n sortedMappers = [];\n for (const sv of mapper.inputs) {\n sv.removeListener(mapper.id);\n }\n }\n },\n };\n}\n\nlet MAPPER_ID = 9999;\n\nexport function startMapper(\n worklet: () => void,\n inputs: any[] = [],\n outputs: any[] = []\n): number {\n const mapperID = (MAPPER_ID += 1);\n\n runOnUI(() => {\n let mapperRegistry = global.__mapperRegistry;\n if (mapperRegistry === undefined) {\n mapperRegistry = global.__mapperRegistry = createMapperRegistry();\n }\n mapperRegistry.start(mapperID, worklet, inputs, outputs);\n })();\n\n return mapperID;\n}\n\nexport function stopMapper(mapperID: number): void {\n runOnUI(() => {\n const mapperRegistry = global.__mapperRegistry;\n mapperRegistry?.stop(mapperID);\n })();\n}\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,aAAa,QAAQ,SAAS;AAEvC,MAAMC,OAAO,GAAGH,MAAM,EAAE;AAUxB,OAAO,SAASI,oBAAoBA,CAAA,EAAG;EACrC,SAAS;;EACT,MAAMC,OAAO,GAAG,IAAIC,GAAG,EAAE;EACzB,IAAIC,aAAuB,GAAG,EAAE;EAEhC,IAAIC,YAAY,GAAG,KAAK;EACxB,IAAIC,iBAAiB,GAAG,KAAK;EAE7B,SAASC,kBAAkBA,CAAA,EAAG;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,MAAMC,GAAG,GAAG,IAAIL,GAAG,EAAE,CAAC,CAAC;IACvBD,OAAO,CAACO,OAAO,CAAEC,MAAM,IAAK;MAC1B,IAAIA,MAAM,CAACC,OAAO,EAAE;QAClB,KAAK,MAAMC,MAAM,IAAIF,MAAM,CAACC,OAAO,EAAE;UACnC,MAAME,UAAU,GAAGL,GAAG,CAACM,GAAG,CAACF,MAAM,CAAC;UAClC,IAAIC,UAAU,KAAKE,SAAS,EAAE;YAC5BP,GAAG,CAACQ,GAAG,CAACJ,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;UAC3B,CAAC,MAAM;YACLG,UAAU,CAACI,IAAI,CAACP,MAAM,CAAC;UACzB;QACF;MACF;IACF,CAAC,CAAC;IACF,MAAMQ,OAAO,GAAG,IAAIC,GAAG,EAAE;IACzB,MAAMC,QAAkB,GAAG,EAAE;IAC7B,SAASC,GAAG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ACZ,MAAMyD,cAAc,GAAGC,MAAM,CAACC,gBAAgB;IAC9CF,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEN,IAAI,CAACJ,QAAQ,CAAC;EAChC,CAAC,CAAC,EAAE;AACN"}
|
|
1
|
+
{"version":3,"names":["isJest","runOnUI","isSharedValue","IS_JEST","createMapperRegistry","mappers","Map","sortedMappers","runRequested","processingMappers","updateMappersOrder","pre","forEach","mapper","outputs","output","preMappers","get","undefined","set","push","visited","Set","newOrder","dfs","add","input","inputs","preMapper","has","mapperRun","size","length","dirty","worklet","maybeRequestUpdates","requestAnimationFrame","queueMicrotask","extractInputs","resultArray","Array","isArray","Object","getPrototypeOf","prototype","element","values","start","mapperID","id","sv","addListener","stop","delete","removeListener","MAPPER_ID","startMapper","arguments","mapperRegistry","global","__mapperRegistry","stopMapper"],"sources":["mappers.ts"],"sourcesContent":["import type { SharedValue } from './commonTypes';\nimport { isJest } from './PlatformChecker';\nimport { runOnUI } from './threads';\nimport { isSharedValue } from './utils';\n\nconst IS_JEST = isJest();\n\ntype Mapper = {\n id: number;\n dirty: boolean;\n worklet: () => void;\n inputs: SharedValue<any>[];\n outputs?: SharedValue<any>[];\n};\n\nfunction createMapperRegistry() {\n 'worklet';\n const mappers = new Map();\n let sortedMappers: Mapper[] = [];\n\n let runRequested = false;\n let processingMappers = false;\n\n function updateMappersOrder() {\n // sort mappers topologically\n // the algorithm here takes adventage of a fact that the topological order\n // of a transposed graph is a reverse topological order of the original graph\n // The graph in our case consists of mappers and an edge between two mappers\n // A and B exists if there is a shared value that's on A's output lists and on\n // B's input list.\n //\n // We don't need however to calculate that graph as it is easier to work with\n // the transposed version of it that can be calculated ad-hoc. For the transposed\n // version to be traversed we use \"pre\" map that maps share value to mappers that\n // output that shared value. Then we can infer all the outgoing edges for a given\n // mapper simply by scanning it's input list and checking if any of the shared values\n // from that list exists in the \"pre\" map. If they do, then we have an edge between\n // that mapper and the mappers from the \"pre\" list for the given shared value.\n //\n // For topological sorting we use a dfs-based approach that requires the graph to\n // be traversed in dfs order and each node after being processed lands at the\n // beginning of the topological order list. Since we traverse a transposed graph,\n // instead of reversing that order we can use a normal array and push processed\n // mappers to the end. There is no need to reverse that array after we are done.\n const pre = new Map(); // map from sv -> mapper that outputs that sv\n mappers.forEach((mapper) => {\n if (mapper.outputs) {\n for (const output of mapper.outputs) {\n const preMappers = pre.get(output);\n if (preMappers === undefined) {\n pre.set(output, [mapper]);\n } else {\n preMappers.push(mapper);\n }\n }\n }\n });\n const visited = new Set();\n const newOrder: Mapper[] = [];\n function dfs(mapper: Mapper) {\n visited.add(mapper);\n for (const input of mapper.inputs) {\n const preMappers = pre.get(input);\n if (preMappers) {\n for (const preMapper of preMappers) {\n if (!visited.has(preMapper)) {\n dfs(preMapper);\n }\n }\n }\n }\n newOrder.push(mapper);\n }\n mappers.forEach((mapper) => {\n if (!visited.has(mapper)) {\n dfs(mapper);\n }\n });\n sortedMappers = newOrder;\n }\n\n function mapperRun() {\n runRequested = false;\n if (processingMappers) {\n return;\n }\n processingMappers = true;\n if (mappers.size !== sortedMappers.length) {\n updateMappersOrder();\n }\n for (const mapper of sortedMappers) {\n if (mapper.dirty) {\n mapper.dirty = false;\n mapper.worklet();\n }\n }\n processingMappers = false;\n }\n\n function maybeRequestUpdates() {\n if (IS_JEST) {\n // On Jest environment we avoid using queueMicrotask as that'd require test\n // to advance the clock manually. This on other hand would require tests\n // to know how many times mappers need to run. As we don't want tests to\n // make any assumptions on that number it is easier to execute mappers\n // immediately for testing purposes and only expect test to advance timers\n // if they want to make any assertions on the effects of animations being run.\n mapperRun();\n } else if (!runRequested) {\n if (processingMappers) {\n // In general, we should avoid having mappers trigger updates as this may\n // result in unpredictable behavior. Specifically, the updated value can\n // be read by mappers that run later in the same frame but previous mappers\n // would access the old value. Updating mappers during the mapper-run phase\n // breaks the order in which we should execute the mappers. However, doing\n // that is still a possibility and there are some instances where people use\n // the API in that way, hence we need to prevent mapper-run phase falling into\n // an infinite loop. We do that by detecting when mapper-run is requested while\n // we are already in mapper-run phase, and in that case we use `requestAnimationFrame`\n // instead of `queueMicrotask` which will schedule mapper run for the next\n // frame instead of queuing another set of updates in the same frame.\n requestAnimationFrame(mapperRun);\n } else {\n queueMicrotask(mapperRun);\n }\n runRequested = true;\n }\n }\n\n function extractInputs(\n inputs: any,\n resultArray: SharedValue<any>[]\n ): SharedValue<any>[] {\n if (Array.isArray(inputs)) {\n for (const input of inputs) {\n input && extractInputs(input, resultArray);\n }\n } else if (isSharedValue(inputs)) {\n resultArray.push(inputs);\n } else if (Object.getPrototypeOf(inputs) === Object.prototype) {\n // we only extract inputs recursively from \"plain\" objects here, if object\n // is of a derivative class (e.g. HostObject on web, or Map) we don't scan\n // it recursively\n for (const element of Object.values(inputs)) {\n element && extractInputs(element, resultArray);\n }\n }\n return resultArray;\n }\n\n return {\n start: (\n mapperID: number,\n worklet: () => void,\n inputs: SharedValue<any>[],\n outputs?: SharedValue<any>[]\n ) => {\n const mapper = {\n id: mapperID,\n dirty: true,\n worklet,\n inputs: extractInputs(inputs, []),\n outputs,\n };\n mappers.set(mapper.id, mapper);\n sortedMappers = [];\n for (const sv of mapper.inputs) {\n sv.addListener(mapper.id, () => {\n mapper.dirty = true;\n maybeRequestUpdates();\n });\n }\n maybeRequestUpdates();\n },\n stop: (mapperID: number) => {\n const mapper = mappers.get(mapperID);\n if (mapper) {\n mappers.delete(mapper.id);\n sortedMappers = [];\n for (const sv of mapper.inputs) {\n sv.removeListener(mapper.id);\n }\n }\n },\n };\n}\n\nlet MAPPER_ID = 9999;\n\nexport function startMapper(\n worklet: () => void,\n inputs: any[] = [],\n outputs: any[] = []\n): number {\n const mapperID = (MAPPER_ID += 1);\n\n runOnUI(() => {\n let mapperRegistry = global.__mapperRegistry;\n if (mapperRegistry === undefined) {\n mapperRegistry = global.__mapperRegistry = createMapperRegistry();\n }\n mapperRegistry.start(mapperID, worklet, inputs, outputs);\n })();\n\n return mapperID;\n}\n\nexport function stopMapper(mapperID: number): void {\n runOnUI(() => {\n const mapperRegistry = global.__mapperRegistry;\n mapperRegistry?.stop(mapperID);\n })();\n}\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,aAAa,QAAQ,SAAS;AAEvC,MAAMC,OAAO,GAAGH,MAAM,EAAE;AAUxB,SAASI,oBAAoBA,CAAA,EAAG;EAC9B,SAAS;;EACT,MAAMC,OAAO,GAAG,IAAIC,GAAG,EAAE;EACzB,IAAIC,aAAuB,GAAG,EAAE;EAEhC,IAAIC,YAAY,GAAG,KAAK;EACxB,IAAIC,iBAAiB,GAAG,KAAK;EAE7B,SAASC,kBAAkBA,CAAA,EAAG;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,MAAMC,GAAG,GAAG,IAAIL,GAAG,EAAE,CAAC,CAAC;IACvBD,OAAO,CAACO,OAAO,CAAEC,MAAM,IAAK;MAC1B,IAAIA,MAAM,CAACC,OAAO,EAAE;QAClB,KAAK,MAAMC,MAAM,IAAIF,MAAM,CAACC,OAAO,EAAE;UACnC,MAAME,UAAU,GAAGL,GAAG,CAACM,GAAG,CAACF,MAAM,CAAC;UAClC,IAAIC,UAAU,KAAKE,SAAS,EAAE;YAC5BP,GAAG,CAACQ,GAAG,CAACJ,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;UAC3B,CAAC,MAAM;YACLG,UAAU,CAACI,IAAI,CAACP,MAAM,CAAC;UACzB;QACF;MACF;IACF,CAAC,CAAC;IACF,MAAMQ,OAAO,GAAG,IAAIC,GAAG,EAAE;IACzB,MAAMC,QAAkB,GAAG,EAAE;IAC7B,SAASC,GAAGA,CAACX,MAAc,EAAE;MAC3BQ,OAAO,CAACI,GAAG,CAACZ,MAAM,CAAC;MACnB,KAAK,MAAMa,KAAK,IAAIb,MAAM,CAACc,MAAM,EAAE;QACjC,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AAC,CAAC,EAAE;AACN"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable node/no-callback-literal */
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
3
|
// @ts-nocheck
|
|
4
|
+
import { SensorType } from './commonTypes';
|
|
4
5
|
const NOOP = () => {
|
|
5
6
|
// noop
|
|
6
7
|
};
|
|
@@ -53,6 +54,31 @@ const ReanimatedV2 = {
|
|
|
53
54
|
}),
|
|
54
55
|
useAnimatedReaction: NOOP,
|
|
55
56
|
useAnimatedProps: IMMEDIATE_CB_INVOCATION,
|
|
57
|
+
SensorType: SensorType,
|
|
58
|
+
useAnimatedSensor: () => ({
|
|
59
|
+
sensor: {
|
|
60
|
+
value: {
|
|
61
|
+
x: 0,
|
|
62
|
+
y: 0,
|
|
63
|
+
z: 0,
|
|
64
|
+
interfaceOrientation: 0,
|
|
65
|
+
qw: 0,
|
|
66
|
+
qx: 0,
|
|
67
|
+
qy: 0,
|
|
68
|
+
qz: 0,
|
|
69
|
+
yaw: 0,
|
|
70
|
+
pitch: 0,
|
|
71
|
+
roll: 0
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
unregister: NOOP,
|
|
75
|
+
isAvailable: false,
|
|
76
|
+
config: {
|
|
77
|
+
interval: 0,
|
|
78
|
+
adjustToInterfaceOrientation: false,
|
|
79
|
+
iosReferenceFrame: 0
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
56
82
|
withTiming: (toValue, _, cb) => {
|
|
57
83
|
cb && cb(true);
|
|
58
84
|
return toValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","ID","t","IMMEDIATE_CB_INVOCATION","cb","BaseAnimationMock","duration","_","delay","springify","damping","stiffness","withCallback","randomDelay","withInitialValues","build","initialValues","animations","ReanimatedV2","useSharedValue","v","value","useDerivedValue","a","useAnimatedScrollHandler","useAnimatedGestureHandler","useAnimatedStyle","useAnimatedRef","current","useAnimatedReaction","useAnimatedProps","withTiming","toValue","withSpring","withDecay","withDelay","animationValue","withSequence","withRepeat","animation","cancelAnimation","measure","
|
|
1
|
+
{"version":3,"names":["SensorType","NOOP","ID","t","IMMEDIATE_CB_INVOCATION","cb","BaseAnimationMock","duration","_","delay","springify","damping","stiffness","withCallback","randomDelay","withInitialValues","build","initialValues","animations","ReanimatedV2","useSharedValue","v","value","useDerivedValue","a","useAnimatedScrollHandler","useAnimatedGestureHandler","useAnimatedStyle","useAnimatedRef","current","useAnimatedReaction","useAnimatedProps","useAnimatedSensor","sensor","x","y","z","interfaceOrientation","qw","qx","qy","qz","yaw","pitch","roll","unregister","isAvailable","config","interval","adjustToInterfaceOrientation","iosReferenceFrame","withTiming","toValue","withSpring","withDecay","withDelay","animationValue","withSequence","withRepeat","animation","cancelAnimation","measure","width","height","pageX","pageY","Easing","linear","ease","quad","cubic","poly","sin","circle","exp","elastic","back","bounce","bezier","factory","bezierFn","steps","in","out","inOut","Extrapolation","EXTEND","CLAMP","IDENTITY","runOnJS","fn","runOnUI","forEach","k","Object","assign","module","exports"],"sources":["mock.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport { SensorType } from './commonTypes';\n\nconst NOOP = () => {\n // noop\n};\nconst ID = (t) => t;\nconst IMMEDIATE_CB_INVOCATION = (cb: () => unknown) => cb();\n\nclass BaseAnimationMock {\n duration(_: number) {\n return this;\n }\n\n delay(_: number) {\n return this;\n }\n\n springify(_: number) {\n return this;\n }\n\n damping(_: number) {\n return this;\n }\n\n stiffness(_: number) {\n return this;\n }\n\n withCallback(_: (finished: boolean) => void) {\n return this;\n }\n\n randomDelay() {\n return this;\n }\n\n withInitialValues() {\n return this;\n }\n\n build() {\n return () => ({ initialValues: {}, animations: {} });\n }\n}\n\nconst ReanimatedV2 = {\n useSharedValue: (v) => ({ value: v }),\n useDerivedValue: (a) => ({ value: a() }),\n useAnimatedScrollHandler: () => NOOP,\n useAnimatedGestureHandler: () => NOOP,\n useAnimatedStyle: IMMEDIATE_CB_INVOCATION,\n useAnimatedRef: () => ({ current: null }),\n useAnimatedReaction: NOOP,\n useAnimatedProps: IMMEDIATE_CB_INVOCATION,\n SensorType: SensorType,\n useAnimatedSensor: () => ({\n sensor: {\n value: {\n x: 0,\n y: 0,\n z: 0,\n interfaceOrientation: 0,\n qw: 0,\n qx: 0,\n qy: 0,\n qz: 0,\n yaw: 0,\n pitch: 0,\n roll: 0,\n },\n },\n unregister: NOOP,\n isAvailable: false,\n config: {\n interval: 0,\n adjustToInterfaceOrientation: false,\n iosReferenceFrame: 0,\n },\n }),\n\n withTiming: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withSpring: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withDecay: (_, cb) => {\n cb && cb(true);\n return 0;\n },\n withDelay: (_, animationValue) => {\n return animationValue;\n },\n withSequence: (..._animations) => {\n return 0;\n },\n withRepeat: (animation) => {\n return animation;\n },\n cancelAnimation: NOOP,\n measure: () => ({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n pageX: 0,\n pageY: 0,\n }),\n Easing: {\n linear: ID,\n ease: ID,\n quad: ID,\n cubic: ID,\n poly: ID,\n sin: ID,\n circle: ID,\n exp: ID,\n elastic: ID,\n back: ID,\n bounce: ID,\n bezier: () => ({ factory: ID }),\n bezierFn: ID,\n steps: ID,\n in: ID,\n out: ID,\n inOut: ID,\n },\n Extrapolation: {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n },\n\n runOnJS: (fn) => fn,\n runOnUI: (fn) => fn,\n};\n\n[\n 'FadeIn',\n 'FadeInRight',\n 'FadeInLeft',\n 'FadeInUp',\n 'FadeInDown',\n 'FadeOut',\n 'FadeOutRight',\n 'FadeOutLeft',\n 'FadeOutUp',\n 'FadeOutDown',\n\n 'FlipInYLeft',\n 'FlipInXDown',\n 'FlipInYRight',\n 'FlipInEasyX',\n 'FlipInEasyY',\n 'FlipOutXUp',\n 'FlipOutYLeft',\n 'FlipOutXDown',\n 'FlipOutYRight',\n 'FlipOutEasyX',\n 'FlipOutEasyY',\n\n 'StretchInY',\n 'StretchOutX',\n 'StretchOutY',\n 'SlideInLeft',\n 'SlideOutRight',\n 'SlideOutLeft',\n 'SlideInUp',\n 'SlideInDown',\n 'SlideOutUp',\n\n 'ZoomInRotate',\n 'ZoomInLeft',\n 'ZoomInRight',\n 'ZoomInUp',\n 'ZoomInDown',\n 'ZoomInEasyUp',\n 'ZoomInEasyDown',\n 'ZoomOut',\n 'ZoomOutRotate',\n 'ZoomOutLeft',\n 'ZoomOutRight',\n 'ZoomOutUp',\n 'ZoomOutDown',\n 'ZoomOutEasyUp',\n 'ZoomOutEasyDown',\n\n 'BounceIn',\n 'BounceInDown',\n 'BounceInUp',\n 'BounceInLeft',\n 'BounceInRight',\n 'BounceOut',\n 'BounceOutDown',\n 'BounceOutUp',\n 'BounceOutLeft',\n 'BounceOutRight',\n\n 'LightSpeedInLeft',\n 'LightSpeedOutRight',\n 'LightSpeedOutLeft',\n\n 'PinwheelOut',\n\n 'RotateInDownRight',\n 'RotateInUpLeft',\n 'RotateInUpRight',\n 'RotateOutDownLeft',\n 'RotateOutDownRight',\n 'RotateOutUpLeft',\n 'RotateOutUpRight',\n\n 'RollInRight',\n 'RollOutLeft',\n 'RollOutRight',\n\n 'Layout',\n 'CurvedTransition',\n 'JumpingTransition',\n 'SequencedTransition',\n 'FadingTransition',\n 'EntryExitTransition',\n].forEach((k) =>\n Object.assign(ReanimatedV2, {\n [k]: new BaseAnimationMock(),\n })\n);\n\nmodule.exports = {\n ...ReanimatedV2,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,eAAe;AAE1C,MAAMC,IAAI,GAAGA,CAAA,KAAM;EACjB;AAAA,CACD;AACD,MAAMC,EAAE,GAAIC,CAAC,IAAKA,CAAC;AACnB,MAAMC,uBAAuB,GAAIC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c,EACd,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,EACb,eAAe,EACf,gBAAgB,EAEhB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EAEnB,aAAa,EAEb,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAElB,aAAa,EACb,aAAa,EACb,cAAc,EAEd,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,CACtB,CAACE,OAAO,CAAEC,CAAC,IACVC,MAAM,CAACC,MAAM,CAAC5E,YAAY,EAAE;EAC1B,CAAC0E,CAAC,GAAG,IAAIvF,iBAAiB;AAC5B,CAAC,CAAC,CACH;AAED0F,MAAM,CAACC,OAAO,GAAG;EACf,GAAG9E;AACL,CAAC"}
|
|
@@ -2,7 +2,6 @@ import NativeReanimatedModule from './NativeReanimated';
|
|
|
2
2
|
import { makeShareableCloneOnUIRecursive, makeShareableCloneRecursive, registerShareableMapping } from './shareables';
|
|
3
3
|
import { runOnUI } from './threads';
|
|
4
4
|
import { valueSetter } from './valueSetter';
|
|
5
|
-
export { stopMapper } from './mappers';
|
|
6
5
|
export function makeUIMutable(initial, syncDataHolder) {
|
|
7
6
|
'worklet';
|
|
8
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeReanimatedModule","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","registerShareableMapping","runOnUI","valueSetter","
|
|
1
|
+
{"version":3,"names":["NativeReanimatedModule","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","registerShareableMapping","runOnUI","valueSetter","makeUIMutable","initial","syncDataHolder","listeners","Map","value","self","newValue","_value","_updateDataSynchronously","forEach","listener","addListener","id","set","removeListener","delete","_animation","_isReanimatedSharedValue","makeMutable","oneWayReadsOnly","arguments","length","undefined","native","makeSynchronizedDataHolder","handle","__init","mutable","getDataSynchronously","Error","modify","modifier","makeRemote"],"sources":["mutables.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport type { SharedValue, ShareableSyncDataHolderRef } from './commonTypes';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n registerShareableMapping,\n} from './shareables';\nimport { runOnUI } from './threads';\nimport { valueSetter } from './valueSetter';\n\nexport function makeUIMutable<T>(\n initial: T,\n syncDataHolder?: ShareableSyncDataHolderRef<T>\n) {\n 'worklet';\n\n const listeners = new Map();\n let value = initial;\n\n const self = {\n set value(newValue) {\n valueSetter(self, newValue);\n },\n get value() {\n return value;\n },\n /**\n * _value prop should only be accessed by the valueSetter implementation\n * which may make the decision about updating the mutable value depending\n * on the provided new value. All other places should only attempt to modify\n * the mutable by assigning to value prop directly.\n */\n set _value(newValue: T) {\n value = newValue;\n if (syncDataHolder) {\n _updateDataSynchronously(\n syncDataHolder,\n makeShareableCloneOnUIRecursive(newValue)\n );\n }\n listeners.forEach((listener) => {\n listener(newValue);\n });\n },\n get _value(): T {\n return value;\n },\n addListener: (id: number, listener: (newValue: T) => void) => {\n listeners.set(id, listener);\n },\n removeListener: (id: number) => {\n listeners.delete(id);\n },\n _animation: null,\n _isReanimatedSharedValue: true,\n };\n return self;\n}\n\nexport function makeMutable<T>(\n initial: T,\n oneWayReadsOnly = false\n): SharedValue<T> {\n let value: T = initial;\n let syncDataHolder: ShareableSyncDataHolderRef<T> | undefined;\n if (!oneWayReadsOnly && NativeReanimatedModule.native) {\n // updates are always synchronous when running on web or in Jest environment\n syncDataHolder = NativeReanimatedModule.makeSynchronizedDataHolder(\n makeShareableCloneRecursive(value)\n );\n registerShareableMapping(syncDataHolder);\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return makeUIMutable(initial, syncDataHolder);\n },\n });\n // listeners can only work on JS thread on Web and jest environments\n const listeners = NativeReanimatedModule.native ? undefined : new Map();\n const mutable = {\n set value(newValue) {\n if (NativeReanimatedModule.native) {\n runOnUI(() => {\n mutable.value = newValue;\n })();\n } else {\n valueSetter(mutable, newValue);\n }\n },\n get value() {\n if (syncDataHolder) {\n return NativeReanimatedModule.getDataSynchronously(syncDataHolder);\n }\n return value;\n },\n set _value(newValue: T) {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'Setting `_value` directly is only possible on the UI runtime'\n );\n }\n value = newValue;\n listeners!.forEach((listener) => {\n listener(newValue);\n });\n },\n get _value(): T {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'Reading from `_value` directly is only possible on the UI runtime'\n );\n }\n return value;\n },\n modify: (modifier: (value: T) => T) => {\n runOnUI(() => {\n mutable.value = modifier(mutable.value);\n })();\n },\n addListener: (id: number, listener: (value: T) => void) => {\n if (NativeReanimatedModule.native) {\n throw new Error('adding listeners is only possible on the UI runtime');\n }\n listeners!.set(id, listener);\n },\n removeListener: (id: number) => {\n if (NativeReanimatedModule.native) {\n throw new Error(\n 'removing listeners is only possible on the UI runtime'\n );\n }\n listeners!.delete(id);\n },\n _isReanimatedSharedValue: true,\n };\n registerShareableMapping(mutable, handle);\n return mutable;\n}\n\nexport function makeRemote<T extends object>(initial: T = {} as T): T {\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return initial;\n },\n });\n registerShareableMapping(initial, handle);\n return initial;\n}\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,oBAAoB;AAEvD,SACEC,+BAA+B,EAC/BC,2BAA2B,EAC3BC,wBAAwB,QACnB,cAAc;AACrB,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,SAASC,aAAaA,CAC3BC,OAAU,EACVC,cAA8C,EAC9C;EACA,SAAS;;EAET,MAAMC,SAAS,GAAG,IAAIC,GAAG,EAAE;EAC3B,IAAIC,KAAK,GAAGJ,OAAO;EAEnB,MAAMK,IAAI,GAAG;IACX,IAAID,KAAKA,CAACE,QAAQ,EAAE;MA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W,EAAEA,CAACC,EAAU,EAAEF,QAA4B,KAAK;MACzD,IAAIjB,sBAAsB,CAAC8B,MAAM,EAAE;QACjC,MAAM,IAAIM,KAAK,CAAC,qDAAqD,CAAC;MACxE;MACA3B,SAAS,CAAEW,GAAG,CAACD,EAAE,EAAEF,QAAQ,CAAC;IAC9B,CAAC;IACDI,cAAc,EAAGF,EAAU,IAAK;MAC9B,IAAInB,sBAAsB,CAAC8B,MAAM,EAAE;QACjC,MAAM,IAAIM,KAAK,CACb,uDAAuD,CACxD;MACH;MACA3B,SAAS,CAAEa,MAAM,CAACH,EAAE,CAAC;IACvB,CAAC;IACDK,wBAAwB,EAAE;EAC5B,CAAC;EACDrB,wBAAwB,CAAC+B,OAAO,EAAEF,MAAM,CAAC;EACzC,OAAOE,OAAO;AAChB;AAEA,OAAO,SAASK,UAAUA,CAAA,EAA4C;EAAA,IAAzBhC,OAAU,GAAAoB,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC1D,MAAMK,MAAM,GAAG9B,2BAA2B,CAAC;IACzC+B,MAAM,EAAEA,CAAA,KAAM;MACZ,SAAS;;MACT,OAAO1B,OAAO;IAChB;EACF,CAAC,CAAC;EACFJ,wBAAwB,CAACI,OAAO,EAAEyB,MAAM,CAAC;EACzC,OAAOzB,OAAO;AAChB"}
|
|
@@ -9,6 +9,9 @@ export function checkCppVersion() {
|
|
|
9
9
|
throw new Error(`[Reanimated] Mismatch between JavaScript part (${jsVersion}) and native part of Reanimated (${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
// This is used only in test files, therefore it is reported by ts-prune (which is desired)
|
|
14
|
+
// ts-prune-ignore-next
|
|
12
15
|
export function matchVersion(version1, version2) {
|
|
13
16
|
if (version1.match(/^\d+\.\d+\.\d+$/) && version2.match(/^\d+\.\d+\.\d+$/)) {
|
|
14
17
|
// x.y.z, compare only major and minor, skip patch
|