@shopify/react-native-skia 0.1.163 → 0.1.164

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. package/cpp/api/JsiSkPaint.h +6 -0
  2. package/cpp/jsi/JsiHostObject.h +25 -25
  3. package/cpp/rnskia/dom/base/DrawingContext.cpp +24 -9
  4. package/cpp/rnskia/dom/base/DrawingContext.h +3 -2
  5. package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +12 -2
  6. package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +4 -4
  7. package/cpp/rnskia/dom/base/JsiDomNode.h +68 -10
  8. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +26 -61
  9. package/cpp/rnskia/dom/base/NodeProp.h +2 -1
  10. package/cpp/rnskia/dom/base/NodePropsContainer.h +10 -0
  11. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +1 -2
  12. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +3 -6
  13. package/cpp/rnskia/dom/nodes/JsiBoxNode.h +2 -4
  14. package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +1 -2
  15. package/cpp/rnskia/dom/nodes/JsiCircleNode.h +2 -3
  16. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +4 -8
  17. package/cpp/rnskia/dom/nodes/JsiCustomDrawingNode.h +1 -2
  18. package/cpp/rnskia/dom/nodes/JsiDiffRectNode.h +2 -7
  19. package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +4 -8
  20. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +19 -37
  21. package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -1
  22. package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +2 -4
  23. package/cpp/rnskia/dom/nodes/JsiLineNode.h +2 -7
  24. package/cpp/rnskia/dom/nodes/JsiOvalNode.h +1 -3
  25. package/cpp/rnskia/dom/nodes/JsiPaintNode.h +2 -3
  26. package/cpp/rnskia/dom/nodes/JsiPatchNode.h +4 -8
  27. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +14 -28
  28. package/cpp/rnskia/dom/nodes/JsiPathNode.h +6 -16
  29. package/cpp/rnskia/dom/nodes/JsiPictureNode.h +1 -2
  30. package/cpp/rnskia/dom/nodes/JsiPointsNode.h +2 -5
  31. package/cpp/rnskia/dom/nodes/JsiRRectNode.h +1 -2
  32. package/cpp/rnskia/dom/nodes/JsiRectNode.h +1 -2
  33. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +37 -69
  34. package/cpp/rnskia/dom/nodes/JsiTextBlobNode.h +3 -6
  35. package/cpp/rnskia/dom/nodes/JsiTextNode.h +4 -8
  36. package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +1 -2
  37. package/cpp/rnskia/dom/nodes/JsiVerticesNode.h +2 -4
  38. package/cpp/rnskia/dom/props/PaintProps.h +1 -2
  39. package/cpp/rnskia/dom/props/TransformProp.h +0 -2
  40. package/cpp/utils/RNSkLog.h +1 -1
  41. package/lib/commonjs/dom/nodes/RenderNode.js +12 -16
  42. package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
  43. package/lib/commonjs/dom/nodes/datatypes/index.js +0 -13
  44. package/lib/commonjs/dom/nodes/datatypes/index.js.map +1 -1
  45. package/lib/commonjs/dom/nodes/drawings/Box.js +6 -6
  46. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  47. package/lib/commonjs/dom/nodes/drawings/PatchNode.js +3 -7
  48. package/lib/commonjs/dom/nodes/drawings/PatchNode.js.map +1 -1
  49. package/lib/commonjs/dom/nodes/drawings/VerticesNode.js +1 -1
  50. package/lib/commonjs/dom/nodes/drawings/VerticesNode.js.map +1 -1
  51. package/lib/commonjs/dom/nodes/paint/ColorFilters.js +1 -3
  52. package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
  53. package/lib/commonjs/dom/nodes/paint/ImageFilters.js +1 -1
  54. package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
  55. package/lib/commonjs/dom/nodes/paint/Shaders.js +1 -3
  56. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  57. package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
  58. package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
  59. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  60. package/lib/commonjs/skia/web/JsiSkPaint.js +4 -0
  61. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  62. package/lib/commonjs/web/LoadSkiaWeb.js +1 -1
  63. package/lib/commonjs/web/LoadSkiaWeb.js.map +1 -1
  64. package/lib/module/dom/nodes/RenderNode.js +12 -16
  65. package/lib/module/dom/nodes/RenderNode.js.map +1 -1
  66. package/lib/module/dom/nodes/datatypes/index.js +0 -1
  67. package/lib/module/dom/nodes/datatypes/index.js.map +1 -1
  68. package/lib/module/dom/nodes/drawings/Box.js +6 -5
  69. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  70. package/lib/module/dom/nodes/drawings/PatchNode.js +4 -8
  71. package/lib/module/dom/nodes/drawings/PatchNode.js.map +1 -1
  72. package/lib/module/dom/nodes/drawings/VerticesNode.js +2 -2
  73. package/lib/module/dom/nodes/drawings/VerticesNode.js.map +1 -1
  74. package/lib/module/dom/nodes/paint/ColorFilters.js +1 -2
  75. package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
  76. package/lib/module/dom/nodes/paint/ImageFilters.js +2 -2
  77. package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
  78. package/lib/module/dom/nodes/paint/Shaders.js +1 -2
  79. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  80. package/lib/module/dom/types/DrawingContext.js.map +1 -1
  81. package/lib/module/renderer/DrawingContext.js.map +1 -1
  82. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  83. package/lib/module/skia/web/JsiSkPaint.js +4 -0
  84. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  85. package/lib/module/web/LoadSkiaWeb.js +1 -1
  86. package/lib/module/web/LoadSkiaWeb.js.map +1 -1
  87. package/lib/typescript/src/dom/nodes/datatypes/index.d.ts +0 -1
  88. package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +1 -1
  89. package/lib/typescript/src/dom/nodes/drawings/PatchNode.d.ts +1 -1
  90. package/lib/typescript/src/dom/types/DrawingContext.d.ts +0 -1
  91. package/lib/typescript/src/renderer/DrawingContext.d.ts +3 -5
  92. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +4 -0
  93. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -0
  94. package/package.json +1 -1
  95. package/src/dom/nodes/RenderNode.ts +11 -21
  96. package/src/dom/nodes/datatypes/index.ts +0 -1
  97. package/src/dom/nodes/drawings/Box.ts +7 -4
  98. package/src/dom/nodes/drawings/PatchNode.ts +4 -18
  99. package/src/dom/nodes/drawings/VerticesNode.ts +2 -2
  100. package/src/dom/nodes/paint/ColorFilters.ts +1 -2
  101. package/src/dom/nodes/paint/ImageFilters.ts +2 -2
  102. package/src/dom/nodes/paint/Shaders.ts +1 -2
  103. package/src/dom/types/DrawingContext.ts +0 -1
  104. package/src/renderer/DrawingContext.ts +5 -5
  105. package/src/skia/types/Paint/Paint.ts +5 -0
  106. package/src/skia/web/JsiSkPaint.ts +4 -0
  107. package/src/web/LoadSkiaWeb.tsx +1 -1
  108. package/lib/commonjs/dom/nodes/datatypes/Color.js +0 -27
  109. package/lib/commonjs/dom/nodes/datatypes/Color.js.map +0 -1
  110. package/lib/module/dom/nodes/datatypes/Color.js +0 -11
  111. package/lib/module/dom/nodes/datatypes/Color.js.map +0 -1
  112. package/lib/typescript/src/dom/nodes/datatypes/Color.d.ts +0 -7
  113. package/src/dom/nodes/datatypes/Color.ts +0 -15
@@ -15,7 +15,7 @@ import type {
15
15
  RuntimeShaderImageFilterProps,
16
16
  } from "../../types";
17
17
  import { DeclarationType, NodeType } from "../../types";
18
- import { processRadius, enumKey, processColor } from "../datatypes";
18
+ import { processRadius, enumKey } from "../datatypes";
19
19
  import type { NodeContext } from "../Node";
20
20
  import { JsiDeclarationNode } from "../Node";
21
21
 
@@ -145,7 +145,7 @@ export class DropShadowImageFilterNode extends ImageFilterDeclaration<DropShadow
145
145
 
146
146
  materialize() {
147
147
  const { dx, dy, blur, shadowOnly, color: cl, inner } = this.props;
148
- const color = processColor(this.Skia, cl, 1);
148
+ const color = this.Skia.Color(cl);
149
149
  const input = this.getOptionalChildInstance(0);
150
150
  let factory;
151
151
  if (inner) {
@@ -19,7 +19,6 @@ import type {
19
19
  TwoPointConicalGradientProps,
20
20
  } from "../../types";
21
21
  import { DeclarationType, NodeType } from "../../types";
22
- import { processColor } from "../datatypes/Color";
23
22
  import {
24
23
  enumKey,
25
24
  fitRects,
@@ -99,7 +98,7 @@ export class ColorNode extends ShaderDeclaration<ColorProps> {
99
98
 
100
99
  materialize() {
101
100
  const { color } = this.props;
102
- return this.Skia.Shader.MakeColor(processColor(this.Skia, color, 1));
101
+ return this.Skia.Shader.MakeColor(this.Skia.Color(color));
103
102
  }
104
103
  }
105
104
 
@@ -3,5 +3,4 @@ import type { SkCanvas, SkPaint } from "../../skia/types";
3
3
  export interface DrawingContext {
4
4
  canvas: SkCanvas;
5
5
  paint: SkPaint;
6
- opacity: number;
7
6
  }
@@ -1,12 +1,12 @@
1
1
  import type { RefObject } from "react";
2
2
 
3
3
  import type { DrawingInfo, SkiaView } from "../views";
4
- import type { SkCanvas, SkPaint, Skia, Vector } from "../skia/types";
4
+ import type { Skia, Vector } from "../skia/types";
5
+ import type { DrawingContext as DOMDrawingContext } from "../dom/types";
5
6
 
6
- export interface DrawingContext extends Omit<DrawingInfo, "touches"> {
7
- canvas: SkCanvas;
8
- paint: SkPaint;
9
- opacity: number;
7
+ export interface DrawingContext
8
+ extends Omit<DrawingInfo, "touches">,
9
+ DOMDrawingContext {
10
10
  center: Vector;
11
11
  ref: RefObject<SkiaView>;
12
12
  Skia: Skia;
@@ -29,6 +29,11 @@ export const isPaint = (obj: SkJSIInstance<string> | null): obj is SkPaint =>
29
29
  obj !== null && obj.__typename__ === "Paint";
30
30
 
31
31
  export interface SkPaint extends SkJSIInstance<"Paint"> {
32
+ /**
33
+ * Retrieves alpha from the color used when stroking and filling.
34
+ */
35
+ getAlphaf(): number;
36
+
32
37
  /**
33
38
  * Returns a copy of this paint.
34
39
  */
@@ -34,6 +34,10 @@ export class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
34
34
  this.ref = new this.CanvasKit.Paint();
35
35
  }
36
36
 
37
+ getAlphaf() {
38
+ return this.getColor()[3];
39
+ }
40
+
37
41
  getColor() {
38
42
  return this.ref.getColor();
39
43
  }
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-expect-error
2
+ // @ts-ignore
3
3
  import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
4
4
  import type {
5
5
  CanvasKit as CanvasKitType,
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.rgbaColor = exports.processColor = exports.RED = exports.GREEN = exports.BLUE = exports.ALPHA = void 0;
7
- const RED = 0;
8
- exports.RED = RED;
9
- const GREEN = 1;
10
- exports.GREEN = GREEN;
11
- const BLUE = 2;
12
- exports.BLUE = BLUE;
13
- const ALPHA = 3;
14
- exports.ALPHA = ALPHA;
15
-
16
- const rgbaColor = (r, g, b, a) => new Float32Array([r, g, b, a]);
17
-
18
- exports.rgbaColor = rgbaColor;
19
-
20
- const processColor = (Skia, cl, currentOpacity) => {
21
- const color = Skia.Color(cl);
22
- color[ALPHA] *= currentOpacity;
23
- return color;
24
- };
25
-
26
- exports.processColor = processColor;
27
- //# sourceMappingURL=Color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["RED","GREEN","BLUE","ALPHA","rgbaColor","r","g","b","a","Float32Array","processColor","Skia","cl","currentOpacity","color","Color"],"sources":["Color.ts"],"sourcesContent":["import type { Color, Skia } from \"../../../skia/types\";\n\nexport const RED = 0;\nexport const GREEN = 1;\nexport const BLUE = 2;\nexport const ALPHA = 3;\n\nexport const rgbaColor = (r: number, g: number, b: number, a: number) =>\n new Float32Array([r, g, b, a]);\n\nexport const processColor = (Skia: Skia, cl: Color, currentOpacity: number) => {\n const color = Skia.Color(cl);\n color[ALPHA] *= currentOpacity;\n return color;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,GAAG,GAAG,CAAZ;;AACA,MAAMC,KAAK,GAAG,CAAd;;AACA,MAAMC,IAAI,GAAG,CAAb;;AACA,MAAMC,KAAK,GAAG,CAAd;;;AAEA,MAAMC,SAAS,GAAG,CAACC,CAAD,EAAYC,CAAZ,EAAuBC,CAAvB,EAAkCC,CAAlC,KACvB,IAAIC,YAAJ,CAAiB,CAACJ,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CADK;;;;AAGA,MAAME,YAAY,GAAG,CAACC,IAAD,EAAaC,EAAb,EAAwBC,cAAxB,KAAmD;EAC7E,MAAMC,KAAK,GAAGH,IAAI,CAACI,KAAL,CAAWH,EAAX,CAAd;EACAE,KAAK,CAACX,KAAD,CAAL,IAAgBU,cAAhB;EACA,OAAOC,KAAP;AACD,CAJM"}
@@ -1,11 +0,0 @@
1
- export const RED = 0;
2
- export const GREEN = 1;
3
- export const BLUE = 2;
4
- export const ALPHA = 3;
5
- export const rgbaColor = (r, g, b, a) => new Float32Array([r, g, b, a]);
6
- export const processColor = (Skia, cl, currentOpacity) => {
7
- const color = Skia.Color(cl);
8
- color[ALPHA] *= currentOpacity;
9
- return color;
10
- };
11
- //# sourceMappingURL=Color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["RED","GREEN","BLUE","ALPHA","rgbaColor","r","g","b","a","Float32Array","processColor","Skia","cl","currentOpacity","color","Color"],"sources":["Color.ts"],"sourcesContent":["import type { Color, Skia } from \"../../../skia/types\";\n\nexport const RED = 0;\nexport const GREEN = 1;\nexport const BLUE = 2;\nexport const ALPHA = 3;\n\nexport const rgbaColor = (r: number, g: number, b: number, a: number) =>\n new Float32Array([r, g, b, a]);\n\nexport const processColor = (Skia: Skia, cl: Color, currentOpacity: number) => {\n const color = Skia.Color(cl);\n color[ALPHA] *= currentOpacity;\n return color;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,GAAG,GAAG,CAAZ;AACP,OAAO,MAAMC,KAAK,GAAG,CAAd;AACP,OAAO,MAAMC,IAAI,GAAG,CAAb;AACP,OAAO,MAAMC,KAAK,GAAG,CAAd;AAEP,OAAO,MAAMC,SAAS,GAAG,CAACC,CAAD,EAAYC,CAAZ,EAAuBC,CAAvB,EAAkCC,CAAlC,KACvB,IAAIC,YAAJ,CAAiB,CAACJ,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CADK;AAGP,OAAO,MAAME,YAAY,GAAG,CAACC,IAAD,EAAaC,EAAb,EAAwBC,cAAxB,KAAmD;EAC7E,MAAMC,KAAK,GAAGH,IAAI,CAACI,KAAL,CAAWH,EAAX,CAAd;EACAE,KAAK,CAACX,KAAD,CAAL,IAAgBU,cAAhB;EACA,OAAOC,KAAP;AACD,CAJM"}
@@ -1,7 +0,0 @@
1
- import type { Color, Skia } from "../../../skia/types";
2
- export declare const RED = 0;
3
- export declare const GREEN = 1;
4
- export declare const BLUE = 2;
5
- export declare const ALPHA = 3;
6
- export declare const rgbaColor: (r: number, g: number, b: number, a: number) => Float32Array;
7
- export declare const processColor: (Skia: Skia, cl: Color, currentOpacity: number) => Float32Array;
@@ -1,15 +0,0 @@
1
- import type { Color, Skia } from "../../../skia/types";
2
-
3
- export const RED = 0;
4
- export const GREEN = 1;
5
- export const BLUE = 2;
6
- export const ALPHA = 3;
7
-
8
- export const rgbaColor = (r: number, g: number, b: number, a: number) =>
9
- new Float32Array([r, g, b, a]);
10
-
11
- export const processColor = (Skia: Skia, cl: Color, currentOpacity: number) => {
12
- const color = Skia.Color(cl);
13
- color[ALPHA] *= currentOpacity;
14
- return color;
15
- };