@shopify/react-native-skia 0.1.123 → 0.1.126
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +1 -1
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +5 -5
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +4 -4
- package/cpp/api/JsiSkApi.h +3 -1
- package/cpp/api/JsiSkCanvas.h +1 -1
- package/cpp/api/JsiSkColor.h +41 -7
- package/cpp/api/JsiSkColorFilterFactory.h +2 -1
- package/cpp/api/JsiSkImageFilter.h +0 -2
- package/cpp/api/JsiSkImageFilterFactory.h +37 -17
- package/cpp/api/JsiSkMatrix.h +44 -2
- package/cpp/api/JsiSkPaint.h +4 -7
- package/cpp/api/JsiSkRuntimeEffect.h +7 -0
- package/cpp/api/JsiSkRuntimeEffectFactory.h +3 -2
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +70 -0
- package/cpp/api/JsiSkShaderFactory.h +2 -2
- package/cpp/api/JsiSkVertices.h +1 -1
- package/cpp/api/third_party/CSSColorParser.cpp +194 -0
- package/cpp/api/third_party/CSSColorParser.h +1 -191
- package/cpp/jsi/JsiSimpleValueWrapper.h +108 -0
- package/cpp/rnskia/RNSkAnimation.h +0 -2
- package/cpp/rnskia/RNSkDrawView.cpp +10 -13
- package/cpp/rnskia/RNSkDrawView.h +2 -2
- package/cpp/rnskia/RNSkValueApi.h +6 -2
- package/cpp/rnskia/values/RNSkClockValue.h +2 -2
- package/cpp/rnskia/values/RNSkDerivedValue.h +12 -5
- package/cpp/rnskia/values/RNSkReadonlyValue.h +14 -12
- package/cpp/rnskia/values/RNSkValue.h +8 -3
- package/ios/RNSkia-iOS/PlatformContext.h +30 -4
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +4 -4
- package/ios/RNSkia-iOS/SkiaDrawView.mm +9 -13
- package/lib/commonjs/{values/animation → animation}/decay/decay.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/decay.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/runDecay.js +1 -1
- package/lib/commonjs/animation/decay/runDecay.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/decay/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/decay/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/functions/index.js.map +0 -0
- package/lib/commonjs/animation/functions/interpolate.js +141 -0
- package/lib/commonjs/animation/functions/interpolate.js.map +1 -0
- package/lib/commonjs/animation/functions/interpolateColors.js +39 -0
- package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/Spring.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/Spring.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/runSpring.js +0 -0
- package/lib/commonjs/animation/spring/runSpring.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/spring/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/spring/useSpring.js +0 -0
- package/lib/commonjs/animation/spring/useSpring.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/Easing.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/Easing.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/createTiming.js +1 -1
- package/lib/commonjs/animation/timing/createTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js +3 -3
- package/lib/commonjs/animation/timing/functions/getResolvedParams.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js.map +1 -1
- package/lib/commonjs/{values/animation → animation}/timing/functions/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/functions/types.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/index.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/index.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/runTiming.js +0 -0
- package/lib/commonjs/animation/timing/runTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/timing/useLoop.js +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/useLoop.js.map +0 -0
- package/lib/commonjs/{values/animation → animation}/timing/useTiming.js +1 -1
- package/lib/commonjs/animation/timing/useTiming.js.map +1 -0
- package/lib/commonjs/{values/animation → animation}/types.js +0 -0
- package/lib/commonjs/{values/animation → animation}/types.js.map +0 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +14 -5
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/colorFilters/BlendColor.js.map +1 -1
- package/lib/commonjs/renderer/components/colorFilters/Lerp.js +1 -1
- package/lib/commonjs/renderer/components/colorFilters/Lerp.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +4 -2
- package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js +37 -0
- package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
- package/lib/commonjs/renderer/components/imageFilters/index.js +13 -0
- package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Gradient.js +1 -1
- package/lib/commonjs/renderer/components/shaders/Gradient.js.map +1 -1
- package/lib/commonjs/renderer/components/shaders/Shader.js +2 -2
- package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/commonjs/renderer/processors/Circles.js +3 -2
- package/lib/commonjs/renderer/processors/Circles.js.map +1 -1
- package/lib/commonjs/renderer/processors/Font.js +1 -1
- package/lib/commonjs/renderer/processors/Font.js.map +1 -1
- package/lib/commonjs/renderer/processors/Rects.js +11 -21
- package/lib/commonjs/renderer/processors/Rects.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Matrix3.js +42 -63
- package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Vector.js +4 -5
- package/lib/commonjs/renderer/processors/math/Vector.js.map +1 -1
- package/lib/commonjs/skia/Color.js +14 -38
- package/lib/commonjs/skia/Color.js.map +1 -1
- package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/Matrix.js.map +1 -1
- package/lib/commonjs/skia/Shader/useShader.js +4 -1
- package/lib/commonjs/skia/Shader/useShader.js.map +1 -1
- package/lib/commonjs/skia/Skia.js +3 -45
- package/lib/commonjs/skia/Skia.js.map +1 -1
- package/lib/commonjs/skia/SkiaApi.js +4 -0
- package/lib/commonjs/skia/SkiaApi.js.map +1 -0
- package/lib/commonjs/values/api.js +4 -6
- package/lib/commonjs/values/api.js.map +1 -1
- package/lib/commonjs/values/api.web.js +18 -0
- package/lib/commonjs/values/api.web.js.map +1 -0
- package/lib/commonjs/values/index.js +0 -13
- package/lib/commonjs/values/index.js.map +1 -1
- package/lib/commonjs/values/web/RNSkAnimation.js +46 -0
- package/lib/commonjs/values/web/RNSkAnimation.js.map +1 -0
- package/lib/commonjs/values/web/RNSkClockValue.js +75 -0
- package/lib/commonjs/values/web/RNSkClockValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkDerivedValue.js +51 -0
- package/lib/commonjs/values/web/RNSkDerivedValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js +45 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -0
- package/lib/commonjs/values/web/RNSkValue.js +73 -0
- package/lib/commonjs/values/web/RNSkValue.js.map +1 -0
- package/lib/commonjs/values/web/api.js +31 -0
- package/lib/commonjs/values/web/api.js.map +1 -0
- package/lib/commonjs/values/web/index.js +19 -0
- package/lib/commonjs/values/web/index.js.map +1 -0
- package/lib/commonjs/views/SkiaView.js +13 -10
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/commonjs/views/api.js +11 -0
- package/lib/commonjs/views/api.js.map +1 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/{values/animation → animation}/decay/decay.js +0 -0
- package/lib/module/{values/animation → animation}/decay/decay.js.map +0 -0
- package/lib/module/{values/animation → animation}/decay/index.js +0 -0
- package/lib/module/{values/animation → animation}/decay/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/decay/runDecay.js +1 -1
- package/lib/module/animation/decay/runDecay.js.map +1 -0
- package/lib/module/{values/animation → animation}/decay/types.js +0 -0
- package/lib/module/{values/animation → animation}/decay/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/functions/index.js.map +0 -0
- package/lib/module/animation/functions/interpolate.js +132 -0
- package/lib/module/animation/functions/interpolate.js.map +1 -0
- package/lib/module/animation/functions/interpolateColors.js +23 -0
- package/lib/module/animation/functions/interpolateColors.js.map +1 -0
- package/lib/module/{values/animation → animation}/index.js +0 -0
- package/lib/module/{values/animation → animation}/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/Spring.js +0 -0
- package/lib/module/{values/animation → animation}/spring/Spring.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/spring.js +0 -0
- package/lib/module/{values/animation → animation}/spring/functions/spring.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/index.js +0 -0
- package/lib/module/{values/animation → animation}/spring/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/runSpring.js +0 -0
- package/lib/module/animation/spring/runSpring.js.map +1 -0
- package/lib/module/{values/animation → animation}/spring/types.js +0 -0
- package/lib/module/{values/animation → animation}/spring/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/spring/useSpring.js +0 -0
- package/lib/module/animation/spring/useSpring.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/Easing.js +0 -0
- package/lib/module/{values/animation → animation}/timing/Easing.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/createTiming.js +1 -1
- package/lib/module/animation/timing/createTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/functions/bezier.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js +3 -3
- package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/functions/index.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/timing.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/timing.js.map +1 -1
- package/lib/module/{values/animation → animation}/timing/functions/types.js +0 -0
- package/lib/module/{values/animation → animation}/timing/functions/types.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/index.js +0 -0
- package/lib/module/{values/animation → animation}/timing/index.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/runTiming.js +0 -0
- package/lib/module/animation/timing/runTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/timing/useLoop.js +0 -0
- package/lib/module/{values/animation → animation}/timing/useLoop.js.map +0 -0
- package/lib/module/{values/animation → animation}/timing/useTiming.js +1 -1
- package/lib/module/animation/timing/useTiming.js.map +1 -0
- package/lib/module/{values/animation → animation}/types.js +0 -0
- package/lib/module/{values/animation → animation}/types.js.map +0 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +10 -4
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/components/colorFilters/BlendColor.js.map +1 -1
- package/lib/module/renderer/components/colorFilters/Lerp.js +1 -1
- package/lib/module/renderer/components/colorFilters/Lerp.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/InnerShadow.js +3 -2
- package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/RuntimeShader.js +19 -0
- package/lib/module/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
- package/lib/module/renderer/components/imageFilters/index.js +1 -0
- package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
- package/lib/module/renderer/components/shaders/Gradient.js +2 -2
- package/lib/module/renderer/components/shaders/Gradient.js.map +1 -1
- package/lib/module/renderer/components/shaders/Shader.js +3 -2
- package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/module/renderer/processors/Circles.js +3 -2
- package/lib/module/renderer/processors/Circles.js.map +1 -1
- package/lib/module/renderer/processors/Font.js +1 -1
- package/lib/module/renderer/processors/Font.js.map +1 -1
- package/lib/module/renderer/processors/Rects.js +9 -21
- package/lib/module/renderer/processors/Rects.js.map +1 -1
- package/lib/module/renderer/processors/math/Matrix3.js +52 -72
- package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
- package/lib/module/renderer/processors/math/Vector.js +3 -5
- package/lib/module/renderer/processors/math/Vector.js.map +1 -1
- package/lib/module/skia/Color.js +9 -25
- package/lib/module/skia/Color.js.map +1 -1
- package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/module/skia/Matrix.js.map +1 -1
- package/lib/module/skia/Shader/useShader.js +4 -1
- package/lib/module/skia/Shader/useShader.js.map +1 -1
- package/lib/module/skia/Skia.js +2 -46
- package/lib/module/skia/Skia.js.map +1 -1
- package/lib/module/skia/SkiaApi.js +2 -0
- package/lib/module/skia/SkiaApi.js.map +1 -0
- package/lib/module/values/api.js +4 -6
- package/lib/module/values/api.js.map +1 -1
- package/lib/module/values/api.web.js +7 -0
- package/lib/module/values/api.web.js.map +1 -0
- package/lib/module/values/index.js +0 -1
- package/lib/module/values/index.js.map +1 -1
- package/lib/module/values/web/RNSkAnimation.js +36 -0
- package/lib/module/values/web/RNSkAnimation.js.map +1 -0
- package/lib/module/values/web/RNSkClockValue.js +65 -0
- package/lib/module/values/web/RNSkClockValue.js.map +1 -0
- package/lib/module/values/web/RNSkDerivedValue.js +41 -0
- package/lib/module/values/web/RNSkDerivedValue.js.map +1 -0
- package/lib/module/values/web/RNSkReadonlyValue.js +36 -0
- package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -0
- package/lib/module/values/web/RNSkValue.js +63 -0
- package/lib/module/values/web/RNSkValue.js.map +1 -0
- package/lib/module/values/web/api.js +19 -0
- package/lib/module/values/web/api.js.map +1 -0
- package/lib/module/values/web/index.js +2 -0
- package/lib/module/values/web/index.js.map +1 -0
- package/lib/module/views/SkiaView.js +1 -3
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/module/views/api.js +4 -0
- package/lib/module/views/api.js.map +1 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/{values/animation → animation}/decay/decay.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/decay/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/decay/runDecay.d.ts +2 -2
- package/lib/typescript/src/{values/animation → animation}/decay/types.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/functions/index.d.ts +0 -0
- package/lib/typescript/src/animation/functions/interpolate.d.ts +11 -0
- package/lib/typescript/src/animation/functions/interpolateColors.d.ts +3 -0
- package/lib/typescript/src/{values/animation → animation}/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/Spring.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/functions/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/functions/spring.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/runSpring.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/spring/types.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/spring/useSpring.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/Easing.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/createTiming.d.ts +2 -2
- package/lib/typescript/src/{values/animation → animation}/timing/functions/bezier.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/getResolvedParams.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/functions/timing.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/functions/types.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/index.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/runTiming.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/timing/useLoop.d.ts +0 -0
- package/lib/typescript/src/{values/animation → animation}/timing/useTiming.d.ts +1 -1
- package/lib/typescript/src/{values/animation → animation}/types.d.ts +5 -5
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/renderer/Canvas.d.ts +6 -0
- package/lib/typescript/src/renderer/components/colorFilters/BlendColor.d.ts +1 -1
- package/lib/typescript/src/renderer/components/imageFilters/RuntimeShader.d.ts +7 -0
- package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -0
- package/lib/typescript/src/renderer/components/shaders/Gradient.d.ts +1 -1
- package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -2
- package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -4
- package/lib/typescript/src/renderer/processors/Rects.d.ts +9 -41
- package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -5
- package/lib/typescript/src/renderer/processors/math/Vector.d.ts +5 -17
- package/lib/typescript/src/skia/Color.d.ts +8 -9
- package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +16 -0
- package/lib/typescript/src/skia/Matrix.d.ts +7 -1
- package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +2 -1
- package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffectFactory.d.ts +2 -2
- package/lib/typescript/src/skia/Shader/useShader.d.ts +1 -1
- package/lib/typescript/src/skia/Skia.d.ts +28 -95
- package/lib/typescript/src/skia/SkiaApi.d.ts +71 -0
- package/lib/typescript/src/skia/Surface/Surface.d.ts +1 -1
- package/lib/typescript/src/skia/Surface/SurfaceFactory.d.ts +2 -2
- package/lib/typescript/src/values/api.d.ts +2 -25
- package/lib/typescript/src/values/api.web.d.ts +2 -0
- package/lib/typescript/src/values/index.d.ts +0 -1
- package/lib/typescript/src/values/types.d.ts +24 -1
- package/lib/typescript/src/values/web/RNSkAnimation.d.ts +9 -0
- package/lib/typescript/src/values/web/RNSkClockValue.d.ts +13 -0
- package/lib/typescript/src/values/web/RNSkDerivedValue.d.ts +9 -0
- package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +11 -0
- package/lib/typescript/src/values/web/RNSkValue.d.ts +14 -0
- package/lib/typescript/src/values/web/api.d.ts +2 -0
- package/lib/typescript/src/values/web/index.d.ts +1 -0
- package/lib/typescript/src/views/SkiaView.d.ts +3 -36
- package/lib/typescript/src/views/api.d.ts +5 -0
- package/lib/typescript/src/views/types.d.ts +32 -0
- package/package.json +2 -2
- package/src/{values/animation → animation}/decay/decay.ts +0 -0
- package/src/{values/animation → animation}/decay/index.ts +0 -0
- package/src/{values/animation → animation}/decay/runDecay.ts +2 -2
- package/src/{values/animation → animation}/decay/types.ts +1 -1
- package/src/{values/animation → animation}/functions/index.ts +0 -0
- package/src/animation/functions/interpolate.ts +182 -0
- package/src/animation/functions/interpolateColors.ts +58 -0
- package/src/{values/animation → animation}/index.ts +0 -0
- package/src/{values/animation → animation}/spring/Spring.ts +0 -0
- package/src/{values/animation → animation}/spring/functions/index.ts +0 -0
- package/src/{values/animation → animation}/spring/functions/spring.ts +0 -0
- package/src/{values/animation → animation}/spring/index.ts +0 -0
- package/src/{values/animation → animation}/spring/runSpring.ts +1 -1
- package/src/{values/animation → animation}/spring/types.ts +0 -0
- package/src/{values/animation → animation}/spring/useSpring.ts +1 -1
- package/src/{values/animation → animation}/timing/Easing.ts +0 -0
- package/src/{values/animation → animation}/timing/createTiming.ts +2 -2
- package/src/{values/animation → animation}/timing/functions/__tests__/timing.spec.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/bezier.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/getResolvedParams.ts +2 -2
- package/src/{values/animation → animation}/timing/functions/index.ts +0 -0
- package/src/{values/animation → animation}/timing/functions/timing.ts +1 -1
- package/src/{values/animation → animation}/timing/functions/types.ts +0 -0
- package/src/{values/animation → animation}/timing/index.ts +0 -0
- package/src/{values/animation → animation}/timing/runTiming.ts +1 -1
- package/src/{values/animation → animation}/timing/useLoop.ts +0 -0
- package/src/{values/animation → animation}/timing/useTiming.ts +2 -2
- package/src/{values/animation → animation}/types.ts +5 -5
- package/src/index.ts +1 -0
- package/src/renderer/Canvas.tsx +11 -4
- package/src/renderer/components/colorFilters/BlendColor.tsx +1 -1
- package/src/renderer/components/colorFilters/Lerp.tsx +1 -1
- package/src/renderer/components/imageFilters/InnerShadow.tsx +4 -2
- package/src/renderer/components/imageFilters/RuntimeShader.tsx +23 -0
- package/src/renderer/components/imageFilters/index.ts +1 -0
- package/src/renderer/components/shaders/Gradient.ts +2 -4
- package/src/renderer/components/shaders/Shader.tsx +3 -3
- package/src/renderer/processors/Circles.ts +2 -1
- package/src/renderer/processors/Font.ts +1 -1
- package/src/renderer/processors/Rects.ts +9 -14
- package/src/renderer/processors/math/Matrix3.ts +24 -105
- package/src/renderer/processors/math/Vector.ts +3 -2
- package/src/skia/Color.ts +13 -27
- package/src/skia/ImageFilter/ImageFilterFactory.ts +20 -0
- package/src/skia/Matrix.ts +8 -1
- package/src/skia/RuntimeEffect/RuntimeEffect.ts +3 -1
- package/src/skia/RuntimeEffect/RuntimeEffectFactory.ts +2 -2
- package/src/skia/Shader/useShader.ts +4 -1
- package/src/skia/Skia.ts +4 -126
- package/src/skia/SkiaApi.ts +86 -0
- package/src/skia/Surface/Surface.ts +1 -1
- package/src/skia/Surface/SurfaceFactory.ts +2 -2
- package/src/values/api.ts +3 -42
- package/src/values/api.web.ts +5 -0
- package/src/values/index.ts +0 -1
- package/src/values/types.ts +30 -1
- package/src/values/web/RNSkAnimation.ts +33 -0
- package/src/values/web/RNSkClockValue.ts +58 -0
- package/src/values/web/RNSkDerivedValue.ts +38 -0
- package/src/values/web/RNSkReadonlyValue.ts +32 -0
- package/src/values/web/RNSkValue.ts +57 -0
- package/src/values/web/__tests__/RNSkAnimation.spec.ts +21 -0
- package/src/values/web/__tests__/RNSkDerivedValue.spec.ts +15 -0
- package/src/values/web/__tests__/RNSkReadonlyValue.spec.ts +8 -0
- package/src/values/web/__tests__/RNSkValue.spec.ts +11 -0
- package/src/values/web/api.ts +33 -0
- package/src/values/web/index.ts +1 -0
- package/src/views/SkiaView.tsx +3 -49
- package/src/views/api.ts +7 -0
- package/src/views/types.ts +40 -0
- package/lib/commonjs/values/animation/decay/runDecay.js.map +0 -1
- package/lib/commonjs/values/animation/functions/interpolate.js +0 -139
- package/lib/commonjs/values/animation/functions/interpolate.js.map +0 -1
- package/lib/commonjs/values/animation/functions/interpolateColors.js +0 -47
- package/lib/commonjs/values/animation/functions/interpolateColors.js.map +0 -1
- package/lib/commonjs/values/animation/spring/runSpring.js.map +0 -1
- package/lib/commonjs/values/animation/spring/useSpring.js.map +0 -1
- package/lib/commonjs/values/animation/timing/createTiming.js.map +0 -1
- package/lib/commonjs/values/animation/timing/functions/getResolvedParams.js.map +0 -1
- package/lib/commonjs/values/animation/timing/runTiming.js.map +0 -1
- package/lib/commonjs/values/animation/timing/useTiming.js.map +0 -1
- package/lib/module/values/animation/decay/runDecay.js.map +0 -1
- package/lib/module/values/animation/functions/interpolate.js +0 -132
- package/lib/module/values/animation/functions/interpolate.js.map +0 -1
- package/lib/module/values/animation/functions/interpolateColors.js +0 -32
- package/lib/module/values/animation/functions/interpolateColors.js.map +0 -1
- package/lib/module/values/animation/spring/runSpring.js.map +0 -1
- package/lib/module/values/animation/spring/useSpring.js.map +0 -1
- package/lib/module/values/animation/timing/createTiming.js.map +0 -1
- package/lib/module/values/animation/timing/functions/getResolvedParams.js.map +0 -1
- package/lib/module/values/animation/timing/runTiming.js.map +0 -1
- package/lib/module/values/animation/timing/useTiming.js.map +0 -1
- package/lib/typescript/scripts/install-npm.d.ts +0 -1
- package/lib/typescript/src/values/animation/functions/interpolate.d.ts +0 -7
- package/lib/typescript/src/values/animation/functions/interpolateColors.d.ts +0 -3
- package/src/values/animation/functions/interpolate.ts +0 -169
- package/src/values/animation/functions/interpolateColors.ts +0 -62
@@ -1,47 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.mixColors = exports.interpolateColors = void 0;
|
7
|
-
|
8
|
-
var _renderer = require("../../../renderer");
|
9
|
-
|
10
|
-
var _skia = require("../../../skia");
|
11
|
-
|
12
|
-
var _interpolate = require("./interpolate");
|
13
|
-
|
14
|
-
const CLAMP = {
|
15
|
-
extrapolateLeft: "clamp",
|
16
|
-
extrapolateRight: "clamp"
|
17
|
-
};
|
18
|
-
|
19
|
-
const interpolateColorsRGB = (value, inputRange, outputRange) => {
|
20
|
-
const r = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => (0, _skia.red)(c)), CLAMP);
|
21
|
-
const g = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => (0, _skia.green)(c)), CLAMP);
|
22
|
-
const b = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => (0, _skia.blue)(c)), CLAMP);
|
23
|
-
const a = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => (0, _skia.alphaf)(c)), CLAMP);
|
24
|
-
return (0, _skia.rgbaColor)(r, g, b, a);
|
25
|
-
};
|
26
|
-
|
27
|
-
const interpolateColors = (value, inputRange, _outputRange) => {
|
28
|
-
const outputRange = _outputRange.map(cl => _skia.Skia.Color(cl));
|
29
|
-
|
30
|
-
return interpolateColorsRGB(value, inputRange, outputRange);
|
31
|
-
}; // This is fast. To be reconcilled with interpolateColors
|
32
|
-
// it looks like interpolateColors may not be working as expected
|
33
|
-
// these functions need to be tested more thoroughly on both platform
|
34
|
-
|
35
|
-
|
36
|
-
exports.interpolateColors = interpolateColors;
|
37
|
-
|
38
|
-
const mixColors = (value, x, y) => {
|
39
|
-
const r = (0, _renderer.mix)(value, (0, _skia.red)(x), (0, _skia.red)(y));
|
40
|
-
const g = (0, _renderer.mix)(value, (0, _skia.green)(x), (0, _skia.green)(y));
|
41
|
-
const b = (0, _renderer.mix)(value, (0, _skia.blue)(x), (0, _skia.blue)(y));
|
42
|
-
const a = (0, _renderer.mix)(value, (0, _skia.alphaf)(x), (0, _skia.alphaf)(y));
|
43
|
-
return (0, _skia.rgbaColor)(r, g, b, a);
|
44
|
-
};
|
45
|
-
|
46
|
-
exports.mixColors = mixColors;
|
47
|
-
//# sourceMappingURL=interpolateColors.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["interpolateColors.ts"],"names":["CLAMP","extrapolateLeft","extrapolateRight","interpolateColorsRGB","value","inputRange","outputRange","r","map","c","g","b","a","interpolateColors","_outputRange","cl","Skia","Color","mixColors","x","y"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEA,MAAMA,KAAK,GAAG;AACZC,EAAAA,eAAe,EAAE,OADL;AAEZC,EAAAA,gBAAgB,EAAE;AAFN,CAAd;;AAKA,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;AACH,QAAMC,CAAC,GAAG,8BACRH,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAO,eAAIA,CAAJ,CAAvB,CAHQ,EAIRT,KAJQ,CAAV;AAMA,QAAMU,CAAC,GAAG,8BACRN,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAO,iBAAMA,CAAN,CAAvB,CAHQ,EAIRT,KAJQ,CAAV;AAMA,QAAMW,CAAC,GAAG,8BACRP,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAO,gBAAKA,CAAL,CAAvB,CAHQ,EAIRT,KAJQ,CAAV;AAMA,QAAMY,CAAC,GAAG,8BACRR,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAO,kBAAOA,CAAP,CAAvB,CAHQ,EAIRT,KAJQ,CAAV;AAMA,SAAO,qBAAUO,CAAV,EAAaG,CAAb,EAAgBC,CAAhB,EAAmBC,CAAnB,CAAP;AACD,CA9BD;;AAgCO,MAAMC,iBAAiB,GAAG,CAC/BT,KAD+B,EAE/BC,UAF+B,EAG/BS,YAH+B,KAI5B;AACH,QAAMR,WAAW,GAAGQ,YAAY,CAACN,GAAb,CAAkBO,EAAD,IAAQC,WAAKC,KAAL,CAAWF,EAAX,CAAzB,CAApB;;AACA,SAAOZ,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CAPM,C,CASP;AACA;AACA;;;;;AACO,MAAMY,SAAS,GAAG,CAACd,KAAD,EAAgBe,CAAhB,EAA2BC,CAA3B,KAAyC;AAChE,QAAMb,CAAC,GAAG,mBAAIH,KAAJ,EAAW,eAAIe,CAAJ,CAAX,EAAmB,eAAIC,CAAJ,CAAnB,CAAV;AACA,QAAMV,CAAC,GAAG,mBAAIN,KAAJ,EAAW,iBAAMe,CAAN,CAAX,EAAqB,iBAAMC,CAAN,CAArB,CAAV;AACA,QAAMT,CAAC,GAAG,mBAAIP,KAAJ,EAAW,gBAAKe,CAAL,CAAX,EAAoB,gBAAKC,CAAL,CAApB,CAAV;AACA,QAAMR,CAAC,GAAG,mBAAIR,KAAJ,EAAW,kBAAOe,CAAP,CAAX,EAAsB,kBAAOC,CAAP,CAAtB,CAAV;AACA,SAAO,qBAAUb,CAAV,EAAaG,CAAb,EAAgBC,CAAhB,EAAmBC,CAAnB,CAAP;AACD,CANM","sourcesContent":["import { mix } from \"../../../renderer\";\nimport type { Color } from \"../../../skia\";\nimport { alphaf, blue, green, red, rgbaColor, Skia } from \"../../../skia\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: number[]\n) => {\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => red(c)),\n CLAMP\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => green(c)),\n CLAMP\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => blue(c)),\n CLAMP\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => alphaf(c)),\n CLAMP\n );\n return rgbaColor(r, g, b, a);\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\n// This is fast. To be reconcilled with interpolateColors\n// it looks like interpolateColors may not be working as expected\n// these functions need to be tested more thoroughly on both platform\nexport const mixColors = (value: number, x: number, y: number) => {\n const r = mix(value, red(x), red(y));\n const g = mix(value, green(x), green(y));\n const b = mix(value, blue(x), blue(y));\n const a = mix(value, alphaf(x), alphaf(y));\n return rgbaColor(r, g, b, a);\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["runSpring.ts"],"names":["runSpring","value","toOrParams","config","callback","Spring","Config","Default"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CACvBC,KADuB,EAEvBC,UAFuB,EAGvBC,MAHuB,EAIvBC,QAJuB,KAKL;AAClB,SAAO,0BACLH,KADK,EAELC,UAFK,EAGL,gCAAmBC,MAAnB,aAAmBA,MAAnB,cAAmBA,MAAnB,GAA6BE,eAAOC,MAAP,CAAcC,OAA3C,CAHK,EAILH,QAJK,CAAP;AAMD,CAZM","sourcesContent":["import type { SkiaValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n SpringConfig,\n AnimationCallback,\n} from \"../types\";\nimport { runTiming } from \"../timing/runTiming\";\n\nimport { Spring } from \"./Spring\";\nimport { createSpringEasing } from \"./functions/spring\";\n\n/**\n * Creates a new animation on an existing value that will be driven by\n * an animation value. The value will be run from / to the value in\n * params and modified by the provided easing curve for the length of\n * the duration. When the value has reached its desired \"to\" value the\n * animation will be stopped.\n *\n * @param value The value to animate\n * @param toOrParams To value or Animation parameters\n * @param config Spring configuration\n * @returns an animation value that can be used to start/stop\n * the animation.\n */\nexport const runSpring = (\n value: SkiaValue<number>,\n toOrParams: number | AnimationParams,\n config?: SpringConfig,\n callback?: AnimationCallback\n): SkiaAnimation => {\n return runTiming(\n value,\n toOrParams,\n createSpringEasing(config ?? Spring.Config.Default),\n callback\n );\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["useSpring.ts"],"names":["useSpring","toOrParams","config","callback","Spring","Config","Default"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAKvB,uBACEF,UADF,EAEE,gCAAmBC,MAAnB,aAAmBA,MAAnB,cAAmBA,MAAnB,GAA6BE,eAAOC,MAAP,CAAcC,OAA3C,CAFF,EAGEH,QAHF,CALK","sourcesContent":["import type { SkiaReadonlyValue } from \"../../types\";\nimport type {\n SpringConfig,\n AnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport { useTiming } from \"../timing\";\n\nimport { Spring } from \"./Spring\";\nimport { createSpringEasing } from \"./functions/spring\";\n\n/**\n * Creats a spring based animation value that will run whenever\n * the animation parameters change.\n * @param toOrParams\n * @param config\n * @returns\n */\nexport const useSpring = (\n toOrParams: number | AnimationParams,\n config?: SpringConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> =>\n useTiming(\n toOrParams,\n createSpringEasing(config ?? Spring.Config.Default),\n callback\n );\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["createTiming.ts"],"names":["createTiming","params","value","callback","resolvedParams","from","current","animationFunction","t","state","nextState","duration","easing","loop","yoyo","finished","to","ValueApi","createAnimation"],"mappings":";;;;;;;AAMA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,YAAY,GAAG,CAC1BC,MAD0B,EAE1BC,KAF0B,EAG1BC,QAH0B,KAIvB;AAAA;;AACH;AACA;AACA,QAAMC,cAAc,GAAG,EACrB,GAAGH,MADkB;AAErBI,IAAAA,IAAI,0BAAEJ,MAAM,CAACI,IAAT,uDAAiBH,KAAjB,aAAiBA,KAAjB,uBAAiBA,KAAK,CAAEI,OAAxB,uCAAmC;AAFlB,GAAvB,CAHG,CAQH;;AACA,QAAMC,iBAAiB,GAAG,CAACC,CAAD,EAAYC,KAAZ,KAAkD;AAAA;;AAC1E;AACA,UAAMC,SAAS,GAAG,uBAChBF,CADgB,EAEhBP,MAAM,CAACU,QAFS,EAGhBV,MAAM,CAACW,MAHS,kBAIhBX,MAAM,CAACY,IAJS,uDAID,KAJC,kBAKhBZ,MAAM,CAACa,IALS,uDAKD,KALC,EAMhBL,KANgB,aAMhBA,KANgB,cAMhBA,KANgB,GAMP;AAAEH,MAAAA,OAAO,EAAEL,MAAM,CAACI,IAAlB;AAAyBU,MAAAA,QAAQ,EAAE;AAAnC,KANO,CAAlB;AAQA,UAAMT,OAAO,GACXI,SAAS,CAACJ,OAAV,IAAqBF,cAAc,CAACY,EAAf,GAAoBZ,cAAc,CAACC,IAAxD,IACAD,cAAc,CAACC,IAFjB;;AAGA,QAAIF,QAAQ,IAAIO,SAAS,CAACK,QAAV,KAAuB,IAAvC,EAA6C;AAC3CZ,MAAAA,QAAQ,CAACG,OAAD,CAAR;AACD;;AACD,WAAO,EACL,GAAGI,SADE;AAELJ,MAAAA;AAFK,KAAP;AAID,GApBD,CATG,CA+BH;;;AACA,SAAOW,cAASC,eAAT,CAAyBX,iBAAzB,CAAP;AACD,CArCM","sourcesContent":["import type {\n TimingConfig,\n RequiredAnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport type { AnimationState, SkiaValue } from \"../../types\";\nimport { ValueApi } from \"../../api\";\n\nimport { timing } from \"./functions\";\n\n/**\n * Creates an animation that is driven by a clock value.\n * The value will be run from / to the value in params and modified\n * by the provided easing curve for the length of the duration. When\n * the value has reached its desired \"to\" value the animation\n * will be stopped. If loop is set to true, the animation will continue\n * to run until stopped.\n *\n * @param params Animation parameters\n * @param config Spring or timing configuration\n * @param value Optional value that the animation will update\n * @params an animation value that can be used to start/stop\n * the animation.\n */\nexport const createTiming = (\n params: RequiredAnimationParams & Required<TimingConfig>,\n value?: SkiaValue<number>,\n callback?: AnimationCallback\n) => {\n // Update from to be either the declared from value,\n // the current value of the value or zero\n const resolvedParams = {\n ...params,\n from: params.from ?? value?.current ?? 0,\n };\n\n // Update function for the animation value\n const animationFunction = (t: number, state: AnimationState | undefined) => {\n // Update the input value using the provided update function\n const nextState = timing(\n t,\n params.duration,\n params.easing,\n params.loop ?? false,\n params.yoyo ?? false,\n state ?? { current: params.from!, finished: false }\n );\n const current =\n nextState.current * (resolvedParams.to - resolvedParams.from!) +\n resolvedParams.from!;\n if (callback && nextState.finished === true) {\n callback(current);\n }\n return {\n ...nextState,\n current,\n };\n };\n\n // Create animation value\n return ValueApi.createAnimation(animationFunction);\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["getResolvedParams.ts"],"names":["DefaultParameters","to","loop","yoyo","immediate","DefaultTimingConfig","duration","easing","t","getResolvedParams","toOrParams","config","resolvedParameters","from","resolvedConfig"],"mappings":";;;;;;AAMA,MAAMA,iBAAiB,GAAG;AACxBC,EAAAA,EAAE,EAAE,CADoB;AAExBC,EAAAA,IAAI,EAAE,KAFkB;AAGxBC,EAAAA,IAAI,EAAE,KAHkB;AAIxBC,EAAAA,SAAS,EAAE;AAJa,CAA1B;AAOA,MAAMC,mBAAmB,GAAG;AAC1BC,EAAAA,QAAQ,EAAE,IADgB;AAE1BC,EAAAA,MAAM,EAAGC,CAAD,IAAeA;AAFG,CAA5B;AAKA;AACA;AACA;AACA;AACA;;AACO,MAAMC,iBAAiB,GAAG,CAC/BC,UAD+B,EAE/BC,MAF+B,KAGsB;AACrD,MAAIC,kBAA2C,GAAG,EAChD,GAAGZ;AAD6C,GAAlD;;AAIA,MAAI,OAAOU,UAAP,KAAsB,QAA1B,EAAoC;AAClCE,IAAAA,kBAAkB,CAACX,EAAnB,GAAwBS,UAAxB;AACD,GAFD,MAEO;AAAA;;AACLE,IAAAA,kBAAkB,GAAG;AACnBC,MAAAA,IAAI,sBAAEH,UAAU,CAACG,IAAb,+DAAqBD,kBAAkB,CAACC,IADzB;AAEnBZ,MAAAA,EAAE,oBAAES,UAAU,CAACT,EAAb,2DAAmBW,kBAAkB,CAACX,EAFrB;AAGnBC,MAAAA,IAAI,sBAAEQ,UAAU,CAACR,IAAb,+DAAqBU,kBAAkB,CAACV,IAHzB;AAInBC,MAAAA,IAAI,sBAAEO,UAAU,CAACP,IAAb,+DAAqBS,kBAAkB,CAACT;AAJzB,KAArB;AAMD;;AAED,QAAMW,cAAsC,GAAG,EAAE,GAAGT;AAAL,GAA/C;;AACA,MAAIM,MAAJ,EAAY;AAAA;;AACVG,IAAAA,cAAc,CAACR,QAAf,GAA0BK,MAAM,CAACL,QAAjC;AACAQ,IAAAA,cAAc,CAACP,MAAf,qBAAwBI,MAAM,CAACJ,MAA/B,2DAA2CC,CAAD,IAAOA,CAAjD;AACD;;AAED,SAAO,EAAE,GAAGI,kBAAL;AAAyB,OAAGE;AAA5B,GAAP;AACD,CA1BM","sourcesContent":["import type {\n RequiredAnimationParams,\n AnimationParams,\n TimingConfig,\n} from \"../../types\";\n\nconst DefaultParameters = {\n to: 1,\n loop: false,\n yoyo: false,\n immediate: true,\n};\n\nconst DefaultTimingConfig = {\n duration: 1000,\n easing: (t: number) => t,\n};\n\n/**\n * Resolves parameters from optional values to a single object\n * @param toOrParams Params or to value\n * @param config timing/spring configuration\n */\nexport const getResolvedParams = (\n toOrParams: number | AnimationParams,\n config?: TimingConfig\n): RequiredAnimationParams & Required<TimingConfig> => {\n let resolvedParameters: RequiredAnimationParams = {\n ...DefaultParameters,\n };\n\n if (typeof toOrParams === \"number\") {\n resolvedParameters.to = toOrParams;\n } else {\n resolvedParameters = {\n from: toOrParams.from ?? resolvedParameters.from,\n to: toOrParams.to ?? resolvedParameters.to,\n loop: toOrParams.loop ?? resolvedParameters.loop,\n yoyo: toOrParams.yoyo ?? resolvedParameters.yoyo,\n };\n }\n\n const resolvedConfig: Required<TimingConfig> = { ...DefaultTimingConfig };\n if (config) {\n resolvedConfig.duration = config.duration;\n resolvedConfig.easing = config.easing ?? ((t) => t);\n }\n\n return { ...resolvedParameters, ...resolvedConfig };\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["runTiming.ts"],"names":["runTiming","value","toOrParams","config","callback","resolvedParameters","animation"],"mappings":";;;;;;;AAOA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CACvBC,KADuB,EAEvBC,UAFuB,EAGvBC,MAHuB,EAIvBC,QAJuB,KAKL;AAClB,QAAMC,kBAAkB,GAAG,kCAAkBH,UAAlB,EAA8BC,MAA9B,CAA3B;AACA,QAAMG,SAAS,GAAG,gCAAaD,kBAAb,EAAiCJ,KAAjC,EAAwCG,QAAxC,CAAlB;AACAH,EAAAA,KAAK,CAACK,SAAN,GAAkBA,SAAlB;AACA,SAAOA,SAAP;AACD,CAVM","sourcesContent":["import type { SkiaValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n/**\n * Creates a new animation on an existing value that will be driven by\n * an animation value. The value will be run from / to the value in\n * params and modified by the provided easing curve for the length of\n * the duration. When the value has reached its desired \"to\" value the\n * animation will be stopped.\n *\n * @param value The value to animate\n * @param toOrParams To value or Animation parameters\n * @param config Spring or timing configuration\n * @returns an animation value that can be used to start/stop\n * the animation.\n */\nexport const runTiming = (\n value: SkiaValue<number>,\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaAnimation => {\n const resolvedParameters = getResolvedParams(toOrParams, config);\n const animation = createTiming(resolvedParameters, value, callback);\n value.animation = animation;\n return animation;\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["useTiming.ts"],"names":["useTiming","toOrParams","config","callback","prevCfgRef","resolvedParameters","nextParams","equals","current","value","from","prevAnimationRef","prevParamsRef","animation","undefined","a","b","JSON","stringify"],"mappings":";;;;;;;AAAA;;AAQA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAIO;AAAA;;AAC9B;AACA;AACA,QAAMC,UAAU,GAAG,oBAAnB;AACA,QAAMC,kBAAkB,GAAG,oBAAQ,MAAM;AACvC,UAAMC,UAAU,GAAG,kCAAkBL,UAAlB,EAA8BC,MAA9B,CAAnB;;AACA,QAAI,CAACK,MAAM,CAACH,UAAU,CAACI,OAAZ,EAAqBF,UAArB,CAAX,EAA6C;AAC3CF,MAAAA,UAAU,CAACI,OAAX,GAAqBF,UAArB;AACD;;AACD,WAAOF,UAAU,CAACI,OAAlB;AACD,GAN0B,EAMxB,CAACN,MAAD,EAASD,UAAT,CANwB,CAA3B,CAJ8B,CAY9B;;AACA,QAAMQ,KAAK,GAAG,iDAASJ,kBAAkB,CAACK,IAA5B,yEAAoC,CAApC,CAAd,CAb8B,CAe9B;AACA;;AACA,QAAMC,gBAAgB,GAAG,oBAAzB;AACA,QAAMC,aAAa,GAAG,oBAAtB;AACA,QAAMC,SAAS,GAAG,oBAAQ,MAAM;AAC9B,QAAI,CAACN,MAAM,CAACK,aAAa,CAACJ,OAAf,EAAwBH,kBAAxB,CAAX,EAAwD;AACtDO,MAAAA,aAAa,CAACJ,OAAd,GAAwBH,kBAAxB;AACAM,MAAAA,gBAAgB,CAACH,OAAjB,GAA2B,gCACzBH,kBADyB,EAEzBI,KAFyB,EAGzBN,QAHyB,CAA3B;AAKD;;AACD,WAAOQ,gBAAgB,CAACH,OAAxB;AACD,GAViB,EAUf,CAACL,QAAD,EAAWE,kBAAX,EAA+BI,KAA/B,CAVe,CAAlB,CAnB8B,CA+B9B;;AACA,wBAAU,MAAM;AACdA,IAAAA,KAAK,CAACI,SAAN,GAAkBA,SAAlB;AACA,WAAO,MAAOJ,KAAK,CAACI,SAAN,GAAkBC,SAAhC;AACD,GAHD,EAGG,CAACD,SAAD,EAAYJ,KAAZ,CAHH,EAhC8B,CAqC9B;;AACA,SAAOA,KAAP;AACD,CA3CM;;;;AA6CP,MAAMF,MAAM,GAAG,CAASQ,CAAT,EAAgBC,CAAhB,KAA0B;AACvC,SAAOC,IAAI,CAACC,SAAL,CAAeH,CAAf,MAAsBE,IAAI,CAACC,SAAL,CAAeF,CAAf,CAA7B;AACD,CAFD","sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\n\nimport type { SkiaReadonlyValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\nimport { useValue } from \"../../hooks/useValue\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n\n/**\n * Creats an animation value that will run whenever\n * the animation parameters change. The animation start immediately.\n * @param toOrParams\n * @param config\n * @returns A value that is animated\n */\nexport const useTiming = (\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> => {\n // Resolve parameters - keep a cached version to avoid\n // unnecesary re-renders.\n const prevCfgRef = useRef<ReturnType<typeof getResolvedParams>>();\n const resolvedParameters = useMemo(() => {\n const nextParams = getResolvedParams(toOrParams, config);\n if (!equals(prevCfgRef.current, nextParams)) {\n prevCfgRef.current = nextParams;\n }\n return prevCfgRef.current!;\n }, [config, toOrParams]);\n\n // Create value\n const value = useValue(resolvedParameters.from ?? 0);\n\n // Create timing animation - keep a cached version to avoid\n // uneccessary recreation of animations\n const prevAnimationRef = useRef<SkiaAnimation>();\n const prevParamsRef = useRef<typeof resolvedParameters>();\n const animation = useMemo(() => {\n if (!equals(prevParamsRef.current, resolvedParameters)) {\n prevParamsRef.current = resolvedParameters;\n prevAnimationRef.current = createTiming(\n resolvedParameters,\n value,\n callback\n );\n }\n return prevAnimationRef.current!;\n }, [callback, resolvedParameters, value]);\n\n // Run animation on the value - and stop it on unmount\n useEffect(() => {\n value.animation = animation;\n return () => (value.animation = undefined);\n }, [animation, value]);\n\n // Return the value that is animated\n return value;\n};\n\nconst equals = <T1, T2>(a: T1, b: T2) => {\n return JSON.stringify(a) === JSON.stringify(b);\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["runDecay.ts"],"names":["ValueApi","decay","runDecay","value","config","resolvedConfig","deceleration","velocityFactor","velocity","from","current","updateFunction","t","state","finished","lastTimestamp","startTimestamp","initialVelocity","animation","createAnimation"],"mappings":"AAAA,SAASA,QAAT,QAAyB,WAAzB;AAGA,SAASC,KAAT,QAAsB,SAAtB;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,CAACC,KAAD,EAA2BC,MAA3B,KAAoD;AAC1E,QAAMC,cAAkC,GAAG;AACzCC,IAAAA,YAAY,EAAE,KAD2B;AAEzCC,IAAAA,cAAc,EAAE,CAFyB;AAGzCC,IAAAA,QAAQ,EAAE,CAH+B;AAIzCC,IAAAA,IAAI,EAAEN,KAAK,CAACO,OAJ6B;AAKzC,OAAGN;AALsC,GAA3C;;AAOA,QAAMO,cAAc,GAAG,CAACC,CAAD,EAAYC,KAAZ,KAA8C;AACnE,QAAI,CAACA,KAAL,EAAY;AACV,aAAO;AACLH,QAAAA,OAAO,EAAEL,cAAc,CAACI,IADnB;AAELK,QAAAA,QAAQ,EAAE,KAFL;AAGLC,QAAAA,aAAa,EAAEH,CAHV;AAILI,QAAAA,cAAc,EAAEJ,CAJX;AAKLK,QAAAA,eAAe,EAAEZ,cAAc,CAACG,QAL3B;AAMLA,QAAAA,QAAQ,EAAEH,cAAc,CAACG;AANpB,OAAP;AAQD;;AACD,WAAOP,KAAK,CAACW,CAAD,EAAIC,KAAJ,EAAWR,cAAX,CAAZ;AACD,GAZD;;AAaAF,EAAAA,KAAK,CAACe,SAAN,GAAkBlB,QAAQ,CAACmB,eAAT,CAAyBR,cAAzB,CAAlB;AACA,SAAOR,KAAK,CAACe,SAAb;AACD,CAvBM","sourcesContent":["import { ValueApi } from \"../../api\";\nimport type { SkiaValue } from \"../../types\";\n\nimport { decay } from \"./decay\";\nimport type { DecayConfig, DefaultDecayConfig, DecayState } from \"./types\";\n\n/**\n * Runs a decay animation from the current value to zero with the given decay\n * configuration.\n * @param value value to animate\n * @param config Configuration or default configuration\n * @returns Animation\n */\nexport const runDecay = (value: SkiaValue<number>, config?: DecayConfig) => {\n const resolvedConfig: DefaultDecayConfig = {\n deceleration: 0.998,\n velocityFactor: 1,\n velocity: 0,\n from: value.current,\n ...config,\n };\n const updateFunction = (t: number, state: DecayState | undefined) => {\n if (!state) {\n return {\n current: resolvedConfig.from,\n finished: false,\n lastTimestamp: t,\n startTimestamp: t,\n initialVelocity: resolvedConfig.velocity,\n velocity: resolvedConfig.velocity,\n };\n }\n return decay(t, state, resolvedConfig);\n };\n value.animation = ValueApi.createAnimation(updateFunction);\n return value.animation;\n};\n"]}
|
@@ -1,132 +0,0 @@
|
|
1
|
-
// eslint-disable-next-line max-len
|
2
|
-
// Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js
|
3
|
-
function interpolateFunction(input, inputRange, outputRange, options) {
|
4
|
-
const {
|
5
|
-
extrapolateLeft,
|
6
|
-
extrapolateRight,
|
7
|
-
easing
|
8
|
-
} = options;
|
9
|
-
let result = input;
|
10
|
-
const [inputMin, inputMax] = inputRange;
|
11
|
-
const [outputMin, outputMax] = outputRange;
|
12
|
-
|
13
|
-
if (result < inputMin) {
|
14
|
-
if (extrapolateLeft === "identity") {
|
15
|
-
return result;
|
16
|
-
}
|
17
|
-
|
18
|
-
if (extrapolateLeft === "clamp") {
|
19
|
-
result = inputMin;
|
20
|
-
} else if (extrapolateLeft === "extend") {// noop
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
if (result > inputMax) {
|
25
|
-
if (extrapolateRight === "identity") {
|
26
|
-
return result;
|
27
|
-
}
|
28
|
-
|
29
|
-
if (extrapolateRight === "clamp") {
|
30
|
-
result = inputMax;
|
31
|
-
} else if (extrapolateRight === "extend") {// noop
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
if (outputMin === outputMax) {
|
36
|
-
return outputMin;
|
37
|
-
} // Input Range
|
38
|
-
|
39
|
-
|
40
|
-
result = (result - inputMin) / (inputMax - inputMin); // Easing
|
41
|
-
|
42
|
-
result = easing(result); // Output Range
|
43
|
-
|
44
|
-
result = result * (outputMax - outputMin) + outputMin;
|
45
|
-
return result;
|
46
|
-
}
|
47
|
-
|
48
|
-
function findRange(input, inputRange) {
|
49
|
-
let i;
|
50
|
-
|
51
|
-
for (i = 1; i < inputRange.length - 1; ++i) {
|
52
|
-
if (inputRange[i] >= input) {
|
53
|
-
break;
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
return i - 1;
|
58
|
-
}
|
59
|
-
|
60
|
-
function checkValidInputRange(arr) {
|
61
|
-
for (let i = 1; i < arr.length; ++i) {
|
62
|
-
if (!(arr[i] > arr[i - 1])) {
|
63
|
-
throw new Error(`inputRange must be strictly monotonically non-decreasing but got [${arr.join(",")}]`);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
function checkInfiniteRange(name, arr) {
|
69
|
-
if (arr.length < 2) {
|
70
|
-
throw new Error(name + " must have at least 2 elements");
|
71
|
-
}
|
72
|
-
|
73
|
-
for (const index in arr) {
|
74
|
-
if (typeof arr[index] !== "number") {
|
75
|
-
throw new Error(`${name} must contain only numbers`);
|
76
|
-
}
|
77
|
-
|
78
|
-
if (arr[index] === -Infinity || arr[index] === Infinity) {
|
79
|
-
throw new Error(`${name} must contain only finite numbers, but got [${arr.join(",")}]`);
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
export function interpolate(input, inputRange, outputRange, options) {
|
85
|
-
var _options$easing;
|
86
|
-
|
87
|
-
if (typeof input === "undefined") {
|
88
|
-
throw new Error("input can not be undefined");
|
89
|
-
}
|
90
|
-
|
91
|
-
if (typeof inputRange === "undefined") {
|
92
|
-
throw new Error("inputRange can not be undefined");
|
93
|
-
}
|
94
|
-
|
95
|
-
if (typeof outputRange === "undefined") {
|
96
|
-
throw new Error("outputRange can not be undefined");
|
97
|
-
}
|
98
|
-
|
99
|
-
if (inputRange.length !== outputRange.length) {
|
100
|
-
throw new Error("inputRange (" + inputRange.length + ") and outputRange (" + outputRange.length + ") must have the same length");
|
101
|
-
}
|
102
|
-
|
103
|
-
checkInfiniteRange("inputRange", inputRange);
|
104
|
-
checkInfiniteRange("outputRange", outputRange);
|
105
|
-
checkValidInputRange(inputRange);
|
106
|
-
const easing = (_options$easing = options === null || options === void 0 ? void 0 : options.easing) !== null && _options$easing !== void 0 ? _options$easing : num => num;
|
107
|
-
let extrapolateLeft = "extend";
|
108
|
-
|
109
|
-
if ((options === null || options === void 0 ? void 0 : options.extrapolateLeft) !== undefined) {
|
110
|
-
// eslint-disable-next-line prefer-destructuring
|
111
|
-
extrapolateLeft = options.extrapolateLeft;
|
112
|
-
}
|
113
|
-
|
114
|
-
let extrapolateRight = "extend";
|
115
|
-
|
116
|
-
if ((options === null || options === void 0 ? void 0 : options.extrapolateRight) !== undefined) {
|
117
|
-
// eslint-disable-next-line prefer-destructuring
|
118
|
-
extrapolateRight = options.extrapolateRight;
|
119
|
-
}
|
120
|
-
|
121
|
-
if (typeof input !== "number") {
|
122
|
-
throw new TypeError("Cannot interpolate an input which is not a number");
|
123
|
-
}
|
124
|
-
|
125
|
-
const range = findRange(input, inputRange);
|
126
|
-
return interpolateFunction(input, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
|
127
|
-
easing,
|
128
|
-
extrapolateLeft,
|
129
|
-
extrapolateRight
|
130
|
-
});
|
131
|
-
}
|
132
|
-
//# sourceMappingURL=interpolate.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["interpolate.ts"],"names":["interpolateFunction","input","inputRange","outputRange","options","extrapolateLeft","extrapolateRight","easing","result","inputMin","inputMax","outputMin","outputMax","findRange","i","length","checkValidInputRange","arr","Error","join","checkInfiniteRange","name","index","Infinity","interpolate","num","undefined","TypeError","range"],"mappings":"AAAA;AACA;AAIA,SAASA,mBAAT,CACEC,KADF,EAEEC,UAFF,EAGEC,WAHF,EAIEC,OAJF,EASU;AACR,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA,gBAAnB;AAAqCC,IAAAA;AAArC,MAAgDH,OAAtD;AAEA,MAAII,MAAM,GAAGP,KAAb;AACA,QAAM,CAACQ,QAAD,EAAWC,QAAX,IAAuBR,UAA7B;AACA,QAAM,CAACS,SAAD,EAAYC,SAAZ,IAAyBT,WAA/B;;AAEA,MAAIK,MAAM,GAAGC,QAAb,EAAuB;AACrB,QAAIJ,eAAe,KAAK,UAAxB,EAAoC;AAClC,aAAOG,MAAP;AACD;;AAED,QAAIH,eAAe,KAAK,OAAxB,EAAiC;AAC/BG,MAAAA,MAAM,GAAGC,QAAT;AACD,KAFD,MAEO,IAAIJ,eAAe,KAAK,QAAxB,EAAkC,CACvC;AACD;AACF;;AAED,MAAIG,MAAM,GAAGE,QAAb,EAAuB;AACrB,QAAIJ,gBAAgB,KAAK,UAAzB,EAAqC;AACnC,aAAOE,MAAP;AACD;;AAED,QAAIF,gBAAgB,KAAK,OAAzB,EAAkC;AAChCE,MAAAA,MAAM,GAAGE,QAAT;AACD,KAFD,MAEO,IAAIJ,gBAAgB,KAAK,QAAzB,EAAmC,CACxC;AACD;AACF;;AAED,MAAIK,SAAS,KAAKC,SAAlB,EAA6B;AAC3B,WAAOD,SAAP;AACD,GAjCO,CAmCR;;;AACAH,EAAAA,MAAM,GAAG,CAACA,MAAM,GAAGC,QAAV,KAAuBC,QAAQ,GAAGD,QAAlC,CAAT,CApCQ,CAsCR;;AACAD,EAAAA,MAAM,GAAGD,MAAM,CAACC,MAAD,CAAf,CAvCQ,CAyCR;;AACAA,EAAAA,MAAM,GAAGA,MAAM,IAAII,SAAS,GAAGD,SAAhB,CAAN,GAAmCA,SAA5C;AAEA,SAAOH,MAAP;AACD;;AAED,SAASK,SAAT,CAAmBZ,KAAnB,EAAkCC,UAAlC,EAAiE;AAC/D,MAAIY,CAAJ;;AACA,OAAKA,CAAC,GAAG,CAAT,EAAYA,CAAC,GAAGZ,UAAU,CAACa,MAAX,GAAoB,CAApC,EAAuC,EAAED,CAAzC,EAA4C;AAC1C,QAAIZ,UAAU,CAACY,CAAD,CAAV,IAAiBb,KAArB,EAA4B;AAC1B;AACD;AACF;;AAED,SAAOa,CAAC,GAAG,CAAX;AACD;;AAED,SAASE,oBAAT,CAA8BC,GAA9B,EAAsD;AACpD,OAAK,IAAIH,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGG,GAAG,CAACF,MAAxB,EAAgC,EAAED,CAAlC,EAAqC;AACnC,QAAI,EAAEG,GAAG,CAACH,CAAD,CAAH,GAASG,GAAG,CAACH,CAAC,GAAG,CAAL,CAAd,CAAJ,EAA4B;AAC1B,YAAM,IAAII,KAAJ,CACH,qEAAoED,GAAG,CAACE,IAAJ,CACnE,GADmE,CAEnE,GAHE,CAAN;AAKD;AACF;AACF;;AAED,SAASC,kBAAT,CAA4BC,IAA5B,EAA0CJ,GAA1C,EAAkE;AAChE,MAAIA,GAAG,CAACF,MAAJ,GAAa,CAAjB,EAAoB;AAClB,UAAM,IAAIG,KAAJ,CAAUG,IAAI,GAAG,gCAAjB,CAAN;AACD;;AAED,OAAK,MAAMC,KAAX,IAAoBL,GAApB,EAAyB;AACvB,QAAI,OAAOA,GAAG,CAACK,KAAD,CAAV,KAAsB,QAA1B,EAAoC;AAClC,YAAM,IAAIJ,KAAJ,CAAW,GAAEG,IAAK,4BAAlB,CAAN;AACD;;AAED,QAAIJ,GAAG,CAACK,KAAD,CAAH,KAAe,CAACC,QAAhB,IAA4BN,GAAG,CAACK,KAAD,CAAH,KAAeC,QAA/C,EAAyD;AACvD,YAAM,IAAIL,KAAJ,CACH,GAAEG,IAAK,+CAA8CJ,GAAG,CAACE,IAAJ,CAAS,GAAT,CAAc,GADhE,CAAN;AAGD;AACF;AACF;;AAED,OAAO,SAASK,WAAT,CACLvB,KADK,EAELC,UAFK,EAGLC,WAHK,EAILC,OAJK,EASG;AAAA;;AACR,MAAI,OAAOH,KAAP,KAAiB,WAArB,EAAkC;AAChC,UAAM,IAAIiB,KAAJ,CAAU,4BAAV,CAAN;AACD;;AAED,MAAI,OAAOhB,UAAP,KAAsB,WAA1B,EAAuC;AACrC,UAAM,IAAIgB,KAAJ,CAAU,iCAAV,CAAN;AACD;;AAED,MAAI,OAAOf,WAAP,KAAuB,WAA3B,EAAwC;AACtC,UAAM,IAAIe,KAAJ,CAAU,kCAAV,CAAN;AACD;;AAED,MAAIhB,UAAU,CAACa,MAAX,KAAsBZ,WAAW,CAACY,MAAtC,EAA8C;AAC5C,UAAM,IAAIG,KAAJ,CACJ,iBACEhB,UAAU,CAACa,MADb,GAEE,qBAFF,GAGEZ,WAAW,CAACY,MAHd,GAIE,6BALE,CAAN;AAOD;;AAEDK,EAAAA,kBAAkB,CAAC,YAAD,EAAelB,UAAf,CAAlB;AACAkB,EAAAA,kBAAkB,CAAC,aAAD,EAAgBjB,WAAhB,CAAlB;AAEAa,EAAAA,oBAAoB,CAACd,UAAD,CAApB;AAEA,QAAMK,MAAM,sBAAGH,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEG,MAAZ,6DAAwBkB,GAAD,IAAyBA,GAA5D;AAEA,MAAIpB,eAAgC,GAAG,QAAvC;;AACA,MAAI,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,eAAT,MAA6BqB,SAAjC,EAA4C;AAC1C;AACArB,IAAAA,eAAe,GAAGD,OAAO,CAACC,eAA1B;AACD;;AAED,MAAIC,gBAAiC,GAAG,QAAxC;;AACA,MAAI,CAAAF,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEE,gBAAT,MAA8BoB,SAAlC,EAA6C;AAC3C;AACApB,IAAAA,gBAAgB,GAAGF,OAAO,CAACE,gBAA3B;AACD;;AAED,MAAI,OAAOL,KAAP,KAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAI0B,SAAJ,CAAc,mDAAd,CAAN;AACD;;AAED,QAAMC,KAAK,GAAGf,SAAS,CAACZ,KAAD,EAAQC,UAAR,CAAvB;AACA,SAAOF,mBAAmB,CACxBC,KADwB,EAExB,CAACC,UAAU,CAAC0B,KAAD,CAAX,EAAoB1B,UAAU,CAAC0B,KAAK,GAAG,CAAT,CAA9B,CAFwB,EAGxB,CAACzB,WAAW,CAACyB,KAAD,CAAZ,EAAqBzB,WAAW,CAACyB,KAAK,GAAG,CAAT,CAAhC,CAHwB,EAIxB;AACErB,IAAAA,MADF;AAEEF,IAAAA,eAFF;AAGEC,IAAAA;AAHF,GAJwB,CAA1B;AAUD","sourcesContent":["// eslint-disable-next-line max-len\n// Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js\n\ntype ExtrapolateType = \"extend\" | \"identity\" | \"clamp\";\n\nfunction interpolateFunction(\n input: number,\n inputRange: [number, number],\n outputRange: [number, number],\n options: {\n easing: (input: number) => number;\n extrapolateLeft: ExtrapolateType;\n extrapolateRight: ExtrapolateType;\n }\n): number {\n const { extrapolateLeft, extrapolateRight, easing } = options;\n\n let result = input;\n const [inputMin, inputMax] = inputRange;\n const [outputMin, outputMax] = outputRange;\n\n if (result < inputMin) {\n if (extrapolateLeft === \"identity\") {\n return result;\n }\n\n if (extrapolateLeft === \"clamp\") {\n result = inputMin;\n } else if (extrapolateLeft === \"extend\") {\n // noop\n }\n }\n\n if (result > inputMax) {\n if (extrapolateRight === \"identity\") {\n return result;\n }\n\n if (extrapolateRight === \"clamp\") {\n result = inputMax;\n } else if (extrapolateRight === \"extend\") {\n // noop\n }\n }\n\n if (outputMin === outputMax) {\n return outputMin;\n }\n\n // Input Range\n result = (result - inputMin) / (inputMax - inputMin);\n\n // Easing\n result = easing(result);\n\n // Output Range\n result = result * (outputMax - outputMin) + outputMin;\n\n return result;\n}\n\nfunction findRange(input: number, inputRange: readonly number[]) {\n let i;\n for (i = 1; i < inputRange.length - 1; ++i) {\n if (inputRange[i] >= input) {\n break;\n }\n }\n\n return i - 1;\n}\n\nfunction checkValidInputRange(arr: readonly number[]) {\n for (let i = 1; i < arr.length; ++i) {\n if (!(arr[i] > arr[i - 1])) {\n throw new Error(\n `inputRange must be strictly monotonically non-decreasing but got [${arr.join(\n \",\"\n )}]`\n );\n }\n }\n}\n\nfunction checkInfiniteRange(name: string, arr: readonly number[]) {\n if (arr.length < 2) {\n throw new Error(name + \" must have at least 2 elements\");\n }\n\n for (const index in arr) {\n if (typeof arr[index] !== \"number\") {\n throw new Error(`${name} must contain only numbers`);\n }\n\n if (arr[index] === -Infinity || arr[index] === Infinity) {\n throw new Error(\n `${name} must contain only finite numbers, but got [${arr.join(\",\")}]`\n );\n }\n }\n}\n\nexport function interpolate(\n input: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n options?: {\n easing?: (input: number) => number;\n extrapolateLeft?: ExtrapolateType;\n extrapolateRight?: ExtrapolateType;\n }\n): number {\n if (typeof input === \"undefined\") {\n throw new Error(\"input can not be undefined\");\n }\n\n if (typeof inputRange === \"undefined\") {\n throw new Error(\"inputRange can not be undefined\");\n }\n\n if (typeof outputRange === \"undefined\") {\n throw new Error(\"outputRange can not be undefined\");\n }\n\n if (inputRange.length !== outputRange.length) {\n throw new Error(\n \"inputRange (\" +\n inputRange.length +\n \") and outputRange (\" +\n outputRange.length +\n \") must have the same length\"\n );\n }\n\n checkInfiniteRange(\"inputRange\", inputRange);\n checkInfiniteRange(\"outputRange\", outputRange);\n\n checkValidInputRange(inputRange);\n\n const easing = options?.easing ?? ((num: number): number => num);\n\n let extrapolateLeft: ExtrapolateType = \"extend\";\n if (options?.extrapolateLeft !== undefined) {\n // eslint-disable-next-line prefer-destructuring\n extrapolateLeft = options.extrapolateLeft;\n }\n\n let extrapolateRight: ExtrapolateType = \"extend\";\n if (options?.extrapolateRight !== undefined) {\n // eslint-disable-next-line prefer-destructuring\n extrapolateRight = options.extrapolateRight;\n }\n\n if (typeof input !== \"number\") {\n throw new TypeError(\"Cannot interpolate an input which is not a number\");\n }\n\n const range = findRange(input, inputRange);\n return interpolateFunction(\n input,\n [inputRange[range], inputRange[range + 1]],\n [outputRange[range], outputRange[range + 1]],\n {\n easing,\n extrapolateLeft,\n extrapolateRight,\n }\n );\n}\n"]}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import { mix } from "../../../renderer";
|
2
|
-
import { alphaf, blue, green, red, rgbaColor, Skia } from "../../../skia";
|
3
|
-
import { interpolate } from "./interpolate";
|
4
|
-
const CLAMP = {
|
5
|
-
extrapolateLeft: "clamp",
|
6
|
-
extrapolateRight: "clamp"
|
7
|
-
};
|
8
|
-
|
9
|
-
const interpolateColorsRGB = (value, inputRange, outputRange) => {
|
10
|
-
const r = interpolate(value, inputRange, outputRange.map(c => red(c)), CLAMP);
|
11
|
-
const g = interpolate(value, inputRange, outputRange.map(c => green(c)), CLAMP);
|
12
|
-
const b = interpolate(value, inputRange, outputRange.map(c => blue(c)), CLAMP);
|
13
|
-
const a = interpolate(value, inputRange, outputRange.map(c => alphaf(c)), CLAMP);
|
14
|
-
return rgbaColor(r, g, b, a);
|
15
|
-
};
|
16
|
-
|
17
|
-
export const interpolateColors = (value, inputRange, _outputRange) => {
|
18
|
-
const outputRange = _outputRange.map(cl => Skia.Color(cl));
|
19
|
-
|
20
|
-
return interpolateColorsRGB(value, inputRange, outputRange);
|
21
|
-
}; // This is fast. To be reconcilled with interpolateColors
|
22
|
-
// it looks like interpolateColors may not be working as expected
|
23
|
-
// these functions need to be tested more thoroughly on both platform
|
24
|
-
|
25
|
-
export const mixColors = (value, x, y) => {
|
26
|
-
const r = mix(value, red(x), red(y));
|
27
|
-
const g = mix(value, green(x), green(y));
|
28
|
-
const b = mix(value, blue(x), blue(y));
|
29
|
-
const a = mix(value, alphaf(x), alphaf(y));
|
30
|
-
return rgbaColor(r, g, b, a);
|
31
|
-
};
|
32
|
-
//# sourceMappingURL=interpolateColors.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["interpolateColors.ts"],"names":["mix","alphaf","blue","green","red","rgbaColor","Skia","interpolate","CLAMP","extrapolateLeft","extrapolateRight","interpolateColorsRGB","value","inputRange","outputRange","r","map","c","g","b","a","interpolateColors","_outputRange","cl","Color","mixColors","x","y"],"mappings":"AAAA,SAASA,GAAT,QAAoB,mBAApB;AAEA,SAASC,MAAT,EAAiBC,IAAjB,EAAuBC,KAAvB,EAA8BC,GAA9B,EAAmCC,SAAnC,EAA8CC,IAA9C,QAA0D,eAA1D;AAEA,SAASC,WAAT,QAA4B,eAA5B;AAEA,MAAMC,KAAK,GAAG;AACZC,EAAAA,eAAe,EAAE,OADL;AAEZC,EAAAA,gBAAgB,EAAE;AAFN,CAAd;;AAKA,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;AACH,QAAMC,CAAC,GAAGR,WAAW,CACnBK,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOb,GAAG,CAACa,CAAD,CAA1B,CAHmB,EAInBT,KAJmB,CAArB;AAMA,QAAMU,CAAC,GAAGX,WAAW,CACnBK,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOd,KAAK,CAACc,CAAD,CAA5B,CAHmB,EAInBT,KAJmB,CAArB;AAMA,QAAMW,CAAC,GAAGZ,WAAW,CACnBK,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOf,IAAI,CAACe,CAAD,CAA3B,CAHmB,EAInBT,KAJmB,CAArB;AAMA,QAAMY,CAAC,GAAGb,WAAW,CACnBK,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOhB,MAAM,CAACgB,CAAD,CAA7B,CAHmB,EAInBT,KAJmB,CAArB;AAMA,SAAOH,SAAS,CAACU,CAAD,EAAIG,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAhB;AACD,CA9BD;;AAgCA,OAAO,MAAMC,iBAAiB,GAAG,CAC/BT,KAD+B,EAE/BC,UAF+B,EAG/BS,YAH+B,KAI5B;AACH,QAAMR,WAAW,GAAGQ,YAAY,CAACN,GAAb,CAAkBO,EAAD,IAAQjB,IAAI,CAACkB,KAAL,CAAWD,EAAX,CAAzB,CAApB;;AACA,SAAOZ,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CAPM,C,CASP;AACA;AACA;;AACA,OAAO,MAAMW,SAAS,GAAG,CAACb,KAAD,EAAgBc,CAAhB,EAA2BC,CAA3B,KAAyC;AAChE,QAAMZ,CAAC,GAAGf,GAAG,CAACY,KAAD,EAAQR,GAAG,CAACsB,CAAD,CAAX,EAAgBtB,GAAG,CAACuB,CAAD,CAAnB,CAAb;AACA,QAAMT,CAAC,GAAGlB,GAAG,CAACY,KAAD,EAAQT,KAAK,CAACuB,CAAD,CAAb,EAAkBvB,KAAK,CAACwB,CAAD,CAAvB,CAAb;AACA,QAAMR,CAAC,GAAGnB,GAAG,CAACY,KAAD,EAAQV,IAAI,CAACwB,CAAD,CAAZ,EAAiBxB,IAAI,CAACyB,CAAD,CAArB,CAAb;AACA,QAAMP,CAAC,GAAGpB,GAAG,CAACY,KAAD,EAAQX,MAAM,CAACyB,CAAD,CAAd,EAAmBzB,MAAM,CAAC0B,CAAD,CAAzB,CAAb;AACA,SAAOtB,SAAS,CAACU,CAAD,EAAIG,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAhB;AACD,CANM","sourcesContent":["import { mix } from \"../../../renderer\";\nimport type { Color } from \"../../../skia\";\nimport { alphaf, blue, green, red, rgbaColor, Skia } from \"../../../skia\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: number[]\n) => {\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => red(c)),\n CLAMP\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => green(c)),\n CLAMP\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => blue(c)),\n CLAMP\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => alphaf(c)),\n CLAMP\n );\n return rgbaColor(r, g, b, a);\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\n// This is fast. To be reconcilled with interpolateColors\n// it looks like interpolateColors may not be working as expected\n// these functions need to be tested more thoroughly on both platform\nexport const mixColors = (value: number, x: number, y: number) => {\n const r = mix(value, red(x), red(y));\n const g = mix(value, green(x), green(y));\n const b = mix(value, blue(x), blue(y));\n const a = mix(value, alphaf(x), alphaf(y));\n return rgbaColor(r, g, b, a);\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["runSpring.ts"],"names":["runTiming","Spring","createSpringEasing","runSpring","value","toOrParams","config","callback","Config","Default"],"mappings":"AAMA,SAASA,SAAT,QAA0B,qBAA1B;AAEA,SAASC,MAAT,QAAuB,UAAvB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,KADuB,EAEvBC,UAFuB,EAGvBC,MAHuB,EAIvBC,QAJuB,KAKL;AAClB,SAAOP,SAAS,CACdI,KADc,EAEdC,UAFc,EAGdH,kBAAkB,CAACI,MAAD,aAACA,MAAD,cAACA,MAAD,GAAWL,MAAM,CAACO,MAAP,CAAcC,OAAzB,CAHJ,EAIdF,QAJc,CAAhB;AAMD,CAZM","sourcesContent":["import type { SkiaValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n SpringConfig,\n AnimationCallback,\n} from \"../types\";\nimport { runTiming } from \"../timing/runTiming\";\n\nimport { Spring } from \"./Spring\";\nimport { createSpringEasing } from \"./functions/spring\";\n\n/**\n * Creates a new animation on an existing value that will be driven by\n * an animation value. The value will be run from / to the value in\n * params and modified by the provided easing curve for the length of\n * the duration. When the value has reached its desired \"to\" value the\n * animation will be stopped.\n *\n * @param value The value to animate\n * @param toOrParams To value or Animation parameters\n * @param config Spring configuration\n * @returns an animation value that can be used to start/stop\n * the animation.\n */\nexport const runSpring = (\n value: SkiaValue<number>,\n toOrParams: number | AnimationParams,\n config?: SpringConfig,\n callback?: AnimationCallback\n): SkiaAnimation => {\n return runTiming(\n value,\n toOrParams,\n createSpringEasing(config ?? Spring.Config.Default),\n callback\n );\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["useSpring.ts"],"names":["useTiming","Spring","createSpringEasing","useSpring","toOrParams","config","callback","Config","Default"],"mappings":"AAMA,SAASA,SAAT,QAA0B,WAA1B;AAEA,SAASC,MAAT,QAAuB,UAAvB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAKvBN,SAAS,CACPI,UADO,EAEPF,kBAAkB,CAACG,MAAD,aAACA,MAAD,cAACA,MAAD,GAAWJ,MAAM,CAACM,MAAP,CAAcC,OAAzB,CAFX,EAGPF,QAHO,CALJ","sourcesContent":["import type { SkiaReadonlyValue } from \"../../types\";\nimport type {\n SpringConfig,\n AnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport { useTiming } from \"../timing\";\n\nimport { Spring } from \"./Spring\";\nimport { createSpringEasing } from \"./functions/spring\";\n\n/**\n * Creats a spring based animation value that will run whenever\n * the animation parameters change.\n * @param toOrParams\n * @param config\n * @returns\n */\nexport const useSpring = (\n toOrParams: number | AnimationParams,\n config?: SpringConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> =>\n useTiming(\n toOrParams,\n createSpringEasing(config ?? Spring.Config.Default),\n callback\n );\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["createTiming.ts"],"names":["ValueApi","timing","createTiming","params","value","callback","resolvedParams","from","current","animationFunction","t","state","nextState","duration","easing","loop","yoyo","finished","to","createAnimation"],"mappings":"AAMA,SAASA,QAAT,QAAyB,WAAzB;AAEA,SAASC,MAAT,QAAuB,aAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,YAAY,GAAG,CAC1BC,MAD0B,EAE1BC,KAF0B,EAG1BC,QAH0B,KAIvB;AAAA;;AACH;AACA;AACA,QAAMC,cAAc,GAAG,EACrB,GAAGH,MADkB;AAErBI,IAAAA,IAAI,0BAAEJ,MAAM,CAACI,IAAT,uDAAiBH,KAAjB,aAAiBA,KAAjB,uBAAiBA,KAAK,CAAEI,OAAxB,uCAAmC;AAFlB,GAAvB,CAHG,CAQH;;AACA,QAAMC,iBAAiB,GAAG,CAACC,CAAD,EAAYC,KAAZ,KAAkD;AAAA;;AAC1E;AACA,UAAMC,SAAS,GAAGX,MAAM,CACtBS,CADsB,EAEtBP,MAAM,CAACU,QAFe,EAGtBV,MAAM,CAACW,MAHe,kBAItBX,MAAM,CAACY,IAJe,uDAIP,KAJO,kBAKtBZ,MAAM,CAACa,IALe,uDAKP,KALO,EAMtBL,KANsB,aAMtBA,KANsB,cAMtBA,KANsB,GAMb;AAAEH,MAAAA,OAAO,EAAEL,MAAM,CAACI,IAAlB;AAAyBU,MAAAA,QAAQ,EAAE;AAAnC,KANa,CAAxB;AAQA,UAAMT,OAAO,GACXI,SAAS,CAACJ,OAAV,IAAqBF,cAAc,CAACY,EAAf,GAAoBZ,cAAc,CAACC,IAAxD,IACAD,cAAc,CAACC,IAFjB;;AAGA,QAAIF,QAAQ,IAAIO,SAAS,CAACK,QAAV,KAAuB,IAAvC,EAA6C;AAC3CZ,MAAAA,QAAQ,CAACG,OAAD,CAAR;AACD;;AACD,WAAO,EACL,GAAGI,SADE;AAELJ,MAAAA;AAFK,KAAP;AAID,GApBD,CATG,CA+BH;;;AACA,SAAOR,QAAQ,CAACmB,eAAT,CAAyBV,iBAAzB,CAAP;AACD,CArCM","sourcesContent":["import type {\n TimingConfig,\n RequiredAnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport type { AnimationState, SkiaValue } from \"../../types\";\nimport { ValueApi } from \"../../api\";\n\nimport { timing } from \"./functions\";\n\n/**\n * Creates an animation that is driven by a clock value.\n * The value will be run from / to the value in params and modified\n * by the provided easing curve for the length of the duration. When\n * the value has reached its desired \"to\" value the animation\n * will be stopped. If loop is set to true, the animation will continue\n * to run until stopped.\n *\n * @param params Animation parameters\n * @param config Spring or timing configuration\n * @param value Optional value that the animation will update\n * @params an animation value that can be used to start/stop\n * the animation.\n */\nexport const createTiming = (\n params: RequiredAnimationParams & Required<TimingConfig>,\n value?: SkiaValue<number>,\n callback?: AnimationCallback\n) => {\n // Update from to be either the declared from value,\n // the current value of the value or zero\n const resolvedParams = {\n ...params,\n from: params.from ?? value?.current ?? 0,\n };\n\n // Update function for the animation value\n const animationFunction = (t: number, state: AnimationState | undefined) => {\n // Update the input value using the provided update function\n const nextState = timing(\n t,\n params.duration,\n params.easing,\n params.loop ?? false,\n params.yoyo ?? false,\n state ?? { current: params.from!, finished: false }\n );\n const current =\n nextState.current * (resolvedParams.to - resolvedParams.from!) +\n resolvedParams.from!;\n if (callback && nextState.finished === true) {\n callback(current);\n }\n return {\n ...nextState,\n current,\n };\n };\n\n // Create animation value\n return ValueApi.createAnimation(animationFunction);\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["getResolvedParams.ts"],"names":["DefaultParameters","to","loop","yoyo","immediate","DefaultTimingConfig","duration","easing","t","getResolvedParams","toOrParams","config","resolvedParameters","from","resolvedConfig"],"mappings":"AAMA,MAAMA,iBAAiB,GAAG;AACxBC,EAAAA,EAAE,EAAE,CADoB;AAExBC,EAAAA,IAAI,EAAE,KAFkB;AAGxBC,EAAAA,IAAI,EAAE,KAHkB;AAIxBC,EAAAA,SAAS,EAAE;AAJa,CAA1B;AAOA,MAAMC,mBAAmB,GAAG;AAC1BC,EAAAA,QAAQ,EAAE,IADgB;AAE1BC,EAAAA,MAAM,EAAGC,CAAD,IAAeA;AAFG,CAA5B;AAKA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,iBAAiB,GAAG,CAC/BC,UAD+B,EAE/BC,MAF+B,KAGsB;AACrD,MAAIC,kBAA2C,GAAG,EAChD,GAAGZ;AAD6C,GAAlD;;AAIA,MAAI,OAAOU,UAAP,KAAsB,QAA1B,EAAoC;AAClCE,IAAAA,kBAAkB,CAACX,EAAnB,GAAwBS,UAAxB;AACD,GAFD,MAEO;AAAA;;AACLE,IAAAA,kBAAkB,GAAG;AACnBC,MAAAA,IAAI,sBAAEH,UAAU,CAACG,IAAb,+DAAqBD,kBAAkB,CAACC,IADzB;AAEnBZ,MAAAA,EAAE,oBAAES,UAAU,CAACT,EAAb,2DAAmBW,kBAAkB,CAACX,EAFrB;AAGnBC,MAAAA,IAAI,sBAAEQ,UAAU,CAACR,IAAb,+DAAqBU,kBAAkB,CAACV,IAHzB;AAInBC,MAAAA,IAAI,sBAAEO,UAAU,CAACP,IAAb,+DAAqBS,kBAAkB,CAACT;AAJzB,KAArB;AAMD;;AAED,QAAMW,cAAsC,GAAG,EAAE,GAAGT;AAAL,GAA/C;;AACA,MAAIM,MAAJ,EAAY;AAAA;;AACVG,IAAAA,cAAc,CAACR,QAAf,GAA0BK,MAAM,CAACL,QAAjC;AACAQ,IAAAA,cAAc,CAACP,MAAf,qBAAwBI,MAAM,CAACJ,MAA/B,2DAA2CC,CAAD,IAAOA,CAAjD;AACD;;AAED,SAAO,EAAE,GAAGI,kBAAL;AAAyB,OAAGE;AAA5B,GAAP;AACD,CA1BM","sourcesContent":["import type {\n RequiredAnimationParams,\n AnimationParams,\n TimingConfig,\n} from \"../../types\";\n\nconst DefaultParameters = {\n to: 1,\n loop: false,\n yoyo: false,\n immediate: true,\n};\n\nconst DefaultTimingConfig = {\n duration: 1000,\n easing: (t: number) => t,\n};\n\n/**\n * Resolves parameters from optional values to a single object\n * @param toOrParams Params or to value\n * @param config timing/spring configuration\n */\nexport const getResolvedParams = (\n toOrParams: number | AnimationParams,\n config?: TimingConfig\n): RequiredAnimationParams & Required<TimingConfig> => {\n let resolvedParameters: RequiredAnimationParams = {\n ...DefaultParameters,\n };\n\n if (typeof toOrParams === \"number\") {\n resolvedParameters.to = toOrParams;\n } else {\n resolvedParameters = {\n from: toOrParams.from ?? resolvedParameters.from,\n to: toOrParams.to ?? resolvedParameters.to,\n loop: toOrParams.loop ?? resolvedParameters.loop,\n yoyo: toOrParams.yoyo ?? resolvedParameters.yoyo,\n };\n }\n\n const resolvedConfig: Required<TimingConfig> = { ...DefaultTimingConfig };\n if (config) {\n resolvedConfig.duration = config.duration;\n resolvedConfig.easing = config.easing ?? ((t) => t);\n }\n\n return { ...resolvedParameters, ...resolvedConfig };\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["runTiming.ts"],"names":["getResolvedParams","createTiming","runTiming","value","toOrParams","config","callback","resolvedParameters","animation"],"mappings":"AAOA,SAASA,iBAAT,QAAkC,aAAlC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,KADuB,EAEvBC,UAFuB,EAGvBC,MAHuB,EAIvBC,QAJuB,KAKL;AAClB,QAAMC,kBAAkB,GAAGP,iBAAiB,CAACI,UAAD,EAAaC,MAAb,CAA5C;AACA,QAAMG,SAAS,GAAGP,YAAY,CAACM,kBAAD,EAAqBJ,KAArB,EAA4BG,QAA5B,CAA9B;AACAH,EAAAA,KAAK,CAACK,SAAN,GAAkBA,SAAlB;AACA,SAAOA,SAAP;AACD,CAVM","sourcesContent":["import type { SkiaValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n/**\n * Creates a new animation on an existing value that will be driven by\n * an animation value. The value will be run from / to the value in\n * params and modified by the provided easing curve for the length of\n * the duration. When the value has reached its desired \"to\" value the\n * animation will be stopped.\n *\n * @param value The value to animate\n * @param toOrParams To value or Animation parameters\n * @param config Spring or timing configuration\n * @returns an animation value that can be used to start/stop\n * the animation.\n */\nexport const runTiming = (\n value: SkiaValue<number>,\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaAnimation => {\n const resolvedParameters = getResolvedParams(toOrParams, config);\n const animation = createTiming(resolvedParameters, value, callback);\n value.animation = animation;\n return animation;\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["useTiming.ts"],"names":["useEffect","useMemo","useRef","useValue","getResolvedParams","createTiming","useTiming","toOrParams","config","callback","prevCfgRef","resolvedParameters","nextParams","equals","current","value","from","prevAnimationRef","prevParamsRef","animation","undefined","a","b","JSON","stringify"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,OAApB,EAA6BC,MAA7B,QAA2C,OAA3C;AAQA,SAASC,QAAT,QAAyB,sBAAzB;AAEA,SAASC,iBAAT,QAAkC,aAAlC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAIO;AAAA;;AAC9B;AACA;AACA,QAAMC,UAAU,GAAGR,MAAM,EAAzB;AACA,QAAMS,kBAAkB,GAAGV,OAAO,CAAC,MAAM;AACvC,UAAMW,UAAU,GAAGR,iBAAiB,CAACG,UAAD,EAAaC,MAAb,CAApC;;AACA,QAAI,CAACK,MAAM,CAACH,UAAU,CAACI,OAAZ,EAAqBF,UAArB,CAAX,EAA6C;AAC3CF,MAAAA,UAAU,CAACI,OAAX,GAAqBF,UAArB;AACD;;AACD,WAAOF,UAAU,CAACI,OAAlB;AACD,GANiC,EAM/B,CAACN,MAAD,EAASD,UAAT,CAN+B,CAAlC,CAJ8B,CAY9B;;AACA,QAAMQ,KAAK,GAAGZ,QAAQ,0BAACQ,kBAAkB,CAACK,IAApB,yEAA4B,CAA5B,CAAtB,CAb8B,CAe9B;AACA;;AACA,QAAMC,gBAAgB,GAAGf,MAAM,EAA/B;AACA,QAAMgB,aAAa,GAAGhB,MAAM,EAA5B;AACA,QAAMiB,SAAS,GAAGlB,OAAO,CAAC,MAAM;AAC9B,QAAI,CAACY,MAAM,CAACK,aAAa,CAACJ,OAAf,EAAwBH,kBAAxB,CAAX,EAAwD;AACtDO,MAAAA,aAAa,CAACJ,OAAd,GAAwBH,kBAAxB;AACAM,MAAAA,gBAAgB,CAACH,OAAjB,GAA2BT,YAAY,CACrCM,kBADqC,EAErCI,KAFqC,EAGrCN,QAHqC,CAAvC;AAKD;;AACD,WAAOQ,gBAAgB,CAACH,OAAxB;AACD,GAVwB,EAUtB,CAACL,QAAD,EAAWE,kBAAX,EAA+BI,KAA/B,CAVsB,CAAzB,CAnB8B,CA+B9B;;AACAf,EAAAA,SAAS,CAAC,MAAM;AACde,IAAAA,KAAK,CAACI,SAAN,GAAkBA,SAAlB;AACA,WAAO,MAAOJ,KAAK,CAACI,SAAN,GAAkBC,SAAhC;AACD,GAHQ,EAGN,CAACD,SAAD,EAAYJ,KAAZ,CAHM,CAAT,CAhC8B,CAqC9B;;AACA,SAAOA,KAAP;AACD,CA3CM;;AA6CP,MAAMF,MAAM,GAAG,CAASQ,CAAT,EAAgBC,CAAhB,KAA0B;AACvC,SAAOC,IAAI,CAACC,SAAL,CAAeH,CAAf,MAAsBE,IAAI,CAACC,SAAL,CAAeF,CAAf,CAA7B;AACD,CAFD","sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\n\nimport type { SkiaReadonlyValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\nimport { useValue } from \"../../hooks/useValue\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n\n/**\n * Creats an animation value that will run whenever\n * the animation parameters change. The animation start immediately.\n * @param toOrParams\n * @param config\n * @returns A value that is animated\n */\nexport const useTiming = (\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> => {\n // Resolve parameters - keep a cached version to avoid\n // unnecesary re-renders.\n const prevCfgRef = useRef<ReturnType<typeof getResolvedParams>>();\n const resolvedParameters = useMemo(() => {\n const nextParams = getResolvedParams(toOrParams, config);\n if (!equals(prevCfgRef.current, nextParams)) {\n prevCfgRef.current = nextParams;\n }\n return prevCfgRef.current!;\n }, [config, toOrParams]);\n\n // Create value\n const value = useValue(resolvedParameters.from ?? 0);\n\n // Create timing animation - keep a cached version to avoid\n // uneccessary recreation of animations\n const prevAnimationRef = useRef<SkiaAnimation>();\n const prevParamsRef = useRef<typeof resolvedParameters>();\n const animation = useMemo(() => {\n if (!equals(prevParamsRef.current, resolvedParameters)) {\n prevParamsRef.current = resolvedParameters;\n prevAnimationRef.current = createTiming(\n resolvedParameters,\n value,\n callback\n );\n }\n return prevAnimationRef.current!;\n }, [callback, resolvedParameters, value]);\n\n // Run animation on the value - and stop it on unmount\n useEffect(() => {\n value.animation = animation;\n return () => (value.animation = undefined);\n }, [animation, value]);\n\n // Return the value that is animated\n return value;\n};\n\nconst equals = <T1, T2>(a: T1, b: T2) => {\n return JSON.stringify(a) === JSON.stringify(b);\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
declare type ExtrapolateType = "extend" | "identity" | "clamp";
|
2
|
-
export declare function interpolate(input: number, inputRange: readonly number[], outputRange: readonly number[], options?: {
|
3
|
-
easing?: (input: number) => number;
|
4
|
-
extrapolateLeft?: ExtrapolateType;
|
5
|
-
extrapolateRight?: ExtrapolateType;
|
6
|
-
}): number;
|
7
|
-
export {};
|
@@ -1,169 +0,0 @@
|
|
1
|
-
// eslint-disable-next-line max-len
|
2
|
-
// Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js
|
3
|
-
|
4
|
-
type ExtrapolateType = "extend" | "identity" | "clamp";
|
5
|
-
|
6
|
-
function interpolateFunction(
|
7
|
-
input: number,
|
8
|
-
inputRange: [number, number],
|
9
|
-
outputRange: [number, number],
|
10
|
-
options: {
|
11
|
-
easing: (input: number) => number;
|
12
|
-
extrapolateLeft: ExtrapolateType;
|
13
|
-
extrapolateRight: ExtrapolateType;
|
14
|
-
}
|
15
|
-
): number {
|
16
|
-
const { extrapolateLeft, extrapolateRight, easing } = options;
|
17
|
-
|
18
|
-
let result = input;
|
19
|
-
const [inputMin, inputMax] = inputRange;
|
20
|
-
const [outputMin, outputMax] = outputRange;
|
21
|
-
|
22
|
-
if (result < inputMin) {
|
23
|
-
if (extrapolateLeft === "identity") {
|
24
|
-
return result;
|
25
|
-
}
|
26
|
-
|
27
|
-
if (extrapolateLeft === "clamp") {
|
28
|
-
result = inputMin;
|
29
|
-
} else if (extrapolateLeft === "extend") {
|
30
|
-
// noop
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
if (result > inputMax) {
|
35
|
-
if (extrapolateRight === "identity") {
|
36
|
-
return result;
|
37
|
-
}
|
38
|
-
|
39
|
-
if (extrapolateRight === "clamp") {
|
40
|
-
result = inputMax;
|
41
|
-
} else if (extrapolateRight === "extend") {
|
42
|
-
// noop
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
if (outputMin === outputMax) {
|
47
|
-
return outputMin;
|
48
|
-
}
|
49
|
-
|
50
|
-
// Input Range
|
51
|
-
result = (result - inputMin) / (inputMax - inputMin);
|
52
|
-
|
53
|
-
// Easing
|
54
|
-
result = easing(result);
|
55
|
-
|
56
|
-
// Output Range
|
57
|
-
result = result * (outputMax - outputMin) + outputMin;
|
58
|
-
|
59
|
-
return result;
|
60
|
-
}
|
61
|
-
|
62
|
-
function findRange(input: number, inputRange: readonly number[]) {
|
63
|
-
let i;
|
64
|
-
for (i = 1; i < inputRange.length - 1; ++i) {
|
65
|
-
if (inputRange[i] >= input) {
|
66
|
-
break;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
return i - 1;
|
71
|
-
}
|
72
|
-
|
73
|
-
function checkValidInputRange(arr: readonly number[]) {
|
74
|
-
for (let i = 1; i < arr.length; ++i) {
|
75
|
-
if (!(arr[i] > arr[i - 1])) {
|
76
|
-
throw new Error(
|
77
|
-
`inputRange must be strictly monotonically non-decreasing but got [${arr.join(
|
78
|
-
","
|
79
|
-
)}]`
|
80
|
-
);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
function checkInfiniteRange(name: string, arr: readonly number[]) {
|
86
|
-
if (arr.length < 2) {
|
87
|
-
throw new Error(name + " must have at least 2 elements");
|
88
|
-
}
|
89
|
-
|
90
|
-
for (const index in arr) {
|
91
|
-
if (typeof arr[index] !== "number") {
|
92
|
-
throw new Error(`${name} must contain only numbers`);
|
93
|
-
}
|
94
|
-
|
95
|
-
if (arr[index] === -Infinity || arr[index] === Infinity) {
|
96
|
-
throw new Error(
|
97
|
-
`${name} must contain only finite numbers, but got [${arr.join(",")}]`
|
98
|
-
);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
export function interpolate(
|
104
|
-
input: number,
|
105
|
-
inputRange: readonly number[],
|
106
|
-
outputRange: readonly number[],
|
107
|
-
options?: {
|
108
|
-
easing?: (input: number) => number;
|
109
|
-
extrapolateLeft?: ExtrapolateType;
|
110
|
-
extrapolateRight?: ExtrapolateType;
|
111
|
-
}
|
112
|
-
): number {
|
113
|
-
if (typeof input === "undefined") {
|
114
|
-
throw new Error("input can not be undefined");
|
115
|
-
}
|
116
|
-
|
117
|
-
if (typeof inputRange === "undefined") {
|
118
|
-
throw new Error("inputRange can not be undefined");
|
119
|
-
}
|
120
|
-
|
121
|
-
if (typeof outputRange === "undefined") {
|
122
|
-
throw new Error("outputRange can not be undefined");
|
123
|
-
}
|
124
|
-
|
125
|
-
if (inputRange.length !== outputRange.length) {
|
126
|
-
throw new Error(
|
127
|
-
"inputRange (" +
|
128
|
-
inputRange.length +
|
129
|
-
") and outputRange (" +
|
130
|
-
outputRange.length +
|
131
|
-
") must have the same length"
|
132
|
-
);
|
133
|
-
}
|
134
|
-
|
135
|
-
checkInfiniteRange("inputRange", inputRange);
|
136
|
-
checkInfiniteRange("outputRange", outputRange);
|
137
|
-
|
138
|
-
checkValidInputRange(inputRange);
|
139
|
-
|
140
|
-
const easing = options?.easing ?? ((num: number): number => num);
|
141
|
-
|
142
|
-
let extrapolateLeft: ExtrapolateType = "extend";
|
143
|
-
if (options?.extrapolateLeft !== undefined) {
|
144
|
-
// eslint-disable-next-line prefer-destructuring
|
145
|
-
extrapolateLeft = options.extrapolateLeft;
|
146
|
-
}
|
147
|
-
|
148
|
-
let extrapolateRight: ExtrapolateType = "extend";
|
149
|
-
if (options?.extrapolateRight !== undefined) {
|
150
|
-
// eslint-disable-next-line prefer-destructuring
|
151
|
-
extrapolateRight = options.extrapolateRight;
|
152
|
-
}
|
153
|
-
|
154
|
-
if (typeof input !== "number") {
|
155
|
-
throw new TypeError("Cannot interpolate an input which is not a number");
|
156
|
-
}
|
157
|
-
|
158
|
-
const range = findRange(input, inputRange);
|
159
|
-
return interpolateFunction(
|
160
|
-
input,
|
161
|
-
[inputRange[range], inputRange[range + 1]],
|
162
|
-
[outputRange[range], outputRange[range + 1]],
|
163
|
-
{
|
164
|
-
easing,
|
165
|
-
extrapolateLeft,
|
166
|
-
extrapolateRight,
|
167
|
-
}
|
168
|
-
);
|
169
|
-
}
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import { mix } from "../../../renderer";
|
2
|
-
import type { Color } from "../../../skia";
|
3
|
-
import { alphaf, blue, green, red, rgbaColor, Skia } from "../../../skia";
|
4
|
-
|
5
|
-
import { interpolate } from "./interpolate";
|
6
|
-
|
7
|
-
const CLAMP = {
|
8
|
-
extrapolateLeft: "clamp",
|
9
|
-
extrapolateRight: "clamp",
|
10
|
-
} as const;
|
11
|
-
|
12
|
-
const interpolateColorsRGB = (
|
13
|
-
value: number,
|
14
|
-
inputRange: number[],
|
15
|
-
outputRange: number[]
|
16
|
-
) => {
|
17
|
-
const r = interpolate(
|
18
|
-
value,
|
19
|
-
inputRange,
|
20
|
-
outputRange.map((c) => red(c)),
|
21
|
-
CLAMP
|
22
|
-
);
|
23
|
-
const g = interpolate(
|
24
|
-
value,
|
25
|
-
inputRange,
|
26
|
-
outputRange.map((c) => green(c)),
|
27
|
-
CLAMP
|
28
|
-
);
|
29
|
-
const b = interpolate(
|
30
|
-
value,
|
31
|
-
inputRange,
|
32
|
-
outputRange.map((c) => blue(c)),
|
33
|
-
CLAMP
|
34
|
-
);
|
35
|
-
const a = interpolate(
|
36
|
-
value,
|
37
|
-
inputRange,
|
38
|
-
outputRange.map((c) => alphaf(c)),
|
39
|
-
CLAMP
|
40
|
-
);
|
41
|
-
return rgbaColor(r, g, b, a);
|
42
|
-
};
|
43
|
-
|
44
|
-
export const interpolateColors = (
|
45
|
-
value: number,
|
46
|
-
inputRange: number[],
|
47
|
-
_outputRange: Color[]
|
48
|
-
) => {
|
49
|
-
const outputRange = _outputRange.map((cl) => Skia.Color(cl));
|
50
|
-
return interpolateColorsRGB(value, inputRange, outputRange);
|
51
|
-
};
|
52
|
-
|
53
|
-
// This is fast. To be reconcilled with interpolateColors
|
54
|
-
// it looks like interpolateColors may not be working as expected
|
55
|
-
// these functions need to be tested more thoroughly on both platform
|
56
|
-
export const mixColors = (value: number, x: number, y: number) => {
|
57
|
-
const r = mix(value, red(x), red(y));
|
58
|
-
const g = mix(value, green(x), green(y));
|
59
|
-
const b = mix(value, blue(x), blue(y));
|
60
|
-
const a = mix(value, alphaf(x), alphaf(y));
|
61
|
-
return rgbaColor(r, g, b, a);
|
62
|
-
};
|