@shopify/react-native-skia 0.1.214 → 0.1.215

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) 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.js.map +1 -1
  16. package/lib/commonjs/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  17. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +53 -0
  18. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -0
  19. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  20. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +2 -1
  21. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +1 -1
  22. package/lib/commonjs/mock/index.js +8 -0
  23. package/lib/commonjs/mock/index.js.map +1 -1
  24. package/lib/commonjs/renderer/HostConfig.js +5 -5
  25. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  26. package/lib/commonjs/skia/core/AnimatedImage.d.ts +0 -1
  27. package/lib/commonjs/skia/core/AnimatedImage.js +1 -45
  28. package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
  29. package/lib/commonjs/skia/types/Matrix.d.ts +4 -0
  30. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  31. package/lib/commonjs/skia/types/Path/Path.d.ts +10 -9
  32. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  33. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +6 -0
  34. package/lib/commonjs/skia/web/JsiSkMatrix.js +33 -5
  35. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  36. package/lib/commonjs/skia/web/JsiSkPath.d.ts +9 -9
  37. package/lib/commonjs/skia/web/JsiSkPath.js +15 -2
  38. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  39. package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  40. package/lib/module/animation/functions/interpolatePaths.js +4 -4
  41. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  42. package/lib/module/external/reanimated/index.d.ts +2 -1
  43. package/lib/module/external/reanimated/index.js +2 -1
  44. package/lib/module/external/reanimated/index.js.map +1 -1
  45. package/lib/module/external/reanimated/interpolators.d.ts +9 -0
  46. package/lib/module/external/reanimated/interpolators.js +34 -0
  47. package/lib/module/external/reanimated/interpolators.js.map +1 -0
  48. package/lib/module/external/reanimated/moduleWrapper.d.ts +8 -6
  49. package/lib/module/external/reanimated/moduleWrapper.js +4 -7
  50. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  51. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  52. package/lib/module/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  53. package/lib/module/external/reanimated/useAnimatedImageValue.js +41 -0
  54. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -0
  55. package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  56. package/lib/module/external/reanimated/useDerivedValueOnJS.js +3 -2
  57. package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +1 -1
  58. package/lib/module/mock/index.js +8 -0
  59. package/lib/module/mock/index.js.map +1 -1
  60. package/lib/module/renderer/HostConfig.js +1 -1
  61. package/lib/module/renderer/HostConfig.js.map +1 -1
  62. package/lib/module/skia/core/AnimatedImage.d.ts +0 -1
  63. package/lib/module/skia/core/AnimatedImage.js +0 -40
  64. package/lib/module/skia/core/AnimatedImage.js.map +1 -1
  65. package/lib/module/skia/types/Matrix.d.ts +4 -0
  66. package/lib/module/skia/types/Matrix.js.map +1 -1
  67. package/lib/module/skia/types/Path/Path.d.ts +10 -9
  68. package/lib/module/skia/types/Path/Path.js.map +1 -1
  69. package/lib/module/skia/web/JsiSkMatrix.d.ts +6 -0
  70. package/lib/module/skia/web/JsiSkMatrix.js +33 -5
  71. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  72. package/lib/module/skia/web/JsiSkPath.d.ts +9 -9
  73. package/lib/module/skia/web/JsiSkPath.js +15 -2
  74. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  75. package/lib/typescript/jestEnv.d.mts +5 -0
  76. package/lib/typescript/jestSetup.d.mts +1 -0
  77. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
  78. package/lib/typescript/src/external/reanimated/index.d.ts +2 -1
  79. package/lib/typescript/src/external/reanimated/interpolators.d.ts +9 -0
  80. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +8 -6
  81. package/lib/typescript/src/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  82. package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  83. package/lib/typescript/src/skia/core/AnimatedImage.d.ts +0 -1
  84. package/lib/typescript/src/skia/types/Matrix.d.ts +4 -0
  85. package/lib/typescript/src/skia/types/Path/Path.d.ts +10 -9
  86. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +6 -0
  87. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +9 -9
  88. package/package.json +4 -3
  89. package/src/animation/functions/interpolatePaths.ts +7 -4
  90. package/src/external/reanimated/index.ts +2 -1
  91. package/src/external/reanimated/interpolators.ts +89 -0
  92. package/src/external/reanimated/moduleWrapper.ts +33 -16
  93. package/src/external/reanimated/renderHelpers.ts +2 -2
  94. package/src/external/reanimated/useAnimatedImageValue.ts +51 -0
  95. package/src/external/reanimated/useDerivedValueOnJS.ts +4 -3
  96. package/src/mock/index.ts +5 -0
  97. package/src/renderer/HostConfig.ts +1 -1
  98. package/src/skia/core/AnimatedImage.ts +0 -47
  99. package/src/skia/types/Matrix.ts +4 -0
  100. package/src/skia/types/Path/Path.ts +10 -9
  101. package/src/skia/web/JsiSkMatrix.ts +33 -27
  102. package/src/skia/web/JsiSkPath.ts +15 -2
  103. package/globalJestSetup.js +0 -6
  104. package/lib/commonjs/external/reanimated/useSharedValueEffect.d.ts +0 -8
  105. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +0 -49
  106. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +0 -1
  107. package/lib/module/external/reanimated/useSharedValueEffect.d.ts +0 -8
  108. package/lib/module/external/reanimated/useSharedValueEffect.js +0 -39
  109. package/lib/module/external/reanimated/useSharedValueEffect.js.map +0 -1
  110. package/lib/typescript/globalJestSetup.d.ts +0 -2
  111. package/lib/typescript/src/external/reanimated/useSharedValueEffect.d.ts +0 -8
  112. package/src/external/reanimated/useSharedValueEffect.ts +0 -55
@@ -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
- };