@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
@@ -1,21 +1,47 @@
1
- import type { RefObject } from "react";
2
- import type { SkiaView } from "../views";
3
1
  import type { SkiaValue } from "../values";
4
2
  import type { Node } from "./nodes";
3
+ import type { AnimatedProps } from "./processors";
5
4
  declare type Unsubscribe = () => void;
6
- declare type Props = {
7
- [key: string]: unknown;
5
+ declare type Mutator = (value: unknown) => void;
6
+ declare type SubscriptionState = {
7
+ nodes: Map<Node, Mutator[]>;
8
+ unsubscribe: null | Unsubscribe;
8
9
  };
9
10
  export declare class DependencyManager {
10
- ref: RefObject<SkiaView>;
11
- subscriptions: Map<Node, {
12
- values: SkiaValue<unknown>[];
13
- unsubscribe: null | Unsubscribe;
14
- }>;
15
- constructor(ref: RefObject<SkiaView>);
16
- unSubscribeNode(node: Node): void;
17
- subscribeNode(node: Node, props: Props): void;
18
- subscribe(): void;
19
- unsubscribe(): void;
11
+ registerValues: (values: Array<SkiaValue<unknown>>) => () => void;
12
+ subscriptions: Map<SkiaValue<unknown>, SubscriptionState>;
13
+ unregisterDependantValues: null | Unsubscribe;
14
+ constructor(registerValues: (values: Array<SkiaValue<unknown>>) => () => void);
15
+ /**
16
+ * Call to unsubscribe all value listeners from the given node based
17
+ * on the current list of subscriptions for the node. This function
18
+ * is typically called when the node is unmounted or when one or more
19
+ * properties have changed.
20
+ * @param node Node to unsubscribe value listeners from
21
+ */
22
+ unsubscribeNode(node: Node): void;
23
+ /**
24
+ * Adds listeners to the provided values so that the node is notified
25
+ * when a value changes. This is done in an optimized way so that this
26
+ * class only needs to listen to the value once and then forwards the
27
+ * change to the node and its listener. This method is typically called
28
+ * when the node is mounted and when one or more props on the node changes.
29
+ * @param node Node to subscribe to value changes for
30
+ * @param props Node's properties
31
+ * @param onResolveProp Callback when a property value changes
32
+ */
33
+ subscribeNode<P extends Record<string, unknown>>(node: Node, props: AnimatedProps<P>): void;
34
+ /**
35
+ * Called when the hosting container is mounted or updated. This ensures that we have
36
+ * a ref to the underlying SkiaView so that we can registers redraw listeners
37
+ * on values used in the current View automatically.
38
+ */
39
+ update(): void;
40
+ /**
41
+ * Called when the hosting container is unmounted or recreated. This ensures that we remove
42
+ * all subscriptions to Skia values so that we don't have any listeners left after
43
+ * the component is removed.
44
+ */
45
+ remove(): void;
20
46
  }
21
47
  export {};
@@ -8,7 +8,7 @@ export declare type DeclarationResult = SkJSIInstance<string> | null;
8
8
  declare type DeclarationCallback<T> = (props: T, children: DeclarationResult[], ctx: DrawingContext) => DeclarationResult;
9
9
  export declare const createDeclaration: <T>(cb: DeclarationCallback<T>) => DeclarationCallback<T>;
10
10
  export declare const useDeclaration: <P>(cb: DeclarationCallback<P>, deps?: DependencyList | undefined) => DeclarationCallback<P>;
11
- export declare const isDeclarationNode: (node: Node) => node is DeclarationNode<unknown>;
11
+ export declare const isDeclarationNode: <P>(node: Node) => node is DeclarationNode<P>;
12
12
  export interface DeclarationProps<P> {
13
13
  onDeclare: DeclarationCallback<P>;
14
14
  }
@@ -16,7 +16,7 @@ export declare class DeclarationNode<P> extends Node<P> {
16
16
  private onDeclare;
17
17
  constructor(depMgr: DependencyManager, onDeclare: DeclarationCallback<P>, props: AnimatedProps<P>);
18
18
  set props(props: AnimatedProps<P>);
19
- get props(): AnimatedProps<P>;
19
+ get props(): P;
20
20
  draw(ctx: DrawingContext): DeclarationResult;
21
21
  }
22
22
  export {};
@@ -7,8 +7,8 @@ declare type DrawingCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>)
7
7
  declare type OnDrawCallback<P> = (ctx: DrawingContext, props: P, node: Node<P>) => void;
8
8
  export declare const createDrawing: <P>(cb: OnDrawCallback<P>) => DrawingCallback<P>;
9
9
  export declare const useDrawing: <P>(cb: OnDrawCallback<P>, deps?: DependencyList | undefined) => OnDrawCallback<P>;
10
- export declare type DrawingProps<T> = {
11
- onDraw: DrawingCallback<T>;
10
+ export declare type DrawingProps<P> = {
11
+ onDraw: DrawingCallback<P>;
12
12
  skipProcessing?: boolean;
13
13
  children?: ReactNode | ReactNode[];
14
14
  };
@@ -9,15 +9,16 @@ export declare enum NodeType {
9
9
  declare type DeclarationResult = SkJSIInstance<string> | null;
10
10
  export declare abstract class Node<P = unknown> {
11
11
  readonly children: Node[];
12
- _props: AnimatedProps<P>;
12
+ resolvedProps: P;
13
13
  memoizable: boolean;
14
14
  memoized: DeclarationResult | null;
15
15
  parent?: Node;
16
16
  depMgr: DependencyManager;
17
17
  constructor(depMgr: DependencyManager, props: AnimatedProps<P>);
18
18
  abstract draw(ctx: DrawingContext): void | DeclarationResult;
19
+ updatePropSubscriptions(props: AnimatedProps<P>): void;
19
20
  set props(props: AnimatedProps<P>);
20
- get props(): AnimatedProps<P>;
21
+ get props(): P;
21
22
  visit(ctx: DrawingContext, children?: Node[]): SkJSIInstance<string>[];
22
23
  }
23
24
  export {};
@@ -1,7 +1,11 @@
1
- import type { SkiaValue } from "../../../values";
1
+ import type { SkiaSelector, SkiaValue } from "../../../values";
2
2
  export declare const isValue: (value: unknown) => value is SkiaValue<unknown>;
3
+ export declare const isSelector: <T, R>(value: unknown) => value is {
4
+ selector: (v: T) => R;
5
+ value: SkiaValue<T>;
6
+ };
3
7
  export declare const isAnimated: <T>(props: AnimatedProps<T>) => boolean;
4
- export declare const materialize: <T>(props: AnimatedProps<T>) => T;
8
+ export declare type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
5
9
  export declare type AnimatedProps<T> = {
6
- [K in keyof T]: T[K] | SkiaValue<T[K]>;
10
+ [K in keyof T]: AnimatedProp<T[K]>;
7
11
  };
@@ -1,5 +1,3 @@
1
- import type { DependencyList } from "react";
2
- import type { SkData, DataSource } from "../types";
3
- export declare const useDataCollection: <T>(sources: DataSource[], factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => (T | null)[] | null;
4
- export declare const useRawData: <T>(source: DataSource | null | undefined, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => T | null;
5
- export declare const useData: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => SkData | null;
1
+ import type { SkData, DataSourceParam } from "../types";
2
+ export declare const useRawData: <T>(source: DataSourceParam, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined) => T | null;
3
+ export declare const useData: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkData | null;
@@ -1,5 +1,5 @@
1
- import type { DataSource, SkFont } from "../types";
1
+ import type { DataSourceParam } from "../types";
2
2
  /**
3
3
  * Returns a Skia Font object
4
4
  * */
5
- export declare const useFont: (font: DataSource | null | undefined, size?: number | undefined, onError?: ((err: Error) => void) | undefined) => SkFont | null;
5
+ export declare const useFont: (font: DataSourceParam, size?: number | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkFont | null;
@@ -1,5 +1,5 @@
1
- import type { DataSource } from "../types";
1
+ import type { DataSourceParam } from "../types";
2
2
  /**
3
3
  * Returns a Skia Image object
4
4
  * */
5
- export declare const useImage: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkImage | null;
5
+ export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkImage | null;
@@ -1,2 +1,2 @@
1
- import type { DataSource } from "../types";
2
- export declare const useSVG: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkSVG | null;
1
+ import type { DataSourceParam } from "../types";
2
+ export declare const useSVG: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkSVG | null;
@@ -1,5 +1,5 @@
1
- import type { DataSource } from "../types";
1
+ import type { DataSourceParam } from "../types";
2
2
  /**
3
3
  * Returns a Skia Typeface object
4
4
  * */
5
- export declare const useTypeface: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkTypeface | null;
5
+ export declare const useTypeface: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkTypeface | null;
@@ -1,5 +1,12 @@
1
- /// <reference types="node" />
2
- /// <reference types="react-native" />
3
1
  import type { SkJSIInstance } from "../JsiInstance";
4
2
  export declare type SkData = SkJSIInstance<"Data">;
5
- export declare type DataSource = ReturnType<typeof require> | string | Uint8Array;
3
+ declare type RNModule = number;
4
+ declare type ESModule = {
5
+ __esModule: true;
6
+ default: string;
7
+ };
8
+ export declare type DataModule = RNModule | ESModule;
9
+ export declare type DataSource = DataModule | string | Uint8Array;
10
+ export declare type DataSourceParam = DataSource | null | undefined;
11
+ export declare const isRNModule: (mod: DataModule) => mod is number;
12
+ export {};
@@ -26,6 +26,11 @@ export interface SkPaint extends SkJSIInstance<"Paint"> {
26
26
  * Returns a copy of this paint.
27
27
  */
28
28
  copy(): SkPaint;
29
+ /**
30
+ * Sets all SkPaint contents to their initial values. This is equivalent to replacing
31
+ SkPaint with the result of SkPaint().
32
+ */
33
+ reset(): void;
29
34
  /**
30
35
  * Retrieves the alpha and RGB unpremultiplied. RGB are extended sRGB values
31
36
  * (sRGB gamut, and encoded with the sRGB transfer function).
@@ -3,7 +3,8 @@ import type { TileMode } from "../ImageFilter";
3
3
  import type { SkRect } from "../Rect";
4
4
  import type { SkShader } from "../Shader";
5
5
  import type { SkMatrix } from "../Matrix";
6
- export interface SkPicture {
6
+ import type { SkJSIInstance } from "../JsiInstance";
7
+ export interface SkPicture extends SkJSIInstance<"Picture"> {
7
8
  /**
8
9
  * Returns a new shader that will draw with this picture.
9
10
  *
@@ -1,21 +1,19 @@
1
1
  import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
2
2
  import type { SkJSIInstance } from "../types";
3
3
  export declare class NotImplementedOnRNWeb extends Error {
4
- constructor();
4
+ constructor(msg?: string);
5
5
  }
6
6
  export declare abstract class Host {
7
7
  readonly CanvasKit: CanvasKit;
8
8
  constructor(CanvasKit: CanvasKit);
9
9
  }
10
- export declare abstract class HostObject<T, N extends string> extends Host implements SkJSIInstance<N> {
10
+ export declare abstract class BaseHostObject<T, N extends string> extends Host implements SkJSIInstance<N> {
11
11
  readonly __typename__: N;
12
- readonly ref: T;
12
+ ref: T;
13
13
  constructor(CanvasKit: CanvasKit, ref: T, typename: N);
14
14
  }
15
- export declare type NonNullish = {};
16
- export declare const toOptionalValue: <T>(value: NonNullish | undefined | null) => T | null | undefined;
17
- export declare const toUndefinedableValue: <T>(value: NonNullish | undefined) => T | undefined;
18
- export declare const toNullableValue: <T>(value: NonNullish | null) => T | null;
19
- export declare const toValue: <T>(value: NonNullish) => T;
15
+ export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
16
+ static fromValue<T>(value: SkJSIInstance<string>): T;
17
+ }
20
18
  export declare const ckEnum: (value: number) => EmbindEnumEntity;
21
19
  export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
@@ -4,16 +4,16 @@ import { Host } from "./Host";
4
4
  import { JsiSkImageFilter } from "./JsiSkImageFilter";
5
5
  export declare class JsiSkImageFilterFactory extends Host implements ImageFilterFactory {
6
6
  constructor(CanvasKit: CanvasKit);
7
- MakeOffset(_dx: number, _dy: number, _input: SkImageFilter | null): SkImageFilter;
8
- MakeDisplacementMap(_channelX: ColorChannel, _channelY: ColorChannel, _scale: number, _in1: SkImageFilter, _input: SkImageFilter | null): SkImageFilter;
9
- MakeShader(_shader: SkShader, _input: SkImageFilter | null): SkImageFilter;
7
+ MakeOffset(dx: number, dy: number, input: SkImageFilter | null): JsiSkImageFilter;
8
+ MakeDisplacementMap(channelX: ColorChannel, channelY: ColorChannel, scale: number, in1: SkImageFilter, input: SkImageFilter | null): SkImageFilter;
9
+ MakeShader(shader: SkShader, _input: SkImageFilter | null): SkImageFilter;
10
10
  MakeBlur(sigmaX: number, sigmaY: number, mode: TileMode, input: SkImageFilter | null): JsiSkImageFilter;
11
11
  MakeColorFilter(cf: SkColorFilter, input: SkImageFilter | null): JsiSkImageFilter;
12
12
  MakeCompose(outer: SkImageFilter | null, inner: SkImageFilter | null): JsiSkImageFilter;
13
- MakeDropShadow(_dx: number, _dy: number, _sigmaX: number, _sigmaY: number, _color: SkColor, _input: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
14
- MakeDropShadowOnly(_dx: number, _dy: number, _sigmaX: number, _sigmaY: number, _color: SkColor, _input: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
15
- MakeErode(_rx: number, _ry: number, _input: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
16
- MakeDilate(_rx: number, _ry: number, _input: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
17
- MakeBlend(_mode: BlendMode, _background: SkImageFilter, _foreground: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
13
+ MakeDropShadow(dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
14
+ MakeDropShadowOnly(dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
15
+ MakeErode(rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
16
+ MakeDilate(rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
17
+ MakeBlend(mode: BlendMode, background: SkImageFilter, foreground: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
18
18
  MakeRuntimeShader(_builder: SkRuntimeShaderBuilder, _childShaderName: string | null, _input: SkImageFilter | null): SkImageFilter;
19
19
  }
@@ -4,6 +4,7 @@ import { HostObject } from "./Host";
4
4
  export declare class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
5
5
  constructor(CanvasKit: CanvasKit, ref: Paint);
6
6
  copy(): JsiSkPaint;
7
+ reset(): void;
7
8
  getColor(): Float32Array;
8
9
  getStrokeCap(): number;
9
10
  getStrokeJoin(): number;
@@ -1,7 +1,8 @@
1
1
  import type { CanvasKit, Point } from "canvaskit-wasm";
2
2
  import type { SkPoint } from "../types";
3
- import { HostObject } from "./Host";
4
- export declare class JsiSkPoint extends HostObject<Point, "Point"> implements SkPoint {
3
+ import { BaseHostObject } from "./Host";
4
+ export declare class JsiSkPoint extends BaseHostObject<Point, "Point"> implements SkPoint {
5
+ static fromValue(point: SkPoint): Float32Array;
5
6
  constructor(CanvasKit: CanvasKit, ref: Point);
6
7
  get x(): number;
7
8
  get y(): number;
@@ -1,8 +1,9 @@
1
1
  import type { CanvasKit, RRect } from "canvaskit-wasm";
2
2
  import type { SkRRect } from "../types";
3
- import { HostObject } from "./Host";
3
+ import { BaseHostObject } from "./Host";
4
4
  import { JsiSkRect } from "./JsiSkRect";
5
- export declare class JsiSkRRect extends HostObject<RRect, "RRect"> implements SkRRect {
5
+ export declare class JsiSkRRect extends BaseHostObject<RRect, "RRect"> implements SkRRect {
6
+ static fromValue(CanvasKit: CanvasKit, rect: SkRRect): Float32Array;
6
7
  constructor(CanvasKit: CanvasKit, ref: RRect);
7
8
  get rx(): number;
8
9
  get ry(): number;
@@ -1,8 +1,7 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
2
  import type { SkRSXform } from "../types";
3
3
  import { HostObject } from "./Host";
4
- declare type RSXform = Float32Array;
4
+ export declare type RSXform = Float32Array;
5
5
  export declare class JsiSkRSXform extends HostObject<RSXform, "RSXform"> implements SkRSXform {
6
6
  constructor(CanvasKit: CanvasKit, ref: RSXform);
7
7
  }
8
- export {};
@@ -1,8 +1,8 @@
1
1
  import type { CanvasKit, Rect } from "canvaskit-wasm";
2
2
  import type { SkRect } from "../types";
3
- import { HostObject } from "./Host";
4
- export declare class JsiSkRect extends HostObject<Rect, "Rect"> implements SkRect {
5
- static fromValue(CanvasKit: CanvasKit, rect: SkRect): JsiSkRect;
3
+ import { BaseHostObject } from "./Host";
4
+ export declare class JsiSkRect extends BaseHostObject<Rect, "Rect"> implements SkRect {
5
+ static fromValue(CanvasKit: CanvasKit, rect: SkRect): Float32Array;
6
6
  constructor(CanvasKit: CanvasKit, ref: Rect);
7
7
  get x(): number;
8
8
  get y(): number;
@@ -1,6 +1,7 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
- import type { SkFont, SkRSXform } from "../types";
2
+ import type { SkFont } from "../types";
3
3
  import type { TextBlobFactory } from "../types/TextBlob";
4
+ import type { SkRSXform } from "../types/RSXform";
4
5
  import { Host } from "./Host";
5
6
  import { JsiSkTextBlob } from "./JsiSkTextBlob";
6
7
  export declare class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
@@ -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,14 @@
1
+ import type { SkiaValue } from "./types";
2
+ export declare type SkiaSelector<TReturn, TInput = unknown> = {
3
+ value: SkiaValue<TInput>;
4
+ selector: (v: TInput) => TReturn;
5
+ };
6
+ /**
7
+ * Wraps a Skia Value with a selector function. The selector function can access the
8
+ * inner values of the Skia Value so that we can dynamically ready array values and
9
+ * object values when doing animations in Skia.
10
+ * @param value Dependant value
11
+ * @param selector Selector function to calculate new value from the Skia Value's value
12
+ * @returns A descriptor that will be used by the reconciler to calculate the value
13
+ */
14
+ export declare const Selector: <TInput, TReturn>(value: SkiaValue<TInput>, selector: (v: TInput) => TReturn) => SkiaSelector<TReturn, TInput>;
@@ -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
  */
@@ -6,4 +6,5 @@ export declare class RNSkComputedValue<T> extends RNSkReadonlyValue<T> {
6
6
  private _callback;
7
7
  private _unsubscribers;
8
8
  unsubscribe(): void;
9
+ __invalidate(): void;
9
10
  }
@@ -8,4 +8,5 @@ export declare class RNSkReadonlyValue<T> implements SkiaValue<T> {
8
8
  readonly __typename__ = "RNSkValue";
9
9
  get current(): T;
10
10
  addListener(cb: (value: T) => void): () => void;
11
+ __invalidate(): void;
11
12
  }
@@ -6,32 +6,32 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_arm64e_x86_64-simulator</string>
9
+ <string>ios-arm64_arm64e</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>libskia.a</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
15
  <string>arm64e</string>
16
- <string>x86_64</string>
17
16
  </array>
18
17
  <key>SupportedPlatform</key>
19
18
  <string>ios</string>
20
- <key>SupportedPlatformVariant</key>
21
- <string>simulator</string>
22
19
  </dict>
23
20
  <dict>
24
21
  <key>LibraryIdentifier</key>
25
- <string>ios-arm64_arm64e</string>
22
+ <string>ios-arm64_arm64e_x86_64-simulator</string>
26
23
  <key>LibraryPath</key>
27
24
  <string>libskia.a</string>
28
25
  <key>SupportedArchitectures</key>
29
26
  <array>
30
27
  <string>arm64</string>
31
28
  <string>arm64e</string>
29
+ <string>x86_64</string>
32
30
  </array>
33
31
  <key>SupportedPlatform</key>
34
32
  <string>ios</string>
33
+ <key>SupportedPlatformVariant</key>
34
+ <string>simulator</string>
35
35
  </dict>
36
36
  </array>
37
37
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.141",
10
+ "version": "0.1.145",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "scripts": {
39
39
  "tsc": "tsc --noEmit",
40
- "lint": "eslint . --ext .ts,.tsx --max-warnings 0",
40
+ "lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
41
41
  "test": "jest",
42
42
  "postinstall": "node scripts/install-npm.js",
43
43
  "build": "bob build"
@@ -89,7 +89,7 @@
89
89
  "typescript": "^4.6.4"
90
90
  },
91
91
  "dependencies": {
92
- "canvaskit-wasm": "^0.35.0",
92
+ "canvaskit-wasm": "^0.36.0",
93
93
  "react-reconciler": "^0.26.2"
94
94
  },
95
95
  "eslintIgnore": [
package/src/mock/index.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  import type { Color, Skia as SkiaApi, SkRect, Vector } from "../skia/types";
4
4
  import * as Values from "../values/web";
5
5
  import * as ValuesHooks from "../values/hooks";
6
+ import { Selector } from "../values/selector";
6
7
  import * as BaseSkia from "../skia/types";
7
8
  import type * as SkiaExports from "../skia";
8
9
  import type * as ExternalExports from "../external";
@@ -46,7 +47,6 @@ export const Mock: typeof SkiaExports &
46
47
  Skia,
47
48
  ...BaseSkia,
48
49
  // 2. Hooks
49
- useDataCollection: Noop,
50
50
  useRawData: Noop,
51
51
  useData: Noop,
52
52
  useFont: Noop,
@@ -87,6 +87,7 @@ export const Mock: typeof SkiaExports &
87
87
  // ValueExports
88
88
  ...Values,
89
89
  ...ValuesHooks,
90
+ Selector,
90
91
  // Animations
91
92
  ...timingFunctions,
92
93
  ...springFunctions,
@@ -20,6 +20,7 @@ import { SkiaView, useDrawCallback } from "../views";
20
20
  import type { TouchHandler } from "../views";
21
21
  import { useValue } from "../values/hooks/useValue";
22
22
  import { Skia } from "../skia/Skia";
23
+ import type { SkiaValue } from "../values";
23
24
 
24
25
  import { debug as hostDebug, skHostConfig } from "./HostConfig";
25
26
  // import { debugTree } from "./nodes";
@@ -38,8 +39,7 @@ skiaReconciler.injectIntoDevTools({
38
39
  const render = (element: ReactNode, root: OpaqueRoot, container: Container) => {
39
40
  skiaReconciler.updateContainer(element, root, null, () => {
40
41
  hostDebug("updateContainer");
41
-
42
- container.depMgr.subscribe();
42
+ container.depMgr.update();
43
43
  });
44
44
  };
45
45
 
@@ -60,9 +60,19 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
60
60
  const [tick, setTick] = useState(0);
61
61
  const redraw = useCallback(() => setTick((t) => t + 1), []);
62
62
 
63
+ const registerValues = useCallback(
64
+ (values: Array<SkiaValue<unknown>>) => {
65
+ if (ref.current === null) {
66
+ throw new Error("Canvas ref is not set");
67
+ }
68
+ return ref.current.registerValues(values);
69
+ },
70
+ [ref]
71
+ );
72
+
63
73
  const container = useMemo(
64
- () => new Container(new DependencyManager(ref), redraw),
65
- [redraw, ref]
74
+ () => new Container(new DependencyManager(registerValues), redraw),
75
+ [redraw, registerValues]
66
76
  );
67
77
 
68
78
  const root = useMemo(
@@ -78,6 +88,8 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
78
88
  );
79
89
  }, [children, root, redraw, container, canvasCtx]);
80
90
 
91
+ const paint = useMemo(() => Skia.Paint(), []);
92
+
81
93
  // Draw callback
82
94
  const onDraw = useDrawCallback(
83
95
  (canvas, info) => {
@@ -92,7 +104,7 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
92
104
  ) {
93
105
  canvasCtx.size.current = { width, height };
94
106
  }
95
- const paint = Skia.Paint();
107
+ paint.reset();
96
108
  const ctx = {
97
109
  width,
98
110
  height,
@@ -101,7 +113,7 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
101
113
  paint,
102
114
  opacity: 1,
103
115
  ref,
104
- center: Skia.Point(width / 2, height / 2),
116
+ center: { x: width / 2, y: height / 2 },
105
117
  Skia,
106
118
  };
107
119
  container.draw(ctx);
@@ -112,7 +124,7 @@ export const Canvas = forwardRef<SkiaView, CanvasProps>(
112
124
  useEffect(() => {
113
125
  return () => {
114
126
  skiaReconciler.updateContainer(null, root, null, () => {
115
- container.depMgr.unsubscribe();
127
+ container.depMgr.remove();
116
128
  });
117
129
  };
118
130
  }, [container, root]);