@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.
Files changed (44) hide show
  1. package/android/build.gradle +15 -2
  2. package/cpp/api/JsiSkMatrix.h +6 -6
  3. package/cpp/rnskia/dom/base/JsiDependencyManager.h +47 -47
  4. package/cpp/rnskia/dom/base/JsiDomNode.h +6 -7
  5. package/cpp/rnskia/dom/base/NodePropsContainer.h +27 -3
  6. package/cpp/rnskia/dom/props/ColorProp.h +7 -0
  7. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +10 -9
  8. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +7 -3
  9. package/ios/RNSkia-iOS/SkiaManager.mm +3 -27
  10. package/ios/RNSkia-iOS/ViewScreenshotService.mm +13 -1
  11. package/lib/commonjs/animation/functions/interpolateColors.d.ts +1 -1
  12. package/lib/commonjs/animation/functions/interpolateColors.js +3 -2
  13. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
  14. package/lib/commonjs/skia/types/Color.d.ts +1 -1
  15. package/lib/commonjs/skia/types/Color.js.map +1 -1
  16. package/lib/commonjs/skia/types/Matrix.d.ts +6 -6
  17. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  18. package/lib/commonjs/skia/web/JsiSkColor.js +2 -0
  19. package/lib/commonjs/skia/web/JsiSkColor.js.map +1 -1
  20. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +6 -6
  21. package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -0
  22. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  23. package/lib/module/animation/functions/interpolateColors.d.ts +1 -1
  24. package/lib/module/animation/functions/interpolateColors.js +3 -2
  25. package/lib/module/animation/functions/interpolateColors.js.map +1 -1
  26. package/lib/module/skia/types/Color.d.ts +1 -1
  27. package/lib/module/skia/types/Color.js.map +1 -1
  28. package/lib/module/skia/types/Matrix.d.ts +6 -6
  29. package/lib/module/skia/types/Matrix.js.map +1 -1
  30. package/lib/module/skia/web/JsiSkColor.js +2 -0
  31. package/lib/module/skia/web/JsiSkColor.js.map +1 -1
  32. package/lib/module/skia/web/JsiSkMatrix.d.ts +6 -6
  33. package/lib/module/skia/web/JsiSkMatrix.js +6 -0
  34. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  35. package/lib/typescript/src/animation/functions/interpolateColors.d.ts +1 -1
  36. package/lib/typescript/src/skia/types/Color.d.ts +1 -1
  37. package/lib/typescript/src/skia/types/Matrix.d.ts +6 -6
  38. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +6 -6
  39. package/package.json +1 -1
  40. package/src/animation/functions/interpolateColors.ts +2 -1
  41. package/src/skia/types/Color.ts +1 -1
  42. package/src/skia/types/Matrix.ts +6 -6
  43. package/src/skia/web/JsiSkColor.ts +2 -0
  44. 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;EAGD;;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;EAMD;;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;EAMD;;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;EAMD;;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;EAMD;;EAEDE,QAAQ,GAAG;IACT,KAAKpB,GAAL,CAASG,GAAT,CAAa,KAAKJ,SAAL,CAAeK,MAAf,CAAsBgB,QAAtB,EAAb;EACD;;EAEDC,GAAG,GAAG;IACJ,OAAOC,KAAK,CAACC,IAAN,CAAW,KAAKvB,GAAhB,CAAP;EACD;;AArDH"}
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[]) => Float32Array;
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) => void;
17
- translate: (x: number, y: number) => void;
18
- scale: (x: number, y?: number) => void;
19
- skew: (x: number, y: number) => void;
20
- rotate: (theta: number) => void;
21
- identity: () => void;
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): void;
7
- translate(x: number, y: number): void;
8
- scale(x: number, y?: number): void;
9
- skew(x: number, y: number): void;
10
- rotate(value: number): void;
11
- identity(): void;
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
@@ -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.187",
10
+ "version": "0.1.189",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -34,7 +34,8 @@ const interpolateColorsRGB = (
34
34
  outputRange.map((c) => c[3]),
35
35
  "clamp"
36
36
  );
37
- return new Float32Array([r, g, b, a]);
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 = (
@@ -1,4 +1,4 @@
1
1
  // This is the JSI color
2
2
  export type SkColor = Float32Array;
3
3
  // Input colors can be string, number or Float32Array
4
- export type Color = string | Float32Array | number;
4
+ export type Color = string | Float32Array | number | number[];
@@ -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) => void;
20
- translate: (x: number, y: number) => void;
21
- scale: (x: number, y?: number) => void;
22
- skew: (x: number, y: number) => void;
23
- rotate: (theta: number) => void;
24
- identity: () => void;
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() {