@shopify/react-native-skia 0.1.138 → 0.1.141
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.
- package/android/CMakeLists.txt +5 -1
- package/android/build.gradle +3 -1
- package/cpp/api/JsiSkApi.h +0 -4
- package/cpp/api/JsiSkFont.h +0 -19
- package/lib/commonjs/mock/index.js +0 -4
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +5 -8
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/components/text/Glyphs.js +4 -6
- package/lib/commonjs/renderer/components/text/Glyphs.js.map +1 -1
- package/lib/commonjs/renderer/components/text/Text.js +4 -6
- package/lib/commonjs/renderer/components/text/Text.js.map +1 -1
- package/lib/commonjs/renderer/components/text/TextPath.js +3 -4
- package/lib/commonjs/renderer/components/text/TextPath.js.map +1 -1
- package/lib/commonjs/renderer/processors/Font.js +1 -27
- package/lib/commonjs/renderer/processors/Font.js.map +1 -1
- package/lib/commonjs/skia/core/Data.js +4 -5
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/core/Image.js +4 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.js +3 -1
- package/lib/commonjs/skia/core/SVG.js.map +1 -1
- package/lib/commonjs/skia/core/Typeface.js +4 -1
- package/lib/commonjs/skia/core/Typeface.js.map +1 -1
- package/lib/commonjs/skia/core/index.js +0 -26
- package/lib/commonjs/skia/core/index.js.map +1 -1
- package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.js +0 -2
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/types/index.js +0 -13
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +0 -6
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +0 -3
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/values/hooks/useComputedValue.js +1 -8
- package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.js +53 -33
- package/lib/commonjs/views/SkiaView.web.js.map +1 -1
- package/lib/commonjs/views/useTouchHandler.js +13 -15
- package/lib/commonjs/views/useTouchHandler.js.map +1 -1
- package/lib/module/mock/index.js +0 -4
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +5 -6
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/components/text/Glyphs.js +4 -5
- package/lib/module/renderer/components/text/Glyphs.js.map +1 -1
- package/lib/module/renderer/components/text/Text.js +4 -5
- package/lib/module/renderer/components/text/Text.js.map +1 -1
- package/lib/module/renderer/components/text/TextPath.js +3 -3
- package/lib/module/renderer/components/text/TextPath.js.map +1 -1
- package/lib/module/renderer/processors/Font.js +0 -23
- package/lib/module/renderer/processors/Font.js.map +1 -1
- package/lib/module/skia/core/Data.js +4 -5
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/core/Image.js +2 -1
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/core/SVG.js +2 -1
- package/lib/module/skia/core/SVG.js.map +1 -1
- package/lib/module/skia/core/Typeface.js +2 -1
- package/lib/module/skia/core/Typeface.js.map +1 -1
- package/lib/module/skia/core/index.js +0 -2
- package/lib/module/skia/core/index.js.map +1 -1
- package/lib/module/skia/types/Font/Font.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.js +0 -1
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/types/index.js +0 -1
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +0 -6
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextBlobFactory.js +1 -1
- package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +0 -2
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/values/hooks/useComputedValue.js +0 -4
- package/lib/module/values/hooks/useComputedValue.js.map +1 -1
- package/lib/module/views/SkiaView.web.js +53 -34
- package/lib/module/views/SkiaView.web.js.map +1 -1
- package/lib/module/views/useTouchHandler.js +12 -14
- package/lib/module/views/useTouchHandler.js.map +1 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +1 -3
- package/lib/typescript/src/renderer/DrawingContext.d.ts +1 -2
- package/lib/typescript/src/renderer/processors/Font.d.ts +1 -5
- package/lib/typescript/src/skia/core/index.d.ts +0 -2
- package/lib/typescript/src/skia/types/Font/Font.d.ts +0 -12
- package/lib/typescript/src/skia/types/Skia.d.ts +0 -2
- package/lib/typescript/src/skia/types/index.d.ts +0 -1
- package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -2
- package/lib/typescript/src/values/hooks/useComputedValue.d.ts +0 -1
- package/lib/typescript/src/views/SkiaView.web.d.ts +5 -5
- package/package.json +12 -7
- package/src/mock/index.ts +0 -4
- package/src/renderer/Canvas.tsx +5 -8
- package/src/renderer/DrawingContext.ts +1 -2
- package/src/renderer/components/text/Glyphs.tsx +2 -6
- package/src/renderer/components/text/Text.tsx +2 -3
- package/src/renderer/components/text/TextPath.tsx +2 -3
- package/src/renderer/processors/Font.ts +2 -25
- package/src/skia/core/Data.ts +8 -5
- package/src/skia/core/Image.ts +3 -1
- package/src/skia/core/SVG.ts +3 -1
- package/src/skia/core/Typeface.ts +4 -6
- package/src/skia/core/index.ts +0 -2
- package/src/skia/types/Font/Font.ts +0 -13
- package/src/skia/types/Image/ImageFactory.ts +0 -1
- package/src/skia/types/Path/Path.ts +0 -1
- package/src/skia/types/Skia.ts +0 -2
- package/src/skia/types/index.ts +0 -1
- package/src/skia/web/JsiSkFont.ts +0 -9
- package/src/skia/web/JsiSkTextBlobFactory.ts +1 -1
- package/src/skia/web/JsiSkia.ts +0 -2
- package/src/values/hooks/useComputedValue.ts +0 -5
- package/src/views/SkiaView.web.tsx +41 -46
- package/src/views/useTouchHandler.ts +15 -19
- package/android/README.md +0 -14
- package/cpp/api/JsiSkFontMgr.h +0 -84
- package/cpp/api/JsiSkFontMgrFactory.h +0 -48
- package/cpp/skia/include/third_party/skcms/LICENSE +0 -29
- package/cpp/skia/include/third_party/vulkan/LICENSE +0 -29
- package/cpp/skia/readme.txt +0 -1
- package/lib/commonjs/skia/core/Paint.js +0 -28
- package/lib/commonjs/skia/core/Paint.js.map +0 -1
- package/lib/commonjs/skia/core/Path.js +0 -72
- package/lib/commonjs/skia/core/Path.js.map +0 -1
- package/lib/commonjs/skia/types/FontMgr/FontMgr.js +0 -6
- package/lib/commonjs/skia/types/FontMgr/FontMgr.js.map +0 -1
- package/lib/commonjs/skia/types/FontMgr/FontMgrFactory.js +0 -6
- package/lib/commonjs/skia/types/FontMgr/FontMgrFactory.js.map +0 -1
- package/lib/commonjs/skia/types/FontMgr/index.js +0 -32
- package/lib/commonjs/skia/types/FontMgr/index.js.map +0 -1
- package/lib/commonjs/skia/web/JsiSkFontMgr.js +0 -33
- package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +0 -1
- package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js +0 -25
- package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js.map +0 -1
- package/lib/module/skia/core/Paint.js +0 -17
- package/lib/module/skia/core/Paint.js.map +0 -1
- package/lib/module/skia/core/Path.js +0 -53
- package/lib/module/skia/core/Path.js.map +0 -1
- package/lib/module/skia/types/FontMgr/FontMgr.js +0 -2
- package/lib/module/skia/types/FontMgr/FontMgr.js.map +0 -1
- package/lib/module/skia/types/FontMgr/FontMgrFactory.js +0 -2
- package/lib/module/skia/types/FontMgr/FontMgrFactory.js.map +0 -1
- package/lib/module/skia/types/FontMgr/index.js +0 -3
- package/lib/module/skia/types/FontMgr/index.js.map +0 -1
- package/lib/module/skia/web/JsiSkFontMgr.js +0 -23
- package/lib/module/skia/web/JsiSkFontMgr.js.map +0 -1
- package/lib/module/skia/web/JsiSkFontMgrFactory.js +0 -14
- package/lib/module/skia/web/JsiSkFontMgrFactory.js.map +0 -1
- package/lib/typescript/src/skia/core/Paint.d.ts +0 -6
- package/lib/typescript/src/skia/core/Path.d.ts +0 -21
- package/lib/typescript/src/skia/types/FontMgr/FontMgr.d.ts +0 -18
- package/lib/typescript/src/skia/types/FontMgr/FontMgrFactory.d.ts +0 -4
- package/lib/typescript/src/skia/types/FontMgr/index.d.ts +0 -2
- package/lib/typescript/src/skia/web/JsiSkFontMgr.d.ts +0 -9
- package/lib/typescript/src/skia/web/JsiSkFontMgrFactory.d.ts +0 -8
- package/src/skia/core/Paint.ts +0 -22
- package/src/skia/core/Path.ts +0 -60
- package/src/skia/types/FontMgr/FontMgr.ts +0 -24
- package/src/skia/types/FontMgr/FontMgrFactory.ts +0 -12
- package/src/skia/types/FontMgr/index.ts +0 -2
- package/src/skia/web/JsiSkFontMgr.ts +0 -38
- package/src/skia/web/JsiSkFontMgrFactory.ts +0 -18
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
SkFont,
|
|
7
7
|
SkPaint,
|
|
8
8
|
SkPoint,
|
|
9
|
-
SkRect,
|
|
10
9
|
SkTypeface,
|
|
11
10
|
} from "../types";
|
|
12
11
|
|
|
@@ -19,14 +18,6 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
|
19
18
|
super(CanvasKit, ref, "Font");
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
measureText(_text: string, _paint?: SkPaint): SkRect {
|
|
23
|
-
console.warn(
|
|
24
|
-
`measureText() is deprecated an returns an empty rectangle on React Native Web.
|
|
25
|
-
Clients should use "Font.getGlyphWidths" instead (the latter does no shaping)`
|
|
26
|
-
);
|
|
27
|
-
return new JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
21
|
getTextWidth(text: string, paint?: SkPaint | undefined) {
|
|
31
22
|
const ids = this.getGlyphIDs(text);
|
|
32
23
|
const widths = this.getGlyphWidths(ids, paint);
|
|
@@ -30,7 +30,7 @@ export class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
|
|
|
30
30
|
this.CanvasKit,
|
|
31
31
|
this.CanvasKit.TextBlob.MakeFromRSXform(
|
|
32
32
|
str,
|
|
33
|
-
rsxforms.map((f) => toValue(f)),
|
|
33
|
+
rsxforms.map((f) => Array.from(toValue<Float32Array>(f))).flat(),
|
|
34
34
|
toValue(font)
|
|
35
35
|
)
|
|
36
36
|
);
|
package/src/skia/web/JsiSkia.ts
CHANGED
|
@@ -34,7 +34,6 @@ import { JsiSkDataFactory } from "./JsiSkDataFactory";
|
|
|
34
34
|
import { JsiSkImageFactory } from "./JsiSkImageFactory";
|
|
35
35
|
import { JsiSkSVGFactory } from "./JsiSkSVGFactory";
|
|
36
36
|
import { JsiSkTextBlobFactory } from "./JsiSkTextBlobFactory";
|
|
37
|
-
import { JsiSkFontMgrFactory } from "./JsiSkFontMgrFactory";
|
|
38
37
|
import { JsiSkFont } from "./JsiSkFont";
|
|
39
38
|
import { MakeVertices } from "./JsiSkVerticesFactory";
|
|
40
39
|
|
|
@@ -90,7 +89,6 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
|
|
|
90
89
|
Image: new JsiSkImageFactory(CanvasKit),
|
|
91
90
|
SVG: new JsiSkSVGFactory(CanvasKit),
|
|
92
91
|
TextBlob: new JsiSkTextBlobFactory(CanvasKit),
|
|
93
|
-
FontMgr: new JsiSkFontMgrFactory(CanvasKit),
|
|
94
92
|
XYWHRect: (x: number, y: number, width: number, height: number) => {
|
|
95
93
|
return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));
|
|
96
94
|
},
|
|
@@ -16,8 +16,3 @@ export const useComputedValue = <R>(cb: () => R, values: unknown[]) =>
|
|
|
16
16
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
17
|
values
|
|
18
18
|
);
|
|
19
|
-
|
|
20
|
-
export const useDerivedValue = <R>(cb: () => R, values: unknown[]) => {
|
|
21
|
-
console.warn("useDerivedValue is deprecated. Use useComputedValue instead.");
|
|
22
|
-
return useComputedValue(cb, values);
|
|
23
|
-
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { PointerEvent } from "react";
|
|
4
4
|
import type { LayoutChangeEvent } from "react-native";
|
|
5
|
-
import { View } from "react-native";
|
|
5
|
+
import { PixelRatio, View } from "react-native";
|
|
6
6
|
|
|
7
7
|
import type { SkRect, SkCanvas } from "../skia/types";
|
|
8
8
|
import type { SkiaValue } from "../values";
|
|
@@ -11,13 +11,11 @@ import { JsiSkSurface } from "../skia/web/JsiSkSurface";
|
|
|
11
11
|
import type { DrawingInfo, DrawMode, SkiaViewProps, TouchInfo } from "./types";
|
|
12
12
|
import { TouchType } from "./types";
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
> {
|
|
14
|
+
const pd = PixelRatio.get();
|
|
15
|
+
|
|
16
|
+
export class SkiaView extends React.Component<SkiaViewProps> {
|
|
18
17
|
constructor(props: SkiaViewProps) {
|
|
19
18
|
super(props);
|
|
20
|
-
this.state = { width: -1, height: -1 };
|
|
21
19
|
this._mode = props.mode ?? "default";
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -25,10 +23,12 @@ export class SkiaView extends React.Component<
|
|
|
25
23
|
private _unsubscriptions: Array<() => void> = [];
|
|
26
24
|
private _touches: Array<TouchInfo> = [];
|
|
27
25
|
private _canvas: SkCanvas | null = null;
|
|
28
|
-
private _canvasRef
|
|
26
|
+
private _canvasRef = React.createRef<HTMLCanvasElement>();
|
|
29
27
|
private _mode: DrawMode;
|
|
30
28
|
private _redrawRequests = 0;
|
|
31
|
-
private
|
|
29
|
+
private width = 0;
|
|
30
|
+
private height = 0;
|
|
31
|
+
private requestId = 0;
|
|
32
32
|
|
|
33
33
|
private unsubscribeAll() {
|
|
34
34
|
this._unsubscriptions.forEach((u) => u());
|
|
@@ -36,27 +36,23 @@ export class SkiaView extends React.Component<
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
private onLayout(evt: LayoutChangeEvent) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
// Get canvas and repaint
|
|
53
|
-
if (this._surface) {
|
|
54
|
-
this._canvas = this._surface.getCanvas();
|
|
55
|
-
this.redraw();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
39
|
+
const { CanvasKit } = global;
|
|
40
|
+
const { width, height } = evt.nativeEvent.layout;
|
|
41
|
+
this.width = width;
|
|
42
|
+
this.height = height;
|
|
43
|
+
// Reset canvas / surface on layout change
|
|
44
|
+
if (this._canvasRef.current) {
|
|
45
|
+
const canvas = this._canvasRef.current;
|
|
46
|
+
canvas.width = canvas.clientWidth * pd;
|
|
47
|
+
canvas.height = canvas.clientHeight * pd;
|
|
48
|
+
const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);
|
|
49
|
+
if (!surface) {
|
|
50
|
+
throw new Error("Could not create surface");
|
|
58
51
|
}
|
|
59
|
-
|
|
52
|
+
this._surface = new JsiSkSurface(CanvasKit, surface);
|
|
53
|
+
this._canvas = this._surface.getCanvas();
|
|
54
|
+
this.redraw();
|
|
55
|
+
}
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
componentDidMount() {
|
|
@@ -64,11 +60,13 @@ export class SkiaView extends React.Component<
|
|
|
64
60
|
this.tick();
|
|
65
61
|
}
|
|
66
62
|
|
|
63
|
+
componentDidUpdate() {
|
|
64
|
+
this.redraw();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
67
|
componentWillUnmount() {
|
|
68
68
|
this.unsubscribeAll();
|
|
69
|
-
this.
|
|
70
|
-
this._canvas = null;
|
|
71
|
-
this._unmounted = true;
|
|
69
|
+
cancelAnimationFrame(this.requestId);
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
/**
|
|
@@ -86,28 +84,26 @@ export class SkiaView extends React.Component<
|
|
|
86
84
|
private tick() {
|
|
87
85
|
if (this._mode === "continuous" || this._redrawRequests > 0) {
|
|
88
86
|
this._redrawRequests = 0;
|
|
89
|
-
if (
|
|
90
|
-
this._canvas &&
|
|
91
|
-
this.props.onDraw &&
|
|
92
|
-
this.state.height !== -1 &&
|
|
93
|
-
this.state.width !== -1
|
|
94
|
-
) {
|
|
87
|
+
if (this._canvas && this.props.onDraw) {
|
|
95
88
|
const touches = [...this._touches];
|
|
96
89
|
this._touches = [];
|
|
97
90
|
const info: DrawingInfo = {
|
|
98
|
-
height: this.
|
|
99
|
-
width: this.
|
|
91
|
+
height: this.height,
|
|
92
|
+
width: this.width,
|
|
100
93
|
timestamp: Date.now(),
|
|
101
94
|
touches: touches.map((t) => [t]),
|
|
102
95
|
};
|
|
103
|
-
|
|
96
|
+
if (this.props.onDraw) {
|
|
97
|
+
const canvas = this._canvas!;
|
|
98
|
+
canvas.save();
|
|
99
|
+
canvas.scale(pd, pd);
|
|
100
|
+
this.props.onDraw(canvas, info);
|
|
101
|
+
canvas.restore();
|
|
102
|
+
}
|
|
104
103
|
this._surface?.ref.flush();
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
if (!this._unmounted) {
|
|
109
|
-
requestAnimationFrame(this.tick.bind(this));
|
|
110
|
-
}
|
|
106
|
+
this.requestId = requestAnimationFrame(this.tick.bind(this));
|
|
111
107
|
}
|
|
112
108
|
|
|
113
109
|
public redraw() {
|
|
@@ -168,8 +164,7 @@ export class SkiaView extends React.Component<
|
|
|
168
164
|
<View {...viewProps} onLayout={this.onLayout.bind(this)}>
|
|
169
165
|
<canvas
|
|
170
166
|
ref={this._canvasRef}
|
|
171
|
-
|
|
172
|
-
height={this.state.height}
|
|
167
|
+
style={{ display: "flex", flex: 1 }}
|
|
173
168
|
onPointerDown={this.createTouchHandler(TouchType.Start)}
|
|
174
169
|
onPointerMove={this.createTouchHandler(TouchType.Active)}
|
|
175
170
|
onPointerUp={this.createTouchHandler(TouchType.End)}
|
|
@@ -2,6 +2,8 @@ import type { DependencyList } from "react";
|
|
|
2
2
|
import { useCallback, useRef } from "react";
|
|
3
3
|
import { PixelRatio } from "react-native";
|
|
4
4
|
|
|
5
|
+
import type { Vector } from "../skia/types";
|
|
6
|
+
|
|
5
7
|
import type {
|
|
6
8
|
ExtendedTouchInfo,
|
|
7
9
|
TouchHandlers,
|
|
@@ -15,10 +17,8 @@ const useInternalTouchHandler = (
|
|
|
15
17
|
deps: DependencyList = [],
|
|
16
18
|
multiTouch = false
|
|
17
19
|
): TouchHandler => {
|
|
18
|
-
const prevTouchInfoRef = useRef<{ [key: number]: TouchInfo }>({});
|
|
19
|
-
const prevVelocityRef = useRef<{ [key: number]:
|
|
20
|
-
{}
|
|
21
|
-
);
|
|
20
|
+
const prevTouchInfoRef = useRef<{ [key: number]: TouchInfo | undefined }>({});
|
|
21
|
+
const prevVelocityRef = useRef<{ [key: number]: Vector | undefined }>({});
|
|
22
22
|
|
|
23
23
|
return useCallback((history: Array<Array<TouchInfo>>) => {
|
|
24
24
|
// Process all items in the current touch history
|
|
@@ -30,34 +30,31 @@ const useInternalTouchHandler = (
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const touch = touches[i];
|
|
33
|
-
|
|
33
|
+
const prevTouch = prevTouchInfoRef.current[touch.id];
|
|
34
34
|
// Calculate the velocity from the previous touch.
|
|
35
35
|
const timeDiffseconds =
|
|
36
36
|
touch.timestamp -
|
|
37
37
|
(prevTouchInfoRef.current[touch.id]?.timestamp ?? touch.timestamp);
|
|
38
38
|
|
|
39
|
-
const distX =
|
|
40
|
-
|
|
41
|
-
const distY =
|
|
42
|
-
touch.y - (prevTouchInfoRef.current[touch.id]?.y ?? touch.y);
|
|
39
|
+
const distX = touch.x - (prevTouch?.x ?? touch.x);
|
|
40
|
+
const distY = touch.y - (prevTouch?.y ?? touch.y);
|
|
43
41
|
|
|
44
42
|
if (
|
|
45
43
|
touch.type !== TouchType.Start &&
|
|
46
44
|
touch.type !== TouchType.End &&
|
|
47
|
-
touch.type !== TouchType.Cancelled
|
|
45
|
+
touch.type !== TouchType.Cancelled &&
|
|
46
|
+
timeDiffseconds > 0
|
|
48
47
|
) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
}
|
|
48
|
+
prevVelocityRef.current[touch.id] = {
|
|
49
|
+
x: distX / timeDiffseconds / PixelRatio.get(),
|
|
50
|
+
y: distY / timeDiffseconds / PixelRatio.get(),
|
|
51
|
+
};
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
const extendedTouchInfo: ExtendedTouchInfo = {
|
|
58
55
|
...touch,
|
|
59
|
-
velocityX: prevVelocityRef.current[touch.id]?.x,
|
|
60
|
-
velocityY: prevVelocityRef.current[touch.id]?.y,
|
|
56
|
+
velocityX: prevVelocityRef.current[touch.id]?.x ?? 0,
|
|
57
|
+
velocityY: prevVelocityRef.current[touch.id]?.y ?? 0,
|
|
61
58
|
};
|
|
62
59
|
|
|
63
60
|
// Save previous touch
|
|
@@ -69,7 +66,6 @@ const useInternalTouchHandler = (
|
|
|
69
66
|
} else if (touch.type === TouchType.Active) {
|
|
70
67
|
handlers.onActive && handlers.onActive(extendedTouchInfo);
|
|
71
68
|
} else {
|
|
72
|
-
handlers.onActive && handlers.onActive(extendedTouchInfo);
|
|
73
69
|
handlers.onEnd && handlers.onEnd(extendedTouchInfo);
|
|
74
70
|
}
|
|
75
71
|
}
|
package/android/README.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
README
|
|
2
|
-
======
|
|
3
|
-
|
|
4
|
-
If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
|
|
5
|
-
|
|
6
|
-
1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
|
|
7
|
-
2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
|
|
8
|
-
```
|
|
9
|
-
ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
|
|
10
|
-
sdk.dir=/Users/{username}/Library/Android/sdk
|
|
11
|
-
```
|
|
12
|
-
3. Delete the `maven` folder
|
|
13
|
-
4. Run `./gradlew installArchives`
|
|
14
|
-
5. Verify that latest set of generated files is in the maven folder with the correct version number
|
package/cpp/api/JsiSkFontMgr.h
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <memory>
|
|
4
|
-
#include <utility>
|
|
5
|
-
|
|
6
|
-
#include <jsi/jsi.h>
|
|
7
|
-
|
|
8
|
-
#include "JsiSkHostObjects.h"
|
|
9
|
-
|
|
10
|
-
#pragma clang diagnostic push
|
|
11
|
-
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
12
|
-
|
|
13
|
-
#include <SkFont.h>
|
|
14
|
-
#include <SkFontMgr.h>
|
|
15
|
-
#include <SkTypeface.h>
|
|
16
|
-
|
|
17
|
-
#pragma clang diagnostic pop
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
namespace RNSkia {
|
|
21
|
-
|
|
22
|
-
using namespace facebook;
|
|
23
|
-
|
|
24
|
-
class JsiSkFontMgr : public JsiSkWrappingSkPtrHostObject<SkFontMgr> {
|
|
25
|
-
public:
|
|
26
|
-
|
|
27
|
-
// TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
|
|
28
|
-
JSI_PROPERTY_GET(__typename__) {
|
|
29
|
-
return jsi::String::createFromUtf8(runtime, "FontMgr");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkFontMgr, __typename__))
|
|
33
|
-
|
|
34
|
-
JsiSkFontMgr(std::shared_ptr<RNSkPlatformContext> context,
|
|
35
|
-
sk_sp<SkFontMgr> fontMgr)
|
|
36
|
-
: JsiSkWrappingSkPtrHostObject(std::move(context), std::move(fontMgr)) {}
|
|
37
|
-
|
|
38
|
-
JSI_HOST_FUNCTION(countFamilies) {
|
|
39
|
-
auto families = getObject()->countFamilies();
|
|
40
|
-
return jsi::Value(families);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
JSI_HOST_FUNCTION(getFamilyName) {
|
|
44
|
-
auto i = arguments[0].asNumber();
|
|
45
|
-
SkString familyName;
|
|
46
|
-
getObject()->getFamilyName(i, &familyName);
|
|
47
|
-
return jsi::String::createFromUtf8(runtime, familyName.c_str());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
JSI_HOST_FUNCTION(matchFamilyStyle) {
|
|
51
|
-
auto familyName = arguments[0].asString(runtime).utf8(runtime);
|
|
52
|
-
auto fontStyle = SkFontStyle::Normal();
|
|
53
|
-
if (count >= 2) {
|
|
54
|
-
auto object = arguments[1].asObject(runtime);
|
|
55
|
-
int weight = object.getProperty(runtime, "weight").asNumber();
|
|
56
|
-
int width = object.getProperty(runtime, "width").asNumber();
|
|
57
|
-
SkFontStyle::Slant slant = (SkFontStyle::Slant)object.getProperty(runtime, "slant").asNumber();
|
|
58
|
-
fontStyle = SkFontStyle(width, weight, slant);
|
|
59
|
-
}
|
|
60
|
-
auto typeface = getObject()->matchFamilyStyle(familyName.c_str(), std::move(fontStyle));
|
|
61
|
-
if (typeface == nullptr) {
|
|
62
|
-
return jsi::Value::null();
|
|
63
|
-
}
|
|
64
|
-
return jsi::Object::createFromHostObject(
|
|
65
|
-
runtime, std::make_shared<JsiSkTypeface>(getContext(), sk_sp<SkTypeface>(std::move(typeface))));;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
JSI_EXPORT_FUNCTIONS(
|
|
69
|
-
JSI_EXPORT_FUNC(JsiSkFontMgr, countFamilies),
|
|
70
|
-
JSI_EXPORT_FUNC(JsiSkFontMgr, getFamilyName),
|
|
71
|
-
JSI_EXPORT_FUNC(JsiSkFontMgr, matchFamilyStyle)
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
Returns the underlying object from a host object of this type
|
|
76
|
-
*/
|
|
77
|
-
static sk_sp<SkFontMgr> fromValue(jsi::Runtime &runtime,
|
|
78
|
-
const jsi::Value &obj) {
|
|
79
|
-
return obj.asObject(runtime)
|
|
80
|
-
.asHostObject<JsiSkFontMgr>(runtime)
|
|
81
|
-
->getObject();
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
} // namespace RNSkia
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <memory>
|
|
4
|
-
#include <utility>
|
|
5
|
-
|
|
6
|
-
#include <jsi/jsi.h>
|
|
7
|
-
|
|
8
|
-
#include "JsiSkHostObjects.h"
|
|
9
|
-
#include "JsiSkFontMgr.h"
|
|
10
|
-
#include "JsiSkData.h"
|
|
11
|
-
#include <SkFontMgr.h>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
namespace RNSkia {
|
|
15
|
-
|
|
16
|
-
using namespace facebook;
|
|
17
|
-
|
|
18
|
-
class JsiSkFontMgrFactory : public JsiSkHostObject {
|
|
19
|
-
public:
|
|
20
|
-
// JSI_HOST_FUNCTION(FromData) {
|
|
21
|
-
// std::vector<sk_sp<SkData>> data;
|
|
22
|
-
// for (int i = 0; i < count; i++) {
|
|
23
|
-
// auto d = JsiSkData::fromValue(
|
|
24
|
-
// runtime, arguments[i]);
|
|
25
|
-
// data.push_back(d);
|
|
26
|
-
// }
|
|
27
|
-
//
|
|
28
|
-
// auto fontMgr = SkFontMgr_New_Custom_Data(data.data(), data.size());
|
|
29
|
-
// return jsi::Object::createFromHostObject(
|
|
30
|
-
// runtime, std::make_shared<JsiSkFontMgr>(getContext(), fontMgr));
|
|
31
|
-
// }
|
|
32
|
-
|
|
33
|
-
JSI_HOST_FUNCTION(RefDefault) {
|
|
34
|
-
auto fontMgr = SkFontMgr::RefDefault();
|
|
35
|
-
return jsi::Object::createFromHostObject(
|
|
36
|
-
runtime, std::make_shared<JsiSkFontMgr>(getContext(), std::move(fontMgr)));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
JSI_EXPORT_FUNCTIONS(
|
|
40
|
-
//JSI_EXPORT_FUNC(JsiSkFontMgrFactory, FromData),
|
|
41
|
-
JSI_EXPORT_FUNC(JsiSkFontMgrFactory, RefDefault)
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
JsiSkFontMgrFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
45
|
-
: JsiSkHostObject(std::move(context)) {}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
} // namespace RNSkia
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2018 Google Inc. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// Redistribution and use in source and binary forms, with or without
|
|
4
|
-
// modification, are permitted provided that the following conditions are
|
|
5
|
-
// met:
|
|
6
|
-
//
|
|
7
|
-
// * Redistributions of source code must retain the above copyright
|
|
8
|
-
// notice, this list of conditions and the following disclaimer.
|
|
9
|
-
// * Redistributions in binary form must reproduce the above
|
|
10
|
-
// copyright notice, this list of conditions and the following disclaimer
|
|
11
|
-
// in the documentation and/or other materials provided with the
|
|
12
|
-
// distribution.
|
|
13
|
-
// * Neither the name of Google Inc. nor the names of its
|
|
14
|
-
// contributors may be used to endorse or promote products derived from
|
|
15
|
-
// this software without specific prior written permission.
|
|
16
|
-
//
|
|
17
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
21
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
23
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
24
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
25
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
|
|
29
|
-
--------------------------------------------------------------------------------
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2018 Google Inc. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// Redistribution and use in source and binary forms, with or without
|
|
4
|
-
// modification, are permitted provided that the following conditions are
|
|
5
|
-
// met:
|
|
6
|
-
//
|
|
7
|
-
// * Redistributions of source code must retain the above copyright
|
|
8
|
-
// notice, this list of conditions and the following disclaimer.
|
|
9
|
-
// * Redistributions in binary form must reproduce the above
|
|
10
|
-
// copyright notice, this list of conditions and the following disclaimer
|
|
11
|
-
// in the documentation and/or other materials provided with the
|
|
12
|
-
// distribution.
|
|
13
|
-
// * Neither the name of Google Inc. nor the names of its
|
|
14
|
-
// contributors may be used to endorse or promote products derived from
|
|
15
|
-
// this software without specific prior written permission.
|
|
16
|
-
//
|
|
17
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
21
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
23
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
24
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
25
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
|
|
29
|
-
--------------------------------------------------------------------------------
|
package/cpp/skia/readme.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Placeholder for the Skia include files.
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.usePaint = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
var _Skia = require("../Skia");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns a Skia Paint object
|
|
14
|
-
* */
|
|
15
|
-
const usePaint = (initializer, deps) => (0, _react.useMemo)(() => {
|
|
16
|
-
console.warn("usePaint() is deprecated. Use Skia.Paint() instead.");
|
|
17
|
-
|
|
18
|
-
const p = _Skia.Skia.Paint();
|
|
19
|
-
|
|
20
|
-
if (initializer) {
|
|
21
|
-
initializer(p);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return p; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
|
-
}, deps);
|
|
26
|
-
|
|
27
|
-
exports.usePaint = usePaint;
|
|
28
|
-
//# sourceMappingURL=Paint.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["Paint.ts"],"names":["usePaint","initializer","deps","console","warn","p","Skia","Paint"],"mappings":";;;;;;;AACA;;AAEA;;AAGA;AACA;AACA;AACO,MAAMA,QAAQ,GAAG,CACtBC,WADsB,EAEtBC,IAFsB,KAItB,oBAAQ,MAAM;AACZC,EAAAA,OAAO,CAACC,IAAR,CAAa,qDAAb;;AACA,QAAMC,CAAC,GAAGC,WAAKC,KAAL,EAAV;;AACA,MAAIN,WAAJ,EAAiB;AACfA,IAAAA,WAAW,CAACI,CAAD,CAAX;AACD;;AACD,SAAOA,CAAP,CANY,CAOZ;AACD,CARD,EAQGH,IARH,CAJK","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkPaint } from \"../types\";\n\n/**\n * Returns a Skia Paint object\n * */\nexport const usePaint = (\n initializer?: (paint: SkPaint) => void,\n deps?: DependencyList\n) =>\n useMemo(() => {\n console.warn(\"usePaint() is deprecated. Use Skia.Paint() instead.\");\n const p = Skia.Paint();\n if (initializer) {\n initializer(p);\n }\n return p;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n"]}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useTextPath = exports.useSvgPath = exports.usePath = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
var _Skia = require("../Skia");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Memoizes and returns a Skia Path object with optional initializer
|
|
14
|
-
* @param initializer
|
|
15
|
-
* @param deps
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
const usePath = (initializer, deps) => (0, _react.useMemo)(() => {
|
|
19
|
-
console.warn("usePath() is deprecated. Use Skia.Path.Make() instead.");
|
|
20
|
-
|
|
21
|
-
const p = _Skia.Skia.Path.Make();
|
|
22
|
-
|
|
23
|
-
if (initializer) {
|
|
24
|
-
initializer(p);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return p; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
-
}, [initializer, deps]);
|
|
29
|
-
/**
|
|
30
|
-
* Initializes a Skia Path from an svg path string
|
|
31
|
-
* @param svgpath
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
// MakeFromSVGString
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exports.usePath = usePath;
|
|
38
|
-
|
|
39
|
-
const useSvgPath = svgpath => (0, _react.useMemo)(() => {
|
|
40
|
-
console.warn("useSvgPath() is deprecated. Use Skia.Path.MakeFromSVGString() instead.");
|
|
41
|
-
|
|
42
|
-
const p = _Skia.Skia.Path.MakeFromSVGString(svgpath);
|
|
43
|
-
|
|
44
|
-
if (p === null) {
|
|
45
|
-
throw new Error(`Invalid SVG path: ${svgpath}`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return p;
|
|
49
|
-
}, [svgpath]);
|
|
50
|
-
/**
|
|
51
|
-
* Initializes a Skia Path from a text string
|
|
52
|
-
* @param svgpath
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
exports.useSvgPath = useSvgPath;
|
|
58
|
-
|
|
59
|
-
const useTextPath = (text, x, y, font) => (0, _react.useMemo)(() => {
|
|
60
|
-
console.warn("useTextPath() is deprecated. Use Skia.Path.MakeFromText() instead.");
|
|
61
|
-
|
|
62
|
-
const p = _Skia.Skia.Path.MakeFromText(text, x, y, font);
|
|
63
|
-
|
|
64
|
-
if (p === null) {
|
|
65
|
-
throw new Error("Text path creation failed.");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return p;
|
|
69
|
-
}, [text, x, y, font]);
|
|
70
|
-
|
|
71
|
-
exports.useTextPath = useTextPath;
|
|
72
|
-
//# sourceMappingURL=Path.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["Path.ts"],"names":["usePath","initializer","deps","console","warn","p","Skia","Path","Make","useSvgPath","svgpath","MakeFromSVGString","Error","useTextPath","text","x","y","font","MakeFromText"],"mappings":";;;;;;;AACA;;AAEA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,OAAO,GAAG,CACrBC,WADqB,EAErBC,IAFqB,KAIrB,oBAAQ,MAAM;AACZC,EAAAA,OAAO,CAACC,IAAR,CAAa,wDAAb;;AACA,QAAMC,CAAC,GAAGC,WAAKC,IAAL,CAAUC,IAAV,EAAV;;AACA,MAAIP,WAAJ,EAAiB;AACfA,IAAAA,WAAW,CAACI,CAAD,CAAX;AACD;;AACD,SAAOA,CAAP,CANY,CAOZ;AACD,CARD,EAQG,CAACJ,WAAD,EAAcC,IAAd,CARH,CAJK;AAcP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,UAAU,GAAIC,OAAD,IACxB,oBAAQ,MAAM;AACZP,EAAAA,OAAO,CAACC,IAAR,CACE,wEADF;;AAGA,QAAMC,CAAC,GAAGC,WAAKC,IAAL,CAAUI,iBAAV,CAA4BD,OAA5B,CAAV;;AACA,MAAIL,CAAC,KAAK,IAAV,EAAgB;AACd,UAAM,IAAIO,KAAJ,CAAW,qBAAoBF,OAAQ,EAAvC,CAAN;AACD;;AACD,SAAOL,CAAP;AACD,CATD,EASG,CAACK,OAAD,CATH,CADK;AAYP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMG,WAAW,GAAG,CAACC,IAAD,EAAeC,CAAf,EAA0BC,CAA1B,EAAqCC,IAArC,KACzB,oBAAQ,MAAM;AACZd,EAAAA,OAAO,CAACC,IAAR,CACE,oEADF;;AAGA,QAAMC,CAAC,GAAGC,WAAKC,IAAL,CAAUW,YAAV,CAAuBJ,IAAvB,EAA6BC,CAA7B,EAAgCC,CAAhC,EAAmCC,IAAnC,CAAV;;AACA,MAAIZ,CAAC,KAAK,IAAV,EAAgB;AACd,UAAM,IAAIO,KAAJ,CAAU,4BAAV,CAAN;AACD;;AACD,SAAOP,CAAP;AACD,CATD,EASG,CAACS,IAAD,EAAOC,CAAP,EAAUC,CAAV,EAAaC,IAAb,CATH,CADK","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkFont, SkPath } from \"../types\";\n\n/**\n * Memoizes and returns a Skia Path object with optional initializer\n * @param initializer\n * @param deps\n * @returns\n */\nexport const usePath = (\n initializer?: (path: SkPath) => void,\n deps?: DependencyList\n) =>\n useMemo(() => {\n console.warn(\"usePath() is deprecated. Use Skia.Path.Make() instead.\");\n const p = Skia.Path.Make();\n if (initializer) {\n initializer(p);\n }\n return p;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [initializer, deps]);\n\n/**\n * Initializes a Skia Path from an svg path string\n * @param svgpath\n * @returns\n */\n// MakeFromSVGString\nexport const useSvgPath = (svgpath: string) =>\n useMemo(() => {\n console.warn(\n \"useSvgPath() is deprecated. Use Skia.Path.MakeFromSVGString() instead.\"\n );\n const p = Skia.Path.MakeFromSVGString(svgpath);\n if (p === null) {\n throw new Error(`Invalid SVG path: ${svgpath}`);\n }\n return p;\n }, [svgpath]);\n\n/**\n * Initializes a Skia Path from a text string\n * @param svgpath\n * @returns\n */\nexport const useTextPath = (text: string, x: number, y: number, font: SkFont) =>\n useMemo(() => {\n console.warn(\n \"useTextPath() is deprecated. Use Skia.Path.MakeFromText() instead.\"\n );\n const p = Skia.Path.MakeFromText(text, x, y, font);\n if (p === null) {\n throw new Error(\"Text path creation failed.\");\n }\n return p;\n }, [text, x, y, font]);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|