@shopify/react-native-skia 0.1.162 → 0.1.163

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +2 -0
  2. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +2 -2
  3. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
  4. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +5 -5
  5. package/cpp/api/JsiSkCanvas.h +8 -8
  6. package/cpp/api/JsiSkColor.h +1 -1
  7. package/cpp/api/JsiSkColorFilter.h +1 -1
  8. package/cpp/api/JsiSkColorFilterFactory.h +2 -2
  9. package/cpp/api/JsiSkContourMeasure.h +1 -1
  10. package/cpp/api/JsiSkContourMeasureIter.h +2 -2
  11. package/cpp/api/JsiSkData.h +2 -2
  12. package/cpp/api/JsiSkDataFactory.h +1 -1
  13. package/cpp/api/JsiSkFont.h +2 -2
  14. package/cpp/api/JsiSkImage.h +3 -3
  15. package/cpp/api/JsiSkImageFilter.h +1 -1
  16. package/cpp/api/JsiSkImageFilterFactory.h +1 -1
  17. package/cpp/api/JsiSkImageInfo.h +1 -1
  18. package/cpp/api/JsiSkMaskFilter.h +1 -1
  19. package/cpp/api/JsiSkMaskFilterFactory.h +1 -1
  20. package/cpp/api/JsiSkMatrix.h +1 -1
  21. package/cpp/api/JsiSkPaint.h +1 -1
  22. package/cpp/api/JsiSkPath.h +15 -15
  23. package/cpp/api/JsiSkPathEffect.h +1 -1
  24. package/cpp/api/JsiSkPathEffectFactory.h +4 -4
  25. package/cpp/api/JsiSkPathFactory.h +2 -2
  26. package/cpp/api/JsiSkPicture.h +1 -1
  27. package/cpp/api/JsiSkPictureFactory.h +2 -2
  28. package/cpp/api/JsiSkPictureRecorder.h +2 -2
  29. package/cpp/api/JsiSkPoint.h +1 -1
  30. package/cpp/api/JsiSkRRect.h +1 -1
  31. package/cpp/api/JsiSkRSXform.h +1 -1
  32. package/cpp/api/JsiSkRect.h +1 -1
  33. package/cpp/api/JsiSkRuntimeEffect.h +1 -1
  34. package/cpp/api/JsiSkRuntimeShaderBuilder.h +1 -1
  35. package/cpp/api/JsiSkSVGFactory.h +1 -1
  36. package/cpp/api/JsiSkShader.h +2 -2
  37. package/cpp/api/JsiSkShaderFactory.h +3 -3
  38. package/cpp/api/JsiSkSurface.h +1 -1
  39. package/cpp/api/JsiSkSurfaceFactory.h +2 -2
  40. package/cpp/api/JsiSkTextBlob.h +1 -1
  41. package/cpp/api/JsiSkTextBlobFactory.h +1 -1
  42. package/cpp/api/JsiSkTypeface.h +2 -2
  43. package/cpp/api/JsiSkVertices.h +1 -1
  44. package/cpp/rnskia/RNSkJsView.h +3 -3
  45. package/cpp/rnskia/RNSkPictureView.h +3 -3
  46. package/cpp/rnskia/RNSkPlatformContext.h +5 -3
  47. package/cpp/rnskia/RNSkView.h +2 -2
  48. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +6 -7
  49. package/cpp/rnskia/dom/nodes/JsiPathNode.h +10 -8
  50. package/cpp/rnskia/dom/props/BlendModeProp.h +2 -2
  51. package/cpp/rnskia/dom/props/PaintProps.h +5 -1
  52. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +8 -7
  53. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -1
  54. package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +4 -4
  55. package/ios/RNSkia-iOS/SkiaManager.mm +5 -5
  56. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +3 -3
  57. package/ios/RNSkia-iOS/SkiaUIView.mm +10 -10
  58. package/lib/commonjs/renderer/Canvas.js +2 -11
  59. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  60. package/lib/commonjs/renderer/Container.js +2 -1
  61. package/lib/commonjs/renderer/Container.js.map +1 -1
  62. package/lib/commonjs/renderer/components/Mask.js +11 -25
  63. package/lib/commonjs/renderer/components/Mask.js.map +1 -1
  64. package/lib/commonjs/renderer/index.js +0 -13
  65. package/lib/commonjs/renderer/index.js.map +1 -1
  66. package/lib/module/renderer/Canvas.js +3 -10
  67. package/lib/module/renderer/Canvas.js.map +1 -1
  68. package/lib/module/renderer/Container.js +2 -1
  69. package/lib/module/renderer/Container.js.map +1 -1
  70. package/lib/module/renderer/components/Mask.js +9 -21
  71. package/lib/module/renderer/components/Mask.js.map +1 -1
  72. package/lib/module/renderer/index.js +0 -1
  73. package/lib/module/renderer/index.js.map +1 -1
  74. package/lib/typescript/src/renderer/Container.d.ts +1 -1
  75. package/lib/typescript/src/renderer/index.d.ts +0 -1
  76. package/package.json +1 -1
  77. package/src/renderer/Canvas.tsx +2 -12
  78. package/src/renderer/Container.tsx +1 -1
  79. package/src/renderer/components/Mask.tsx +11 -20
  80. package/src/renderer/index.ts +0 -1
  81. package/lib/commonjs/renderer/useCanvas.js +0 -32
  82. package/lib/commonjs/renderer/useCanvas.js.map +0 -1
  83. package/lib/module/renderer/useCanvas.js +0 -15
  84. package/lib/module/renderer/useCanvas.js.map +0 -1
  85. package/lib/typescript/src/renderer/useCanvas.d.ts +0 -9
  86. package/src/renderer/useCanvas.ts +0 -21
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkDOM","Container","constructor","Skia","depMgr","redraw","Sk","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AAWA,OAAO,MAAMC,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAGFC,MAHE,EAIT;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIN,QAAJ,CAAa;MAAEG,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKG,KAAL,GAAa,KAAKD,EAAL,CAAQE,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
1
+ {"version":3,"names":["JsiSkDOM","Container","constructor","Skia","depMgr","redraw","Sk","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void = () => {}\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AAWA,OAAO,MAAMC,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAIT;IAAA,IADOC,MACP,uEAD4B,MAAM,CAAE,CACpC;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIN,QAAJ,CAAa;MAAEG,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKG,KAAL,GAAa,KAAKD,EAAL,CAAQE,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
@@ -1,7 +1,7 @@
1
- import React, { useMemo } from "react";
2
- import { BlendMode } from "../../skia/types";
3
- import { useSkiaPrivate } from "../useCanvas";
1
+ import React from "react";
4
2
  import { Group } from "./Group";
3
+ import { LumaColorFilter } from "./colorFilters/LumaColorFilter";
4
+ import { Paint } from "./Paint";
5
5
  export const Mask = _ref => {
6
6
  let {
7
7
  children,
@@ -9,28 +9,16 @@ export const Mask = _ref => {
9
9
  mode,
10
10
  clip
11
11
  } = _ref;
12
- const Skia = useSkiaPrivate();
13
- const maskPaint = useMemo(() => {
14
- const paint = Skia.Paint();
15
- paint.setBlendMode(BlendMode.Src);
16
-
17
- if (mode === "luminance") {
18
- paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());
19
- }
20
-
21
- return paint;
22
- }, [Skia, mode]);
23
- const clippingPaint = useMemo(() => {
24
- const paint = Skia.Paint();
25
- paint.setBlendMode(BlendMode.DstIn);
26
- return paint;
27
- }, [Skia]);
28
12
  return /*#__PURE__*/React.createElement(Group, {
29
13
  layer: true
30
14
  }, /*#__PURE__*/React.createElement(Group, {
31
- layer: maskPaint
15
+ layer: /*#__PURE__*/React.createElement(Paint, {
16
+ blendMode: "src"
17
+ }, mode === "luminance" && /*#__PURE__*/React.createElement(LumaColorFilter, null))
32
18
  }, mask, clip && /*#__PURE__*/React.createElement(Group, {
33
- layer: clippingPaint
19
+ layer: /*#__PURE__*/React.createElement(Paint, {
20
+ blendMode: "dstIn"
21
+ })
34
22
  }, children)), /*#__PURE__*/React.createElement(Group, {
35
23
  blendMode: "srcIn"
36
24
  }, children));
@@ -1 +1 @@
1
- {"version":3,"names":["React","useMemo","BlendMode","useSkiaPrivate","Group","Mask","children","mask","mode","clip","Skia","maskPaint","paint","Paint","setBlendMode","Src","setColorFilter","ColorFilter","MakeLumaColorFilter","clippingPaint","DstIn","defaultProps"],"sources":["Mask.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useMemo } from \"react\";\n\nimport { BlendMode } from \"../../skia/types\";\nimport { useSkiaPrivate } from \"../useCanvas\";\n\nimport { Group } from \"./Group\";\n\ninterface MaskProps {\n mode: \"luminance\" | \"alpha\";\n clip: boolean;\n mask: ReactNode | ReactNode[];\n children: ReactNode | ReactNode[];\n}\n\nexport const Mask = ({ children, mask, mode, clip }: MaskProps) => {\n const Skia = useSkiaPrivate();\n const maskPaint = useMemo(() => {\n const paint = Skia.Paint();\n paint.setBlendMode(BlendMode.Src);\n if (mode === \"luminance\") {\n paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());\n }\n return paint;\n }, [Skia, mode]);\n const clippingPaint = useMemo(() => {\n const paint = Skia.Paint();\n paint.setBlendMode(BlendMode.DstIn);\n return paint;\n }, [Skia]);\n return (\n <Group layer>\n <Group layer={maskPaint}>\n {mask}\n {clip && <Group layer={clippingPaint}>{children}</Group>}\n </Group>\n <Group blendMode=\"srcIn\">{children}</Group>\n </Group>\n );\n};\n\nMask.defaultProps = {\n mode: \"alpha\",\n clip: true,\n};\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,OAAhB,QAA+B,OAA/B;AAEA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,cAAT,QAA+B,cAA/B;AAEA,SAASC,KAAT,QAAsB,SAAtB;AASA,OAAO,MAAMC,IAAI,GAAG,QAA+C;EAAA,IAA9C;IAAEC,QAAF;IAAYC,IAAZ;IAAkBC,IAAlB;IAAwBC;EAAxB,CAA8C;EACjE,MAAMC,IAAI,GAAGP,cAAc,EAA3B;EACA,MAAMQ,SAAS,GAAGV,OAAO,CAAC,MAAM;IAC9B,MAAMW,KAAK,GAAGF,IAAI,CAACG,KAAL,EAAd;IACAD,KAAK,CAACE,YAAN,CAAmBZ,SAAS,CAACa,GAA7B;;IACA,IAAIP,IAAI,KAAK,WAAb,EAA0B;MACxBI,KAAK,CAACI,cAAN,CAAqBN,IAAI,CAACO,WAAL,CAAiBC,mBAAjB,EAArB;IACD;;IACD,OAAON,KAAP;EACD,CAPwB,EAOtB,CAACF,IAAD,EAAOF,IAAP,CAPsB,CAAzB;EAQA,MAAMW,aAAa,GAAGlB,OAAO,CAAC,MAAM;IAClC,MAAMW,KAAK,GAAGF,IAAI,CAACG,KAAL,EAAd;IACAD,KAAK,CAACE,YAAN,CAAmBZ,SAAS,CAACkB,KAA7B;IACA,OAAOR,KAAP;EACD,CAJ4B,EAI1B,CAACF,IAAD,CAJ0B,CAA7B;EAKA,oBACE,oBAAC,KAAD;IAAO,KAAK;EAAZ,gBACE,oBAAC,KAAD;IAAO,KAAK,EAAEC;EAAd,GACGJ,IADH,EAEGE,IAAI,iBAAI,oBAAC,KAAD;IAAO,KAAK,EAAEU;EAAd,GAA8Bb,QAA9B,CAFX,CADF,eAKE,oBAAC,KAAD;IAAO,SAAS,EAAC;EAAjB,GAA0BA,QAA1B,CALF,CADF;AASD,CAxBM;AA0BPD,IAAI,CAACgB,YAAL,GAAoB;EAClBb,IAAI,EAAE,OADY;EAElBC,IAAI,EAAE;AAFY,CAApB"}
1
+ {"version":3,"names":["React","Group","LumaColorFilter","Paint","Mask","children","mask","mode","clip","defaultProps"],"sources":["Mask.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React from \"react\";\n\nimport { Group } from \"./Group\";\nimport { LumaColorFilter } from \"./colorFilters/LumaColorFilter\";\nimport { Paint } from \"./Paint\";\n\ninterface MaskProps {\n mode: \"luminance\" | \"alpha\";\n clip: boolean;\n mask: ReactNode | ReactNode[];\n children: ReactNode | ReactNode[];\n}\n\nexport const Mask = ({ children, mask, mode, clip }: MaskProps) => {\n return (\n <Group layer>\n <Group\n layer={\n <Paint blendMode=\"src\">\n {mode === \"luminance\" && <LumaColorFilter />}\n </Paint>\n }\n >\n {mask}\n {clip && <Group layer={<Paint blendMode=\"dstIn\" />}>{children}</Group>}\n </Group>\n <Group blendMode=\"srcIn\">{children}</Group>\n </Group>\n );\n};\n\nMask.defaultProps = {\n mode: \"alpha\",\n clip: true,\n};\n"],"mappings":"AACA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,KAAT,QAAsB,SAAtB;AASA,OAAO,MAAMC,IAAI,GAAG,QAA+C;EAAA,IAA9C;IAAEC,QAAF;IAAYC,IAAZ;IAAkBC,IAAlB;IAAwBC;EAAxB,CAA8C;EACjE,oBACE,oBAAC,KAAD;IAAO,KAAK;EAAZ,gBACE,oBAAC,KAAD;IACE,KAAK,eACH,oBAAC,KAAD;MAAO,SAAS,EAAC;IAAjB,GACGD,IAAI,KAAK,WAAT,iBAAwB,oBAAC,eAAD,OAD3B;EAFJ,GAOGD,IAPH,EAQGE,IAAI,iBAAI,oBAAC,KAAD;IAAO,KAAK,eAAE,oBAAC,KAAD;MAAO,SAAS,EAAC;IAAjB;EAAd,GAA4CH,QAA5C,CARX,CADF,eAWE,oBAAC,KAAD;IAAO,SAAS,EAAC;EAAjB,GAA0BA,QAA1B,CAXF,CADF;AAeD,CAhBM;AAkBPD,IAAI,CAACK,YAAL,GAAoB;EAClBF,IAAI,EAAE,OADY;EAElBC,IAAI,EAAE;AAFY,CAApB"}
@@ -1,5 +1,4 @@
1
1
  export * from "./components";
2
2
  export * from "./useContextBridge";
3
3
  export * from "./DependencyManager";
4
- export * from "./useCanvas";
5
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\nexport * from \"./useCanvas\";\n"],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,oBAAd;AACA,cAAc,qBAAd;AACA,cAAc,aAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\n"],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,oBAAd;AACA,cAAc,qBAAd"}
@@ -6,7 +6,7 @@ export declare class Container {
6
6
  redraw: () => void;
7
7
  private _root;
8
8
  Sk: SkDOM;
9
- constructor(Skia: Skia, depMgr: DependencyManager, redraw: () => void);
9
+ constructor(Skia: Skia, depMgr: DependencyManager, redraw?: () => void);
10
10
  draw(ctx: DrawingContext): void;
11
11
  get root(): RenderNode<GroupProps>;
12
12
  }
@@ -1,4 +1,3 @@
1
1
  export * from "./components";
2
2
  export * from "./useContextBridge";
3
3
  export * from "./DependencyManager";
4
- export * from "./useCanvas";
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.162",
10
+ "version": "0.1.163",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -4,7 +4,6 @@ import React, {
4
4
  useMemo,
5
5
  forwardRef,
6
6
  useRef,
7
- useState,
8
7
  } from "react";
9
8
  import type {
10
9
  RefObject,
@@ -15,7 +14,6 @@ import type {
15
14
  } from "react";
16
15
  import type { OpaqueRoot } from "react-reconciler";
17
16
  import ReactReconciler from "react-reconciler";
18
- import { Platform } from "react-native";
19
17
 
20
18
  import { SkiaDomView } from "../views";
21
19
  import type { TouchHandler } from "../views";
@@ -26,7 +24,6 @@ import { debug as hostDebug, skHostConfig } from "./HostConfig";
26
24
  // import { debugTree } from "./nodes";
27
25
  import { Container } from "./Container";
28
26
  import { DependencyManager } from "./DependencyManager";
29
- import { CanvasProvider } from "./useCanvas";
30
27
 
31
28
  export const skiaReconciler = ReactReconciler(skHostConfig);
32
29
 
@@ -65,11 +62,8 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
65
62
  ) => {
66
63
  const innerRef = useCanvasRef();
67
64
  const ref = useCombinedRefs(forwardedRef, innerRef);
68
- const [, setTick] = useState(0);
69
65
  const redraw = useCallback(() => {
70
- Platform.OS === "web"
71
- ? setTick((tick) => tick + 1)
72
- : innerRef.current?.redraw();
66
+ innerRef.current?.redraw();
73
67
  }, [innerRef]);
74
68
 
75
69
  const registerValues = useCallback(
@@ -107,11 +101,7 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
107
101
 
108
102
  // Render effect
109
103
  useEffect(() => {
110
- render(
111
- <CanvasProvider value={{ Skia }}>{children}</CanvasProvider>,
112
- root,
113
- container
114
- );
104
+ render(children, root, container);
115
105
  }, [children, root, redraw, container]);
116
106
 
117
107
  useEffect(() => {
@@ -15,7 +15,7 @@ export class Container {
15
15
  constructor(
16
16
  Skia: Skia,
17
17
  public depMgr: DependencyManager,
18
- public redraw: () => void
18
+ public redraw: () => void = () => {}
19
19
  ) {
20
20
  this.Sk = new JsiSkDOM({ Skia, depMgr });
21
21
  this._root = this.Sk.Group();
@@ -1,10 +1,9 @@
1
1
  import type { ReactNode } from "react";
2
- import React, { useMemo } from "react";
3
-
4
- import { BlendMode } from "../../skia/types";
5
- import { useSkiaPrivate } from "../useCanvas";
2
+ import React from "react";
6
3
 
7
4
  import { Group } from "./Group";
5
+ import { LumaColorFilter } from "./colorFilters/LumaColorFilter";
6
+ import { Paint } from "./Paint";
8
7
 
9
8
  interface MaskProps {
10
9
  mode: "luminance" | "alpha";
@@ -14,25 +13,17 @@ interface MaskProps {
14
13
  }
15
14
 
16
15
  export const Mask = ({ children, mask, mode, clip }: MaskProps) => {
17
- const Skia = useSkiaPrivate();
18
- const maskPaint = useMemo(() => {
19
- const paint = Skia.Paint();
20
- paint.setBlendMode(BlendMode.Src);
21
- if (mode === "luminance") {
22
- paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());
23
- }
24
- return paint;
25
- }, [Skia, mode]);
26
- const clippingPaint = useMemo(() => {
27
- const paint = Skia.Paint();
28
- paint.setBlendMode(BlendMode.DstIn);
29
- return paint;
30
- }, [Skia]);
31
16
  return (
32
17
  <Group layer>
33
- <Group layer={maskPaint}>
18
+ <Group
19
+ layer={
20
+ <Paint blendMode="src">
21
+ {mode === "luminance" && <LumaColorFilter />}
22
+ </Paint>
23
+ }
24
+ >
34
25
  {mask}
35
- {clip && <Group layer={clippingPaint}>{children}</Group>}
26
+ {clip && <Group layer={<Paint blendMode="dstIn" />}>{children}</Group>}
36
27
  </Group>
37
28
  <Group blendMode="srcIn">{children}</Group>
38
29
  </Group>
@@ -1,4 +1,3 @@
1
1
  export * from "./components";
2
2
  export * from "./useContextBridge";
3
3
  export * from "./DependencyManager";
4
- export * from "./useCanvas";
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useSkiaPrivate = exports.CanvasProvider = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
-
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
-
14
- const CanvasContext = /*#__PURE__*/_react.default.createContext(null);
15
-
16
- const CanvasProvider = CanvasContext.Provider; // This private function will be removed once we remove the useCanvas hook and
17
- // implement the Mask component as a node (will be faster too)
18
-
19
- exports.CanvasProvider = CanvasProvider;
20
-
21
- const useSkiaPrivate = () => {
22
- const ctx = (0, _react.useContext)(CanvasContext);
23
-
24
- if (!ctx) {
25
- throw new Error("Skia Canvas context is not available");
26
- }
27
-
28
- return ctx.Skia;
29
- };
30
-
31
- exports.useSkiaPrivate = useSkiaPrivate;
32
- //# sourceMappingURL=useCanvas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["CanvasContext","React","createContext","CanvasProvider","Provider","useSkiaPrivate","ctx","useContext","Error","Skia"],"sources":["useCanvas.ts"],"sourcesContent":["import React, { useContext } from \"react\";\n\nimport type { Skia } from \"../skia/types\";\n\ninterface CanvasContext {\n Skia: Skia;\n}\n\nconst CanvasContext = React.createContext<CanvasContext | null>(null);\n\nexport const CanvasProvider = CanvasContext.Provider;\n\n// This private function will be removed once we remove the useCanvas hook and\n// implement the Mask component as a node (will be faster too)\nexport const useSkiaPrivate = () => {\n const ctx = useContext(CanvasContext);\n if (!ctx) {\n throw new Error(\"Skia Canvas context is not available\");\n }\n return ctx.Skia;\n};\n"],"mappings":";;;;;;;AAAA;;;;;;AAQA,MAAMA,aAAa,gBAAGC,cAAA,CAAMC,aAAN,CAA0C,IAA1C,CAAtB;;AAEO,MAAMC,cAAc,GAAGH,aAAa,CAACI,QAArC,C,CAEP;AACA;;;;AACO,MAAMC,cAAc,GAAG,MAAM;EAClC,MAAMC,GAAG,GAAG,IAAAC,iBAAA,EAAWP,aAAX,CAAZ;;EACA,IAAI,CAACM,GAAL,EAAU;IACR,MAAM,IAAIE,KAAJ,CAAU,sCAAV,CAAN;EACD;;EACD,OAAOF,GAAG,CAACG,IAAX;AACD,CANM"}
@@ -1,15 +0,0 @@
1
- import React, { useContext } from "react";
2
- const CanvasContext = /*#__PURE__*/React.createContext(null);
3
- export const CanvasProvider = CanvasContext.Provider; // This private function will be removed once we remove the useCanvas hook and
4
- // implement the Mask component as a node (will be faster too)
5
-
6
- export const useSkiaPrivate = () => {
7
- const ctx = useContext(CanvasContext);
8
-
9
- if (!ctx) {
10
- throw new Error("Skia Canvas context is not available");
11
- }
12
-
13
- return ctx.Skia;
14
- };
15
- //# sourceMappingURL=useCanvas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","useContext","CanvasContext","createContext","CanvasProvider","Provider","useSkiaPrivate","ctx","Error","Skia"],"sources":["useCanvas.ts"],"sourcesContent":["import React, { useContext } from \"react\";\n\nimport type { Skia } from \"../skia/types\";\n\ninterface CanvasContext {\n Skia: Skia;\n}\n\nconst CanvasContext = React.createContext<CanvasContext | null>(null);\n\nexport const CanvasProvider = CanvasContext.Provider;\n\n// This private function will be removed once we remove the useCanvas hook and\n// implement the Mask component as a node (will be faster too)\nexport const useSkiaPrivate = () => {\n const ctx = useContext(CanvasContext);\n if (!ctx) {\n throw new Error(\"Skia Canvas context is not available\");\n }\n return ctx.Skia;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AAQA,MAAMC,aAAa,gBAAGF,KAAK,CAACG,aAAN,CAA0C,IAA1C,CAAtB;AAEA,OAAO,MAAMC,cAAc,GAAGF,aAAa,CAACG,QAArC,C,CAEP;AACA;;AACA,OAAO,MAAMC,cAAc,GAAG,MAAM;EAClC,MAAMC,GAAG,GAAGN,UAAU,CAACC,aAAD,CAAtB;;EACA,IAAI,CAACK,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;EACD;;EACD,OAAOD,GAAG,CAACE,IAAX;AACD,CANM"}
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import type { Skia } from "../skia/types";
3
- interface CanvasContext {
4
- Skia: Skia;
5
- }
6
- declare const CanvasContext: React.Context<CanvasContext | null>;
7
- export declare const CanvasProvider: React.Provider<CanvasContext | null>;
8
- export declare const useSkiaPrivate: () => Skia;
9
- export {};
@@ -1,21 +0,0 @@
1
- import React, { useContext } from "react";
2
-
3
- import type { Skia } from "../skia/types";
4
-
5
- interface CanvasContext {
6
- Skia: Skia;
7
- }
8
-
9
- const CanvasContext = React.createContext<CanvasContext | null>(null);
10
-
11
- export const CanvasProvider = CanvasContext.Provider;
12
-
13
- // This private function will be removed once we remove the useCanvas hook and
14
- // implement the Mask component as a node (will be faster too)
15
- export const useSkiaPrivate = () => {
16
- const ctx = useContext(CanvasContext);
17
- if (!ctx) {
18
- throw new Error("Skia Canvas context is not available");
19
- }
20
- return ctx.Skia;
21
- };