@shopify/react-native-skia 0.1.165 → 0.1.167

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +11 -5
  2. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +34 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomViewManager.java +2 -47
  4. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawViewManager.java +2 -44
  5. package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureViewManager.java +2 -47
  6. package/cpp/api/JsiSkPath.h +20 -3
  7. package/cpp/rnskia/dom/base/DerivedNodeProp.h +4 -4
  8. package/cpp/rnskia/dom/nodes/JsiBoxNode.h +8 -16
  9. package/cpp/rnskia/dom/nodes/JsiPathNode.h +12 -5
  10. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +44 -13
  11. package/cpp/rnskia/dom/props/ClipProp.h +6 -6
  12. package/cpp/rnskia/dom/props/ImageProps.h +13 -8
  13. package/cpp/rnskia/dom/props/PaintProps.h +0 -16
  14. package/cpp/rnskia/dom/props/PointProp.h +4 -13
  15. package/cpp/rnskia/dom/props/PointsProp.h +1 -7
  16. package/cpp/rnskia/dom/props/RRectProp.h +53 -0
  17. package/cpp/rnskia/dom/props/RadiusProp.h +7 -9
  18. package/cpp/rnskia/dom/props/TransformProp.h +2 -2
  19. package/cpp/rnskia/dom/props/VerticesProps.h +2 -2
  20. package/lib/commonjs/dom/nodes/datatypes/Transform.js +0 -3
  21. package/lib/commonjs/dom/nodes/datatypes/Transform.js.map +1 -1
  22. package/lib/commonjs/dom/nodes/drawings/Box.js +1 -1
  23. package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
  24. package/lib/commonjs/dom/nodes/paint/ImageFilters.js +1 -1
  25. package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
  26. package/lib/commonjs/dom/nodes/paint/Shaders.js +5 -2
  27. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  28. package/lib/commonjs/renderer/Canvas.js +8 -39
  29. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  30. package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
  31. package/lib/commonjs/renderer/Reconciler.js +64 -0
  32. package/lib/commonjs/renderer/Reconciler.js.map +1 -0
  33. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  34. package/lib/commonjs/skia/types/Shader/Shader.js +26 -27
  35. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  36. package/lib/commonjs/skia/web/JsiSkPath.js +7 -0
  37. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkRRect.js +14 -1
  39. package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkia.js +1 -1
  41. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  42. package/lib/module/dom/nodes/datatypes/Transform.js +0 -3
  43. package/lib/module/dom/nodes/datatypes/Transform.js.map +1 -1
  44. package/lib/module/dom/nodes/drawings/Box.js +1 -1
  45. package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
  46. package/lib/module/dom/nodes/paint/ImageFilters.js +1 -1
  47. package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
  48. package/lib/module/dom/nodes/paint/Shaders.js +5 -4
  49. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  50. package/lib/module/renderer/Canvas.js +7 -33
  51. package/lib/module/renderer/Canvas.js.map +1 -1
  52. package/lib/module/renderer/DrawingContext.js.map +1 -1
  53. package/lib/module/renderer/Reconciler.js +48 -0
  54. package/lib/module/renderer/Reconciler.js.map +1 -0
  55. package/lib/module/skia/types/Path/Path.js.map +1 -1
  56. package/lib/module/skia/types/Shader/Shader.js +26 -27
  57. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  58. package/lib/module/skia/web/JsiSkPath.js +7 -0
  59. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  60. package/lib/module/skia/web/JsiSkRRect.js +14 -1
  61. package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
  62. package/lib/module/skia/web/JsiSkia.js +1 -1
  63. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  64. package/lib/typescript/src/renderer/Canvas.d.ts +4 -7
  65. package/lib/typescript/src/renderer/DrawingContext.d.ts +2 -5
  66. package/lib/typescript/src/renderer/Reconciler.d.ts +13 -0
  67. package/lib/typescript/src/skia/types/Path/Path.d.ts +13 -0
  68. package/lib/typescript/src/skia/types/Shader/Shader.d.ts +1 -2
  69. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +1 -0
  70. package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +2 -2
  71. package/package.json +1 -1
  72. package/src/dom/nodes/datatypes/Transform.ts +0 -2
  73. package/src/dom/nodes/drawings/Box.ts +1 -1
  74. package/src/dom/nodes/paint/ImageFilters.ts +1 -1
  75. package/src/dom/nodes/paint/Shaders.ts +5 -5
  76. package/src/renderer/Canvas.tsx +12 -61
  77. package/src/renderer/DrawingContext.ts +2 -6
  78. package/src/renderer/Reconciler.tsx +66 -0
  79. package/src/skia/types/Path/Path.ts +14 -0
  80. package/src/skia/types/Shader/Shader.ts +30 -38
  81. package/src/skia/web/JsiSkPath.ts +10 -0
  82. package/src/skia/web/JsiSkRRect.ts +13 -2
  83. package/src/skia/web/JsiSkia.ts +1 -4
@@ -1 +1 @@
1
- {"version":3,"names":["BaseHostObject","JsiSkRect","JsiSkRRect","fromValue","CanvasKit","rect","ref","RRectXY","rx","ry","constructor","Float32Array","of"],"sources":["JsiSkRRect.ts"],"sourcesContent":["import type { CanvasKit, RRect } from \"canvaskit-wasm\";\n\nimport type { SkRRect } from \"../types\";\n\nimport { BaseHostObject } from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkRRect\n extends BaseHostObject<RRect, \"RRect\">\n implements SkRRect\n{\n static fromValue(CanvasKit: CanvasKit, rect: SkRRect) {\n if (rect instanceof JsiSkRect) {\n return rect.ref;\n }\n return CanvasKit.RRectXY(\n JsiSkRect.fromValue(CanvasKit, rect.rect),\n rect.rx,\n rect.ry\n );\n }\n\n constructor(CanvasKit: CanvasKit, ref: RRect) {\n super(CanvasKit, ref, \"RRect\");\n }\n\n get rx() {\n return this.ref[4];\n }\n\n get ry() {\n return this.ref[5];\n }\n\n get rect() {\n return new JsiSkRect(\n this.CanvasKit,\n Float32Array.of(this.ref[0], this.ref[1], this.ref[2], this.ref[3])\n );\n }\n}\n"],"mappings":"AAIA,SAASA,cAAT,QAA+B,QAA/B;AACA,SAASC,SAAT,QAA0B,aAA1B;AAEA,OAAO,MAAMC,UAAN,SACGF,cADH,CAGP;EACkB,OAATG,SAAS,CAACC,SAAD,EAAuBC,IAAvB,EAAsC;IACpD,IAAIA,IAAI,YAAYJ,SAApB,EAA+B;MAC7B,OAAOI,IAAI,CAACC,GAAZ;IACD;;IACD,OAAOF,SAAS,CAACG,OAAV,CACLN,SAAS,CAACE,SAAV,CAAoBC,SAApB,EAA+BC,IAAI,CAACA,IAApC,CADK,EAELA,IAAI,CAACG,EAFA,EAGLH,IAAI,CAACI,EAHA,CAAP;EAKD;;EAEDC,WAAW,CAACN,SAAD,EAAuBE,GAAvB,EAAmC;IAC5C,MAAMF,SAAN,EAAiBE,GAAjB,EAAsB,OAAtB;EACD;;EAEK,IAAFE,EAAE,GAAG;IACP,OAAO,KAAKF,GAAL,CAAS,CAAT,CAAP;EACD;;EAEK,IAAFG,EAAE,GAAG;IACP,OAAO,KAAKH,GAAL,CAAS,CAAT,CAAP;EACD;;EAEO,IAAJD,IAAI,GAAG;IACT,OAAO,IAAIJ,SAAJ,CACL,KAAKG,SADA,EAELO,YAAY,CAACC,EAAb,CAAgB,KAAKN,GAAL,CAAS,CAAT,CAAhB,EAA6B,KAAKA,GAAL,CAAS,CAAT,CAA7B,EAA0C,KAAKA,GAAL,CAAS,CAAT,CAA1C,EAAuD,KAAKA,GAAL,CAAS,CAAT,CAAvD,CAFK,CAAP;EAID;;AA7BH"}
1
+ {"version":3,"names":["BaseHostObject","JsiSkRect","JsiSkRRect","fromValue","CanvasKit","rect","ref","RRectXY","rx","ry","constructor","Infinity","width","height","scale","Math","min","Float32Array","of"],"sources":["JsiSkRRect.ts"],"sourcesContent":["import type { CanvasKit, RRect } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkRRect } from \"../types\";\n\nimport { BaseHostObject } from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkRRect\n extends BaseHostObject<RRect, \"RRect\">\n implements SkRRect\n{\n static fromValue(CanvasKit: CanvasKit, rect: SkRRect) {\n if (rect instanceof JsiSkRect) {\n return rect.ref;\n }\n return CanvasKit.RRectXY(\n JsiSkRect.fromValue(CanvasKit, rect.rect),\n rect.rx,\n rect.ry\n );\n }\n\n constructor(CanvasKit: CanvasKit, rect: SkRect, rx: number, ry: number) {\n // based on https://github.com/google/skia/blob/main/src/core/SkRRect.cpp#L51\n if (rx === Infinity || ry === Infinity) {\n rx = ry = 0;\n }\n if (rect.width < rx + rx || rect.height < ry + ry) {\n // At most one of these two divides will be by zero, and neither numerator is zero.\n const scale = Math.min(rect.width / (rx + rx), rect.height / (ry + ry));\n rx *= scale;\n ry *= scale;\n }\n const ref = CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry);\n super(CanvasKit, ref, \"RRect\");\n }\n\n get rx() {\n return this.ref[4];\n }\n\n get ry() {\n return this.ref[5];\n }\n\n get rect() {\n return new JsiSkRect(\n this.CanvasKit,\n Float32Array.of(this.ref[0], this.ref[1], this.ref[2], this.ref[3])\n );\n }\n}\n"],"mappings":"AAIA,SAASA,cAAT,QAA+B,QAA/B;AACA,SAASC,SAAT,QAA0B,aAA1B;AAEA,OAAO,MAAMC,UAAN,SACGF,cADH,CAGP;EACkB,OAATG,SAAS,CAACC,SAAD,EAAuBC,IAAvB,EAAsC;IACpD,IAAI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AKZ,GAAL,CAAS,CAAT,CAAhB,EAA6B,KAAKA,GAAL,CAAS,CAAT,CAA7B,EAA0C,KAAKA,GAAL,CAAS,CAAT,CAA1C,EAAuD,KAAKA,GAAL,CAAS,CAAT,CAAvD,CAFK,CAAP;EAID;;AAxCH"}
@@ -30,7 +30,7 @@ export const JsiSkApi = CanvasKit => ({
30
30
  RuntimeShaderBuilder: _ => {
31
31
  throw new Error("Not implemented on React Native Web");
32
32
  },
33
- RRectXY: (rect, rx, ry) => new JsiSkRRect(CanvasKit, CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry)),
33
+ RRectXY: (rect, rx, ry) => new JsiSkRRect(CanvasKit, rect, rx, ry),
34
34
  RSXform: (scos, ssin, tx, ty) => new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),
35
35
  Color,
36
36
  ContourMeasureIter: (path, forceClosed, resScale) => new JsiSkContourMeasureIter(CanvasKit, new CanvasKit.ContourMeasureIter(JsiSkPath.fromValue(path), forceClosed, resScale)),
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkPath","JsiSkTypeface","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","fromValue","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","Paint","paint","setAntiAlias","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","XYWHRect","width","height","Surface"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(\n CanvasKit,\n CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry)\n ),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n});\n"],"mappings":"AAYA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,yBAAT,QAA0C,6BAA1C;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC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lB,EAAwB3C,SAAxB,CA1DyC;EA2DvD4C,IAAI,EAAE,IAAIrD,gBAAJ,CAAqBS,SAArB,CA3DiD;EA4DvD6C,KAAK,EAAE,IAAIrD,iBAAJ,CAAsBQ,SAAtB,CA5DgD;EA6DvD8C,GAAG,EAAE,IAAIrD,eAAJ,CAAoBO,SAApB,CA7DkD;EA8DvD+C,QAAQ,EAAE,IAAIrD,oBAAJ,CAAyBM,SAAzB,CA9D6C;EA+DvDgD,QAAQ,EAAE,CAAC9C,CAAD,EAAYC,CAAZ,EAAuB8C,KAAvB,EAAsCC,MAAtC,KAAyD;IACjE,OAAO,IAAI5E,SAAJ,CAAc0B,SAAd,EAAyBA,SAAS,CAACgD,QAAV,CAAmB9C,CAAnB,EAAsBC,CAAtB,EAAyB8C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;EACD,CAjEsD;EAkEvDC,OAAO,EAAE,IAAI3E,mBAAJ,CAAwBwB,SAAxB;AAlE8C,CAAjC,CAAjB"}
1
+ {"version":3,"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkPath","JsiSkTypeface","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","fromValue","Paint","paint","setAntiAlias","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","XYWHRect","width","height","Surface"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, rect, rx, ry),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n});\n"],"mappings":"AAYA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,yBAAT,QAA0C,6BAA1C;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA,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EAAE,IAAIrD,eAAJ,CAAoBO,SAApB,CA1DkD;EA2DvD+C,QAAQ,EAAE,IAAIrD,oBAAJ,CAAyBM,SAAzB,CA3D6C;EA4DvDgD,QAAQ,EAAE,CAAC9C,CAAD,EAAYC,CAAZ,EAAuB8C,KAAvB,EAAsCC,MAAtC,KAAyD;IACjE,OAAO,IAAI5E,SAAJ,CAAc0B,SAAd,EAAyBA,SAAS,CAACgD,QAAV,CAAmB9C,CAAnB,EAAsBC,CAAtB,EAAyB8C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;EACD,CA9DsD;EA+DvDC,OAAO,EAAE,IAAI3E,mBAAJ,CAAwBwB,SAAxB;AA/D8C,CAAjC,CAAjB"}
@@ -1,14 +1,11 @@
1
1
  import React from "react";
2
- import type { RefObject, ReactNode, ComponentProps } from "react";
3
- import ReactReconciler from "react-reconciler";
2
+ import type { RefObject, ReactNode } from "react";
4
3
  import { SkiaDomView } from "../views";
5
- import type { TouchHandler } from "../views";
6
- import { Container } from "./Container";
7
- export declare const skiaReconciler: ReactReconciler.Reconciler<Container, import("..").Node<unknown>, import("..").Node<unknown>, import("..").Node<unknown>, import("..").Node<unknown>>;
4
+ import type { TouchHandler, SkiaBaseViewProps } from "../views";
8
5
  export declare const useCanvasRef: () => React.RefObject<SkiaDomView>;
9
- export interface CanvasProps extends ComponentProps<typeof SkiaDomView> {
6
+ export interface CanvasProps extends SkiaBaseViewProps {
10
7
  ref?: RefObject<SkiaDomView>;
11
8
  children: ReactNode;
12
9
  onTouch?: TouchHandler;
13
10
  }
14
- export declare const Canvas: React.ForwardRefExoticComponent<Pick<CanvasProps, "children" | "style" | "mode" | "debug" | "onSize" | "root" | "onTouch" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors"> & React.RefAttributes<SkiaDomView>>;
11
+ export declare const Canvas: React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;
@@ -1,9 +1,6 @@
1
- import type { RefObject } from "react";
2
- import type { DrawingInfo, SkiaView } from "../views";
3
- import type { Skia, Vector } from "../skia/types";
1
+ import type { DrawingInfo } from "../views";
2
+ import type { Skia } from "../skia/types";
4
3
  import type { DrawingContext as DOMDrawingContext } from "../dom/types";
5
4
  export interface DrawingContext extends Omit<DrawingInfo, "touches">, DOMDrawingContext {
6
- center: Vector;
7
- ref: RefObject<SkiaView>;
8
5
  Skia: Skia;
9
6
  }
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from "react";
2
+ import type { Skia } from "../skia/types";
3
+ import type { SkiaValue } from "../values/types";
4
+ declare type RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;
5
+ export declare class SkiaRoot {
6
+ private root;
7
+ private container;
8
+ constructor(Skia: Skia, registerValues?: RegisterValues, redraw?: () => void);
9
+ render(element: ReactNode): void;
10
+ unmount(): void;
11
+ get dom(): import("..").RenderNode<import("..").GroupProps>;
12
+ }
13
+ export {};
@@ -348,6 +348,19 @@ export interface SkPath extends SkJSIInstance<"Path"> {
348
348
  * @param isCCW
349
349
  */
350
350
  addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;
351
+ /** Appends src to SkPath, transformed by matrix. Transformed curves may have
352
+ different verbs, SkPoint, and conic weights.
353
+
354
+ If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic
355
+ weights are added unaltered. If mode is kExtend_AddPathMode, add line
356
+ before appending verbs, SkPoint, and conic weights.
357
+
358
+ @param src SkPath verbs, SkPoint, and conic weights to add
359
+ @param matrix transform applied to src
360
+ @param extend extends path with line if true
361
+ @return reference to SkPath
362
+ */
363
+ addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPath;
351
364
  /**
352
365
  * Returns the Point at index in Point array. Valid range for index is
353
366
  * 0 to countPoints() - 1.
@@ -3,8 +3,7 @@ import type { Vector } from "../Point";
3
3
  import type { SkRuntimeEffect, SkRuntimeShaderBuilder } from "../RuntimeEffect";
4
4
  export declare const isShader: (obj: SkJSIInstance<string> | null) => obj is SkShader;
5
5
  export declare type SkShader = SkJSIInstance<"Shader">;
6
- export declare type UniformValue = number | Vector | readonly number[];
7
- export declare type Uniform = UniformValue | readonly UniformValue[] | Float32Array;
6
+ export declare type Uniform = number | Vector | Float32Array | Uniform[];
8
7
  export interface Uniforms {
9
8
  [name: string]: Uniform;
10
9
  }
@@ -5,6 +5,7 @@ import { JsiSkPoint } from "./JsiSkPoint";
5
5
  import { JsiSkRect } from "./JsiSkRect";
6
6
  export declare class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
7
7
  constructor(CanvasKit: CanvasKit, ref: Path);
8
+ addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): this;
8
9
  addArc(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number): this;
9
10
  addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): this;
10
11
  countPoints(): number;
@@ -1,10 +1,10 @@
1
1
  import type { CanvasKit, RRect } from "canvaskit-wasm";
2
- import type { SkRRect } from "../types";
2
+ import type { SkRect, SkRRect } from "../types";
3
3
  import { BaseHostObject } from "./Host";
4
4
  import { JsiSkRect } from "./JsiSkRect";
5
5
  export declare class JsiSkRRect extends BaseHostObject<RRect, "RRect"> implements SkRRect {
6
6
  static fromValue(CanvasKit: CanvasKit, rect: SkRRect): Float32Array;
7
- constructor(CanvasKit: CanvasKit, ref: RRect);
7
+ constructor(CanvasKit: CanvasKit, rect: SkRect, rx: number, ry: number);
8
8
  get rx(): number;
9
9
  get ry(): number;
10
10
  get rect(): JsiSkRect;
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.165",
10
+ "version": "0.1.167",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -10,11 +10,9 @@ export const processTransformProps = (m3: SkMatrix, props: TransformProps) => {
10
10
  m3.concat(matrix);
11
11
  m3.translate(-origin.x, -origin.y);
12
12
  } else {
13
- m3.identity();
14
13
  m3.concat(matrix);
15
14
  }
16
15
  } else if (transform) {
17
- m3.identity();
18
16
  if (origin) {
19
17
  m3.translate(origin.x, origin.y);
20
18
  }
@@ -40,7 +40,7 @@ export class BoxShadowNode extends JsiDeclarationNode<
40
40
  BoxShadowProps
41
41
  > {
42
42
  constructor(ctx: NodeContext, props: BoxShadowProps) {
43
- super(ctx, DeclarationType.Unknown, NodeType.Box, props);
43
+ super(ctx, DeclarationType.Unknown, NodeType.BoxShadow, props);
44
44
  }
45
45
 
46
46
  materialize() {
@@ -140,7 +140,7 @@ export class BlurImageFilterNode extends ImageFilterDeclaration<BlurImageFilterP
140
140
 
141
141
  export class DropShadowImageFilterNode extends ImageFilterDeclaration<DropShadowImageFilterProps> {
142
142
  constructor(ctx: NodeContext, props: DropShadowImageFilterProps) {
143
- super(ctx, NodeType.BlurImageFilter, props);
143
+ super(ctx, NodeType.DropShadowImageFilter, props);
144
144
  }
145
145
 
146
146
  materialize() {
@@ -67,19 +67,19 @@ export class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {
67
67
  materialize() {
68
68
  const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;
69
69
  const rct = getRect(this.Skia, imageShaderProps);
70
+ const m3 = this.Skia.Matrix();
70
71
  if (rct) {
71
72
  const rects = fitRects(
72
73
  fit,
73
74
  { x: 0, y: 0, width: image.width(), height: image.height() },
74
75
  rct
75
76
  );
76
- const m3 = rect2rect(rects.src, rects.dst);
77
- imageShaderProps.transform = [
78
- ...(imageShaderProps.transform ?? []),
79
- ...m3,
80
- ];
77
+ const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);
78
+ m3.translate(x.translateX, y.translateY);
79
+ m3.scale(sx.scaleX, sy.scaleY);
81
80
  }
82
81
  const lm = this.Skia.Matrix();
82
+ lm.concat(m3);
83
83
  processTransformProps(lm, imageShaderProps);
84
84
  return image.makeShaderOptions(
85
85
  TileMode[enumKey(tx)],
@@ -8,48 +8,20 @@ import React, {
8
8
  import type {
9
9
  RefObject,
10
10
  ReactNode,
11
- ComponentProps,
12
11
  MutableRefObject,
13
12
  ForwardedRef,
14
13
  } from "react";
15
- import type { OpaqueRoot } from "react-reconciler";
16
- import ReactReconciler from "react-reconciler";
17
14
 
18
15
  import { SkiaDomView } from "../views";
19
- import type { TouchHandler } from "../views";
20
16
  import { Skia } from "../skia/Skia";
21
- import type { SkiaValue } from "../values";
17
+ import type { TouchHandler, SkiaBaseViewProps } from "../views";
18
+ import type { SkiaValue } from "../values/types";
22
19
 
23
- import { debug as hostDebug, skHostConfig } from "./HostConfig";
24
- // import { debugTree } from "./nodes";
25
- import { Container } from "./Container";
26
- import { DependencyManager } from "./DependencyManager";
27
-
28
- export const skiaReconciler = ReactReconciler(skHostConfig);
29
-
30
- skiaReconciler.injectIntoDevTools({
31
- bundleType: 1,
32
- version: "0.0.1",
33
- rendererPackageName: "react-native-skia",
34
- });
35
-
36
- const render = (element: ReactNode, root: OpaqueRoot, container: Container) => {
37
- skiaReconciler.updateContainer(element, root, null, () => {
38
- hostDebug("updateContainer");
39
- container.depMgr.update();
40
- });
41
- };
20
+ import { SkiaRoot } from "./Reconciler";
42
21
 
43
22
  export const useCanvasRef = () => useRef<SkiaDomView>(null);
44
23
 
45
- const createDependencyManager = (
46
- registerValues: (values: Array<SkiaValue<unknown>>) => () => void
47
- ) =>
48
- global.SkiaDomApi && global.SkiaDomApi.DependencyManager
49
- ? global.SkiaDomApi.DependencyManager(registerValues)
50
- : new DependencyManager(registerValues);
51
-
52
- export interface CanvasProps extends ComponentProps<typeof SkiaDomView> {
24
+ export interface CanvasProps extends SkiaBaseViewProps {
53
25
  ref?: RefObject<SkiaDomView>;
54
26
  children: ReactNode;
55
27
  onTouch?: TouchHandler;
@@ -75,48 +47,27 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
75
47
  },
76
48
  [ref]
77
49
  );
78
-
79
- const container = useMemo(() => {
80
- return new Container(
81
- Skia,
82
- createDependencyManager(registerValues),
83
- redraw
84
- );
85
- }, [redraw, registerValues]);
86
-
87
50
  const root = useMemo(
88
- () =>
89
- skiaReconciler.createContainer(
90
- container,
91
- 0,
92
- null,
93
- true,
94
- null,
95
- "",
96
- console.error,
97
- null
98
- ),
99
- [container]
51
+ () => new SkiaRoot(Skia, registerValues, redraw),
52
+ [redraw, registerValues]
100
53
  );
101
54
 
102
55
  // Render effect
103
56
  useEffect(() => {
104
- render(children, root, container);
105
- }, [children, root, redraw, container]);
57
+ root.render(children);
58
+ }, [children, root, redraw]);
106
59
 
107
60
  useEffect(() => {
108
61
  return () => {
109
- skiaReconciler.updateContainer(null, root, null, () => {
110
- container.depMgr.remove();
111
- });
62
+ root.unmount();
112
63
  };
113
- }, [container, root]);
64
+ }, [root]);
114
65
 
115
66
  return (
116
67
  <SkiaDomView
117
68
  ref={ref}
118
69
  style={style}
119
- root={container.root}
70
+ root={root.dom}
120
71
  onTouch={onTouch}
121
72
  onSize={onSize}
122
73
  mode={mode}
@@ -125,7 +76,7 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
125
76
  />
126
77
  );
127
78
  }
128
- );
79
+ ) as React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;
129
80
 
130
81
  /**
131
82
  * Combines a list of refs into a single ref. This can be used to provide
@@ -1,13 +1,9 @@
1
- import type { RefObject } from "react";
2
-
3
- import type { DrawingInfo, SkiaView } from "../views";
4
- import type { Skia, Vector } from "../skia/types";
1
+ import type { DrawingInfo } from "../views";
2
+ import type { Skia } from "../skia/types";
5
3
  import type { DrawingContext as DOMDrawingContext } from "../dom/types";
6
4
 
7
5
  export interface DrawingContext
8
6
  extends Omit<DrawingInfo, "touches">,
9
7
  DOMDrawingContext {
10
- center: Vector;
11
- ref: RefObject<SkiaView>;
12
8
  Skia: Skia;
13
9
  }
@@ -0,0 +1,66 @@
1
+ import type { ReactNode } from "react";
2
+ import type { OpaqueRoot } from "react-reconciler";
3
+ import ReactReconciler from "react-reconciler";
4
+
5
+ import type { Skia } from "../skia/types";
6
+ import type { SkiaValue } from "../values/types";
7
+
8
+ import { DependencyManager } from "./DependencyManager";
9
+ import { skHostConfig, debug as hostDebug } from "./HostConfig";
10
+ import { Container } from "./Container";
11
+
12
+ const skiaReconciler = ReactReconciler(skHostConfig);
13
+
14
+ type RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;
15
+
16
+ const createDependencyManager = (registerValues: RegisterValues) =>
17
+ global.SkiaDomApi && global.SkiaDomApi.DependencyManager
18
+ ? global.SkiaDomApi.DependencyManager(registerValues)
19
+ : new DependencyManager(registerValues);
20
+
21
+ skiaReconciler.injectIntoDevTools({
22
+ bundleType: 1,
23
+ version: "0.0.1",
24
+ rendererPackageName: "react-native-skia",
25
+ });
26
+
27
+ export class SkiaRoot {
28
+ private root: OpaqueRoot;
29
+ private container: Container;
30
+
31
+ constructor(
32
+ Skia: Skia,
33
+ registerValues: RegisterValues = () => () => {},
34
+ redraw: () => void = () => {}
35
+ ) {
36
+ const depMgr = createDependencyManager(registerValues);
37
+ this.container = new Container(Skia, depMgr, redraw);
38
+ this.root = skiaReconciler.createContainer(
39
+ this.container,
40
+ 0,
41
+ null,
42
+ true,
43
+ null,
44
+ "",
45
+ console.error,
46
+ null
47
+ );
48
+ }
49
+
50
+ render(element: ReactNode) {
51
+ skiaReconciler.updateContainer(element, this.root, null, () => {
52
+ hostDebug("updateContainer");
53
+ this.container.depMgr.update();
54
+ });
55
+ }
56
+
57
+ unmount() {
58
+ skiaReconciler.updateContainer(null, this.root, null, () => {
59
+ this.container.depMgr.remove();
60
+ });
61
+ }
62
+
63
+ get dom() {
64
+ return this.container.root;
65
+ }
66
+ }
@@ -441,6 +441,20 @@ export interface SkPath extends SkJSIInstance<"Path"> {
441
441
  */
442
442
  addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;
443
443
 
444
+ /** Appends src to SkPath, transformed by matrix. Transformed curves may have
445
+ different verbs, SkPoint, and conic weights.
446
+
447
+ If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic
448
+ weights are added unaltered. If mode is kExtend_AddPathMode, add line
449
+ before appending verbs, SkPoint, and conic weights.
450
+
451
+ @param src SkPath verbs, SkPoint, and conic weights to add
452
+ @param matrix transform applied to src
453
+ @param extend extends path with line if true
454
+ @return reference to SkPath
455
+ */
456
+ addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPath;
457
+
444
458
  /**
445
459
  * Returns the Point at index in Point array. Valid range for index is
446
460
  * 0 to countPoints() - 1.
@@ -7,9 +7,7 @@ export const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>
7
7
 
8
8
  export type SkShader = SkJSIInstance<"Shader">;
9
9
 
10
- export type UniformValue = number | Vector | readonly number[];
11
-
12
- export type Uniform = UniformValue | readonly UniformValue[] | Float32Array;
10
+ export type Uniform = number | Vector | Float32Array | Uniform[];
13
11
 
14
12
  export interface Uniforms {
15
13
  [name: string]: Uniform;
@@ -20,11 +18,16 @@ const isVector = (obj: unknown): obj is Vector =>
20
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
19
  (obj as any).x !== undefined && (obj as any).y !== undefined;
22
20
 
23
- const processValue = (value: UniformValue): number | readonly number[] => {
24
- if (isVector(value)) {
25
- return [value.x, value.y];
21
+ const processValue = (values: number[], value: Uniform) => {
22
+ if (typeof value === "number") {
23
+ values.push(value);
24
+ } else if (Array.isArray(value)) {
25
+ value.forEach((v) => processValue(values, v));
26
+ } else if (isVector(value)) {
27
+ values.push(value.x, value.y);
28
+ } else if (value instanceof Float32Array) {
29
+ values.push(...value);
26
30
  }
27
- return value;
28
31
  };
29
32
 
30
33
  export const processUniforms = (
@@ -32,36 +35,25 @@ export const processUniforms = (
32
35
  uniforms: Uniforms,
33
36
  builder?: SkRuntimeShaderBuilder
34
37
  ) => {
35
- const processed = new Array(source.getUniformCount())
36
- .fill(0)
37
- .flatMap((_, i) => {
38
- const name = source.getUniformName(i);
39
- const rawValue = uniforms[name];
40
- if (rawValue === undefined) {
41
- throw new Error(`No value specified for uniform ${name}`);
42
- }
43
- const value =
44
- rawValue instanceof Float32Array ? Array.from(rawValue) : rawValue;
45
- const result = Array.isArray(value)
46
- ? value.flatMap(processValue)
47
- : processValue(value as UniformValue);
48
- builder?.setUniform(name, typeof result === "number" ? [result] : result);
49
- return result;
50
- });
51
- const names = Object.keys(uniforms);
52
- if (names.length > source.getUniformCount()) {
53
- const usedUniforms = new Array(source.getUniformCount())
54
- .fill(0)
55
- .map((_, i) => source.getUniformName(i));
56
- const unusedUniform = names
57
- .map((name) => {
58
- if (usedUniforms.indexOf(name) === -1) {
59
- return name;
60
- }
61
- return null;
62
- })
63
- .filter((n) => n !== null);
64
- console.warn("Unused uniforms were provided: " + unusedUniform.join(", "));
38
+ const result: number[] = [];
39
+ const uniformsCount = source.getUniformCount();
40
+ for (let i = 0; i < uniformsCount; i++) {
41
+ const name = source.getUniformName(i);
42
+ const value = uniforms[name];
43
+ if (!value === undefined) {
44
+ throw new Error(
45
+ // eslint-disable-next-line max-len
46
+ `The runtime effect has the uniform value "${name}" declared, but it is missing from the uniforms property of the Runtime effect.`
47
+ );
48
+ }
49
+ if (builder === undefined) {
50
+ processValue(result, value);
51
+ } else {
52
+ const uniformValue: number[] = [];
53
+ processValue(uniformValue, value);
54
+ builder.setUniform(name, uniformValue);
55
+ result.push(...uniformValue);
56
+ }
65
57
  }
66
- return processed;
58
+ return result;
67
59
  };
@@ -33,6 +33,16 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
33
33
  super(CanvasKit, ref, "Path");
34
34
  }
35
35
 
36
+ addPath(src: SkPath, matrix?: SkMatrix, extend = false) {
37
+ const args = [
38
+ JsiSkPath.fromValue(src),
39
+ ...(matrix ? JsiSkMatrix.fromValue<Float32Array>(matrix) : []),
40
+ extend,
41
+ ];
42
+ this.ref.addPath(...args);
43
+ return this;
44
+ }
45
+
36
46
  addArc(
37
47
  oval: SkRect,
38
48
  startAngleInDegrees: number,
@@ -1,6 +1,6 @@
1
1
  import type { CanvasKit, RRect } from "canvaskit-wasm";
2
2
 
3
- import type { SkRRect } from "../types";
3
+ import type { SkRect, SkRRect } from "../types";
4
4
 
5
5
  import { BaseHostObject } from "./Host";
6
6
  import { JsiSkRect } from "./JsiSkRect";
@@ -20,7 +20,18 @@ export class JsiSkRRect
20
20
  );
21
21
  }
22
22
 
23
- constructor(CanvasKit: CanvasKit, ref: RRect) {
23
+ constructor(CanvasKit: CanvasKit, rect: SkRect, rx: number, ry: number) {
24
+ // based on https://github.com/google/skia/blob/main/src/core/SkRRect.cpp#L51
25
+ if (rx === Infinity || ry === Infinity) {
26
+ rx = ry = 0;
27
+ }
28
+ if (rect.width < rx + rx || rect.height < ry + ry) {
29
+ // At most one of these two divides will be by zero, and neither numerator is zero.
30
+ const scale = Math.min(rect.width / (rx + rx), rect.height / (ry + ry));
31
+ rx *= scale;
32
+ ry *= scale;
33
+ }
34
+ const ref = CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry);
24
35
  super(CanvasKit, ref, "RRect");
25
36
  }
26
37
 
@@ -45,10 +45,7 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
45
45
  throw new Error("Not implemented on React Native Web");
46
46
  },
47
47
  RRectXY: (rect: SkRect, rx: number, ry: number) =>
48
- new JsiSkRRect(
49
- CanvasKit,
50
- CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry)
51
- ),
48
+ new JsiSkRRect(CanvasKit, rect, rx, ry),
52
49
  RSXform: (scos: number, ssin: number, tx: number, ty: number) =>
53
50
  new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),
54
51
  Color,