@shopify/react-native-skia 0.1.224 → 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 (245) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +3 -3
  2. package/cpp/api/JsiSkMatrix.h +8 -2
  3. package/cpp/api/JsiSkParagraphStyle.h +3 -2
  4. package/cpp/api/JsiSkPictureRecorder.h +10 -3
  5. package/cpp/api/JsiSkStrutStyle.h +10 -3
  6. package/cpp/rnskia/dom/props/MatrixProp.h +8 -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.js +10 -4
  32. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  33. package/lib/commonjs/renderer/Canvas.js +34 -28
  34. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  35. package/lib/commonjs/renderer/components/Drawing.d.ts +5 -0
  36. package/lib/commonjs/renderer/components/Drawing.js +5 -0
  37. package/lib/commonjs/renderer/components/Drawing.js.map +1 -1
  38. package/lib/commonjs/renderer/components/shapes/FitBox.d.ts +5 -5
  39. package/lib/commonjs/skia/core/Matrix.d.ts +2 -2
  40. package/lib/commonjs/skia/core/Matrix.js.map +1 -1
  41. package/lib/commonjs/skia/core/Picture.d.ts +2 -2
  42. package/lib/commonjs/skia/core/Picture.js +12 -2
  43. package/lib/commonjs/skia/core/Picture.js.map +1 -1
  44. package/lib/commonjs/skia/core/Vector.d.ts +3 -3
  45. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  46. package/lib/commonjs/skia/types/Canvas.d.ts +1 -1
  47. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  48. package/lib/commonjs/skia/types/Matrix.d.ts +4 -9
  49. package/lib/commonjs/skia/types/Matrix.js +5 -56
  50. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  51. package/lib/commonjs/skia/types/Matrix4.d.ts +39 -0
  52. package/lib/commonjs/skia/types/Matrix4.js +213 -0
  53. package/lib/commonjs/skia/types/Matrix4.js.map +1 -0
  54. package/lib/commonjs/skia/types/Path/Path.d.ts +1 -1
  55. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  56. package/lib/commonjs/skia/types/Picture/PictureRecorder.d.ts +1 -1
  57. package/lib/commonjs/skia/types/Picture/PictureRecorder.js.map +1 -1
  58. package/lib/commonjs/skia/types/Rect.d.ts +1 -0
  59. package/lib/commonjs/skia/types/Rect.js +18 -0
  60. package/lib/commonjs/skia/types/Rect.js.map +1 -1
  61. package/lib/commonjs/skia/types/index.d.ts +1 -0
  62. package/lib/commonjs/skia/types/index.js +13 -0
  63. package/lib/commonjs/skia/types/index.js.map +1 -1
  64. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  65. package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -1
  66. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  67. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +1 -1
  68. package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
  69. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  70. package/lib/commonjs/skia/web/JsiSkPath.js +1 -1
  71. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  72. package/lib/commonjs/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  73. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +1 -1
  74. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
  75. package/lib/commonjs/values/api.d.ts +23 -2
  76. package/lib/commonjs/values/api.js +44 -1
  77. package/lib/commonjs/values/api.js.map +1 -1
  78. package/lib/commonjs/values/hooks/useClockValue.d.ts +3 -0
  79. package/lib/commonjs/values/hooks/useClockValue.js +3 -0
  80. package/lib/commonjs/values/hooks/useClockValue.js.map +1 -1
  81. package/lib/commonjs/values/hooks/useComputedValue.d.ts +3 -0
  82. package/lib/commonjs/values/hooks/useComputedValue.js +3 -0
  83. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  84. package/lib/commonjs/values/hooks/useValue.d.ts +3 -0
  85. package/lib/commonjs/values/hooks/useValue.js +3 -0
  86. package/lib/commonjs/values/hooks/useValue.js.map +1 -1
  87. package/lib/commonjs/values/hooks/useValueEffect.d.ts +3 -0
  88. package/lib/commonjs/values/hooks/useValueEffect.js +3 -0
  89. package/lib/commonjs/values/hooks/useValueEffect.js.map +1 -1
  90. package/lib/commonjs/values/types.d.ts +4 -4
  91. package/lib/commonjs/values/types.js.map +1 -1
  92. package/lib/commonjs/views/SkiaView.d.ts +5 -0
  93. package/lib/commonjs/views/SkiaView.js +9 -0
  94. package/lib/commonjs/views/SkiaView.js.map +1 -1
  95. package/lib/module/animation/spring/runSpring.d.ts +3 -0
  96. package/lib/module/animation/spring/runSpring.js +3 -0
  97. package/lib/module/animation/spring/runSpring.js.map +1 -1
  98. package/lib/module/animation/spring/useSpring.d.ts +3 -0
  99. package/lib/module/animation/spring/useSpring.js +3 -0
  100. package/lib/module/animation/spring/useSpring.js.map +1 -1
  101. package/lib/module/animation/timing/runTiming.d.ts +3 -0
  102. package/lib/module/animation/timing/runTiming.js +3 -0
  103. package/lib/module/animation/timing/runTiming.js.map +1 -1
  104. package/lib/module/animation/timing/useLoop.d.ts +3 -0
  105. package/lib/module/animation/timing/useLoop.js +3 -0
  106. package/lib/module/animation/timing/useLoop.js.map +1 -1
  107. package/lib/module/animation/timing/useTiming.d.ts +3 -0
  108. package/lib/module/animation/timing/useTiming.js +3 -0
  109. package/lib/module/animation/timing/useTiming.js.map +1 -1
  110. package/lib/module/dom/nodes/JsiSkDOM.js +2 -0
  111. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  112. package/lib/module/dom/nodes/datatypes/Fitting.d.ts +5 -5
  113. package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
  114. package/lib/module/dom/nodes/datatypes/Gradient.d.ts +235 -75
  115. package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
  116. package/lib/module/dom/types/Common.d.ts +3 -3
  117. package/lib/module/dom/types/Common.js.map +1 -1
  118. package/lib/module/external/reanimated/interpolators.js +11 -5
  119. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  120. package/lib/module/renderer/Canvas.js +35 -29
  121. package/lib/module/renderer/Canvas.js.map +1 -1
  122. package/lib/module/renderer/components/Drawing.d.ts +5 -0
  123. package/lib/module/renderer/components/Drawing.js +6 -0
  124. package/lib/module/renderer/components/Drawing.js.map +1 -1
  125. package/lib/module/renderer/components/shapes/FitBox.d.ts +5 -5
  126. package/lib/module/skia/core/Matrix.d.ts +2 -2
  127. package/lib/module/skia/core/Matrix.js.map +1 -1
  128. package/lib/module/skia/core/Picture.d.ts +2 -2
  129. package/lib/module/skia/core/Picture.js +12 -3
  130. package/lib/module/skia/core/Picture.js.map +1 -1
  131. package/lib/module/skia/core/Vector.d.ts +3 -3
  132. package/lib/module/skia/core/Vector.js.map +1 -1
  133. package/lib/module/skia/types/Canvas.d.ts +1 -1
  134. package/lib/module/skia/types/Canvas.js.map +1 -1
  135. package/lib/module/skia/types/Matrix.d.ts +4 -9
  136. package/lib/module/skia/types/Matrix.js +3 -57
  137. package/lib/module/skia/types/Matrix.js.map +1 -1
  138. package/lib/module/skia/types/Matrix4.d.ts +39 -0
  139. package/lib/module/skia/types/Matrix4.js +200 -0
  140. package/lib/module/skia/types/Matrix4.js.map +1 -0
  141. package/lib/module/skia/types/Path/Path.d.ts +1 -1
  142. package/lib/module/skia/types/Path/Path.js.map +1 -1
  143. package/lib/module/skia/types/Picture/PictureRecorder.d.ts +1 -1
  144. package/lib/module/skia/types/Picture/PictureRecorder.js.map +1 -1
  145. package/lib/module/skia/types/Rect.d.ts +1 -0
  146. package/lib/module/skia/types/Rect.js +9 -0
  147. package/lib/module/skia/types/Rect.js.map +1 -1
  148. package/lib/module/skia/types/index.d.ts +1 -0
  149. package/lib/module/skia/types/index.js +1 -0
  150. package/lib/module/skia/types/index.js.map +1 -1
  151. package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  152. package/lib/module/skia/web/JsiSkCanvas.js +1 -1
  153. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  154. package/lib/module/skia/web/JsiSkMatrix.d.ts +1 -1
  155. package/lib/module/skia/web/JsiSkMatrix.js +1 -1
  156. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  157. package/lib/module/skia/web/JsiSkPath.js +1 -1
  158. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  159. package/lib/module/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  160. package/lib/module/skia/web/JsiSkPictureRecorder.js +1 -1
  161. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  162. package/lib/module/values/api.d.ts +23 -2
  163. package/lib/module/values/api.js +44 -1
  164. package/lib/module/values/api.js.map +1 -1
  165. package/lib/module/values/hooks/useClockValue.d.ts +3 -0
  166. package/lib/module/values/hooks/useClockValue.js +3 -0
  167. package/lib/module/values/hooks/useClockValue.js.map +1 -1
  168. package/lib/module/values/hooks/useComputedValue.d.ts +3 -0
  169. package/lib/module/values/hooks/useComputedValue.js +3 -0
  170. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  171. package/lib/module/values/hooks/useValue.d.ts +3 -0
  172. package/lib/module/values/hooks/useValue.js +3 -0
  173. package/lib/module/values/hooks/useValue.js.map +1 -1
  174. package/lib/module/values/hooks/useValueEffect.d.ts +3 -0
  175. package/lib/module/values/hooks/useValueEffect.js +3 -0
  176. package/lib/module/values/hooks/useValueEffect.js.map +1 -1
  177. package/lib/module/values/types.d.ts +4 -4
  178. package/lib/module/values/types.js.map +1 -1
  179. package/lib/module/views/SkiaView.d.ts +5 -0
  180. package/lib/module/views/SkiaView.js +10 -0
  181. package/lib/module/views/SkiaView.js.map +1 -1
  182. package/lib/typescript/src/animation/spring/runSpring.d.ts +3 -0
  183. package/lib/typescript/src/animation/spring/useSpring.d.ts +3 -0
  184. package/lib/typescript/src/animation/timing/runTiming.d.ts +3 -0
  185. package/lib/typescript/src/animation/timing/useLoop.d.ts +3 -0
  186. package/lib/typescript/src/animation/timing/useTiming.d.ts +3 -0
  187. package/lib/typescript/src/dom/nodes/datatypes/Fitting.d.ts +5 -5
  188. package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +235 -75
  189. package/lib/typescript/src/dom/types/Common.d.ts +3 -3
  190. package/lib/typescript/src/renderer/components/Drawing.d.ts +5 -0
  191. package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +5 -5
  192. package/lib/typescript/src/skia/core/Matrix.d.ts +2 -2
  193. package/lib/typescript/src/skia/core/Picture.d.ts +2 -2
  194. package/lib/typescript/src/skia/core/Vector.d.ts +3 -3
  195. package/lib/typescript/src/skia/types/Canvas.d.ts +1 -1
  196. package/lib/typescript/src/skia/types/Matrix.d.ts +4 -9
  197. package/lib/typescript/src/skia/types/Matrix4.d.ts +39 -0
  198. package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -1
  199. package/lib/typescript/src/skia/types/Picture/PictureRecorder.d.ts +1 -1
  200. package/lib/typescript/src/skia/types/Rect.d.ts +1 -0
  201. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  202. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
  203. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +1 -1
  204. package/lib/typescript/src/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  205. package/lib/typescript/src/values/api.d.ts +23 -2
  206. package/lib/typescript/src/values/hooks/useClockValue.d.ts +3 -0
  207. package/lib/typescript/src/values/hooks/useComputedValue.d.ts +3 -0
  208. package/lib/typescript/src/values/hooks/useValue.d.ts +3 -0
  209. package/lib/typescript/src/values/hooks/useValueEffect.d.ts +3 -0
  210. package/lib/typescript/src/values/types.d.ts +4 -4
  211. package/lib/typescript/src/views/SkiaView.d.ts +5 -0
  212. package/package.json +1 -1
  213. package/src/animation/spring/runSpring.ts +3 -0
  214. package/src/animation/spring/useSpring.ts +3 -0
  215. package/src/animation/timing/runTiming.ts +3 -0
  216. package/src/animation/timing/useLoop.ts +3 -0
  217. package/src/animation/timing/useTiming.ts +3 -0
  218. package/src/dom/nodes/JsiSkDOM.ts +4 -0
  219. package/src/dom/nodes/datatypes/Fitting.ts +10 -2
  220. package/src/dom/nodes/datatypes/Gradient.ts +2 -2
  221. package/src/dom/types/Common.ts +3 -3
  222. package/src/external/reanimated/interpolators.ts +14 -6
  223. package/src/renderer/Canvas.tsx +41 -30
  224. package/src/renderer/components/Drawing.tsx +5 -0
  225. package/src/skia/core/Matrix.ts +2 -2
  226. package/src/skia/core/Picture.ts +11 -3
  227. package/src/skia/core/Vector.ts +5 -2
  228. package/src/skia/types/Canvas.ts +1 -1
  229. package/src/skia/types/Matrix.ts +7 -74
  230. package/src/skia/types/Matrix4.ts +266 -0
  231. package/src/skia/types/Path/Path.ts +1 -1
  232. package/src/skia/types/Picture/PictureRecorder.ts +1 -1
  233. package/src/skia/types/Rect.ts +14 -0
  234. package/src/skia/types/index.ts +1 -0
  235. package/src/skia/web/JsiSkCanvas.ts +2 -2
  236. package/src/skia/web/JsiSkMatrix.ts +4 -2
  237. package/src/skia/web/JsiSkPath.ts +1 -1
  238. package/src/skia/web/JsiSkPictureRecorder.ts +6 -2
  239. package/src/values/api.ts +55 -2
  240. package/src/values/hooks/useClockValue.ts +3 -0
  241. package/src/values/hooks/useComputedValue.ts +3 -0
  242. package/src/values/hooks/useValue.ts +3 -0
  243. package/src/values/hooks/useValueEffect.ts +3 -0
  244. package/src/values/types.ts +6 -6
  245. package/src/views/SkiaView.tsx +11 -0
@@ -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,8 +1,8 @@
1
- import type { SkCanvas, SkRect } from "../types";
1
+ import { type SkCanvas, type SkRect, type SkSize } from "../types";
2
2
  /**
3
3
  * Memoizes and returns an SkPicture that can be drawn to another canvas.
4
4
  * @param rect Picture bounds
5
5
  * @param cb Callback for drawing to the canvas
6
6
  * @returns SkPicture
7
7
  */
8
- export declare const createPicture: (rect: SkRect, cb: (canvas: SkCanvas) => void) => import("../types").SkPicture;
8
+ export declare const createPicture: (cb: (canvas: SkCanvas) => void, rect?: SkRect | SkSize) => import("../types").SkPicture;
@@ -5,8 +5,8 @@ export declare const neg: (a: Vector) => import("../types").SkPoint;
5
5
  export declare const add: (a: Vector, b: Vector) => import("../types").SkPoint;
6
6
  export declare const sub: (a: Vector, b: Vector) => import("../types").SkPoint;
7
7
  export declare const dist: (a: Vector, b: Vector) => number;
8
- export declare const translate: ({ x, y }: Vector) => readonly [{
9
- readonly translateX: number;
8
+ export declare const translate: ({ x, y, }: Vector) => [{
9
+ translateX: number;
10
10
  }, {
11
- readonly translateY: number;
11
+ translateY: number;
12
12
  }];
@@ -372,7 +372,7 @@ export interface SkCanvas {
372
372
  * Replaces current matrix with m premultiplied with the existing matrix.
373
373
  * @param m
374
374
  */
375
- concat(m: SkMatrix): void;
375
+ concat(m: SkMatrix | number[]): void;
376
376
  /**
377
377
  * Draws the given picture using the current clip, current matrix, and the provided paint.
378
378
  * @param skp
@@ -1,5 +1,6 @@
1
1
  import type { SkJSIInstance } from "./JsiInstance";
2
2
  import type { SkCanvas } from "./Canvas";
3
+ import type { Transforms3d } from "./Matrix4";
3
4
  export declare enum MatrixIndex {
4
5
  ScaleX = 0,
5
6
  SkewX = 1,
@@ -13,7 +14,7 @@ export declare enum MatrixIndex {
13
14
  }
14
15
  export declare const isMatrix: (obj: unknown) => obj is SkMatrix;
15
16
  export interface SkMatrix extends SkJSIInstance<"Matrix"> {
16
- concat: (matrix: SkMatrix) => SkMatrix;
17
+ concat: (matrix: SkMatrix | number[]) => SkMatrix;
17
18
  translate: (x: number, y: number) => SkMatrix;
18
19
  scale: (x: number, y?: number) => SkMatrix;
19
20
  skew: (x: number, y: number) => SkMatrix;
@@ -25,14 +26,8 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
25
26
  identity: () => SkMatrix;
26
27
  get: () => number[];
27
28
  }
28
- type Transform2dName = "translateX" | "translateY" | "scale" | "skewX" | "skewY" | "scaleX" | "scaleY" | "rotateZ" | "rotate";
29
- type Transformations = {
30
- readonly [Name in Transform2dName]: number;
31
- };
32
- export type Transforms2d = readonly (Pick<Transformations, "translateX"> | Pick<Transformations, "translateY"> | Pick<Transformations, "scale"> | Pick<Transformations, "scaleX"> | Pick<Transformations, "scaleY"> | Pick<Transformations, "skewX"> | Pick<Transformations, "skewY"> | Pick<Transformations, "rotate">)[];
33
29
  export interface TransformProp {
34
- transform?: Transforms2d;
30
+ transform?: Transforms3d;
35
31
  }
36
- export declare const processTransform: <T extends SkMatrix | SkCanvas>(m: T, transforms: Transforms2d) => T;
32
+ export declare const processTransform: <T extends SkMatrix | SkCanvas>(m: T, transforms: Transforms3d) => T;
37
33
  export declare const toDegrees: (rad: number) => number;
38
- export {};
@@ -0,0 +1,39 @@
1
+ type Vec2 = readonly [number, number];
2
+ type Vec3 = readonly [number, number, number];
3
+ export type Matrix4 = readonly [
4
+ number,
5
+ number,
6
+ number,
7
+ number,
8
+ number,
9
+ number,
10
+ number,
11
+ number,
12
+ number,
13
+ number,
14
+ number,
15
+ number,
16
+ number,
17
+ number,
18
+ number,
19
+ number
20
+ ];
21
+ type Transform3dName = "translateX" | "translateY" | "translateZ" | "translate" | "scale" | "scaleX" | "scaleY" | "skewX" | "skewY" | "rotateZ" | "rotate" | "perspective" | "rotateX" | "rotateY" | "matrix";
22
+ type Transformations = {
23
+ [Name in Transform3dName]: Name extends "matrix" ? Matrix4 : Name extends "translate" ? Vec3 | Vec2 : number;
24
+ };
25
+ type Transform3d = Pick<Transformations, "translateX"> | Pick<Transformations, "translateY"> | Pick<Transformations, "translateZ"> | Pick<Transformations, "translate"> | Pick<Transformations, "scale"> | Pick<Transformations, "scaleX"> | Pick<Transformations, "scaleY"> | Pick<Transformations, "skewX"> | Pick<Transformations, "skewY"> | Pick<Transformations, "perspective"> | Pick<Transformations, "rotateX"> | Pick<Transformations, "rotateY"> | Pick<Transformations, "rotateZ"> | Pick<Transformations, "rotate"> | Pick<Transformations, "matrix">;
26
+ export type Transforms3d = Transform3d[];
27
+ /**
28
+ * @worklet
29
+ */
30
+ export declare const Matrix4: () => Matrix4;
31
+ /**
32
+ * @worklet
33
+ */
34
+ export declare const mapPoint3d: (m: Matrix4, v: Vec3) => readonly [number, number, number];
35
+ /**
36
+ * @worklet
37
+ */
38
+ export declare const processTransform3d: (transforms: Transforms3d) => number[];
39
+ export {};
@@ -440,7 +440,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
440
440
  /**
441
441
  * Transforms the path by the specified matrix.
442
442
  */
443
- transform(m3: SkMatrix): SkPath;
443
+ transform(m3: SkMatrix | number[]): SkPath;
444
444
  /**
445
445
  * Interpolates between Path with point array of equal size.
446
446
  * Copy verb array and weights to result, and set result path to a weighted
@@ -7,7 +7,7 @@ export interface SkPictureRecorder {
7
7
  *
8
8
  * @param bounds - a rect to cull the results.
9
9
  */
10
- beginRecording(bounds: SkRect): SkCanvas;
10
+ beginRecording(bounds?: SkRect): SkCanvas;
11
11
  /**
12
12
  * Returns the captured draw commands as a picture and invalidates the canvas returned earlier.
13
13
  */
@@ -4,3 +4,4 @@ export interface SkRect {
4
4
  readonly width: number;
5
5
  readonly height: number;
6
6
  }
7
+ export declare const isRect: (def: unknown) => def is SkRect;
@@ -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";
@@ -40,7 +40,7 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
40
40
  clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;
41
41
  clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;
42
42
  clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;
43
- concat(m: SkMatrix): void;
43
+ concat(m: SkMatrix | number[]): void;
44
44
  drawPicture(skp: SkPicture): void;
45
45
  readPixels(srcX: number, srcY: number, imageInfo: ImageInfo): Float32Array | Uint8Array | null;
46
46
  }
@@ -6,7 +6,7 @@ export declare class JsiSkMatrix extends HostObject<Matrix3x3, "Matrix"> impleme
6
6
  private preMultiply;
7
7
  private postMultiply;
8
8
  dispose: () => void;
9
- concat(matrix: SkMatrix): this;
9
+ concat(matrix: SkMatrix | number[]): this;
10
10
  translate(x: number, y: number): this;
11
11
  postTranslate(x: number, y: number): this;
12
12
  scale(x: number, y?: number): this;
@@ -7,6 +7,6 @@ import { JsiSkPicture } from "./JsiSkPicture";
7
7
  export declare class JsiSkPictureRecorder extends HostObject<PictureRecorder, "PictureRecorder"> implements SkPictureRecorder {
8
8
  constructor(CanvasKit: CanvasKit, ref: PictureRecorder);
9
9
  dispose: () => void;
10
- beginRecording(bounds: SkRect): JsiSkCanvas;
10
+ beginRecording(bounds?: SkRect): JsiSkCanvas;
11
11
  finishRecordingAsPicture(): JsiSkPicture;
12
12
  }
@@ -1,5 +1,26 @@
1
- import type { ISkiaValueApi } from "./types";
1
+ import type { AnimationState, ISkiaValueApi, SkiaAnimation, SkiaClockValue, SkiaMutableValue, SkiaValue } from "./types";
2
2
  declare global {
3
3
  var SkiaValueApi: ISkiaValueApi;
4
4
  }
5
- export declare const ValueApi: ISkiaValueApi;
5
+ export declare const ValueApi: {
6
+ /**
7
+ * @deprecated Use Reanimated 3
8
+ * for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
9
+ */
10
+ createValue<T>(initialValue: T): SkiaMutableValue<T>;
11
+ /**
12
+ * @deprecated Use Reanimated 3
13
+ * for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
14
+ */
15
+ createComputedValue<R>(cb: () => R, values: SkiaValue<unknown>[]): SkiaValue<R>;
16
+ /**
17
+ * @deprecated Use Reanimated 3
18
+ * for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
19
+ */
20
+ createClockValue(): SkiaClockValue;
21
+ /**
22
+ * @deprecated Use Reanimated 3
23
+ * for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
24
+ */
25
+ createAnimation<S extends AnimationState = AnimationState>(cb: (t: number, state: S | undefined) => S): SkiaAnimation;
26
+ };
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * @deprecated Use Reanimated 3
3
+ * for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
4
+ *
2
5
  * @returns A new value that will be updated on every frame redraw with the
3
6
  * number of milliseconds elapsed since the value was started.
4
7
  * The clock is created in the stopped state.
@@ -1,4 +1,7 @@
1
1
  /**
2
+ * @deprecated Use Reanimated 3
3
+ * for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
4
+ *
2
5
  * Creates a new computed value - a value that will calculate its value depending
3
6
  * on other values.
4
7
  * @param cb Callback to calculate new value
@@ -1,5 +1,8 @@
1
1
  import type { SkiaMutableValue } from "../types";
2
2
  /**
3
+ * @deprecated Use Reanimated 3
4
+ * for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
5
+ *
3
6
  * Creates a new value that holds some data.
4
7
  * @param v Value to hold
5
8
  * @returns A Value of type of v
@@ -1,5 +1,8 @@
1
1
  import type { SkiaValue } from "../types";
2
2
  /**
3
+ * @deprecated Use Reanimated 3
4
+ * for animating Skia: https://shopify.github.io/react-native-skia/docs/animations/animations
5
+ *
3
6
  * Sets up an effect that will be run whenever the value changes
4
7
  * @param value Value to subscribe to changes on
5
8
  * @param cb Callback to run when value changes
@@ -43,21 +43,21 @@ export interface ISkiaValueApi {
43
43
  * Creates a new value that holds the initial value and that
44
44
  * can be changed.
45
45
  */
46
- createValue: <T>(initialValue: T) => SkiaMutableValue<T>;
46
+ createValue<T>(initialValue: T): SkiaMutableValue<T>;
47
47
  /**
48
48
  * Creates a computed value. This is a calculated value that returns the result of
49
49
  * a function that is called with the values of the dependencies.
50
50
  */
51
- createComputedValue: <R>(cb: () => R, values: Array<SkiaValue<unknown>>) => SkiaValue<R>;
51
+ createComputedValue<R>(cb: () => R, values: Array<SkiaValue<unknown>>): SkiaValue<R>;
52
52
  /**
53
53
  * Creates a clock value where the value is the number of milliseconds elapsed
54
54
  * since the clock was created
55
55
  */
56
- createClockValue: () => SkiaClockValue;
56
+ createClockValue(): SkiaClockValue;
57
57
  /**
58
58
  * Creates an animation that is driven from a clock and updated every frame.
59
59
  * @param cb Callback to calculate next value from time.
60
60
  * @returns An animation object that can control a value.
61
61
  */
62
- createAnimation: <S extends AnimationState = AnimationState>(cb: (t: number, state: S | undefined) => S) => SkiaAnimation;
62
+ createAnimation<S extends AnimationState = AnimationState>(cb: (t: number, state: S | undefined) => S): SkiaAnimation;
63
63
  }
@@ -5,6 +5,11 @@ import type { SkiaDrawViewProps } from "./types";
5
5
  export declare const SkiaViewNativeId: {
6
6
  current: number;
7
7
  };
8
+ /**
9
+ * @deprecated If you are looking to use the Skia imperative API, you can use:
10
+ * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
11
+ * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
12
+ */
8
13
  export declare class SkiaView extends React.Component<SkiaDrawViewProps> {
9
14
  constructor(props: SkiaDrawViewProps);
10
15
  private _nativeId;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.224",
10
+ "version": "0.1.227",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -10,6 +10,9 @@ import { Spring } from "./Spring";
10
10
  import { createSpringEasing } from "./functions/spring";
11
11
 
12
12
  /**
13
+ * @deprecated Use Reanimated 3 for animations:
14
+ * https://shopify.github.io/react-native-skia/docs/animations/animations
15
+ *
13
16
  * Creates a new animation on an existing value that will be driven by
14
17
  * an animation value. The value will be run from / to the value in
15
18
  * params and modified by the provided easing curve for the length of
@@ -10,6 +10,9 @@ import { Spring } from "./Spring";
10
10
  import { createSpringEasing } from "./functions/spring";
11
11
 
12
12
  /**
13
+ * @deprecated Use Reanimated 3 for animations:
14
+ * https://shopify.github.io/react-native-skia/docs/animations/animations
15
+ *
13
16
  * Creats a spring based animation value that will run whenever
14
17
  * the animation parameters change.
15
18
  * @param toOrParams
@@ -8,6 +8,9 @@ import type {
8
8
  import { getResolvedParams } from "./functions";
9
9
  import { createTiming } from "./createTiming";
10
10
  /**
11
+ * @deprecated Use Reanimated 3 for animations:
12
+ * https://shopify.github.io/react-native-skia/docs/animations/animations
13
+ *
11
14
  * Creates a new animation on an existing value that will be driven by
12
15
  * an animation value. The value will be run from / to the value in
13
16
  * params and modified by the provided easing curve for the length of
@@ -3,6 +3,9 @@ import type { TimingConfig } from "../types";
3
3
  import { useTiming } from "./useTiming";
4
4
 
5
5
  /**
6
+ * @deprecated Use Reanimated 3 for animations:
7
+ * https://shopify.github.io/react-native-skia/docs/animations/animations
8
+ *
6
9
  * Configures a looped timing value. The value will go back and forth
7
10
  * between 0 and 1 and back.
8
11
  * @param config Timing configuration for easing and duration
@@ -12,6 +12,9 @@ import { getResolvedParams } from "./functions";
12
12
  import { createTiming } from "./createTiming";
13
13
 
14
14
  /**
15
+ * @deprecated Use Reanimated 3 for animations:
16
+ * https://shopify.github.io/react-native-skia/docs/animations/animations
17
+ *
15
18
  * Creats an animation value that will run whenever
16
19
  * the animation parameters change. The animation start immediately.
17
20
  * @param toOrParams
@@ -173,6 +173,10 @@ export class JsiSkDOM implements SkDOM {
173
173
  }
174
174
 
175
175
  CustomDrawing(props: CustomDrawingNodeProps) {
176
+ console.warn(
177
+ // eslint-disable-next-line max-len
178
+ "The <Drawing /> component is deprecated and will be removed in the next release. For custom drawings, please sure the <Picture /> component: https://shopify.github.io/react-native-skia/docs/shapes/pictures/"
179
+ );
176
180
  return NATIVE_DOM
177
181
  ? global.SkiaDomApi.CustomDrawingNode(props ?? {})
178
182
  : new CustomDrawingNode(this.ctx, props);
@@ -9,12 +9,20 @@ export interface Size {
9
9
 
10
10
  export const size = (width = 0, height = 0) => ({ width, height });
11
11
 
12
- export const rect2rect = (src: SkRect, dst: SkRect) => {
12
+ export const rect2rect = (
13
+ src: SkRect,
14
+ dst: SkRect
15
+ ): [
16
+ { translateX: number },
17
+ { translateY: number },
18
+ { scaleX: number },
19
+ { scaleY: number }
20
+ ] => {
13
21
  const scaleX = dst.width / src.width;
14
22
  const scaleY = dst.height / src.height;
15
23
  const translateX = dst.x - src.x * scaleX;
16
24
  const translateY = dst.y - src.y * scaleY;
17
- return [{ translateX }, { translateY }, { scaleX }, { scaleY }] as const;
25
+ return [{ translateX }, { translateY }, { scaleX }, { scaleY }];
18
26
  };
19
27
 
20
28
  export const fitRects = (
@@ -1,11 +1,11 @@
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
4
 
5
5
  import { enumKey } from "./Enum";
6
6
  import { processTransformProps } from "./Transform";
7
7
 
8
- export const transformOrigin = (origin: Vector, transform: Transforms2d) => [
8
+ export const transformOrigin = (origin: Vector, transform: Transforms3d) => [
9
9
  { translateX: origin.x },
10
10
  { translateY: origin.y },
11
11
  ...transform,
@@ -11,7 +11,7 @@ import type {
11
11
  SkRRect,
12
12
  StrokeCap,
13
13
  StrokeJoin,
14
- Transforms2d,
14
+ Transforms3d,
15
15
  Vector,
16
16
  } from "../../skia/types";
17
17
 
@@ -64,9 +64,9 @@ export interface ScalarCircleDef {
64
64
  export type CircleDef = PointCircleDef | ScalarCircleDef;
65
65
 
66
66
  export interface TransformProps {
67
- transform?: Transforms2d;
67
+ transform?: Transforms3d;
68
68
  origin?: Vector;
69
- matrix?: SkMatrix;
69
+ matrix?: SkMatrix | number[];
70
70
  }
71
71
 
72
72
  export interface PaintProps extends ChildrenProps {
@@ -1,5 +1,9 @@
1
- import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
2
- import { useMemo } from "react";
1
+ import type {
2
+ ExtrapolationType,
3
+ FrameInfo,
4
+ SharedValue,
5
+ } from "react-native-reanimated";
6
+ import { useMemo, useRef } from "react";
3
7
 
4
8
  import type { SkPath, SkPoint } from "../../skia/types";
5
9
  import { interpolatePaths, interpolateVector } from "../../animation";
@@ -13,15 +17,19 @@ import {
13
17
 
14
18
  export const notifyChange = (value: SharedValue<unknown>) => {
15
19
  "worklet";
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- (value as any)._value = value.value;
20
+ if (_WORKLET) {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ (value as any)._value = value.value;
23
+ }
18
24
  };
19
25
 
20
26
  export const useClock = () => {
21
27
  const clock = useSharedValue(0);
22
- useFrameCallback((info) => {
28
+ const callback = useRef((info: FrameInfo) => {
29
+ "worklet";
23
30
  clock.value = info.timeSinceFirstFrame;
24
- });
31
+ }).current;
32
+ useFrameCallback(callback);
25
33
  return clock;
26
34
  };
27
35
 
@@ -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,10 @@ 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) => {
25
+ export const translate = ({
26
+ x,
27
+ y,
28
+ }: Vector): [{ translateX: number }, { translateY: number }] => {
26
29
  "worklet";
27
- return [{ translateX: x }, { translateY: y }] as const;
30
+ return [{ translateX: x }, { translateY: y }];
28
31
  };