@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.
Files changed (423) hide show
  1. package/android/CMakeLists.txt +3 -0
  2. package/android/build.gradle +1 -1
  3. package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +5 -5
  4. package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +4 -4
  5. package/cpp/api/JsiSkApi.h +3 -1
  6. package/cpp/api/JsiSkCanvas.h +1 -1
  7. package/cpp/api/JsiSkColor.h +41 -7
  8. package/cpp/api/JsiSkColorFilterFactory.h +2 -1
  9. package/cpp/api/JsiSkImageFilter.h +0 -2
  10. package/cpp/api/JsiSkImageFilterFactory.h +37 -17
  11. package/cpp/api/JsiSkMatrix.h +44 -2
  12. package/cpp/api/JsiSkPaint.h +4 -7
  13. package/cpp/api/JsiSkRuntimeEffect.h +7 -0
  14. package/cpp/api/JsiSkRuntimeEffectFactory.h +3 -2
  15. package/cpp/api/JsiSkRuntimeShaderBuilder.h +70 -0
  16. package/cpp/api/JsiSkShaderFactory.h +2 -2
  17. package/cpp/api/JsiSkVertices.h +1 -1
  18. package/cpp/api/third_party/CSSColorParser.cpp +194 -0
  19. package/cpp/api/third_party/CSSColorParser.h +1 -191
  20. package/cpp/jsi/JsiSimpleValueWrapper.h +108 -0
  21. package/cpp/rnskia/RNSkAnimation.h +0 -2
  22. package/cpp/rnskia/RNSkDrawView.cpp +10 -13
  23. package/cpp/rnskia/RNSkDrawView.h +2 -2
  24. package/cpp/rnskia/RNSkValueApi.h +6 -2
  25. package/cpp/rnskia/values/RNSkClockValue.h +2 -2
  26. package/cpp/rnskia/values/RNSkDerivedValue.h +12 -5
  27. package/cpp/rnskia/values/RNSkReadonlyValue.h +14 -12
  28. package/cpp/rnskia/values/RNSkValue.h +8 -3
  29. package/ios/RNSkia-iOS/PlatformContext.h +30 -4
  30. package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +4 -4
  31. package/ios/RNSkia-iOS/SkiaDrawView.mm +9 -13
  32. package/lib/commonjs/{values/animation → animation}/decay/decay.js +0 -0
  33. package/lib/commonjs/{values/animation → animation}/decay/decay.js.map +0 -0
  34. package/lib/commonjs/{values/animation → animation}/decay/index.js +0 -0
  35. package/lib/commonjs/{values/animation → animation}/decay/index.js.map +0 -0
  36. package/lib/commonjs/{values/animation → animation}/decay/runDecay.js +1 -1
  37. package/lib/commonjs/animation/decay/runDecay.js.map +1 -0
  38. package/lib/commonjs/{values/animation → animation}/decay/types.js +0 -0
  39. package/lib/commonjs/{values/animation → animation}/decay/types.js.map +0 -0
  40. package/lib/commonjs/{values/animation → animation}/functions/index.js +0 -0
  41. package/lib/commonjs/{values/animation → animation}/functions/index.js.map +0 -0
  42. package/lib/commonjs/animation/functions/interpolate.js +141 -0
  43. package/lib/commonjs/animation/functions/interpolate.js.map +1 -0
  44. package/lib/commonjs/animation/functions/interpolateColors.js +39 -0
  45. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -0
  46. package/lib/commonjs/{values/animation → animation}/index.js +0 -0
  47. package/lib/commonjs/{values/animation → animation}/index.js.map +0 -0
  48. package/lib/commonjs/{values/animation → animation}/spring/Spring.js +0 -0
  49. package/lib/commonjs/{values/animation → animation}/spring/Spring.js.map +0 -0
  50. package/lib/commonjs/{values/animation → animation}/spring/functions/index.js +0 -0
  51. package/lib/commonjs/{values/animation → animation}/spring/functions/index.js.map +0 -0
  52. package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js +0 -0
  53. package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js.map +0 -0
  54. package/lib/commonjs/{values/animation → animation}/spring/index.js +0 -0
  55. package/lib/commonjs/{values/animation → animation}/spring/index.js.map +0 -0
  56. package/lib/commonjs/{values/animation → animation}/spring/runSpring.js +0 -0
  57. package/lib/commonjs/animation/spring/runSpring.js.map +1 -0
  58. package/lib/commonjs/{values/animation → animation}/spring/types.js +0 -0
  59. package/lib/commonjs/{values/animation → animation}/spring/types.js.map +0 -0
  60. package/lib/commonjs/{values/animation → animation}/spring/useSpring.js +0 -0
  61. package/lib/commonjs/animation/spring/useSpring.js.map +1 -0
  62. package/lib/commonjs/{values/animation → animation}/timing/Easing.js +0 -0
  63. package/lib/commonjs/{values/animation → animation}/timing/Easing.js.map +0 -0
  64. package/lib/commonjs/{values/animation → animation}/timing/createTiming.js +1 -1
  65. package/lib/commonjs/animation/timing/createTiming.js.map +1 -0
  66. package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js +0 -0
  67. package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
  68. package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js +3 -3
  69. package/lib/commonjs/animation/timing/functions/getResolvedParams.js.map +1 -0
  70. package/lib/commonjs/{values/animation → animation}/timing/functions/index.js +0 -0
  71. package/lib/commonjs/{values/animation → animation}/timing/functions/index.js.map +0 -0
  72. package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js +0 -0
  73. package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js.map +1 -1
  74. package/lib/commonjs/{values/animation → animation}/timing/functions/types.js +0 -0
  75. package/lib/commonjs/{values/animation → animation}/timing/functions/types.js.map +0 -0
  76. package/lib/commonjs/{values/animation → animation}/timing/index.js +0 -0
  77. package/lib/commonjs/{values/animation → animation}/timing/index.js.map +0 -0
  78. package/lib/commonjs/{values/animation → animation}/timing/runTiming.js +0 -0
  79. package/lib/commonjs/animation/timing/runTiming.js.map +1 -0
  80. package/lib/commonjs/{values/animation → animation}/timing/useLoop.js +0 -0
  81. package/lib/commonjs/{values/animation → animation}/timing/useLoop.js.map +0 -0
  82. package/lib/commonjs/{values/animation → animation}/timing/useTiming.js +1 -1
  83. package/lib/commonjs/animation/timing/useTiming.js.map +1 -0
  84. package/lib/commonjs/{values/animation → animation}/types.js +0 -0
  85. package/lib/commonjs/{values/animation → animation}/types.js.map +0 -0
  86. package/lib/commonjs/index.js +13 -0
  87. package/lib/commonjs/index.js.map +1 -1
  88. package/lib/commonjs/renderer/Canvas.js +14 -5
  89. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  90. package/lib/commonjs/renderer/components/colorFilters/BlendColor.js.map +1 -1
  91. package/lib/commonjs/renderer/components/colorFilters/Lerp.js +1 -1
  92. package/lib/commonjs/renderer/components/colorFilters/Lerp.js.map +1 -1
  93. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +4 -2
  94. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  95. package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js +37 -0
  96. package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
  97. package/lib/commonjs/renderer/components/imageFilters/index.js +13 -0
  98. package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
  99. package/lib/commonjs/renderer/components/shaders/Gradient.js +1 -1
  100. package/lib/commonjs/renderer/components/shaders/Gradient.js.map +1 -1
  101. package/lib/commonjs/renderer/components/shaders/Shader.js +2 -2
  102. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  103. package/lib/commonjs/renderer/processors/Circles.js +3 -2
  104. package/lib/commonjs/renderer/processors/Circles.js.map +1 -1
  105. package/lib/commonjs/renderer/processors/Font.js +1 -1
  106. package/lib/commonjs/renderer/processors/Font.js.map +1 -1
  107. package/lib/commonjs/renderer/processors/Rects.js +11 -21
  108. package/lib/commonjs/renderer/processors/Rects.js.map +1 -1
  109. package/lib/commonjs/renderer/processors/math/Matrix3.js +42 -63
  110. package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
  111. package/lib/commonjs/renderer/processors/math/Vector.js +4 -5
  112. package/lib/commonjs/renderer/processors/math/Vector.js.map +1 -1
  113. package/lib/commonjs/skia/Color.js +14 -38
  114. package/lib/commonjs/skia/Color.js.map +1 -1
  115. package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  116. package/lib/commonjs/skia/Matrix.js.map +1 -1
  117. package/lib/commonjs/skia/Shader/useShader.js +4 -1
  118. package/lib/commonjs/skia/Shader/useShader.js.map +1 -1
  119. package/lib/commonjs/skia/Skia.js +3 -45
  120. package/lib/commonjs/skia/Skia.js.map +1 -1
  121. package/lib/commonjs/skia/SkiaApi.js +4 -0
  122. package/lib/commonjs/skia/SkiaApi.js.map +1 -0
  123. package/lib/commonjs/values/api.js +4 -6
  124. package/lib/commonjs/values/api.js.map +1 -1
  125. package/lib/commonjs/values/api.web.js +18 -0
  126. package/lib/commonjs/values/api.web.js.map +1 -0
  127. package/lib/commonjs/values/index.js +0 -13
  128. package/lib/commonjs/values/index.js.map +1 -1
  129. package/lib/commonjs/values/web/RNSkAnimation.js +46 -0
  130. package/lib/commonjs/values/web/RNSkAnimation.js.map +1 -0
  131. package/lib/commonjs/values/web/RNSkClockValue.js +75 -0
  132. package/lib/commonjs/values/web/RNSkClockValue.js.map +1 -0
  133. package/lib/commonjs/values/web/RNSkDerivedValue.js +51 -0
  134. package/lib/commonjs/values/web/RNSkDerivedValue.js.map +1 -0
  135. package/lib/commonjs/values/web/RNSkReadonlyValue.js +45 -0
  136. package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -0
  137. package/lib/commonjs/values/web/RNSkValue.js +73 -0
  138. package/lib/commonjs/values/web/RNSkValue.js.map +1 -0
  139. package/lib/commonjs/values/web/api.js +31 -0
  140. package/lib/commonjs/values/web/api.js.map +1 -0
  141. package/lib/commonjs/values/web/index.js +19 -0
  142. package/lib/commonjs/values/web/index.js.map +1 -0
  143. package/lib/commonjs/views/SkiaView.js +13 -10
  144. package/lib/commonjs/views/SkiaView.js.map +1 -1
  145. package/lib/commonjs/views/api.js +11 -0
  146. package/lib/commonjs/views/api.js.map +1 -0
  147. package/lib/commonjs/views/types.js.map +1 -1
  148. package/lib/module/{values/animation → animation}/decay/decay.js +0 -0
  149. package/lib/module/{values/animation → animation}/decay/decay.js.map +0 -0
  150. package/lib/module/{values/animation → animation}/decay/index.js +0 -0
  151. package/lib/module/{values/animation → animation}/decay/index.js.map +0 -0
  152. package/lib/module/{values/animation → animation}/decay/runDecay.js +1 -1
  153. package/lib/module/animation/decay/runDecay.js.map +1 -0
  154. package/lib/module/{values/animation → animation}/decay/types.js +0 -0
  155. package/lib/module/{values/animation → animation}/decay/types.js.map +0 -0
  156. package/lib/module/{values/animation → animation}/functions/index.js +0 -0
  157. package/lib/module/{values/animation → animation}/functions/index.js.map +0 -0
  158. package/lib/module/animation/functions/interpolate.js +132 -0
  159. package/lib/module/animation/functions/interpolate.js.map +1 -0
  160. package/lib/module/animation/functions/interpolateColors.js +23 -0
  161. package/lib/module/animation/functions/interpolateColors.js.map +1 -0
  162. package/lib/module/{values/animation → animation}/index.js +0 -0
  163. package/lib/module/{values/animation → animation}/index.js.map +0 -0
  164. package/lib/module/{values/animation → animation}/spring/Spring.js +0 -0
  165. package/lib/module/{values/animation → animation}/spring/Spring.js.map +0 -0
  166. package/lib/module/{values/animation → animation}/spring/functions/index.js +0 -0
  167. package/lib/module/{values/animation → animation}/spring/functions/index.js.map +0 -0
  168. package/lib/module/{values/animation → animation}/spring/functions/spring.js +0 -0
  169. package/lib/module/{values/animation → animation}/spring/functions/spring.js.map +0 -0
  170. package/lib/module/{values/animation → animation}/spring/index.js +0 -0
  171. package/lib/module/{values/animation → animation}/spring/index.js.map +0 -0
  172. package/lib/module/{values/animation → animation}/spring/runSpring.js +0 -0
  173. package/lib/module/animation/spring/runSpring.js.map +1 -0
  174. package/lib/module/{values/animation → animation}/spring/types.js +0 -0
  175. package/lib/module/{values/animation → animation}/spring/types.js.map +0 -0
  176. package/lib/module/{values/animation → animation}/spring/useSpring.js +0 -0
  177. package/lib/module/animation/spring/useSpring.js.map +1 -0
  178. package/lib/module/{values/animation → animation}/timing/Easing.js +0 -0
  179. package/lib/module/{values/animation → animation}/timing/Easing.js.map +0 -0
  180. package/lib/module/{values/animation → animation}/timing/createTiming.js +1 -1
  181. package/lib/module/animation/timing/createTiming.js.map +1 -0
  182. package/lib/module/{values/animation → animation}/timing/functions/bezier.js +0 -0
  183. package/lib/module/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
  184. package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js +3 -3
  185. package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -0
  186. package/lib/module/{values/animation → animation}/timing/functions/index.js +0 -0
  187. package/lib/module/{values/animation → animation}/timing/functions/index.js.map +0 -0
  188. package/lib/module/{values/animation → animation}/timing/functions/timing.js +0 -0
  189. package/lib/module/{values/animation → animation}/timing/functions/timing.js.map +1 -1
  190. package/lib/module/{values/animation → animation}/timing/functions/types.js +0 -0
  191. package/lib/module/{values/animation → animation}/timing/functions/types.js.map +0 -0
  192. package/lib/module/{values/animation → animation}/timing/index.js +0 -0
  193. package/lib/module/{values/animation → animation}/timing/index.js.map +0 -0
  194. package/lib/module/{values/animation → animation}/timing/runTiming.js +0 -0
  195. package/lib/module/animation/timing/runTiming.js.map +1 -0
  196. package/lib/module/{values/animation → animation}/timing/useLoop.js +0 -0
  197. package/lib/module/{values/animation → animation}/timing/useLoop.js.map +0 -0
  198. package/lib/module/{values/animation → animation}/timing/useTiming.js +1 -1
  199. package/lib/module/animation/timing/useTiming.js.map +1 -0
  200. package/lib/module/{values/animation → animation}/types.js +0 -0
  201. package/lib/module/{values/animation → animation}/types.js.map +0 -0
  202. package/lib/module/index.js +1 -0
  203. package/lib/module/index.js.map +1 -1
  204. package/lib/module/renderer/Canvas.js +10 -4
  205. package/lib/module/renderer/Canvas.js.map +1 -1
  206. package/lib/module/renderer/components/colorFilters/BlendColor.js.map +1 -1
  207. package/lib/module/renderer/components/colorFilters/Lerp.js +1 -1
  208. package/lib/module/renderer/components/colorFilters/Lerp.js.map +1 -1
  209. package/lib/module/renderer/components/imageFilters/InnerShadow.js +3 -2
  210. package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  211. package/lib/module/renderer/components/imageFilters/RuntimeShader.js +19 -0
  212. package/lib/module/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
  213. package/lib/module/renderer/components/imageFilters/index.js +1 -0
  214. package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
  215. package/lib/module/renderer/components/shaders/Gradient.js +2 -2
  216. package/lib/module/renderer/components/shaders/Gradient.js.map +1 -1
  217. package/lib/module/renderer/components/shaders/Shader.js +3 -2
  218. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  219. package/lib/module/renderer/processors/Circles.js +3 -2
  220. package/lib/module/renderer/processors/Circles.js.map +1 -1
  221. package/lib/module/renderer/processors/Font.js +1 -1
  222. package/lib/module/renderer/processors/Font.js.map +1 -1
  223. package/lib/module/renderer/processors/Rects.js +9 -21
  224. package/lib/module/renderer/processors/Rects.js.map +1 -1
  225. package/lib/module/renderer/processors/math/Matrix3.js +52 -72
  226. package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
  227. package/lib/module/renderer/processors/math/Vector.js +3 -5
  228. package/lib/module/renderer/processors/math/Vector.js.map +1 -1
  229. package/lib/module/skia/Color.js +9 -25
  230. package/lib/module/skia/Color.js.map +1 -1
  231. package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  232. package/lib/module/skia/Matrix.js.map +1 -1
  233. package/lib/module/skia/Shader/useShader.js +4 -1
  234. package/lib/module/skia/Shader/useShader.js.map +1 -1
  235. package/lib/module/skia/Skia.js +2 -46
  236. package/lib/module/skia/Skia.js.map +1 -1
  237. package/lib/module/skia/SkiaApi.js +2 -0
  238. package/lib/module/skia/SkiaApi.js.map +1 -0
  239. package/lib/module/values/api.js +4 -6
  240. package/lib/module/values/api.js.map +1 -1
  241. package/lib/module/values/api.web.js +7 -0
  242. package/lib/module/values/api.web.js.map +1 -0
  243. package/lib/module/values/index.js +0 -1
  244. package/lib/module/values/index.js.map +1 -1
  245. package/lib/module/values/web/RNSkAnimation.js +36 -0
  246. package/lib/module/values/web/RNSkAnimation.js.map +1 -0
  247. package/lib/module/values/web/RNSkClockValue.js +65 -0
  248. package/lib/module/values/web/RNSkClockValue.js.map +1 -0
  249. package/lib/module/values/web/RNSkDerivedValue.js +41 -0
  250. package/lib/module/values/web/RNSkDerivedValue.js.map +1 -0
  251. package/lib/module/values/web/RNSkReadonlyValue.js +36 -0
  252. package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -0
  253. package/lib/module/values/web/RNSkValue.js +63 -0
  254. package/lib/module/values/web/RNSkValue.js.map +1 -0
  255. package/lib/module/values/web/api.js +19 -0
  256. package/lib/module/values/web/api.js.map +1 -0
  257. package/lib/module/values/web/index.js +2 -0
  258. package/lib/module/values/web/index.js.map +1 -0
  259. package/lib/module/views/SkiaView.js +1 -3
  260. package/lib/module/views/SkiaView.js.map +1 -1
  261. package/lib/module/views/api.js +4 -0
  262. package/lib/module/views/api.js.map +1 -0
  263. package/lib/module/views/types.js.map +1 -1
  264. package/lib/typescript/src/{values/animation → animation}/decay/decay.d.ts +0 -0
  265. package/lib/typescript/src/{values/animation → animation}/decay/index.d.ts +0 -0
  266. package/lib/typescript/src/{values/animation → animation}/decay/runDecay.d.ts +2 -2
  267. package/lib/typescript/src/{values/animation → animation}/decay/types.d.ts +1 -1
  268. package/lib/typescript/src/{values/animation → animation}/functions/index.d.ts +0 -0
  269. package/lib/typescript/src/animation/functions/interpolate.d.ts +11 -0
  270. package/lib/typescript/src/animation/functions/interpolateColors.d.ts +3 -0
  271. package/lib/typescript/src/{values/animation → animation}/index.d.ts +0 -0
  272. package/lib/typescript/src/{values/animation → animation}/spring/Spring.d.ts +0 -0
  273. package/lib/typescript/src/{values/animation → animation}/spring/functions/index.d.ts +0 -0
  274. package/lib/typescript/src/{values/animation → animation}/spring/functions/spring.d.ts +0 -0
  275. package/lib/typescript/src/{values/animation → animation}/spring/index.d.ts +0 -0
  276. package/lib/typescript/src/{values/animation → animation}/spring/runSpring.d.ts +1 -1
  277. package/lib/typescript/src/{values/animation → animation}/spring/types.d.ts +0 -0
  278. package/lib/typescript/src/{values/animation → animation}/spring/useSpring.d.ts +1 -1
  279. package/lib/typescript/src/{values/animation → animation}/timing/Easing.d.ts +0 -0
  280. package/lib/typescript/src/{values/animation → animation}/timing/createTiming.d.ts +2 -2
  281. package/lib/typescript/src/{values/animation → animation}/timing/functions/bezier.d.ts +0 -0
  282. package/lib/typescript/src/{values/animation → animation}/timing/functions/getResolvedParams.d.ts +0 -0
  283. package/lib/typescript/src/{values/animation → animation}/timing/functions/index.d.ts +0 -0
  284. package/lib/typescript/src/{values/animation → animation}/timing/functions/timing.d.ts +1 -1
  285. package/lib/typescript/src/{values/animation → animation}/timing/functions/types.d.ts +0 -0
  286. package/lib/typescript/src/{values/animation → animation}/timing/index.d.ts +0 -0
  287. package/lib/typescript/src/{values/animation → animation}/timing/runTiming.d.ts +1 -1
  288. package/lib/typescript/src/{values/animation → animation}/timing/useLoop.d.ts +0 -0
  289. package/lib/typescript/src/{values/animation → animation}/timing/useTiming.d.ts +1 -1
  290. package/lib/typescript/src/{values/animation → animation}/types.d.ts +5 -5
  291. package/lib/typescript/src/index.d.ts +1 -0
  292. package/lib/typescript/src/renderer/Canvas.d.ts +6 -0
  293. package/lib/typescript/src/renderer/components/colorFilters/BlendColor.d.ts +1 -1
  294. package/lib/typescript/src/renderer/components/imageFilters/RuntimeShader.d.ts +7 -0
  295. package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -0
  296. package/lib/typescript/src/renderer/components/shaders/Gradient.d.ts +1 -1
  297. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -2
  298. package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -4
  299. package/lib/typescript/src/renderer/processors/Rects.d.ts +9 -41
  300. package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -5
  301. package/lib/typescript/src/renderer/processors/math/Vector.d.ts +5 -17
  302. package/lib/typescript/src/skia/Color.d.ts +8 -9
  303. package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +16 -0
  304. package/lib/typescript/src/skia/Matrix.d.ts +7 -1
  305. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +2 -1
  306. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffectFactory.d.ts +2 -2
  307. package/lib/typescript/src/skia/Shader/useShader.d.ts +1 -1
  308. package/lib/typescript/src/skia/Skia.d.ts +28 -95
  309. package/lib/typescript/src/skia/SkiaApi.d.ts +71 -0
  310. package/lib/typescript/src/skia/Surface/Surface.d.ts +1 -1
  311. package/lib/typescript/src/skia/Surface/SurfaceFactory.d.ts +2 -2
  312. package/lib/typescript/src/values/api.d.ts +2 -25
  313. package/lib/typescript/src/values/api.web.d.ts +2 -0
  314. package/lib/typescript/src/values/index.d.ts +0 -1
  315. package/lib/typescript/src/values/types.d.ts +24 -1
  316. package/lib/typescript/src/values/web/RNSkAnimation.d.ts +9 -0
  317. package/lib/typescript/src/values/web/RNSkClockValue.d.ts +13 -0
  318. package/lib/typescript/src/values/web/RNSkDerivedValue.d.ts +9 -0
  319. package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +11 -0
  320. package/lib/typescript/src/values/web/RNSkValue.d.ts +14 -0
  321. package/lib/typescript/src/values/web/api.d.ts +2 -0
  322. package/lib/typescript/src/values/web/index.d.ts +1 -0
  323. package/lib/typescript/src/views/SkiaView.d.ts +3 -36
  324. package/lib/typescript/src/views/api.d.ts +5 -0
  325. package/lib/typescript/src/views/types.d.ts +32 -0
  326. package/package.json +2 -2
  327. package/src/{values/animation → animation}/decay/decay.ts +0 -0
  328. package/src/{values/animation → animation}/decay/index.ts +0 -0
  329. package/src/{values/animation → animation}/decay/runDecay.ts +2 -2
  330. package/src/{values/animation → animation}/decay/types.ts +1 -1
  331. package/src/{values/animation → animation}/functions/index.ts +0 -0
  332. package/src/animation/functions/interpolate.ts +182 -0
  333. package/src/animation/functions/interpolateColors.ts +58 -0
  334. package/src/{values/animation → animation}/index.ts +0 -0
  335. package/src/{values/animation → animation}/spring/Spring.ts +0 -0
  336. package/src/{values/animation → animation}/spring/functions/index.ts +0 -0
  337. package/src/{values/animation → animation}/spring/functions/spring.ts +0 -0
  338. package/src/{values/animation → animation}/spring/index.ts +0 -0
  339. package/src/{values/animation → animation}/spring/runSpring.ts +1 -1
  340. package/src/{values/animation → animation}/spring/types.ts +0 -0
  341. package/src/{values/animation → animation}/spring/useSpring.ts +1 -1
  342. package/src/{values/animation → animation}/timing/Easing.ts +0 -0
  343. package/src/{values/animation → animation}/timing/createTiming.ts +2 -2
  344. package/src/{values/animation → animation}/timing/functions/__tests__/timing.spec.ts +0 -0
  345. package/src/{values/animation → animation}/timing/functions/bezier.ts +0 -0
  346. package/src/{values/animation → animation}/timing/functions/getResolvedParams.ts +2 -2
  347. package/src/{values/animation → animation}/timing/functions/index.ts +0 -0
  348. package/src/{values/animation → animation}/timing/functions/timing.ts +1 -1
  349. package/src/{values/animation → animation}/timing/functions/types.ts +0 -0
  350. package/src/{values/animation → animation}/timing/index.ts +0 -0
  351. package/src/{values/animation → animation}/timing/runTiming.ts +1 -1
  352. package/src/{values/animation → animation}/timing/useLoop.ts +0 -0
  353. package/src/{values/animation → animation}/timing/useTiming.ts +2 -2
  354. package/src/{values/animation → animation}/types.ts +5 -5
  355. package/src/index.ts +1 -0
  356. package/src/renderer/Canvas.tsx +11 -4
  357. package/src/renderer/components/colorFilters/BlendColor.tsx +1 -1
  358. package/src/renderer/components/colorFilters/Lerp.tsx +1 -1
  359. package/src/renderer/components/imageFilters/InnerShadow.tsx +4 -2
  360. package/src/renderer/components/imageFilters/RuntimeShader.tsx +23 -0
  361. package/src/renderer/components/imageFilters/index.ts +1 -0
  362. package/src/renderer/components/shaders/Gradient.ts +2 -4
  363. package/src/renderer/components/shaders/Shader.tsx +3 -3
  364. package/src/renderer/processors/Circles.ts +2 -1
  365. package/src/renderer/processors/Font.ts +1 -1
  366. package/src/renderer/processors/Rects.ts +9 -14
  367. package/src/renderer/processors/math/Matrix3.ts +24 -105
  368. package/src/renderer/processors/math/Vector.ts +3 -2
  369. package/src/skia/Color.ts +13 -27
  370. package/src/skia/ImageFilter/ImageFilterFactory.ts +20 -0
  371. package/src/skia/Matrix.ts +8 -1
  372. package/src/skia/RuntimeEffect/RuntimeEffect.ts +3 -1
  373. package/src/skia/RuntimeEffect/RuntimeEffectFactory.ts +2 -2
  374. package/src/skia/Shader/useShader.ts +4 -1
  375. package/src/skia/Skia.ts +4 -126
  376. package/src/skia/SkiaApi.ts +86 -0
  377. package/src/skia/Surface/Surface.ts +1 -1
  378. package/src/skia/Surface/SurfaceFactory.ts +2 -2
  379. package/src/values/api.ts +3 -42
  380. package/src/values/api.web.ts +5 -0
  381. package/src/values/index.ts +0 -1
  382. package/src/values/types.ts +30 -1
  383. package/src/values/web/RNSkAnimation.ts +33 -0
  384. package/src/values/web/RNSkClockValue.ts +58 -0
  385. package/src/values/web/RNSkDerivedValue.ts +38 -0
  386. package/src/values/web/RNSkReadonlyValue.ts +32 -0
  387. package/src/values/web/RNSkValue.ts +57 -0
  388. package/src/values/web/__tests__/RNSkAnimation.spec.ts +21 -0
  389. package/src/values/web/__tests__/RNSkDerivedValue.spec.ts +15 -0
  390. package/src/values/web/__tests__/RNSkReadonlyValue.spec.ts +8 -0
  391. package/src/values/web/__tests__/RNSkValue.spec.ts +11 -0
  392. package/src/values/web/api.ts +33 -0
  393. package/src/values/web/index.ts +1 -0
  394. package/src/views/SkiaView.tsx +3 -49
  395. package/src/views/api.ts +7 -0
  396. package/src/views/types.ts +40 -0
  397. package/lib/commonjs/values/animation/decay/runDecay.js.map +0 -1
  398. package/lib/commonjs/values/animation/functions/interpolate.js +0 -139
  399. package/lib/commonjs/values/animation/functions/interpolate.js.map +0 -1
  400. package/lib/commonjs/values/animation/functions/interpolateColors.js +0 -47
  401. package/lib/commonjs/values/animation/functions/interpolateColors.js.map +0 -1
  402. package/lib/commonjs/values/animation/spring/runSpring.js.map +0 -1
  403. package/lib/commonjs/values/animation/spring/useSpring.js.map +0 -1
  404. package/lib/commonjs/values/animation/timing/createTiming.js.map +0 -1
  405. package/lib/commonjs/values/animation/timing/functions/getResolvedParams.js.map +0 -1
  406. package/lib/commonjs/values/animation/timing/runTiming.js.map +0 -1
  407. package/lib/commonjs/values/animation/timing/useTiming.js.map +0 -1
  408. package/lib/module/values/animation/decay/runDecay.js.map +0 -1
  409. package/lib/module/values/animation/functions/interpolate.js +0 -132
  410. package/lib/module/values/animation/functions/interpolate.js.map +0 -1
  411. package/lib/module/values/animation/functions/interpolateColors.js +0 -32
  412. package/lib/module/values/animation/functions/interpolateColors.js.map +0 -1
  413. package/lib/module/values/animation/spring/runSpring.js.map +0 -1
  414. package/lib/module/values/animation/spring/useSpring.js.map +0 -1
  415. package/lib/module/values/animation/timing/createTiming.js.map +0 -1
  416. package/lib/module/values/animation/timing/functions/getResolvedParams.js.map +0 -1
  417. package/lib/module/values/animation/timing/runTiming.js.map +0 -1
  418. package/lib/module/values/animation/timing/useTiming.js.map +0 -1
  419. package/lib/typescript/scripts/install-npm.d.ts +0 -1
  420. package/lib/typescript/src/values/animation/functions/interpolate.d.ts +0 -7
  421. package/lib/typescript/src/values/animation/functions/interpolateColors.d.ts +0 -3
  422. package/src/values/animation/functions/interpolate.ts +0 -169
  423. package/src/values/animation/functions/interpolateColors.ts +0 -62
@@ -30,7 +30,7 @@ export interface SkiaClockValue extends SkiaReadonlyValue<number> {
30
30
  stop: () => void;
31
31
  }
32
32
 
33
- export interface SkiaAnimation {
33
+ export interface SkiaAnimation extends SkiaClockValue {
34
34
  cancel: () => void;
35
35
  }
36
36
 
@@ -38,3 +38,32 @@ export interface AnimationState {
38
38
  current: number;
39
39
  finished: boolean;
40
40
  }
41
+
42
+ export interface ISkiaValueApi {
43
+ /**
44
+ * Creates a new value that holds the initial value and that
45
+ * can be changed.
46
+ */
47
+ createValue: <T>(initialValue: T) => SkiaValue<T>;
48
+ /**
49
+ * Creates a derived value. This is a calculated value that returns the result of
50
+ * a function that is called with the values of the dependencies.
51
+ */
52
+ createDerivedValue: <R>(
53
+ cb: () => R,
54
+ values: Array<SkiaReadonlyValue<unknown>>
55
+ ) => SkiaReadonlyValue<R>;
56
+ /**
57
+ * Creates a clock value where the value is the number of milliseconds elapsed
58
+ * since the clock was created
59
+ */
60
+ createClockValue: () => SkiaClockValue;
61
+ /**
62
+ * Creates an animation that is driven from a clock and updated every frame.
63
+ * @param cb Callback to calculate next value from time.
64
+ * @returns An animation object that can control a value.
65
+ */
66
+ createAnimation: <S extends AnimationState = AnimationState>(
67
+ cb: (t: number, state: S | undefined) => S
68
+ ) => SkiaAnimation;
69
+ }
@@ -0,0 +1,33 @@
1
+ import type { AnimationState, SkiaAnimation } from "../types";
2
+
3
+ import { RNSkClockValue } from "./RNSkClockValue";
4
+
5
+ export class RNSkAnimation<S extends AnimationState = AnimationState>
6
+ extends RNSkClockValue
7
+ implements SkiaAnimation
8
+ {
9
+ constructor(
10
+ callback: (t: number, state: S | undefined) => S,
11
+ raf: (callback: (time: number) => void) => number
12
+ ) {
13
+ super(raf);
14
+ this._callback = callback;
15
+ }
16
+
17
+ private _callback: (t: number, state: S | undefined) => S;
18
+ private _animationState: S | undefined = undefined;
19
+
20
+ public cancel() {
21
+ this.stop();
22
+ }
23
+
24
+ protected update(nextValue: number): void {
25
+ if (this._callback) {
26
+ this._animationState = this._callback(nextValue, this._animationState);
27
+ if (this._animationState?.finished) {
28
+ this.stop();
29
+ }
30
+ }
31
+ super.update(this._animationState?.current ?? nextValue);
32
+ }
33
+ }
@@ -0,0 +1,58 @@
1
+ import type { SkiaClockValue } from "../types";
2
+
3
+ import { RNSkReadonlyValue } from "./RNSkReadonlyValue";
4
+
5
+ enum RNSkClockState {
6
+ NotStarted = 0,
7
+ Running = 1,
8
+ Stopped = 2,
9
+ }
10
+
11
+ export class RNSkClockValue
12
+ extends RNSkReadonlyValue<number>
13
+ implements SkiaClockValue
14
+ {
15
+ constructor(raf: (callback: (time: number) => void) => number) {
16
+ super(0);
17
+ this._raf = raf;
18
+ this.update(0);
19
+ }
20
+
21
+ private _raf: (callback: (time: number) => void) => number;
22
+ private _start: number | undefined;
23
+ private _stop: number | undefined;
24
+ private _state: RNSkClockState = RNSkClockState.NotStarted;
25
+
26
+ private notifyUpdate = (_: number) => {
27
+ if (this._state === RNSkClockState.Running) {
28
+ const now = Date.now();
29
+ const deltaFromStart = now - this._start!;
30
+ this.tick(deltaFromStart);
31
+ this._raf(this.notifyUpdate);
32
+ }
33
+ };
34
+
35
+ protected tick(value: number) {
36
+ this.update(value);
37
+ }
38
+
39
+ public start() {
40
+ if (this._state === RNSkClockState.NotStarted) {
41
+ this._start = Date.now();
42
+ this._stop = this._start;
43
+ }
44
+ // Subtract pause time from start
45
+ const timeSinceStop = Date.now() - this._stop!;
46
+ this._start! += timeSinceStop;
47
+
48
+ this._state = RNSkClockState.Running;
49
+ this._raf(this.notifyUpdate);
50
+ }
51
+
52
+ public stop() {
53
+ if (this._state === RNSkClockState.Running) {
54
+ this._state = RNSkClockState.Stopped;
55
+ this._stop = Date.now();
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,38 @@
1
+ import type { DependencyList } from "react";
2
+
3
+ import { RNSkReadonlyValue } from "./RNSkReadonlyValue";
4
+
5
+ export class RNSkDerivedValue<T> extends RNSkReadonlyValue<T> {
6
+ constructor(callback: () => T, dependencies: DependencyList) {
7
+ // Initialize dependencies - we can't call this yet, since
8
+ // super if not called and it requires a start value to be set.
9
+ const unsubscribers: Array<() => void> = [];
10
+ const notifyUpdateRef: { current: (() => void) | undefined } = {
11
+ current: undefined,
12
+ };
13
+ dependencies.forEach((dep) => {
14
+ if ("__typename__" in dep && "addListener" in dep) {
15
+ unsubscribers.push(
16
+ (dep as RNSkReadonlyValue<unknown>).addListener(() =>
17
+ notifyUpdateRef.current?.()
18
+ )
19
+ );
20
+ }
21
+ });
22
+ super(callback());
23
+ this._unsubscribers = unsubscribers;
24
+ notifyUpdateRef.current = this.dependecyUpdated.bind(this);
25
+ this._callback = callback;
26
+ }
27
+
28
+ private dependecyUpdated() {
29
+ this.update(this._callback());
30
+ }
31
+
32
+ private _callback: () => T;
33
+ private _unsubscribers: Array<() => void>;
34
+
35
+ public unsubscribe() {
36
+ this._unsubscribers.forEach((unsubscribe) => unsubscribe());
37
+ }
38
+ }
@@ -0,0 +1,32 @@
1
+ import type { SkiaReadonlyValue } from "../types";
2
+
3
+ export class RNSkReadonlyValue<T> implements SkiaReadonlyValue<T> {
4
+ constructor(value: T) {
5
+ this._current = value;
6
+ }
7
+
8
+ private _current: T;
9
+ private _listeners: Array<(value: T) => void> = [];
10
+
11
+ private notifyListeners(): void {
12
+ this._listeners.forEach((cb) => cb(this._current));
13
+ }
14
+
15
+ protected update(nextValue: T): void {
16
+ this._current = nextValue;
17
+ this.notifyListeners();
18
+ }
19
+
20
+ public readonly __typename__ = "RNSkValue";
21
+
22
+ public get current(): T {
23
+ return this._current;
24
+ }
25
+
26
+ public addListener(cb: (value: T) => void) {
27
+ this._listeners.push(cb);
28
+ return () => {
29
+ this._listeners.splice(this._listeners.indexOf(cb), 1);
30
+ };
31
+ }
32
+ }
@@ -0,0 +1,57 @@
1
+ import type { SkiaAnimation, SkiaValue } from "../types";
2
+
3
+ import { RNSkReadonlyValue } from "./RNSkReadonlyValue";
4
+
5
+ export class RNSkValue<T> extends RNSkReadonlyValue<T> implements SkiaValue<T> {
6
+ constructor(value: T) {
7
+ super(value);
8
+ this._unsubscribe = undefined;
9
+ }
10
+
11
+ public set current(value: T) {
12
+ this.update(value);
13
+ }
14
+
15
+ public get current(): T {
16
+ return super.current;
17
+ }
18
+
19
+ private _unsubscribe: (() => void) | undefined;
20
+
21
+ private unsubscribe() {
22
+ if (this._unsubscribe) {
23
+ this._unsubscribe();
24
+ this._unsubscribe = undefined;
25
+ }
26
+ if (this._animation) {
27
+ this._animation.cancel();
28
+ this._animation = undefined;
29
+ }
30
+ }
31
+
32
+ private subscribe(animation: SkiaAnimation | undefined) {
33
+ this.unsubscribe();
34
+ if (animation) {
35
+ this._animation = animation;
36
+ this._unsubscribe = animation.addListener(
37
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
38
+ // @ts-ignore
39
+ this.animationDidUpdate.bind(this)
40
+ );
41
+ this._animation.start();
42
+ }
43
+ }
44
+
45
+ private animationDidUpdate(value: T) {
46
+ this.update(value);
47
+ }
48
+
49
+ private _animation: SkiaAnimation | undefined;
50
+ public get animation(): SkiaAnimation | undefined {
51
+ return this._animation;
52
+ }
53
+
54
+ public set animation(v: SkiaAnimation | undefined) {
55
+ this.subscribe(v);
56
+ }
57
+ }
@@ -0,0 +1,21 @@
1
+ import { RNSkAnimation } from "../RNSkAnimation";
2
+ import { RNSkValue } from "../RNSkValue";
3
+
4
+ describe("RNSkAnimation", () => {
5
+ it("should update a value", () => {
6
+ const valueToTest = new RNSkValue(0);
7
+ const raf = (cb: (t: number) => void) => {
8
+ cb(1);
9
+ return 1;
10
+ };
11
+ valueToTest.animation = new RNSkAnimation(
12
+ () => ({
13
+ finished: true,
14
+ current: 1,
15
+ }),
16
+ raf
17
+ );
18
+ valueToTest.animation.stop();
19
+ expect(valueToTest.current).toBe(1);
20
+ });
21
+ });
@@ -0,0 +1,15 @@
1
+ import { RNSkDerivedValue } from "../RNSkDerivedValue";
2
+ import { RNSkValue } from "../RNSkValue";
3
+
4
+ describe("RNSkDerivedValue", () => {
5
+ it("should update when dependency changes", () => {
6
+ const dependency = new RNSkValue(10);
7
+ const derived = new RNSkDerivedValue(
8
+ () => 10 * dependency.current,
9
+ [dependency]
10
+ );
11
+ expect(derived.current).toBe(100);
12
+ dependency.current = 20;
13
+ expect(derived.current).toBe(200);
14
+ });
15
+ });
@@ -0,0 +1,8 @@
1
+ import { RNSkReadonlyValue } from "../RNSkReadonlyValue";
2
+
3
+ describe("RNSkReadonlyValue", () => {
4
+ it("should expose __typename as RNSkValue", () => {
5
+ const valueToTest = new RNSkReadonlyValue(100);
6
+ expect(valueToTest.__typename__).toEqual("RNSkValue");
7
+ });
8
+ });
@@ -0,0 +1,11 @@
1
+ import { RNSkValue } from "../RNSkValue";
2
+
3
+ describe("RNSkValue", () => {
4
+ it("should notify on change", () => {
5
+ const valueToTest = new RNSkValue(100);
6
+ const spy = jest.fn();
7
+ valueToTest.addListener(spy);
8
+ valueToTest.current = 200;
9
+ expect(spy).toHaveBeenCalledWith(200);
10
+ });
11
+ });
@@ -0,0 +1,33 @@
1
+ import type {
2
+ ISkiaValueApi,
3
+ SkiaValue,
4
+ SkiaReadonlyValue,
5
+ SkiaClockValue,
6
+ AnimationState,
7
+ SkiaAnimation,
8
+ } from "../types";
9
+
10
+ import { RNSkAnimation } from "./RNSkAnimation";
11
+ import { RNSkClockValue } from "./RNSkClockValue";
12
+ import { RNSkDerivedValue } from "./RNSkDerivedValue";
13
+ import { RNSkValue } from "./RNSkValue";
14
+
15
+ export const ValueApi: ISkiaValueApi = {
16
+ createValue: function <T>(initialValue: T): SkiaValue<T> {
17
+ return new RNSkValue(initialValue);
18
+ },
19
+ createDerivedValue: function <R>(
20
+ cb: () => R,
21
+ values: SkiaReadonlyValue<unknown>[]
22
+ ): SkiaReadonlyValue<R> {
23
+ return new RNSkDerivedValue(cb, values);
24
+ },
25
+ createClockValue: function (): SkiaClockValue {
26
+ return new RNSkClockValue(requestAnimationFrame);
27
+ },
28
+ createAnimation: function <S extends AnimationState = AnimationState>(
29
+ cb: (t: number, state: S | undefined) => S
30
+ ): SkiaAnimation {
31
+ return new RNSkAnimation(cb, requestAnimationFrame);
32
+ },
33
+ };
@@ -0,0 +1 @@
1
+ export * from "./api";
@@ -1,15 +1,11 @@
1
1
  import React from "react";
2
- import type { ViewProps } from "react-native";
3
2
  import { requireNativeComponent } from "react-native";
4
3
 
5
- import type { SkImage, SkRect } from "../skia";
4
+ import type { SkRect } from "../skia";
6
5
  import type { SkiaReadonlyValue } from "../values";
7
6
 
8
- import type {
9
- DrawMode,
10
- RNSkiaDrawCallback,
11
- NativeSkiaViewProps,
12
- } from "./types";
7
+ import { SkiaViewApi } from "./api";
8
+ import type { DrawMode, NativeSkiaViewProps, SkiaViewProps } from "./types";
13
9
 
14
10
  let SkiaViewNativeId = 1000;
15
11
 
@@ -17,48 +13,6 @@ const NativeSkiaView = requireNativeComponent<NativeSkiaViewProps>(
17
13
  "ReactNativeSkiaView"
18
14
  );
19
15
 
20
- declare global {
21
- var SkiaViewApi: {
22
- invalidateSkiaView: (nativeId: number) => void;
23
- makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
24
- setDrawCallback: (
25
- nativeId: number,
26
- callback: RNSkiaDrawCallback | undefined
27
- ) => void;
28
- setDrawMode: (nativeId: number, mode: DrawMode) => void;
29
- registerValuesInView: (
30
- nativeId: number,
31
- values: SkiaReadonlyValue<unknown>[]
32
- ) => () => void;
33
- };
34
- }
35
-
36
- const { SkiaViewApi } = global;
37
-
38
- export interface SkiaViewProps extends ViewProps {
39
- /**
40
- * Sets the drawing mode for the skia view. There are two drawing
41
- * modes, "continuous" and "default", where the continuous mode will
42
- * continuously redraw the view, and the default mode will only
43
- * redraw when any of the regular react properties are changed like
44
- * sizes and margins.
45
- */
46
- mode?: DrawMode;
47
- /**
48
- * When set to true the view will display information about the
49
- * average time it takes to render.
50
- */
51
- debug?: boolean;
52
- /**
53
- * Draw callback. Will be called whenever the view is invalidated and
54
- * needs to redraw. This is either caused by a change in a react
55
- * property, a touch event, or a call to redraw. If the view is in
56
- * continuous mode the callback will be called 60 frames per second
57
- * by the native view.
58
- */
59
- onDraw?: RNSkiaDrawCallback;
60
- }
61
-
62
16
  export class SkiaView extends React.Component<SkiaViewProps> {
63
17
  constructor(props: SkiaViewProps) {
64
18
  super(props);
@@ -0,0 +1,7 @@
1
+ import type { ISkiaViewApi } from "./types";
2
+
3
+ declare global {
4
+ var SkiaViewApi: ISkiaViewApi;
5
+ }
6
+
7
+ export const { SkiaViewApi } = global;
@@ -1,6 +1,8 @@
1
1
  import type { ViewProps } from "react-native";
2
2
 
3
+ import type { SkImage, SkRect } from "../skia";
3
4
  import type { SkCanvas } from "../skia/Canvas";
5
+ import type { SkiaReadonlyValue } from "../values";
4
6
 
5
7
  export type DrawMode = "continuous" | "default";
6
8
 
@@ -54,3 +56,41 @@ export interface ValueListener {
54
56
  addListener: (callback: () => void) => number;
55
57
  removeListener: (id: number) => void;
56
58
  }
59
+
60
+ export interface ISkiaViewApi {
61
+ invalidateSkiaView: (nativeId: number) => void;
62
+ makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
63
+ setDrawCallback: (
64
+ nativeId: number,
65
+ callback: RNSkiaDrawCallback | undefined
66
+ ) => void;
67
+ setDrawMode: (nativeId: number, mode: DrawMode) => void;
68
+ registerValuesInView: (
69
+ nativeId: number,
70
+ values: SkiaReadonlyValue<unknown>[]
71
+ ) => () => void;
72
+ }
73
+
74
+ export interface SkiaViewProps extends ViewProps {
75
+ /**
76
+ * Sets the drawing mode for the skia view. There are two drawing
77
+ * modes, "continuous" and "default", where the continuous mode will
78
+ * continuously redraw the view, and the default mode will only
79
+ * redraw when any of the regular react properties are changed like
80
+ * sizes and margins.
81
+ */
82
+ mode?: DrawMode;
83
+ /**
84
+ * When set to true the view will display information about the
85
+ * average time it takes to render.
86
+ */
87
+ debug?: boolean;
88
+ /**
89
+ * Draw callback. Will be called whenever the view is invalidated and
90
+ * needs to redraw. This is either caused by a change in a react
91
+ * property, a touch event, or a call to redraw. If the view is in
92
+ * continuous mode the callback will be called 60 frames per second
93
+ * by the native view.
94
+ */
95
+ onDraw?: RNSkiaDrawCallback;
96
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["runDecay.ts"],"names":["runDecay","value","config","resolvedConfig","deceleration","velocityFactor","velocity","from","current","updateFunction","t","state","finished","lastTimestamp","startTimestamp","initialVelocity","animation","ValueApi","createAnimation"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,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,WAAO,kBAAMI,CAAN,EAASC,KAAT,EAAgBR,cAAhB,CAAP;AACD,GAZD;;AAaAF,EAAAA,KAAK,CAACe,SAAN,GAAkBC,cAASC,eAAT,CAAyBT,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,139 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.interpolate = interpolate;
7
-
8
- // eslint-disable-next-line max-len
9
- // Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js
10
- function interpolateFunction(input, inputRange, outputRange, options) {
11
- const {
12
- extrapolateLeft,
13
- extrapolateRight,
14
- easing
15
- } = options;
16
- let result = input;
17
- const [inputMin, inputMax] = inputRange;
18
- const [outputMin, outputMax] = outputRange;
19
-
20
- if (result < inputMin) {
21
- if (extrapolateLeft === "identity") {
22
- return result;
23
- }
24
-
25
- if (extrapolateLeft === "clamp") {
26
- result = inputMin;
27
- } else if (extrapolateLeft === "extend") {// noop
28
- }
29
- }
30
-
31
- if (result > inputMax) {
32
- if (extrapolateRight === "identity") {
33
- return result;
34
- }
35
-
36
- if (extrapolateRight === "clamp") {
37
- result = inputMax;
38
- } else if (extrapolateRight === "extend") {// noop
39
- }
40
- }
41
-
42
- if (outputMin === outputMax) {
43
- return outputMin;
44
- } // Input Range
45
-
46
-
47
- result = (result - inputMin) / (inputMax - inputMin); // Easing
48
-
49
- result = easing(result); // Output Range
50
-
51
- result = result * (outputMax - outputMin) + outputMin;
52
- return result;
53
- }
54
-
55
- function findRange(input, inputRange) {
56
- let i;
57
-
58
- for (i = 1; i < inputRange.length - 1; ++i) {
59
- if (inputRange[i] >= input) {
60
- break;
61
- }
62
- }
63
-
64
- return i - 1;
65
- }
66
-
67
- function checkValidInputRange(arr) {
68
- for (let i = 1; i < arr.length; ++i) {
69
- if (!(arr[i] > arr[i - 1])) {
70
- throw new Error(`inputRange must be strictly monotonically non-decreasing but got [${arr.join(",")}]`);
71
- }
72
- }
73
- }
74
-
75
- function checkInfiniteRange(name, arr) {
76
- if (arr.length < 2) {
77
- throw new Error(name + " must have at least 2 elements");
78
- }
79
-
80
- for (const index in arr) {
81
- if (typeof arr[index] !== "number") {
82
- throw new Error(`${name} must contain only numbers`);
83
- }
84
-
85
- if (arr[index] === -Infinity || arr[index] === Infinity) {
86
- throw new Error(`${name} must contain only finite numbers, but got [${arr.join(",")}]`);
87
- }
88
- }
89
- }
90
-
91
- function interpolate(input, inputRange, outputRange, options) {
92
- var _options$easing;
93
-
94
- if (typeof input === "undefined") {
95
- throw new Error("input can not be undefined");
96
- }
97
-
98
- if (typeof inputRange === "undefined") {
99
- throw new Error("inputRange can not be undefined");
100
- }
101
-
102
- if (typeof outputRange === "undefined") {
103
- throw new Error("outputRange can not be undefined");
104
- }
105
-
106
- if (inputRange.length !== outputRange.length) {
107
- throw new Error("inputRange (" + inputRange.length + ") and outputRange (" + outputRange.length + ") must have the same length");
108
- }
109
-
110
- checkInfiniteRange("inputRange", inputRange);
111
- checkInfiniteRange("outputRange", outputRange);
112
- checkValidInputRange(inputRange);
113
- const easing = (_options$easing = options === null || options === void 0 ? void 0 : options.easing) !== null && _options$easing !== void 0 ? _options$easing : num => num;
114
- let extrapolateLeft = "extend";
115
-
116
- if ((options === null || options === void 0 ? void 0 : options.extrapolateLeft) !== undefined) {
117
- // eslint-disable-next-line prefer-destructuring
118
- extrapolateLeft = options.extrapolateLeft;
119
- }
120
-
121
- let extrapolateRight = "extend";
122
-
123
- if ((options === null || options === void 0 ? void 0 : options.extrapolateRight) !== undefined) {
124
- // eslint-disable-next-line prefer-destructuring
125
- extrapolateRight = options.extrapolateRight;
126
- }
127
-
128
- if (typeof input !== "number") {
129
- throw new TypeError("Cannot interpolate an input which is not a number");
130
- }
131
-
132
- const range = findRange(input, inputRange);
133
- return interpolateFunction(input, [inputRange[range], inputRange[range + 1]], [outputRange[range], outputRange[range + 1]], {
134
- easing,
135
- extrapolateLeft,
136
- extrapolateRight
137
- });
138
- }
139
- //# 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":"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","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"]}