@shopify/react-native-skia 0.1.156 → 0.1.158
Sign up to get free protection for your applications and to get access to all the features.
- package/android/build.gradle +10 -5
- package/cpp/api/JsiSkContourMeasure.h +7 -5
- package/lib/commonjs/dom/nodes/DrawingNode.js +1 -5
- package/lib/commonjs/dom/nodes/DrawingNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.js +2 -8
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Text.js +4 -9
- package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +10 -2
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +10 -1
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/renderer/components/Mask.js +1 -3
- package/lib/commonjs/renderer/components/Mask.js.map +1 -1
- package/lib/commonjs/renderer/components/Paint.js +5 -18
- package/lib/commonjs/renderer/components/Paint.js.map +1 -1
- package/lib/commonjs/renderer/useCanvas.js +18 -2
- package/lib/commonjs/renderer/useCanvas.js.map +1 -1
- package/lib/commonjs/skia/core/Picture.js +1 -24
- package/lib/commonjs/skia/core/Picture.js.map +1 -1
- package/lib/commonjs/skia/core/Rect.js +1 -1
- package/lib/commonjs/skia/core/Rect.js.map +1 -1
- package/lib/commonjs/skia/types/ContourMeasure.js.map +1 -1
- package/lib/commonjs/skia/types/Size.js +2 -0
- package/lib/commonjs/skia/types/Size.js.map +1 -0
- package/lib/commonjs/skia/types/index.js +13 -0
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColor.js +8 -0
- package/lib/commonjs/skia/web/JsiSkColor.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -7
- package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/commonjs/values/web/RNSkReadonlyValue.js +4 -2
- package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.js +2 -2
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/animation/spring/runSpring.js +1 -1
- package/lib/module/animation/spring/runSpring.js.map +1 -1
- package/lib/module/animation/spring/useSpring.js +1 -1
- package/lib/module/animation/spring/useSpring.js.map +1 -1
- package/lib/module/animation/timing/createTiming.js +6 -2
- package/lib/module/animation/timing/createTiming.js.map +1 -1
- package/lib/module/animation/timing/functions/getResolvedParams.js +10 -6
- package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -1
- package/lib/module/animation/timing/useTiming.js +3 -1
- package/lib/module/animation/timing/useTiming.js.map +1 -1
- package/lib/module/dom/nodes/DrawingNode.js +2 -6
- package/lib/module/dom/nodes/DrawingNode.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js +2 -2
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/dom/nodes/RenderNode.js +1 -4
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Gradient.js +2 -2
- package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Text.js +4 -9
- package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js +4 -2
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/mock/index.js +10 -7
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +10 -2
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +9 -1
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/renderer/components/Mask.js +2 -4
- package/lib/module/renderer/components/Mask.js.map +1 -1
- package/lib/module/renderer/components/Paint.js +3 -14
- package/lib/module/renderer/components/Paint.js.map +1 -1
- package/lib/module/renderer/useCanvas.js +13 -0
- package/lib/module/renderer/useCanvas.js.map +1 -1
- package/lib/module/skia/core/Picture.js +0 -18
- package/lib/module/skia/core/Picture.js.map +1 -1
- package/lib/module/skia/core/Rect.js +1 -1
- package/lib/module/skia/core/Rect.js.map +1 -1
- package/lib/module/skia/core/Vector.js +1 -1
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/lib/module/skia/types/ContourMeasure.js.map +1 -1
- package/lib/module/skia/types/Size.js +2 -0
- package/lib/module/skia/types/Size.js.map +1 -0
- package/lib/module/skia/types/index.js +1 -0
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/Host.js +1 -1
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkColor.js +8 -0
- package/lib/module/skia/web/JsiSkColor.js.map +1 -1
- package/lib/module/skia/web/JsiSkContourMeasure.js +3 -7
- package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/values/web/RNSkAnimation.js +2 -2
- package/lib/module/values/web/RNSkAnimation.js.map +1 -1
- package/lib/module/values/web/RNSkReadonlyValue.js +4 -2
- package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +5 -3
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/useTouchHandler.js +6 -6
- package/lib/module/views/useTouchHandler.js.map +1 -1
- package/lib/module/web/WithSkiaWeb.js +1 -1
- package/lib/module/web/WithSkiaWeb.js.map +1 -1
- package/lib/typescript/src/dom/nodes/RenderNode.d.ts +1 -3
- package/lib/typescript/src/dom/types/Common.d.ts +2 -3
- package/lib/typescript/src/dom/types/Drawings.d.ts +1 -3
- package/lib/typescript/src/renderer/Canvas.d.ts +4 -1
- package/lib/typescript/src/renderer/HostComponents.d.ts +1 -5
- package/lib/typescript/src/renderer/components/Paint.d.ts +3 -4
- package/lib/typescript/src/renderer/useCanvas.d.ts +1 -0
- package/lib/typescript/src/skia/core/Picture.d.ts +0 -8
- package/lib/typescript/src/skia/types/ContourMeasure.d.ts +3 -2
- package/lib/typescript/src/skia/types/Size.d.ts +4 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkContourMeasure.d.ts +2 -6
- package/package.json +12 -6
- package/src/dom/nodes/DrawingNode.ts +2 -4
- package/src/dom/nodes/RenderNode.ts +1 -13
- package/src/dom/nodes/drawings/Text.ts +4 -4
- package/src/dom/types/Common.ts +2 -4
- package/src/dom/types/Drawings.ts +1 -4
- package/src/mock/index.ts +0 -1
- package/src/renderer/Canvas.tsx +18 -3
- package/src/renderer/HostComponents.ts +1 -4
- package/src/renderer/HostConfig.ts +8 -1
- package/src/renderer/components/Mask.tsx +2 -2
- package/src/renderer/components/Paint.tsx +3 -14
- package/src/renderer/useCanvas.ts +14 -0
- package/src/skia/core/Picture.ts +0 -24
- package/src/skia/core/Rect.ts +1 -1
- package/src/skia/types/ContourMeasure.tsx +3 -2
- package/src/skia/types/Size.ts +4 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkColor.ts +11 -0
- package/src/skia/web/JsiSkContourMeasure.ts +7 -3
- package/src/values/web/RNSkReadonlyValue.ts +4 -2
- package/src/views/SkiaBaseWebView.tsx +2 -2
package/src/skia/core/Picture.ts
CHANGED
@@ -1,30 +1,6 @@
|
|
1
|
-
import type { DependencyList } from "react";
|
2
|
-
import { useMemo } from "react";
|
3
|
-
|
4
1
|
import { Skia } from "../Skia";
|
5
2
|
import type { SkCanvas, SkRect } from "../types";
|
6
3
|
|
7
|
-
/**
|
8
|
-
* Memoizes and returns an SkPicture that can be drawn to another canvas.
|
9
|
-
* @param rect Picture bounds
|
10
|
-
* @param cb Callback for drawing to the canvas
|
11
|
-
* @returns SkPicture
|
12
|
-
*/
|
13
|
-
export const usePicture = (
|
14
|
-
rect: SkRect,
|
15
|
-
cb: (canvas: SkCanvas) => void,
|
16
|
-
deps: DependencyList = []
|
17
|
-
) => {
|
18
|
-
console.warn("usePicture() is deprecated. Use createPicture() instead.");
|
19
|
-
return useMemo(() => {
|
20
|
-
const recorder = Skia.PictureRecorder();
|
21
|
-
const canvas = recorder.beginRecording(rect);
|
22
|
-
cb(canvas);
|
23
|
-
return recorder.finishRecordingAsPicture();
|
24
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
25
|
-
}, deps);
|
26
|
-
};
|
27
|
-
|
28
4
|
/**
|
29
5
|
* Memoizes and returns an SkPicture that can be drawn to another canvas.
|
30
6
|
* @param rect Picture bounds
|
package/src/skia/core/Rect.ts
CHANGED
@@ -12,7 +12,7 @@ export const bounds = (rects: SkRect[]) => {
|
|
12
12
|
const y = Math.min(...rects.map((r) => r.y));
|
13
13
|
const width = Math.max(...rects.map((r) => r.x + r.width));
|
14
14
|
const height = Math.max(...rects.map((r) => r.y + r.height));
|
15
|
-
return rect(x, y, width, height);
|
15
|
+
return rect(x, y, width - x, height - y);
|
16
16
|
};
|
17
17
|
|
18
18
|
export const topLeft = (r: SkRect | SkRRect) =>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { SkJSIInstance } from "./JsiInstance";
|
2
2
|
import type { SkPath } from "./Path/Path";
|
3
|
+
import type { SkPoint } from "./Point";
|
3
4
|
|
4
5
|
export interface PosTan {
|
5
6
|
px: number;
|
@@ -11,10 +12,10 @@ export interface PosTan {
|
|
11
12
|
export interface SkContourMeasure extends SkJSIInstance<"ContourMeasure"> {
|
12
13
|
/**
|
13
14
|
* Returns the given position and tangent line for the distance on the given contour.
|
14
|
-
* The return value
|
15
|
+
* The return value an array of 2 vectors: [position, tangent]
|
15
16
|
* @param distance - will be pinned between 0 and length().
|
16
17
|
*/
|
17
|
-
getPosTan(distance: number):
|
18
|
+
getPosTan(distance: number): [position: SkPoint, tangent: SkPoint];
|
18
19
|
|
19
20
|
/**
|
20
21
|
* Returns an Path representing the segment of this contour.
|
package/src/skia/types/index.ts
CHANGED
@@ -241,6 +241,17 @@ const parseCSSColor = (cssStr: string) => {
|
|
241
241
|
return null;
|
242
242
|
} // Covers NaN.
|
243
243
|
return [(iv & 0xff0000) >> 16, (iv & 0xff00) >> 8, iv & 0xff, 1];
|
244
|
+
} else if (str.length === 9) {
|
245
|
+
var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
|
246
|
+
if (!(iv >= 0 && iv <= 0xffffffff)) {
|
247
|
+
return null; // Covers NaN.
|
248
|
+
}
|
249
|
+
return [
|
250
|
+
((iv & 0xff000000) >> 24) & 0xff,
|
251
|
+
(iv & 0xff0000) >> 16,
|
252
|
+
(iv & 0xff00) >> 8,
|
253
|
+
(iv & 0xff) / 255,
|
254
|
+
];
|
244
255
|
}
|
245
256
|
|
246
257
|
return null;
|
@@ -4,6 +4,7 @@ import type { SkContourMeasure } from "../types";
|
|
4
4
|
|
5
5
|
import { HostObject } from "./Host";
|
6
6
|
import { JsiSkPath } from "./JsiSkPath";
|
7
|
+
import { JsiSkPoint } from "./JsiSkPoint";
|
7
8
|
|
8
9
|
export class JsiSkContourMeasure
|
9
10
|
extends HostObject<ContourMeasure, "ContourMeasure">
|
@@ -13,9 +14,12 @@ export class JsiSkContourMeasure
|
|
13
14
|
super(CanvasKit, ref, "ContourMeasure");
|
14
15
|
}
|
15
16
|
|
16
|
-
getPosTan(distance: number) {
|
17
|
-
const
|
18
|
-
return
|
17
|
+
getPosTan(distance: number): [position: JsiSkPoint, tangent: JsiSkPoint] {
|
18
|
+
const posTan = this.ref.getPosTan(distance);
|
19
|
+
return [
|
20
|
+
new JsiSkPoint(this.CanvasKit, posTan.slice(0, 2)),
|
21
|
+
new JsiSkPoint(this.CanvasKit, posTan.slice(2)),
|
22
|
+
];
|
19
23
|
}
|
20
24
|
|
21
25
|
getSegment(startD: number, stopD: number, startWithMoveTo: boolean) {
|
@@ -13,8 +13,10 @@ export class RNSkReadonlyValue<T> implements SkiaValue<T> {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
protected update(nextValue: T): void {
|
16
|
-
this._current
|
17
|
-
|
16
|
+
if (this._current !== nextValue) {
|
17
|
+
this._current = nextValue;
|
18
|
+
this.notifyListeners();
|
19
|
+
}
|
18
20
|
}
|
19
21
|
|
20
22
|
public readonly __typename__ = "RNSkValue";
|
@@ -46,8 +46,8 @@ export abstract class SkiaBaseWebView<
|
|
46
46
|
// Reset canvas / surface on layout change
|
47
47
|
if (this._canvasRef.current) {
|
48
48
|
const canvas = this._canvasRef.current;
|
49
|
-
canvas.width =
|
50
|
-
canvas.height =
|
49
|
+
canvas.width = width * pd;
|
50
|
+
canvas.height = height * pd;
|
51
51
|
const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);
|
52
52
|
if (!surface) {
|
53
53
|
throw new Error("Could not create surface");
|