@shopify/react-native-skia 0.1.209 → 0.1.211
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkAnimatedImage.h +60 -0
- package/cpp/api/JsiSkAnimatedImageFactory.h +39 -0
- package/cpp/api/JsiSkApi.h +4 -0
- package/cpp/api/JsiSkFont.h +17 -0
- package/cpp/api/JsiSkImage.h +15 -23
- package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -0
- package/lib/commonjs/external/reanimated/moduleWrapper.js +11 -11
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.d.ts +6 -0
- package/lib/commonjs/skia/core/AnimatedImage.js +65 -0
- package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -0
- package/lib/commonjs/skia/core/index.d.ts +1 -0
- package/lib/commonjs/skia/core/index.js +13 -0
- package/lib/commonjs/skia/core/index.js.map +1 -1
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
- package/lib/commonjs/{dom/nodes/PaintContext.js → skia/types/AnimatedImage/AnimatedImage.js} +1 -1
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.js.map +1 -0
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.js +6 -0
- package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.js.map +1 -0
- package/lib/commonjs/skia/types/AnimatedImage/index.d.ts +2 -0
- package/lib/commonjs/skia/types/AnimatedImage/index.js +32 -0
- package/lib/commonjs/skia/types/AnimatedImage/index.js.map +1 -0
- package/lib/commonjs/skia/types/Font/Font.d.ts +9 -0
- package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +2 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/index.d.ts +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/JsiSkAnimatedImage.d.ts +11 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImage.js +44 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImage.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.js +32 -0
- package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkFont.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +4 -0
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +3 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -0
- package/lib/module/external/reanimated/moduleWrapper.js +8 -11
- package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/module/skia/core/AnimatedImage.d.ts +6 -0
- package/lib/module/skia/core/AnimatedImage.js +49 -0
- package/lib/module/skia/core/AnimatedImage.js.map +1 -0
- package/lib/module/skia/core/index.d.ts +1 -0
- package/lib/module/skia/core/index.js +1 -0
- package/lib/module/skia/core/index.js.map +1 -1
- package/lib/module/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImage.js +2 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImage.js.map +1 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.js +2 -0
- package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.js.map +1 -0
- package/lib/module/skia/types/AnimatedImage/index.d.ts +2 -0
- package/lib/module/skia/types/AnimatedImage/index.js +3 -0
- package/lib/module/skia/types/AnimatedImage/index.js.map +1 -0
- package/lib/module/skia/types/Font/Font.d.ts +9 -0
- package/lib/module/skia/types/Font/Font.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +2 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/index.d.ts +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/JsiSkAnimatedImage.d.ts +11 -0
- package/lib/module/skia/web/JsiSkAnimatedImage.js +33 -0
- package/lib/module/skia/web/JsiSkAnimatedImage.js.map +1 -0
- package/lib/module/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
- package/lib/module/skia/web/JsiSkAnimatedImageFactory.js +20 -0
- package/lib/module/skia/web/JsiSkAnimatedImageFactory.js.map +1 -0
- package/lib/module/skia/web/JsiSkFont.d.ts +2 -1
- package/lib/module/skia/web/JsiSkFont.js +5 -1
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +2 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -0
- package/lib/typescript/src/skia/core/AnimatedImage.d.ts +6 -0
- package/lib/typescript/src/skia/core/index.d.ts +1 -0
- package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
- package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
- package/lib/typescript/src/skia/types/AnimatedImage/index.d.ts +2 -0
- package/lib/typescript/src/skia/types/Font/Font.d.ts +9 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkAnimatedImage.d.ts +11 -0
- package/lib/typescript/src/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
- package/lib/typescript/src/skia/web/JsiSkFont.d.ts +2 -1
- package/package.json +1 -1
- package/src/external/reanimated/moduleWrapper.ts +9 -8
- package/src/skia/core/AnimatedImage.ts +63 -0
- package/src/skia/core/index.ts +1 -0
- package/src/skia/types/AnimatedImage/AnimatedImage.ts +29 -0
- package/src/skia/types/AnimatedImage/AnimatedImageFactory.ts +15 -0
- package/src/skia/types/AnimatedImage/index.ts +2 -0
- package/src/skia/types/Font/Font.ts +10 -0
- package/src/skia/types/Skia.ts +3 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkAnimatedImage.ts +35 -0
- package/src/skia/web/JsiSkAnimatedImageFactory.ts +27 -0
- package/src/skia/web/JsiSkFont.ts +6 -1
- package/src/skia/web/JsiSkia.ts +2 -0
- package/lib/commonjs/dom/nodes/PaintContext.d.ts +0 -19
- package/lib/commonjs/dom/nodes/PaintContext.js.map +0 -1
- package/lib/module/dom/nodes/PaintContext.d.ts +0 -19
- package/lib/module/dom/nodes/PaintContext.js +0 -2
- package/lib/module/dom/nodes/PaintContext.js.map +0 -1
- package/lib/typescript/src/dom/nodes/PaintContext.d.ts +0 -19
- package/src/dom/nodes/PaintContext.ts +0 -32
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { SkData } from "../Data";
|
2
|
+
|
3
|
+
import type { SkAnimatedImage } from "./AnimatedImage";
|
4
|
+
|
5
|
+
export interface AnimatedImageFactory {
|
6
|
+
/**
|
7
|
+
* Decodes the given bytes into an animated image. Returns null if the bytes were invalid.
|
8
|
+
* The passed in bytes will be copied into the WASM heap, so the caller can dispose of them.
|
9
|
+
*
|
10
|
+
* The returned AnimatedImage will be "pointing to" the first frame, i.e. currentFrameDuration
|
11
|
+
* and makeImageAtCurrentFrame will be referring to the first frame.
|
12
|
+
* @param encoded
|
13
|
+
*/
|
14
|
+
MakeAnimatedImageFromEncoded: (encoded: SkData) => SkAnimatedImage | null;
|
15
|
+
}
|
@@ -12,10 +12,20 @@ export interface FontMetrics {
|
|
12
12
|
}
|
13
13
|
|
14
14
|
export interface SkFont extends SkJSIInstance<"Font"> {
|
15
|
+
/**
|
16
|
+
* Returns the advance width of text.
|
17
|
+
* The advance is the normal distance to move before drawing additional text.
|
18
|
+
* Returns the bounding box of text
|
19
|
+
* @param text
|
20
|
+
* @param paint
|
21
|
+
*/
|
22
|
+
measureText(text: string, paint?: SkPaint): SkRect;
|
23
|
+
|
15
24
|
/**
|
16
25
|
* Retrieves the total width of the provided text
|
17
26
|
* @param text
|
18
27
|
* @param paint
|
28
|
+
* @deprecated Use measureText or getGlyphWidths instead
|
19
29
|
*/
|
20
30
|
getTextWidth(text: string, paint?: SkPaint): number;
|
21
31
|
|
package/src/skia/types/Skia.ts
CHANGED
@@ -28,6 +28,8 @@ import type { SkContourMeasureIter } from "./ContourMeasure";
|
|
28
28
|
import type { PictureFactory, SkPictureRecorder } from "./Picture";
|
29
29
|
import type { Color, SkColor } from "./Color";
|
30
30
|
import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
|
31
|
+
import type { AnimatedImageFactory } from "./AnimatedImage";
|
32
|
+
|
31
33
|
/**
|
32
34
|
* Declares the interface for the native Skia API
|
33
35
|
*/
|
@@ -78,6 +80,7 @@ export interface Skia {
|
|
78
80
|
): SkVertices;
|
79
81
|
Data: DataFactory;
|
80
82
|
Image: ImageFactory;
|
83
|
+
AnimatedImage: AnimatedImageFactory;
|
81
84
|
SVG: SVGFactory;
|
82
85
|
TextBlob: TextBlobFactory;
|
83
86
|
Surface: SurfaceFactory;
|
package/src/skia/types/index.ts
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
import type { AnimatedImage, CanvasKit } from "canvaskit-wasm";
|
2
|
+
|
3
|
+
import type { SkAnimatedImage } from "../types/AnimatedImage";
|
4
|
+
|
5
|
+
import { HostObject } from "./Host";
|
6
|
+
import { JsiSkImage } from "./JsiSkImage";
|
7
|
+
|
8
|
+
export class JsiSkAnimatedImage
|
9
|
+
extends HostObject<AnimatedImage, "AnimatedImage">
|
10
|
+
implements SkAnimatedImage
|
11
|
+
{
|
12
|
+
constructor(CanvasKit: CanvasKit, ref: AnimatedImage) {
|
13
|
+
super(CanvasKit, ref, "AnimatedImage");
|
14
|
+
}
|
15
|
+
|
16
|
+
decodeNextFrame() {
|
17
|
+
return this.ref.decodeNextFrame();
|
18
|
+
}
|
19
|
+
|
20
|
+
currentFrameDuration() {
|
21
|
+
return this.ref.currentFrameDuration();
|
22
|
+
}
|
23
|
+
|
24
|
+
getCurrentFrame() {
|
25
|
+
const image = this.ref.makeImageAtCurrentFrame();
|
26
|
+
if (image === null) {
|
27
|
+
return null;
|
28
|
+
}
|
29
|
+
return new JsiSkImage(this.CanvasKit, image);
|
30
|
+
}
|
31
|
+
|
32
|
+
dispose = () => {
|
33
|
+
this.ref.delete();
|
34
|
+
};
|
35
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { CanvasKit } from "canvaskit-wasm";
|
2
|
+
|
3
|
+
import type { SkData } from "../types";
|
4
|
+
import type { AnimatedImageFactory } from "../types/AnimatedImage/AnimatedImageFactory";
|
5
|
+
|
6
|
+
import { Host } from "./Host";
|
7
|
+
import { JsiSkData } from "./JsiSkData";
|
8
|
+
import { JsiSkAnimatedImage } from "./JsiSkAnimatedImage";
|
9
|
+
|
10
|
+
export class JsiSkAnimatedImageFactory
|
11
|
+
extends Host
|
12
|
+
implements AnimatedImageFactory
|
13
|
+
{
|
14
|
+
constructor(CanvasKit: CanvasKit) {
|
15
|
+
super(CanvasKit);
|
16
|
+
}
|
17
|
+
|
18
|
+
MakeAnimatedImageFromEncoded(encoded: SkData) {
|
19
|
+
const image = this.CanvasKit.MakeAnimatedImageFromEncoded(
|
20
|
+
JsiSkData.fromValue(encoded)
|
21
|
+
);
|
22
|
+
if (image === null) {
|
23
|
+
return null;
|
24
|
+
}
|
25
|
+
return new JsiSkAnimatedImage(this.CanvasKit, image);
|
26
|
+
}
|
27
|
+
}
|
@@ -6,10 +6,11 @@ import type {
|
|
6
6
|
SkFont,
|
7
7
|
SkPaint,
|
8
8
|
SkPoint,
|
9
|
+
SkRect,
|
9
10
|
SkTypeface,
|
10
11
|
} from "../types";
|
11
12
|
|
12
|
-
import { HostObject, ckEnum } from "./Host";
|
13
|
+
import { HostObject, NotImplementedOnRNWeb, ckEnum } from "./Host";
|
13
14
|
import { JsiSkPaint } from "./JsiSkPaint";
|
14
15
|
import { JsiSkPoint } from "./JsiSkPoint";
|
15
16
|
import { JsiSkRect } from "./JsiSkRect";
|
@@ -20,6 +21,10 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
20
21
|
super(CanvasKit, ref, "Font");
|
21
22
|
}
|
22
23
|
|
24
|
+
measureText(_text: string, _paint?: SkPaint | undefined): SkRect {
|
25
|
+
throw new NotImplementedOnRNWeb();
|
26
|
+
}
|
27
|
+
|
23
28
|
dispose = () => {
|
24
29
|
this.ref.delete();
|
25
30
|
};
|
package/src/skia/web/JsiSkia.ts
CHANGED
@@ -39,6 +39,7 @@ import { JsiSkPath } from "./JsiSkPath";
|
|
39
39
|
import { JsiSkTypeface } from "./JsiSkTypeface";
|
40
40
|
import { JsiSkTypefaceFontProviderFactory } from "./JsiSkTypefaceFontProviderFactory";
|
41
41
|
import { JsiSkFontMgrFactory } from "./JsiSkFontMgrFactory";
|
42
|
+
import { JsiSkAnimatedImageFactory } from "./JsiSkAnimatedImageFactory";
|
42
43
|
|
43
44
|
export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
|
44
45
|
Point: (x: number, y: number) =>
|
@@ -98,6 +99,7 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
|
|
98
99
|
MakeVertices: MakeVertices.bind(null, CanvasKit),
|
99
100
|
Data: new JsiSkDataFactory(CanvasKit),
|
100
101
|
Image: new JsiSkImageFactory(CanvasKit),
|
102
|
+
AnimatedImage: new JsiSkAnimatedImageFactory(CanvasKit),
|
101
103
|
SVG: new JsiSkSVGFactory(CanvasKit),
|
102
104
|
TextBlob: new JsiSkTextBlobFactory(CanvasKit),
|
103
105
|
XYWHRect: (x: number, y: number, width: number, height: number) => {
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { BlendMode, PaintStyle, SkColorFilter, SkImageFilter, SkMaskFilter, SkPathEffect, SkShader, StrokeCap, StrokeJoin } from "../../skia/types";
|
2
|
-
import type { SkColor } from "../../skia/types/Color";
|
3
|
-
export interface PaintContext {
|
4
|
-
color?: SkColor;
|
5
|
-
strokeWidth?: number;
|
6
|
-
blendMode?: BlendMode;
|
7
|
-
style?: PaintStyle;
|
8
|
-
strokeJoin?: StrokeJoin;
|
9
|
-
strokeCap?: StrokeCap;
|
10
|
-
strokeMiter?: number;
|
11
|
-
opacity?: number;
|
12
|
-
antiAlias?: boolean;
|
13
|
-
dither?: boolean;
|
14
|
-
shader?: SkShader;
|
15
|
-
colorFilter?: SkColorFilter;
|
16
|
-
imageFilter?: SkImageFilter;
|
17
|
-
maskFilter?: SkMaskFilter;
|
18
|
-
pathEffect?: SkPathEffect;
|
19
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["PaintContext.ts"],"sourcesContent":["import type {\n BlendMode,\n PaintStyle,\n SkColorFilter,\n SkImageFilter,\n SkMaskFilter,\n SkPathEffect,\n SkShader,\n StrokeCap,\n StrokeJoin,\n} from \"../../skia/types\";\nimport type { SkColor } from \"../../skia/types/Color\";\n\n// TODO: to remove\nexport interface PaintContext {\n color?: SkColor;\n strokeWidth?: number;\n blendMode?: BlendMode;\n style?: PaintStyle;\n strokeJoin?: StrokeJoin;\n strokeCap?: StrokeCap;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n dither?: boolean;\n\n shader?: SkShader;\n colorFilter?: SkColorFilter;\n imageFilter?: SkImageFilter;\n maskFilter?: SkMaskFilter;\n pathEffect?: SkPathEffect;\n}\n"],"mappings":""}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { BlendMode, PaintStyle, SkColorFilter, SkImageFilter, SkMaskFilter, SkPathEffect, SkShader, StrokeCap, StrokeJoin } from "../../skia/types";
|
2
|
-
import type { SkColor } from "../../skia/types/Color";
|
3
|
-
export interface PaintContext {
|
4
|
-
color?: SkColor;
|
5
|
-
strokeWidth?: number;
|
6
|
-
blendMode?: BlendMode;
|
7
|
-
style?: PaintStyle;
|
8
|
-
strokeJoin?: StrokeJoin;
|
9
|
-
strokeCap?: StrokeCap;
|
10
|
-
strokeMiter?: number;
|
11
|
-
opacity?: number;
|
12
|
-
antiAlias?: boolean;
|
13
|
-
dither?: boolean;
|
14
|
-
shader?: SkShader;
|
15
|
-
colorFilter?: SkColorFilter;
|
16
|
-
imageFilter?: SkImageFilter;
|
17
|
-
maskFilter?: SkMaskFilter;
|
18
|
-
pathEffect?: SkPathEffect;
|
19
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["PaintContext.ts"],"sourcesContent":["import type {\n BlendMode,\n PaintStyle,\n SkColorFilter,\n SkImageFilter,\n SkMaskFilter,\n SkPathEffect,\n SkShader,\n StrokeCap,\n StrokeJoin,\n} from \"../../skia/types\";\nimport type { SkColor } from \"../../skia/types/Color\";\n\n// TODO: to remove\nexport interface PaintContext {\n color?: SkColor;\n strokeWidth?: number;\n blendMode?: BlendMode;\n style?: PaintStyle;\n strokeJoin?: StrokeJoin;\n strokeCap?: StrokeCap;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n dither?: boolean;\n\n shader?: SkShader;\n colorFilter?: SkColorFilter;\n imageFilter?: SkImageFilter;\n maskFilter?: SkMaskFilter;\n pathEffect?: SkPathEffect;\n}\n"],"mappings":""}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { BlendMode, PaintStyle, SkColorFilter, SkImageFilter, SkMaskFilter, SkPathEffect, SkShader, StrokeCap, StrokeJoin } from "../../skia/types";
|
2
|
-
import type { SkColor } from "../../skia/types/Color";
|
3
|
-
export interface PaintContext {
|
4
|
-
color?: SkColor;
|
5
|
-
strokeWidth?: number;
|
6
|
-
blendMode?: BlendMode;
|
7
|
-
style?: PaintStyle;
|
8
|
-
strokeJoin?: StrokeJoin;
|
9
|
-
strokeCap?: StrokeCap;
|
10
|
-
strokeMiter?: number;
|
11
|
-
opacity?: number;
|
12
|
-
antiAlias?: boolean;
|
13
|
-
dither?: boolean;
|
14
|
-
shader?: SkShader;
|
15
|
-
colorFilter?: SkColorFilter;
|
16
|
-
imageFilter?: SkImageFilter;
|
17
|
-
maskFilter?: SkMaskFilter;
|
18
|
-
pathEffect?: SkPathEffect;
|
19
|
-
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import type {
|
2
|
-
BlendMode,
|
3
|
-
PaintStyle,
|
4
|
-
SkColorFilter,
|
5
|
-
SkImageFilter,
|
6
|
-
SkMaskFilter,
|
7
|
-
SkPathEffect,
|
8
|
-
SkShader,
|
9
|
-
StrokeCap,
|
10
|
-
StrokeJoin,
|
11
|
-
} from "../../skia/types";
|
12
|
-
import type { SkColor } from "../../skia/types/Color";
|
13
|
-
|
14
|
-
// TODO: to remove
|
15
|
-
export interface PaintContext {
|
16
|
-
color?: SkColor;
|
17
|
-
strokeWidth?: number;
|
18
|
-
blendMode?: BlendMode;
|
19
|
-
style?: PaintStyle;
|
20
|
-
strokeJoin?: StrokeJoin;
|
21
|
-
strokeCap?: StrokeCap;
|
22
|
-
strokeMiter?: number;
|
23
|
-
opacity?: number;
|
24
|
-
antiAlias?: boolean;
|
25
|
-
dither?: boolean;
|
26
|
-
|
27
|
-
shader?: SkShader;
|
28
|
-
colorFilter?: SkColorFilter;
|
29
|
-
imageFilter?: SkImageFilter;
|
30
|
-
maskFilter?: SkMaskFilter;
|
31
|
-
pathEffect?: SkPathEffect;
|
32
|
-
}
|