@shopify/react-native-skia 0.1.225 → 0.1.228

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 (326) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +3 -3
  2. package/cpp/api/JsiSkCanvas.h +2 -1
  3. package/cpp/api/JsiSkMatrix.h +35 -13
  4. package/cpp/api/JsiSkPictureRecorder.h +10 -3
  5. package/cpp/api/JsiSkTypeface.h +1 -0
  6. package/cpp/rnskia/dom/props/MatrixProp.h +19 -0
  7. package/cpp/rnskia/dom/props/TransformProp.h +76 -9
  8. package/lib/commonjs/animation/spring/runSpring.d.ts +3 -0
  9. package/lib/commonjs/animation/spring/runSpring.js +3 -0
  10. package/lib/commonjs/animation/spring/runSpring.js.map +1 -1
  11. package/lib/commonjs/animation/spring/useSpring.d.ts +3 -0
  12. package/lib/commonjs/animation/spring/useSpring.js +3 -0
  13. package/lib/commonjs/animation/spring/useSpring.js.map +1 -1
  14. package/lib/commonjs/animation/timing/runTiming.d.ts +3 -0
  15. package/lib/commonjs/animation/timing/runTiming.js +3 -0
  16. package/lib/commonjs/animation/timing/runTiming.js.map +1 -1
  17. package/lib/commonjs/animation/timing/useLoop.d.ts +3 -0
  18. package/lib/commonjs/animation/timing/useLoop.js +3 -0
  19. package/lib/commonjs/animation/timing/useLoop.js.map +1 -1
  20. package/lib/commonjs/animation/timing/useTiming.d.ts +3 -0
  21. package/lib/commonjs/animation/timing/useTiming.js +3 -0
  22. package/lib/commonjs/animation/timing/useTiming.js.map +1 -1
  23. package/lib/commonjs/dom/nodes/JsiSkDOM.js +2 -0
  24. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  25. package/lib/commonjs/dom/nodes/datatypes/Fitting.d.ts +5 -5
  26. package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
  27. package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +235 -75
  28. package/lib/commonjs/dom/nodes/datatypes/Gradient.js.map +1 -1
  29. package/lib/commonjs/dom/types/Common.d.ts +3 -3
  30. package/lib/commonjs/dom/types/Common.js.map +1 -1
  31. package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -0
  32. package/lib/commonjs/external/reanimated/interpolators.js +24 -5
  33. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  34. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -1
  35. package/lib/commonjs/external/reanimated/moduleWrapper.js +9 -7
  36. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  37. package/lib/commonjs/renderer/Canvas.js +34 -28
  38. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  39. package/lib/commonjs/renderer/components/Drawing.d.ts +5 -0
  40. package/lib/commonjs/renderer/components/Drawing.js +5 -0
  41. package/lib/commonjs/renderer/components/Drawing.js.map +1 -1
  42. package/lib/commonjs/renderer/components/shapes/FitBox.d.ts +5 -5
  43. package/lib/commonjs/skia/core/Matrix.d.ts +2 -2
  44. package/lib/commonjs/skia/core/Matrix.js.map +1 -1
  45. package/lib/commonjs/skia/core/Picture.d.ts +2 -2
  46. package/lib/commonjs/skia/core/Picture.js +12 -2
  47. package/lib/commonjs/skia/core/Picture.js.map +1 -1
  48. package/lib/commonjs/skia/core/Vector.d.ts +0 -5
  49. package/lib/commonjs/skia/core/Vector.js +1 -17
  50. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  51. package/lib/commonjs/skia/types/Canvas.d.ts +1 -1
  52. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  53. package/lib/commonjs/skia/types/Matrix.d.ts +4 -20
  54. package/lib/commonjs/skia/types/Matrix.js +4 -70
  55. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  56. package/lib/commonjs/skia/types/Matrix4.d.ts +90 -0
  57. package/lib/commonjs/skia/types/Matrix4.js +312 -0
  58. package/lib/commonjs/skia/types/Matrix4.js.map +1 -0
  59. package/lib/commonjs/skia/types/Path/Path.d.ts +1 -1
  60. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  61. package/lib/commonjs/skia/types/Picture/PictureRecorder.d.ts +1 -1
  62. package/lib/commonjs/skia/types/Picture/PictureRecorder.js.map +1 -1
  63. package/lib/commonjs/skia/types/Rect.d.ts +1 -0
  64. package/lib/commonjs/skia/types/Rect.js +18 -0
  65. package/lib/commonjs/skia/types/Rect.js.map +1 -1
  66. package/lib/commonjs/skia/types/index.d.ts +1 -0
  67. package/lib/commonjs/skia/types/index.js +13 -0
  68. package/lib/commonjs/skia/types/index.js.map +1 -1
  69. package/lib/commonjs/skia/web/Host.d.ts +2 -3
  70. package/lib/commonjs/skia/web/Host.js +4 -12
  71. package/lib/commonjs/skia/web/Host.js.map +1 -1
  72. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  73. package/lib/commonjs/skia/web/JsiSkCanvas.js +13 -13
  74. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  75. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  76. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  77. package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
  78. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  79. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  80. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  81. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  82. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  83. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
  84. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  85. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  86. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  87. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
  88. package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
  89. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  90. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  91. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  92. package/lib/commonjs/skia/web/JsiSkPath.js +5 -5
  93. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  94. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
  95. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  96. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  97. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  98. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  99. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  100. package/lib/commonjs/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  101. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +1 -1
  102. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
  103. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  104. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  105. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
  106. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  107. package/lib/commonjs/values/api.d.ts +23 -2
  108. package/lib/commonjs/values/api.js +44 -1
  109. package/lib/commonjs/values/api.js.map +1 -1
  110. package/lib/commonjs/values/hooks/useClockValue.d.ts +3 -0
  111. package/lib/commonjs/values/hooks/useClockValue.js +3 -0
  112. package/lib/commonjs/values/hooks/useClockValue.js.map +1 -1
  113. package/lib/commonjs/values/hooks/useComputedValue.d.ts +3 -0
  114. package/lib/commonjs/values/hooks/useComputedValue.js +3 -0
  115. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  116. package/lib/commonjs/values/hooks/useValue.d.ts +3 -0
  117. package/lib/commonjs/values/hooks/useValue.js +3 -0
  118. package/lib/commonjs/values/hooks/useValue.js.map +1 -1
  119. package/lib/commonjs/values/hooks/useValueEffect.d.ts +3 -0
  120. package/lib/commonjs/values/hooks/useValueEffect.js +3 -0
  121. package/lib/commonjs/values/hooks/useValueEffect.js.map +1 -1
  122. package/lib/commonjs/values/types.d.ts +4 -4
  123. package/lib/commonjs/values/types.js.map +1 -1
  124. package/lib/commonjs/views/SkiaView.d.ts +5 -0
  125. package/lib/commonjs/views/SkiaView.js +9 -0
  126. package/lib/commonjs/views/SkiaView.js.map +1 -1
  127. package/lib/module/animation/spring/runSpring.d.ts +3 -0
  128. package/lib/module/animation/spring/runSpring.js +3 -0
  129. package/lib/module/animation/spring/runSpring.js.map +1 -1
  130. package/lib/module/animation/spring/useSpring.d.ts +3 -0
  131. package/lib/module/animation/spring/useSpring.js +3 -0
  132. package/lib/module/animation/spring/useSpring.js.map +1 -1
  133. package/lib/module/animation/timing/runTiming.d.ts +3 -0
  134. package/lib/module/animation/timing/runTiming.js +3 -0
  135. package/lib/module/animation/timing/runTiming.js.map +1 -1
  136. package/lib/module/animation/timing/useLoop.d.ts +3 -0
  137. package/lib/module/animation/timing/useLoop.js +3 -0
  138. package/lib/module/animation/timing/useLoop.js.map +1 -1
  139. package/lib/module/animation/timing/useTiming.d.ts +3 -0
  140. package/lib/module/animation/timing/useTiming.js +3 -0
  141. package/lib/module/animation/timing/useTiming.js.map +1 -1
  142. package/lib/module/dom/nodes/JsiSkDOM.js +2 -0
  143. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  144. package/lib/module/dom/nodes/datatypes/Fitting.d.ts +5 -5
  145. package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
  146. package/lib/module/dom/nodes/datatypes/Gradient.d.ts +235 -75
  147. package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
  148. package/lib/module/dom/types/Common.d.ts +3 -3
  149. package/lib/module/dom/types/Common.js.map +1 -1
  150. package/lib/module/external/reanimated/interpolators.d.ts +1 -0
  151. package/lib/module/external/reanimated/interpolators.js +22 -6
  152. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  153. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
  154. package/lib/module/external/reanimated/moduleWrapper.js +7 -6
  155. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  156. package/lib/module/renderer/Canvas.js +35 -29
  157. package/lib/module/renderer/Canvas.js.map +1 -1
  158. package/lib/module/renderer/components/Drawing.d.ts +5 -0
  159. package/lib/module/renderer/components/Drawing.js +6 -0
  160. package/lib/module/renderer/components/Drawing.js.map +1 -1
  161. package/lib/module/renderer/components/shapes/FitBox.d.ts +5 -5
  162. package/lib/module/skia/core/Matrix.d.ts +2 -2
  163. package/lib/module/skia/core/Matrix.js.map +1 -1
  164. package/lib/module/skia/core/Picture.d.ts +2 -2
  165. package/lib/module/skia/core/Picture.js +12 -3
  166. package/lib/module/skia/core/Picture.js.map +1 -1
  167. package/lib/module/skia/core/Vector.d.ts +0 -5
  168. package/lib/module/skia/core/Vector.js +0 -13
  169. package/lib/module/skia/core/Vector.js.map +1 -1
  170. package/lib/module/skia/types/Canvas.d.ts +1 -1
  171. package/lib/module/skia/types/Canvas.js.map +1 -1
  172. package/lib/module/skia/types/Matrix.d.ts +4 -20
  173. package/lib/module/skia/types/Matrix.js +3 -71
  174. package/lib/module/skia/types/Matrix.js.map +1 -1
  175. package/lib/module/skia/types/Matrix4.d.ts +90 -0
  176. package/lib/module/skia/types/Matrix4.js +274 -0
  177. package/lib/module/skia/types/Matrix4.js.map +1 -0
  178. package/lib/module/skia/types/Path/Path.d.ts +1 -1
  179. package/lib/module/skia/types/Path/Path.js.map +1 -1
  180. package/lib/module/skia/types/Picture/PictureRecorder.d.ts +1 -1
  181. package/lib/module/skia/types/Picture/PictureRecorder.js.map +1 -1
  182. package/lib/module/skia/types/Rect.d.ts +1 -0
  183. package/lib/module/skia/types/Rect.js +9 -0
  184. package/lib/module/skia/types/Rect.js.map +1 -1
  185. package/lib/module/skia/types/index.d.ts +1 -0
  186. package/lib/module/skia/types/index.js +1 -0
  187. package/lib/module/skia/types/index.js.map +1 -1
  188. package/lib/module/skia/web/Host.d.ts +2 -3
  189. package/lib/module/skia/web/Host.js +2 -7
  190. package/lib/module/skia/web/Host.js.map +1 -1
  191. package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  192. package/lib/module/skia/web/JsiSkCanvas.js +14 -14
  193. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  194. package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
  195. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  196. package/lib/module/skia/web/JsiSkFont.js +3 -3
  197. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  198. package/lib/module/skia/web/JsiSkImage.js +7 -7
  199. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  200. package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
  201. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  202. package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
  203. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  204. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
  205. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  206. package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
  207. package/lib/module/skia/web/JsiSkMatrix.js +6 -1
  208. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  209. package/lib/module/skia/web/JsiSkPaint.js +4 -4
  210. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  211. package/lib/module/skia/web/JsiSkPath.js +6 -6
  212. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  213. package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
  214. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  215. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  216. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  217. package/lib/module/skia/web/JsiSkPicture.js +2 -2
  218. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  219. package/lib/module/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  220. package/lib/module/skia/web/JsiSkPictureRecorder.js +1 -1
  221. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  222. package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
  223. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  224. package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
  225. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  226. package/lib/module/values/api.d.ts +23 -2
  227. package/lib/module/values/api.js +44 -1
  228. package/lib/module/values/api.js.map +1 -1
  229. package/lib/module/values/hooks/useClockValue.d.ts +3 -0
  230. package/lib/module/values/hooks/useClockValue.js +3 -0
  231. package/lib/module/values/hooks/useClockValue.js.map +1 -1
  232. package/lib/module/values/hooks/useComputedValue.d.ts +3 -0
  233. package/lib/module/values/hooks/useComputedValue.js +3 -0
  234. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  235. package/lib/module/values/hooks/useValue.d.ts +3 -0
  236. package/lib/module/values/hooks/useValue.js +3 -0
  237. package/lib/module/values/hooks/useValue.js.map +1 -1
  238. package/lib/module/values/hooks/useValueEffect.d.ts +3 -0
  239. package/lib/module/values/hooks/useValueEffect.js +3 -0
  240. package/lib/module/values/hooks/useValueEffect.js.map +1 -1
  241. package/lib/module/values/types.d.ts +4 -4
  242. package/lib/module/values/types.js.map +1 -1
  243. package/lib/module/views/SkiaView.d.ts +5 -0
  244. package/lib/module/views/SkiaView.js +10 -0
  245. package/lib/module/views/SkiaView.js.map +1 -1
  246. package/lib/typescript/src/animation/spring/runSpring.d.ts +3 -0
  247. package/lib/typescript/src/animation/spring/useSpring.d.ts +3 -0
  248. package/lib/typescript/src/animation/timing/runTiming.d.ts +3 -0
  249. package/lib/typescript/src/animation/timing/useLoop.d.ts +3 -0
  250. package/lib/typescript/src/animation/timing/useTiming.d.ts +3 -0
  251. package/lib/typescript/src/dom/nodes/datatypes/Fitting.d.ts +5 -5
  252. package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +235 -75
  253. package/lib/typescript/src/dom/types/Common.d.ts +3 -3
  254. package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
  255. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
  256. package/lib/typescript/src/renderer/components/Drawing.d.ts +5 -0
  257. package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +5 -5
  258. package/lib/typescript/src/skia/core/Matrix.d.ts +2 -2
  259. package/lib/typescript/src/skia/core/Picture.d.ts +2 -2
  260. package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
  261. package/lib/typescript/src/skia/types/Canvas.d.ts +1 -1
  262. package/lib/typescript/src/skia/types/Matrix.d.ts +4 -20
  263. package/lib/typescript/src/skia/types/Matrix4.d.ts +90 -0
  264. package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -1
  265. package/lib/typescript/src/skia/types/Picture/PictureRecorder.d.ts +1 -1
  266. package/lib/typescript/src/skia/types/Rect.d.ts +1 -0
  267. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  268. package/lib/typescript/src/skia/web/Host.d.ts +2 -3
  269. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
  270. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
  271. package/lib/typescript/src/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  272. package/lib/typescript/src/values/api.d.ts +23 -2
  273. package/lib/typescript/src/values/hooks/useClockValue.d.ts +3 -0
  274. package/lib/typescript/src/values/hooks/useComputedValue.d.ts +3 -0
  275. package/lib/typescript/src/values/hooks/useValue.d.ts +3 -0
  276. package/lib/typescript/src/values/hooks/useValueEffect.d.ts +3 -0
  277. package/lib/typescript/src/values/types.d.ts +4 -4
  278. package/lib/typescript/src/views/SkiaView.d.ts +5 -0
  279. package/package.json +2 -1
  280. package/src/animation/spring/runSpring.ts +3 -0
  281. package/src/animation/spring/useSpring.ts +3 -0
  282. package/src/animation/timing/runTiming.ts +3 -0
  283. package/src/animation/timing/useLoop.ts +3 -0
  284. package/src/animation/timing/useTiming.ts +3 -0
  285. package/src/dom/nodes/JsiSkDOM.ts +4 -0
  286. package/src/dom/nodes/datatypes/Fitting.ts +10 -2
  287. package/src/dom/nodes/datatypes/Gradient.ts +2 -2
  288. package/src/dom/types/Common.ts +5 -3
  289. package/src/external/reanimated/interpolators.ts +30 -7
  290. package/src/external/reanimated/moduleWrapper.ts +6 -0
  291. package/src/renderer/Canvas.tsx +41 -30
  292. package/src/renderer/components/Drawing.tsx +5 -0
  293. package/src/skia/core/Matrix.ts +2 -2
  294. package/src/skia/core/Picture.ts +11 -3
  295. package/src/skia/core/Vector.ts +0 -4
  296. package/src/skia/types/Canvas.ts +1 -1
  297. package/src/skia/types/Matrix.ts +7 -85
  298. package/src/skia/types/Matrix4.ts +344 -0
  299. package/src/skia/types/Path/Path.ts +1 -1
  300. package/src/skia/types/Picture/PictureRecorder.ts +1 -1
  301. package/src/skia/types/Rect.ts +14 -0
  302. package/src/skia/types/index.ts +1 -0
  303. package/src/skia/web/Host.ts +4 -3
  304. package/src/skia/web/JsiSkCanvas.ts +24 -17
  305. package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
  306. package/src/skia/web/JsiSkFont.ts +3 -3
  307. package/src/skia/web/JsiSkImage.ts +14 -11
  308. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  309. package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
  310. package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
  311. package/src/skia/web/JsiSkMatrix.ts +14 -3
  312. package/src/skia/web/JsiSkPaint.ts +4 -4
  313. package/src/skia/web/JsiSkPath.ts +9 -6
  314. package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
  315. package/src/skia/web/JsiSkPathFactory.ts +2 -2
  316. package/src/skia/web/JsiSkPicture.ts +4 -4
  317. package/src/skia/web/JsiSkPictureRecorder.ts +6 -2
  318. package/src/skia/web/JsiSkShaderFactory.ts +6 -6
  319. package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
  320. package/src/values/api.ts +55 -2
  321. package/src/values/hooks/useClockValue.ts +3 -0
  322. package/src/values/hooks/useComputedValue.ts +3 -0
  323. package/src/values/hooks/useValue.ts +3 -0
  324. package/src/values/hooks/useValueEffect.ts +3 -0
  325. package/src/values/types.ts +6 -6
  326. package/src/views/SkiaView.tsx +11 -0
@@ -4,7 +4,6 @@ import React, {
4
4
  useMemo,
5
5
  forwardRef,
6
6
  useRef,
7
- useLayoutEffect,
8
7
  } from "react";
9
8
  import type {
10
9
  RefObject,
@@ -13,13 +12,13 @@ import type {
13
12
  ForwardedRef,
14
13
  FunctionComponent,
15
14
  } from "react";
15
+ import type { LayoutChangeEvent } from "react-native";
16
16
 
17
- import { SkiaDomView, SkiaView } from "../views";
17
+ import { SkiaDomView, SkiaPictureView } from "../views";
18
18
  import { Skia } from "../skia/Skia";
19
19
  import type { TouchHandler, SkiaBaseViewProps } from "../views";
20
20
  import type { SkiaValue } from "../values/types";
21
21
  import { JsiDrawingContext } from "../dom/types";
22
- import { useValue } from "../values";
23
22
 
24
23
  import { SkiaRoot } from "./Reconciler";
25
24
  import { NATIVE_DOM } from "./HostComponents";
@@ -33,34 +32,42 @@ export interface CanvasProps extends SkiaBaseViewProps {
33
32
  onTouch?: TouchHandler;
34
33
  }
35
34
 
36
- const useOnSizeEvent = (resultValue: SkiaBaseViewProps["onSize"]) => {
37
- const onSize = useValue({
38
- width: 0,
39
- height: 0,
40
- });
35
+ const useOnSizeEvent = (
36
+ resultValue: SkiaBaseViewProps["onSize"],
37
+ onLayout?: (event: LayoutChangeEvent) => void
38
+ ) => {
39
+ return useCallback(
40
+ (event: LayoutChangeEvent) => {
41
+ if (onLayout) {
42
+ onLayout(event);
43
+ }
44
+ const { width, height } = event.nativeEvent.layout;
41
45
 
42
- useLayoutEffect(() => {
43
- if (!resultValue) {
44
- return;
45
- }
46
- return onSize.addListener((newValue) => {
47
46
  if (isValue(resultValue)) {
48
- resultValue.current = newValue;
49
- } else {
50
- resultValue.value = newValue;
47
+ resultValue.current = { width, height };
48
+ } else if (resultValue) {
49
+ resultValue.value = { width, height };
51
50
  }
52
- });
53
- }, [resultValue, onSize]);
54
-
55
- return onSize;
51
+ },
52
+ [onLayout, resultValue]
53
+ );
56
54
  };
57
55
 
58
56
  export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
59
57
  (
60
- { children, style, debug, mode, onTouch, onSize: _onSize, ...props },
58
+ {
59
+ children,
60
+ style,
61
+ debug,
62
+ mode,
63
+ onTouch,
64
+ onSize: _onSize,
65
+ onLayout: _onLayout,
66
+ ...props
67
+ },
61
68
  forwardedRef
62
69
  ) => {
63
- const onSize = useOnSizeEvent(_onSize);
70
+ const onLayout = useOnSizeEvent(_onSize, _onLayout);
64
71
  const innerRef = useCanvasRef();
65
72
  const ref = useCombinedRefs(forwardedRef, innerRef);
66
73
  const redraw = useCallback(() => {
@@ -102,26 +109,30 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
102
109
  style={style}
103
110
  root={root.dom}
104
111
  onTouch={onTouch}
105
- onSize={onSize}
112
+ onLayout={onLayout}
106
113
  mode={mode}
107
114
  debug={debug}
108
115
  {...props}
109
116
  />
110
117
  );
111
118
  } else {
119
+ // This is for debugging
120
+ const recorder = Skia.PictureRecorder();
121
+ const canvas = recorder.beginRecording(
122
+ Skia.XYWHRect(0, 0, 2_000_000, 2_000_000)
123
+ );
124
+ const ctx = new JsiDrawingContext(Skia, canvas);
125
+ root.dom.render(ctx);
126
+ const picture = recorder.finishRecordingAsPicture();
112
127
  return (
113
- <SkiaView
128
+ <SkiaPictureView
114
129
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
130
  ref={ref as any}
116
131
  style={style}
117
132
  mode={mode}
118
133
  debug={debug}
119
- onSize={onSize}
120
- onDraw={(canvas, info) => {
121
- onTouch && onTouch(info.touches);
122
- const ctx = new JsiDrawingContext(Skia, canvas);
123
- root.dom.render(ctx);
124
- }}
134
+ picture={picture}
135
+ onLayout={onLayout}
125
136
  {...props}
126
137
  />
127
138
  );
@@ -2,6 +2,11 @@ import React from "react";
2
2
 
3
3
  import type { CustomDrawingNodeProps } from "../../dom/types";
4
4
 
5
+ /**
6
+ * @deprecated If you are looking to use the Skia imperative API, you can use:
7
+ * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
8
+ * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
9
+ */
5
10
  export const Drawing = (props: CustomDrawingNodeProps) => {
6
11
  return <skDrawing {...props} />;
7
12
  };
@@ -1,6 +1,6 @@
1
1
  import { Skia } from "../Skia";
2
- import type { Transforms2d } from "../types";
2
+ import type { Transforms3d } from "../types";
3
3
  import { processTransform } from "../types";
4
4
 
5
- export const processTransform2d = (transforms: Transforms2d) =>
5
+ export const processTransform2d = (transforms: Transforms3d) =>
6
6
  processTransform(Skia.Matrix(), transforms);
@@ -1,5 +1,5 @@
1
1
  import { Skia } from "../Skia";
2
- import type { SkCanvas, SkRect } from "../types";
2
+ import { isRect, type SkCanvas, type SkRect, type SkSize } from "../types";
3
3
 
4
4
  /**
5
5
  * Memoizes and returns an SkPicture that can be drawn to another canvas.
@@ -7,9 +7,17 @@ import type { SkCanvas, SkRect } from "../types";
7
7
  * @param cb Callback for drawing to the canvas
8
8
  * @returns SkPicture
9
9
  */
10
- export const createPicture = (rect: SkRect, cb: (canvas: SkCanvas) => void) => {
10
+ export const createPicture = (
11
+ cb: (canvas: SkCanvas) => void,
12
+ rect?: SkRect | SkSize
13
+ ) => {
14
+ "worklet";
11
15
  const recorder = Skia.PictureRecorder();
12
- const canvas = recorder.beginRecording(rect);
16
+ let bounds: undefined | SkRect;
17
+ if (rect) {
18
+ bounds = isRect(rect) ? rect : Skia.XYWHRect(0, 0, rect.width, rect.height);
19
+ }
20
+ const canvas = recorder.beginRecording(bounds);
13
21
  cb(canvas);
14
22
  return recorder.finishRecordingAsPicture();
15
23
  };
@@ -22,7 +22,3 @@ export const dist = (a: Vector, b: Vector) => {
22
22
  "worklet";
23
23
  return Math.hypot(a.x - b.x, a.y - b.y);
24
24
  };
25
- export const translate = ({ x, y }: Vector) => {
26
- "worklet";
27
- return [{ translateX: x }, { translateY: y }] as const;
28
- };
@@ -485,7 +485,7 @@ export interface SkCanvas {
485
485
  * Replaces current matrix with m premultiplied with the existing matrix.
486
486
  * @param m
487
487
  */
488
- concat(m: SkMatrix): void;
488
+ concat(m: SkMatrix | number[]): void;
489
489
 
490
490
  /**
491
491
  * Draws the given picture using the current clip, current matrix, and the provided paint.
@@ -1,22 +1,13 @@
1
1
  import type { SkJSIInstance } from "./JsiInstance";
2
2
  import type { SkCanvas } from "./Canvas";
3
- export enum MatrixIndex {
4
- ScaleX = 0,
5
- SkewX = 1,
6
- TransX = 2,
7
- SkewY = 3,
8
- ScaleY = 4,
9
- TransY = 5,
10
- Persp0 = 6,
11
- Persp1 = 7,
12
- Persp2 = 8,
13
- }
3
+ import type { Matrix3, Matrix4, Transforms3d } from "./Matrix4";
4
+ import { processTransform3d } from "./Matrix4";
14
5
 
15
6
  export const isMatrix = (obj: unknown): obj is SkMatrix =>
16
7
  obj !== null && (obj as SkJSIInstance<string>).__typename__ === "Matrix";
17
8
 
18
9
  export interface SkMatrix extends SkJSIInstance<"Matrix"> {
19
- concat: (matrix: SkMatrix) => SkMatrix;
10
+ concat: (matrix: SkMatrix | Matrix4 | Matrix3 | number[]) => SkMatrix;
20
11
  translate: (x: number, y: number) => SkMatrix;
21
12
  scale: (x: number, y?: number) => SkMatrix;
22
13
  skew: (x: number, y: number) => SkMatrix;
@@ -29,88 +20,19 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
29
20
  get: () => number[];
30
21
  }
31
22
 
32
- type Transform2dName =
33
- | "translateX"
34
- | "translateY"
35
- | "scale"
36
- | "skewX"
37
- | "skewY"
38
- | "scaleX"
39
- | "scaleY"
40
- | "rotateZ"
41
- | "rotate";
42
-
43
- type Transformations = {
44
- readonly [Name in Transform2dName]: number;
45
- };
46
-
47
- export type Transforms2d = readonly (
48
- | Pick<Transformations, "translateX">
49
- | Pick<Transformations, "translateY">
50
- | Pick<Transformations, "scale">
51
- | Pick<Transformations, "scaleX">
52
- | Pick<Transformations, "scaleY">
53
- | Pick<Transformations, "skewX">
54
- | Pick<Transformations, "skewY">
55
- | Pick<Transformations, "rotate">
56
- )[];
57
-
58
23
  export interface TransformProp {
59
- transform?: Transforms2d;
24
+ transform?: Transforms3d;
60
25
  }
61
26
 
62
27
  export const processTransform = <T extends SkMatrix | SkCanvas>(
63
28
  m: T,
64
- transforms: Transforms2d
29
+ transforms: Transforms3d
65
30
  ) => {
66
- for (const transform of transforms) {
67
- const key = Object.keys(transform)[0] as Transform2dName;
68
- const value = (transform as Pick<Transformations, typeof key>)[key];
69
- if (key === "translateX") {
70
- m.translate(value, 0);
71
- continue;
72
- }
73
- if (key === "translateY") {
74
- m.translate(0, value);
75
- continue;
76
- }
77
- if (key === "scale") {
78
- m.scale(value, value);
79
- continue;
80
- }
81
- if (key === "scaleX") {
82
- m.scale(value, 1);
83
- continue;
84
- }
85
- if (key === "scaleY") {
86
- m.scale(1, value);
87
- continue;
88
- }
89
- if (key === "skewX") {
90
- m.skew(value, 0);
91
- continue;
92
- }
93
- if (key === "skewY") {
94
- m.skew(0, value);
95
- continue;
96
- }
97
- if (key === "rotate" || key === "rotateZ") {
98
- if (isMatrix(m)) {
99
- m.rotate(value);
100
- } else {
101
- m.rotate(toDegrees(value), 0, 0);
102
- }
103
- continue;
104
- }
105
- exhaustiveCheck(key);
106
- }
31
+ const m3 = processTransform3d(transforms);
32
+ m.concat(m3);
107
33
  return m;
108
34
  };
109
35
 
110
- const exhaustiveCheck = (a: never): never => {
111
- throw new Error(`Unknown transformation: ${a}`);
112
- };
113
-
114
36
  export const toDegrees = (rad: number) => {
115
37
  return (rad * 180) / Math.PI;
116
38
  };
@@ -0,0 +1,344 @@
1
+ type Point = { x: number; y: number };
2
+ type Vec2 = readonly [number, number];
3
+ type Vec3 = readonly [number, number, number];
4
+ type Vec4 = readonly [number, number, number, number];
5
+
6
+ export type Matrix3 = readonly [
7
+ number,
8
+ number,
9
+ number,
10
+ number,
11
+ number,
12
+ number,
13
+ number,
14
+ number,
15
+ number
16
+ ];
17
+
18
+ export type Matrix4 = readonly [
19
+ number,
20
+ number,
21
+ number,
22
+ number,
23
+ number,
24
+ number,
25
+ number,
26
+ number,
27
+ number,
28
+ number,
29
+ number,
30
+ number,
31
+ number,
32
+ number,
33
+ number,
34
+ number
35
+ ];
36
+
37
+ type Transform3dName =
38
+ | "translateX"
39
+ | "translateY"
40
+ | "translateZ"
41
+ | "translate"
42
+ | "scale"
43
+ | "scaleX"
44
+ | "scaleY"
45
+ | "skewX"
46
+ | "skewY"
47
+ | "rotateZ"
48
+ | "rotate"
49
+ | "perspective"
50
+ | "rotateX"
51
+ | "rotateY"
52
+ | "matrix";
53
+
54
+ type Transformations = {
55
+ [Name in Transform3dName]: Name extends "matrix"
56
+ ? Matrix4
57
+ : Name extends "translate"
58
+ ? Vec3 | Vec2
59
+ : number;
60
+ };
61
+
62
+ type Transform3d =
63
+ | Pick<Transformations, "translateX">
64
+ | Pick<Transformations, "translateY">
65
+ | Pick<Transformations, "translateZ">
66
+ | Pick<Transformations, "translate">
67
+ | Pick<Transformations, "scale">
68
+ | Pick<Transformations, "scaleX">
69
+ | Pick<Transformations, "scaleY">
70
+ | Pick<Transformations, "skewX">
71
+ | Pick<Transformations, "skewY">
72
+ | Pick<Transformations, "perspective">
73
+ | Pick<Transformations, "rotateX">
74
+ | Pick<Transformations, "rotateY">
75
+ | Pick<Transformations, "rotateZ">
76
+ | Pick<Transformations, "rotate">
77
+ | Pick<Transformations, "matrix">;
78
+
79
+ export type Transforms3d = Transform3d[];
80
+
81
+ const exhaustiveCheck = (a: never): never => {
82
+ "worklet";
83
+ throw new Error(`Unexhaustive handling for ${a}`);
84
+ };
85
+
86
+ /**
87
+ * @worklet
88
+ */
89
+ export const Matrix4 = (): Matrix4 => {
90
+ "worklet";
91
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
92
+ };
93
+
94
+ /**
95
+ * @worklet
96
+ */
97
+ export const translate = (x: number, y: number, z: number = 0): Matrix4 => {
98
+ "worklet";
99
+ return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];
100
+ };
101
+
102
+ /**
103
+ * @worklet
104
+ */
105
+ export const perspective = (p: number): Matrix4 => {
106
+ "worklet";
107
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];
108
+ };
109
+
110
+ const normalizeVec = (vec: Vec3): Vec3 => {
111
+ "worklet";
112
+ const [x, y, z] = vec;
113
+ const length = Math.sqrt(x * x + y * y + z * z);
114
+ // Check for zero length to avoid division by zero
115
+ if (length === 0) {
116
+ return [0, 0, 0];
117
+ }
118
+ return [x / length, y / length, z / length];
119
+ };
120
+
121
+ const rotatedUnitSinCos = (
122
+ axisVec: Vec3,
123
+ sinAngle: number,
124
+ cosAngle: number
125
+ ): Matrix4 => {
126
+ "worklet";
127
+ const x = axisVec[0];
128
+ const y = axisVec[1];
129
+ const z = axisVec[2];
130
+ const c = cosAngle;
131
+ const s = sinAngle;
132
+ const t = 1 - c;
133
+ return [
134
+ t * x * x + c,
135
+ t * x * y - s * z,
136
+ t * x * z + s * y,
137
+ 0,
138
+ t * x * y + s * z,
139
+ t * y * y + c,
140
+ t * y * z - s * x,
141
+ 0,
142
+ t * x * z - s * y,
143
+ t * y * z + s * x,
144
+ t * z * z + c,
145
+ 0,
146
+ 0,
147
+ 0,
148
+ 0,
149
+ 1,
150
+ ];
151
+ };
152
+
153
+ const matrixVecMul4 = (m: Matrix4, v: Vec4) => {
154
+ "worklet";
155
+ const [vx, vy, vz, vw] = v;
156
+ return [
157
+ vx * m[0] + vy * m[4] + vz * m[8] + vw * m[12],
158
+ vx * m[1] + vy * m[5] + vz * m[9] + vw * m[13],
159
+ vx * m[2] + vy * m[6] + vz * m[10] + vw * m[14],
160
+ vx * m[3] + vy * m[7] + vz * m[11] + vw * m[15],
161
+ ];
162
+ };
163
+
164
+ /**
165
+ * @worklet
166
+ */
167
+ export const mapPoint3d = (m: Matrix4, v: Vec3) => {
168
+ "worklet";
169
+ const r = matrixVecMul4(m, [...v, 1]);
170
+ return [r[0] / r[3], r[1] / r[3], r[2] / r[3]] as const;
171
+ };
172
+
173
+ /**
174
+ * @worklet
175
+ */
176
+ export const multiply4 = (a: Matrix4, b: Matrix4): Matrix4 => {
177
+ "worklet";
178
+ const result = new Array(16).fill(0);
179
+ for (let i = 0; i < 4; i++) {
180
+ for (let j = 0; j < 4; j++) {
181
+ result[i * 4 + j] =
182
+ a[i * 4] * b[j] +
183
+ a[i * 4 + 1] * b[j + 4] +
184
+ a[i * 4 + 2] * b[j + 8] +
185
+ a[i * 4 + 3] * b[j + 12];
186
+ }
187
+ }
188
+ return result as unknown as Matrix4;
189
+ };
190
+
191
+ const skewY = (angle: number): Matrix4 => {
192
+ "worklet";
193
+ return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
194
+ };
195
+
196
+ const skewX = (angle: number): Matrix4 => {
197
+ "worklet";
198
+ return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
199
+ };
200
+
201
+ /**
202
+ * @worklet
203
+ */
204
+ export const toMatrix3 = (m: Matrix4) => {
205
+ "worklet";
206
+ return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];
207
+ };
208
+
209
+ const rotate = (axis: Vec3, value: number) => {
210
+ "worklet";
211
+ return rotatedUnitSinCos(
212
+ normalizeVec(axis),
213
+ Math.sin(value),
214
+ Math.cos(value)
215
+ );
216
+ };
217
+
218
+ /**
219
+ * @worklet
220
+ */
221
+ export const pivot = (m: Matrix4, p: Point) => {
222
+ "worklet";
223
+ return multiply4(translate(p.x, p.y), multiply4(m, translate(-p.x, -p.y)));
224
+ };
225
+
226
+ /**
227
+ * @worklet
228
+ */
229
+ export const scale = (
230
+ sx: number,
231
+ sy: number,
232
+ sz: number = 1,
233
+ p?: Point
234
+ ): Matrix4 => {
235
+ "worklet";
236
+ const m4: Matrix4 = [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];
237
+ if (p) {
238
+ return pivot(m4, p);
239
+ }
240
+ return m4;
241
+ };
242
+
243
+ const rotateAxis = (axis: Vec3, angle: number, p?: Point) => {
244
+ "worklet";
245
+ const result = rotate(axis, angle);
246
+ if (p) {
247
+ return pivot(result, p);
248
+ }
249
+ return result;
250
+ };
251
+
252
+ /**
253
+ * @worklet
254
+ */
255
+ export const rotateZ = (value: number, p?: Point) => {
256
+ "worklet";
257
+ return rotateAxis([0, 0, 1], value, p);
258
+ };
259
+
260
+ /**
261
+ * @worklet
262
+ */
263
+ export const rotateX = (value: number, p?: Point) => {
264
+ "worklet";
265
+ return rotateAxis([1, 0, 0], value, p);
266
+ };
267
+
268
+ /**
269
+ * @worklet
270
+ */
271
+ export const rotateY = (value: number, p?: Point) => {
272
+ "worklet";
273
+ return rotateAxis([0, 1, 0], value, p);
274
+ };
275
+
276
+ /**
277
+ * @worklet
278
+ */
279
+ export const processTransform3d = (transforms: Transforms3d) => {
280
+ "worklet";
281
+ return toMatrix3(
282
+ transforms.reduce((acc, val) => {
283
+ const key = Object.keys(val)[0] as Transform3dName;
284
+ const transform = val as Pick<Transformations, typeof key>;
285
+ if (key === "translateX") {
286
+ const value = transform[key];
287
+ return multiply4(acc, translate(value, 0, 0));
288
+ }
289
+ if (key === "translate") {
290
+ const [x, y, z = 0] = transform[key];
291
+ return multiply4(acc, translate(x, y, z));
292
+ }
293
+ if (key === "translateY") {
294
+ const value = transform[key];
295
+ return multiply4(acc, translate(0, value, 0));
296
+ }
297
+ if (key === "translateZ") {
298
+ const value = transform[key];
299
+ return multiply4(acc, translate(0, 0, value));
300
+ }
301
+ if (key === "scale") {
302
+ const value = transform[key];
303
+ return multiply4(acc, scale(value, value, 1));
304
+ }
305
+ if (key === "scaleX") {
306
+ const value = transform[key];
307
+ return multiply4(acc, scale(value, 1, 1));
308
+ }
309
+ if (key === "scaleY") {
310
+ const value = transform[key];
311
+ return multiply4(acc, scale(1, value, 1));
312
+ }
313
+ if (key === "skewX") {
314
+ const value = transform[key];
315
+ return multiply4(acc, skewX(value));
316
+ }
317
+ if (key === "skewY") {
318
+ const value = transform[key];
319
+ return multiply4(acc, skewY(value));
320
+ }
321
+ if (key === "rotateX") {
322
+ const value = transform[key];
323
+ return multiply4(acc, rotate([1, 0, 0], value));
324
+ }
325
+ if (key === "rotateY") {
326
+ const value = transform[key];
327
+ return multiply4(acc, rotate([0, 1, 0], value));
328
+ }
329
+ if (key === "perspective") {
330
+ const value = transform[key];
331
+ return multiply4(acc, perspective(value));
332
+ }
333
+ if (key === "rotate" || key === "rotateZ") {
334
+ const value = transform[key];
335
+ return multiply4(acc, rotate([0, 0, 1], value));
336
+ }
337
+ if (key === "matrix") {
338
+ const value = transform[key];
339
+ return multiply4(acc, value);
340
+ }
341
+ return exhaustiveCheck(key);
342
+ }, Matrix4())
343
+ );
344
+ };
@@ -540,7 +540,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
540
540
  /**
541
541
  * Transforms the path by the specified matrix.
542
542
  */
543
- transform(m3: SkMatrix): SkPath;
543
+ transform(m3: SkMatrix | number[]): SkPath;
544
544
 
545
545
  /**
546
546
  * Interpolates between Path with point array of equal size.
@@ -9,7 +9,7 @@ export interface SkPictureRecorder {
9
9
  *
10
10
  * @param bounds - a rect to cull the results.
11
11
  */
12
- beginRecording(bounds: SkRect): SkCanvas;
12
+ beginRecording(bounds?: SkRect): SkCanvas;
13
13
 
14
14
  /**
15
15
  * Returns the captured draw commands as a picture and invalidates the canvas returned earlier.
@@ -4,3 +4,17 @@ export interface SkRect {
4
4
  readonly width: number;
5
5
  readonly height: number;
6
6
  }
7
+
8
+ export const isRect = (def: unknown): def is SkRect => {
9
+ "worklet";
10
+ if (typeof def === "object" && def !== null) {
11
+ const rect = def as SkRect;
12
+ return (
13
+ typeof rect.x === "number" &&
14
+ typeof rect.y === "number" &&
15
+ typeof rect.width === "number" &&
16
+ typeof rect.height === "number"
17
+ );
18
+ }
19
+ return false;
20
+ };
@@ -28,3 +28,4 @@ export * from "./Skia";
28
28
  export * from "./TextBlob";
29
29
  export * from "./Size";
30
30
  export * from "./Paragraph";
31
+ export * from "./Matrix4";