@shopify/react-native-skia 0.1.141 → 0.1.145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +2 -2
  2. package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +1 -1
  3. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +15 -16
  4. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +2 -2
  5. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +69 -27
  6. package/cpp/api/JsiSkPaint.h +6 -0
  7. package/cpp/api/JsiSkPathFactory.h +1 -1
  8. package/cpp/api/JsiSkPicture.h +7 -1
  9. package/cpp/rnskia/RNSkDrawView.cpp +66 -66
  10. package/cpp/rnskia/RNSkDrawView.h +22 -6
  11. package/cpp/rnskia/RNSkJsiViewApi.h +2 -2
  12. package/cpp/rnskia/values/RNSkComputedValue.h +10 -7
  13. package/cpp/rnskia/values/RNSkReadonlyValue.h +21 -2
  14. package/cpp/rnskia/values/RNSkValue.h +1 -0
  15. package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +1 -1
  16. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +2 -2
  17. package/ios/RNSkia-iOS/SkiaDrawView.mm +4 -0
  18. package/lib/commonjs/mock/index.js +3 -1
  19. package/lib/commonjs/mock/index.js.map +1 -1
  20. package/lib/commonjs/renderer/Canvas.js +17 -7
  21. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  22. package/lib/commonjs/renderer/DependencyManager.js +144 -36
  23. package/lib/commonjs/renderer/DependencyManager.js.map +1 -1
  24. package/lib/commonjs/renderer/HostConfig.js +1 -1
  25. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  26. package/lib/commonjs/renderer/components/Blend.js +20 -5
  27. package/lib/commonjs/renderer/components/Blend.js.map +1 -1
  28. package/lib/commonjs/renderer/components/backdrop/BackdropFilter.js.map +1 -1
  29. package/lib/commonjs/renderer/components/imageFilters/Morphology.js +1 -1
  30. package/lib/commonjs/renderer/components/imageFilters/Morphology.js.map +1 -1
  31. package/lib/commonjs/renderer/components/imageFilters/Shadow.js +1 -1
  32. package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -1
  33. package/lib/commonjs/renderer/nodes/Declaration.js +2 -3
  34. package/lib/commonjs/renderer/nodes/Declaration.js.map +1 -1
  35. package/lib/commonjs/renderer/nodes/Drawing.js +3 -7
  36. package/lib/commonjs/renderer/nodes/Drawing.js.map +1 -1
  37. package/lib/commonjs/renderer/nodes/Node.js +9 -7
  38. package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
  39. package/lib/commonjs/renderer/processors/Animations/Animations.js +14 -20
  40. package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
  41. package/lib/commonjs/skia/core/Data.js +10 -22
  42. package/lib/commonjs/skia/core/Data.js.map +1 -1
  43. package/lib/commonjs/skia/core/Font.js +2 -3
  44. package/lib/commonjs/skia/core/Font.js.map +1 -1
  45. package/lib/commonjs/skia/core/Image.js.map +1 -1
  46. package/lib/commonjs/skia/core/SVG.js.map +1 -1
  47. package/lib/commonjs/skia/core/Typeface.js.map +1 -1
  48. package/lib/commonjs/skia/types/Data/Data.js +5 -0
  49. package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
  50. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  51. package/lib/commonjs/skia/web/Host.js +12 -21
  52. package/lib/commonjs/skia/web/Host.js.map +1 -1
  53. package/lib/commonjs/skia/web/JsiSkCanvas.js +50 -28
  54. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  55. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +4 -4
  56. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  57. package/lib/commonjs/skia/web/JsiSkFont.js +7 -3
  58. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  59. package/lib/commonjs/skia/web/JsiSkImage.js +4 -2
  60. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  61. package/lib/commonjs/skia/web/JsiSkImageFactory.js +4 -2
  62. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  63. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +61 -19
  64. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  65. package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
  66. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  67. package/lib/commonjs/skia/web/JsiSkPaint.js +19 -6
  68. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  69. package/lib/commonjs/skia/web/JsiSkPath.js +16 -60
  70. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  71. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +7 -3
  72. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  73. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  74. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  75. package/lib/commonjs/skia/web/JsiSkPicture.js +5 -1
  76. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  77. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +3 -1
  78. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
  79. package/lib/commonjs/skia/web/JsiSkPoint.js +9 -1
  80. package/lib/commonjs/skia/web/JsiSkPoint.js.map +1 -1
  81. package/lib/commonjs/skia/web/JsiSkRRect.js +9 -1
  82. package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
  83. package/lib/commonjs/skia/web/JsiSkRSXform.js.map +1 -1
  84. package/lib/commonjs/skia/web/JsiSkRect.js +3 -3
  85. package/lib/commonjs/skia/web/JsiSkRect.js.map +1 -1
  86. package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js +4 -2
  87. package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  88. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +10 -6
  89. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  90. package/lib/commonjs/skia/web/JsiSkSurface.js +3 -1
  91. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  92. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +8 -4
  93. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  94. package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js +1 -1
  95. package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js.map +1 -1
  96. package/lib/commonjs/skia/web/JsiSkia.js +12 -6
  97. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  98. package/lib/commonjs/values/hooks/useComputedValue.js +6 -2
  99. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  100. package/lib/commonjs/values/index.js +13 -0
  101. package/lib/commonjs/values/index.js.map +1 -1
  102. package/lib/commonjs/values/selector.js +24 -0
  103. package/lib/commonjs/values/selector.js.map +1 -0
  104. package/lib/commonjs/values/web/RNSkComputedValue.js +8 -0
  105. package/lib/commonjs/values/web/RNSkComputedValue.js.map +1 -1
  106. package/lib/commonjs/values/web/RNSkReadonlyValue.js +4 -0
  107. package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -1
  108. package/lib/module/mock/index.js +2 -1
  109. package/lib/module/mock/index.js.map +1 -1
  110. package/lib/module/renderer/Canvas.js +17 -6
  111. package/lib/module/renderer/Canvas.js.map +1 -1
  112. package/lib/module/renderer/DependencyManager.js +141 -34
  113. package/lib/module/renderer/DependencyManager.js.map +1 -1
  114. package/lib/module/renderer/HostConfig.js +1 -1
  115. package/lib/module/renderer/HostConfig.js.map +1 -1
  116. package/lib/module/renderer/components/Blend.js +21 -5
  117. package/lib/module/renderer/components/Blend.js.map +1 -1
  118. package/lib/module/renderer/components/backdrop/BackdropFilter.js.map +1 -1
  119. package/lib/module/renderer/components/imageFilters/Morphology.js +1 -1
  120. package/lib/module/renderer/components/imageFilters/Morphology.js.map +1 -1
  121. package/lib/module/renderer/components/imageFilters/Shadow.js +1 -1
  122. package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -1
  123. package/lib/module/renderer/nodes/Declaration.js +3 -4
  124. package/lib/module/renderer/nodes/Declaration.js.map +1 -1
  125. package/lib/module/renderer/nodes/Drawing.js +3 -6
  126. package/lib/module/renderer/nodes/Drawing.js.map +1 -1
  127. package/lib/module/renderer/nodes/Node.js +9 -7
  128. package/lib/module/renderer/nodes/Node.js.map +1 -1
  129. package/lib/module/renderer/processors/Animations/Animations.js +9 -15
  130. package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
  131. package/lib/module/skia/core/Data.js +10 -20
  132. package/lib/module/skia/core/Data.js.map +1 -1
  133. package/lib/module/skia/core/Font.js +2 -3
  134. package/lib/module/skia/core/Font.js.map +1 -1
  135. package/lib/module/skia/core/Image.js.map +1 -1
  136. package/lib/module/skia/core/SVG.js.map +1 -1
  137. package/lib/module/skia/core/Typeface.js.map +1 -1
  138. package/lib/module/skia/types/Data/Data.js +1 -1
  139. package/lib/module/skia/types/Data/Data.js.map +1 -1
  140. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  141. package/lib/module/skia/web/Host.js +9 -9
  142. package/lib/module/skia/web/Host.js.map +1 -1
  143. package/lib/module/skia/web/JsiSkCanvas.js +40 -29
  144. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  145. package/lib/module/skia/web/JsiSkColorFilterFactory.js +5 -5
  146. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  147. package/lib/module/skia/web/JsiSkFont.js +6 -4
  148. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  149. package/lib/module/skia/web/JsiSkImage.js +4 -3
  150. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  151. package/lib/module/skia/web/JsiSkImageFactory.js +4 -3
  152. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  153. package/lib/module/skia/web/JsiSkImageFilterFactory.js +61 -20
  154. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  155. package/lib/module/skia/web/JsiSkMatrix.js +2 -2
  156. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  157. package/lib/module/skia/web/JsiSkPaint.js +15 -7
  158. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  159. package/lib/module/skia/web/JsiSkPath.js +15 -62
  160. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  161. package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -4
  162. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  163. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  164. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  165. package/lib/module/skia/web/JsiSkPicture.js +4 -2
  166. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  167. package/lib/module/skia/web/JsiSkPictureRecorder.js +3 -2
  168. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  169. package/lib/module/skia/web/JsiSkPoint.js +10 -2
  170. package/lib/module/skia/web/JsiSkPoint.js.map +1 -1
  171. package/lib/module/skia/web/JsiSkRRect.js +10 -2
  172. package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
  173. package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
  174. package/lib/module/skia/web/JsiSkRect.js +4 -4
  175. package/lib/module/skia/web/JsiSkRect.js.map +1 -1
  176. package/lib/module/skia/web/JsiSkRuntimeEffect.js +4 -3
  177. package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  178. package/lib/module/skia/web/JsiSkShaderFactory.js +9 -7
  179. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  180. package/lib/module/skia/web/JsiSkSurface.js +3 -2
  181. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  182. package/lib/module/skia/web/JsiSkTextBlobFactory.js +7 -5
  183. package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  184. package/lib/module/skia/web/JsiSkTypefaceFactory.js +2 -2
  185. package/lib/module/skia/web/JsiSkTypefaceFactory.js.map +1 -1
  186. package/lib/module/skia/web/JsiSkia.js +10 -5
  187. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  188. package/lib/module/values/hooks/useComputedValue.js +7 -3
  189. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  190. package/lib/module/values/index.js +1 -0
  191. package/lib/module/values/index.js.map +1 -1
  192. package/lib/module/values/selector.js +15 -0
  193. package/lib/module/values/selector.js.map +1 -0
  194. package/lib/module/values/web/RNSkComputedValue.js +8 -0
  195. package/lib/module/values/web/RNSkComputedValue.js.map +1 -1
  196. package/lib/module/values/web/RNSkReadonlyValue.js +4 -0
  197. package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -1
  198. package/lib/typescript/src/renderer/Canvas.d.ts +1 -1
  199. package/lib/typescript/src/renderer/DependencyManager.d.ts +40 -14
  200. package/lib/typescript/src/renderer/nodes/Declaration.d.ts +2 -2
  201. package/lib/typescript/src/renderer/nodes/Drawing.d.ts +2 -2
  202. package/lib/typescript/src/renderer/nodes/Node.d.ts +3 -2
  203. package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +7 -3
  204. package/lib/typescript/src/skia/core/Data.d.ts +3 -5
  205. package/lib/typescript/src/skia/core/Font.d.ts +2 -2
  206. package/lib/typescript/src/skia/core/Image.d.ts +2 -2
  207. package/lib/typescript/src/skia/core/SVG.d.ts +2 -2
  208. package/lib/typescript/src/skia/core/Typeface.d.ts +2 -2
  209. package/lib/typescript/src/skia/types/Data/Data.d.ts +10 -3
  210. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +5 -0
  211. package/lib/typescript/src/skia/types/Picture/Picture.d.ts +2 -1
  212. package/lib/typescript/src/skia/web/Host.d.ts +6 -8
  213. package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +8 -8
  214. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
  215. package/lib/typescript/src/skia/web/JsiSkPoint.d.ts +3 -2
  216. package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +3 -2
  217. package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +1 -2
  218. package/lib/typescript/src/skia/web/JsiSkRect.d.ts +3 -3
  219. package/lib/typescript/src/skia/web/JsiSkTextBlobFactory.d.ts +2 -1
  220. package/lib/typescript/src/values/index.d.ts +1 -0
  221. package/lib/typescript/src/values/selector.d.ts +14 -0
  222. package/lib/typescript/src/values/types.d.ts +4 -0
  223. package/lib/typescript/src/values/web/RNSkComputedValue.d.ts +1 -0
  224. package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +1 -0
  225. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  226. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  227. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  228. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  229. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  230. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  231. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  232. package/package.json +3 -3
  233. package/src/mock/index.ts +2 -1
  234. package/src/renderer/Canvas.tsx +19 -7
  235. package/src/renderer/DependencyManager.tsx +171 -37
  236. package/src/renderer/HostConfig.ts +1 -1
  237. package/src/renderer/components/Blend.tsx +25 -5
  238. package/src/renderer/components/backdrop/BackdropFilter.tsx +1 -1
  239. package/src/renderer/components/imageFilters/Morphology.tsx +2 -2
  240. package/src/renderer/components/imageFilters/Shadow.tsx +2 -2
  241. package/src/renderer/nodes/Declaration.tsx +6 -8
  242. package/src/renderer/nodes/Drawing.tsx +5 -7
  243. package/src/renderer/nodes/Node.ts +11 -9
  244. package/src/renderer/processors/Animations/Animations.ts +23 -14
  245. package/src/skia/core/Data.ts +20 -51
  246. package/src/skia/core/Font.ts +4 -5
  247. package/src/skia/core/Image.ts +2 -2
  248. package/src/skia/core/SVG.ts +2 -2
  249. package/src/skia/core/Typeface.ts +2 -2
  250. package/src/skia/types/Data/Data.ts +11 -1
  251. package/src/skia/types/Paint/Paint.ts +6 -0
  252. package/src/skia/types/Picture/Picture.ts +2 -1
  253. package/src/skia/web/Host.ts +12 -22
  254. package/src/skia/web/JsiSkCanvas.ts +99 -56
  255. package/src/skia/web/JsiSkColorFilterFactory.ts +15 -5
  256. package/src/skia/web/JsiSkFont.ts +11 -4
  257. package/src/skia/web/JsiSkImage.ts +4 -3
  258. package/src/skia/web/JsiSkImageFactory.ts +6 -3
  259. package/src/skia/web/JsiSkImageFilterFactory.ts +124 -52
  260. package/src/skia/web/JsiSkMatrix.ts +4 -2
  261. package/src/skia/web/JsiSkPaint.ts +15 -7
  262. package/src/skia/web/JsiSkPath.ts +30 -56
  263. package/src/skia/web/JsiSkPathEffectFactory.ts +10 -5
  264. package/src/skia/web/JsiSkPathFactory.ts +3 -3
  265. package/src/skia/web/JsiSkPicture.ts +5 -3
  266. package/src/skia/web/JsiSkPictureRecorder.ts +3 -2
  267. package/src/skia/web/JsiSkPoint.ts +12 -2
  268. package/src/skia/web/JsiSkRRect.ts +16 -2
  269. package/src/skia/web/JsiSkRSXform.ts +1 -1
  270. package/src/skia/web/JsiSkRect.ts +4 -7
  271. package/src/skia/web/JsiSkRuntimeEffect.ts +9 -4
  272. package/src/skia/web/JsiSkShaderFactory.ts +24 -15
  273. package/src/skia/web/JsiSkSurface.ts +7 -2
  274. package/src/skia/web/JsiSkTextBlobFactory.ts +14 -8
  275. package/src/skia/web/JsiSkTypefaceFactory.tsx +4 -2
  276. package/src/skia/web/JsiSkia.ts +17 -5
  277. package/src/values/hooks/useComputedValue.ts +6 -3
  278. package/src/values/index.ts +1 -0
  279. package/src/values/selector.ts +24 -0
  280. package/src/values/types.ts +4 -0
  281. package/src/values/web/RNSkComputedValue.ts +6 -0
  282. package/src/values/web/RNSkReadonlyValue.ts +4 -0
@@ -3,7 +3,8 @@ import type { CanvasKit, RuntimeEffect } from "canvaskit-wasm";
3
3
  import type { SkMatrix, SkShader } from "../types";
4
4
  import type { SkRuntimeEffect } from "../types/RuntimeEffect/RuntimeEffect";
5
5
 
6
- import { HostObject, toValue } from "./Host";
6
+ import { HostObject } from "./Host";
7
+ import { JsiSkMatrix } from "./JsiSkMatrix";
7
8
  import { JsiSkShader } from "./JsiSkShader";
8
9
 
9
10
  export class JsiSkRuntimeEffect
@@ -19,7 +20,9 @@ export class JsiSkRuntimeEffect
19
20
  this.CanvasKit,
20
21
  this.ref.makeShader(
21
22
  uniforms,
22
- localMatrix !== undefined ? toValue(localMatrix) : localMatrix
23
+ localMatrix !== undefined
24
+ ? JsiSkMatrix.fromValue(localMatrix)
25
+ : localMatrix
23
26
  )
24
27
  );
25
28
  }
@@ -33,8 +36,10 @@ export class JsiSkRuntimeEffect
33
36
  this.CanvasKit,
34
37
  this.ref.makeShaderWithChildren(
35
38
  uniforms,
36
- children?.map((child) => toValue(child)),
37
- localMatrix !== undefined ? toValue(localMatrix) : localMatrix
39
+ children?.map((child) => JsiSkShader.fromValue(child)),
40
+ localMatrix !== undefined
41
+ ? JsiSkMatrix.fromValue(localMatrix)
42
+ : localMatrix
38
43
  )
39
44
  );
40
45
  }
@@ -10,7 +10,9 @@ import type {
10
10
  } from "../types";
11
11
  import type { ShaderFactory } from "../types/Shader/ShaderFactory";
12
12
 
13
- import { Host, toValue, ckEnum } from "./Host";
13
+ import { Host, ckEnum } from "./Host";
14
+ import { JsiSkMatrix } from "./JsiSkMatrix";
15
+ import { JsiSkPoint } from "./JsiSkPoint";
14
16
  import { JsiSkShader } from "./JsiSkShader";
15
17
 
16
18
  export class JsiSkShaderFactory extends Host implements ShaderFactory {
@@ -30,12 +32,14 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
30
32
  return new JsiSkShader(
31
33
  this.CanvasKit,
32
34
  this.CanvasKit.Shader.MakeLinearGradient(
33
- toValue(start),
34
- toValue(end),
35
+ JsiSkPoint.fromValue(start),
36
+ JsiSkPoint.fromValue(end),
35
37
  colors,
36
38
  pos,
37
39
  ckEnum(mode),
38
- localMatrix === undefined ? undefined : toValue(localMatrix),
40
+ localMatrix === undefined
41
+ ? undefined
42
+ : JsiSkMatrix.fromValue(localMatrix),
39
43
  flags
40
44
  )
41
45
  );
@@ -53,12 +57,14 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
53
57
  return new JsiSkShader(
54
58
  this.CanvasKit,
55
59
  this.CanvasKit.Shader.MakeRadialGradient(
56
- toValue(center),
60
+ JsiSkPoint.fromValue(center),
57
61
  radius,
58
62
  colors,
59
63
  pos,
60
64
  ckEnum(mode),
61
- localMatrix === undefined ? undefined : toValue(localMatrix),
65
+ localMatrix === undefined
66
+ ? undefined
67
+ : JsiSkMatrix.fromValue(localMatrix),
62
68
  flags
63
69
  )
64
70
  );
@@ -78,14 +84,16 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
78
84
  return new JsiSkShader(
79
85
  this.CanvasKit,
80
86
  this.CanvasKit.Shader.MakeTwoPointConicalGradient(
81
- toValue(start),
87
+ JsiSkPoint.fromValue(start),
82
88
  startRadius,
83
- toValue(end),
89
+ JsiSkPoint.fromValue(end),
84
90
  endRadius,
85
91
  colors,
86
92
  pos,
87
93
  ckEnum(mode),
88
- localMatrix === undefined ? undefined : toValue(localMatrix),
94
+ localMatrix === undefined
95
+ ? undefined
96
+ : JsiSkMatrix.fromValue(localMatrix),
89
97
  flags
90
98
  )
91
99
  );
@@ -112,7 +120,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
112
120
  ckEnum(mode),
113
121
  localMatrix === undefined || localMatrix === null
114
122
  ? undefined
115
- : toValue(localMatrix),
123
+ : JsiSkMatrix.fromValue(localMatrix),
116
124
  flags,
117
125
  startAngleInDegrees,
118
126
  endAngleInDegrees
@@ -165,17 +173,18 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
165
173
  MakeBlend(mode: BlendMode, one: SkShader, two: SkShader) {
166
174
  return new JsiSkShader(
167
175
  this.CanvasKit,
168
- this.CanvasKit.Shader.MakeBlend(ckEnum(mode), toValue(one), toValue(two))
176
+ this.CanvasKit.Shader.MakeBlend(
177
+ ckEnum(mode),
178
+ JsiSkShader.fromValue(one),
179
+ JsiSkShader.fromValue(two)
180
+ )
169
181
  );
170
182
  }
171
183
 
172
184
  MakeColor(color: SkColor) {
173
185
  return new JsiSkShader(
174
186
  this.CanvasKit,
175
- this.CanvasKit.Shader.MakeColor(
176
- toValue(color),
177
- this.CanvasKit.ColorSpace.SRGB
178
- )
187
+ this.CanvasKit.Shader.MakeColor(color, this.CanvasKit.ColorSpace.SRGB)
179
188
  );
180
189
  }
181
190
  }
@@ -2,9 +2,10 @@ import type { CanvasKit, Surface } from "canvaskit-wasm";
2
2
 
3
3
  import type { SkCanvas, SkImage, SkRect, SkSurface } from "../types";
4
4
 
5
- import { HostObject, toUndefinedableValue } from "./Host";
5
+ import { HostObject } from "./Host";
6
6
  import { JsiSkCanvas } from "./JsiSkCanvas";
7
7
  import { JsiSkImage } from "./JsiSkImage";
8
+ import { JsiSkRect } from "./JsiSkRect";
8
9
 
9
10
  export class JsiSkSurface
10
11
  extends HostObject<Surface, "Surface">
@@ -19,7 +20,11 @@ export class JsiSkSurface
19
20
  }
20
21
 
21
22
  makeImageSnapshot(bounds?: SkRect): SkImage {
22
- const image = this.ref.makeImageSnapshot(toUndefinedableValue(bounds));
23
+ const image = this.ref.makeImageSnapshot(
24
+ bounds
25
+ ? Array.from(JsiSkRect.fromValue(this.CanvasKit, bounds))
26
+ : undefined
27
+ );
23
28
  return new JsiSkImage(this.CanvasKit, image);
24
29
  }
25
30
  }
@@ -1,10 +1,14 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
2
 
3
- import type { SkFont, SkRSXform } from "../types";
3
+ import type { SkFont } from "../types";
4
4
  import type { TextBlobFactory } from "../types/TextBlob";
5
+ import type { SkRSXform } from "../types/RSXform";
5
6
 
6
- import { Host, toValue } from "./Host";
7
+ import { Host } from "./Host";
8
+ import { JsiSkFont } from "./JsiSkFont";
7
9
  import { JsiSkTextBlob } from "./JsiSkTextBlob";
10
+ import type { RSXform } from "./JsiSkRSXform";
11
+ import { JsiSkRSXform } from "./JsiSkRSXform";
8
12
 
9
13
  export class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
10
14
  constructor(CanvasKit: CanvasKit) {
@@ -14,14 +18,14 @@ export class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
14
18
  MakeFromText(str: string, font: SkFont) {
15
19
  return new JsiSkTextBlob(
16
20
  this.CanvasKit,
17
- this.CanvasKit.TextBlob.MakeFromText(str, toValue(font))
21
+ this.CanvasKit.TextBlob.MakeFromText(str, JsiSkFont.fromValue(font))
18
22
  );
19
23
  }
20
24
 
21
25
  MakeFromGlyphs(glyphs: number[], font: SkFont) {
22
26
  return new JsiSkTextBlob(
23
27
  this.CanvasKit,
24
- this.CanvasKit.TextBlob.MakeFromGlyphs(glyphs, toValue(font))
28
+ this.CanvasKit.TextBlob.MakeFromGlyphs(glyphs, JsiSkFont.fromValue(font))
25
29
  );
26
30
  }
27
31
 
@@ -30,8 +34,10 @@ export class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
30
34
  this.CanvasKit,
31
35
  this.CanvasKit.TextBlob.MakeFromRSXform(
32
36
  str,
33
- rsxforms.map((f) => Array.from(toValue<Float32Array>(f))).flat(),
34
- toValue(font)
37
+ rsxforms
38
+ .map((f) => Array.from(JsiSkRSXform.fromValue<RSXform>(f)))
39
+ .flat(),
40
+ JsiSkFont.fromValue(font)
35
41
  )
36
42
  );
37
43
  }
@@ -41,8 +47,8 @@ export class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
41
47
  this.CanvasKit,
42
48
  this.CanvasKit.TextBlob.MakeFromRSXformGlyphs(
43
49
  glyphs,
44
- rsxforms.map((f) => toValue(f)),
45
- toValue(font)
50
+ rsxforms.map((f) => JsiSkRSXform.fromValue(f)),
51
+ JsiSkFont.fromValue(font)
46
52
  )
47
53
  );
48
54
  }
@@ -2,7 +2,7 @@ import type { CanvasKit } from "canvaskit-wasm";
2
2
 
3
3
  import type { SkData, TypefaceFactory } from "../types";
4
4
 
5
- import { Host, toValue } from "./Host";
5
+ import { Host } from "./Host";
6
6
  import { JsiSkTypeface } from "./JsiSkTypeface";
7
7
 
8
8
  export class JsiSkTypefaceFactory extends Host implements TypefaceFactory {
@@ -11,7 +11,9 @@ export class JsiSkTypefaceFactory extends Host implements TypefaceFactory {
11
11
  }
12
12
 
13
13
  MakeFreeTypeFaceFromData(data: SkData) {
14
- const tf = this.CanvasKit.Typeface.MakeFreeTypeFaceFromData(toValue(data));
14
+ const tf = this.CanvasKit.Typeface.MakeFreeTypeFaceFromData(
15
+ JsiSkTypeface.fromValue(data)
16
+ );
15
17
  if (tf === null) {
16
18
  return null;
17
19
  }
@@ -17,7 +17,6 @@ import { Color } from "./JsiSkColor";
17
17
  import { JsiSkSurfaceFactory } from "./JsiSkSurfaceFactory";
18
18
  import { JsiSkRRect } from "./JsiSkRRect";
19
19
  import { JsiSkRSXform } from "./JsiSkRSXform";
20
- import { toValue } from "./Host";
21
20
  import { JsiSkContourMeasureIter } from "./JsiSkContourMeasureIter";
22
21
  import { JsiSkPictureRecorder } from "./JsiSkPictureRecorder";
23
22
  import { JsiSkPictureFactory } from "./JsiSkPictureFactory";
@@ -36,6 +35,8 @@ import { JsiSkSVGFactory } from "./JsiSkSVGFactory";
36
35
  import { JsiSkTextBlobFactory } from "./JsiSkTextBlobFactory";
37
36
  import { JsiSkFont } from "./JsiSkFont";
38
37
  import { MakeVertices } from "./JsiSkVerticesFactory";
38
+ import { JsiSkPath } from "./JsiSkPath";
39
+ import { JsiSkTypeface } from "./JsiSkTypeface";
39
40
 
40
41
  export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
41
42
  Point: (x: number, y: number) =>
@@ -44,7 +45,10 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
44
45
  throw new Error("Not implemented on React Native Web");
45
46
  },
46
47
  RRectXY: (rect: SkRect, rx: number, ry: number) =>
47
- new JsiSkRRect(CanvasKit, CanvasKit.RRectXY(toValue(rect), rx, ry)),
48
+ new JsiSkRRect(
49
+ CanvasKit,
50
+ CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry)
51
+ ),
48
52
  RSXform: (scos: number, ssin: number, tx: number, ty: number) =>
49
53
  new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),
50
54
  Color,
@@ -55,9 +59,17 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
55
59
  ): SkContourMeasureIter =>
56
60
  new JsiSkContourMeasureIter(
57
61
  CanvasKit,
58
- new CanvasKit.ContourMeasureIter(toValue(path), forceClosed, resScale)
62
+ new CanvasKit.ContourMeasureIter(
63
+ JsiSkPath.fromValue(path),
64
+ forceClosed,
65
+ resScale
66
+ )
59
67
  ),
60
- Paint: () => new JsiSkPaint(CanvasKit, new CanvasKit.Paint()),
68
+ Paint: () => {
69
+ const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());
70
+ paint.setAntiAlias(true);
71
+ return paint;
72
+ },
61
73
  PictureRecorder: () =>
62
74
  new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),
63
75
  Picture: new JsiSkPictureFactory(CanvasKit),
@@ -74,7 +86,7 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
74
86
  new JsiSkFont(
75
87
  CanvasKit,
76
88
  new CanvasKit.Font(
77
- typeface === undefined ? null : toValue(typeface),
89
+ typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),
78
90
  size
79
91
  )
80
92
  ),
@@ -1,4 +1,4 @@
1
- import { useMemo } from "react";
1
+ import { useEffect, useMemo } from "react";
2
2
 
3
3
  import { ValueApi } from "../api";
4
4
  import { isValue } from "../../renderer/processors/Animations";
@@ -10,9 +10,12 @@ import { isValue } from "../../renderer/processors/Animations";
10
10
  * @param values Dependant values
11
11
  * @returns A readonly value
12
12
  */
13
- export const useComputedValue = <R>(cb: () => R, values: unknown[]) =>
14
- useMemo(
13
+ export const useComputedValue = <R>(cb: () => R, values: unknown[]) => {
14
+ const value = useMemo(
15
15
  () => ValueApi.createComputedValue<R>(cb, values.filter(isValue)),
16
16
  // eslint-disable-next-line react-hooks/exhaustive-deps
17
17
  values
18
18
  );
19
+ useEffect(() => () => value.__invalidate(), [value]);
20
+ return value;
21
+ };
@@ -1,3 +1,4 @@
1
1
  export * from "./types";
2
2
  export * from "./hooks";
3
3
  export * from "./api";
4
+ export * from "./selector";
@@ -0,0 +1,24 @@
1
+ import type { SkiaValue } from "./types";
2
+
3
+ export type SkiaSelector<TReturn, TInput = unknown> = {
4
+ value: SkiaValue<TInput>;
5
+ selector: (v: TInput) => TReturn;
6
+ };
7
+
8
+ /**
9
+ * Wraps a Skia Value with a selector function. The selector function can access the
10
+ * inner values of the Skia Value so that we can dynamically ready array values and
11
+ * object values when doing animations in Skia.
12
+ * @param value Dependant value
13
+ * @param selector Selector function to calculate new value from the Skia Value's value
14
+ * @returns A descriptor that will be used by the reconciler to calculate the value
15
+ */
16
+ export const Selector = <TInput, TReturn>(
17
+ value: SkiaValue<TInput>,
18
+ selector: (v: TInput) => TReturn
19
+ ): SkiaSelector<TReturn, TInput> => {
20
+ return {
21
+ selector,
22
+ value,
23
+ };
24
+ };
@@ -8,6 +8,10 @@ export interface SkiaValue<T = number> {
8
8
  * Returns unsubscribe method.
9
9
  */
10
10
  addListener: (cb: (value: T) => void) => () => void;
11
+ /**
12
+ * Invalidates the value. Has different meaning depending on the type of the value.
13
+ */
14
+ __invalidate: () => void;
11
15
  /**
12
16
  * Field to make typechecking easier
13
17
  */
@@ -34,5 +34,11 @@ export class RNSkComputedValue<T> extends RNSkReadonlyValue<T> {
34
34
 
35
35
  public unsubscribe() {
36
36
  this._unsubscribers.forEach((unsubscribe) => unsubscribe());
37
+ this._unsubscribers = [];
38
+ }
39
+
40
+ public __invalidate(): void {
41
+ this._unsubscribers.forEach((unsubscribe) => unsubscribe());
42
+ this._unsubscribers = [];
37
43
  }
38
44
  }
@@ -29,4 +29,8 @@ export class RNSkReadonlyValue<T> implements SkiaValue<T> {
29
29
  this._listeners.splice(this._listeners.indexOf(cb), 1);
30
30
  };
31
31
  }
32
+
33
+ public __invalidate(): void {
34
+ this._listeners = [];
35
+ }
32
36
  }