@shopify/react-native-skia 0.1.142 → 0.1.146

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. package/cpp/api/JsiSkContourMeasure.h +4 -4
  2. package/cpp/api/JsiSkDataFactory.h +3 -3
  3. package/cpp/api/JsiSkFont.h +1 -1
  4. package/cpp/api/JsiSkPaint.h +6 -0
  5. package/cpp/api/JsiSkPathFactory.h +2 -2
  6. package/cpp/api/JsiSkPicture.h +7 -1
  7. package/cpp/api/JsiSkPictureFactory.h +1 -1
  8. package/cpp/api/JsiSkRuntimeEffect.h +6 -6
  9. package/cpp/api/JsiSkRuntimeEffectFactory.h +1 -1
  10. package/cpp/jsi/JsiSimpleValueWrapper.h +27 -27
  11. package/cpp/jsi/JsiValueWrapper.h +127 -0
  12. package/cpp/rnskia/RNSkDrawView.cpp +44 -20
  13. package/cpp/rnskia/RNSkDrawView.h +18 -20
  14. package/cpp/rnskia/RNSkJsiViewApi.h +180 -166
  15. package/cpp/rnskia/values/RNSkComputedValue.h +11 -11
  16. package/cpp/rnskia/values/RNSkReadonlyValue.h +19 -19
  17. package/cpp/rnskia/values/RNSkValue.h +13 -13
  18. package/cpp/utils/RNSkLog.h +4 -4
  19. package/lib/commonjs/renderer/Canvas.js +17 -7
  20. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  21. package/lib/commonjs/renderer/DependencyManager.js +144 -36
  22. package/lib/commonjs/renderer/DependencyManager.js.map +1 -1
  23. package/lib/commonjs/renderer/HostConfig.js +18 -2
  24. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  25. package/lib/commonjs/renderer/components/Blend.js +20 -5
  26. package/lib/commonjs/renderer/components/Blend.js.map +1 -1
  27. package/lib/commonjs/renderer/components/backdrop/BackdropFilter.js.map +1 -1
  28. package/lib/commonjs/renderer/components/imageFilters/Morphology.js +1 -1
  29. package/lib/commonjs/renderer/components/imageFilters/Morphology.js.map +1 -1
  30. package/lib/commonjs/renderer/components/imageFilters/Shadow.js +1 -1
  31. package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -1
  32. package/lib/commonjs/renderer/nodes/Declaration.js +2 -3
  33. package/lib/commonjs/renderer/nodes/Declaration.js.map +1 -1
  34. package/lib/commonjs/renderer/nodes/Drawing.js +3 -7
  35. package/lib/commonjs/renderer/nodes/Drawing.js.map +1 -1
  36. package/lib/commonjs/renderer/nodes/Node.js +9 -7
  37. package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
  38. package/lib/commonjs/renderer/processors/Animations/Animations.js +3 -22
  39. package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
  40. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  41. package/lib/commonjs/skia/web/Host.js +12 -21
  42. package/lib/commonjs/skia/web/Host.js.map +1 -1
  43. package/lib/commonjs/skia/web/JsiSkCanvas.js +46 -26
  44. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  45. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +4 -4
  46. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  47. package/lib/commonjs/skia/web/JsiSkFont.js +7 -3
  48. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  49. package/lib/commonjs/skia/web/JsiSkImage.js +4 -2
  50. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  51. package/lib/commonjs/skia/web/JsiSkImageFactory.js +4 -2
  52. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  53. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +61 -19
  54. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  55. package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
  56. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  57. package/lib/commonjs/skia/web/JsiSkPaint.js +19 -6
  58. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  59. package/lib/commonjs/skia/web/JsiSkPath.js +9 -55
  60. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  61. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +7 -3
  62. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  63. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  64. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  65. package/lib/commonjs/skia/web/JsiSkPicture.js +5 -1
  66. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  67. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +3 -1
  68. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
  69. package/lib/commonjs/skia/web/JsiSkPoint.js +9 -1
  70. package/lib/commonjs/skia/web/JsiSkPoint.js.map +1 -1
  71. package/lib/commonjs/skia/web/JsiSkRRect.js +1 -1
  72. package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
  73. package/lib/commonjs/skia/web/JsiSkRSXform.js.map +1 -1
  74. package/lib/commonjs/skia/web/JsiSkRect.js +1 -1
  75. package/lib/commonjs/skia/web/JsiSkRect.js.map +1 -1
  76. package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js +4 -2
  77. package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  78. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +10 -6
  79. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  80. package/lib/commonjs/skia/web/JsiSkSurface.js +3 -1
  81. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  82. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +8 -4
  83. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  84. package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js +1 -1
  85. package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js.map +1 -1
  86. package/lib/commonjs/skia/web/JsiSkia.js +12 -6
  87. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  88. package/lib/commonjs/views/SkiaView.js +11 -27
  89. package/lib/commonjs/views/SkiaView.js.map +1 -1
  90. package/lib/commonjs/views/types.js.map +1 -1
  91. package/lib/module/renderer/Canvas.js +17 -6
  92. package/lib/module/renderer/Canvas.js.map +1 -1
  93. package/lib/module/renderer/DependencyManager.js +140 -33
  94. package/lib/module/renderer/DependencyManager.js.map +1 -1
  95. package/lib/module/renderer/HostConfig.js +18 -2
  96. package/lib/module/renderer/HostConfig.js.map +1 -1
  97. package/lib/module/renderer/components/Blend.js +21 -5
  98. package/lib/module/renderer/components/Blend.js.map +1 -1
  99. package/lib/module/renderer/components/backdrop/BackdropFilter.js.map +1 -1
  100. package/lib/module/renderer/components/imageFilters/Morphology.js +1 -1
  101. package/lib/module/renderer/components/imageFilters/Morphology.js.map +1 -1
  102. package/lib/module/renderer/components/imageFilters/Shadow.js +1 -1
  103. package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -1
  104. package/lib/module/renderer/nodes/Declaration.js +3 -4
  105. package/lib/module/renderer/nodes/Declaration.js.map +1 -1
  106. package/lib/module/renderer/nodes/Drawing.js +3 -6
  107. package/lib/module/renderer/nodes/Drawing.js.map +1 -1
  108. package/lib/module/renderer/nodes/Node.js +9 -7
  109. package/lib/module/renderer/nodes/Node.js.map +1 -1
  110. package/lib/module/renderer/processors/Animations/Animations.js +1 -16
  111. package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
  112. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  113. package/lib/module/skia/web/Host.js +9 -9
  114. package/lib/module/skia/web/Host.js.map +1 -1
  115. package/lib/module/skia/web/JsiSkCanvas.js +37 -27
  116. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  117. package/lib/module/skia/web/JsiSkColorFilterFactory.js +5 -5
  118. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  119. package/lib/module/skia/web/JsiSkFont.js +6 -4
  120. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  121. package/lib/module/skia/web/JsiSkImage.js +4 -3
  122. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  123. package/lib/module/skia/web/JsiSkImageFactory.js +4 -3
  124. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  125. package/lib/module/skia/web/JsiSkImageFilterFactory.js +61 -20
  126. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  127. package/lib/module/skia/web/JsiSkMatrix.js +2 -2
  128. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  129. package/lib/module/skia/web/JsiSkPaint.js +15 -7
  130. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  131. package/lib/module/skia/web/JsiSkPath.js +9 -57
  132. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  133. package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -4
  134. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  135. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  136. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  137. package/lib/module/skia/web/JsiSkPicture.js +4 -2
  138. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  139. package/lib/module/skia/web/JsiSkPictureRecorder.js +3 -2
  140. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  141. package/lib/module/skia/web/JsiSkPoint.js +10 -2
  142. package/lib/module/skia/web/JsiSkPoint.js.map +1 -1
  143. package/lib/module/skia/web/JsiSkRRect.js +2 -2
  144. package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
  145. package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
  146. package/lib/module/skia/web/JsiSkRect.js +2 -2
  147. package/lib/module/skia/web/JsiSkRect.js.map +1 -1
  148. package/lib/module/skia/web/JsiSkRuntimeEffect.js +4 -3
  149. package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  150. package/lib/module/skia/web/JsiSkShaderFactory.js +9 -7
  151. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  152. package/lib/module/skia/web/JsiSkSurface.js +3 -2
  153. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  154. package/lib/module/skia/web/JsiSkTextBlobFactory.js +7 -5
  155. package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  156. package/lib/module/skia/web/JsiSkTypefaceFactory.js +2 -2
  157. package/lib/module/skia/web/JsiSkTypefaceFactory.js.map +1 -1
  158. package/lib/module/skia/web/JsiSkia.js +10 -5
  159. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  160. package/lib/module/views/SkiaView.js +11 -26
  161. package/lib/module/views/SkiaView.js.map +1 -1
  162. package/lib/module/views/types.js.map +1 -1
  163. package/lib/typescript/src/renderer/Canvas.d.ts +1 -1
  164. package/lib/typescript/src/renderer/DependencyManager.d.ts +40 -14
  165. package/lib/typescript/src/renderer/nodes/Declaration.d.ts +2 -2
  166. package/lib/typescript/src/renderer/nodes/Drawing.d.ts +2 -2
  167. package/lib/typescript/src/renderer/nodes/Node.d.ts +3 -2
  168. package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +0 -1
  169. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +5 -0
  170. package/lib/typescript/src/skia/types/Picture/Picture.d.ts +2 -1
  171. package/lib/typescript/src/skia/web/Host.d.ts +6 -8
  172. package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +8 -8
  173. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
  174. package/lib/typescript/src/skia/web/JsiSkPoint.d.ts +3 -2
  175. package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +2 -2
  176. package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +1 -2
  177. package/lib/typescript/src/skia/web/JsiSkRect.d.ts +2 -2
  178. package/lib/typescript/src/skia/web/JsiSkTextBlobFactory.d.ts +2 -1
  179. package/lib/typescript/src/views/SkiaView.d.ts +1 -11
  180. package/lib/typescript/src/views/types.d.ts +5 -5
  181. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  182. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  183. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  184. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  185. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  186. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  187. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  188. package/package.json +2 -2
  189. package/src/renderer/Canvas.tsx +19 -7
  190. package/src/renderer/DependencyManager.tsx +170 -39
  191. package/src/renderer/HostConfig.ts +12 -2
  192. package/src/renderer/components/Blend.tsx +25 -5
  193. package/src/renderer/components/backdrop/BackdropFilter.tsx +1 -1
  194. package/src/renderer/components/imageFilters/Morphology.tsx +2 -2
  195. package/src/renderer/components/imageFilters/Shadow.tsx +2 -2
  196. package/src/renderer/nodes/Declaration.tsx +6 -8
  197. package/src/renderer/nodes/Drawing.tsx +5 -7
  198. package/src/renderer/nodes/Node.ts +11 -9
  199. package/src/renderer/processors/Animations/Animations.ts +2 -15
  200. package/src/skia/types/Paint/Paint.ts +6 -0
  201. package/src/skia/types/Picture/Picture.ts +2 -1
  202. package/src/skia/web/Host.ts +12 -22
  203. package/src/skia/web/JsiSkCanvas.ts +78 -47
  204. package/src/skia/web/JsiSkColorFilterFactory.ts +15 -5
  205. package/src/skia/web/JsiSkFont.ts +11 -4
  206. package/src/skia/web/JsiSkImage.ts +4 -3
  207. package/src/skia/web/JsiSkImageFactory.ts +6 -3
  208. package/src/skia/web/JsiSkImageFilterFactory.ts +124 -52
  209. package/src/skia/web/JsiSkMatrix.ts +4 -2
  210. package/src/skia/web/JsiSkPaint.ts +15 -7
  211. package/src/skia/web/JsiSkPath.ts +16 -51
  212. package/src/skia/web/JsiSkPathEffectFactory.ts +10 -5
  213. package/src/skia/web/JsiSkPathFactory.ts +3 -3
  214. package/src/skia/web/JsiSkPicture.ts +5 -3
  215. package/src/skia/web/JsiSkPictureRecorder.ts +3 -2
  216. package/src/skia/web/JsiSkPoint.ts +12 -2
  217. package/src/skia/web/JsiSkRRect.ts +5 -2
  218. package/src/skia/web/JsiSkRSXform.ts +1 -1
  219. package/src/skia/web/JsiSkRect.ts +2 -2
  220. package/src/skia/web/JsiSkRuntimeEffect.ts +9 -4
  221. package/src/skia/web/JsiSkShaderFactory.ts +24 -15
  222. package/src/skia/web/JsiSkSurface.ts +7 -2
  223. package/src/skia/web/JsiSkTextBlobFactory.ts +14 -8
  224. package/src/skia/web/JsiSkTypefaceFactory.tsx +4 -2
  225. package/src/skia/web/JsiSkia.ts +17 -5
  226. package/src/views/SkiaView.tsx +17 -28
  227. package/src/views/types.ts +7 -6
@@ -1,4 +1,4 @@
1
- import type { Canvas, Image, CanvasKit, Paint } from "canvaskit-wasm";
1
+ import type { Canvas, CanvasKit } from "canvaskit-wasm";
2
2
 
3
3
  import type {
4
4
  BlendMode,
@@ -24,15 +24,19 @@ import type {
24
24
  SkVertices,
25
25
  } from "../types";
26
26
 
27
- import {
28
- ckEnum,
29
- HostObject,
30
- toValue,
31
- toUndefinedableValue,
32
- toOptionalValue,
33
- } from "./Host";
27
+ import { ckEnum, HostObject } from "./Host";
28
+ import { JsiSkPaint } from "./JsiSkPaint";
34
29
  import { JsiSkRect } from "./JsiSkRect";
35
30
  import { JsiSkRRect } from "./JsiSkRRect";
31
+ import { JsiSkImage } from "./JsiSkImage";
32
+ import { JsiSkVertices } from "./JsiSkVertices";
33
+ import { JsiSkPath } from "./JsiSkPath";
34
+ import { JsiSkFont } from "./JsiSkFont";
35
+ import { JsiSkTextBlob } from "./JsiSkTextBlob";
36
+ import { JsiSkPicture } from "./JsiSkPicture";
37
+ import { JsiSkMatrix } from "./JsiSkMatrix";
38
+ import { JsiSkImageFilter } from "./JsiSkImageFilter";
39
+ import { JsiSkPoint } from "./JsiSkPoint";
36
40
 
37
41
  export class JsiSkCanvas
38
42
  extends HostObject<Canvas, "Canvas">
@@ -45,12 +49,17 @@ export class JsiSkCanvas
45
49
  drawRect(rect: SkRect, paint: SkPaint) {
46
50
  this.ref.drawRect(
47
51
  JsiSkRect.fromValue(this.CanvasKit, rect),
48
- toValue<Paint>(paint)
52
+ JsiSkPaint.fromValue(paint)
49
53
  );
50
54
  }
51
55
 
52
56
  drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {
53
- this.ref.drawImage(toValue<Image>(image), x, y, toOptionalValue(paint));
57
+ this.ref.drawImage(
58
+ JsiSkImage.fromValue(image),
59
+ x,
60
+ y,
61
+ paint ? JsiSkPaint.fromValue(paint) : paint
62
+ );
54
63
  }
55
64
 
56
65
  drawImageRect(
@@ -61,10 +70,10 @@ export class JsiSkCanvas
61
70
  fastSample?: boolean
62
71
  ) {
63
72
  this.ref.drawImageRect(
64
- toValue<Image>(img),
73
+ JsiSkImage.fromValue(img),
65
74
  JsiSkRect.fromValue(this.CanvasKit, src),
66
75
  JsiSkRect.fromValue(this.CanvasKit, dest),
67
- toValue<Paint>(paint),
76
+ JsiSkPaint.fromValue(paint),
68
77
  fastSample
69
78
  );
70
79
  }
@@ -78,12 +87,12 @@ export class JsiSkCanvas
78
87
  paint?: SkPaint | null
79
88
  ) {
80
89
  this.ref.drawImageCubic(
81
- toValue(img),
90
+ JsiSkImage.fromValue(img),
82
91
  left,
83
92
  top,
84
93
  B,
85
94
  C,
86
- toOptionalValue(paint)
95
+ paint ? JsiSkPaint.fromValue(paint) : paint
87
96
  );
88
97
  }
89
98
 
@@ -96,12 +105,12 @@ export class JsiSkCanvas
96
105
  paint?: SkPaint | null
97
106
  ) {
98
107
  this.ref.drawImageOptions(
99
- toValue(img),
108
+ JsiSkImage.fromValue(img),
100
109
  left,
101
110
  top,
102
111
  ckEnum(fm),
103
112
  ckEnum(mm),
104
- toOptionalValue(paint)
113
+ paint ? JsiSkPaint.fromValue(paint) : paint
105
114
  );
106
115
  }
107
116
 
@@ -113,11 +122,11 @@ export class JsiSkCanvas
113
122
  paint?: SkPaint | null
114
123
  ) {
115
124
  this.ref.drawImageNine(
116
- toValue(img),
117
- toValue(center),
118
- toValue(dest),
125
+ JsiSkImage.fromValue(img),
126
+ Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),
127
+ JsiSkRect.fromValue(this.CanvasKit, dest),
119
128
  ckEnum(filter),
120
- toOptionalValue(paint)
129
+ paint ? JsiSkPaint.fromValue(paint) : paint
121
130
  );
122
131
  }
123
132
 
@@ -130,12 +139,12 @@ export class JsiSkCanvas
130
139
  paint?: SkPaint | null
131
140
  ) {
132
141
  this.ref.drawImageRectCubic(
133
- toValue<Image>(img),
142
+ JsiSkImage.fromValue(img),
134
143
  JsiSkRect.fromValue(this.CanvasKit, src),
135
144
  JsiSkRect.fromValue(this.CanvasKit, dest),
136
145
  B,
137
146
  C,
138
- toOptionalValue(paint)
147
+ paint ? JsiSkPaint.fromValue(paint) : paint
139
148
  );
140
149
  }
141
150
 
@@ -148,29 +157,33 @@ export class JsiSkCanvas
148
157
  paint?: SkPaint | null
149
158
  ) {
150
159
  this.ref.drawImageRectOptions(
151
- toValue<Image>(img),
160
+ JsiSkImage.fromValue(img),
152
161
  JsiSkRect.fromValue(this.CanvasKit, src),
153
162
  JsiSkRect.fromValue(this.CanvasKit, dest),
154
163
  ckEnum(fm),
155
164
  ckEnum(mm),
156
- toOptionalValue(paint)
165
+ paint ? JsiSkPaint.fromValue(paint) : paint
157
166
  );
158
167
  }
159
168
 
160
169
  drawPaint(paint: SkPaint) {
161
- this.ref.drawPaint(toValue(paint));
170
+ this.ref.drawPaint(JsiSkPaint.fromValue(paint));
162
171
  }
163
172
 
164
173
  drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {
165
- this.ref.drawLine(x0, y0, x1, y1, toValue(paint));
174
+ this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));
166
175
  }
167
176
 
168
177
  drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {
169
- this.ref.drawCircle(cx, cy, radius, toValue(paint));
178
+ this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));
170
179
  }
171
180
 
172
181
  drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {
173
- this.ref.drawVertices(toValue(verts), ckEnum(mode), toValue(paint));
182
+ this.ref.drawVertices(
183
+ JsiSkVertices.fromValue(verts),
184
+ ckEnum(mode),
185
+ JsiSkPaint.fromValue(paint)
186
+ );
174
187
  }
175
188
 
176
189
  drawPatch(
@@ -183,9 +196,9 @@ export class JsiSkCanvas
183
196
  this.ref.drawPatch(
184
197
  cubics.map(({ x, y }) => [x, y]).flat(),
185
198
  colors,
186
- toOptionalValue(texs),
199
+ texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,
187
200
  mode ? ckEnum(mode) : null,
188
- toUndefinedableValue(paint)
201
+ paint ? JsiSkPaint.fromValue(paint) : undefined
189
202
  );
190
203
  }
191
204
 
@@ -197,7 +210,7 @@ export class JsiSkCanvas
197
210
  this.ref.drawPoints(
198
211
  ckEnum(mode),
199
212
  points.map(({ x, y }) => [x, y]).flat(),
200
- toValue(paint)
213
+ JsiSkPaint.fromValue(paint)
201
214
  );
202
215
  }
203
216
 
@@ -209,39 +222,57 @@ export class JsiSkCanvas
209
222
  paint: SkPaint
210
223
  ) {
211
224
  this.ref.drawArc(
212
- toValue(oval),
225
+ JsiSkRect.fromValue(this.CanvasKit, oval),
213
226
  startAngle,
214
227
  sweepAngle,
215
228
  useCenter,
216
- toValue(paint)
229
+ JsiSkPaint.fromValue(paint)
217
230
  );
218
231
  }
219
232
 
220
233
  drawRRect(rrect: SkRRect, paint: SkPaint) {
221
234
  this.ref.drawRRect(
222
235
  JsiSkRRect.fromValue(this.CanvasKit, rrect),
223
- toValue(paint)
236
+ JsiSkPaint.fromValue(paint)
224
237
  );
225
238
  }
226
239
 
227
240
  drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint) {
228
- this.ref.drawDRRect(toValue(outer), toValue(inner), toValue(paint));
241
+ this.ref.drawDRRect(
242
+ JsiSkRRect.fromValue(this.CanvasKit, outer),
243
+ JsiSkRRect.fromValue(this.CanvasKit, inner),
244
+ JsiSkPaint.fromValue(paint)
245
+ );
229
246
  }
230
247
 
231
248
  drawOval(oval: SkRect, paint: SkPaint) {
232
- this.ref.drawOval(toValue(oval), toValue(paint));
249
+ this.ref.drawOval(
250
+ JsiSkRect.fromValue(this.CanvasKit, oval),
251
+ JsiSkPaint.fromValue(paint)
252
+ );
233
253
  }
234
254
 
235
255
  drawPath(path: SkPath, paint: SkPaint) {
236
- this.ref.drawPath(toValue(path), toValue(paint));
256
+ this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));
237
257
  }
238
258
 
239
259
  drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {
240
- this.ref.drawText(str, x, y, toValue(paint), toValue(font));
260
+ this.ref.drawText(
261
+ str,
262
+ x,
263
+ y,
264
+ JsiSkPaint.fromValue(paint),
265
+ JsiSkFont.fromValue(font)
266
+ );
241
267
  }
242
268
 
243
269
  drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {
244
- this.ref.drawTextBlob(toValue(blob), x, y, toValue(paint));
270
+ this.ref.drawTextBlob(
271
+ JsiSkTextBlob.fromValue(blob),
272
+ x,
273
+ y,
274
+ JsiSkPaint.fromValue(paint)
275
+ );
245
276
  }
246
277
 
247
278
  drawGlyphs(
@@ -257,8 +288,8 @@ export class JsiSkCanvas
257
288
  positions.map((p) => [p.x, p.y]).flat(),
258
289
  x,
259
290
  y,
260
- toValue(font),
261
- toValue(paint)
291
+ JsiSkFont.fromValue(font),
292
+ JsiSkPaint.fromValue(paint)
262
293
  );
263
294
  }
264
295
 
@@ -277,9 +308,9 @@ export class JsiSkCanvas
277
308
  flags?: SaveLayerFlag
278
309
  ) {
279
310
  return this.ref.saveLayer(
280
- toUndefinedableValue(paint),
281
- toOptionalValue(bounds),
282
- toOptionalValue(backdrop),
311
+ paint ? JsiSkPaint.fromValue(paint) : undefined,
312
+ bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,
313
+ backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,
283
314
  flags
284
315
  );
285
316
  }
@@ -313,7 +344,7 @@ export class JsiSkCanvas
313
344
  }
314
345
 
315
346
  clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {
316
- this.ref.clipPath(toValue(path), ckEnum(op), doAntiAlias);
347
+ this.ref.clipPath(JsiSkPath.fromValue(path), ckEnum(op), doAntiAlias);
317
348
  }
318
349
 
319
350
  clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {
@@ -333,10 +364,10 @@ export class JsiSkCanvas
333
364
  }
334
365
 
335
366
  concat(m: SkMatrix) {
336
- this.ref.concat(toValue(m));
367
+ this.ref.concat(JsiSkMatrix.fromValue(m));
337
368
  }
338
369
 
339
370
  drawPicture(skp: SkPicture) {
340
- this.ref.drawPicture(toValue(skp));
371
+ this.ref.drawPicture(JsiSkPicture.fromValue(skp));
341
372
  }
342
373
  }
@@ -8,7 +8,7 @@ import type {
8
8
  BlendMode,
9
9
  } from "../types";
10
10
 
11
- import { ckEnum, Host, toValue, NotImplementedOnRNWeb } from "./Host";
11
+ import { ckEnum, Host } from "./Host";
12
12
  import { JsiSkColorFilter } from "./JsiSkColorFilter";
13
13
 
14
14
  export class JsiSkColorFilterFactory
@@ -29,21 +29,28 @@ export class JsiSkColorFilterFactory
29
29
  MakeBlend(color: SkColor, mode: BlendMode) {
30
30
  return new JsiSkColorFilter(
31
31
  this.CanvasKit,
32
- this.CanvasKit.ColorFilter.MakeBlend(toValue(color), ckEnum(mode))
32
+ this.CanvasKit.ColorFilter.MakeBlend(color, ckEnum(mode))
33
33
  );
34
34
  }
35
35
 
36
36
  MakeCompose(outer: SkColorFilter, inner: SkColorFilter) {
37
37
  return new JsiSkColorFilter(
38
38
  this.CanvasKit,
39
- this.CanvasKit.ColorFilter.MakeCompose(toValue(outer), toValue(inner))
39
+ this.CanvasKit.ColorFilter.MakeCompose(
40
+ JsiSkColorFilter.fromValue(outer),
41
+ JsiSkColorFilter.fromValue(inner)
42
+ )
40
43
  );
41
44
  }
42
45
 
43
46
  MakeLerp(t: number, dst: SkColorFilter, src: SkColorFilter) {
44
47
  return new JsiSkColorFilter(
45
48
  this.CanvasKit,
46
- this.CanvasKit.ColorFilter.MakeLerp(t, toValue(dst), toValue(src))
49
+ this.CanvasKit.ColorFilter.MakeLerp(
50
+ t,
51
+ JsiSkColorFilter.fromValue(dst),
52
+ JsiSkColorFilter.fromValue(src)
53
+ )
47
54
  );
48
55
  }
49
56
 
@@ -62,6 +69,9 @@ export class JsiSkColorFilterFactory
62
69
  }
63
70
 
64
71
  MakeLumaColorFilter(): SkColorFilter {
65
- throw new NotImplementedOnRNWeb();
72
+ return new JsiSkColorFilter(
73
+ this.CanvasKit,
74
+ this.CanvasKit.ColorFilter.MakeLuma()
75
+ );
66
76
  }
67
77
  }
@@ -9,7 +9,9 @@ import type {
9
9
  SkTypeface,
10
10
  } from "../types";
11
11
 
12
- import { HostObject, toValue, ckEnum } from "./Host";
12
+ import { HostObject, ckEnum } from "./Host";
13
+ import { JsiSkPaint } from "./JsiSkPaint";
14
+ import { JsiSkPoint } from "./JsiSkPoint";
13
15
  import { JsiSkRect } from "./JsiSkRect";
14
16
  import { JsiSkTypeface } from "./JsiSkTypeface";
15
17
 
@@ -43,7 +45,12 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
43
45
 
44
46
  // TODO: Fix return value in the C++ implementation, it return float32
45
47
  getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {
46
- return [...this.ref.getGlyphWidths(glyphs, paint ? toValue(paint) : null)];
48
+ return [
49
+ ...this.ref.getGlyphWidths(
50
+ glyphs,
51
+ paint ? JsiSkPaint.fromValue(paint) : null
52
+ ),
53
+ ];
47
54
  }
48
55
 
49
56
  getGlyphIntercepts(
@@ -55,7 +62,7 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
55
62
  return [
56
63
  ...this.ref.getGlyphIntercepts(
57
64
  glyphs,
58
- positions.map((p) => toValue(p)),
65
+ positions.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),
59
66
  top,
60
67
  bottom
61
68
  ),
@@ -120,6 +127,6 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
120
127
  }
121
128
 
122
129
  setTypeface(face: SkTypeface | null) {
123
- this.ref.setTypeface(face ? toValue(face) : null);
130
+ this.ref.setTypeface(face ? JsiSkTypeface.fromValue(face) : null);
124
131
  }
125
132
  }
@@ -11,7 +11,8 @@ import type {
11
11
  TileMode,
12
12
  } from "../types";
13
13
 
14
- import { ckEnum, HostObject, toValue } from "./Host";
14
+ import { ckEnum, HostObject } from "./Host";
15
+ import { JsiSkMatrix } from "./JsiSkMatrix";
15
16
  import { JsiSkShader } from "./JsiSkShader";
16
17
 
17
18
  export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
@@ -41,7 +42,7 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
41
42
  ckEnum(ty),
42
43
  ckEnum(fm),
43
44
  ckEnum(mm),
44
- localMatrix ? toValue(localMatrix) : undefined
45
+ localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined
45
46
  )
46
47
  );
47
48
  }
@@ -60,7 +61,7 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
60
61
  ckEnum(ty),
61
62
  B,
62
63
  C,
63
- localMatrix ? toValue(localMatrix) : undefined
64
+ localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined
64
65
  )
65
66
  );
66
67
  }
@@ -3,8 +3,9 @@ import type { CanvasKit } from "canvaskit-wasm";
3
3
  import type { SkData, ImageInfo } from "../types";
4
4
  import type { ImageFactory } from "../types/Image/ImageFactory";
5
5
 
6
- import { Host, toValue, ckEnum } from "./Host";
6
+ import { Host, ckEnum } from "./Host";
7
7
  import { JsiSkImage } from "./JsiSkImage";
8
+ import { JsiSkData } from "./JsiSkData";
8
9
 
9
10
  export class JsiSkImageFactory extends Host implements ImageFactory {
10
11
  constructor(CanvasKit: CanvasKit) {
@@ -12,7 +13,9 @@ export class JsiSkImageFactory extends Host implements ImageFactory {
12
13
  }
13
14
 
14
15
  MakeImageFromEncoded(encoded: SkData) {
15
- const image = this.CanvasKit.MakeImageFromEncoded(toValue(encoded));
16
+ const image = this.CanvasKit.MakeImageFromEncoded(
17
+ JsiSkData.fromValue(encoded)
18
+ );
16
19
  if (image === null) {
17
20
  return null;
18
21
  }
@@ -29,7 +32,7 @@ export class JsiSkImageFactory extends Host implements ImageFactory {
29
32
  height: info.height,
30
33
  width: info.width,
31
34
  },
32
- toValue(data),
35
+ JsiSkData.fromValue(data),
33
36
  bytesPerRow
34
37
  );
35
38
  if (image === null) {
@@ -1,4 +1,4 @@
1
- import type { CanvasKit } from "canvaskit-wasm";
1
+ import type { CanvasKit, ImageFilter } from "canvaskit-wasm";
2
2
 
3
3
  import type {
4
4
  ColorChannel,
@@ -13,8 +13,9 @@ import type {
13
13
  TileMode,
14
14
  } from "../types";
15
15
 
16
- import { Host, NotImplementedOnRNWeb, ckEnum, toValue } from "./Host";
16
+ import { Host, NotImplementedOnRNWeb, ckEnum } from "./Host";
17
17
  import { JsiSkImageFilter } from "./JsiSkImageFilter";
18
+ import { JsiSkColorFilter } from "./JsiSkColorFilter";
18
19
 
19
20
  export class JsiSkImageFilterFactory
20
21
  extends Host
@@ -24,26 +25,37 @@ export class JsiSkImageFilterFactory
24
25
  super(CanvasKit);
25
26
  }
26
27
 
27
- MakeOffset(
28
- _dx: number,
29
- _dy: number,
30
- _input: SkImageFilter | null
31
- ): SkImageFilter {
32
- throw new NotImplementedOnRNWeb();
28
+ MakeOffset(dx: number, dy: number, input: SkImageFilter | null) {
29
+ const inputFilter =
30
+ input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
31
+ const filter = this.CanvasKit.ImageFilter.MakeOffset(dx, dy, inputFilter);
32
+ return new JsiSkImageFilter(this.CanvasKit, filter);
33
33
  }
34
34
 
35
35
  MakeDisplacementMap(
36
- _channelX: ColorChannel,
37
- _channelY: ColorChannel,
38
- _scale: number,
39
- _in1: SkImageFilter,
40
- _input: SkImageFilter | null
36
+ channelX: ColorChannel,
37
+ channelY: ColorChannel,
38
+ scale: number,
39
+ in1: SkImageFilter,
40
+ input: SkImageFilter | null
41
41
  ): SkImageFilter {
42
- throw new NotImplementedOnRNWeb();
42
+ const inputFilter =
43
+ input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
44
+ const filter = this.CanvasKit.ImageFilter.MakeDisplacementMap(
45
+ ckEnum(channelX),
46
+ ckEnum(channelY),
47
+ scale,
48
+ JsiSkImageFilter.fromValue(in1),
49
+ inputFilter
50
+ );
51
+ return new JsiSkImageFilter(this.CanvasKit, filter);
43
52
  }
44
53
 
45
- MakeShader(_shader: SkShader, _input: SkImageFilter | null): SkImageFilter {
46
- throw new NotImplementedOnRNWeb();
54
+ MakeShader(shader: SkShader, _input: SkImageFilter | null): SkImageFilter {
55
+ const filter = this.CanvasKit.ImageFilter.MakeShader(
56
+ JsiSkImageFilter.fromValue(shader)
57
+ );
58
+ return new JsiSkImageFilter(this.CanvasKit, filter);
47
59
  }
48
60
 
49
61
  MakeBlur(
@@ -58,7 +70,7 @@ export class JsiSkImageFilterFactory
58
70
  sigmaX,
59
71
  sigmaY,
60
72
  ckEnum(mode),
61
- input === null ? null : toValue(input)
73
+ input === null ? null : JsiSkImageFilter.fromValue(input)
62
74
  )
63
75
  );
64
76
  }
@@ -67,8 +79,8 @@ export class JsiSkImageFilterFactory
67
79
  return new JsiSkImageFilter(
68
80
  this.CanvasKit,
69
81
  this.CanvasKit.ImageFilter.MakeColorFilter(
70
- toValue(cf),
71
- input === null ? null : toValue(input)
82
+ JsiSkColorFilter.fromValue(cf),
83
+ input === null ? null : JsiSkImageFilter.fromValue(input)
72
84
  )
73
85
  );
74
86
  }
@@ -77,61 +89,121 @@ export class JsiSkImageFilterFactory
77
89
  return new JsiSkImageFilter(
78
90
  this.CanvasKit,
79
91
  this.CanvasKit.ImageFilter.MakeCompose(
80
- outer === null ? null : toValue(outer),
81
- inner === null ? null : toValue(inner)
92
+ outer === null ? null : JsiSkImageFilter.fromValue(outer),
93
+ inner === null ? null : JsiSkImageFilter.fromValue(inner)
82
94
  )
83
95
  );
84
96
  }
85
97
 
86
98
  MakeDropShadow(
87
- _dx: number,
88
- _dy: number,
89
- _sigmaX: number,
90
- _sigmaY: number,
91
- _color: SkColor,
92
- _input: SkImageFilter | null,
93
- _cropRect?: SkRect
99
+ dx: number,
100
+ dy: number,
101
+ sigmaX: number,
102
+ sigmaY: number,
103
+ color: SkColor,
104
+ input: SkImageFilter | null,
105
+ cropRect?: SkRect
94
106
  ): SkImageFilter {
95
- throw new NotImplementedOnRNWeb();
107
+ const inputFilter =
108
+ input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
109
+ if (cropRect) {
110
+ throw new NotImplementedOnRNWeb(
111
+ "The cropRect argument is not yet supported on React Native Web."
112
+ );
113
+ }
114
+ const filter = this.CanvasKit.ImageFilter.MakeDropShadow(
115
+ dx,
116
+ dy,
117
+ sigmaX,
118
+ sigmaY,
119
+ color,
120
+ inputFilter
121
+ );
122
+ return new JsiSkImageFilter(this.CanvasKit, filter);
96
123
  }
97
124
 
98
125
  MakeDropShadowOnly(
99
- _dx: number,
100
- _dy: number,
101
- _sigmaX: number,
102
- _sigmaY: number,
103
- _color: SkColor,
104
- _input: SkImageFilter | null,
105
- _cropRect?: SkRect
126
+ dx: number,
127
+ dy: number,
128
+ sigmaX: number,
129
+ sigmaY: number,
130
+ color: SkColor,
131
+ input: SkImageFilter | null,
132
+ cropRect?: SkRect
106
133
  ): SkImageFilter {
107
- throw new NotImplementedOnRNWeb();
134
+ const inputFilter =
135
+ input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
136
+ if (cropRect) {
137
+ throw new NotImplementedOnRNWeb(
138
+ "The cropRect argument is not yet supported on React Native Web."
139
+ );
140
+ }
141
+ const filter = this.CanvasKit.ImageFilter.MakeDropShadowOnly(
142
+ dx,
143
+ dy,
144
+ sigmaX,
145
+ sigmaY,
146
+ color,
147
+ inputFilter
148
+ );
149
+ return new JsiSkImageFilter(this.CanvasKit, filter);
108
150
  }
109
151
 
110
152
  MakeErode(
111
- _rx: number,
112
- _ry: number,
113
- _input: SkImageFilter | null,
114
- _cropRect?: SkRect
153
+ rx: number,
154
+ ry: number,
155
+ input: SkImageFilter | null,
156
+ cropRect?: SkRect
115
157
  ): SkImageFilter {
116
- throw new NotImplementedOnRNWeb();
158
+ const inputFilter =
159
+ input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
160
+ if (cropRect) {
161
+ throw new NotImplementedOnRNWeb(
162
+ "The cropRect argument is not yet supported on React Native Web."
163
+ );
164
+ }
165
+ const filter = this.CanvasKit.ImageFilter.MakeErode(rx, ry, inputFilter);
166
+ return new JsiSkImageFilter(this.CanvasKit, filter);
117
167
  }
118
168
 
119
169
  MakeDilate(
120
- _rx: number,
121
- _ry: number,
122
- _input: SkImageFilter | null,
123
- _cropRect?: SkRect
170
+ rx: number,
171
+ ry: number,
172
+ input: SkImageFilter | null,
173
+ cropRect?: SkRect
124
174
  ): SkImageFilter {
125
- throw new NotImplementedOnRNWeb();
175
+ const inputFilter =
176
+ input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
177
+ if (cropRect) {
178
+ throw new NotImplementedOnRNWeb(
179
+ "The cropRect argument is not yet supported on React Native Web."
180
+ );
181
+ }
182
+ const filter = this.CanvasKit.ImageFilter.MakeDilate(rx, ry, inputFilter);
183
+ return new JsiSkImageFilter(this.CanvasKit, filter);
126
184
  }
127
185
 
128
186
  MakeBlend(
129
- _mode: BlendMode,
130
- _background: SkImageFilter,
131
- _foreground: SkImageFilter | null,
132
- _cropRect?: SkRect
187
+ mode: BlendMode,
188
+ background: SkImageFilter,
189
+ foreground: SkImageFilter | null,
190
+ cropRect?: SkRect
133
191
  ): SkImageFilter {
134
- throw new NotImplementedOnRNWeb();
192
+ const inputFilter =
193
+ foreground === null
194
+ ? null
195
+ : JsiSkImageFilter.fromValue<ImageFilter>(foreground);
196
+ if (cropRect) {
197
+ throw new NotImplementedOnRNWeb(
198
+ "The cropRect argument is not yet supported on React Native Web."
199
+ );
200
+ }
201
+ const filter = this.CanvasKit.ImageFilter.MakeBlend(
202
+ ckEnum(mode),
203
+ JsiSkImageFilter.fromValue(background),
204
+ inputFilter
205
+ );
206
+ return new JsiSkImageFilter(this.CanvasKit, filter);
135
207
  }
136
208
 
137
209
  MakeRuntimeShader(