@shopify/react-native-skia 0.1.214 → 0.1.216

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 (117) hide show
  1. package/cpp/api/JsiSkMatrix.h +31 -0
  2. package/cpp/api/JsiSkPath.h +15 -7
  3. package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  4. package/lib/commonjs/animation/functions/interpolatePaths.js +4 -4
  5. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  6. package/lib/commonjs/external/reanimated/index.d.ts +2 -1
  7. package/lib/commonjs/external/reanimated/index.js +17 -4
  8. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  9. package/lib/commonjs/external/reanimated/interpolators.d.ts +9 -0
  10. package/lib/commonjs/external/reanimated/interpolators.js +56 -0
  11. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -0
  12. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +8 -6
  13. package/lib/commonjs/external/reanimated/moduleWrapper.js +6 -11
  14. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  15. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +1 -0
  16. package/lib/commonjs/external/reanimated/renderHelpers.js +16 -3
  17. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  18. package/lib/commonjs/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  19. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +53 -0
  20. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -0
  21. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  22. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +2 -1
  23. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +1 -1
  24. package/lib/commonjs/mock/index.js +8 -0
  25. package/lib/commonjs/mock/index.js.map +1 -1
  26. package/lib/commonjs/renderer/HostConfig.js +6 -5
  27. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  28. package/lib/commonjs/skia/core/AnimatedImage.d.ts +0 -1
  29. package/lib/commonjs/skia/core/AnimatedImage.js +1 -45
  30. package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
  31. package/lib/commonjs/skia/types/Matrix.d.ts +4 -0
  32. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  33. package/lib/commonjs/skia/types/Path/Path.d.ts +10 -9
  34. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  35. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +6 -0
  36. package/lib/commonjs/skia/web/JsiSkMatrix.js +33 -5
  37. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkPath.d.ts +9 -9
  39. package/lib/commonjs/skia/web/JsiSkPath.js +15 -2
  40. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  41. package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  42. package/lib/module/animation/functions/interpolatePaths.js +4 -4
  43. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  44. package/lib/module/external/reanimated/index.d.ts +2 -1
  45. package/lib/module/external/reanimated/index.js +2 -1
  46. package/lib/module/external/reanimated/index.js.map +1 -1
  47. package/lib/module/external/reanimated/interpolators.d.ts +9 -0
  48. package/lib/module/external/reanimated/interpolators.js +34 -0
  49. package/lib/module/external/reanimated/interpolators.js.map +1 -0
  50. package/lib/module/external/reanimated/moduleWrapper.d.ts +8 -6
  51. package/lib/module/external/reanimated/moduleWrapper.js +4 -7
  52. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  53. package/lib/module/external/reanimated/renderHelpers.d.ts +1 -0
  54. package/lib/module/external/reanimated/renderHelpers.js +12 -3
  55. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  56. package/lib/module/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  57. package/lib/module/external/reanimated/useAnimatedImageValue.js +41 -0
  58. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -0
  59. package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  60. package/lib/module/external/reanimated/useDerivedValueOnJS.js +3 -2
  61. package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +1 -1
  62. package/lib/module/mock/index.js +8 -0
  63. package/lib/module/mock/index.js.map +1 -1
  64. package/lib/module/renderer/HostConfig.js +2 -1
  65. package/lib/module/renderer/HostConfig.js.map +1 -1
  66. package/lib/module/skia/core/AnimatedImage.d.ts +0 -1
  67. package/lib/module/skia/core/AnimatedImage.js +0 -40
  68. package/lib/module/skia/core/AnimatedImage.js.map +1 -1
  69. package/lib/module/skia/types/Matrix.d.ts +4 -0
  70. package/lib/module/skia/types/Matrix.js.map +1 -1
  71. package/lib/module/skia/types/Path/Path.d.ts +10 -9
  72. package/lib/module/skia/types/Path/Path.js.map +1 -1
  73. package/lib/module/skia/web/JsiSkMatrix.d.ts +6 -0
  74. package/lib/module/skia/web/JsiSkMatrix.js +33 -5
  75. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkPath.d.ts +9 -9
  77. package/lib/module/skia/web/JsiSkPath.js +15 -2
  78. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  79. package/lib/typescript/jestEnv.d.mts +5 -0
  80. package/lib/typescript/jestSetup.d.mts +1 -0
  81. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
  82. package/lib/typescript/src/external/reanimated/index.d.ts +2 -1
  83. package/lib/typescript/src/external/reanimated/interpolators.d.ts +9 -0
  84. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +8 -6
  85. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +1 -0
  86. package/lib/typescript/src/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  87. package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  88. package/lib/typescript/src/skia/core/AnimatedImage.d.ts +0 -1
  89. package/lib/typescript/src/skia/types/Matrix.d.ts +4 -0
  90. package/lib/typescript/src/skia/types/Path/Path.d.ts +10 -9
  91. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +6 -0
  92. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +9 -9
  93. package/package.json +4 -3
  94. package/src/animation/functions/interpolatePaths.ts +7 -4
  95. package/src/external/reanimated/index.ts +2 -1
  96. package/src/external/reanimated/interpolators.ts +89 -0
  97. package/src/external/reanimated/moduleWrapper.ts +33 -16
  98. package/src/external/reanimated/renderHelpers.ts +14 -5
  99. package/src/external/reanimated/useAnimatedImageValue.ts +51 -0
  100. package/src/external/reanimated/useDerivedValueOnJS.ts +4 -3
  101. package/src/mock/index.ts +5 -0
  102. package/src/renderer/HostConfig.ts +3 -1
  103. package/src/skia/core/AnimatedImage.ts +0 -47
  104. package/src/skia/types/Matrix.ts +4 -0
  105. package/src/skia/types/Path/Path.ts +10 -9
  106. package/src/skia/web/JsiSkMatrix.ts +33 -27
  107. package/src/skia/web/JsiSkPath.ts +15 -2
  108. package/globalJestSetup.js +0 -6
  109. package/lib/commonjs/external/reanimated/useSharedValueEffect.d.ts +0 -8
  110. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +0 -49
  111. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +0 -1
  112. package/lib/module/external/reanimated/useSharedValueEffect.d.ts +0 -8
  113. package/lib/module/external/reanimated/useSharedValueEffect.js +0 -39
  114. package/lib/module/external/reanimated/useSharedValueEffect.js.map +0 -1
  115. package/lib/typescript/globalJestSetup.d.ts +0 -2
  116. package/lib/typescript/src/external/reanimated/useSharedValueEffect.d.ts +0 -8
  117. package/src/external/reanimated/useSharedValueEffect.ts +0 -55
@@ -0,0 +1,51 @@
1
+ import type { FrameInfo } from "react-native-reanimated";
2
+
3
+ import { useAnimatedImage } from "../../skia/core/AnimatedImage";
4
+ import type { DataSourceParam, SkImage } from "../../skia/types";
5
+
6
+ import {
7
+ throwOnMissingReanimated,
8
+ useFrameCallback,
9
+ useSharedValue,
10
+ } from "./moduleWrapper";
11
+
12
+ const DEFAULT_FRAME_DURATION = 60;
13
+
14
+ export const useAnimatedImageValue = (source: DataSourceParam) => {
15
+ throwOnMissingReanimated();
16
+ const currentFrame = useSharedValue<null | SkImage>(null);
17
+ const lastTimestamp = useSharedValue(0);
18
+ const animatedImage = useAnimatedImage(source, (err) => {
19
+ console.error(err);
20
+ throw new Error(`Could not load animated image - got '${err.message}'`);
21
+ });
22
+ const frameDuration =
23
+ animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;
24
+
25
+ useFrameCallback((frameInfo: FrameInfo) => {
26
+ if (!animatedImage) {
27
+ currentFrame.value = null;
28
+ return;
29
+ }
30
+
31
+ const { timestamp } = frameInfo;
32
+ const elapsed = timestamp - lastTimestamp.value;
33
+
34
+ // Check if it's time to switch frames based on GIF frame duration
35
+ if (elapsed < frameDuration) {
36
+ return;
37
+ }
38
+
39
+ // Update the current frame
40
+ animatedImage.decodeNextFrame();
41
+ if (currentFrame.value) {
42
+ currentFrame.value.dispose();
43
+ }
44
+ currentFrame.value = animatedImage.getCurrentFrame();
45
+
46
+ // Update the last timestamp
47
+ lastTimestamp.value = timestamp;
48
+ // eslint-disable-next-line react-hooks/exhaustive-deps
49
+ }, true);
50
+ return currentFrame;
51
+ };
@@ -1,4 +1,4 @@
1
- import { useEffect, type DependencyList } from "react";
1
+ import { useEffect, useMemo } from "react";
2
2
 
3
3
  import {
4
4
  useSharedValue,
@@ -10,9 +10,10 @@ import {
10
10
  export const useDerivedValueOnJS = (
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  fn: () => any,
13
- deps?: DependencyList
13
+ deps: unknown[]
14
14
  ) => {
15
- const value = useSharedValue(fn());
15
+ const init = useMemo(() => fn(), [fn]);
16
+ const value = useSharedValue(init);
16
17
  useEffect(() => {
17
18
  const mapperId = startMapper(() => {
18
19
  "worklet";
package/src/mock/index.ts CHANGED
@@ -6,6 +6,7 @@ import { ValueApi } from "../values/web";
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
7
  const Noop: () => any = () => undefined;
8
8
  const NoopValue = () => ({ current: 0 });
9
+ const NoopSharedValue = () => ({ value: 0 });
9
10
 
10
11
  export const Mock = (CanvasKit: CanvasKit) => {
11
12
  global.SkiaApi = JsiSkApi(CanvasKit);
@@ -21,6 +22,7 @@ export const Mock = (CanvasKit: CanvasKit) => {
21
22
  ...require("../dom/nodes"),
22
23
  // We could use the real Canvas if we mock the SkiaView component for node
23
24
  Canvas: Noop,
25
+ // Skia Animations
24
26
  useValue: NoopValue,
25
27
  useComputedValue: NoopValue,
26
28
  useTouchHandler: Noop,
@@ -29,6 +31,9 @@ export const Mock = (CanvasKit: CanvasKit) => {
29
31
  useSpring: NoopValue,
30
32
  useClockValue: NoopValue,
31
33
  useValueEffect: Noop,
34
+ // Reanimated hooks
35
+ useClock: NoopSharedValue,
36
+ usePathInterpolation: NoopSharedValue,
32
37
  useRawData: Noop,
33
38
  useData: Noop,
34
39
  useFont: () => Skia.Font(undefined, 0),
@@ -7,7 +7,8 @@ import type { SkiaValue } from "../values";
7
7
  import {
8
8
  bindReanimatedProps,
9
9
  extractReanimatedProps,
10
- } from "../external/reanimated";
10
+ unbindReanimatedNode,
11
+ } from "../external/reanimated/renderHelpers";
11
12
 
12
13
  import type { Container } from "./Container";
13
14
  import { createNode } from "./HostComponents";
@@ -56,6 +57,7 @@ const appendNode = (parent: Node<unknown>, child: Node<unknown>) => {
56
57
  };
57
58
 
58
59
  const removeNode = (parent: Node<unknown>, child: Node<unknown>) => {
60
+ unbindReanimatedNode(child);
59
61
  return parent.removeChild(child);
60
62
  };
61
63
 
@@ -1,8 +1,3 @@
1
- import {
2
- throwOnMissingReanimated,
3
- useFrameCallback,
4
- useSharedValue,
5
- } from "../../external/reanimated/moduleWrapper";
6
1
  import { Skia } from "../Skia";
7
2
  import type { DataSourceParam } from "../types";
8
3
 
@@ -19,45 +14,3 @@ export const useAnimatedImage = (
19
14
  source: DataSourceParam,
20
15
  onError?: (err: Error) => void
21
16
  ) => useRawData(source, animatedImgFactory, onError);
22
-
23
- const DEFAULT_FRAME_DURATION = 60;
24
-
25
- export const useAnimatedImageValue = (source: DataSourceParam) => {
26
- throwOnMissingReanimated();
27
- const currentFrame = useSharedValue(null);
28
- const lastTimestamp = useSharedValue(0);
29
- const animatedImage = useAnimatedImage(source, (err) => {
30
- console.error(err);
31
- throw new Error(`Could not load animated image - got '${err.message}'`);
32
- });
33
- const frameDuration =
34
- animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;
35
-
36
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
- useFrameCallback((frameInfo: any) => {
38
- if (!animatedImage) {
39
- currentFrame.value = null;
40
- return;
41
- }
42
-
43
- const { timestamp } = frameInfo;
44
- const elapsed = timestamp - lastTimestamp.value;
45
-
46
- // Check if it's time to switch frames based on GIF frame duration
47
- if (elapsed < frameDuration) {
48
- return;
49
- }
50
-
51
- // Update the current frame
52
- animatedImage.decodeNextFrame();
53
- if (currentFrame.value) {
54
- currentFrame.value.dispose();
55
- }
56
- currentFrame.value = animatedImage.getCurrentFrame();
57
-
58
- // Update the last timestamp
59
- lastTimestamp.value = timestamp;
60
- // eslint-disable-next-line react-hooks/exhaustive-deps
61
- }, true);
62
- return currentFrame;
63
- };
@@ -21,6 +21,10 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
21
21
  scale: (x: number, y?: number) => SkMatrix;
22
22
  skew: (x: number, y: number) => SkMatrix;
23
23
  rotate: (theta: number) => SkMatrix;
24
+ postTranslate: (x: number, y: number) => SkMatrix;
25
+ postScale: (x: number, y?: number) => SkMatrix;
26
+ postSkew: (x: number, y: number) => SkMatrix;
27
+ postRotate: (theta: number) => SkMatrix;
24
28
  identity: () => SkMatrix;
25
29
  get: () => number[];
26
30
  }
@@ -213,7 +213,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
213
213
  * Sets FillType, the rule used to fill Path.
214
214
  * @param fill
215
215
  */
216
- setFillType(fill: FillType): void;
216
+ setFillType(fill: FillType): SkPath;
217
217
 
218
218
  /**
219
219
  * Specifies whether Path is volatile; whether it will be altered or discarded
@@ -223,7 +223,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
223
223
  * Mark unchanging Path non-volatile to improve repeated rendering.
224
224
  * @param volatile
225
225
  */
226
- setIsVolatile(volatile: boolean): void;
226
+ setIsVolatile(volatile: boolean): SkPath;
227
227
 
228
228
  /**
229
229
  * Turns this path into the filled equivalent of the stroked path. Returns false if the operation
@@ -237,14 +237,14 @@ export interface SkPath extends SkJSIInstance<"Path"> {
237
237
  * Appends CLOSE_VERB to Path. A closed contour connects the first and last point
238
238
  * with a line, forming a continuous loop.
239
239
  */
240
- close(): void;
240
+ close(): SkPath;
241
241
 
242
242
  /**
243
243
  * Sets Path to its initial state.
244
244
  * Removes verb array, point array, and weights, and sets FillType to Winding.
245
245
  * Internal storage associated with Path is released
246
246
  */
247
- reset(): void;
247
+ reset(): SkPath;
248
248
 
249
249
  /**
250
250
  * Sets Path to its initial state.
@@ -253,7 +253,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
253
253
  * Use rewind() instead of reset() if Path storage will be reused and performance
254
254
  * is critical.
255
255
  */
256
- rewind(): void;
256
+ rewind(): SkPath;
257
257
 
258
258
  /**
259
259
  * Returns minimum and maximum axes values of the lines and curves in Path.
@@ -420,7 +420,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
420
420
  reference to SkPath
421
421
  example: https://fiddle.skia.org/c/@Path_quadTo
422
422
  */
423
- quadTo(x1: number, y1: number, x2: number, y2: number): void;
423
+ quadTo(x1: number, y1: number, x2: number, y2: number): SkPath;
424
424
 
425
425
  /**
426
426
  * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,
@@ -431,7 +431,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
431
431
  * @param rect
432
432
  * @param isCCW
433
433
  */
434
- addRect(rect: SkRect, isCCW?: boolean): void;
434
+ addRect(rect: SkRect, isCCW?: boolean): SkPath;
435
435
 
436
436
  /**
437
437
  * Adds rrect to Path, creating a new closed contour.
@@ -540,7 +540,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
540
540
  /**
541
541
  * Transforms the path by the specified matrix.
542
542
  */
543
- transform(m3: SkMatrix): void;
543
+ transform(m3: SkMatrix): SkPath;
544
544
 
545
545
  /**
546
546
  * Interpolates between Path with point array of equal size.
@@ -558,10 +558,11 @@ export interface SkPath extends SkJSIInstance<"Path"> {
558
558
  * @param ending path to interpolate with
559
559
  * @param weight contribution of this path, and
560
560
  * one minus contribution of ending path
561
+ * @param output path to be replaced with the interpolated averages
561
562
  * @return Path replaced by interpolated averages or null if
562
563
  * not interpolatable
563
564
  * */
564
- interpolate(end: SkPath, weight: number): SkPath | null;
565
+ interpolate(end: SkPath, weight: number, output?: SkPath): SkPath | null;
565
566
 
566
567
  /** Returns true if Path contain equal verbs and equal weights.
567
568
  * @param compare path to compare
@@ -12,54 +12,60 @@ export class JsiSkMatrix
12
12
  super(CanvasKit, ref, "Matrix");
13
13
  }
14
14
 
15
+ private preMultiply(matrix: number[]) {
16
+ this.ref.set(this.CanvasKit.Matrix.multiply(this.ref, matrix));
17
+ }
18
+
19
+ private postMultiply(matrix: number[]) {
20
+ this.ref.set(this.CanvasKit.Matrix.multiply(matrix, this.ref));
21
+ }
22
+
15
23
  dispose = () => {
16
24
  // Do nothing - the matrix is represenetd by a Float32Array
17
25
  };
18
26
 
19
27
  concat(matrix: SkMatrix) {
20
- this.ref.set(
21
- this.CanvasKit.Matrix.multiply(this.ref, JsiSkMatrix.fromValue(matrix))
22
- );
28
+ this.preMultiply(JsiSkMatrix.fromValue(matrix));
23
29
  return this;
24
30
  }
25
31
 
26
32
  translate(x: number, y: number) {
27
- this.concat(
28
- new JsiSkMatrix(
29
- this.CanvasKit,
30
- Float32Array.of(...this.CanvasKit.Matrix.translated(x, y))
31
- )
32
- );
33
+ this.preMultiply(this.CanvasKit.Matrix.translated(x, y));
34
+ return this;
35
+ }
36
+
37
+ postTranslate(x: number, y: number) {
38
+ this.postMultiply(this.CanvasKit.Matrix.translated(x, y));
33
39
  return this;
34
40
  }
35
41
 
36
42
  scale(x: number, y?: number) {
37
- this.concat(
38
- new JsiSkMatrix(
39
- this.CanvasKit,
40
- Float32Array.of(...this.CanvasKit.Matrix.scaled(x, y ?? x))
41
- )
42
- );
43
+ this.preMultiply(this.CanvasKit.Matrix.scaled(x, y ?? x));
44
+ return this;
45
+ }
46
+
47
+ postScale(x: number, y?: number) {
48
+ this.postMultiply(this.CanvasKit.Matrix.scaled(x, y ?? x));
43
49
  return this;
44
50
  }
45
51
 
46
52
  skew(x: number, y: number) {
47
- this.concat(
48
- new JsiSkMatrix(
49
- this.CanvasKit,
50
- Float32Array.of(...this.CanvasKit.Matrix.skewed(x, y))
51
- )
52
- );
53
+ this.preMultiply(this.CanvasKit.Matrix.skewed(x, y));
54
+ return this;
55
+ }
56
+
57
+ postSkew(x: number, y: number) {
58
+ this.postMultiply(this.CanvasKit.Matrix.skewed(x, y));
53
59
  return this;
54
60
  }
55
61
 
56
62
  rotate(value: number) {
57
- this.concat(
58
- new JsiSkMatrix(
59
- this.CanvasKit,
60
- Float32Array.of(...this.CanvasKit.Matrix.rotated(value))
61
- )
62
- );
63
+ this.preMultiply(this.CanvasKit.Matrix.rotated(value));
64
+ return this;
65
+ }
66
+
67
+ postRotate(value: number) {
68
+ this.postMultiply(this.CanvasKit.Matrix.rotated(value));
63
69
  return this;
64
70
  }
65
71
 
@@ -150,10 +150,12 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
150
150
 
151
151
  setFillType(fill: FillType) {
152
152
  this.ref.setFillType(ckEnum(fill));
153
+ return this;
153
154
  }
154
155
 
155
156
  setIsVolatile(volatile: boolean) {
156
157
  this.ref.setIsVolatile(volatile);
158
+ return this;
157
159
  }
158
160
 
159
161
  stroke(opts?: StrokeOpts) {
@@ -174,14 +176,17 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
174
176
 
175
177
  close() {
176
178
  this.ref.close();
179
+ return this;
177
180
  }
178
181
 
179
182
  reset() {
180
183
  this.ref.reset();
184
+ return this;
181
185
  }
182
186
 
183
187
  rewind() {
184
188
  this.ref.rewind();
189
+ return this;
185
190
  }
186
191
 
187
192
  computeTightBounds(): SkRect {
@@ -272,10 +277,12 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
272
277
 
273
278
  quadTo(x1: number, y1: number, x2: number, y2: number) {
274
279
  this.ref.quadTo(x1, y1, x2, y2);
280
+ return this;
275
281
  }
276
282
 
277
283
  addRect(rect: SkRect, isCCW?: boolean) {
278
284
  this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);
285
+ return this;
279
286
  }
280
287
 
281
288
  addRRect(rrect: SkRRect, isCCW?: boolean) {
@@ -331,9 +338,10 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
331
338
 
332
339
  transform(m3: SkMatrix) {
333
340
  this.ref.transform(JsiSkMatrix.fromValue(m3));
341
+ return this;
334
342
  }
335
343
 
336
- interpolate(end: SkPath, t: number) {
344
+ interpolate(end: SkPath, t: number, output?: SkPath) {
337
345
  const path = this.CanvasKit.Path.MakeFromPathInterpolation(
338
346
  this.ref,
339
347
  JsiSkPath.fromValue(end),
@@ -342,7 +350,12 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
342
350
  if (path === null) {
343
351
  return null;
344
352
  }
345
- return new JsiSkPath(this.CanvasKit, path);
353
+ if (output) {
354
+ (output as JsiSkPath).ref = path;
355
+ return output;
356
+ } else {
357
+ return new JsiSkPath(this.CanvasKit, path);
358
+ }
346
359
  }
347
360
 
348
361
  isInterpolatable(path2: SkPath): boolean {
@@ -1,6 +0,0 @@
1
- module.exports = async () => {
2
- const {
3
- LoadSkiaWeb,
4
- } = require("@shopify/react-native-skia/lib/commonjs/web/LoadSkiaWeb");
5
- await LoadSkiaWeb();
6
- };
@@ -1,8 +0,0 @@
1
- import type { SharedValueType } from "../../renderer/processors/Animations";
2
- /**
3
- * Connects a shared value from reanimated to a SkiaView or Canvas
4
- * so whenever the shared value changes the SkiaView will redraw.
5
- * @param cb Callback that will be called whenever the shared value changes.
6
- * @param values One or more shared values to listen for.
7
- */
8
- export declare const useSharedValueEffect: <T = number>(cb: () => void, value: SharedValueType<T>, ...values: SharedValueType<T>[]) => void;
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useSharedValueEffect = void 0;
7
-
8
- var _react = require("react");
9
-
10
- var _moduleWrapper = require("./moduleWrapper");
11
-
12
- /**
13
- * Connects a shared value from reanimated to a SkiaView or Canvas
14
- * so whenever the shared value changes the SkiaView will redraw.
15
- * @param cb Callback that will be called whenever the shared value changes.
16
- * @param values One or more shared values to listen for.
17
- */
18
- const useSharedValueEffect = function (cb, value) {
19
- for (var _len = arguments.length, values = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
20
- values[_key - 2] = arguments[_key];
21
- }
22
-
23
- console.warn(`useSharedValueEffect() is deprecated and will be removed in the next release
24
- Learn more at https://shopify.github.io/react-native-skia/docs/animations/animations.`);
25
- const input = (0, _moduleWrapper.useSharedValue)(0);
26
- (0, _react.useEffect)(() => {
27
- if (!_moduleWrapper.HAS_REANIMATED2) {
28
- console.warn("Reanimated was not found and the useSharedValueEffect hook will have no effect.");
29
- } else {
30
- // Start a mapper in Reanimated
31
- const mapperId = (0, _moduleWrapper.startMapper)(() => {
32
- "worklet";
33
-
34
- (0, _moduleWrapper.runOnJS)(cb)();
35
- }, [value, ...values], [input]); // Return unregistering the mapper
36
-
37
- return () => {
38
- if (_moduleWrapper.stopMapper && mapperId !== undefined) {
39
- (0, _moduleWrapper.stopMapper)(mapperId);
40
- }
41
- };
42
- }
43
-
44
- return () => {}; // eslint-disable-next-line react-hooks/exhaustive-deps
45
- }, [input, value, ...values]);
46
- };
47
-
48
- exports.useSharedValueEffect = useSharedValueEffect;
49
- //# sourceMappingURL=useSharedValueEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useSharedValueEffect","cb","value","values","console","warn","input","useSharedValue","useEffect","HAS_REANIMATED2","mapperId","startMapper","runOnJS","stopMapper","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED2,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n console.warn(\n `useSharedValueEffect() is deprecated and will be removed in the next release\nLearn more at https://shopify.github.io/react-native-skia/docs/animations/animations.`\n );\n const input = useSharedValue(0);\n\n useEffect(() => {\n if (!HAS_REANIMATED2) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACHC,OAAO,CAACC,IAAR,CACG;AACL,sFAFE;EAIA,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAe,CAAf,CAAd;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACd,IAAI,CAACC,8BAAL,EAAsB;MACpBL,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAMK,QAAQ,GAAG,IAAAC,0BAAA,EACf,MAAM;QACJ;;QACA,IAAAC,sBAAA,EAAQX,EAAR;MACD,CAJc,EAKf,CAACC,KAAD,EAAQ,GAAGC,MAAX,CALe,EAMf,CAACG,KAAD,CANe,CAAjB,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIO,yBAAA,IAAcH,QAAQ,KAAKI,SAA/B,EAA0C;UACxC,IAAAD,yBAAA,EAAWH,QAAX;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBD,EAwBG,CAACJ,KAAD,EAAQJ,KAAR,EAAe,GAAGC,MAAlB,CAxBH;AAyBD,CApCM"}
@@ -1,8 +0,0 @@
1
- import type { SharedValueType } from "../../renderer/processors/Animations";
2
- /**
3
- * Connects a shared value from reanimated to a SkiaView or Canvas
4
- * so whenever the shared value changes the SkiaView will redraw.
5
- * @param cb Callback that will be called whenever the shared value changes.
6
- * @param values One or more shared values to listen for.
7
- */
8
- export declare const useSharedValueEffect: <T = number>(cb: () => void, value: SharedValueType<T>, ...values: SharedValueType<T>[]) => void;
@@ -1,39 +0,0 @@
1
- import { useEffect } from "react";
2
- import { HAS_REANIMATED2, useSharedValue, runOnJS, startMapper, stopMapper } from "./moduleWrapper";
3
- /**
4
- * Connects a shared value from reanimated to a SkiaView or Canvas
5
- * so whenever the shared value changes the SkiaView will redraw.
6
- * @param cb Callback that will be called whenever the shared value changes.
7
- * @param values One or more shared values to listen for.
8
- */
9
-
10
- export const useSharedValueEffect = function (cb, value) {
11
- for (var _len = arguments.length, values = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
12
- values[_key - 2] = arguments[_key];
13
- }
14
-
15
- console.warn(`useSharedValueEffect() is deprecated and will be removed in the next release
16
- Learn more at https://shopify.github.io/react-native-skia/docs/animations/animations.`);
17
- const input = useSharedValue(0);
18
- useEffect(() => {
19
- if (!HAS_REANIMATED2) {
20
- console.warn("Reanimated was not found and the useSharedValueEffect hook will have no effect.");
21
- } else {
22
- // Start a mapper in Reanimated
23
- const mapperId = startMapper(() => {
24
- "worklet";
25
-
26
- runOnJS(cb)();
27
- }, [value, ...values], [input]); // Return unregistering the mapper
28
-
29
- return () => {
30
- if (stopMapper && mapperId !== undefined) {
31
- stopMapper(mapperId);
32
- }
33
- };
34
- }
35
-
36
- return () => {}; // eslint-disable-next-line react-hooks/exhaustive-deps
37
- }, [input, value, ...values]);
38
- };
39
- //# sourceMappingURL=useSharedValueEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","HAS_REANIMATED2","useSharedValue","runOnJS","startMapper","stopMapper","useSharedValueEffect","cb","value","values","console","warn","input","mapperId","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED2,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n console.warn(\n `useSharedValueEffect() is deprecated and will be removed in the next release\nLearn more at https://shopify.github.io/react-native-skia/docs/animations/animations.`\n );\n const input = useSharedValue(0);\n\n useEffect(() => {\n if (!HAS_REANIMATED2) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AAIA,SACEC,eADF,EAEEC,cAFF,EAGEC,OAHF,EAIEC,WAJF,EAKEC,UALF,QAMO,iBANP;AAQA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACHC,OAAO,CAACC,IAAR,CACG;AACL,sFAFE;EAIA,MAAMC,KAAK,GAAGV,cAAc,CAAC,CAAD,CAA5B;EAEAF,SAAS,CAAC,MAAM;IACd,IAAI,CAACC,eAAL,EAAsB;MACpBS,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAME,QAAQ,GAAGT,WAAW,CAC1B,MAAM;QACJ;;QACAD,OAAO,CAACI,EAAD,CAAP;MACD,CAJyB,EAK1B,CAACC,KAAD,EAAQ,GAAGC,MAAX,CAL0B,EAM1B,CAACG,KAAD,CAN0B,CAA5B,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIP,UAAU,IAAIQ,QAAQ,KAAKC,SAA/B,EAA0C;UACxCT,UAAU,CAACQ,QAAD,CAAV;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBQ,EAwBN,CAACD,KAAD,EAAQJ,KAAR,EAAe,GAAGC,MAAlB,CAxBM,CAAT;AAyBD,CApCM"}
@@ -1,2 +0,0 @@
1
- declare function _exports(): Promise<void>;
2
- export = _exports;
@@ -1,8 +0,0 @@
1
- import type { SharedValueType } from "../../renderer/processors/Animations";
2
- /**
3
- * Connects a shared value from reanimated to a SkiaView or Canvas
4
- * so whenever the shared value changes the SkiaView will redraw.
5
- * @param cb Callback that will be called whenever the shared value changes.
6
- * @param values One or more shared values to listen for.
7
- */
8
- export declare const useSharedValueEffect: <T = number>(cb: () => void, value: SharedValueType<T>, ...values: SharedValueType<T>[]) => void;
@@ -1,55 +0,0 @@
1
- import { useEffect } from "react";
2
-
3
- import type { SharedValueType } from "../../renderer/processors/Animations";
4
-
5
- import {
6
- HAS_REANIMATED2,
7
- useSharedValue,
8
- runOnJS,
9
- startMapper,
10
- stopMapper,
11
- } from "./moduleWrapper";
12
-
13
- /**
14
- * Connects a shared value from reanimated to a SkiaView or Canvas
15
- * so whenever the shared value changes the SkiaView will redraw.
16
- * @param cb Callback that will be called whenever the shared value changes.
17
- * @param values One or more shared values to listen for.
18
- */
19
- export const useSharedValueEffect = <T = number>(
20
- cb: () => void,
21
- value: SharedValueType<T>,
22
- ...values: SharedValueType<T>[]
23
- ) => {
24
- console.warn(
25
- `useSharedValueEffect() is deprecated and will be removed in the next release
26
- Learn more at https://shopify.github.io/react-native-skia/docs/animations/animations.`
27
- );
28
- const input = useSharedValue(0);
29
-
30
- useEffect(() => {
31
- if (!HAS_REANIMATED2) {
32
- console.warn(
33
- "Reanimated was not found and the useSharedValueEffect hook will have no effect."
34
- );
35
- } else {
36
- // Start a mapper in Reanimated
37
- const mapperId = startMapper(
38
- () => {
39
- "worklet";
40
- runOnJS(cb)();
41
- },
42
- [value, ...values],
43
- [input]
44
- );
45
- // Return unregistering the mapper
46
- return () => {
47
- if (stopMapper && mapperId !== undefined) {
48
- stopMapper(mapperId);
49
- }
50
- };
51
- }
52
- return () => {};
53
- // eslint-disable-next-line react-hooks/exhaustive-deps
54
- }, [input, value, ...values]);
55
- };