@shopify/react-native-skia 0.1.225 → 0.1.227

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 (243) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +3 -3
  2. package/cpp/api/JsiSkMatrix.h +8 -2
  3. package/cpp/api/JsiSkPictureRecorder.h +10 -3
  4. package/cpp/rnskia/dom/props/MatrixProp.h +8 -0
  5. package/cpp/rnskia/dom/props/TransformProp.h +76 -9
  6. package/lib/commonjs/animation/spring/runSpring.d.ts +3 -0
  7. package/lib/commonjs/animation/spring/runSpring.js +3 -0
  8. package/lib/commonjs/animation/spring/runSpring.js.map +1 -1
  9. package/lib/commonjs/animation/spring/useSpring.d.ts +3 -0
  10. package/lib/commonjs/animation/spring/useSpring.js +3 -0
  11. package/lib/commonjs/animation/spring/useSpring.js.map +1 -1
  12. package/lib/commonjs/animation/timing/runTiming.d.ts +3 -0
  13. package/lib/commonjs/animation/timing/runTiming.js +3 -0
  14. package/lib/commonjs/animation/timing/runTiming.js.map +1 -1
  15. package/lib/commonjs/animation/timing/useLoop.d.ts +3 -0
  16. package/lib/commonjs/animation/timing/useLoop.js +3 -0
  17. package/lib/commonjs/animation/timing/useLoop.js.map +1 -1
  18. package/lib/commonjs/animation/timing/useTiming.d.ts +3 -0
  19. package/lib/commonjs/animation/timing/useTiming.js +3 -0
  20. package/lib/commonjs/animation/timing/useTiming.js.map +1 -1
  21. package/lib/commonjs/dom/nodes/JsiSkDOM.js +2 -0
  22. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  23. package/lib/commonjs/dom/nodes/datatypes/Fitting.d.ts +5 -5
  24. package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
  25. package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +235 -75
  26. package/lib/commonjs/dom/nodes/datatypes/Gradient.js.map +1 -1
  27. package/lib/commonjs/dom/types/Common.d.ts +3 -3
  28. package/lib/commonjs/dom/types/Common.js.map +1 -1
  29. package/lib/commonjs/external/reanimated/interpolators.js +10 -4
  30. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  31. package/lib/commonjs/renderer/Canvas.js +34 -28
  32. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  33. package/lib/commonjs/renderer/components/Drawing.d.ts +5 -0
  34. package/lib/commonjs/renderer/components/Drawing.js +5 -0
  35. package/lib/commonjs/renderer/components/Drawing.js.map +1 -1
  36. package/lib/commonjs/renderer/components/shapes/FitBox.d.ts +5 -5
  37. package/lib/commonjs/skia/core/Matrix.d.ts +2 -2
  38. package/lib/commonjs/skia/core/Matrix.js.map +1 -1
  39. package/lib/commonjs/skia/core/Picture.d.ts +2 -2
  40. package/lib/commonjs/skia/core/Picture.js +12 -2
  41. package/lib/commonjs/skia/core/Picture.js.map +1 -1
  42. package/lib/commonjs/skia/core/Vector.d.ts +3 -3
  43. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  44. package/lib/commonjs/skia/types/Canvas.d.ts +1 -1
  45. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  46. package/lib/commonjs/skia/types/Matrix.d.ts +4 -9
  47. package/lib/commonjs/skia/types/Matrix.js +5 -56
  48. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  49. package/lib/commonjs/skia/types/Matrix4.d.ts +39 -0
  50. package/lib/commonjs/skia/types/Matrix4.js +213 -0
  51. package/lib/commonjs/skia/types/Matrix4.js.map +1 -0
  52. package/lib/commonjs/skia/types/Path/Path.d.ts +1 -1
  53. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  54. package/lib/commonjs/skia/types/Picture/PictureRecorder.d.ts +1 -1
  55. package/lib/commonjs/skia/types/Picture/PictureRecorder.js.map +1 -1
  56. package/lib/commonjs/skia/types/Rect.d.ts +1 -0
  57. package/lib/commonjs/skia/types/Rect.js +18 -0
  58. package/lib/commonjs/skia/types/Rect.js.map +1 -1
  59. package/lib/commonjs/skia/types/index.d.ts +1 -0
  60. package/lib/commonjs/skia/types/index.js +13 -0
  61. package/lib/commonjs/skia/types/index.js.map +1 -1
  62. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  63. package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -1
  64. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  65. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +1 -1
  66. package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
  67. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  68. package/lib/commonjs/skia/web/JsiSkPath.js +1 -1
  69. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  70. package/lib/commonjs/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  71. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +1 -1
  72. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
  73. package/lib/commonjs/values/api.d.ts +23 -2
  74. package/lib/commonjs/values/api.js +44 -1
  75. package/lib/commonjs/values/api.js.map +1 -1
  76. package/lib/commonjs/values/hooks/useClockValue.d.ts +3 -0
  77. package/lib/commonjs/values/hooks/useClockValue.js +3 -0
  78. package/lib/commonjs/values/hooks/useClockValue.js.map +1 -1
  79. package/lib/commonjs/values/hooks/useComputedValue.d.ts +3 -0
  80. package/lib/commonjs/values/hooks/useComputedValue.js +3 -0
  81. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  82. package/lib/commonjs/values/hooks/useValue.d.ts +3 -0
  83. package/lib/commonjs/values/hooks/useValue.js +3 -0
  84. package/lib/commonjs/values/hooks/useValue.js.map +1 -1
  85. package/lib/commonjs/values/hooks/useValueEffect.d.ts +3 -0
  86. package/lib/commonjs/values/hooks/useValueEffect.js +3 -0
  87. package/lib/commonjs/values/hooks/useValueEffect.js.map +1 -1
  88. package/lib/commonjs/values/types.d.ts +4 -4
  89. package/lib/commonjs/values/types.js.map +1 -1
  90. package/lib/commonjs/views/SkiaView.d.ts +5 -0
  91. package/lib/commonjs/views/SkiaView.js +9 -0
  92. package/lib/commonjs/views/SkiaView.js.map +1 -1
  93. package/lib/module/animation/spring/runSpring.d.ts +3 -0
  94. package/lib/module/animation/spring/runSpring.js +3 -0
  95. package/lib/module/animation/spring/runSpring.js.map +1 -1
  96. package/lib/module/animation/spring/useSpring.d.ts +3 -0
  97. package/lib/module/animation/spring/useSpring.js +3 -0
  98. package/lib/module/animation/spring/useSpring.js.map +1 -1
  99. package/lib/module/animation/timing/runTiming.d.ts +3 -0
  100. package/lib/module/animation/timing/runTiming.js +3 -0
  101. package/lib/module/animation/timing/runTiming.js.map +1 -1
  102. package/lib/module/animation/timing/useLoop.d.ts +3 -0
  103. package/lib/module/animation/timing/useLoop.js +3 -0
  104. package/lib/module/animation/timing/useLoop.js.map +1 -1
  105. package/lib/module/animation/timing/useTiming.d.ts +3 -0
  106. package/lib/module/animation/timing/useTiming.js +3 -0
  107. package/lib/module/animation/timing/useTiming.js.map +1 -1
  108. package/lib/module/dom/nodes/JsiSkDOM.js +2 -0
  109. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  110. package/lib/module/dom/nodes/datatypes/Fitting.d.ts +5 -5
  111. package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
  112. package/lib/module/dom/nodes/datatypes/Gradient.d.ts +235 -75
  113. package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
  114. package/lib/module/dom/types/Common.d.ts +3 -3
  115. package/lib/module/dom/types/Common.js.map +1 -1
  116. package/lib/module/external/reanimated/interpolators.js +11 -5
  117. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  118. package/lib/module/renderer/Canvas.js +35 -29
  119. package/lib/module/renderer/Canvas.js.map +1 -1
  120. package/lib/module/renderer/components/Drawing.d.ts +5 -0
  121. package/lib/module/renderer/components/Drawing.js +6 -0
  122. package/lib/module/renderer/components/Drawing.js.map +1 -1
  123. package/lib/module/renderer/components/shapes/FitBox.d.ts +5 -5
  124. package/lib/module/skia/core/Matrix.d.ts +2 -2
  125. package/lib/module/skia/core/Matrix.js.map +1 -1
  126. package/lib/module/skia/core/Picture.d.ts +2 -2
  127. package/lib/module/skia/core/Picture.js +12 -3
  128. package/lib/module/skia/core/Picture.js.map +1 -1
  129. package/lib/module/skia/core/Vector.d.ts +3 -3
  130. package/lib/module/skia/core/Vector.js.map +1 -1
  131. package/lib/module/skia/types/Canvas.d.ts +1 -1
  132. package/lib/module/skia/types/Canvas.js.map +1 -1
  133. package/lib/module/skia/types/Matrix.d.ts +4 -9
  134. package/lib/module/skia/types/Matrix.js +3 -57
  135. package/lib/module/skia/types/Matrix.js.map +1 -1
  136. package/lib/module/skia/types/Matrix4.d.ts +39 -0
  137. package/lib/module/skia/types/Matrix4.js +200 -0
  138. package/lib/module/skia/types/Matrix4.js.map +1 -0
  139. package/lib/module/skia/types/Path/Path.d.ts +1 -1
  140. package/lib/module/skia/types/Path/Path.js.map +1 -1
  141. package/lib/module/skia/types/Picture/PictureRecorder.d.ts +1 -1
  142. package/lib/module/skia/types/Picture/PictureRecorder.js.map +1 -1
  143. package/lib/module/skia/types/Rect.d.ts +1 -0
  144. package/lib/module/skia/types/Rect.js +9 -0
  145. package/lib/module/skia/types/Rect.js.map +1 -1
  146. package/lib/module/skia/types/index.d.ts +1 -0
  147. package/lib/module/skia/types/index.js +1 -0
  148. package/lib/module/skia/types/index.js.map +1 -1
  149. package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  150. package/lib/module/skia/web/JsiSkCanvas.js +1 -1
  151. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  152. package/lib/module/skia/web/JsiSkMatrix.d.ts +1 -1
  153. package/lib/module/skia/web/JsiSkMatrix.js +1 -1
  154. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  155. package/lib/module/skia/web/JsiSkPath.js +1 -1
  156. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  157. package/lib/module/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  158. package/lib/module/skia/web/JsiSkPictureRecorder.js +1 -1
  159. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  160. package/lib/module/values/api.d.ts +23 -2
  161. package/lib/module/values/api.js +44 -1
  162. package/lib/module/values/api.js.map +1 -1
  163. package/lib/module/values/hooks/useClockValue.d.ts +3 -0
  164. package/lib/module/values/hooks/useClockValue.js +3 -0
  165. package/lib/module/values/hooks/useClockValue.js.map +1 -1
  166. package/lib/module/values/hooks/useComputedValue.d.ts +3 -0
  167. package/lib/module/values/hooks/useComputedValue.js +3 -0
  168. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  169. package/lib/module/values/hooks/useValue.d.ts +3 -0
  170. package/lib/module/values/hooks/useValue.js +3 -0
  171. package/lib/module/values/hooks/useValue.js.map +1 -1
  172. package/lib/module/values/hooks/useValueEffect.d.ts +3 -0
  173. package/lib/module/values/hooks/useValueEffect.js +3 -0
  174. package/lib/module/values/hooks/useValueEffect.js.map +1 -1
  175. package/lib/module/values/types.d.ts +4 -4
  176. package/lib/module/values/types.js.map +1 -1
  177. package/lib/module/views/SkiaView.d.ts +5 -0
  178. package/lib/module/views/SkiaView.js +10 -0
  179. package/lib/module/views/SkiaView.js.map +1 -1
  180. package/lib/typescript/src/animation/spring/runSpring.d.ts +3 -0
  181. package/lib/typescript/src/animation/spring/useSpring.d.ts +3 -0
  182. package/lib/typescript/src/animation/timing/runTiming.d.ts +3 -0
  183. package/lib/typescript/src/animation/timing/useLoop.d.ts +3 -0
  184. package/lib/typescript/src/animation/timing/useTiming.d.ts +3 -0
  185. package/lib/typescript/src/dom/nodes/datatypes/Fitting.d.ts +5 -5
  186. package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +235 -75
  187. package/lib/typescript/src/dom/types/Common.d.ts +3 -3
  188. package/lib/typescript/src/renderer/components/Drawing.d.ts +5 -0
  189. package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +5 -5
  190. package/lib/typescript/src/skia/core/Matrix.d.ts +2 -2
  191. package/lib/typescript/src/skia/core/Picture.d.ts +2 -2
  192. package/lib/typescript/src/skia/core/Vector.d.ts +3 -3
  193. package/lib/typescript/src/skia/types/Canvas.d.ts +1 -1
  194. package/lib/typescript/src/skia/types/Matrix.d.ts +4 -9
  195. package/lib/typescript/src/skia/types/Matrix4.d.ts +39 -0
  196. package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -1
  197. package/lib/typescript/src/skia/types/Picture/PictureRecorder.d.ts +1 -1
  198. package/lib/typescript/src/skia/types/Rect.d.ts +1 -0
  199. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  200. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
  201. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +1 -1
  202. package/lib/typescript/src/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  203. package/lib/typescript/src/values/api.d.ts +23 -2
  204. package/lib/typescript/src/values/hooks/useClockValue.d.ts +3 -0
  205. package/lib/typescript/src/values/hooks/useComputedValue.d.ts +3 -0
  206. package/lib/typescript/src/values/hooks/useValue.d.ts +3 -0
  207. package/lib/typescript/src/values/hooks/useValueEffect.d.ts +3 -0
  208. package/lib/typescript/src/values/types.d.ts +4 -4
  209. package/lib/typescript/src/views/SkiaView.d.ts +5 -0
  210. package/package.json +1 -1
  211. package/src/animation/spring/runSpring.ts +3 -0
  212. package/src/animation/spring/useSpring.ts +3 -0
  213. package/src/animation/timing/runTiming.ts +3 -0
  214. package/src/animation/timing/useLoop.ts +3 -0
  215. package/src/animation/timing/useTiming.ts +3 -0
  216. package/src/dom/nodes/JsiSkDOM.ts +4 -0
  217. package/src/dom/nodes/datatypes/Fitting.ts +10 -2
  218. package/src/dom/nodes/datatypes/Gradient.ts +2 -2
  219. package/src/dom/types/Common.ts +3 -3
  220. package/src/external/reanimated/interpolators.ts +14 -6
  221. package/src/renderer/Canvas.tsx +41 -30
  222. package/src/renderer/components/Drawing.tsx +5 -0
  223. package/src/skia/core/Matrix.ts +2 -2
  224. package/src/skia/core/Picture.ts +11 -3
  225. package/src/skia/core/Vector.ts +5 -2
  226. package/src/skia/types/Canvas.ts +1 -1
  227. package/src/skia/types/Matrix.ts +7 -74
  228. package/src/skia/types/Matrix4.ts +266 -0
  229. package/src/skia/types/Path/Path.ts +1 -1
  230. package/src/skia/types/Picture/PictureRecorder.ts +1 -1
  231. package/src/skia/types/Rect.ts +14 -0
  232. package/src/skia/types/index.ts +1 -0
  233. package/src/skia/web/JsiSkCanvas.ts +2 -2
  234. package/src/skia/web/JsiSkMatrix.ts +4 -2
  235. package/src/skia/web/JsiSkPath.ts +1 -1
  236. package/src/skia/web/JsiSkPictureRecorder.ts +6 -2
  237. package/src/values/api.ts +55 -2
  238. package/src/values/hooks/useClockValue.ts +3 -0
  239. package/src/values/hooks/useComputedValue.ts +3 -0
  240. package/src/values/hooks/useValue.ts +3 -0
  241. package/src/values/hooks/useValueEffect.ts +3 -0
  242. package/src/values/types.ts +6 -6
  243. package/src/views/SkiaView.tsx +11 -0
@@ -1,87 +1,247 @@
1
- import type { Skia, SkRect, Transforms2d, Vector } from "../../../skia/types";
1
+ import type { Skia, SkRect, Transforms3d, Vector } from "../../../skia/types";
2
2
  import { TileMode } from "../../../skia/types";
3
3
  import type { GradientProps, ImageShaderProps } from "../../types";
4
- export declare const transformOrigin: (origin: Vector, transform: Transforms2d) => (Pick<{
5
- readonly translateX: number;
6
- readonly translateY: number;
7
- readonly scale: number;
8
- readonly skewX: number;
9
- readonly skewY: number;
10
- readonly scaleX: number;
11
- readonly scaleY: number;
12
- readonly rotateZ: number;
13
- readonly rotate: number;
4
+ export declare const transformOrigin: (origin: Vector, transform: Transforms3d) => (Pick<{
5
+ translateX: number;
6
+ translateY: number;
7
+ translateZ: number;
8
+ translate: readonly [number, number] | readonly [number, number, number];
9
+ scale: number;
10
+ scaleX: number;
11
+ scaleY: number;
12
+ skewX: number;
13
+ skewY: number;
14
+ rotateZ: number;
15
+ rotate: number;
16
+ perspective: number;
17
+ rotateX: number;
18
+ rotateY: number;
19
+ matrix: import("../../../skia/types").Matrix4;
14
20
  }, "translateX"> | Pick<{
15
- readonly translateX: number;
16
- readonly translateY: number;
17
- readonly scale: number;
18
- readonly skewX: number;
19
- readonly skewY: number;
20
- readonly scaleX: number;
21
- readonly scaleY: number;
22
- readonly rotateZ: number;
23
- readonly rotate: number;
21
+ translateX: number;
22
+ translateY: number;
23
+ translateZ: number;
24
+ translate: readonly [number, number] | readonly [number, number, number];
25
+ scale: number;
26
+ scaleX: number;
27
+ scaleY: number;
28
+ skewX: number;
29
+ skewY: number;
30
+ rotateZ: number;
31
+ rotate: number;
32
+ perspective: number;
33
+ rotateX: number;
34
+ rotateY: number;
35
+ matrix: import("../../../skia/types").Matrix4;
24
36
  }, "translateY"> | Pick<{
25
- readonly translateX: number;
26
- readonly translateY: number;
27
- readonly scale: number;
28
- readonly skewX: number;
29
- readonly skewY: number;
30
- readonly scaleX: number;
31
- readonly scaleY: number;
32
- readonly rotateZ: number;
33
- readonly rotate: number;
37
+ translateX: number;
38
+ translateY: number;
39
+ translateZ: number;
40
+ translate: readonly [number, number] | readonly [number, number, number];
41
+ scale: number;
42
+ scaleX: number;
43
+ scaleY: number;
44
+ skewX: number;
45
+ skewY: number;
46
+ rotateZ: number;
47
+ rotate: number;
48
+ perspective: number;
49
+ rotateX: number;
50
+ rotateY: number;
51
+ matrix: import("../../../skia/types").Matrix4;
52
+ }, "translateZ"> | Pick<{
53
+ translateX: number;
54
+ translateY: number;
55
+ translateZ: number;
56
+ translate: readonly [number, number] | readonly [number, number, number];
57
+ scale: number;
58
+ scaleX: number;
59
+ scaleY: number;
60
+ skewX: number;
61
+ skewY: number;
62
+ rotateZ: number;
63
+ rotate: number;
64
+ perspective: number;
65
+ rotateX: number;
66
+ rotateY: number;
67
+ matrix: import("../../../skia/types").Matrix4;
68
+ }, "translate"> | Pick<{
69
+ translateX: number;
70
+ translateY: number;
71
+ translateZ: number;
72
+ translate: readonly [number, number] | readonly [number, number, number];
73
+ scale: number;
74
+ scaleX: number;
75
+ scaleY: number;
76
+ skewX: number;
77
+ skewY: number;
78
+ rotateZ: number;
79
+ rotate: number;
80
+ perspective: number;
81
+ rotateX: number;
82
+ rotateY: number;
83
+ matrix: import("../../../skia/types").Matrix4;
34
84
  }, "scale"> | Pick<{
35
- readonly translateX: number;
36
- readonly translateY: number;
37
- readonly scale: number;
38
- readonly skewX: number;
39
- readonly skewY: number;
40
- readonly scaleX: number;
41
- readonly scaleY: number;
42
- readonly rotateZ: number;
43
- readonly rotate: number;
85
+ translateX: number;
86
+ translateY: number;
87
+ translateZ: number;
88
+ translate: readonly [number, number] | readonly [number, number, number];
89
+ scale: number;
90
+ scaleX: number;
91
+ scaleY: number;
92
+ skewX: number;
93
+ skewY: number;
94
+ rotateZ: number;
95
+ rotate: number;
96
+ perspective: number;
97
+ rotateX: number;
98
+ rotateY: number;
99
+ matrix: import("../../../skia/types").Matrix4;
44
100
  }, "scaleX"> | Pick<{
45
- readonly translateX: number;
46
- readonly translateY: number;
47
- readonly scale: number;
48
- readonly skewX: number;
49
- readonly skewY: number;
50
- readonly scaleX: number;
51
- readonly scaleY: number;
52
- readonly rotateZ: number;
53
- readonly rotate: number;
101
+ translateX: number;
102
+ translateY: number;
103
+ translateZ: number;
104
+ translate: readonly [number, number] | readonly [number, number, number];
105
+ scale: number;
106
+ scaleX: number;
107
+ scaleY: number;
108
+ skewX: number;
109
+ skewY: number;
110
+ rotateZ: number;
111
+ rotate: number;
112
+ perspective: number;
113
+ rotateX: number;
114
+ rotateY: number;
115
+ matrix: import("../../../skia/types").Matrix4;
54
116
  }, "scaleY"> | Pick<{
55
- readonly translateX: number;
56
- readonly translateY: number;
57
- readonly scale: number;
58
- readonly skewX: number;
59
- readonly skewY: number;
60
- readonly scaleX: number;
61
- readonly scaleY: number;
62
- readonly rotateZ: number;
63
- readonly rotate: number;
117
+ translateX: number;
118
+ translateY: number;
119
+ translateZ: number;
120
+ translate: readonly [number, number] | readonly [number, number, number];
121
+ scale: number;
122
+ scaleX: number;
123
+ scaleY: number;
124
+ skewX: number;
125
+ skewY: number;
126
+ rotateZ: number;
127
+ rotate: number;
128
+ perspective: number;
129
+ rotateX: number;
130
+ rotateY: number;
131
+ matrix: import("../../../skia/types").Matrix4;
64
132
  }, "skewX"> | Pick<{
65
- readonly translateX: number;
66
- readonly translateY: number;
67
- readonly scale: number;
68
- readonly skewX: number;
69
- readonly skewY: number;
70
- readonly scaleX: number;
71
- readonly scaleY: number;
72
- readonly rotateZ: number;
73
- readonly rotate: number;
133
+ translateX: number;
134
+ translateY: number;
135
+ translateZ: number;
136
+ translate: readonly [number, number] | readonly [number, number, number];
137
+ scale: number;
138
+ scaleX: number;
139
+ scaleY: number;
140
+ skewX: number;
141
+ skewY: number;
142
+ rotateZ: number;
143
+ rotate: number;
144
+ perspective: number;
145
+ rotateX: number;
146
+ rotateY: number;
147
+ matrix: import("../../../skia/types").Matrix4;
74
148
  }, "skewY"> | Pick<{
75
- readonly translateX: number;
76
- readonly translateY: number;
77
- readonly scale: number;
78
- readonly skewX: number;
79
- readonly skewY: number;
80
- readonly scaleX: number;
81
- readonly scaleY: number;
82
- readonly rotateZ: number;
83
- readonly rotate: number;
84
- }, "rotate">)[];
149
+ translateX: number;
150
+ translateY: number;
151
+ translateZ: number;
152
+ translate: readonly [number, number] | readonly [number, number, number];
153
+ scale: number;
154
+ scaleX: number;
155
+ scaleY: number;
156
+ skewX: number;
157
+ skewY: number;
158
+ rotateZ: number;
159
+ rotate: number;
160
+ perspective: number;
161
+ rotateX: number;
162
+ rotateY: number;
163
+ matrix: import("../../../skia/types").Matrix4;
164
+ }, "perspective"> | Pick<{
165
+ translateX: number;
166
+ translateY: number;
167
+ translateZ: number;
168
+ translate: readonly [number, number] | readonly [number, number, number];
169
+ scale: number;
170
+ scaleX: number;
171
+ scaleY: number;
172
+ skewX: number;
173
+ skewY: number;
174
+ rotateZ: number;
175
+ rotate: number;
176
+ perspective: number;
177
+ rotateX: number;
178
+ rotateY: number;
179
+ matrix: import("../../../skia/types").Matrix4;
180
+ }, "rotateX"> | Pick<{
181
+ translateX: number;
182
+ translateY: number;
183
+ translateZ: number;
184
+ translate: readonly [number, number] | readonly [number, number, number];
185
+ scale: number;
186
+ scaleX: number;
187
+ scaleY: number;
188
+ skewX: number;
189
+ skewY: number;
190
+ rotateZ: number;
191
+ rotate: number;
192
+ perspective: number;
193
+ rotateX: number;
194
+ rotateY: number;
195
+ matrix: import("../../../skia/types").Matrix4;
196
+ }, "rotateY"> | Pick<{
197
+ translateX: number;
198
+ translateY: number;
199
+ translateZ: number;
200
+ translate: readonly [number, number] | readonly [number, number, number];
201
+ scale: number;
202
+ scaleX: number;
203
+ scaleY: number;
204
+ skewX: number;
205
+ skewY: number;
206
+ rotateZ: number;
207
+ rotate: number;
208
+ perspective: number;
209
+ rotateX: number;
210
+ rotateY: number;
211
+ matrix: import("../../../skia/types").Matrix4;
212
+ }, "rotateZ"> | Pick<{
213
+ translateX: number;
214
+ translateY: number;
215
+ translateZ: number;
216
+ translate: readonly [number, number] | readonly [number, number, number];
217
+ scale: number;
218
+ scaleX: number;
219
+ scaleY: number;
220
+ skewX: number;
221
+ skewY: number;
222
+ rotateZ: number;
223
+ rotate: number;
224
+ perspective: number;
225
+ rotateX: number;
226
+ rotateY: number;
227
+ matrix: import("../../../skia/types").Matrix4;
228
+ }, "rotate"> | Pick<{
229
+ translateX: number;
230
+ translateY: number;
231
+ translateZ: number;
232
+ translate: readonly [number, number] | readonly [number, number, number];
233
+ scale: number;
234
+ scaleX: number;
235
+ scaleY: number;
236
+ skewX: number;
237
+ skewY: number;
238
+ rotateZ: number;
239
+ rotate: number;
240
+ perspective: number;
241
+ rotateX: number;
242
+ rotateY: number;
243
+ matrix: import("../../../skia/types").Matrix4;
244
+ }, "matrix">)[];
85
245
  export declare const processGradientProps: (Skia: Skia, { colors, positions, mode, flags, ...transform }: GradientProps) => {
86
246
  colors: Float32Array[];
87
247
  positions: number[] | null;
@@ -1 +1 @@
1
- {"version":3,"names":["transformOrigin","origin","transform","translateX","x","translateY","y","processGradientProps","Skia","colors","positions","mode","flags","localMatrix","Matrix","processTransformProps","map","color","Color","TileMode","enumKey","getRect","props","width","height","rect","undefined","XYWHRect"],"sources":["Gradient.ts"],"sourcesContent":["import type { Skia, SkRect, Transforms2d, Vector } from \"../../../skia/types\";\nimport { TileMode } from \"../../../skia/types\";\nimport type { GradientProps, ImageShaderProps } from \"../../types\";\n\nimport { enumKey } from \"./Enum\";\nimport { processTransformProps } from \"./Transform\";\n\nexport const transformOrigin = (origin: Vector, transform: Transforms2d) => [\n { translateX: origin.x },\n { translateY: origin.y },\n ...transform,\n { translateX: -origin.x },\n { translateY: -origin.y },\n];\n\nexport const processGradientProps = (\n Skia: Skia,\n { colors, positions, mode, flags, ...transform }: GradientProps\n) => {\n const localMatrix = Skia.Matrix();\n processTransformProps(localMatrix, transform);\n return {\n colors: colors.map((color) => Skia.Color(color)),\n positions: positions ?? null,\n mode: TileMode[enumKey(mode ?? \"clamp\")],\n flags,\n localMatrix,\n };\n};\n\nexport const getRect = (\n Skia: Skia,\n props: Omit<ImageShaderProps, \"tx\" | \"ty\" | \"fm\" | \"mm\" | \"fit\" | \"image\">\n): SkRect | undefined => {\n const { x, y, width, height } = props;\n if (props.rect) {\n return props.rect;\n } else if (\n x !== undefined &&\n y !== undefined &&\n width !== undefined &&\n height !== undefined\n ) {\n return Skia.XYWHRect(x, y, width, height);\n } else {\n return undefined;\n }\n};\n"],"mappings":";;;;;;;AACA;;AAGA;;AACA;;AAEO,MAAMA,eAAe,GAAG,CAACC,MAAD,EAAiBC,SAAjB,KAA6C,CAC1E;EAAEC,UAAU,EAAEF,MAAM,CAACG;AAArB,CAD0E,EAE1E;EAAEC,UAAU,EAAEJ,MAAM,CAACK;AAArB,CAF0E,EAG1E,GAAGJ,SAHuE,EAI1E;EAAEC,UAAU,EAAE,CAACF,MAAM,CAACG;AAAtB,CAJ0E,EAK1E;EAAEC,UAAU,EAAE,CAACJ,MAAM,CAACK;AAAtB,CAL0E,CAArE;;;;AAQA,MAAMC,oBAAoB,GAAG,CAClCC,IADkC,WAG/B;EAAA,IADH;IAAEC,MAAF;IAAUC,SAAV;IAAqBC,IAArB;IAA2BC,KAA3B;IAAkC,GAAGV;EAArC,CACG;EACH,MAAMW,WAAW,GAAGL,IAAI,CAACM,MAAL,EAApB;EACA,IAAAC,gCAAA,EAAsBF,WAAtB,EAAmCX,SAAnC;EACA,OAAO;IACLO,MAAM,EAAEA,MAAM,CAACO,GAAP,CAAYC,KAAD,IAAWT,IAAI,CAACU,KAAL,CAAWD,KAAX,CAAtB,CADH;IAELP,SAAS,EAAEA,SAAS,IAAI,IAFnB;IAGLC,IAAI,EAAEQ,eAAA,CAAS,IAAAC,aAAA,EAAQT,IAAI,IAAI,OAAhB,CAAT,CAHD;IAILC,KAJK;IAKLC;EALK,CAAP;AAOD,CAbM;;;;AAeA,MAAMQ,OAAO,GAAG,CACrBb,IADqB,EAErBc,KAFqB,KAGE;EACvB,MAAM;IAAElB,CAAF;IAAKE,CAAL;IAAQiB,KAAR;IAAeC;EAAf,IAA0BF,KAAhC;;EACA,IAAIA,KAAK,CAACG,IAAV,EAAgB;IACd,OAAOH,KAAK,CAACG,IAAb;EACD,CAFD,MAEO,IACLrB,CAAC,KAAKsB,SAAN,IACApB,CAAC,KAAKoB,SADN,IAEAH,KAAK,KAAKG,SAFV,IAGAF,MAAM,KAAKE,SAJN,EAKL;IACA,OAAOlB,IAAI,CAACmB,QAAL,CAAcvB,CAAd,EAAiBE,CAAjB,EAAoBiB,KAApB,EAA2BC,MAA3B,CAAP;EACD,CAPM,MAOA;IACL,OAAOE,SAAP;EACD;AACF,CAjBM"}
1
+ {"version":3,"names":["transformOrigin","origin","transform","translateX","x","translateY","y","processGradientProps","Skia","colors","positions","mode","flags","localMatrix","Matrix","processTransformProps","map","color","Color","TileMode","enumKey","getRect","props","width","height","rect","undefined","XYWHRect"],"sources":["Gradient.ts"],"sourcesContent":["import type { Skia, SkRect, Transforms3d, Vector } from \"../../../skia/types\";\nimport { TileMode } from \"../../../skia/types\";\nimport type { GradientProps, ImageShaderProps } from \"../../types\";\n\nimport { enumKey } from \"./Enum\";\nimport { processTransformProps } from \"./Transform\";\n\nexport const transformOrigin = (origin: Vector, transform: Transforms3d) => [\n { translateX: origin.x },\n { translateY: origin.y },\n ...transform,\n { translateX: -origin.x },\n { translateY: -origin.y },\n];\n\nexport const processGradientProps = (\n Skia: Skia,\n { colors, positions, mode, flags, ...transform }: GradientProps\n) => {\n const localMatrix = Skia.Matrix();\n processTransformProps(localMatrix, transform);\n return {\n colors: colors.map((color) => Skia.Color(color)),\n positions: positions ?? null,\n mode: TileMode[enumKey(mode ?? \"clamp\")],\n flags,\n localMatrix,\n };\n};\n\nexport const getRect = (\n Skia: Skia,\n props: Omit<ImageShaderProps, \"tx\" | \"ty\" | \"fm\" | \"mm\" | \"fit\" | \"image\">\n): SkRect | undefined => {\n const { x, y, width, height } = props;\n if (props.rect) {\n return props.rect;\n } else if (\n x !== undefined &&\n y !== undefined &&\n width !== undefined &&\n height !== undefined\n ) {\n return Skia.XYWHRect(x, y, width, height);\n } else {\n return undefined;\n }\n};\n"],"mappings":";;;;;;;AACA;;AAGA;;AACA;;AAEO,MAAMA,eAAe,GAAG,CAACC,MAAD,EAAiBC,SAAjB,KAA6C,CAC1E;EAAEC,UAAU,EAAEF,MAAM,CAACG;AAArB,CAD0E,EAE1E;EAAEC,UAAU,EAAEJ,MAAM,CAACK;AAArB,CAF0E,EAG1E,GAAGJ,SAHuE,EAI1E;EAAEC,UAAU,EAAE,CAACF,MAAM,CAACG;AAAtB,CAJ0E,EAK1E;EAAEC,UAAU,EAAE,CAACJ,MAAM,CAACK;AAAtB,CAL0E,CAArE;;;;AAQA,MAAMC,oBAAoB,GAAG,CAClCC,IADkC,WAG/B;EAAA,IADH;IAAEC,MAAF;IAAUC,SAAV;IAAqBC,IAArB;IAA2BC,KAA3B;IAAkC,GAAGV;EAArC,CACG;EACH,MAAMW,WAAW,GAAGL,IAAI,CAACM,MAAL,EAApB;EACA,IAAAC,gCAAA,EAAsBF,WAAtB,EAAmCX,SAAnC;EACA,OAAO;IACLO,MAAM,EAAEA,MAAM,CAACO,GAAP,CAAYC,KAAD,IAAWT,IAAI,CAACU,KAAL,CAAWD,KAAX,CAAtB,CADH;IAELP,SAAS,EAAEA,SAAS,IAAI,IAFnB;IAGLC,IAAI,EAAEQ,eAAA,CAAS,IAAAC,aAAA,EAAQT,IAAI,IAAI,OAAhB,CAAT,CAHD;IAILC,KAJK;IAKLC;EALK,CAAP;AAOD,CAbM;;;;AAeA,MAAMQ,OAAO,GAAG,CACrBb,IADqB,EAErBc,KAFqB,KAGE;EACvB,MAAM;IAAElB,CAAF;IAAKE,CAAL;IAAQiB,KAAR;IAAeC;EAAf,IAA0BF,KAAhC;;EACA,IAAIA,KAAK,CAACG,IAAV,EAAgB;IACd,OAAOH,KAAK,CAACG,IAAb;EACD,CAFD,MAEO,IACLrB,CAAC,KAAKsB,SAAN,IACApB,CAAC,KAAKoB,SADN,IAEAH,KAAK,KAAKG,SAFV,IAGAF,MAAM,KAAKE,SAJN,EAKL;IACA,OAAOlB,IAAI,CAACmB,QAAL,CAAcvB,CAAd,EAAiBE,CAAjB,EAAoBiB,KAApB,EAA2BC,MAA3B,CAAP;EACD,CAPM,MAOA;IACL,OAAOE,SAAP;EACD;AACF,CAjBM"}
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { BlendMode, Color, PaintStyle, SkMatrix, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms2d, Vector } from "../../skia/types";
2
+ import type { BlendMode, Color, PaintStyle, SkMatrix, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms3d, Vector } from "../../skia/types";
3
3
  export type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;
4
4
  export type PathDef = string | SkPath;
5
5
  export type ClipDef = SkRRect | SkRect | PathDef;
@@ -34,9 +34,9 @@ export interface ScalarCircleDef {
34
34
  }
35
35
  export type CircleDef = PointCircleDef | ScalarCircleDef;
36
36
  export interface TransformProps {
37
- transform?: Transforms2d;
37
+ transform?: Transforms3d;
38
38
  origin?: Vector;
39
- matrix?: SkMatrix;
39
+ matrix?: SkMatrix | number[];
40
40
  }
41
41
  export interface PaintProps extends ChildrenProps {
42
42
  color?: Color;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Common.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\n\nimport type {\n BlendMode,\n Color,\n PaintStyle,\n SkMatrix,\n SkPaint,\n SkPath,\n SkRect,\n SkRRect,\n StrokeCap,\n StrokeJoin,\n Transforms2d,\n Vector,\n} from \"../../skia/types\";\n\nexport type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;\n\nexport type PathDef = string | SkPath;\n\nexport type ClipDef = SkRRect | SkRect | PathDef;\n\nexport type Fit =\n | \"cover\"\n | \"contain\"\n | \"fill\"\n | \"fitHeight\"\n | \"fitWidth\"\n | \"none\"\n | \"scaleDown\";\n\nexport type Radius = number | Vector;\n\nexport interface ChildrenProps {\n children?: ReactNode | ReactNode[];\n}\n\nexport interface RectCtor {\n x?: number;\n y?: number;\n width: number;\n height: number;\n}\n\nexport interface RRectCtor extends RectCtor {\n r?: Radius;\n}\n\nexport type RectDef = RectCtor | { rect: SkRect };\nexport type RRectDef = RRectCtor | { rect: SkRRect };\n\nexport interface PointCircleDef {\n c?: Vector;\n r: number;\n}\n\nexport interface ScalarCircleDef {\n cx: number;\n cy: number;\n r: number;\n}\n\nexport type CircleDef = PointCircleDef | ScalarCircleDef;\n\nexport interface TransformProps {\n transform?: Transforms2d;\n origin?: Vector;\n matrix?: SkMatrix;\n}\n\nexport interface PaintProps extends ChildrenProps {\n color?: Color;\n strokeWidth?: number;\n blendMode?: SkEnum<typeof BlendMode>;\n style?: SkEnum<typeof PaintStyle>;\n strokeJoin?: SkEnum<typeof StrokeJoin>;\n strokeCap?: SkEnum<typeof StrokeCap>;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n dither?: boolean;\n}\n\nexport interface GroupProps extends PaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: SkPaint | boolean;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Common.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\n\nimport type {\n BlendMode,\n Color,\n PaintStyle,\n SkMatrix,\n SkPaint,\n SkPath,\n SkRect,\n SkRRect,\n StrokeCap,\n StrokeJoin,\n Transforms3d,\n Vector,\n} from \"../../skia/types\";\n\nexport type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;\n\nexport type PathDef = string | SkPath;\n\nexport type ClipDef = SkRRect | SkRect | PathDef;\n\nexport type Fit =\n | \"cover\"\n | \"contain\"\n | \"fill\"\n | \"fitHeight\"\n | \"fitWidth\"\n | \"none\"\n | \"scaleDown\";\n\nexport type Radius = number | Vector;\n\nexport interface ChildrenProps {\n children?: ReactNode | ReactNode[];\n}\n\nexport interface RectCtor {\n x?: number;\n y?: number;\n width: number;\n height: number;\n}\n\nexport interface RRectCtor extends RectCtor {\n r?: Radius;\n}\n\nexport type RectDef = RectCtor | { rect: SkRect };\nexport type RRectDef = RRectCtor | { rect: SkRRect };\n\nexport interface PointCircleDef {\n c?: Vector;\n r: number;\n}\n\nexport interface ScalarCircleDef {\n cx: number;\n cy: number;\n r: number;\n}\n\nexport type CircleDef = PointCircleDef | ScalarCircleDef;\n\nexport interface TransformProps {\n transform?: Transforms3d;\n origin?: Vector;\n matrix?: SkMatrix | number[];\n}\n\nexport interface PaintProps extends ChildrenProps {\n color?: Color;\n strokeWidth?: number;\n blendMode?: SkEnum<typeof BlendMode>;\n style?: SkEnum<typeof PaintStyle>;\n strokeJoin?: SkEnum<typeof StrokeJoin>;\n strokeCap?: SkEnum<typeof StrokeCap>;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n dither?: boolean;\n}\n\nexport interface GroupProps extends PaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: SkPaint | boolean;\n}\n"],"mappings":""}
@@ -14,18 +14,24 @@ var _skia = require("../../skia");
14
14
  var _moduleWrapper = require("./moduleWrapper");
15
15
 
16
16
  const notifyChange = value => {
17
- "worklet"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ "worklet";
18
18
 
19
- value._value = value.value;
19
+ if (_WORKLET) {
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ value._value = value.value;
22
+ }
20
23
  };
21
24
 
22
25
  exports.notifyChange = notifyChange;
23
26
 
24
27
  const useClock = () => {
25
28
  const clock = (0, _moduleWrapper.useSharedValue)(0);
26
- (0, _moduleWrapper.useFrameCallback)(info => {
29
+ const callback = (0, _react.useRef)(info => {
30
+ "worklet";
31
+
27
32
  clock.value = info.timeSinceFirstFrame;
28
- });
33
+ }).current;
34
+ (0, _moduleWrapper.useFrameCallback)(callback);
29
35
  return clock;
30
36
  };
31
37
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["notifyChange","value","_value","useClock","clock","useSharedValue","useFrameCallback","info","timeSinceFirstFrame","useInterpolator","factory","interpolator","input","output","options","init","useMemo","result","useAnimatedReaction","val","usePathInterpolation","outputRange","Skia","Path","Make","interpolatePaths","useVectorInterpolation","Point","interpolateVector"],"sources":["interpolators.ts"],"sourcesContent":["import type { ExtrapolationType, SharedValue } from \"react-native-reanimated\";\nimport { useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n useFrameCallback((info) => {\n clock.value = info.timeSinceFirstFrame;\n });\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":";;;;;;;AACA;;AAGA;;AACA;;AAEA;;AAMO,MAAMA,YAAY,GAAIC,KAAD,IAAiC;EAC3D,UAD2D,CAE3D;;EACCA,KAAD,CAAeC,MAAf,GAAwBD,KAAK,CAACA,KAA9B;AACD,CAJM;;;;AAMA,MAAME,QAAQ,GAAG,MAAM;EAC5B,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAe,CAAf,CAAd;EACA,IAAAC,+BAAA,EAAkBC,IAAD,IAAU;IACzBH,KAAK,CAACH,KAAN,GAAcM,IAAI,CAACC,mBAAnB;EACD,CAFD;EAGA,OAAOJ,KAAP;AACD,CANM;AAQP;AACA;AACA;;;;;AASA,MAAMK,eAAe,GAAG,CACtBC,OADsB,EAEtBT,KAFsB,EAGtBU,YAHsB,EAItBC,KAJsB,EAKtBC,MALsB,EAMtBC,OANsB,KAOnB;EACH;EACA,MAAMC,IAAI,GAAG,IAAAC,cAAA,EAAQ,MAAMN,OAAO,EAArB,EAAyB,EAAzB,CAAb;EACA,MAAMO,MAAM,GAAG,IAAAZ,6BAAA,EAAeU,IAAf,CAAf;EACA,IAAAG,kCAAA,EACE,MAAMjB,KAAK,CAACA,KADd,EAEGkB,GAAD,IAAS;IACPF,MAAM,CAAChB,KAAP,GAAeU,YAAY,CAACQ,GAAD,EAAMP,KAAN,EAAaC,MAAb,EAAqBC,OAArB,EAA8BG,MAAM,CAAChB,KAArC,CAA3B;IACAD,YAAY,CAACiB,MAAD,CAAZ;EACD,CALH,EAME,CAACL,KAAD,EAAQC,MAAR,EAAgBC,OAAhB,CANF;EAQA,OAAOG,MAAP;AACD,CApBD;;AAsBO,MAAMG,oBAAoB,GAAG,CAClCnB,KADkC,EAElCW,KAFkC,EAGlCS,WAHkC,EAIlCP,OAJkC,KAMlCL,eAAe,CACb,MAAMa,UAAA,CAAKC,IAAL,CAAUC,IAAV,EADO,EAEbvB,KAFa,EAGbwB,2BAHa,EAIbb,KAJa,EAKbS,WALa,EAMbP,OANa,CANV;;;;AAeA,MAAMY,sBAAsB,GAAG,CACpCzB,KADoC,EAEpCW,KAFoC,EAGpCS,WAHoC,EAIpCP,OAJoC,KAMpCL,eAAe,CACb,MAAMa,UAAA,CAAKK,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEb1B,KAFa,EAGb2B,4BAHa,EAIbhB,KAJa,EAKbS,WALa,EAMbP,OANa,CANV"}
1
+ {"version":3,"names":["notifyChange","value","_WORKLET","_value","useClock","clock","useSharedValue","callback","useRef","info","timeSinceFirstFrame","current","useFrameCallback","useInterpolator","factory","interpolator","input","output","options","init","useMemo","result","useAnimatedReaction","val","usePathInterpolation","outputRange","Skia","Path","Make","interpolatePaths","useVectorInterpolation","Point","interpolateVector"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useMemo, useRef } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useRef((info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n }).current;\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":";;;;;;;AAKA;;AAGA;;AACA;;AAEA;;AAMO,MAAMA,YAAY,GAAIC,KAAD,I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a,EAMbP,OANa,CANV;;;;AAeA,MAAMY,sBAAsB,GAAG,CACpC7B,KADoC,EAEpCe,KAFoC,EAGpCS,WAHoC,EAIpCP,OAJoC,KAMpCL,eAAe,CACb,MAAMa,UAAA,CAAKK,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEb9B,KAFa,EAGb+B,4BAHa,EAIbhB,KAJa,EAKbS,WALa,EAMbP,OANa,CANV"}
@@ -13,8 +13,6 @@ var _Skia = require("../skia/Skia");
13
13
 
14
14
  var _types = require("../dom/types");
15
15
 
16
- var _values = require("../values");
17
-
18
16
  var _Reconciler = require("./Reconciler");
19
17
 
20
18
  var _HostComponents = require("./HostComponents");
@@ -31,25 +29,29 @@ const useCanvasRef = () => (0, _react.useRef)(null);
31
29
 
32
30
  exports.useCanvasRef = useCanvasRef;
33
31
 
34
- const useOnSizeEvent = resultValue => {
35
- const onSize = (0, _values.useValue)({
36
- width: 0,
37
- height: 0
38
- });
39
- (0, _react.useLayoutEffect)(() => {
40
- if (!resultValue) {
41
- return;
32
+ const useOnSizeEvent = (resultValue, onLayout) => {
33
+ return (0, _react.useCallback)(event => {
34
+ if (onLayout) {
35
+ onLayout(event);
42
36
  }
43
37
 
44
- return onSize.addListener(newValue => {
45
- if ((0, _processors.isValue)(resultValue)) {
46
- resultValue.current = newValue;
47
- } else {
48
- resultValue.value = newValue;
49
- }
50
- });
51
- }, [resultValue, onSize]);
52
- return onSize;
38
+ const {
39
+ width,
40
+ height
41
+ } = event.nativeEvent.layout;
42
+
43
+ if ((0, _processors.isValue)(resultValue)) {
44
+ resultValue.current = {
45
+ width,
46
+ height
47
+ };
48
+ } else if (resultValue) {
49
+ resultValue.value = {
50
+ width,
51
+ height
52
+ };
53
+ }
54
+ }, [onLayout, resultValue]);
53
55
  };
54
56
 
55
57
  const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
@@ -60,9 +62,10 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
60
62
  mode,
61
63
  onTouch,
62
64
  onSize: _onSize,
65
+ onLayout: _onLayout,
63
66
  ...props
64
67
  } = _ref;
65
- const onSize = useOnSizeEvent(_onSize);
68
+ const onLayout = useOnSizeEvent(_onSize, _onLayout);
66
69
  const innerRef = useCanvasRef();
67
70
  const ref = useCombinedRefs(forwardedRef, innerRef);
68
71
  const redraw = (0, _react.useCallback)(() => {
@@ -100,23 +103,26 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
100
103
  style: style,
101
104
  root: root.dom,
102
105
  onTouch: onTouch,
103
- onSize: onSize,
106
+ onLayout: onLayout,
104
107
  mode: mode,
105
108
  debug: debug
106
109
  }, props));
107
110
  } else {
108
- return /*#__PURE__*/_react.default.createElement(_views.SkiaView // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ // This is for debugging
112
+ const recorder = _Skia.Skia.PictureRecorder();
113
+
114
+ const canvas = recorder.beginRecording(_Skia.Skia.XYWHRect(0, 0, 2_000_000, 2_000_000));
115
+ const ctx = new _types.JsiDrawingContext(_Skia.Skia, canvas);
116
+ root.dom.render(ctx);
117
+ const picture = recorder.finishRecordingAsPicture();
118
+ return /*#__PURE__*/_react.default.createElement(_views.SkiaPictureView // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
119
  , _extends({
110
120
  ref: ref,
111
121
  style: style,
112
122
  mode: mode,
113
123
  debug: debug,
114
- onSize: onSize,
115
- onDraw: (canvas, info) => {
116
- onTouch && onTouch(info.touches);
117
- const ctx = new _types.JsiDrawingContext(_Skia.Skia, canvas);
118
- root.dom.render(ctx);
119
- }
124
+ picture: picture,
125
+ onLayout: onLayout
120
126
  }, props));
121
127
  }
122
128
  });
@@ -1 +1 @@
1
- {"version":3,"names":["useCanvasRef","useRef","useOnSizeEvent","resultValue","onSize","useValue","width","height","useLayoutEffect","addListener","newValue","isValue","current","value","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","_onSize","props","innerRef","ref","useCombinedRefs","redraw","useCallback","getNativeId","id","nativeId","registerValues","values","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","NATIVE_DOM","dom","canvas","info","touches","ctx","JsiDrawingContext","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n useLayoutEffect,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\n\nimport { SkiaDomView, SkiaView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\nimport { JsiDrawingContext } from \"../dom/types\";\nimport { useValue } from \"../values\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\nimport { isValue } from \"./processors\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (resultValue: SkiaBaseViewProps[\"onSize\"]) => {\n const onSize = useValue({\n width: 0,\n height: 0,\n });\n\n useLayoutEffect(() => {\n if (!resultValue) {\n return;\n }\n return onSize.addListener((newValue) => {\n if (isValue(resultValue)) {\n resultValue.current = newValue;\n } else {\n resultValue.value = newValue;\n }\n });\n }, [resultValue, onSize]);\n\n return onSize;\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize: _onSize, ...props },\n forwardedRef\n ) => {\n const onSize = useOnSizeEvent(_onSize);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaView\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n mode={mode}\n debug={debug}\n onSize={onSize}\n onDraw={(canvas, info) => {\n onTouch && onTouch(info.touches);\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n }}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;;;;;;AAAA;;AAgBA;;AACA;;AAGA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;AAEO,MAAMA,YAAY,GAAG,MAAM,IAAAC,aAAA,EAAoB,IAApB,CAA3B;;;;AAQP,MAAMC,cAAc,GAAIC,WAAD,IAA8C;EACnE,MAAMC,MAAM,GAAG,IA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AlB;QACA,MAAMC,GAAG,GAAG,IAAIC,wBAAJ,CAAsBV,UAAtB,EAA4BM,MAA5B,CAAZ;QACAT,IAAI,CAACQ,GAAL,CAASH,MAAT,CAAgBO,GAAhB;MACD;IAXH,GAYMvB,KAZN,EADF;EAgBD;AACF,CAvEmB,CAAf;AA0EP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAsB,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGC,cAAA,CAAMjD,MAAN,CAAgB,IAAhB,CAAlB;;EACAiD,cAAA,CAAMZ,SAAN,CAAgB,MAAM;IACpBU,IAAI,CAACG,OAAL,CAAc1B,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACwB,SAAS,CAACrC,OAAX,CAAH;QACD,CAFD,MAEO;UACLa,GAAG,CAACb,OAAJ,GAAcqC,SAAS,CAACrC,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACoC,IAAD,CAVH;;EAWA,OAAOC,SAAP;AACD,CAhBD"}
1
+ {"version":3,"names":["useCanvasRef","useRef","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","isValue","current","value","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","getNativeId","id","nativeId","registerValues","values","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","NATIVE_DOM","dom","recorder","PictureRecorder","canvas","beginRecording","XYWHRect","ctx","JsiDrawingContext","picture","finishRecordingAsPicture","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView, SkiaPictureView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\nimport { isValue } from \"./processors\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (isValue(resultValue)) {\n resultValue.current = { width, height };\n } else if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n // This is for debugging\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(\n Skia.XYWHRect(0, 0, 2_000_000, 2_000_000)\n );\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n const picture = recorder.finishRecordingAsPicture();\n return (\n <SkiaPictureView\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n mode={mode}\n debug={debug}\n picture={picture}\n onLayout={onLayout}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;;;;;;AAAA;;AAgBA;;AACA;;AAGA;;AAEA;;AACA;;AACA;;;;;;;;AAEO,MAAMA,YAAY,GAAG,MAAM,IAAAC,aAAA,EAAoB,IAApB,CAA3B;;;;AAQP,MAAMC,cAAc,GAAG,CACrBC,WADqB,EAErBC,QAFqB,KAGlB;EACH,OAAO,IAAAC,kBAAA,EACJC,KAAD,IAA8B;IAC5B,IAAIF,QAAJ,EAAc;MACZA,QAAQ,CAACE,KAAD,CAAR;IACD;;IACD,MAAM;MAAEC,KAAF;MAASC;IAAT,IA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,QAAQ,CAACQ,wBAAT,EAAhB;IACA,oBACE,6BAAC,sBAAD,CACE;IADF;MAEE,GAAG,EAAEzB,GAFP;MAGE,KAAK,EAAET,KAHT;MAIE,IAAI,EAAEE,IAJR;MAKE,KAAK,EAAED,KALT;MAME,OAAO,EAAEgC,OANX;MAOE,QAAQ,EAAE/C;IAPZ,GAQMqB,KARN,EADF;EAYD;AACF,CApFmB,CAAf;AAuFP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAyB,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGC,cAAA,CAAMtD,MAAN,CAAgB,IAAhB,CAAlB;;EACAsD,cAAA,CAAMhB,SAAN,CAAgB,MAAM;IACpBc,IAAI,CAACG,OAAL,CAAc7B,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAAC2B,SAAS,CAAC1C,OAAX,CAAH;QACD,CAFD,MAEO;UACLe,GAAG,CAACf,OAAJ,GAAc0C,SAAS,CAAC1C,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACyC,IAAD,CAVH;;EAWA,OAAOC,SAAP;AACD,CAhBD"}
@@ -1,3 +1,8 @@
1
1
  import React from "react";
2
2
  import type { CustomDrawingNodeProps } from "../../dom/types";
3
+ /**
4
+ * @deprecated If you are looking to use the Skia imperative API, you can use:
5
+ * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
6
+ * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
7
+ */
3
8
  export declare const Drawing: (props: CustomDrawingNodeProps) => React.JSX.Element;
@@ -9,6 +9,11 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ /**
13
+ * @deprecated If you are looking to use the Skia imperative API, you can use:
14
+ * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
15
+ * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
16
+ */
12
17
  const Drawing = props => {
13
18
  return /*#__PURE__*/_react.default.createElement("skDrawing", props);
14
19
  };
@@ -1 +1 @@
1
- {"version":3,"names":["Drawing","props"],"sources":["Drawing.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { CustomDrawingNodeProps } from \"../../dom/types\";\n\nexport const Drawing = (props: CustomDrawingNodeProps) => {\n return <skDrawing {...props} />;\n};\n"],"mappings":";;;;;;;AAAA;;;;AAIO,MAAMA,OAAO,GAAIC,KAAD,IAAmC;EACxD,oBAAO,0CAAeA,KAAf,CAAP;AACD,CAFM"}
1
+ {"version":3,"names":["Drawing","props"],"sources":["Drawing.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { CustomDrawingNodeProps } from \"../../dom/types\";\n\n/**\n * @deprecated If you are looking to use the Skia imperative API, you can use:\n * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/\n * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures\n */\nexport const Drawing = (props: CustomDrawingNodeProps) => {\n return <skDrawing {...props} />;\n};\n"],"mappings":";;;;;;;AAAA;;;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,OAAO,GAAIC,KAAD,IAAmC;EACxD,oBAAO,0CAAeA,KAAf,CAAP;AACD,CAFM"}
@@ -8,14 +8,14 @@ interface FitProps {
8
8
  dst: SkRect;
9
9
  children: ReactNode | ReactNode[];
10
10
  }
11
- export declare const fitbox: (fit: Fit, src: SkRect, dst: SkRect) => readonly [{
12
- readonly translateX: number;
11
+ export declare const fitbox: (fit: Fit, src: SkRect, dst: SkRect) => [{
12
+ translateX: number;
13
13
  }, {
14
- readonly translateY: number;
14
+ translateY: number;
15
15
  }, {
16
- readonly scaleX: number;
16
+ scaleX: number;
17
17
  }, {
18
- readonly scaleY: number;
18
+ scaleY: number;
19
19
  }];
20
20
  export declare const FitBox: ({ fit, src, dst, children }: FitProps) => React.JSX.Element;
21
21
  export {};
@@ -1,2 +1,2 @@
1
- import type { Transforms2d } from "../types";
2
- export declare const processTransform2d: (transforms: Transforms2d) => import("../types").SkMatrix;
1
+ import type { Transforms3d } from "../types";
2
+ export declare const processTransform2d: (transforms: Transforms3d) => import("../types").SkMatrix;
@@ -1 +1 @@
1
- {"version":3,"names":["processTransform2d","transforms","processTransform","Skia","Matrix"],"sources":["Matrix.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Transforms2d } from \"../types\";\nimport { processTransform } from \"../types\";\n\nexport const processTransform2d = (transforms: Transforms2d) =>\n processTransform(Skia.Matrix(), transforms);\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEO,MAAMA,kBAAkB,GAAIC,UAAD,IAChC,IAAAC,uBAAA,EAAiBC,UAAA,CAAKC,MAAL,EAAjB,EAAgCH,UAAhC,CADK"}
1
+ {"version":3,"names":["processTransform2d","transforms","processTransform","Skia","Matrix"],"sources":["Matrix.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Transforms3d } from \"../types\";\nimport { processTransform } from \"../types\";\n\nexport const processTransform2d = (transforms: Transforms3d) =>\n processTransform(Skia.Matrix(), transforms);\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEO,MAAMA,kBAAkB,GAAIC,UAAD,IAChC,IAAAC,uBAAA,EAAiBC,UAAA,CAAKC,MAAL,EAAjB,EAAgCH,UAAhC,CADK"}