@shopify/react-native-skia 2.5.4 → 2.6.0

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 (178) hide show
  1. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +7 -7
  2. package/apple/{WebGPUView.h → SkiaWebGPUView.h} +1 -1
  3. package/apple/{WebGPUView.mm → SkiaWebGPUView.mm} +7 -7
  4. package/cpp/api/CustomBlendModes.h +1 -0
  5. package/cpp/api/JsiSkApi.h +4 -0
  6. package/cpp/api/JsiSkCanvas.h +2 -2
  7. package/cpp/api/JsiSkContourMeasureIter.h +1 -1
  8. package/cpp/api/JsiSkPath.h +483 -355
  9. package/cpp/api/JsiSkPathBuilder.h +415 -0
  10. package/cpp/api/JsiSkPathBuilderFactory.h +53 -0
  11. package/cpp/api/JsiSkPathEffectFactory.h +2 -2
  12. package/cpp/api/JsiSkPathFactory.h +274 -3
  13. package/cpp/api/recorder/DataTypes.h +1 -1
  14. package/cpp/api/recorder/Drawings.h +6 -2
  15. package/cpp/rnskia/RNDawnContext.h +21 -0
  16. package/cpp/rnskia/RNDawnUtils.h +115 -113
  17. package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  18. package/lib/commonjs/animation/functions/interpolatePaths.js +5 -4
  19. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  20. package/lib/commonjs/external/reanimated/interpolators.d.ts +11 -2
  21. package/lib/commonjs/external/reanimated/interpolators.js +21 -4
  22. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  23. package/lib/commonjs/skia/types/Path/PathBuilder.d.ts +201 -0
  24. package/lib/commonjs/skia/types/Path/PathBuilder.js +6 -0
  25. package/lib/commonjs/skia/types/Path/PathBuilder.js.map +1 -0
  26. package/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  27. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js +6 -0
  28. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js.map +1 -0
  29. package/lib/commonjs/skia/types/Path/PathFactory.d.ts +87 -1
  30. package/lib/commonjs/skia/types/Path/PathFactory.js.map +1 -1
  31. package/lib/commonjs/skia/types/Path/index.d.ts +2 -0
  32. package/lib/commonjs/skia/types/Path/index.js +22 -0
  33. package/lib/commonjs/skia/types/Path/index.js.map +1 -1
  34. package/lib/commonjs/skia/types/Skia.d.ts +2 -1
  35. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  36. package/lib/commonjs/skia/web/Host.js +1 -3
  37. package/lib/commonjs/skia/web/Host.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkCanvas.js +6 -2
  39. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -1
  41. package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkPath.d.ts +42 -30
  43. package/lib/commonjs/skia/web/JsiSkPath.js +302 -111
  44. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  45. package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +45 -0
  46. package/lib/commonjs/skia/web/JsiSkPathBuilder.js +192 -0
  47. package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -0
  48. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  49. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js +26 -0
  50. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  51. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +6 -2
  52. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  53. package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +13 -1
  54. package/lib/commonjs/skia/web/JsiSkPathFactory.js +140 -5
  55. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  56. package/lib/commonjs/skia/web/JsiSkia.js +8 -1
  57. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  58. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +18 -6
  59. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  60. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  61. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -3
  62. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  63. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -2
  64. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +2 -3
  65. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -1
  66. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +2 -0
  67. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  68. package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  69. package/lib/module/animation/functions/interpolatePaths.js +5 -4
  70. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  71. package/lib/module/external/reanimated/interpolators.d.ts +11 -2
  72. package/lib/module/external/reanimated/interpolators.js +21 -4
  73. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  74. package/lib/module/skia/types/Path/PathBuilder.d.ts +201 -0
  75. package/lib/module/skia/types/Path/PathBuilder.js +2 -0
  76. package/lib/module/skia/types/Path/PathBuilder.js.map +1 -0
  77. package/lib/module/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  78. package/lib/module/skia/types/Path/PathBuilderFactory.js +2 -0
  79. package/lib/module/skia/types/Path/PathBuilderFactory.js.map +1 -0
  80. package/lib/module/skia/types/Path/PathFactory.d.ts +87 -1
  81. package/lib/module/skia/types/Path/PathFactory.js.map +1 -1
  82. package/lib/module/skia/types/Path/index.d.ts +2 -0
  83. package/lib/module/skia/types/Path/index.js +2 -0
  84. package/lib/module/skia/types/Path/index.js.map +1 -1
  85. package/lib/module/skia/types/Skia.d.ts +2 -1
  86. package/lib/module/skia/types/Skia.js.map +1 -1
  87. package/lib/module/skia/web/Host.js +1 -3
  88. package/lib/module/skia/web/Host.js.map +1 -1
  89. package/lib/module/skia/web/JsiSkCanvas.js +6 -2
  90. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  91. package/lib/module/skia/web/JsiSkContourMeasure.js +4 -1
  92. package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
  93. package/lib/module/skia/web/JsiSkPath.d.ts +42 -30
  94. package/lib/module/skia/web/JsiSkPath.js +300 -110
  95. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  96. package/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  97. package/lib/module/skia/web/JsiSkPathBuilder.js +186 -0
  98. package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -0
  99. package/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  100. package/lib/module/skia/web/JsiSkPathBuilderFactory.js +19 -0
  101. package/lib/module/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  102. package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -2
  103. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  104. package/lib/module/skia/web/JsiSkPathFactory.d.ts +13 -1
  105. package/lib/module/skia/web/JsiSkPathFactory.js +141 -6
  106. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  107. package/lib/module/skia/web/JsiSkia.js +8 -1
  108. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  109. package/lib/module/sksg/Recorder/commands/Drawing.js +18 -6
  110. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  111. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  112. package/lib/module/specs/SkiaPictureViewNativeComponent.js +1 -1
  113. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  114. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -2
  115. package/lib/module/specs/WebGPUViewNativeComponent.js +2 -2
  116. package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -1
  117. package/lib/module/specs/WebGPUViewNativeComponent.web.js +2 -0
  118. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  119. package/lib/typescript/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  120. package/lib/typescript/lib/commonjs/external/reanimated/interpolators.d.ts +1 -1
  121. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilder.d.ts +1 -0
  122. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  123. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +33 -25
  124. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +46 -0
  125. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +7 -0
  126. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +12 -0
  127. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  128. package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -1
  129. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -1
  130. package/lib/typescript/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  131. package/lib/typescript/lib/module/external/reanimated/interpolators.d.ts +1 -1
  132. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  133. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
  134. package/lib/typescript/lib/module/skia/types/Path/PathBuilder.d.ts +1 -0
  135. package/lib/typescript/lib/module/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  136. package/lib/typescript/lib/module/skia/types/Path/index.d.ts +2 -0
  137. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +38 -25
  138. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  139. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +6 -0
  140. package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +12 -0
  141. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  142. package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -1
  143. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +1 -1
  144. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
  145. package/lib/typescript/src/external/reanimated/interpolators.d.ts +11 -2
  146. package/lib/typescript/src/skia/types/Path/PathBuilder.d.ts +201 -0
  147. package/lib/typescript/src/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  148. package/lib/typescript/src/skia/types/Path/PathFactory.d.ts +87 -1
  149. package/lib/typescript/src/skia/types/Path/index.d.ts +2 -0
  150. package/lib/typescript/src/skia/types/Skia.d.ts +2 -1
  151. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +42 -30
  152. package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +45 -0
  153. package/lib/typescript/src/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  154. package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +13 -1
  155. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  156. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +2 -2
  157. package/package.json +4 -3
  158. package/scripts/install-libs.js +16 -6
  159. package/src/animation/functions/interpolatePaths.ts +5 -6
  160. package/src/external/reanimated/interpolators.ts +25 -5
  161. package/src/skia/types/Path/PathBuilder.ts +303 -0
  162. package/src/skia/types/Path/PathBuilderFactory.ts +15 -0
  163. package/src/skia/types/Path/PathFactory.ts +108 -1
  164. package/src/skia/types/Path/index.ts +2 -0
  165. package/src/skia/types/Skia.ts +2 -1
  166. package/src/skia/web/Host.ts +7 -1
  167. package/src/skia/web/JsiSkCanvas.ts +6 -6
  168. package/src/skia/web/JsiSkContourMeasure.ts +4 -4
  169. package/src/skia/web/JsiSkPath.ts +451 -168
  170. package/src/skia/web/JsiSkPathBuilder.ts +293 -0
  171. package/src/skia/web/JsiSkPathBuilderFactory.ts +32 -0
  172. package/src/skia/web/JsiSkPathEffectFactory.ts +6 -2
  173. package/src/skia/web/JsiSkPathFactory.ts +231 -8
  174. package/src/skia/web/JsiSkia.ts +11 -8
  175. package/src/sksg/Recorder/commands/Drawing.ts +20 -7
  176. package/src/specs/SkiaPictureViewNativeComponent.ts +1 -2
  177. package/src/specs/WebGPUViewNativeComponent.ts +3 -3
  178. package/src/specs/WebGPUViewNativeComponent.web.ts +2 -0
@@ -1,4 +1,4 @@
1
- import type { CanvasKit, Matrix3x3, Path } from "canvaskit-wasm";
1
+ import type { CanvasKit, PathBuilder as CKPathBuilder } from "canvaskit-wasm";
2
2
 
3
3
  import { PathVerb } from "../types";
4
4
  import type {
@@ -29,20 +29,84 @@ const CommandCount = {
29
29
  [PathVerb.Close]: 1,
30
30
  };
31
31
 
32
- const pinT = (t: number) => Math.min(Math.max(t, 0), 1);
32
+ // Track which deprecation warnings have been shown to avoid spam
33
+ const shownDeprecationWarnings = new Set<string>();
33
34
 
34
- export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
35
- constructor(CanvasKit: CanvasKit, ref: Path) {
35
+ const warnDeprecatedPathMethod = (
36
+ methodName: string,
37
+ suggestion: string
38
+ ): void => {
39
+ if (shownDeprecationWarnings.has(methodName)) {
40
+ return;
41
+ }
42
+ shownDeprecationWarnings.add(methodName);
43
+ console.warn(
44
+ `[react-native-skia] SkPath.${methodName}() is deprecated and will be removed in a future release. ${suggestion} See migration guide: https://shopify.github.io/react-native-skia/docs/shapes/path-migration`
45
+ );
46
+ };
47
+
48
+ export const toMatrix3x3 = (m: InputMatrix): number[] => {
49
+ let matrix =
50
+ m instanceof JsiSkMatrix
51
+ ? Array.from(JsiSkMatrix.fromValue<Float32Array>(m))
52
+ : (m as Exclude<InputMatrix, SkMatrix>);
53
+ if (matrix.length === 16) {
54
+ matrix = [
55
+ matrix[0],
56
+ matrix[1],
57
+ matrix[3],
58
+ matrix[4],
59
+ matrix[5],
60
+ matrix[7],
61
+ matrix[12],
62
+ matrix[13],
63
+ matrix[15],
64
+ ];
65
+ } else if (matrix.length !== 9) {
66
+ throw new Error(`Invalid matrix length: ${matrix.length}`);
67
+ }
68
+ return matrix as number[];
69
+ };
70
+
71
+ /**
72
+ * SkPath wraps a CK PathBuilder internally, providing both mutable building
73
+ * methods and immutable query methods. Use snapshot() internally to get
74
+ * an immutable CK Path for read-only operations.
75
+ */
76
+ export class JsiSkPath
77
+ extends HostObject<CKPathBuilder, "Path">
78
+ implements SkPath
79
+ {
80
+ constructor(CanvasKit: CanvasKit, ref: CKPathBuilder) {
36
81
  super(CanvasKit, ref, "Path");
37
82
  }
38
83
 
84
+ /** Returns an immutable CK Path snapshot for read-only operations. */
85
+ private asPath() {
86
+ return this.ref.snapshot();
87
+ }
88
+
89
+ /** Extract an immutable CK Path from a JsiSkPath value (for CK interop). */
90
+ static pathFromValue(value: SkPath) {
91
+ return JsiSkPath.fromValue<CKPathBuilder>(value).snapshot();
92
+ }
93
+
94
+ // ---- Mutable building methods (deprecated) ----
95
+
39
96
  addPath(src: SkPath, matrix?: SkMatrix, extend = false) {
97
+ warnDeprecatedPathMethod(
98
+ "addPath",
99
+ "Use Skia.PathBuilder.Make().addPath() instead."
100
+ );
101
+ const srcBuilder = JsiSkPath.fromValue<CKPathBuilder>(src);
102
+ const srcPath = srcBuilder.snapshot();
40
103
  const args = [
41
- JsiSkPath.fromValue(src),
104
+ srcPath,
42
105
  ...(matrix ? JsiSkMatrix.fromValue<Float32Array>(matrix) : []),
43
106
  extend,
44
107
  ];
45
108
  this.ref.addPath(...args);
109
+ srcPath.delete();
46
110
  return this;
47
111
  }
48
112
 
@@ -51,6 +115,10 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
51
115
  startAngleInDegrees: number,
52
116
  sweepAngleInDegrees: number
53
117
  ) {
118
+ warnDeprecatedPathMethod(
119
+ "addArc",
120
+ "Use Skia.PathBuilder.Make().addArc() instead."
121
+ );
54
122
  this.ref.addArc(
55
123
  JsiSkRect.fromValue(this.CanvasKit, oval),
56
124
  startAngleInDegrees,
@@ -60,6 +128,10 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
60
128
  }
61
129
 
62
130
  addOval(oval: SkRect, isCCW?: boolean, startIndex?: number) {
131
+ warnDeprecatedPathMethod(
132
+ "addOval",
133
+ "Use Skia.Path.Oval() or Skia.PathBuilder.Make().addOval() instead."
134
+ );
63
135
  this.ref.addOval(
64
136
  JsiSkRect.fromValue(this.CanvasKit, oval),
65
137
  isCCW,
@@ -68,126 +140,183 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
68
140
  return this;
69
141
  }
70
142
 
71
- countPoints() {
72
- return this.ref.countPoints();
73
- }
74
-
75
143
  addPoly(points: SkPoint[], close: boolean) {
76
- this.ref.addPoly(
144
+ warnDeprecatedPathMethod(
145
+ "addPoly",
146
+ "Use Skia.Path.Polygon() or Skia.PathBuilder.Make().addPoly() instead."
147
+ );
148
+ this.ref.addPolygon(
77
149
  points.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),
78
150
  close
79
151
  );
80
152
  return this;
81
153
  }
82
154
 
83
- moveTo(x: number, y: number) {
84
- this.ref.moveTo(x, y);
155
+ addRect(rect: SkRect, isCCW?: boolean) {
156
+ warnDeprecatedPathMethod(
157
+ "addRect",
158
+ "Use Skia.Path.Rect() or Skia.PathBuilder.Make().addRect() instead."
159
+ );
160
+ this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);
85
161
  return this;
86
162
  }
87
163
 
88
- lineTo(x: number, y: number) {
89
- this.ref.lineTo(x, y);
164
+ addRRect(rrect: InputRRect, isCCW?: boolean) {
165
+ warnDeprecatedPathMethod(
166
+ "addRRect",
167
+ "Use Skia.Path.RRect() or Skia.PathBuilder.Make().addRRect() instead."
168
+ );
169
+ this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);
90
170
  return this;
91
171
  }
92
172
 
93
- makeAsWinding() {
94
- const result = this.ref.makeAsWinding();
95
- return result === null ? result : this;
96
- }
97
-
98
- offset(dx: number, dy: number) {
99
- this.ref.offset(dx, dy);
173
+ addCircle(x: number, y: number, r: number) {
174
+ warnDeprecatedPathMethod(
175
+ "addCircle",
176
+ "Use Skia.Path.Circle() or Skia.PathBuilder.Make().addCircle() instead."
177
+ );
178
+ this.ref.addCircle(x, y, r);
100
179
  return this;
101
180
  }
102
181
 
103
- rArcTo(
104
- rx: number,
105
- ry: number,
106
- xAxisRotateInDegrees: number,
107
- useSmallArc: boolean,
108
- isCCW: boolean,
109
- dx: number,
110
- dy: number
111
- ) {
112
- this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);
182
+ moveTo(x: number, y: number) {
183
+ warnDeprecatedPathMethod(
184
+ "moveTo",
185
+ "Use Skia.PathBuilder.Make().moveTo() instead."
186
+ );
187
+ this.ref.moveTo(x, y);
113
188
  return this;
114
189
  }
115
190
 
116
- rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number) {
117
- this.ref.rConicTo(dx1, dy1, dx2, dy2, w);
191
+ rMoveTo(x: number, y: number) {
192
+ warnDeprecatedPathMethod(
193
+ "rMoveTo",
194
+ "Use Skia.PathBuilder.Make().rMoveTo() instead."
195
+ );
196
+ this.ref.rMoveTo(x, y);
118
197
  return this;
119
198
  }
120
199
 
121
- rCubicTo(
122
- cpx1: number,
123
- cpy1: number,
124
- cpx2: number,
125
- cpy2: number,
126
- x: number,
127
- y: number
128
- ) {
129
- this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
200
+ lineTo(x: number, y: number) {
201
+ warnDeprecatedPathMethod(
202
+ "lineTo",
203
+ "Use Skia.PathBuilder.Make().lineTo() instead."
204
+ );
205
+ this.ref.lineTo(x, y);
130
206
  return this;
131
207
  }
132
208
 
133
- rMoveTo(x: number, y: number) {
134
- this.ref.rMoveTo(x, y);
209
+ rLineTo(x: number, y: number) {
210
+ warnDeprecatedPathMethod(
211
+ "rLineTo",
212
+ "Use Skia.PathBuilder.Make().rLineTo() instead."
213
+ );
214
+ this.ref.rLineTo(x, y);
135
215
  return this;
136
216
  }
137
217
 
138
- rLineTo(x: number, y: number) {
139
- this.ref.rLineTo(x, y);
218
+ quadTo(x1: number, y1: number, x2: number, y2: number) {
219
+ warnDeprecatedPathMethod(
220
+ "quadTo",
221
+ "Use Skia.PathBuilder.Make().quadTo() instead."
222
+ );
223
+ this.ref.quadTo(x1, y1, x2, y2);
140
224
  return this;
141
225
  }
142
226
 
143
227
  rQuadTo(x1: number, y1: number, x2: number, y2: number) {
228
+ warnDeprecatedPathMethod(
229
+ "rQuadTo",
230
+ "Use Skia.PathBuilder.Make().rQuadTo() instead."
231
+ );
144
232
  this.ref.rQuadTo(x1, y1, x2, y2);
145
233
  return this;
146
234
  }
147
235
 
148
- setFillType(fill: FillType) {
149
- this.ref.setFillType(getEnum(this.CanvasKit, "FillType", fill));
236
+ conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {
237
+ warnDeprecatedPathMethod(
238
+ "conicTo",
239
+ "Use Skia.PathBuilder.Make().conicTo() instead."
240
+ );
241
+ this.ref.conicTo(x1, y1, x2, y2, w);
150
242
  return this;
151
243
  }
152
244
 
153
- setIsVolatile(volatile: boolean) {
154
- this.ref.setIsVolatile(volatile);
245
+ rConicTo(x1: number, y1: number, x2: number, y2: number, w: number) {
246
+ warnDeprecatedPathMethod(
247
+ "rConicTo",
248
+ "Use Skia.PathBuilder.Make().rConicTo() instead."
249
+ );
250
+ this.ref.rConicTo(x1, y1, x2, y2, w);
155
251
  return this;
156
252
  }
157
253
 
158
- stroke(opts?: StrokeOpts) {
159
- const result = this.ref.stroke(
160
- opts === undefined
161
- ? undefined
162
- : {
163
- width: opts.width,
164
- // eslint-disable-next-line camelcase
165
- miter_limit: opts.width,
166
- precision: opts.width,
167
- join: optEnum(this.CanvasKit, "StrokeJoin", opts.join),
168
- cap: optEnum(this.CanvasKit, "StrokeCap", opts.cap),
169
- }
254
+ cubicTo(
255
+ cpx1: number,
256
+ cpy1: number,
257
+ cpx2: number,
258
+ cpy2: number,
259
+ x: number,
260
+ y: number
261
+ ) {
262
+ warnDeprecatedPathMethod(
263
+ "cubicTo",
264
+ "Use Skia.PathBuilder.Make().cubicTo() instead."
170
265
  );
171
- return result === null ? result : this;
266
+ this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
267
+ return this;
268
+ }
269
+
270
+ rCubicTo(
271
+ cpx1: number,
272
+ cpy1: number,
273
+ cpx2: number,
274
+ cpy2: number,
275
+ x: number,
276
+ y: number
277
+ ) {
278
+ warnDeprecatedPathMethod(
279
+ "rCubicTo",
280
+ "Use Skia.PathBuilder.Make().rCubicTo() instead."
281
+ );
282
+ this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
283
+ return this;
172
284
  }
173
285
 
174
286
  close() {
287
+ warnDeprecatedPathMethod(
288
+ "close",
289
+ "Use Skia.PathBuilder.Make().close() instead."
290
+ );
175
291
  this.ref.close();
176
292
  return this;
177
293
  }
178
294
 
179
295
  reset() {
180
- this.ref.reset();
296
+ warnDeprecatedPathMethod(
297
+ "reset",
298
+ "Use Skia.PathBuilder.Make().reset() instead."
299
+ );
300
+ // CK PathBuilder has no reset — recreate
301
+ const newBuilder = new this.CanvasKit.PathBuilder();
302
+ if (
303
+ this.ref !== null &&
304
+ typeof this.ref === "object" &&
305
+ "delete" in this.ref &&
306
+ typeof this.ref.delete === "function"
307
+ ) {
308
+ this.ref.delete();
309
+ }
310
+ this.ref = newBuilder;
181
311
  return this;
182
312
  }
183
313
 
184
314
  rewind() {
185
- this.ref.rewind();
186
- return this;
187
- }
188
-
189
- computeTightBounds(): SkRect {
190
- return new JsiSkRect(this.CanvasKit, this.ref.computeTightBounds());
315
+ warnDeprecatedPathMethod(
316
+ "rewind",
317
+ "Use Skia.PathBuilder.Make().reset() instead."
318
+ );
319
+ return this.reset();
191
320
  }
192
321
 
193
322
  arcToOval(
@@ -196,6 +325,10 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
196
325
  sweepAngleInDegrees: number,
197
326
  forceMoveTo: boolean
198
327
  ) {
328
+ warnDeprecatedPathMethod(
329
+ "arcToOval",
330
+ "Use Skia.PathBuilder.Make().arcToOval() instead."
331
+ );
199
332
  this.ref.arcToOval(
200
333
  JsiSkRect.fromValue(this.CanvasKit, oval),
201
334
  startAngleInDegrees,
@@ -214,6 +347,10 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
214
347
  x: number,
215
348
  y: number
216
349
  ) {
350
+ warnDeprecatedPathMethod(
351
+ "arcToRotated",
352
+ "Use Skia.PathBuilder.Make().arcToRotated() instead."
353
+ );
217
354
  this.ref.arcToRotated(
218
355
  rx,
219
356
  ry,
@@ -226,166 +363,312 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
226
363
  return this;
227
364
  }
228
365
 
366
+ rArcTo(
367
+ rx: number,
368
+ ry: number,
369
+ xAxisRotateInDegrees: number,
370
+ useSmallArc: boolean,
371
+ isCCW: boolean,
372
+ dx: number,
373
+ dy: number
374
+ ) {
375
+ warnDeprecatedPathMethod(
376
+ "rArcTo",
377
+ "Use Skia.PathBuilder.Make().rArcTo() instead."
378
+ );
379
+ this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);
380
+ return this;
381
+ }
382
+
229
383
  arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number) {
384
+ warnDeprecatedPathMethod(
385
+ "arcToTangent",
386
+ "Use Skia.PathBuilder.Make().arcToTangent() instead."
387
+ );
230
388
  this.ref.arcToTangent(x1, y1, x2, y2, radius);
231
389
  return this;
232
390
  }
233
391
 
234
- conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {
235
- this.ref.conicTo(x1, y1, x2, y2, w);
392
+ setFillType(fill: FillType) {
393
+ warnDeprecatedPathMethod(
394
+ "setFillType",
395
+ "Use Skia.PathBuilder.Make().setFillType() instead."
396
+ );
397
+ this.ref.setFillType(getEnum(this.CanvasKit, "FillType", fill));
236
398
  return this;
237
399
  }
238
400
 
239
- contains(x: number, y: number) {
240
- return this.ref.contains(x, y);
401
+ setIsVolatile(_volatile: boolean) {
402
+ warnDeprecatedPathMethod(
403
+ "setIsVolatile",
404
+ "Use Skia.PathBuilder.Make().setIsVolatile() instead."
405
+ );
406
+ // Not supported in CK PathBuilder — no-op
407
+ return this;
241
408
  }
242
409
 
243
- copy() {
244
- return new JsiSkPath(this.CanvasKit, this.ref.copy());
245
- }
410
+ // ---- Mutable path operations (deprecated) ----
246
411
 
247
- cubicTo(
248
- cpx1: number,
249
- cpy1: number,
250
- cpx2: number,
251
- cpy2: number,
252
- x: number,
253
- y: number
254
- ) {
255
- this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
412
+ offset(dx: number, dy: number) {
413
+ warnDeprecatedPathMethod(
414
+ "offset",
415
+ "Use Skia.PathBuilder.Make().offset() instead."
416
+ );
417
+ this.ref.offset(dx, dy);
256
418
  return this;
257
419
  }
258
420
 
259
- dash(on: number, off: number, phase: number) {
260
- return this.ref.dash(on, off, phase);
421
+ transform(m: InputMatrix) {
422
+ warnDeprecatedPathMethod(
423
+ "transform",
424
+ "Use Skia.PathBuilder.Make().transform() instead."
425
+ );
426
+ const matrix = toMatrix3x3(m);
427
+ this.ref.transform(matrix);
428
+ return this;
261
429
  }
262
430
 
263
- equals(other: SkPath) {
264
- return this.ref.equals(JsiSkPath.fromValue(other));
431
+ makeAsWinding() {
432
+ warnDeprecatedPathMethod(
433
+ "makeAsWinding",
434
+ "Use Skia.Path.AsWinding(path) instead."
435
+ );
436
+ const path = this.asPath();
437
+ const result = path.makeAsWinding();
438
+ path.delete();
439
+ if (result === null) {
440
+ return null;
441
+ }
442
+ const old = this.ref;
443
+ this.ref = new this.CanvasKit.PathBuilder(result);
444
+ result.delete();
445
+ old.delete();
446
+ return this;
265
447
  }
266
448
 
267
- getBounds() {
268
- return new JsiSkRect(this.CanvasKit, this.ref.getBounds());
449
+ simplify() {
450
+ warnDeprecatedPathMethod("simplify", "Use Skia.Path.Simplify(path) instead.");
451
+ const path = this.asPath();
452
+ const result = path.makeSimplified();
453
+ path.delete();
454
+ if (result === null) {
455
+ return false;
456
+ }
457
+ const old = this.ref;
458
+ this.ref = new this.CanvasKit.PathBuilder(result);
459
+ result.delete();
460
+ old.delete();
461
+ return true;
269
462
  }
270
463
 
271
- getFillType() {
272
- return this.ref.getFillType().value;
464
+ op(path: SkPath, op: PathOp) {
465
+ warnDeprecatedPathMethod("op", "Use Skia.Path.MakeFromOp() instead.");
466
+ const self = this.asPath();
467
+ const other = JsiSkPath.fromValue<CKPathBuilder>(path).snapshot();
468
+ const result = self.makeCombined(
469
+ other,
470
+ getEnum(this.CanvasKit, "PathOp", op)
471
+ );
472
+ self.delete();
473
+ other.delete();
474
+ if (result === null) {
475
+ return false;
476
+ }
477
+ const old = this.ref;
478
+ this.ref = new this.CanvasKit.PathBuilder(result);
479
+ result.delete();
480
+ old.delete();
481
+ return true;
273
482
  }
274
483
 
275
- quadTo(x1: number, y1: number, x2: number, y2: number) {
276
- this.ref.quadTo(x1, y1, x2, y2);
277
- return this;
484
+ dash(on: number, off: number, phase: number) {
485
+ warnDeprecatedPathMethod(
486
+ "dash",
487
+ "Use Skia.Path.Dash(path, on, off, phase) instead."
488
+ );
489
+ const path = this.asPath();
490
+ const result = path.makeDashed(on, off, phase);
491
+ path.delete();
492
+ if (result === null) {
493
+ return false;
494
+ }
495
+ const old = this.ref;
496
+ this.ref = new this.CanvasKit.PathBuilder(result);
497
+ result.delete();
498
+ old.delete();
499
+ return true;
278
500
  }
279
501
 
280
- addRect(rect: SkRect, isCCW?: boolean) {
281
- this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);
502
+ stroke(opts?: StrokeOpts) {
503
+ warnDeprecatedPathMethod("stroke", "Use Skia.Path.Stroke(path, opts) instead.");
504
+ const path = this.asPath();
505
+ const result = path.makeStroked(
506
+ opts === undefined
507
+ ? undefined
508
+ : {
509
+ width: opts.width,
510
+ // eslint-disable-next-line camelcase
511
+ miter_limit: opts.miter_limit,
512
+ precision: opts.precision,
513
+ join: optEnum(this.CanvasKit, "StrokeJoin", opts.join),
514
+ cap: optEnum(this.CanvasKit, "StrokeCap", opts.cap),
515
+ }
516
+ );
517
+ path.delete();
518
+ if (result === null) {
519
+ return null;
520
+ }
521
+ const old = this.ref;
522
+ this.ref = new this.CanvasKit.PathBuilder(result);
523
+ result.delete();
524
+ old.delete();
282
525
  return this;
283
526
  }
284
527
 
285
- addRRect(rrect: InputRRect, isCCW?: boolean) {
286
- this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);
528
+ trim(start: number, stop: number, isComplement: boolean) {
529
+ warnDeprecatedPathMethod(
530
+ "trim",
531
+ "Use Skia.Path.Trim(path, start, end, isComplement) instead."
532
+ );
533
+ const startT = Math.min(Math.max(start, 0), 1);
534
+ const stopT = Math.min(Math.max(stop, 0), 1);
535
+ if (startT === 0 && stopT === 1 && !isComplement) {
536
+ return this;
537
+ }
538
+ const path = this.asPath();
539
+ const result = path.makeTrimmed(startT, stopT, isComplement);
540
+ path.delete();
541
+ if (result === null) {
542
+ return null;
543
+ }
544
+ const old = this.ref;
545
+ this.ref = new this.CanvasKit.PathBuilder(result);
546
+ result.delete();
547
+ old.delete();
287
548
  return this;
288
549
  }
289
550
 
290
- getPoint(index: number) {
291
- return new JsiSkPoint(this.CanvasKit, this.ref.getPoint(index));
292
- }
551
+ // ---- Query methods (use snapshot for read-only) ----
293
552
 
294
- isEmpty() {
295
- return this.ref.isEmpty();
553
+ countPoints() {
554
+ return this.ref.countPoints();
296
555
  }
297
556
 
298
- isVolatile() {
299
- return this.ref.isVolatile();
557
+ computeTightBounds(): SkRect {
558
+ const path = this.asPath();
559
+ const result = new JsiSkRect(this.CanvasKit, path.computeTightBounds());
560
+ path.delete();
561
+ return result;
300
562
  }
301
563
 
302
- addCircle(x: number, y: number, r: number) {
303
- this.ref.addCircle(x, y, r);
304
- return this;
564
+ contains(x: number, y: number) {
565
+ const path = this.asPath();
566
+ const result = path.contains(x, y);
567
+ path.delete();
568
+ return result;
305
569
  }
306
570
 
307
- getLastPt() {
308
- return new JsiSkPoint(
571
+ copy() {
572
+ const path = this.asPath();
573
+ const result = new JsiSkPath(
309
574
  this.CanvasKit,
310
- this.ref.getPoint(this.ref.countPoints() - 1)
575
+ new this.CanvasKit.PathBuilder(path)
311
576
  );
577
+ path.delete();
578
+ return result;
312
579
  }
313
580
 
314
- op(path: SkPath, op: PathOp) {
315
- return this.ref.op(
316
- JsiSkPath.fromValue(path),
317
- getEnum(this.CanvasKit, "PathOp", op)
318
- );
581
+ equals(other: SkPath) {
582
+ const p1 = this.asPath();
583
+ const p2 = JsiSkPath.fromValue<CKPathBuilder>(other).snapshot();
584
+ const result = p1.equals(p2);
585
+ p1.delete();
586
+ p2.delete();
587
+ return result;
319
588
  }
320
589
 
321
- simplify() {
322
- return this.ref.simplify();
590
+ getBounds() {
591
+ return new JsiSkRect(this.CanvasKit, this.ref.getBounds());
323
592
  }
324
593
 
325
- toSVGString() {
326
- return this.ref.toSVGString();
594
+ getFillType(): FillType {
595
+ const path = this.asPath();
596
+ const result = path.getFillType().value;
597
+ path.delete();
598
+ return result;
327
599
  }
328
600
 
329
- trim(start: number, stop: number, isComplement: boolean) {
330
- const startT = pinT(start);
331
- const stopT = pinT(stop);
332
- if (startT === 0 && stopT === 1) {
333
- return this;
334
- }
335
- const result = this.ref.trim(startT, stopT, isComplement);
336
- return result === null ? result : this;
601
+ getPoint(index: number): SkPoint {
602
+ const path = this.asPath();
603
+ const result = new JsiSkPoint(this.CanvasKit, path.getPoint(index));
604
+ path.delete();
605
+ return result;
337
606
  }
338
607
 
339
- transform(m: InputMatrix) {
340
- let matrix =
341
- m instanceof JsiSkMatrix
342
- ? Array.from(JsiSkMatrix.fromValue<Matrix3x3>(m))
343
- : (m as Exclude<InputMatrix, SkMatrix>);
344
- if (matrix.length === 16) {
345
- matrix = [
346
- matrix[0],
347
- matrix[1],
348
- matrix[3],
349
- matrix[4],
350
- matrix[5],
351
- matrix[7],
352
- matrix[12],
353
- matrix[13],
354
- matrix[15],
355
- ];
356
- } else if (matrix.length !== 9) {
357
- throw new Error(`Invalid matrix length: ${matrix.length}`);
608
+ isEmpty() {
609
+ return this.ref.isEmpty();
610
+ }
611
+
612
+ isVolatile() {
613
+ return false;
614
+ }
615
+
616
+ getLastPt() {
617
+ const count = this.ref.countPoints();
618
+ if (count === 0) {
619
+ return { x: 0, y: 0 };
358
620
  }
359
- this.ref.transform(matrix);
360
- return this;
621
+ const path = this.asPath();
622
+ const pt = path.getPoint(count - 1);
623
+ path.delete();
624
+ return { x: pt[0], y: pt[1] };
361
625
  }
362
626
 
363
- interpolate(end: SkPath, t: number, output?: SkPath) {
364
- const path = this.CanvasKit.Path.MakeFromPathInterpolation(
365
- this.ref,
366
- JsiSkPath.fromValue(end),
367
- t
368
- );
627
+ toSVGString() {
628
+ const path = this.asPath();
629
+ const result = path.toSVGString();
630
+ path.delete();
631
+ return result;
632
+ }
633
+
634
+ isInterpolatable(path2: SkPath): boolean {
635
+ const p1 = this.asPath();
636
+ const p2 = JsiSkPath.fromValue<CKPathBuilder>(path2).snapshot();
637
+ const result = this.CanvasKit.Path.CanInterpolate(p1, p2);
638
+ p1.delete();
639
+ p2.delete();
640
+ return result;
641
+ }
642
+
643
+ interpolate(end: SkPath, weight: number, output?: SkPath): SkPath | null {
644
+ const p1 = this.asPath();
645
+ const p2 = JsiSkPath.fromValue<CKPathBuilder>(end).snapshot();
646
+ const path = this.CanvasKit.Path.MakeFromPathInterpolation(p1, p2, weight);
647
+ p1.delete();
648
+ p2.delete();
369
649
  if (path === null) {
370
650
  return null;
371
651
  }
372
652
  if (output) {
373
- (output as JsiSkPath).ref = path;
653
+ const outRef = output as JsiSkPath;
654
+ const old = outRef.ref;
655
+ outRef.ref = new this.CanvasKit.PathBuilder(path);
656
+ path.delete();
657
+ old.delete();
374
658
  return output;
375
- } else {
376
- return new JsiSkPath(this.CanvasKit, path);
377
659
  }
378
- }
379
-
380
- isInterpolatable(path2: SkPath): boolean {
381
- return this.CanvasKit.Path.CanInterpolate(
382
- this.ref,
383
- JsiSkPath.fromValue(path2)
660
+ const result = new JsiSkPath(
661
+ this.CanvasKit,
662
+ new this.CanvasKit.PathBuilder(path)
384
663
  );
664
+ path.delete();
665
+ return result;
385
666
  }
386
667
 
387
668
  toCmds() {
388
- const cmds = this.ref.toCmds();
669
+ const path = this.asPath();
670
+ const cmds = path.toCmds();
671
+ path.delete();
389
672
  const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {
390
673
  if (i === 0) {
391
674
  acc.push([]);