@shopify/react-native-skia 0.1.227 → 0.1.229
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/cpp/api/JsiSkCanvas.h +2 -1
- package/cpp/api/JsiSkMatrix.h +27 -11
- package/cpp/api/JsiSkTypeface.h +1 -0
- package/cpp/rnskia/dom/props/MatrixProp.h +14 -3
- package/lib/commonjs/dom/types/Common.d.ts +2 -2
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -0
- package/lib/commonjs/external/reanimated/interpolators.js +16 -3
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -1
- package/lib/commonjs/external/reanimated/moduleWrapper.js +9 -7
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +7 -13
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/core/Vector.d.ts +0 -5
- package/lib/commonjs/skia/core/Vector.js +1 -17
- package/lib/commonjs/skia/core/Vector.js.map +1 -1
- package/lib/commonjs/skia/types/Canvas.d.ts +2 -2
- package/lib/commonjs/skia/types/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix.d.ts +3 -13
- package/lib/commonjs/skia/types/Matrix.js +1 -16
- package/lib/commonjs/skia/types/Matrix.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +60 -1
- package/lib/commonjs/skia/types/Matrix4.js +159 -14
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.d.ts +2 -2
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/web/Host.d.ts +2 -3
- package/lib/commonjs/skia/web/Host.js +4 -12
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +12 -12
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
- package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
- package/lib/module/dom/types/Common.d.ts +2 -2
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.d.ts +1 -0
- package/lib/module/external/reanimated/interpolators.js +14 -4
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
- package/lib/module/external/reanimated/moduleWrapper.js +7 -6
- package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/module/renderer/Canvas.js +7 -12
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/core/Vector.d.ts +0 -5
- package/lib/module/skia/core/Vector.js +0 -13
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/lib/module/skia/types/Canvas.d.ts +2 -2
- package/lib/module/skia/types/Canvas.js.map +1 -1
- package/lib/module/skia/types/Matrix.d.ts +3 -13
- package/lib/module/skia/types/Matrix.js +0 -14
- package/lib/module/skia/types/Matrix.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +60 -1
- package/lib/module/skia/types/Matrix4.js +132 -18
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Path/Path.d.ts +2 -2
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/web/Host.d.ts +2 -3
- package/lib/module/skia/web/Host.js +2 -7
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +13 -13
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
- package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +3 -3
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +7 -7
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
- package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
- package/lib/module/skia/web/JsiSkMatrix.js +6 -1
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +4 -4
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +5 -5
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPicture.js +2 -2
- package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
- package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
- package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
- package/lib/typescript/src/dom/types/Common.d.ts +2 -2
- package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
- package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
- package/lib/typescript/src/skia/types/Canvas.d.ts +2 -2
- package/lib/typescript/src/skia/types/Matrix.d.ts +3 -13
- package/lib/typescript/src/skia/types/Matrix4.d.ts +60 -1
- package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -2
- package/lib/typescript/src/skia/web/Host.d.ts +2 -3
- package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
- package/package.json +2 -1
- package/src/dom/types/Common.ts +2 -2
- package/src/external/reanimated/interpolators.ts +20 -5
- package/src/external/reanimated/moduleWrapper.ts +6 -0
- package/src/renderer/Canvas.tsx +6 -13
- package/src/skia/core/Vector.ts +0 -7
- package/src/skia/types/Canvas.ts +2 -2
- package/src/skia/types/Matrix.ts +4 -13
- package/src/skia/types/Matrix4.ts +190 -81
- package/src/skia/types/Path/Path.ts +2 -2
- package/src/skia/web/Host.ts +4 -3
- package/src/skia/web/JsiSkCanvas.ts +22 -15
- package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
- package/src/skia/web/JsiSkFont.ts +3 -3
- package/src/skia/web/JsiSkImage.ts +14 -11
- package/src/skia/web/JsiSkImageFactory.ts +3 -3
- package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
- package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
- package/src/skia/web/JsiSkMatrix.ts +12 -3
- package/src/skia/web/JsiSkPaint.ts +4 -4
- package/src/skia/web/JsiSkPath.ts +8 -5
- package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
- package/src/skia/web/JsiSkPathFactory.ts +2 -2
- package/src/skia/web/JsiSkPicture.ts +4 -4
- package/src/skia/web/JsiSkShaderFactory.ts +6 -6
- package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ckEnum } from "./Host";
|
|
2
1
|
import { JsiSkVertices } from "./JsiSkVertices";
|
|
2
|
+
import { getEnum } from "./Host";
|
|
3
3
|
|
|
4
4
|
const concat = function () {
|
|
5
5
|
let totalLength = 0;
|
|
@@ -23,7 +23,7 @@ const concat = function () {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export const MakeVertices = (CanvasKit, mode, positions, textureCoordinates, colors, indices, isVolatile) => new JsiSkVertices(CanvasKit, CanvasKit.MakeVertices(
|
|
26
|
+
export const MakeVertices = (CanvasKit, mode, positions, textureCoordinates, colors, indices, isVolatile) => new JsiSkVertices(CanvasKit, CanvasKit.MakeVertices(getEnum(CanvasKit.VertexMode, mode), positions.map(_ref => {
|
|
27
27
|
let {
|
|
28
28
|
x,
|
|
29
29
|
y
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["JsiSkVertices","getEnum","concat","totalLength","arrays","arr","length","result","Float32Array","offset","set","MakeVertices","CanvasKit","mode","positions","textureCoordinates","colors","indices","isVolatile","VertexMode","map","x","y","flat","reduce","a","c"],"sources":["JsiSkVerticesFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkColor, SkPoint, VertexMode } from \"../types\";\n\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { getEnum } from \"./Host\";\n\nconst concat = (...arrays: Float32Array[]) => {\n let totalLength = 0;\n for (const arr of arrays) {\n totalLength += arr.length;\n }\n const result = new Float32Array(totalLength);\n let offset = 0;\n for (const arr of arrays) {\n result.set(arr, offset);\n offset += arr.length;\n }\n return result;\n};\n\nexport const MakeVertices = (\n CanvasKit: CanvasKit,\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n) =>\n new JsiSkVertices(\n CanvasKit,\n CanvasKit.MakeVertices(\n getEnum(CanvasKit.VertexMode, mode),\n positions.map(({ x, y }) => [x, y]).flat(),\n (textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),\n !colors ? null : colors.reduce((a, c) => concat(a, c)),\n indices,\n isVolatile\n )\n );\n"],"mappings":"AAIA,SAASA,aAAT,QAA8B,iBAA9B;AACA,SAASC,OAAT,QAAwB,QAAxB;;AAEA,MAAMC,MAAM,GAAG,YAA+B;EAC5C,IAAIC,WAAW,GAAG,CAAlB;;EAD4C,kCAA3BC,MAA2B;IAA3BA,MAA2B;EAAA;;EAE5C,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACxBD,WAAW,IAAIE,GAAG,CAACC,MAAnB;EACD;;EACD,MAAMC,MAAM,GAAG,IAAIC,YAAJ,CAAiBL,WAAjB,CAAf;EACA,IAAIM,MAAM,GAAG,CAAb;;EACA,KAAK,MAAMJ,GAAX,IAAkBD,MAAlB,EAA0B;IACxBG,MAAM,CAACG,GAAP,CAAWL,GAAX,EAAgBI,MAAhB;IACAA,MAAM,IAAIJ,GAAG,CAACC,MAAd;EACD;;EACD,OAAOC,MAAP;AACD,CAZD;;AAcA,OAAO,MAAMI,YAAY,GAAG,CAC1BC,SAD0B,EAE1BC,IAF0B,EAG1BC,SAH0B,EAI1BC,kBAJ0B,EAK1BC,MAL0B,EAM1BC,OAN0B,EAO1BC,UAP0B,KAS1B,IAAIlB,aAAJ,CACEY,SADF,EAEEA,SAAS,CAACD,YAAV,CACEV,OAAO,CAACW,SAAS,CAACO,UAAX,EAAuBN,IAAvB,CADT,EAEEC,SAAS,CAACM,GAAV,CAAc;EAAA,IAAC;IAAEC,CAAF;IAAKC;EAAL,CAAD;EAAA,OAAc,CAACD,CAAD,EAAIC,CAAJ,CAAd;AAAA,CAAd,EAAoCC,IAApC,EAFF,EAGE,CAACR,kBAAkB,IAAI,EAAvB,EAA2BK,GAA3B,CAA+B;EAAA,IAAC;IAAEC,CAAF;IAAKC;EAAL,CAAD;EAAA,OAAc,CAACD,CAAD,EAAIC,CAAJ,CAAd;AAAA,CAA/B,EAAqDC,IAArD,EAHF,EAIE,CAACP,MAAD,GAAU,IAAV,GAAiBA,MAAM,CAACQ,MAAP,CAAc,CAACC,CAAD,EAAIC,CAAJ,KAAUxB,MAAM,CAACuB,CAAD,EAAIC,CAAJ,CAA9B,CAJnB,EAKET,OALF,EAMEC,UANF,CAFF,CATK"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { BlendMode, Color,
|
|
2
|
+
import type { BlendMode, Color, InputMatrix, PaintStyle, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms3d, Vector } from "../../skia/types";
|
|
3
3
|
export type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;
|
|
4
4
|
export type PathDef = string | SkPath;
|
|
5
5
|
export type ClipDef = SkRRect | SkRect | PathDef;
|
|
@@ -36,7 +36,7 @@ export type CircleDef = PointCircleDef | ScalarCircleDef;
|
|
|
36
36
|
export interface TransformProps {
|
|
37
37
|
transform?: Transforms3d;
|
|
38
38
|
origin?: Vector;
|
|
39
|
-
matrix?:
|
|
39
|
+
matrix?: InputMatrix;
|
|
40
40
|
}
|
|
41
41
|
export interface PaintProps extends ChildrenProps {
|
|
42
42
|
color?: Color;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
|
|
2
2
|
import type { SkPath, SkPoint } from "../../skia/types";
|
|
3
3
|
export declare const notifyChange: (value: SharedValue<unknown>) => void;
|
|
4
|
+
export declare const usePathValue: (cb: (path: SkPath) => void) => SharedValue<SkPath>;
|
|
4
5
|
export declare const useClock: () => SharedValue<number>;
|
|
5
6
|
export declare const usePathInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPath[], options?: ExtrapolationType) => SharedValue<SkPath>;
|
|
6
7
|
export declare const useVectorInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPoint[], options?: ExtrapolationType) => SharedValue<{
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { DependencyList } from "react";
|
|
2
|
-
import type { FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
|
|
2
|
+
import type { DerivedValue, FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
|
|
3
3
|
export declare const HAS_REANIMATED2: boolean;
|
|
4
4
|
export declare const HAS_REANIMATED3: boolean;
|
|
5
5
|
export declare function throwOnMissingReanimated(): void;
|
|
6
6
|
export declare const useSharedValue: <T>(init: T, oneWayReadsOnly?: boolean) => SharedValue<T>;
|
|
7
|
+
export declare const useDerivedValue: <T>(processor: () => T, dependencies?: DependencyList) => DerivedValue<T>;
|
|
7
8
|
export declare const useFrameCallback: (callback: (frameInfo: FrameInfo) => void, autostart?: boolean) => FrameCallback;
|
|
8
9
|
export declare const startMapper: (worklet: () => void, inputs?: unknown[], outputs?: unknown[]) => number;
|
|
9
10
|
export declare const stopMapper: (mapperID: number) => void;
|
|
@@ -5,8 +5,3 @@ export declare const neg: (a: Vector) => import("../types").SkPoint;
|
|
|
5
5
|
export declare const add: (a: Vector, b: Vector) => import("../types").SkPoint;
|
|
6
6
|
export declare const sub: (a: Vector, b: Vector) => import("../types").SkPoint;
|
|
7
7
|
export declare const dist: (a: Vector, b: Vector) => number;
|
|
8
|
-
export declare const translate: ({ x, y, }: Vector) => [{
|
|
9
|
-
translateX: number;
|
|
10
|
-
}, {
|
|
11
|
-
translateY: number;
|
|
12
|
-
}];
|
|
@@ -8,7 +8,7 @@ import type { SkColor } from "./Color";
|
|
|
8
8
|
import type { SkRRect } from "./RRect";
|
|
9
9
|
import type { BlendMode } from "./Paint/BlendMode";
|
|
10
10
|
import type { SkPoint, PointMode } from "./Point";
|
|
11
|
-
import type {
|
|
11
|
+
import type { InputMatrix } from "./Matrix";
|
|
12
12
|
import type { SkImageFilter } from "./ImageFilter";
|
|
13
13
|
import type { SkVertices } from "./Vertices";
|
|
14
14
|
import type { SkTextBlob } from "./TextBlob";
|
|
@@ -372,7 +372,7 @@ export interface SkCanvas {
|
|
|
372
372
|
* Replaces current matrix with m premultiplied with the existing matrix.
|
|
373
373
|
* @param m
|
|
374
374
|
*/
|
|
375
|
-
concat(m:
|
|
375
|
+
concat(m: InputMatrix): void;
|
|
376
376
|
/**
|
|
377
377
|
* Draws the given picture using the current clip, current matrix, and the provided paint.
|
|
378
378
|
* @param skp
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import type { SkJSIInstance } from "./JsiInstance";
|
|
2
2
|
import type { SkCanvas } from "./Canvas";
|
|
3
|
-
import type { Transforms3d } from "./Matrix4";
|
|
4
|
-
export declare enum MatrixIndex {
|
|
5
|
-
ScaleX = 0,
|
|
6
|
-
SkewX = 1,
|
|
7
|
-
TransX = 2,
|
|
8
|
-
SkewY = 3,
|
|
9
|
-
ScaleY = 4,
|
|
10
|
-
TransY = 5,
|
|
11
|
-
Persp0 = 6,
|
|
12
|
-
Persp1 = 7,
|
|
13
|
-
Persp2 = 8
|
|
14
|
-
}
|
|
3
|
+
import type { Matrix3, Matrix4, Transforms3d } from "./Matrix4";
|
|
15
4
|
export declare const isMatrix: (obj: unknown) => obj is SkMatrix;
|
|
16
5
|
export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
|
17
|
-
concat: (matrix:
|
|
6
|
+
concat: (matrix: InputMatrix) => SkMatrix;
|
|
18
7
|
translate: (x: number, y: number) => SkMatrix;
|
|
19
8
|
scale: (x: number, y?: number) => SkMatrix;
|
|
20
9
|
skew: (x: number, y: number) => SkMatrix;
|
|
@@ -26,6 +15,7 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
|
|
26
15
|
identity: () => SkMatrix;
|
|
27
16
|
get: () => number[];
|
|
28
17
|
}
|
|
18
|
+
export type InputMatrix = SkMatrix | Matrix3 | Matrix4 | number[];
|
|
29
19
|
export interface TransformProp {
|
|
30
20
|
transform?: Transforms3d;
|
|
31
21
|
}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
type Point = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
1
5
|
type Vec2 = readonly [number, number];
|
|
2
6
|
type Vec3 = readonly [number, number, number];
|
|
7
|
+
export type Matrix3 = readonly [
|
|
8
|
+
number,
|
|
9
|
+
number,
|
|
10
|
+
number,
|
|
11
|
+
number,
|
|
12
|
+
number,
|
|
13
|
+
number,
|
|
14
|
+
number,
|
|
15
|
+
number,
|
|
16
|
+
number
|
|
17
|
+
];
|
|
3
18
|
export type Matrix4 = readonly [
|
|
4
19
|
number,
|
|
5
20
|
number,
|
|
@@ -28,6 +43,14 @@ export type Transforms3d = Transform3d[];
|
|
|
28
43
|
* @worklet
|
|
29
44
|
*/
|
|
30
45
|
export declare const Matrix4: () => Matrix4;
|
|
46
|
+
/**
|
|
47
|
+
* @worklet
|
|
48
|
+
*/
|
|
49
|
+
export declare const translate: (x: number, y: number, z?: number) => Matrix4;
|
|
50
|
+
/**
|
|
51
|
+
* @worklet
|
|
52
|
+
*/
|
|
53
|
+
export declare const perspective: (p: number) => Matrix4;
|
|
31
54
|
/**
|
|
32
55
|
* @worklet
|
|
33
56
|
*/
|
|
@@ -35,5 +58,41 @@ export declare const mapPoint3d: (m: Matrix4, v: Vec3) => readonly [number, numb
|
|
|
35
58
|
/**
|
|
36
59
|
* @worklet
|
|
37
60
|
*/
|
|
38
|
-
export declare const
|
|
61
|
+
export declare const multiply4: (a: Matrix4, b: Matrix4) => Matrix4;
|
|
62
|
+
/**
|
|
63
|
+
* @worklet
|
|
64
|
+
*/
|
|
65
|
+
export declare const toMatrix3: (m: Matrix4) => number[];
|
|
66
|
+
/**
|
|
67
|
+
* @worklet
|
|
68
|
+
*/
|
|
69
|
+
export declare const pivot: (m: Matrix4, p: Point) => Matrix4;
|
|
70
|
+
/**
|
|
71
|
+
* @worklet
|
|
72
|
+
*/
|
|
73
|
+
export declare const scale: (sx: number, sy: number, sz?: number, p?: Point) => Matrix4;
|
|
74
|
+
/**
|
|
75
|
+
* @worklet
|
|
76
|
+
*/
|
|
77
|
+
export declare const rotateZ: (value: number, p?: Point) => Matrix4;
|
|
78
|
+
/**
|
|
79
|
+
* @worklet
|
|
80
|
+
*/
|
|
81
|
+
export declare const rotateX: (value: number, p?: Point) => Matrix4;
|
|
82
|
+
/**
|
|
83
|
+
* @worklet
|
|
84
|
+
*/
|
|
85
|
+
export declare const rotateY: (value: number, p?: Point) => Matrix4;
|
|
86
|
+
/**
|
|
87
|
+
* @worklet
|
|
88
|
+
*/
|
|
89
|
+
export declare const processTransform3d: (transforms: Transforms3d) => Matrix4;
|
|
90
|
+
/**
|
|
91
|
+
* @worklet
|
|
92
|
+
*/
|
|
93
|
+
export declare const convertToColumnMajor: (rowMajorMatrix: Matrix4) => number[];
|
|
94
|
+
/**
|
|
95
|
+
* @worklet
|
|
96
|
+
*/
|
|
97
|
+
export declare const convertToAffineMatrix: (m4: number[]) => number[];
|
|
39
98
|
export {};
|
|
@@ -2,7 +2,7 @@ import type { SkRect } from "../Rect";
|
|
|
2
2
|
import type { SkPoint } from "../Point";
|
|
3
3
|
import type { SkRRect } from "../RRect";
|
|
4
4
|
import type { StrokeJoin, StrokeCap } from "../Paint";
|
|
5
|
-
import type { SkMatrix } from "../Matrix";
|
|
5
|
+
import type { InputMatrix, SkMatrix } from "../Matrix";
|
|
6
6
|
import type { SkJSIInstance } from "../JsiInstance";
|
|
7
7
|
/**
|
|
8
8
|
* Options used for Path.stroke(). If an option is omitted, a sensible default will be used.
|
|
@@ -440,7 +440,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
|
|
|
440
440
|
/**
|
|
441
441
|
* Transforms the path by the specified matrix.
|
|
442
442
|
*/
|
|
443
|
-
transform(m3:
|
|
443
|
+
transform(m3: InputMatrix): SkPath;
|
|
444
444
|
/**
|
|
445
445
|
* Interpolates between Path with point array of equal size.
|
|
446
446
|
* Copy verb array and weights to result, and set result path to a weighted
|
|
@@ -16,6 +16,5 @@ export declare abstract class BaseHostObject<T, N extends string> extends Host i
|
|
|
16
16
|
export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
|
|
17
17
|
static fromValue<T>(value: SkJSIInstance<string>): T;
|
|
18
18
|
}
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
|
|
19
|
+
export declare const getEnum: (e: EmbindEnum, v: number) => EmbindEnumEntity;
|
|
20
|
+
export declare const optEnum: (e: EmbindEnum, value: number | undefined) => EmbindEnumEntity | undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { CanvasKit, Matrix3x3 } from "canvaskit-wasm";
|
|
2
|
-
import type { SkMatrix } from "../types";
|
|
2
|
+
import type { SkMatrix, InputMatrix } from "../types";
|
|
3
3
|
import { HostObject } from "./Host";
|
|
4
4
|
export declare class JsiSkMatrix extends HostObject<Matrix3x3, "Matrix"> implements SkMatrix {
|
|
5
5
|
constructor(CanvasKit: CanvasKit, ref: Matrix3x3);
|
|
6
6
|
private preMultiply;
|
|
7
7
|
private postMultiply;
|
|
8
8
|
dispose: () => void;
|
|
9
|
-
concat(matrix:
|
|
9
|
+
concat(matrix: InputMatrix): this;
|
|
10
10
|
translate(x: number, y: number): this;
|
|
11
11
|
postTranslate(x: number, y: number): this;
|
|
12
12
|
scale(x: number, y?: number): this;
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
|
8
8
|
},
|
|
9
9
|
"title": "React Native Skia",
|
|
10
|
-
"version": "0.1.
|
|
10
|
+
"version": "0.1.229",
|
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
|
12
12
|
"main": "lib/module/index.js",
|
|
13
13
|
"files": [
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"eslint-config-react-native-wcandillon": "3.10.2",
|
|
95
95
|
"eslint-plugin-reanimated": "2.0.0",
|
|
96
96
|
"jest": "29.6.4",
|
|
97
|
+
"jest-diff": "^29.7.0",
|
|
97
98
|
"merge-dirs": "^0.2.1",
|
|
98
99
|
"pixelmatch": "^5.3.0",
|
|
99
100
|
"pngjs": "^6.0.0",
|
package/src/dom/types/Common.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { ReactNode } from "react";
|
|
|
3
3
|
import type {
|
|
4
4
|
BlendMode,
|
|
5
5
|
Color,
|
|
6
|
+
InputMatrix,
|
|
6
7
|
PaintStyle,
|
|
7
|
-
SkMatrix,
|
|
8
8
|
SkPaint,
|
|
9
9
|
SkPath,
|
|
10
10
|
SkRect,
|
|
@@ -66,7 +66,7 @@ export type CircleDef = PointCircleDef | ScalarCircleDef;
|
|
|
66
66
|
export interface TransformProps {
|
|
67
67
|
transform?: Transforms3d;
|
|
68
68
|
origin?: Vector;
|
|
69
|
-
matrix?:
|
|
69
|
+
matrix?: InputMatrix;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export interface PaintProps extends ChildrenProps {
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
FrameInfo,
|
|
4
4
|
SharedValue,
|
|
5
5
|
} from "react-native-reanimated";
|
|
6
|
-
import {
|
|
6
|
+
import { useCallback, useMemo } from "react";
|
|
7
7
|
|
|
8
8
|
import type { SkPath, SkPoint } from "../../skia/types";
|
|
9
9
|
import { interpolatePaths, interpolateVector } from "../../animation";
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
useAnimatedReaction,
|
|
14
14
|
useFrameCallback,
|
|
15
15
|
useSharedValue,
|
|
16
|
+
useDerivedValue,
|
|
16
17
|
} from "./moduleWrapper";
|
|
17
18
|
|
|
18
19
|
export const notifyChange = (value: SharedValue<unknown>) => {
|
|
@@ -23,12 +24,26 @@ export const notifyChange = (value: SharedValue<unknown>) => {
|
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
export const usePathValue = (cb: (path: SkPath) => void) => {
|
|
28
|
+
const pathInit = useMemo(() => Skia.Path.Make(), []);
|
|
29
|
+
const path = useSharedValue(pathInit);
|
|
30
|
+
useDerivedValue(() => {
|
|
31
|
+
path.value.reset();
|
|
32
|
+
cb(path.value);
|
|
33
|
+
notifyChange(path);
|
|
34
|
+
});
|
|
35
|
+
return path;
|
|
36
|
+
};
|
|
37
|
+
|
|
26
38
|
export const useClock = () => {
|
|
27
39
|
const clock = useSharedValue(0);
|
|
28
|
-
const callback =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
const callback = useCallback(
|
|
41
|
+
(info: FrameInfo) => {
|
|
42
|
+
"worklet";
|
|
43
|
+
clock.value = info.timeSinceFirstFrame;
|
|
44
|
+
},
|
|
45
|
+
[clock]
|
|
46
|
+
);
|
|
32
47
|
useFrameCallback(callback);
|
|
33
48
|
return clock;
|
|
34
49
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import type { DependencyList } from "react";
|
|
3
3
|
import type {
|
|
4
|
+
DerivedValue,
|
|
4
5
|
FrameCallback,
|
|
5
6
|
FrameInfo,
|
|
6
7
|
SharedValue,
|
|
@@ -42,6 +43,11 @@ export const useSharedValue: <T>(
|
|
|
42
43
|
oneWayReadsOnly?: boolean
|
|
43
44
|
) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;
|
|
44
45
|
|
|
46
|
+
export const useDerivedValue: <T>(
|
|
47
|
+
processor: () => T,
|
|
48
|
+
dependencies?: DependencyList
|
|
49
|
+
) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;
|
|
50
|
+
|
|
45
51
|
export const useFrameCallback: (
|
|
46
52
|
callback: (frameInfo: FrameInfo) => void,
|
|
47
53
|
autostart?: boolean
|
package/src/renderer/Canvas.tsx
CHANGED
|
@@ -14,11 +14,11 @@ import type {
|
|
|
14
14
|
} from "react";
|
|
15
15
|
import type { LayoutChangeEvent } from "react-native";
|
|
16
16
|
|
|
17
|
-
import { SkiaDomView
|
|
17
|
+
import { SkiaDomView } from "../views";
|
|
18
|
+
import { SkiaDomView as SkiaDomViewWeb } from "../views/SkiaDomView.web";
|
|
18
19
|
import { Skia } from "../skia/Skia";
|
|
19
20
|
import type { TouchHandler, SkiaBaseViewProps } from "../views";
|
|
20
21
|
import type { SkiaValue } from "../values/types";
|
|
21
|
-
import { JsiDrawingContext } from "../dom/types";
|
|
22
22
|
|
|
23
23
|
import { SkiaRoot } from "./Reconciler";
|
|
24
24
|
import { NATIVE_DOM } from "./HostComponents";
|
|
@@ -116,23 +116,16 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
|
116
116
|
/>
|
|
117
117
|
);
|
|
118
118
|
} else {
|
|
119
|
-
// This is for debugging
|
|
120
|
-
const recorder = Skia.PictureRecorder();
|
|
121
|
-
const canvas = recorder.beginRecording(
|
|
122
|
-
Skia.XYWHRect(0, 0, 2_000_000, 2_000_000)
|
|
123
|
-
);
|
|
124
|
-
const ctx = new JsiDrawingContext(Skia, canvas);
|
|
125
|
-
root.dom.render(ctx);
|
|
126
|
-
const picture = recorder.finishRecordingAsPicture();
|
|
127
119
|
return (
|
|
128
|
-
<
|
|
120
|
+
<SkiaDomViewWeb
|
|
129
121
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
122
|
ref={ref as any}
|
|
131
123
|
style={style}
|
|
124
|
+
root={root.dom}
|
|
125
|
+
onTouch={onTouch}
|
|
126
|
+
onLayout={onLayout}
|
|
132
127
|
mode={mode}
|
|
133
128
|
debug={debug}
|
|
134
|
-
picture={picture}
|
|
135
|
-
onLayout={onLayout}
|
|
136
129
|
{...props}
|
|
137
130
|
/>
|
|
138
131
|
);
|
package/src/skia/core/Vector.ts
CHANGED
|
@@ -22,10 +22,3 @@ export const dist = (a: Vector, b: Vector) => {
|
|
|
22
22
|
"worklet";
|
|
23
23
|
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
24
24
|
};
|
|
25
|
-
export const translate = ({
|
|
26
|
-
x,
|
|
27
|
-
y,
|
|
28
|
-
}: Vector): [{ translateX: number }, { translateY: number }] => {
|
|
29
|
-
"worklet";
|
|
30
|
-
return [{ translateX: x }, { translateY: y }];
|
|
31
|
-
};
|
package/src/skia/types/Canvas.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { SkColor } from "./Color";
|
|
|
8
8
|
import type { SkRRect } from "./RRect";
|
|
9
9
|
import type { BlendMode } from "./Paint/BlendMode";
|
|
10
10
|
import type { SkPoint, PointMode } from "./Point";
|
|
11
|
-
import type {
|
|
11
|
+
import type { InputMatrix } from "./Matrix";
|
|
12
12
|
import type { SkImageFilter } from "./ImageFilter";
|
|
13
13
|
import type { SkVertices } from "./Vertices";
|
|
14
14
|
import type { SkTextBlob } from "./TextBlob";
|
|
@@ -485,7 +485,7 @@ export interface SkCanvas {
|
|
|
485
485
|
* Replaces current matrix with m premultiplied with the existing matrix.
|
|
486
486
|
* @param m
|
|
487
487
|
*/
|
|
488
|
-
concat(m:
|
|
488
|
+
concat(m: InputMatrix): void;
|
|
489
489
|
|
|
490
490
|
/**
|
|
491
491
|
* Draws the given picture using the current clip, current matrix, and the provided paint.
|
package/src/skia/types/Matrix.ts
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import type { SkJSIInstance } from "./JsiInstance";
|
|
2
2
|
import type { SkCanvas } from "./Canvas";
|
|
3
|
-
import type { Transforms3d } from "./Matrix4";
|
|
3
|
+
import type { Matrix3, Matrix4, Transforms3d } from "./Matrix4";
|
|
4
4
|
import { processTransform3d } from "./Matrix4";
|
|
5
|
-
export enum MatrixIndex {
|
|
6
|
-
ScaleX = 0,
|
|
7
|
-
SkewX = 1,
|
|
8
|
-
TransX = 2,
|
|
9
|
-
SkewY = 3,
|
|
10
|
-
ScaleY = 4,
|
|
11
|
-
TransY = 5,
|
|
12
|
-
Persp0 = 6,
|
|
13
|
-
Persp1 = 7,
|
|
14
|
-
Persp2 = 8,
|
|
15
|
-
}
|
|
16
5
|
|
|
17
6
|
export const isMatrix = (obj: unknown): obj is SkMatrix =>
|
|
18
7
|
obj !== null && (obj as SkJSIInstance<string>).__typename__ === "Matrix";
|
|
19
8
|
|
|
20
9
|
export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
|
21
|
-
concat: (matrix:
|
|
10
|
+
concat: (matrix: InputMatrix) => SkMatrix;
|
|
22
11
|
translate: (x: number, y: number) => SkMatrix;
|
|
23
12
|
scale: (x: number, y?: number) => SkMatrix;
|
|
24
13
|
skew: (x: number, y: number) => SkMatrix;
|
|
@@ -31,6 +20,8 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
|
|
31
20
|
get: () => number[];
|
|
32
21
|
}
|
|
33
22
|
|
|
23
|
+
export type InputMatrix = SkMatrix | Matrix3 | Matrix4 | number[];
|
|
24
|
+
|
|
34
25
|
export interface TransformProp {
|
|
35
26
|
transform?: Transforms3d;
|
|
36
27
|
}
|