@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
@@ -0,0 +1,45 @@
1
+ import type { CanvasKit, PathBuilder as CKPathBuilder } from "canvaskit-wasm";
2
+ import type { FillType, InputMatrix, InputRRect, SkMatrix, SkPath, SkPathBuilder, SkPoint, SkRect } from "../types";
3
+ import { HostObject } from "./Host";
4
+ /**
5
+ * Web implementation of SkPathBuilder using CanvasKit's native PathBuilder.
6
+ */
7
+ export declare class JsiSkPathBuilder extends HostObject<CKPathBuilder, "PathBuilder"> implements SkPathBuilder {
8
+ constructor(CanvasKit: CanvasKit, ref: CKPathBuilder);
9
+ moveTo(x: number, y: number): this;
10
+ rMoveTo(x: number, y: number): this;
11
+ lineTo(x: number, y: number): this;
12
+ rLineTo(x: number, y: number): this;
13
+ quadTo(x1: number, y1: number, x2: number, y2: number): this;
14
+ rQuadTo(x1: number, y1: number, x2: number, y2: number): this;
15
+ conicTo(x1: number, y1: number, x2: number, y2: number, w: number): this;
16
+ rConicTo(x1: number, y1: number, x2: number, y2: number, w: number): this;
17
+ cubicTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): this;
18
+ rCubicTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): this;
19
+ close(): this;
20
+ arcToOval(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number, forceMoveTo: boolean): this;
21
+ arcToRotated(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, x: number, y: number): this;
22
+ rArcTo(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, dx: number, dy: number): this;
23
+ arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number): this;
24
+ addRect(rect: SkRect, isCCW?: boolean): this;
25
+ addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): this;
26
+ addArc(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number): this;
27
+ addRRect(rrect: InputRRect, isCCW?: boolean): this;
28
+ addCircle(x: number, y: number, r: number, _isCCW?: boolean): this;
29
+ addPoly(points: SkPoint[], close: boolean): this;
30
+ addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): this;
31
+ setFillType(fill: FillType): this;
32
+ setIsVolatile(_isVolatile: boolean): this;
33
+ reset(): this;
34
+ offset(dx: number, dy: number): this;
35
+ transform(m: InputMatrix): this;
36
+ computeBounds(): SkRect;
37
+ isEmpty(): boolean;
38
+ getLastPt(): {
39
+ x: number;
40
+ y: number;
41
+ };
42
+ countPoints(): number;
43
+ build(): SkPath;
44
+ detach(): SkPath;
45
+ }
@@ -0,0 +1,9 @@
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+ import type { PathBuilderFactory, SkPath } from "../types";
3
+ import { Host } from "./Host";
4
+ import { JsiSkPathBuilder } from "./JsiSkPathBuilder";
5
+ export declare class JsiSkPathBuilderFactory extends Host implements PathBuilderFactory {
6
+ constructor(CanvasKit: CanvasKit);
7
+ Make(): JsiSkPathBuilder;
8
+ MakeFromPath(path: SkPath): JsiSkPathBuilder;
9
+ }
@@ -1,5 +1,5 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
- import type { PathCommand, PathOp, SkFont, SkPath } from "../types";
2
+ import type { InputRRect, PathCommand, PathOp, SkFont, SkPath, SkPoint, SkRect, StrokeOpts } from "../types";
3
3
  import type { PathFactory } from "../types/Path/PathFactory";
4
4
  import { Host } from "./Host";
5
5
  import { JsiSkPath } from "./JsiSkPath";
@@ -10,4 +10,16 @@ export declare class JsiSkPathFactory extends Host implements PathFactory {
10
10
  MakeFromOp(one: SkPath, two: SkPath, op: PathOp): JsiSkPath | null;
11
11
  MakeFromCmds(cmds: PathCommand[]): JsiSkPath | null;
12
12
  MakeFromText(_text: string, _x: number, _y: number, _font: SkFont): SkPath;
13
+ Rect(rect: SkRect, isCCW?: boolean): JsiSkPath;
14
+ Oval(rect: SkRect, isCCW?: boolean, startIndex?: number): JsiSkPath;
15
+ Circle(x: number, y: number, r: number): JsiSkPath;
16
+ RRect(rrect: InputRRect, isCCW?: boolean): JsiSkPath;
17
+ Line(p1: SkPoint, p2: SkPoint): JsiSkPath;
18
+ Polygon(points: SkPoint[], close: boolean): JsiSkPath;
19
+ Stroke(srcPath: SkPath, opts?: StrokeOpts): JsiSkPath | null;
20
+ Trim(srcPath: SkPath, start: number, end: number, isComplement: boolean): JsiSkPath | null;
21
+ Simplify(srcPath: SkPath): JsiSkPath | null;
22
+ Dash(srcPath: SkPath, on: number, off: number, phase: number): JsiSkPath | null;
23
+ AsWinding(srcPath: SkPath): JsiSkPath | null;
24
+ Interpolate(start: SkPath, end: SkPath, weight: number): JsiSkPath | null;
13
25
  }
@@ -1,4 +1,4 @@
1
- import type { ViewProps } from "react-native";
1
+ import { type ViewProps } from "react-native";
2
2
  import type { WithDefault } from "react-native/Libraries/Types/CodegenTypes";
3
3
  export interface NativeProps extends ViewProps {
4
4
  debug?: boolean;
@@ -7,5 +7,5 @@ export interface NativeProps extends ViewProps {
7
7
  androidWarmup?: boolean;
8
8
  pointerEvents?: WithDefault<"auto" | "none" | "box-none" | "box-only", "auto">;
9
9
  }
10
- declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
10
+ declare const _default: import("react-native").HostComponent<NativeProps>;
11
11
  export default _default;
@@ -1,8 +1,8 @@
1
- import type { Int32 } from "react-native/Libraries/Types/CodegenTypes";
2
1
  import type { ViewProps } from "react-native";
2
+ import type { Int32 } from "react-native/Libraries/Types/CodegenTypes";
3
3
  export interface NativeProps extends ViewProps {
4
4
  contextId: Int32;
5
5
  transparent: boolean;
6
6
  }
7
- declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
7
+ declare const _default: import("react-native").HostComponent<NativeProps>;
8
8
  export default _default;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "setup-skia-web": "scripts/setup-canvaskit.js"
10
10
  },
11
11
  "title": "React Native Skia",
12
- "version": "2.5.4",
12
+ "version": "2.6.0",
13
13
  "description": "High-performance React Native Graphics using Skia",
14
14
  "main": "lib/module/index.js",
15
15
  "react-native": "src/index.ts",
@@ -48,6 +48,7 @@
48
48
  "build-skia": "tsx ./scripts/build-skia.ts",
49
49
  "copy-skia-headers": "tsx ./scripts/copy-skia-headers.ts",
50
50
  "install-skia-graphite": "tsx ./scripts/install-skia-graphite.ts",
51
+ "install-skia": "node scripts/install-libs.js",
51
52
  "clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
52
53
  "clang-format-ios": "find apple/ -iname '*.h' -o -iname '*.mm' -o -iname '*.cpp' | xargs clang-format -i",
53
54
  "clang-format-android": "find android/cpp/ -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' | xargs clang-format -i",
@@ -127,7 +128,7 @@
127
128
  "ws": "8.18.0"
128
129
  },
129
130
  "dependencies": {
130
- "canvaskit-wasm": "0.40.0",
131
+ "canvaskit-wasm": "0.41.0",
131
132
  "react-native-skia-android": "144.3.0",
132
133
  "react-native-skia-apple-ios": "144.3.0",
133
134
  "react-native-skia-apple-macos": "144.3.0",
@@ -148,7 +149,7 @@
148
149
  "ios": {
149
150
  "componentProvider": {
150
151
  "SkiaPictureView": "SkiaPictureView",
151
- "WebGPUView": "WebGPUView"
152
+ "SkiaWebGPUView": "SkiaWebGPUView"
152
153
  }
153
154
  }
154
155
  },
@@ -19,9 +19,13 @@ function copySync(src, dest, options) {
19
19
  const basePath = wildcardSplit[0];
20
20
  const files = fs.readdirSync(basePath);
21
21
  files
22
- .filter(file => file.endsWith(wildcardSplit[1]))
22
+ .filter((file) => file.endsWith(wildcardSplit[1]))
23
23
  .forEach((file) => {
24
- return fs.cpSync(path.join(basePath, file), path.join(dest, file), options);
24
+ return fs.cpSync(
25
+ path.join(basePath, file),
26
+ path.join(dest, file),
27
+ options
28
+ );
25
29
  });
26
30
  }
27
31
 
@@ -69,8 +73,12 @@ fs.rmSync(path.join(libsDir, "tvos"), { recursive: true, force: true });
69
73
  fs.mkdirSync(path.join(libsDir, "ios"), { recursive: true });
70
74
  fs.mkdirSync(path.join(libsDir, "macos"), { recursive: true });
71
75
 
72
- copySync(iosPackage + '/libs/*.xcframework', path.join(libsDir, "ios"), {recursive: true});
73
- copySync(macosPackage + '/libs/*.xcframework', path.join(libsDir, "macos"), {recursive: true});
76
+ copySync(iosPackage + "/libs/*.xcframework", path.join(libsDir, "ios"), {
77
+ recursive: true,
78
+ });
79
+ copySync(macosPackage + "/libs/*.xcframework", path.join(libsDir, "macos"), {
80
+ recursive: true,
81
+ });
74
82
 
75
83
  // Handle tvOS (non-Graphite only)
76
84
  if (!useGraphite) {
@@ -80,7 +88,9 @@ if (!useGraphite) {
80
88
  );
81
89
  console.log("-- Skia tvOS package: " + tvosPackage);
82
90
  fs.mkdirSync(path.join(libsDir, "tvos"), { recursive: true });
83
- copySync(tvosPackage + '/libs/*.xcframework', path.join(libsDir, "tvos"), {recursive: true});
91
+ copySync(tvosPackage + "/libs/*.xcframework", path.join(libsDir, "tvos"), {
92
+ recursive: true,
93
+ });
84
94
  } catch (e) {
85
95
  console.log("-- tvOS package not found, skipping");
86
96
  }
@@ -118,6 +128,6 @@ console.log("-- Skia Android package: " + androidPackage);
118
128
  // Copy Android libs (per-ABI static libraries)
119
129
  const androidDest = path.join(libsDir, "android");
120
130
  fs.rmSync(androidDest, { recursive: true, force: true });
121
- copySync(androidSrcLibs, androidDest, {recursive: true});
131
+ copySync(androidSrcLibs, androidDest, { recursive: true });
122
132
 
123
133
  console.log("-- Copied Android libs to libs/android/");
@@ -9,12 +9,12 @@ const lerp = (
9
9
  from: number,
10
10
  to: number,
11
11
  p1: SkPath,
12
- p2: SkPath,
13
- output?: SkPath
12
+ p2: SkPath
14
13
  ) => {
15
14
  "worklet";
16
15
  const t = (value - from) / (to - from);
17
- return p2.interpolate(p1, t, output)!;
16
+ // interpolate returns a new path (immutable operation)
17
+ return p2.interpolate(p1, t)!;
18
18
  };
19
19
 
20
20
  /**
@@ -38,7 +38,7 @@ export const interpolatePaths = (
38
38
  input: number[],
39
39
  outputRange: SkPath[],
40
40
  options?: ExtrapolationType,
41
- output?: SkPath
41
+ _output?: SkPath
42
42
  ) => {
43
43
  "worklet";
44
44
  const extrapolation = validateInterpolationOptions(options);
@@ -86,7 +86,6 @@ export const interpolatePaths = (
86
86
  input[i],
87
87
  input[i + 1],
88
88
  outputRange[i],
89
- outputRange[i + 1],
90
- output
89
+ outputRange[i + 1]
91
90
  );
92
91
  };
@@ -5,7 +5,7 @@ import type {
5
5
  } from "react-native-reanimated";
6
6
  import { useCallback, useMemo } from "react";
7
7
 
8
- import type { SkPath, SkPoint } from "../../skia/types";
8
+ import type { SkPath, SkPathBuilder, SkPoint } from "../../skia/types";
9
9
  import { interpolatePaths, interpolateVector } from "../../animation";
10
10
  import { Skia } from "../../skia";
11
11
  import { isOnMainThread } from "../../renderer/Offscreen";
@@ -20,15 +20,35 @@ export const notifyChange = <T>(value: SharedValue<T>) => {
20
20
  }
21
21
  };
22
22
 
23
- export const usePathValue = (cb: (path: SkPath) => void, init?: SkPath) => {
23
+ /**
24
+ * Hook for creating animated paths using PathBuilder.
25
+ * The callback receives a mutable PathBuilder that can be used to construct the path.
26
+ * The resulting immutable SkPath is stored in a shared value.
27
+ *
28
+ * @param cb - Callback that receives the PathBuilder to construct the path
29
+ * @param init - Optional initial path to add to the builder
30
+ * @param transform - Optional transform function applied to the built path
31
+ */
32
+ export const usePathValue = (
33
+ cb: (builder: SkPathBuilder) => void,
34
+ init?: SkPath,
35
+ transform?: (path: SkPath) => SkPath
36
+ ) => {
37
+ const builderInit = useMemo(() => Skia.PathBuilder.Make(), []);
24
38
  const pathInit = useMemo(() => Skia.Path.Make(), []);
39
+ const builder = Rea.useSharedValue(builderInit);
25
40
  const path = Rea.useSharedValue(pathInit);
26
41
  Rea.useDerivedValue(() => {
27
- path.value.reset();
42
+ builder.value.reset();
28
43
  if (init !== undefined) {
29
- path.value.addPath(init);
44
+ builder.value.addPath(init);
45
+ }
46
+ cb(builder.value);
47
+ let result = builder.value.build();
48
+ if (transform !== undefined) {
49
+ result = transform(result);
30
50
  }
31
- cb(path.value);
51
+ path.value = result;
32
52
  notifyChange(path);
33
53
  });
34
54
  return path;
@@ -0,0 +1,303 @@
1
+ import type { SkRect } from "../Rect";
2
+ import type { SkPoint } from "../Point";
3
+ import type { InputRRect } from "../RRect";
4
+ import type { InputMatrix, SkMatrix } from "../Matrix";
5
+ import type { SkJSIInstance } from "../JsiInstance";
6
+
7
+ import type { FillType, SkPath } from "./Path";
8
+
9
+ /**
10
+ * SkPathBuilder is a mutable builder for constructing SkPath objects.
11
+ * Once construction is complete, call build() or detach() to get the immutable SkPath.
12
+ */
13
+ export interface SkPathBuilder extends SkJSIInstance<"PathBuilder"> {
14
+ // Movement methods
15
+
16
+ /**
17
+ * Adds beginning of contour at point (x, y).
18
+ * @param x - x-axis value of contour start
19
+ * @param y - y-axis value of contour start
20
+ * @returns reference to this PathBuilder for chaining
21
+ */
22
+ moveTo(x: number, y: number): SkPathBuilder;
23
+
24
+ /**
25
+ * Adds beginning of contour relative to the last point.
26
+ * @param x - offset from last point on x-axis
27
+ * @param y - offset from last point on y-axis
28
+ * @returns reference to this PathBuilder for chaining
29
+ */
30
+ rMoveTo(x: number, y: number): SkPathBuilder;
31
+
32
+ /**
33
+ * Adds line from last point to (x, y).
34
+ * @param x - end of line on x-axis
35
+ * @param y - end of line on y-axis
36
+ * @returns reference to this PathBuilder for chaining
37
+ */
38
+ lineTo(x: number, y: number): SkPathBuilder;
39
+
40
+ /**
41
+ * Adds line from last point, relative to last point.
42
+ * @param x - offset from last point on x-axis
43
+ * @param y - offset from last point on y-axis
44
+ * @returns reference to this PathBuilder for chaining
45
+ */
46
+ rLineTo(x: number, y: number): SkPathBuilder;
47
+
48
+ // Curve methods
49
+
50
+ /**
51
+ * Adds quad from last point towards (x1, y1), to (x2, y2).
52
+ */
53
+ quadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;
54
+
55
+ /**
56
+ * Relative version of quadTo.
57
+ */
58
+ rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;
59
+
60
+ /**
61
+ * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.
62
+ */
63
+ conicTo(
64
+ x1: number,
65
+ y1: number,
66
+ x2: number,
67
+ y2: number,
68
+ w: number
69
+ ): SkPathBuilder;
70
+
71
+ /**
72
+ * Relative version of conicTo.
73
+ */
74
+ rConicTo(
75
+ x1: number,
76
+ y1: number,
77
+ x2: number,
78
+ y2: number,
79
+ w: number
80
+ ): SkPathBuilder;
81
+
82
+ /**
83
+ * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3).
84
+ */
85
+ cubicTo(
86
+ x1: number,
87
+ y1: number,
88
+ x2: number,
89
+ y2: number,
90
+ x3: number,
91
+ y3: number
92
+ ): SkPathBuilder;
93
+
94
+ /**
95
+ * Relative version of cubicTo.
96
+ */
97
+ rCubicTo(
98
+ x1: number,
99
+ y1: number,
100
+ x2: number,
101
+ y2: number,
102
+ x3: number,
103
+ y3: number
104
+ ): SkPathBuilder;
105
+
106
+ /**
107
+ * Appends CLOSE_VERB to the builder, connecting first and last points.
108
+ */
109
+ close(): SkPathBuilder;
110
+
111
+ // Arc methods
112
+
113
+ /**
114
+ * Appends arc to the builder. Arc is part of ellipse bounded by oval.
115
+ * @param oval - bounds of ellipse containing arc
116
+ * @param startAngleInDegrees - starting angle of arc in degrees
117
+ * @param sweepAngleInDegrees - sweep, in degrees. Positive is clockwise
118
+ * @param forceMoveTo - true to start a new contour with arc
119
+ */
120
+ arcToOval(
121
+ oval: SkRect,
122
+ startAngleInDegrees: number,
123
+ sweepAngleInDegrees: number,
124
+ forceMoveTo: boolean
125
+ ): SkPathBuilder;
126
+
127
+ /**
128
+ * Appends arc to the builder with SVG-style parameters.
129
+ * @param rx - x-radius of ellipse
130
+ * @param ry - y-radius of ellipse
131
+ * @param xAxisRotateInDegrees - rotation of ellipse
132
+ * @param useSmallArc - if true, use smaller of two arcs
133
+ * @param isCCW - if true, arc sweeps counter-clockwise
134
+ * @param x - end point x
135
+ * @param y - end point y
136
+ */
137
+ arcToRotated(
138
+ rx: number,
139
+ ry: number,
140
+ xAxisRotateInDegrees: number,
141
+ useSmallArc: boolean,
142
+ isCCW: boolean,
143
+ x: number,
144
+ y: number
145
+ ): SkPathBuilder;
146
+
147
+ /**
148
+ * Relative version of arcToRotated.
149
+ */
150
+ rArcTo(
151
+ rx: number,
152
+ ry: number,
153
+ xAxisRotateInDegrees: number,
154
+ useSmallArc: boolean,
155
+ isCCW: boolean,
156
+ dx: number,
157
+ dy: number
158
+ ): SkPathBuilder;
159
+
160
+ /**
161
+ * Appends arc to the builder, tangent to two lines.
162
+ * @param x1 - x of first tangent point
163
+ * @param y1 - y of first tangent point
164
+ * @param x2 - x of second tangent point
165
+ * @param y2 - y of second tangent point
166
+ * @param radius - arc radius
167
+ */
168
+ arcToTangent(
169
+ x1: number,
170
+ y1: number,
171
+ x2: number,
172
+ y2: number,
173
+ radius: number
174
+ ): SkPathBuilder;
175
+
176
+ // Shape methods
177
+
178
+ /**
179
+ * Adds Rect to the builder.
180
+ * @param rect - rectangle to add
181
+ * @param isCCW - if true, draws counter-clockwise
182
+ */
183
+ addRect(rect: SkRect, isCCW?: boolean): SkPathBuilder;
184
+
185
+ /**
186
+ * Adds oval to the builder.
187
+ * @param oval - bounds of ellipse
188
+ * @param isCCW - if true, draws counter-clockwise
189
+ * @param startIndex - index of initial point
190
+ */
191
+ addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPathBuilder;
192
+
193
+ /**
194
+ * Appends arc to the builder as a new contour.
195
+ * @param oval - bounds of ellipse
196
+ * @param startAngleInDegrees - starting angle
197
+ * @param sweepAngleInDegrees - sweep angle
198
+ */
199
+ addArc(
200
+ oval: SkRect,
201
+ startAngleInDegrees: number,
202
+ sweepAngleInDegrees: number
203
+ ): SkPathBuilder;
204
+
205
+ /**
206
+ * Adds rounded rectangle to the builder.
207
+ * @param rrect - rounded rectangle to add
208
+ * @param isCCW - if true, draws counter-clockwise
209
+ */
210
+ addRRect(rrect: InputRRect, isCCW?: boolean): SkPathBuilder;
211
+
212
+ /**
213
+ * Adds circle to the builder.
214
+ * @param x - center x
215
+ * @param y - center y
216
+ * @param r - radius
217
+ * @param isCCW - if true, draws counter-clockwise
218
+ */
219
+ addCircle(x: number, y: number, r: number, isCCW?: boolean): SkPathBuilder;
220
+
221
+ /**
222
+ * Adds polygon to the builder from array of points.
223
+ * @param points - array of points
224
+ * @param close - if true, close the polygon
225
+ */
226
+ addPoly(points: SkPoint[], close: boolean): SkPathBuilder;
227
+
228
+ /**
229
+ * Adds the path to the builder.
230
+ * @param src - path to add
231
+ * @param matrix - optional transform matrix
232
+ * @param extend - if true, extend rather than append
233
+ */
234
+ addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPathBuilder;
235
+
236
+ // Configuration methods
237
+
238
+ /**
239
+ * Sets the fill type for the path.
240
+ * @param fill - fill type to set
241
+ */
242
+ setFillType(fill: FillType): SkPathBuilder;
243
+
244
+ /**
245
+ * Sets whether the path is volatile (temporary/animating).
246
+ * @param isVolatile - true if path will be altered frequently
247
+ */
248
+ setIsVolatile(isVolatile: boolean): SkPathBuilder;
249
+
250
+ /**
251
+ * Resets the builder to empty state.
252
+ */
253
+ reset(): SkPathBuilder;
254
+
255
+ /**
256
+ * Translates all points in the builder.
257
+ * @param dx - translation in x
258
+ * @param dy - translation in y
259
+ */
260
+ offset(dx: number, dy: number): SkPathBuilder;
261
+
262
+ /**
263
+ * Transforms all points in the builder by the matrix.
264
+ * @param m - transformation matrix
265
+ */
266
+ transform(m: InputMatrix): SkPathBuilder;
267
+
268
+ // Query methods
269
+
270
+ /**
271
+ * Returns the bounds of the path being built.
272
+ */
273
+ computeBounds(): SkRect;
274
+
275
+ /**
276
+ * Returns true if the builder has no verbs.
277
+ */
278
+ isEmpty(): boolean;
279
+
280
+ /**
281
+ * Returns the last point added to the builder.
282
+ */
283
+ getLastPt(): { x: number; y: number };
284
+
285
+ /**
286
+ * Returns the number of points in the builder.
287
+ */
288
+ countPoints(): number;
289
+
290
+ // Build methods
291
+
292
+ /**
293
+ * Returns a new SkPath with the current builder state.
294
+ * The builder is NOT reset and can continue to be used.
295
+ */
296
+ build(): SkPath;
297
+
298
+ /**
299
+ * Returns a new SkPath with the current builder state and resets the builder.
300
+ * More efficient than build() when you're done with this builder.
301
+ */
302
+ detach(): SkPath;
303
+ }
@@ -0,0 +1,15 @@
1
+ import type { SkPath } from "./Path";
2
+ import type { SkPathBuilder } from "./PathBuilder";
3
+
4
+ export interface PathBuilderFactory {
5
+ /**
6
+ * Creates a new empty PathBuilder.
7
+ */
8
+ Make(): SkPathBuilder;
9
+
10
+ /**
11
+ * Creates a new PathBuilder initialized with the given path's contents.
12
+ * @param path - path to copy into the builder
13
+ */
14
+ MakeFromPath(path: SkPath): SkPathBuilder;
15
+ }