@shopify/react-native-skia 0.1.187 → 0.1.189
Sign up to get free protection for your applications and to get access to all the features.
- package/android/build.gradle +15 -2
- package/cpp/api/JsiSkMatrix.h +6 -6
- package/cpp/rnskia/dom/base/JsiDependencyManager.h +47 -47
- package/cpp/rnskia/dom/base/JsiDomNode.h +6 -7
- package/cpp/rnskia/dom/base/NodePropsContainer.h +27 -3
- package/cpp/rnskia/dom/props/ColorProp.h +7 -0
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +10 -9
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +7 -3
- package/ios/RNSkia-iOS/SkiaManager.mm +3 -27
- package/ios/RNSkia-iOS/ViewScreenshotService.mm +13 -1
- package/lib/commonjs/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/commonjs/animation/functions/interpolateColors.js +3 -2
- package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
- package/lib/commonjs/skia/types/Color.d.ts +1 -1
- package/lib/commonjs/skia/types/Color.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix.d.ts +6 -6
- package/lib/commonjs/skia/types/Matrix.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColor.js +2 -0
- package/lib/commonjs/skia/web/JsiSkColor.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +6 -6
- package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -0
- package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/module/animation/functions/interpolateColors.js +3 -2
- package/lib/module/animation/functions/interpolateColors.js.map +1 -1
- package/lib/module/skia/types/Color.d.ts +1 -1
- package/lib/module/skia/types/Color.js.map +1 -1
- package/lib/module/skia/types/Matrix.d.ts +6 -6
- package/lib/module/skia/types/Matrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkColor.js +2 -0
- package/lib/module/skia/web/JsiSkColor.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.d.ts +6 -6
- package/lib/module/skia/web/JsiSkMatrix.js +6 -0
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/typescript/src/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/typescript/src/skia/types/Color.d.ts +1 -1
- package/lib/typescript/src/skia/types/Matrix.d.ts +6 -6
- package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +6 -6
- package/package.json +1 -1
- package/src/animation/functions/interpolateColors.ts +2 -1
- package/src/skia/types/Color.ts +1 -1
- package/src/skia/types/Matrix.ts +6 -6
- package/src/skia/web/JsiSkColor.ts +2 -0
- package/src/skia/web/JsiSkMatrix.ts +6 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["HostObject","JsiSkMatrix","constructor","CanvasKit","ref","concat","matrix","set","Matrix","multiply","fromValue","translate","x","y","Float32Array","of","translated","scale","scaled","skew","skewed","rotate","value","rotated","identity","get","Array","from"],"sources":["JsiSkMatrix.ts"],"sourcesContent":["import type { CanvasKit, Matrix3x3 } from \"canvaskit-wasm\";\n\nimport type { SkMatrix } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\nexport class JsiSkMatrix\n extends HostObject<Matrix3x3, \"Matrix\">\n implements SkMatrix\n{\n constructor(CanvasKit: CanvasKit, ref: Matrix3x3) {\n super(CanvasKit, ref, \"Matrix\");\n }\n\n concat(matrix: SkMatrix) {\n this.ref.set(\n this.CanvasKit.Matrix.multiply(this.ref, JsiSkMatrix.fromValue(matrix))\n );\n }\n\n translate(x: number, y: number) {\n this.concat(\n new JsiSkMatrix(\n this.CanvasKit,\n Float32Array.of(...this.CanvasKit.Matrix.translated(x, y))\n )\n );\n }\n\n scale(x: number, y?: number) {\n this.concat(\n new JsiSkMatrix(\n this.CanvasKit,\n Float32Array.of(...this.CanvasKit.Matrix.scaled(x, y ?? x))\n )\n );\n }\n\n skew(x: number, y: number) {\n this.concat(\n new JsiSkMatrix(\n this.CanvasKit,\n Float32Array.of(...this.CanvasKit.Matrix.skewed(x, y))\n )\n );\n }\n\n rotate(value: number) {\n this.concat(\n new JsiSkMatrix(\n this.CanvasKit,\n Float32Array.of(...this.CanvasKit.Matrix.rotated(value))\n )\n );\n }\n\n identity() {\n this.ref.set(this.CanvasKit.Matrix.identity());\n }\n\n get() {\n return Array.from(this.ref);\n }\n}\n"],"mappings":"AAIA,SAASA,UAAT,QAA2B,QAA3B;AAEA,OAAO,MAAMC,WAAN,SACGD,UADH,CAGP;EACEE,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAuC;IAChD,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,QAAtB;EACD;;EAEDC,MAAM,CAACC,MAAD,EAAmB;IACvB,KAAKF,GAAL,CAASG,GAAT,CACE,KAAKJ,SAAL,CAAeK,MAAf,CAAsBC,QAAtB,CAA+B,KAAKL,GAApC,EAAyCH,WAAW,CAACS,SAAZ,CAAsBJ,MAAtB,CAAzC,CADF;
|
1
|
+
{"version":3,"names":["HostObject","JsiSkMatrix","constructor","CanvasKit","ref","concat","matrix","set","Matrix","multiply","fromValue","translate","x","y","Float32Array","of","translated","scale","scaled","skew","skewed","rotate","value","rotated","identity","get","Array","from"],"sources":["JsiSkMatrix.ts"],"sourcesContent":["import type { CanvasKit, Matrix3x3 } from \"canvaskit-wasm\";\n\nimport type { SkMatrix } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\nexport class JsiSkMatrix\n extends HostObject<Matrix3x3, \"Matrix\">\n implements SkMatrix\n{\n constructor(CanvasKit: CanvasKit, ref: Matrix3x3) {\n super(CanvasKit, ref, \"Matrix\");\n }\n\n concat(matrix: SkMatrix) {\n this.ref.set(\n this.CanvasKit.Matrix.multiply(this.ref, JsiSkMatrix.fromValue(matrix))\n );\n return this;\n }\n\n translate(x: number, y: number) {\n this.concat(\n new JsiSkMatrix(\n this.CanvasKit,\n Float32Array.of(...this.CanvasKit.Matrix.translated(x, y))\n )\n );\n return this;\n }\n\n scale(x: number, y?: number) {\n this.concat(\n new JsiSkMatrix(\n this.CanvasKit,\n Float32Array.of(...this.CanvasKit.Matrix.scaled(x, y ?? x))\n )\n );\n return this;\n }\n\n skew(x: number, y: number) {\n this.concat(\n new JsiSkMatrix(\n this.CanvasKit,\n Float32Array.of(...this.CanvasKit.Matrix.skewed(x, y))\n )\n );\n return this;\n }\n\n rotate(value: number) {\n this.concat(\n new JsiSkMatrix(\n this.CanvasKit,\n Float32Array.of(...this.CanvasKit.Matrix.rotated(value))\n )\n );\n return this;\n }\n\n identity() {\n this.ref.set(this.CanvasKit.Matrix.identity());\n return this;\n }\n\n get() {\n return Array.from(this.ref);\n }\n}\n"],"mappings":"AAIA,SAASA,UAAT,QAA2B,QAA3B;AAEA,OAAO,MAAMC,WAAN,SACGD,UADH,CAGP;EACEE,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAuC;IAChD,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,QAAtB;EACD;;EAEDC,MAAM,CAACC,MAAD,EAAmB;IACvB,KAAKF,GAAL,CAASG,GAAT,CACE,KAAKJ,SAAL,CAAeK,MAAf,CAAsBC,QAAtB,CAA+B,KAAKL,GAApC,EAAyCH,WAAW,CAACS,SAAZ,CAAsBJ,MAAtB,CAAzC,CADF;IAGA,OAAO,IAAP;EACD;;EAEDK,SAAS,CAACC,CAAD,EAAYC,CAAZ,EAAuB;IAC9B,KAAKR,MAAL,CACE,IAAIJ,WAAJ,CACE,KAAKE,SADP,EAEEW,YAAY,CAACC,EAAb,CAAgB,GAAG,KAAKZ,SAAL,CAAeK,MAAf,CAAsBQ,UAAtB,CAAiCJ,CAAjC,EAAoCC,CAApC,CAAnB,CAFF,CADF;IAMA,OAAO,IAAP;EACD;;EAEDI,KAAK,CAACL,CAAD,EAAYC,CAAZ,EAAwB;IAC3B,KAAKR,MAAL,CACE,IAAIJ,WAAJ,CACE,KAAKE,SADP,EAEEW,YAAY,CAACC,EAAb,CAAgB,GAAG,KAAKZ,SAAL,CAAeK,MAAf,CAAsBU,MAAtB,CAA6BN,CAA7B,EAAgCC,CAAhC,aAAgCA,CAAhC,cAAgCA,CAAhC,GAAqCD,CAArC,CAAnB,CAFF,CADF;IAMA,OAAO,IAAP;EACD;;EAEDO,IAAI,CAACP,CAAD,EAAYC,CAAZ,EAAuB;IACzB,KAAKR,MAAL,CACE,IAAIJ,WAAJ,CACE,KAAKE,SADP,EAEEW,YAAY,CAACC,EAAb,CAAgB,GAAG,KAAKZ,SAAL,CAAeK,MAAf,CAAsBY,MAAtB,CAA6BR,CAA7B,EAAgCC,CAAhC,CAAnB,CAFF,CADF;IAMA,OAAO,IAAP;EACD;;EAEDQ,MAAM,CAACC,KAAD,EAAgB;IACpB,KAAKjB,MAAL,CACE,IAAIJ,WAAJ,CACE,KAAKE,SADP,EAEEW,YAAY,CAACC,EAAb,CAAgB,GAAG,KAAKZ,SAAL,CAAeK,MAAf,CAAsBe,OAAtB,CAA8BD,KAA9B,CAAnB,CAFF,CADF;IAMA,OAAO,IAAP;EACD;;EAEDE,QAAQ,GAAG;IACT,KAAKpB,GAAL,CAASG,GAAT,CAAa,KAAKJ,SAAL,CAAeK,MAAf,CAAsBgB,QAAtB,EAAb;IACA,OAAO,IAAP;EACD;;EAEDC,GAAG,GAAG;IACJ,OAAOC,KAAK,CAACC,IAAN,CAAW,KAAKvB,GAAhB,CAAP;EACD;;AA3DH"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import type { Color } from "../../skia";
|
2
|
-
export declare const interpolateColors: (value: number, inputRange: number[], _outputRange: Color[]) =>
|
2
|
+
export declare const interpolateColors: (value: number, inputRange: number[], _outputRange: Color[]) => number[];
|
3
3
|
export declare const mixColors: (value: number, x: Color, y: Color) => Float32Array;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export declare type SkColor = Float32Array;
|
2
|
-
export declare type Color = string | Float32Array | number;
|
2
|
+
export declare type Color = string | Float32Array | number | number[];
|
@@ -13,12 +13,12 @@ export declare enum MatrixIndex {
|
|
13
13
|
}
|
14
14
|
export declare const isMatrix: (obj: unknown) => obj is SkMatrix;
|
15
15
|
export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
16
|
-
concat: (matrix: SkMatrix) =>
|
17
|
-
translate: (x: number, y: number) =>
|
18
|
-
scale: (x: number, y?: number) =>
|
19
|
-
skew: (x: number, y: number) =>
|
20
|
-
rotate: (theta: number) =>
|
21
|
-
identity: () =>
|
16
|
+
concat: (matrix: SkMatrix) => SkMatrix;
|
17
|
+
translate: (x: number, y: number) => SkMatrix;
|
18
|
+
scale: (x: number, y?: number) => SkMatrix;
|
19
|
+
skew: (x: number, y: number) => SkMatrix;
|
20
|
+
rotate: (theta: number) => SkMatrix;
|
21
|
+
identity: () => SkMatrix;
|
22
22
|
get: () => number[];
|
23
23
|
}
|
24
24
|
declare type Transform2dName = "translateX" | "translateY" | "scale" | "skewX" | "skewY" | "scaleX" | "scaleY" | "rotateZ" | "rotate";
|
@@ -3,11 +3,11 @@ import type { SkMatrix } 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
|
-
concat(matrix: SkMatrix):
|
7
|
-
translate(x: number, y: number):
|
8
|
-
scale(x: number, y?: number):
|
9
|
-
skew(x: number, y: number):
|
10
|
-
rotate(value: number):
|
11
|
-
identity():
|
6
|
+
concat(matrix: SkMatrix): this;
|
7
|
+
translate(x: number, y: number): this;
|
8
|
+
scale(x: number, y?: number): this;
|
9
|
+
skew(x: number, y: number): this;
|
10
|
+
rotate(value: number): this;
|
11
|
+
identity(): this;
|
12
12
|
get(): number[];
|
13
13
|
}
|
package/package.json
CHANGED
@@ -34,7 +34,8 @@ const interpolateColorsRGB = (
|
|
34
34
|
outputRange.map((c) => c[3]),
|
35
35
|
"clamp"
|
36
36
|
);
|
37
|
-
|
37
|
+
// TODO: once Float32Array are supported in the reanimated integration we can switch there
|
38
|
+
return [r, g, b, a];
|
38
39
|
};
|
39
40
|
|
40
41
|
export const interpolateColors = (
|
package/src/skia/types/Color.ts
CHANGED
package/src/skia/types/Matrix.ts
CHANGED
@@ -16,12 +16,12 @@ export const isMatrix = (obj: unknown): obj is SkMatrix =>
|
|
16
16
|
obj !== null && (obj as SkJSIInstance<string>).__typename__ === "Matrix";
|
17
17
|
|
18
18
|
export interface SkMatrix extends SkJSIInstance<"Matrix"> {
|
19
|
-
concat: (matrix: SkMatrix) =>
|
20
|
-
translate: (x: number, y: number) =>
|
21
|
-
scale: (x: number, y?: number) =>
|
22
|
-
skew: (x: number, y: number) =>
|
23
|
-
rotate: (theta: number) =>
|
24
|
-
identity: () =>
|
19
|
+
concat: (matrix: SkMatrix) => SkMatrix;
|
20
|
+
translate: (x: number, y: number) => SkMatrix;
|
21
|
+
scale: (x: number, y?: number) => SkMatrix;
|
22
|
+
skew: (x: number, y: number) => SkMatrix;
|
23
|
+
rotate: (theta: number) => SkMatrix;
|
24
|
+
identity: () => SkMatrix;
|
25
25
|
get: () => number[];
|
26
26
|
}
|
27
27
|
|
@@ -318,6 +318,8 @@ const parseCSSColor = (cssStr: string) => {
|
|
318
318
|
export const Color = (color: InputColor): SkColor => {
|
319
319
|
if (color instanceof Float32Array) {
|
320
320
|
return color;
|
321
|
+
} else if (Array.isArray(color)) {
|
322
|
+
return new Float32Array(color);
|
321
323
|
} else if (typeof color === "string") {
|
322
324
|
const r = parseCSSColor(color);
|
323
325
|
const rgba = r === null ? CSSColorTable.black : r;
|
@@ -16,6 +16,7 @@ export class JsiSkMatrix
|
|
16
16
|
this.ref.set(
|
17
17
|
this.CanvasKit.Matrix.multiply(this.ref, JsiSkMatrix.fromValue(matrix))
|
18
18
|
);
|
19
|
+
return this;
|
19
20
|
}
|
20
21
|
|
21
22
|
translate(x: number, y: number) {
|
@@ -25,6 +26,7 @@ export class JsiSkMatrix
|
|
25
26
|
Float32Array.of(...this.CanvasKit.Matrix.translated(x, y))
|
26
27
|
)
|
27
28
|
);
|
29
|
+
return this;
|
28
30
|
}
|
29
31
|
|
30
32
|
scale(x: number, y?: number) {
|
@@ -34,6 +36,7 @@ export class JsiSkMatrix
|
|
34
36
|
Float32Array.of(...this.CanvasKit.Matrix.scaled(x, y ?? x))
|
35
37
|
)
|
36
38
|
);
|
39
|
+
return this;
|
37
40
|
}
|
38
41
|
|
39
42
|
skew(x: number, y: number) {
|
@@ -43,6 +46,7 @@ export class JsiSkMatrix
|
|
43
46
|
Float32Array.of(...this.CanvasKit.Matrix.skewed(x, y))
|
44
47
|
)
|
45
48
|
);
|
49
|
+
return this;
|
46
50
|
}
|
47
51
|
|
48
52
|
rotate(value: number) {
|
@@ -52,10 +56,12 @@ export class JsiSkMatrix
|
|
52
56
|
Float32Array.of(...this.CanvasKit.Matrix.rotated(value))
|
53
57
|
)
|
54
58
|
);
|
59
|
+
return this;
|
55
60
|
}
|
56
61
|
|
57
62
|
identity() {
|
58
63
|
this.ref.set(this.CanvasKit.Matrix.identity());
|
64
|
+
return this;
|
59
65
|
}
|
60
66
|
|
61
67
|
get() {
|