@shopify/react-native-skia 2.5.5 → 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 (175) hide show
  1. package/cpp/api/CustomBlendModes.h +1 -0
  2. package/cpp/api/JsiSkApi.h +4 -0
  3. package/cpp/api/JsiSkCanvas.h +2 -2
  4. package/cpp/api/JsiSkContourMeasureIter.h +1 -1
  5. package/cpp/api/JsiSkPath.h +483 -355
  6. package/cpp/api/JsiSkPathBuilder.h +415 -0
  7. package/cpp/api/JsiSkPathBuilderFactory.h +53 -0
  8. package/cpp/api/JsiSkPathEffectFactory.h +2 -2
  9. package/cpp/api/JsiSkPathFactory.h +274 -3
  10. package/cpp/api/recorder/DataTypes.h +1 -1
  11. package/cpp/api/recorder/Drawings.h +6 -2
  12. package/cpp/rnskia/RNDawnContext.h +21 -0
  13. package/cpp/rnskia/RNDawnUtils.h +115 -113
  14. package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  15. package/lib/commonjs/animation/functions/interpolatePaths.js +5 -4
  16. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  17. package/lib/commonjs/external/reanimated/interpolators.d.ts +11 -2
  18. package/lib/commonjs/external/reanimated/interpolators.js +21 -4
  19. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  20. package/lib/commonjs/skia/types/Path/PathBuilder.d.ts +201 -0
  21. package/lib/commonjs/skia/types/Path/PathBuilder.js +6 -0
  22. package/lib/commonjs/skia/types/Path/PathBuilder.js.map +1 -0
  23. package/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  24. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js +6 -0
  25. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js.map +1 -0
  26. package/lib/commonjs/skia/types/Path/PathFactory.d.ts +87 -1
  27. package/lib/commonjs/skia/types/Path/PathFactory.js.map +1 -1
  28. package/lib/commonjs/skia/types/Path/index.d.ts +2 -0
  29. package/lib/commonjs/skia/types/Path/index.js +22 -0
  30. package/lib/commonjs/skia/types/Path/index.js.map +1 -1
  31. package/lib/commonjs/skia/types/Skia.d.ts +2 -1
  32. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  33. package/lib/commonjs/skia/web/Host.js +1 -3
  34. package/lib/commonjs/skia/web/Host.js.map +1 -1
  35. package/lib/commonjs/skia/web/JsiSkCanvas.js +6 -2
  36. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  37. package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -1
  38. package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
  39. package/lib/commonjs/skia/web/JsiSkPath.d.ts +42 -30
  40. package/lib/commonjs/skia/web/JsiSkPath.js +302 -111
  41. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +45 -0
  43. package/lib/commonjs/skia/web/JsiSkPathBuilder.js +192 -0
  44. package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -0
  45. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  46. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js +26 -0
  47. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  48. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +6 -2
  49. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +13 -1
  51. package/lib/commonjs/skia/web/JsiSkPathFactory.js +140 -5
  52. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  53. package/lib/commonjs/skia/web/JsiSkia.js +8 -1
  54. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  55. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +18 -6
  56. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  57. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  58. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -3
  59. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  60. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -2
  61. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +2 -3
  62. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -1
  63. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +2 -0
  64. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  65. package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  66. package/lib/module/animation/functions/interpolatePaths.js +5 -4
  67. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  68. package/lib/module/external/reanimated/interpolators.d.ts +11 -2
  69. package/lib/module/external/reanimated/interpolators.js +21 -4
  70. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  71. package/lib/module/skia/types/Path/PathBuilder.d.ts +201 -0
  72. package/lib/module/skia/types/Path/PathBuilder.js +2 -0
  73. package/lib/module/skia/types/Path/PathBuilder.js.map +1 -0
  74. package/lib/module/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  75. package/lib/module/skia/types/Path/PathBuilderFactory.js +2 -0
  76. package/lib/module/skia/types/Path/PathBuilderFactory.js.map +1 -0
  77. package/lib/module/skia/types/Path/PathFactory.d.ts +87 -1
  78. package/lib/module/skia/types/Path/PathFactory.js.map +1 -1
  79. package/lib/module/skia/types/Path/index.d.ts +2 -0
  80. package/lib/module/skia/types/Path/index.js +2 -0
  81. package/lib/module/skia/types/Path/index.js.map +1 -1
  82. package/lib/module/skia/types/Skia.d.ts +2 -1
  83. package/lib/module/skia/types/Skia.js.map +1 -1
  84. package/lib/module/skia/web/Host.js +1 -3
  85. package/lib/module/skia/web/Host.js.map +1 -1
  86. package/lib/module/skia/web/JsiSkCanvas.js +6 -2
  87. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkContourMeasure.js +4 -1
  89. package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
  90. package/lib/module/skia/web/JsiSkPath.d.ts +42 -30
  91. package/lib/module/skia/web/JsiSkPath.js +300 -110
  92. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  93. package/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  94. package/lib/module/skia/web/JsiSkPathBuilder.js +186 -0
  95. package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -0
  96. package/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  97. package/lib/module/skia/web/JsiSkPathBuilderFactory.js +19 -0
  98. package/lib/module/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  99. package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -2
  100. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  101. package/lib/module/skia/web/JsiSkPathFactory.d.ts +13 -1
  102. package/lib/module/skia/web/JsiSkPathFactory.js +141 -6
  103. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  104. package/lib/module/skia/web/JsiSkia.js +8 -1
  105. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  106. package/lib/module/sksg/Recorder/commands/Drawing.js +18 -6
  107. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  108. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  109. package/lib/module/specs/SkiaPictureViewNativeComponent.js +1 -1
  110. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  111. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -2
  112. package/lib/module/specs/WebGPUViewNativeComponent.js +1 -1
  113. package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -1
  114. package/lib/module/specs/WebGPUViewNativeComponent.web.js +2 -0
  115. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  116. package/lib/typescript/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  117. package/lib/typescript/lib/commonjs/external/reanimated/interpolators.d.ts +1 -1
  118. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilder.d.ts +1 -0
  119. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  120. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +33 -25
  121. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +46 -0
  122. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +7 -0
  123. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +12 -0
  124. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  125. package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -1
  126. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -1
  127. package/lib/typescript/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  128. package/lib/typescript/lib/module/external/reanimated/interpolators.d.ts +1 -1
  129. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  130. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
  131. package/lib/typescript/lib/module/skia/types/Path/PathBuilder.d.ts +1 -0
  132. package/lib/typescript/lib/module/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  133. package/lib/typescript/lib/module/skia/types/Path/index.d.ts +2 -0
  134. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +38 -25
  135. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  136. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +6 -0
  137. package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +12 -0
  138. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  139. package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -1
  140. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +1 -1
  141. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
  142. package/lib/typescript/src/external/reanimated/interpolators.d.ts +11 -2
  143. package/lib/typescript/src/skia/types/Path/PathBuilder.d.ts +201 -0
  144. package/lib/typescript/src/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  145. package/lib/typescript/src/skia/types/Path/PathFactory.d.ts +87 -1
  146. package/lib/typescript/src/skia/types/Path/index.d.ts +2 -0
  147. package/lib/typescript/src/skia/types/Skia.d.ts +2 -1
  148. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +42 -30
  149. package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +45 -0
  150. package/lib/typescript/src/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  151. package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +13 -1
  152. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  153. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +2 -2
  154. package/package.json +3 -2
  155. package/scripts/install-libs.js +16 -6
  156. package/src/animation/functions/interpolatePaths.ts +5 -6
  157. package/src/external/reanimated/interpolators.ts +25 -5
  158. package/src/skia/types/Path/PathBuilder.ts +303 -0
  159. package/src/skia/types/Path/PathBuilderFactory.ts +15 -0
  160. package/src/skia/types/Path/PathFactory.ts +108 -1
  161. package/src/skia/types/Path/index.ts +2 -0
  162. package/src/skia/types/Skia.ts +2 -1
  163. package/src/skia/web/Host.ts +7 -1
  164. package/src/skia/web/JsiSkCanvas.ts +6 -6
  165. package/src/skia/web/JsiSkContourMeasure.ts +4 -4
  166. package/src/skia/web/JsiSkPath.ts +451 -168
  167. package/src/skia/web/JsiSkPathBuilder.ts +293 -0
  168. package/src/skia/web/JsiSkPathBuilderFactory.ts +32 -0
  169. package/src/skia/web/JsiSkPathEffectFactory.ts +6 -2
  170. package/src/skia/web/JsiSkPathFactory.ts +231 -8
  171. package/src/skia/web/JsiSkia.ts +11 -8
  172. package/src/sksg/Recorder/commands/Drawing.ts +20 -7
  173. package/src/specs/SkiaPictureViewNativeComponent.ts +1 -2
  174. package/src/specs/WebGPUViewNativeComponent.ts +2 -2
  175. package/src/specs/WebGPUViewNativeComponent.web.ts +2 -0
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.JsiSkPath = void 0;
6
+ exports.toMatrix3x3 = exports.JsiSkPath = void 0;
7
7
  var _types = require("../types");
8
8
  var _Host = require("./Host");
9
9
  var _JsiSkPoint = require("./JsiSkPoint");
@@ -18,216 +18,407 @@ const CommandCount = {
18
18
  [_types.PathVerb.Cubic]: 7,
19
19
  [_types.PathVerb.Close]: 1
20
20
  };
21
- const pinT = t => Math.min(Math.max(t, 0), 1);
21
+
22
+ // Track which deprecation warnings have been shown to avoid spam
23
+ const shownDeprecationWarnings = new Set();
24
+ const warnDeprecatedPathMethod = (methodName, suggestion) => {
25
+ if (shownDeprecationWarnings.has(methodName)) {
26
+ return;
27
+ }
28
+ shownDeprecationWarnings.add(methodName);
29
+ console.warn(`[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`);
30
+ };
31
+ const toMatrix3x3 = m => {
32
+ let matrix = m instanceof _JsiSkMatrix.JsiSkMatrix ? Array.from(_JsiSkMatrix.JsiSkMatrix.fromValue(m)) : m;
33
+ if (matrix.length === 16) {
34
+ matrix = [matrix[0], matrix[1], matrix[3], matrix[4], matrix[5], matrix[7], matrix[12], matrix[13], matrix[15]];
35
+ } else if (matrix.length !== 9) {
36
+ throw new Error(`Invalid matrix length: ${matrix.length}`);
37
+ }
38
+ return matrix;
39
+ };
40
+
41
+ /**
42
+ * SkPath wraps a CK PathBuilder internally, providing both mutable building
43
+ * methods and immutable query methods. Use snapshot() internally to get
44
+ * an immutable CK Path for read-only operations.
45
+ */
46
+ exports.toMatrix3x3 = toMatrix3x3;
22
47
  class JsiSkPath extends _Host.HostObject {
23
48
  constructor(CanvasKit, ref) {
24
49
  super(CanvasKit, ref, "Path");
25
50
  }
51
+
52
+ /** Returns an immutable CK Path snapshot for read-only operations. */
53
+ asPath() {
54
+ return this.ref.snapshot();
55
+ }
56
+
57
+ /** Extract an immutable CK Path from a JsiSkPath value (for CK interop). */
58
+ static pathFromValue(value) {
59
+ return JsiSkPath.fromValue(value).snapshot();
60
+ }
61
+
62
+ // ---- Mutable building methods (deprecated) ----
63
+
26
64
  addPath(src, matrix, extend = false) {
27
- const args = [JsiSkPath.fromValue(src), ...(matrix ? _JsiSkMatrix.JsiSkMatrix.fromValue(matrix) : []), extend];
65
+ warnDeprecatedPathMethod("addPath", "Use Skia.PathBuilder.Make().addPath() instead.");
66
+ const srcBuilder = JsiSkPath.fromValue(src);
67
+ const srcPath = srcBuilder.snapshot();
68
+ const args = [srcPath, ...(matrix ? _JsiSkMatrix.JsiSkMatrix.fromValue(matrix) : []), extend];
28
69
  this.ref.addPath(...args);
70
+ srcPath.delete();
29
71
  return this;
30
72
  }
31
73
  addArc(oval, startAngleInDegrees, sweepAngleInDegrees) {
74
+ warnDeprecatedPathMethod("addArc", "Use Skia.PathBuilder.Make().addArc() instead.");
32
75
  this.ref.addArc(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, oval), startAngleInDegrees, sweepAngleInDegrees);
33
76
  return this;
34
77
  }
35
78
  addOval(oval, isCCW, startIndex) {
79
+ warnDeprecatedPathMethod("addOval", "Use Skia.Path.Oval() or Skia.PathBuilder.Make().addOval() instead.");
36
80
  this.ref.addOval(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, oval), isCCW, startIndex);
37
81
  return this;
38
82
  }
39
- countPoints() {
40
- return this.ref.countPoints();
41
- }
42
83
  addPoly(points, close) {
43
- this.ref.addPoly(points.map(p => Array.from(_JsiSkPoint.JsiSkPoint.fromValue(p))).flat(), close);
44
- return this;
45
- }
46
- moveTo(x, y) {
47
- this.ref.moveTo(x, y);
48
- return this;
49
- }
50
- lineTo(x, y) {
51
- this.ref.lineTo(x, y);
84
+ warnDeprecatedPathMethod("addPoly", "Use Skia.Path.Polygon() or Skia.PathBuilder.Make().addPoly() instead.");
85
+ this.ref.addPolygon(points.map(p => Array.from(_JsiSkPoint.JsiSkPoint.fromValue(p))).flat(), close);
52
86
  return this;
53
87
  }
54
- makeAsWinding() {
55
- const result = this.ref.makeAsWinding();
56
- return result === null ? result : this;
57
- }
58
- offset(dx, dy) {
59
- this.ref.offset(dx, dy);
88
+ addRect(rect, isCCW) {
89
+ warnDeprecatedPathMethod("addRect", "Use Skia.Path.Rect() or Skia.PathBuilder.Make().addRect() instead.");
90
+ this.ref.addRect(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);
60
91
  return this;
61
92
  }
62
- rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy) {
63
- this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);
93
+ addRRect(rrect, isCCW) {
94
+ warnDeprecatedPathMethod("addRRect", "Use Skia.Path.RRect() or Skia.PathBuilder.Make().addRRect() instead.");
95
+ this.ref.addRRect(_JsiSkRRect.JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);
64
96
  return this;
65
97
  }
66
- rConicTo(dx1, dy1, dx2, dy2, w) {
67
- this.ref.rConicTo(dx1, dy1, dx2, dy2, w);
98
+ addCircle(x, y, r) {
99
+ warnDeprecatedPathMethod("addCircle", "Use Skia.Path.Circle() or Skia.PathBuilder.Make().addCircle() instead.");
100
+ this.ref.addCircle(x, y, r);
68
101
  return this;
69
102
  }
70
- rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y) {
71
- this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
103
+ moveTo(x, y) {
104
+ warnDeprecatedPathMethod("moveTo", "Use Skia.PathBuilder.Make().moveTo() instead.");
105
+ this.ref.moveTo(x, y);
72
106
  return this;
73
107
  }
74
108
  rMoveTo(x, y) {
109
+ warnDeprecatedPathMethod("rMoveTo", "Use Skia.PathBuilder.Make().rMoveTo() instead.");
75
110
  this.ref.rMoveTo(x, y);
76
111
  return this;
77
112
  }
113
+ lineTo(x, y) {
114
+ warnDeprecatedPathMethod("lineTo", "Use Skia.PathBuilder.Make().lineTo() instead.");
115
+ this.ref.lineTo(x, y);
116
+ return this;
117
+ }
78
118
  rLineTo(x, y) {
119
+ warnDeprecatedPathMethod("rLineTo", "Use Skia.PathBuilder.Make().rLineTo() instead.");
79
120
  this.ref.rLineTo(x, y);
80
121
  return this;
81
122
  }
123
+ quadTo(x1, y1, x2, y2) {
124
+ warnDeprecatedPathMethod("quadTo", "Use Skia.PathBuilder.Make().quadTo() instead.");
125
+ this.ref.quadTo(x1, y1, x2, y2);
126
+ return this;
127
+ }
82
128
  rQuadTo(x1, y1, x2, y2) {
129
+ warnDeprecatedPathMethod("rQuadTo", "Use Skia.PathBuilder.Make().rQuadTo() instead.");
83
130
  this.ref.rQuadTo(x1, y1, x2, y2);
84
131
  return this;
85
132
  }
86
- setFillType(fill) {
87
- this.ref.setFillType((0, _Host.getEnum)(this.CanvasKit, "FillType", fill));
133
+ conicTo(x1, y1, x2, y2, w) {
134
+ warnDeprecatedPathMethod("conicTo", "Use Skia.PathBuilder.Make().conicTo() instead.");
135
+ this.ref.conicTo(x1, y1, x2, y2, w);
88
136
  return this;
89
137
  }
90
- setIsVolatile(volatile) {
91
- this.ref.setIsVolatile(volatile);
138
+ rConicTo(x1, y1, x2, y2, w) {
139
+ warnDeprecatedPathMethod("rConicTo", "Use Skia.PathBuilder.Make().rConicTo() instead.");
140
+ this.ref.rConicTo(x1, y1, x2, y2, w);
92
141
  return this;
93
142
  }
94
- stroke(opts) {
95
- const result = this.ref.stroke(opts === undefined ? undefined : {
96
- width: opts.width,
97
- // eslint-disable-next-line camelcase
98
- miter_limit: opts.width,
99
- precision: opts.width,
100
- join: (0, _Host.optEnum)(this.CanvasKit, "StrokeJoin", opts.join),
101
- cap: (0, _Host.optEnum)(this.CanvasKit, "StrokeCap", opts.cap)
102
- });
103
- return result === null ? result : this;
143
+ cubicTo(cpx1, cpy1, cpx2, cpy2, x, y) {
144
+ warnDeprecatedPathMethod("cubicTo", "Use Skia.PathBuilder.Make().cubicTo() instead.");
145
+ this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
146
+ return this;
147
+ }
148
+ rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y) {
149
+ warnDeprecatedPathMethod("rCubicTo", "Use Skia.PathBuilder.Make().rCubicTo() instead.");
150
+ this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
151
+ return this;
104
152
  }
105
153
  close() {
154
+ warnDeprecatedPathMethod("close", "Use Skia.PathBuilder.Make().close() instead.");
106
155
  this.ref.close();
107
156
  return this;
108
157
  }
109
158
  reset() {
110
- this.ref.reset();
159
+ warnDeprecatedPathMethod("reset", "Use Skia.PathBuilder.Make().reset() instead.");
160
+ // CK PathBuilder has no reset — recreate
161
+ const newBuilder = new this.CanvasKit.PathBuilder();
162
+ if (this.ref !== null && typeof this.ref === "object" && "delete" in this.ref && typeof this.ref.delete === "function") {
163
+ this.ref.delete();
164
+ }
165
+ this.ref = newBuilder;
111
166
  return this;
112
167
  }
113
168
  rewind() {
114
- this.ref.rewind();
115
- return this;
116
- }
117
- computeTightBounds() {
118
- return new _JsiSkRect.JsiSkRect(this.CanvasKit, this.ref.computeTightBounds());
169
+ warnDeprecatedPathMethod("rewind", "Use Skia.PathBuilder.Make().reset() instead.");
170
+ return this.reset();
119
171
  }
120
172
  arcToOval(oval, startAngleInDegrees, sweepAngleInDegrees, forceMoveTo) {
173
+ warnDeprecatedPathMethod("arcToOval", "Use Skia.PathBuilder.Make().arcToOval() instead.");
121
174
  this.ref.arcToOval(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, oval), startAngleInDegrees, sweepAngleInDegrees, forceMoveTo);
122
175
  return this;
123
176
  }
124
177
  arcToRotated(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, x, y) {
178
+ warnDeprecatedPathMethod("arcToRotated", "Use Skia.PathBuilder.Make().arcToRotated() instead.");
125
179
  this.ref.arcToRotated(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, x, y);
126
180
  return this;
127
181
  }
182
+ rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy) {
183
+ warnDeprecatedPathMethod("rArcTo", "Use Skia.PathBuilder.Make().rArcTo() instead.");
184
+ this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);
185
+ return this;
186
+ }
128
187
  arcToTangent(x1, y1, x2, y2, radius) {
188
+ warnDeprecatedPathMethod("arcToTangent", "Use Skia.PathBuilder.Make().arcToTangent() instead.");
129
189
  this.ref.arcToTangent(x1, y1, x2, y2, radius);
130
190
  return this;
131
191
  }
132
- conicTo(x1, y1, x2, y2, w) {
133
- this.ref.conicTo(x1, y1, x2, y2, w);
192
+ setFillType(fill) {
193
+ warnDeprecatedPathMethod("setFillType", "Use Skia.PathBuilder.Make().setFillType() instead.");
194
+ this.ref.setFillType((0, _Host.getEnum)(this.CanvasKit, "FillType", fill));
134
195
  return this;
135
196
  }
136
- contains(x, y) {
137
- return this.ref.contains(x, y);
197
+ setIsVolatile(_volatile) {
198
+ warnDeprecatedPathMethod("setIsVolatile", "Use Skia.PathBuilder.Make().setIsVolatile() instead.");
199
+ // Not supported in CK PathBuilder — no-op
200
+ return this;
138
201
  }
139
- copy() {
140
- return new JsiSkPath(this.CanvasKit, this.ref.copy());
202
+
203
+ // ---- Mutable path operations (deprecated) ----
204
+
205
+ offset(dx, dy) {
206
+ warnDeprecatedPathMethod("offset", "Use Skia.PathBuilder.Make().offset() instead.");
207
+ this.ref.offset(dx, dy);
208
+ return this;
141
209
  }
142
- cubicTo(cpx1, cpy1, cpx2, cpy2, x, y) {
143
- this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);
210
+ transform(m) {
211
+ warnDeprecatedPathMethod("transform", "Use Skia.PathBuilder.Make().transform() instead.");
212
+ const matrix = toMatrix3x3(m);
213
+ this.ref.transform(matrix);
144
214
  return this;
145
215
  }
146
- dash(on, off, phase) {
147
- return this.ref.dash(on, off, phase);
216
+ makeAsWinding() {
217
+ warnDeprecatedPathMethod("makeAsWinding", "Use Skia.Path.AsWinding(path) instead.");
218
+ const path = this.asPath();
219
+ const result = path.makeAsWinding();
220
+ path.delete();
221
+ if (result === null) {
222
+ return null;
223
+ }
224
+ const old = this.ref;
225
+ this.ref = new this.CanvasKit.PathBuilder(result);
226
+ result.delete();
227
+ old.delete();
228
+ return this;
148
229
  }
149
- equals(other) {
150
- return this.ref.equals(JsiSkPath.fromValue(other));
230
+ simplify() {
231
+ warnDeprecatedPathMethod("simplify", "Use Skia.Path.Simplify(path) instead.");
232
+ const path = this.asPath();
233
+ const result = path.makeSimplified();
234
+ path.delete();
235
+ if (result === null) {
236
+ return false;
237
+ }
238
+ const old = this.ref;
239
+ this.ref = new this.CanvasKit.PathBuilder(result);
240
+ result.delete();
241
+ old.delete();
242
+ return true;
151
243
  }
152
- getBounds() {
153
- return new _JsiSkRect.JsiSkRect(this.CanvasKit, this.ref.getBounds());
244
+ op(path, op) {
245
+ warnDeprecatedPathMethod("op", "Use Skia.Path.MakeFromOp() instead.");
246
+ const self = this.asPath();
247
+ const other = JsiSkPath.fromValue(path).snapshot();
248
+ const result = self.makeCombined(other, (0, _Host.getEnum)(this.CanvasKit, "PathOp", op));
249
+ self.delete();
250
+ other.delete();
251
+ if (result === null) {
252
+ return false;
253
+ }
254
+ const old = this.ref;
255
+ this.ref = new this.CanvasKit.PathBuilder(result);
256
+ result.delete();
257
+ old.delete();
258
+ return true;
154
259
  }
155
- getFillType() {
156
- return this.ref.getFillType().value;
260
+ dash(on, off, phase) {
261
+ warnDeprecatedPathMethod("dash", "Use Skia.Path.Dash(path, on, off, phase) instead.");
262
+ const path = this.asPath();
263
+ const result = path.makeDashed(on, off, phase);
264
+ path.delete();
265
+ if (result === null) {
266
+ return false;
267
+ }
268
+ const old = this.ref;
269
+ this.ref = new this.CanvasKit.PathBuilder(result);
270
+ result.delete();
271
+ old.delete();
272
+ return true;
157
273
  }
158
- quadTo(x1, y1, x2, y2) {
159
- this.ref.quadTo(x1, y1, x2, y2);
274
+ stroke(opts) {
275
+ warnDeprecatedPathMethod("stroke", "Use Skia.Path.Stroke(path, opts) instead.");
276
+ const path = this.asPath();
277
+ const result = path.makeStroked(opts === undefined ? undefined : {
278
+ width: opts.width,
279
+ // eslint-disable-next-line camelcase
280
+ miter_limit: opts.miter_limit,
281
+ precision: opts.precision,
282
+ join: (0, _Host.optEnum)(this.CanvasKit, "StrokeJoin", opts.join),
283
+ cap: (0, _Host.optEnum)(this.CanvasKit, "StrokeCap", opts.cap)
284
+ });
285
+ path.delete();
286
+ if (result === null) {
287
+ return null;
288
+ }
289
+ const old = this.ref;
290
+ this.ref = new this.CanvasKit.PathBuilder(result);
291
+ result.delete();
292
+ old.delete();
160
293
  return this;
161
294
  }
162
- addRect(rect, isCCW) {
163
- this.ref.addRect(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);
295
+ trim(start, stop, isComplement) {
296
+ warnDeprecatedPathMethod("trim", "Use Skia.Path.Trim(path, start, end, isComplement) instead.");
297
+ const startT = Math.min(Math.max(start, 0), 1);
298
+ const stopT = Math.min(Math.max(stop, 0), 1);
299
+ if (startT === 0 && stopT === 1 && !isComplement) {
300
+ return this;
301
+ }
302
+ const path = this.asPath();
303
+ const result = path.makeTrimmed(startT, stopT, isComplement);
304
+ path.delete();
305
+ if (result === null) {
306
+ return null;
307
+ }
308
+ const old = this.ref;
309
+ this.ref = new this.CanvasKit.PathBuilder(result);
310
+ result.delete();
311
+ old.delete();
164
312
  return this;
165
313
  }
166
- addRRect(rrect, isCCW) {
167
- this.ref.addRRect(_JsiSkRRect.JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);
168
- return this;
314
+
315
+ // ---- Query methods (use snapshot for read-only) ----
316
+
317
+ countPoints() {
318
+ return this.ref.countPoints();
319
+ }
320
+ computeTightBounds() {
321
+ const path = this.asPath();
322
+ const result = new _JsiSkRect.JsiSkRect(this.CanvasKit, path.computeTightBounds());
323
+ path.delete();
324
+ return result;
325
+ }
326
+ contains(x, y) {
327
+ const path = this.asPath();
328
+ const result = path.contains(x, y);
329
+ path.delete();
330
+ return result;
331
+ }
332
+ copy() {
333
+ const path = this.asPath();
334
+ const result = new JsiSkPath(this.CanvasKit, new this.CanvasKit.PathBuilder(path));
335
+ path.delete();
336
+ return result;
337
+ }
338
+ equals(other) {
339
+ const p1 = this.asPath();
340
+ const p2 = JsiSkPath.fromValue(other).snapshot();
341
+ const result = p1.equals(p2);
342
+ p1.delete();
343
+ p2.delete();
344
+ return result;
345
+ }
346
+ getBounds() {
347
+ return new _JsiSkRect.JsiSkRect(this.CanvasKit, this.ref.getBounds());
348
+ }
349
+ getFillType() {
350
+ const path = this.asPath();
351
+ const result = path.getFillType().value;
352
+ path.delete();
353
+ return result;
169
354
  }
170
355
  getPoint(index) {
171
- return new _JsiSkPoint.JsiSkPoint(this.CanvasKit, this.ref.getPoint(index));
356
+ const path = this.asPath();
357
+ const result = new _JsiSkPoint.JsiSkPoint(this.CanvasKit, path.getPoint(index));
358
+ path.delete();
359
+ return result;
172
360
  }
173
361
  isEmpty() {
174
362
  return this.ref.isEmpty();
175
363
  }
176
364
  isVolatile() {
177
- return this.ref.isVolatile();
178
- }
179
- addCircle(x, y, r) {
180
- this.ref.addCircle(x, y, r);
181
- return this;
365
+ return false;
182
366
  }
183
367
  getLastPt() {
184
- return new _JsiSkPoint.JsiSkPoint(this.CanvasKit, this.ref.getPoint(this.ref.countPoints() - 1));
185
- }
186
- op(path, op) {
187
- return this.ref.op(JsiSkPath.fromValue(path), (0, _Host.getEnum)(this.CanvasKit, "PathOp", op));
188
- }
189
- simplify() {
190
- return this.ref.simplify();
368
+ const count = this.ref.countPoints();
369
+ if (count === 0) {
370
+ return {
371
+ x: 0,
372
+ y: 0
373
+ };
374
+ }
375
+ const path = this.asPath();
376
+ const pt = path.getPoint(count - 1);
377
+ path.delete();
378
+ return {
379
+ x: pt[0],
380
+ y: pt[1]
381
+ };
191
382
  }
192
383
  toSVGString() {
193
- return this.ref.toSVGString();
194
- }
195
- trim(start, stop, isComplement) {
196
- const startT = pinT(start);
197
- const stopT = pinT(stop);
198
- if (startT === 0 && stopT === 1) {
199
- return this;
200
- }
201
- const result = this.ref.trim(startT, stopT, isComplement);
202
- return result === null ? result : this;
384
+ const path = this.asPath();
385
+ const result = path.toSVGString();
386
+ path.delete();
387
+ return result;
203
388
  }
204
- transform(m) {
205
- let matrix = m instanceof _JsiSkMatrix.JsiSkMatrix ? Array.from(_JsiSkMatrix.JsiSkMatrix.fromValue(m)) : m;
206
- if (matrix.length === 16) {
207
- matrix = [matrix[0], matrix[1], matrix[3], matrix[4], matrix[5], matrix[7], matrix[12], matrix[13], matrix[15]];
208
- } else if (matrix.length !== 9) {
209
- throw new Error(`Invalid matrix length: ${matrix.length}`);
210
- }
211
- this.ref.transform(matrix);
212
- return this;
389
+ isInterpolatable(path2) {
390
+ const p1 = this.asPath();
391
+ const p2 = JsiSkPath.fromValue(path2).snapshot();
392
+ const result = this.CanvasKit.Path.CanInterpolate(p1, p2);
393
+ p1.delete();
394
+ p2.delete();
395
+ return result;
213
396
  }
214
- interpolate(end, t, output) {
215
- const path = this.CanvasKit.Path.MakeFromPathInterpolation(this.ref, JsiSkPath.fromValue(end), t);
397
+ interpolate(end, weight, output) {
398
+ const p1 = this.asPath();
399
+ const p2 = JsiSkPath.fromValue(end).snapshot();
400
+ const path = this.CanvasKit.Path.MakeFromPathInterpolation(p1, p2, weight);
401
+ p1.delete();
402
+ p2.delete();
216
403
  if (path === null) {
217
404
  return null;
218
405
  }
219
406
  if (output) {
220
- output.ref = path;
407
+ const outRef = output;
408
+ const old = outRef.ref;
409
+ outRef.ref = new this.CanvasKit.PathBuilder(path);
410
+ path.delete();
411
+ old.delete();
221
412
  return output;
222
- } else {
223
- return new JsiSkPath(this.CanvasKit, path);
224
413
  }
225
- }
226
- isInterpolatable(path2) {
227
- return this.CanvasKit.Path.CanInterpolate(this.ref, JsiSkPath.fromValue(path2));
414
+ const result = new JsiSkPath(this.CanvasKit, new this.CanvasKit.PathBuilder(path));
415
+ path.delete();
416
+ return result;
228
417
  }
229
418
  toCmds() {
230
- const cmds = this.ref.toCmds();
419
+ const path = this.asPath();
420
+ const cmds = path.toCmds();
421
+ path.delete();
231
422
  const result = cmds.reduce((acc, cmd, i) => {
232
423
  if (i === 0) {
233
424
  acc.push([]);