@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
@@ -0,0 +1,182 @@
1
+ /* eslint-disable max-len */
2
+ export enum Extrapolate {
3
+ IDENTITY = "identity",
4
+ CLAMP = "clamp",
5
+ EXTEND = "extend",
6
+ }
7
+
8
+ interface InterpolationNarrowedInput {
9
+ leftEdgeInput: number;
10
+ rightEdgeInput: number;
11
+ leftEdgeOutput: number;
12
+ rightEdgeOutput: number;
13
+ }
14
+
15
+ export interface ExtrapolationConfig {
16
+ extrapolateLeft?: Extrapolate | string;
17
+ extrapolateRight?: Extrapolate | string;
18
+ }
19
+
20
+ interface RequiredExtrapolationConfig {
21
+ extrapolateLeft: Extrapolate;
22
+ extrapolateRight: Extrapolate;
23
+ }
24
+
25
+ export type ExtrapolationType =
26
+ | ExtrapolationConfig
27
+ | Extrapolate
28
+ | string
29
+ | undefined;
30
+
31
+ function getVal(
32
+ type: Extrapolate,
33
+ coef: number,
34
+ val: number,
35
+ leftEdgeOutput: number,
36
+ rightEdgeOutput: number,
37
+ x: number
38
+ ): number {
39
+ switch (type) {
40
+ case Extrapolate.IDENTITY:
41
+ return x;
42
+ case Extrapolate.CLAMP:
43
+ if (coef * val < coef * leftEdgeOutput) {
44
+ return leftEdgeOutput;
45
+ }
46
+ return rightEdgeOutput;
47
+ case Extrapolate.EXTEND:
48
+ default:
49
+ return val;
50
+ }
51
+ }
52
+
53
+ function isExtrapolate(value: string): value is Extrapolate {
54
+ return (
55
+ value === Extrapolate.EXTEND ||
56
+ value === Extrapolate.CLAMP ||
57
+ value === Extrapolate.IDENTITY
58
+ );
59
+ }
60
+
61
+ // validates extrapolations type
62
+ // if type is correct, converts it to ExtrapolationConfig
63
+ function validateType(type: ExtrapolationType): RequiredExtrapolationConfig {
64
+ // initialize extrapolationConfig with default extrapolation
65
+ const extrapolationConfig: RequiredExtrapolationConfig = {
66
+ extrapolateLeft: Extrapolate.EXTEND,
67
+ extrapolateRight: Extrapolate.EXTEND,
68
+ };
69
+
70
+ if (!type) {
71
+ return extrapolationConfig;
72
+ }
73
+
74
+ if (typeof type === "string") {
75
+ if (!isExtrapolate(type)) {
76
+ throw new Error(
77
+ `No supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
78
+ interpolate(value, [inputRange], [outputRange], "clamp")`
79
+ );
80
+ }
81
+ extrapolationConfig.extrapolateLeft = type;
82
+ extrapolationConfig.extrapolateRight = type;
83
+ return extrapolationConfig;
84
+ }
85
+
86
+ // otherwise type is extrapolation config object
87
+ if (
88
+ (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||
89
+ (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))
90
+ ) {
91
+ throw new Error(
92
+ `No supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
93
+ interpolate(value, [inputRange], [outputRange], {
94
+ extrapolateLeft: Extrapolation.CLAMP,
95
+ extrapolateRight: Extrapolation.IDENTITY
96
+ }})`
97
+ );
98
+ }
99
+
100
+ Object.assign(extrapolationConfig, type);
101
+ return extrapolationConfig;
102
+ }
103
+
104
+ function internalInterpolate(
105
+ x: number,
106
+ narrowedInput: InterpolationNarrowedInput,
107
+ extrapolationConfig: RequiredExtrapolationConfig
108
+ ) {
109
+ const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =
110
+ narrowedInput;
111
+ if (rightEdgeInput - leftEdgeInput === 0) {
112
+ return leftEdgeOutput;
113
+ }
114
+ const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);
115
+ const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);
116
+ const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;
117
+
118
+ if (coef * val < coef * leftEdgeOutput) {
119
+ return getVal(
120
+ extrapolationConfig.extrapolateLeft,
121
+ coef,
122
+ val,
123
+ leftEdgeOutput,
124
+ rightEdgeOutput,
125
+ x
126
+ );
127
+ } else if (coef * val > coef * rightEdgeOutput) {
128
+ return getVal(
129
+ extrapolationConfig.extrapolateRight,
130
+ coef,
131
+ val,
132
+ leftEdgeOutput,
133
+ rightEdgeOutput,
134
+ x
135
+ );
136
+ }
137
+
138
+ return val;
139
+ }
140
+
141
+ // e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)
142
+ export function interpolate(
143
+ x: number,
144
+ input: readonly number[],
145
+ output: readonly number[],
146
+ type?: ExtrapolationType
147
+ ): number {
148
+ if (input.length < 2 || output.length < 2) {
149
+ throw Error(
150
+ "Interpolation input and output should contain at least two values."
151
+ );
152
+ }
153
+
154
+ const extrapolationConfig = validateType(type);
155
+ const { length } = input;
156
+ const narrowedInput: InterpolationNarrowedInput = {
157
+ leftEdgeInput: input[0],
158
+ rightEdgeInput: input[1],
159
+ leftEdgeOutput: output[0],
160
+ rightEdgeOutput: output[1],
161
+ };
162
+ if (length > 2) {
163
+ if (x > input[length - 1]) {
164
+ narrowedInput.leftEdgeInput = input[length - 2];
165
+ narrowedInput.rightEdgeInput = input[length - 1];
166
+ narrowedInput.leftEdgeOutput = output[length - 2];
167
+ narrowedInput.rightEdgeOutput = output[length - 1];
168
+ } else {
169
+ for (let i = 1; i < length; ++i) {
170
+ if (x <= input[i]) {
171
+ narrowedInput.leftEdgeInput = input[i - 1];
172
+ narrowedInput.rightEdgeInput = input[i];
173
+ narrowedInput.leftEdgeOutput = output[i - 1];
174
+ narrowedInput.rightEdgeOutput = output[i];
175
+ break;
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ return internalInterpolate(x, narrowedInput, extrapolationConfig);
182
+ }
@@ -0,0 +1,58 @@
1
+ import { mix } from "../../renderer";
2
+ import type { Color } from "../../skia";
3
+ import { Skia } from "../../skia";
4
+ import type { SkColor } from "../../skia/Color";
5
+
6
+ import { interpolate } from "./interpolate";
7
+
8
+ const interpolateColorsRGB = (
9
+ value: number,
10
+ inputRange: number[],
11
+ outputRange: SkColor[]
12
+ ) => {
13
+ const r = interpolate(
14
+ value,
15
+ inputRange,
16
+ outputRange.map((c) => c[0]),
17
+ "clamp"
18
+ );
19
+ const g = interpolate(
20
+ value,
21
+ inputRange,
22
+ outputRange.map((c) => c[1]),
23
+ "clamp"
24
+ );
25
+ const b = interpolate(
26
+ value,
27
+ inputRange,
28
+ outputRange.map((c) => c[2]),
29
+ "clamp"
30
+ );
31
+ const a = interpolate(
32
+ value,
33
+ inputRange,
34
+ outputRange.map((c) => c[3]),
35
+ "clamp"
36
+ );
37
+ return new Float32Array([r, g, b, a]);
38
+ };
39
+
40
+ export const interpolateColors = (
41
+ value: number,
42
+ inputRange: number[],
43
+ _outputRange: Color[]
44
+ ) => {
45
+ const outputRange = _outputRange.map((cl) => Skia.Color(cl));
46
+ return interpolateColorsRGB(value, inputRange, outputRange);
47
+ };
48
+
49
+ export const mixColors = (value: number, x: Color, y: Color) => {
50
+ const c1 = Skia.Color(x);
51
+ const c2 = Skia.Color(y);
52
+ return new Float32Array([
53
+ mix(value, c1[0], c2[0]),
54
+ mix(value, c1[1], c2[1]),
55
+ mix(value, c1[2], c2[2]),
56
+ mix(value, c1[3], c2[3]),
57
+ ]);
58
+ };
File without changes
@@ -1,4 +1,4 @@
1
- import type { SkiaValue, SkiaAnimation } from "../../types";
1
+ import type { SkiaValue, SkiaAnimation } from "../../values/types";
2
2
  import type {
3
3
  AnimationParams,
4
4
  SpringConfig,
@@ -1,4 +1,4 @@
1
- import type { SkiaReadonlyValue } from "../../types";
1
+ import type { SkiaReadonlyValue } from "../../values/types";
2
2
  import type {
3
3
  SpringConfig,
4
4
  AnimationParams,
@@ -3,8 +3,8 @@ import type {
3
3
  RequiredAnimationParams,
4
4
  AnimationCallback,
5
5
  } from "../types";
6
- import type { AnimationState, SkiaValue } from "../../types";
7
- import { ValueApi } from "../../api";
6
+ import type { AnimationState, SkiaValue } from "../../values/types";
7
+ import { ValueApi } from "../../values/api";
8
8
 
9
9
  import { timing } from "./functions";
10
10
 
@@ -42,8 +42,8 @@ export const getResolvedParams = (
42
42
 
43
43
  const resolvedConfig: Required<TimingConfig> = { ...DefaultTimingConfig };
44
44
  if (config) {
45
- resolvedConfig.duration = config.duration;
46
- resolvedConfig.easing = config.easing ?? ((t) => t);
45
+ resolvedConfig.duration = config.duration ?? DefaultTimingConfig.duration;
46
+ resolvedConfig.easing = config.easing ?? DefaultTimingConfig.easing;
47
47
  }
48
48
 
49
49
  return { ...resolvedParameters, ...resolvedConfig };
@@ -1,4 +1,4 @@
1
- import type { AnimationState } from "../../../types";
1
+ import type { AnimationState } from "../../../values/types";
2
2
 
3
3
  /**
4
4
  * Calculates and returns a timing value based on the
@@ -1,4 +1,4 @@
1
- import type { SkiaValue, SkiaAnimation } from "../../types";
1
+ import type { SkiaValue, SkiaAnimation } from "../../values/types";
2
2
  import type {
3
3
  AnimationParams,
4
4
  TimingConfig,
@@ -1,12 +1,12 @@
1
1
  import { useEffect, useMemo, useRef } from "react";
2
2
 
3
- import type { SkiaReadonlyValue, SkiaAnimation } from "../../types";
3
+ import type { SkiaReadonlyValue, SkiaAnimation } from "../../values/types";
4
4
  import type {
5
5
  AnimationParams,
6
6
  TimingConfig,
7
7
  AnimationCallback,
8
8
  } from "../types";
9
- import { useValue } from "../../hooks/useValue";
9
+ import { useValue } from "../../values/hooks/useValue";
10
10
 
11
11
  import { getResolvedParams } from "./functions";
12
12
  import { createTiming } from "./createTiming";
@@ -1,12 +1,12 @@
1
1
  export interface SpringConfig {
2
- mass: number;
3
- stiffness: number;
4
- damping: number;
5
- velocity: number;
2
+ mass?: number;
3
+ stiffness?: number;
4
+ damping?: number;
5
+ velocity?: number;
6
6
  }
7
7
 
8
8
  export interface TimingConfig {
9
- duration: number;
9
+ duration?: number;
10
10
  easing?: (t: number) => number;
11
11
  }
12
12
 
package/src/index.ts CHANGED
@@ -5,3 +5,4 @@ export * from "./views";
5
5
  export * from "./skia";
6
6
  export * from "./external";
7
7
  export * from "./values";
8
+ export * from "./animation";
@@ -36,12 +36,19 @@ const CanvasContext = React.createContext<SkiaReadonlyValue<{
36
36
  height: number;
37
37
  }> | null>(null);
38
38
 
39
- export const useCanvasSize = () => {
40
- const canvas = useContext(CanvasContext);
41
- if (!canvas) {
39
+ export const useCanvas = () => {
40
+ const size = useContext(CanvasContext);
41
+ if (!size) {
42
42
  throw new Error("Canvas context is not available");
43
43
  }
44
- return canvas;
44
+ return { size };
45
+ };
46
+
47
+ export const useCanvasSize = () => {
48
+ console.warn(
49
+ "useCanvasSize is deprecated, use the size member of useCanvas() instead."
50
+ );
51
+ return useCanvas().size;
45
52
  };
46
53
 
47
54
  export const skiaReconciler = ReactReconciler(skHostConfig);
@@ -1,11 +1,11 @@
1
1
  import React from "react";
2
2
  import type { ReactNode } from "react";
3
3
 
4
+ import type { Color } from "../../../skia";
4
5
  import { BlendMode, Skia } from "../../../skia";
5
6
  import { createDeclaration } from "../../nodes";
6
7
  import type { SkEnum, AnimatedProps } from "../../processors";
7
8
  import { enumKey } from "../../processors";
8
- import type { Color } from "../../../skia";
9
9
 
10
10
  import { composeColorFilter } from "./Compose";
11
11
 
@@ -15,7 +15,7 @@ export interface LerpProps {
15
15
 
16
16
  const onDeclare = createDeclaration<LerpProps>(({ t }, children) => {
17
17
  const [src, dst] = children.filter(isColorFilter);
18
- const cf = Skia.ColorFilter.MakeLerp(t, dst, src);
18
+ const cf = Skia.ColorFilter.MakeLerp(t, src, dst);
19
19
  return composeColorFilter(
20
20
  cf,
21
21
  children.filter((c) => c !== src && c !== dst)
@@ -2,6 +2,8 @@ import type { SkColor } from "../../../skia";
2
2
  import { BlendMode, Skia, TileMode } from "../../../skia";
3
3
  import type { SkImageFilter } from "../../../skia/ImageFilter/ImageFilter";
4
4
 
5
+ const Black = Skia.Color("black");
6
+
5
7
  export const MakeInnerShadow = (
6
8
  shadowOnly: boolean | undefined,
7
9
  dx: number,
@@ -12,11 +14,11 @@ export const MakeInnerShadow = (
12
14
  input: SkImageFilter | null
13
15
  ) => {
14
16
  const sourceGraphic = Skia.ImageFilter.MakeColorFilter(
15
- Skia.ColorFilter.MakeBlend(0xff000000, BlendMode.Dst),
17
+ Skia.ColorFilter.MakeBlend(Black, BlendMode.Dst),
16
18
  null
17
19
  );
18
20
  const sourceAlpha = Skia.ImageFilter.MakeColorFilter(
19
- Skia.ColorFilter.MakeBlend(0xff000000, BlendMode.SrcIn),
21
+ Skia.ColorFilter.MakeBlend(Black, BlendMode.SrcIn),
20
22
  null
21
23
  );
22
24
  const f1 = Skia.ImageFilter.MakeColorFilter(
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+
3
+ import { Skia } from "../../../skia";
4
+ import { createDeclaration } from "../../nodes/Declaration";
5
+ import type { AnimatedProps } from "../../processors/Animations/Animations";
6
+ import type { SkRuntimeEffect } from "../../../skia/RuntimeEffect/RuntimeEffect";
7
+
8
+ import { getInput } from "./getInput";
9
+
10
+ export interface RuntimeShaderProps {
11
+ source: SkRuntimeEffect;
12
+ }
13
+
14
+ const onDeclare = createDeclaration<RuntimeShaderProps>(
15
+ ({ source }, children) => {
16
+ const rtb = Skia.RuntimeShaderBuilder(source);
17
+ return Skia.ImageFilter.MakeRuntimeShader(rtb, null, getInput(children));
18
+ }
19
+ );
20
+
21
+ export const RuntimeShader = (props: AnimatedProps<RuntimeShaderProps>) => {
22
+ return <skDeclaration onDeclare={onDeclare} {...props} />;
23
+ };
@@ -3,3 +3,4 @@ export * from "./Offset";
3
3
  export * from "./DisplacementMap";
4
4
  export * from "./Shadow";
5
5
  export * from "./Morphology";
6
+ export * from "./RuntimeShader";
@@ -1,4 +1,4 @@
1
- import { TileMode, Skia } from "../../../skia";
1
+ import { Skia, TileMode } from "../../../skia";
2
2
  import type { SkEnum } from "../../processors/Paint";
3
3
  import type { TransformProps } from "../../processors/Transform";
4
4
  import { enumKey } from "../../processors/Paint";
@@ -19,9 +19,7 @@ export const processGradientProps = ({
19
19
  flags,
20
20
  ...transform
21
21
  }: GradientProps) => ({
22
- colors: colors.map((color) =>
23
- typeof color === "string" ? Skia.Color(color) : color
24
- ),
22
+ colors: colors.map((color) => Skia.Color(color)),
25
23
  positions: positions ?? null,
26
24
  mode: TileMode[enumKey(mode ?? "clamp")],
27
25
  flags,
@@ -2,13 +2,13 @@ import React from "react";
2
2
  import type { ReactNode } from "react";
3
3
 
4
4
  import { isShader } from "../../../skia";
5
- import type { IRuntimeEffect } from "../../../skia";
5
+ import type { SkRuntimeEffect } from "../../../skia";
6
6
  import type { Vector, AnimatedProps, TransformProps } from "../../processors";
7
7
  import { createDeclaration } from "../../nodes/Declaration";
8
8
  import { localMatrix } from "../../processors";
9
9
 
10
- // We need to use any here because hasOwnProperty doesn't work on JSI instances
11
10
  const isVector = (obj: unknown): obj is Vector =>
11
+ // We have an issue to check property existence on JSI backed instances
12
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
13
  (obj as any).x !== undefined && (obj as any).y !== undefined;
14
14
 
@@ -28,7 +28,7 @@ const processValue = (value: UniformValue): number | readonly number[] => {
28
28
  };
29
29
 
30
30
  export interface ShaderProps extends TransformProps {
31
- source: IRuntimeEffect;
31
+ source: SkRuntimeEffect;
32
32
  uniforms: Uniforms;
33
33
  opaque?: boolean;
34
34
  children?: ReactNode | ReactNode[];
@@ -15,8 +15,9 @@ interface ScalarCircleDef {
15
15
  export type CircleDef = PointCircleDef | ScalarCircleDef;
16
16
 
17
17
  const isCircleScalarDef = (def: CircleDef): def is ScalarCircleDef =>
18
+ // We have an issue to check property existence on JSI backed instances
18
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- (def as any).cx;
20
+ (def as any).cx !== undefined;
20
21
  export const processCircle = (def: CircleDef) => {
21
22
  if (isCircleScalarDef(def)) {
22
23
  return { c: vec(def.cx, def.cy), r: def.r };
@@ -5,7 +5,7 @@ import type { FontMgr } from "../../skia/FontMgr/FontMgr";
5
5
  export type FontDef = { font: SkFont } | { familyName: string; size: number };
6
6
 
7
7
  export const isFont = (fontDef: FontDef): fontDef is { font: SkFont } =>
8
- // We use any here for safety (JSI instances don't have hasProperty working properly);
8
+ // We have an issue to check property existence on JSI backed instances
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  (fontDef as any).font !== undefined;
11
11
 
@@ -1,26 +1,18 @@
1
- // Here we use any because hasOwnProperty doesn't work on JSI instances not does the (key in obj) syntax
2
- // And using Object.keys for such use-case is incredibly slow
3
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
2
  import type { SkRect, SkRRect } from "../../skia";
3
+ import { Skia } from "../../skia";
5
4
 
6
5
  import { vec } from "./math/Vector";
7
6
  import type { Radius } from "./Radius";
8
7
  import { processRadius } from "./Radius";
9
8
 
10
- export const point = (x: number, y: number) => ({ x, y });
9
+ export const point = (x: number, y: number) => Skia.Point(x, y);
11
10
 
12
- export const rect = (x: number, y: number, width: number, height: number) => ({
13
- x,
14
- y,
15
- width,
16
- height,
17
- });
11
+ export const rect = (x: number, y: number, width: number, height: number) =>
12
+ Skia.XYWHRect(x, y, width, height);
18
13
 
19
- export const rrect = (r: SkRect, rx: number, ry: number) => ({
20
- rect: r,
21
- rx,
22
- ry,
23
- });
14
+ export const rrect = (r: SkRect, rx: number, ry: number) =>
15
+ Skia.RRectXY(r, rx, ry);
24
16
 
25
17
  export const bounds = (rects: SkRect[]) => {
26
18
  const x = Math.min(...rects.map((r) => r.x));
@@ -47,10 +39,13 @@ export const center = (r: SkRect | SkRRect) =>
47
39
  ? vec(r.rect.x + r.rect.width / 2, r.rect.y + r.rect.height / 2)
48
40
  : vec(r.x + r.width / 2, r.y + r.height / 2);
49
41
 
42
+ // We have an issue to check property existence on JSI backed instances
50
43
  const isRRectCtor = (def: RRectDef): def is RRectCtor =>
51
44
  (def as any).rect === undefined;
45
+ // We have an issue to check property existence on JSI backed instances
52
46
  const isRectCtor = (def: RectDef): def is RectCtor =>
53
47
  (def as any).rect === undefined;
48
+ // We have an issue to check property existence on JSI backed instances
54
49
  export const isRRect = (def: SkRect | SkRRect): def is SkRRect =>
55
50
  (def as any).rect !== undefined;
56
51