@shopify/react-native-skia 0.1.214 → 0.1.216
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkMatrix.h +31 -0
- package/cpp/api/JsiSkPath.h +15 -7
- package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +4 -4
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/external/reanimated/index.d.ts +2 -1
- package/lib/commonjs/external/reanimated/index.js +17 -4
- package/lib/commonjs/external/reanimated/index.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +9 -0
- package/lib/commonjs/external/reanimated/interpolators.js +56 -0
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -0
- package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +8 -6
- package/lib/commonjs/external/reanimated/moduleWrapper.js +6 -11
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +1 -0
- package/lib/commonjs/external/reanimated/renderHelpers.js +16 -3
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.d.ts +2 -0
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +53 -0
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -0
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +2 -1
- package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +1 -1
- package/lib/commonjs/mock/index.js +8 -0
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +6 -5
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.d.ts +0 -1
- package/lib/commonjs/skia/core/AnimatedImage.js +1 -45
- package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix.d.ts +4 -0
- package/lib/commonjs/skia/types/Matrix.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.d.ts +10 -9
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +6 -0
- package/lib/commonjs/skia/web/JsiSkMatrix.js +33 -5
- package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +9 -9
- package/lib/commonjs/skia/web/JsiSkPath.js +15 -2
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +4 -4
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/external/reanimated/index.d.ts +2 -1
- package/lib/module/external/reanimated/index.js +2 -1
- package/lib/module/external/reanimated/index.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +9 -0
- package/lib/module/external/reanimated/interpolators.js +34 -0
- package/lib/module/external/reanimated/interpolators.js.map +1 -0
- package/lib/module/external/reanimated/moduleWrapper.d.ts +8 -6
- package/lib/module/external/reanimated/moduleWrapper.js +4 -7
- package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +1 -0
- package/lib/module/external/reanimated/renderHelpers.js +12 -3
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/external/reanimated/useAnimatedImageValue.d.ts +2 -0
- package/lib/module/external/reanimated/useAnimatedImageValue.js +41 -0
- package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -0
- package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
- package/lib/module/external/reanimated/useDerivedValueOnJS.js +3 -2
- package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +1 -1
- package/lib/module/mock/index.js +8 -0
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +2 -1
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/skia/core/AnimatedImage.d.ts +0 -1
- package/lib/module/skia/core/AnimatedImage.js +0 -40
- package/lib/module/skia/core/AnimatedImage.js.map +1 -1
- package/lib/module/skia/types/Matrix.d.ts +4 -0
- package/lib/module/skia/types/Matrix.js.map +1 -1
- package/lib/module/skia/types/Path/Path.d.ts +10 -9
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.d.ts +6 -0
- package/lib/module/skia/web/JsiSkMatrix.js +33 -5
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +9 -9
- package/lib/module/skia/web/JsiSkPath.js +15 -2
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/typescript/jestEnv.d.mts +5 -0
- package/lib/typescript/jestSetup.d.mts +1 -0
- package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/index.d.ts +2 -1
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +9 -0
- package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +8 -6
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/useAnimatedImageValue.d.ts +2 -0
- package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
- package/lib/typescript/src/skia/core/AnimatedImage.d.ts +0 -1
- package/lib/typescript/src/skia/types/Matrix.d.ts +4 -0
- package/lib/typescript/src/skia/types/Path/Path.d.ts +10 -9
- package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +6 -0
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +9 -9
- package/package.json +4 -3
- package/src/animation/functions/interpolatePaths.ts +7 -4
- package/src/external/reanimated/index.ts +2 -1
- package/src/external/reanimated/interpolators.ts +89 -0
- package/src/external/reanimated/moduleWrapper.ts +33 -16
- package/src/external/reanimated/renderHelpers.ts +14 -5
- package/src/external/reanimated/useAnimatedImageValue.ts +51 -0
- package/src/external/reanimated/useDerivedValueOnJS.ts +4 -3
- package/src/mock/index.ts +5 -0
- package/src/renderer/HostConfig.ts +3 -1
- package/src/skia/core/AnimatedImage.ts +0 -47
- package/src/skia/types/Matrix.ts +4 -0
- package/src/skia/types/Path/Path.ts +10 -9
- package/src/skia/web/JsiSkMatrix.ts +33 -27
- package/src/skia/web/JsiSkPath.ts +15 -2
- package/globalJestSetup.js +0 -6
- package/lib/commonjs/external/reanimated/useSharedValueEffect.d.ts +0 -8
- package/lib/commonjs/external/reanimated/useSharedValueEffect.js +0 -49
- package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +0 -1
- package/lib/module/external/reanimated/useSharedValueEffect.d.ts +0 -8
- package/lib/module/external/reanimated/useSharedValueEffect.js +0 -39
- package/lib/module/external/reanimated/useSharedValueEffect.js.map +0 -1
- package/lib/typescript/globalJestSetup.d.ts +0 -2
- package/lib/typescript/src/external/reanimated/useSharedValueEffect.d.ts +0 -8
- 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,
|
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
|
13
|
+
deps: unknown[]
|
14
14
|
) => {
|
15
|
-
const
|
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
|
-
|
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
|
-
};
|
package/src/skia/types/Matrix.ts
CHANGED
@@ -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):
|
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):
|
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():
|
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():
|
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():
|
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):
|
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):
|
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):
|
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.
|
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.
|
28
|
-
|
29
|
-
|
30
|
-
|
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.
|
38
|
-
|
39
|
-
|
40
|
-
|
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.
|
48
|
-
|
49
|
-
|
50
|
-
|
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.
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
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 {
|
package/globalJestSetup.js
DELETED
@@ -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,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
|
-
};
|