@shopify/react-native-skia 0.1.132 → 0.1.133

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +5 -0
  2. package/cpp/api/JsiSkImage.h +2 -19
  3. package/cpp/api/JsiSkPaint.h +5 -32
  4. package/cpp/api/JsiSkPath.h +4 -4
  5. package/lib/commonjs/skia/types/Image/Image.js +5 -5
  6. package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
  7. package/lib/commonjs/skia/types/Paint/Paint.js +3 -3
  8. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  9. package/lib/commonjs/skia/types/Path/Path.js +0 -1
  10. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  11. package/lib/commonjs/skia/types/Shader/Shader.js +1 -7
  12. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  13. package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -1
  14. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  15. package/lib/commonjs/skia/web/JsiSkFontMgr.js +0 -2
  16. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +1 -1
  17. package/lib/commonjs/skia/web/JsiSkImage.js +10 -6
  18. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  19. package/lib/commonjs/skia/web/{JsiImageFilterFactory.js → JsiSkImageFilterFactory.js} +1 -1
  20. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -0
  21. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  22. package/lib/commonjs/skia/web/JsiSkPath.js +65 -52
  23. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  24. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +1 -1
  25. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  26. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +23 -1
  27. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  28. package/lib/commonjs/skia/web/JsiSkia.js +2 -2
  29. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  30. package/lib/commonjs/views/SkiaView.web.js +4 -4
  31. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  32. package/lib/commonjs/web/index.js +4 -2
  33. package/lib/commonjs/web/index.js.map +1 -1
  34. package/lib/module/skia/types/Image/Image.js +5 -5
  35. package/lib/module/skia/types/Image/Image.js.map +1 -1
  36. package/lib/module/skia/types/Paint/Paint.js +3 -3
  37. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  38. package/lib/module/skia/types/Path/Path.js +0 -1
  39. package/lib/module/skia/types/Path/Path.js.map +1 -1
  40. package/lib/module/skia/types/Shader/Shader.js +1 -7
  41. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  42. package/lib/module/skia/web/JsiSkCanvas.js +1 -1
  43. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  44. package/lib/module/skia/web/JsiSkFontMgr.js +0 -2
  45. package/lib/module/skia/web/JsiSkFontMgr.js.map +1 -1
  46. package/lib/module/skia/web/JsiSkImage.js +10 -7
  47. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  48. package/lib/module/skia/web/{JsiImageFilterFactory.js → JsiSkImageFilterFactory.js} +1 -1
  49. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -0
  50. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  51. package/lib/module/skia/web/JsiSkPath.js +65 -52
  52. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  53. package/lib/module/skia/web/JsiSkShaderFactory.js +1 -1
  54. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  55. package/lib/module/skia/web/JsiSkVerticesFactory.js +24 -1
  56. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  57. package/lib/module/skia/web/JsiSkia.js +1 -1
  58. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  59. package/lib/module/views/SkiaView.web.js +4 -4
  60. package/lib/module/views/SkiaView.web.js.map +1 -1
  61. package/lib/module/web/index.js +3 -1
  62. package/lib/module/web/index.js.map +1 -1
  63. package/lib/typescript/src/skia/types/Image/Image.d.ts +5 -5
  64. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +3 -3
  65. package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -2
  66. package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +1 -0
  67. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +3 -3
  68. package/lib/typescript/src/skia/web/{JsiImageFilterFactory.d.ts → JsiSkImageFilterFactory.d.ts} +0 -0
  69. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -1
  70. package/package.json +1 -1
  71. package/src/skia/types/Image/Image.ts +4 -4
  72. package/src/skia/types/Paint/Paint.ts +1 -1
  73. package/src/skia/types/Path/Path.ts +0 -1
  74. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -0
  75. package/src/skia/types/Shader/Shader.ts +3 -5
  76. package/src/skia/web/JsiSkCanvas.ts +2 -2
  77. package/src/skia/web/JsiSkFontMgr.ts +0 -4
  78. package/src/skia/web/JsiSkImage.ts +37 -16
  79. package/src/skia/web/{JsiImageFilterFactory.ts → JsiSkImageFilterFactory.ts} +0 -0
  80. package/src/skia/web/JsiSkPaint.ts +1 -1
  81. package/src/skia/web/JsiSkPath.ts +64 -47
  82. package/src/skia/web/JsiSkShaderFactory.ts +4 -1
  83. package/src/skia/web/JsiSkVerticesFactory.ts +15 -1
  84. package/src/skia/web/JsiSkia.ts +1 -1
  85. package/src/views/SkiaView.web.tsx +9 -11
  86. package/src/web/index.ts +3 -1
  87. package/lib/commonjs/skia/web/JsiImageFilterFactory.js.map +0 -1
  88. package/lib/module/skia/web/JsiImageFilterFactory.js.map +0 -1
@@ -34,7 +34,7 @@ export class JsiSkShaderFactory extends Host {
34
34
  }
35
35
 
36
36
  MakeColor(color) {
37
- return new JsiSkShader(this.CanvasKit, this.CanvasKit.Shader.MakeColor(toValue(color)));
37
+ return new JsiSkShader(this.CanvasKit, this.CanvasKit.Shader.MakeColor(toValue(color), this.CanvasKit.ColorSpace.SRGB));
38
38
  }
39
39
 
40
40
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkShaderFactory.ts"],"names":["Host","toValue","ckEnum","JsiSkShader","JsiSkShaderFactory","constructor","CanvasKit","MakeLinearGradient","start","end","colors","pos","mode","localMatrix","flags","Shader","undefined","MakeRadialGradient","center","radius","MakeTwoPointConicalGradient","startRadius","endRadius","MakeSweepGradient","cx","cy","startAngleInDegrees","endAngleInDegrees","MakeTurbulence","baseFreqX","baseFreqY","octaves","seed","tileW","tileH","MakeFractalNoise","MakeBlend","one","two","MakeColor","color"],"mappings":"AAYA,SAASA,IAAT,EAAeC,OAAf,EAAwBC,MAAxB,QAAsC,QAAtC;AACA,SAASC,WAAT,QAA4B,eAA5B;AAEA,OAAO,MAAMC,kBAAN,SAAiCJ,IAAjC,CAA+D;AACpEK,EAAAA,WAAW,CAACC,SAAD,EAAuB;AAChC,UAAMA,SAAN;AACD;;AAEDC,EAAAA,kBAAkB,CAChBC,KADgB,EAEhBC,GAFgB,EAGhBC,MAHgB,EAIhBC,GAJgB,EAKhBC,IALgB,EAMhBC,WANgB,EAOhBC,KAPgB,EAQhB;AACA,WAAO,IAAIX,WAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeS,MAAf,CAAsBR,kBAAtB,CACEN,OAAO,CAACO,KAAD,CADT,EAEEP,OAAO,CAACQ,GAAD,CAFT,EAGEC,MAHF,EAIEC,GAJF,EAKET,MAAM,CAACU,IAAD,CALR,EAMEC,WAAW,KAAKG,SAAhB,GAA4BA,SAA5B,GAAwCf,OAAO,CAACY,WAAD,CANjD,EAOEC,KAPF,CAFK,CAAP;AAYD;;AAEDG,EAAAA,kBAAkB,CAChBC,MADgB,EAEhBC,MAFgB,EAGhBT,MAHgB,EAIhBC,GAJgB,EAKhBC,IALgB,EAMhBC,WANgB,E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AD,CARb,EASEC,KATF,EAUEY,mBAVF,EAWEC,iBAXF,CAFK,CAAP;AAgBD;;AAEDC,EAAAA,cAAc,CACZC,SADY,EAEZC,SAFY,EAGZC,OAHY,EAIZC,IAJY,EAKZC,KALY,EAMZC,KANY,EAOZ;AACA,WAAO,IAAI/B,WAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeS,MAAf,CAAsBa,cAAtB,CACEC,SADF,EAEEC,SAFF,EAGEC,OAHF,EAIEC,IAJF,EAKEC,KALF,EAMEC,KANF,CAFK,CAAP;AAWD;;AAEDC,EAAAA,gBAAgB,CACdN,SADc,EAEdC,SAFc,EAGdC,OAHc,EAIdC,IAJc,EAKdC,KALc,EAMdC,KANc,EAOd;AACA,WAAO,IAAI/B,WAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeS,MAAf,CAAsBoB,gBAAtB,CACEN,SADF,EAEEC,SAFF,EAGEC,OAHF,EAIEC,IAJF,EAKEC,KALF,EAMEC,KANF,CAFK,CAAP;AAWD;;AAEDE,EAAAA,SAAS,CAACxB,IAAD,EAAkByB,GAAlB,EAAiCC,GAAjC,EAAgD;AACvD,WAAO,IAAInC,WAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeS,MAAf,CAAsBqB,SAAtB,CAAgClC,MAAM,CAACU,IAAD,CAAtC,EAA8CX,OAAO,CAACoC,GAAD,CAArD,EAA4DpC,OAAO,CAACqC,GAAD,CAAnE,CAFK,CAAP;AAID;;AAEDC,EAAAA,SAAS,CAACC,KAAD,EAAiB;AACxB,WAAO,IAAIrC,WAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeS,MAAf,CAAsBwB,SAAtB,CAAgCtC,OAAO,CAACuC,KAAD,CAAvC,CAFK,CAAP;AAID;;AAjKmE","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n BlendMode,\n SkColor,\n SkMatrix,\n SkPoint,\n SkShader,\n TileMode,\n} from \"../types\";\nimport type { ShaderFactory } from \"../types/Shader/ShaderFactory\";\n\nimport { Host, toValue, ckEnum } from \"./Host\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\nexport class JsiSkShaderFactory extends Host implements ShaderFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeLinearGradient(\n start: SkPoint,\n end: SkPoint,\n colors: SkColor[],\n pos: number[] | null,\n mode: TileMode,\n localMatrix?: SkMatrix,\n flags?: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeLinearGradient(\n toValue(start),\n toValue(end),\n colors,\n pos,\n ckEnum(mode),\n localMatrix === undefined ? undefined : toValue(localMatrix),\n flags\n )\n );\n }\n\n MakeRadialGradient(\n center: SkPoint,\n radius: number,\n colors: SkColor[],\n pos: number[] | null,\n mode: TileMode,\n localMatrix?: SkMatrix,\n flags?: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeRadialGradient(\n toValue(center),\n radius,\n colors,\n pos,\n ckEnum(mode),\n localMatrix === undefined ? undefined : toValue(localMatrix),\n flags\n )\n );\n }\n\n MakeTwoPointConicalGradient(\n start: SkPoint,\n startRadius: number,\n end: SkPoint,\n endRadius: number,\n colors: SkColor[],\n pos: number[] | null,\n mode: TileMode,\n localMatrix?: SkMatrix,\n flags?: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeTwoPointConicalGradient(\n toValue(start),\n startRadius,\n toValue(end),\n endRadius,\n colors,\n pos,\n ckEnum(mode),\n localMatrix === undefined ? undefined : toValue(localMatrix),\n flags\n )\n );\n }\n\n MakeSweepGradient(\n cx: number,\n cy: number,\n colors: SkColor[],\n pos: number[] | null,\n mode: TileMode,\n localMatrix?: SkMatrix | null,\n flags?: number,\n startAngleInDegrees?: number,\n endAngleInDegrees?: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeSweepGradient(\n cx,\n cy,\n colors,\n pos,\n ckEnum(mode),\n localMatrix === undefined || localMatrix === null\n ? undefined\n : toValue(localMatrix),\n flags,\n startAngleInDegrees,\n endAngleInDegrees\n )\n );\n }\n\n MakeTurbulence(\n baseFreqX: number,\n baseFreqY: number,\n octaves: number,\n seed: number,\n tileW: number,\n tileH: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeTurbulence(\n baseFreqX,\n baseFreqY,\n octaves,\n seed,\n tileW,\n tileH\n )\n );\n }\n\n MakeFractalNoise(\n baseFreqX: number,\n baseFreqY: number,\n octaves: number,\n seed: number,\n tileW: number,\n tileH: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeFractalNoise(\n baseFreqX,\n baseFreqY,\n octaves,\n seed,\n tileW,\n tileH\n )\n );\n }\n\n MakeBlend(mode: BlendMode, one: SkShader, two: SkShader) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeBlend(ckEnum(mode), toValue(one), toValue(two))\n );\n }\n\n MakeColor(color: SkColor) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeColor(toValue(color))\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["JsiSkShaderFactory.ts"],"names":["Host","toValue","ckEnum","JsiSkShader","JsiSkShaderFactory","constructor","CanvasKit","MakeLinearGradient","start","end","colors","pos","mode","localMatrix","flags","Shader","undefined","MakeRadialGradient","center","radius","MakeTwoPointConicalGradient","startRadius","endRadius","MakeSweepGradient","cx","cy","startAngleInDegrees","endAngleInDegrees","MakeTurbulence","baseFreqX","baseFreqY","octaves","seed","tileW","tileH","MakeFractalNoise","MakeBlend","one","two","MakeColor","color","ColorSpace","SRGB"],"mappings":"AAYA,SAASA,IAAT,EAAeC,OAAf,EAAwBC,MAAxB,QAAsC,QAAtC;AACA,SAASC,WAAT,QAA4B,eAA5B;AAEA,OAAO,MAAMC,kBAAN,SAAiCJ,IAA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AIEC,IAJF,EAKEC,KALF,EAMEC,KANF,CAFK,CAAP;AAWD;;AAEDE,EAAAA,SAAS,CAACxB,IAAD,EAAkByB,GAAlB,EAAiCC,GAAjC,EAAgD;AACvD,WAAO,IAAInC,WAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeS,MAAf,CAAsBqB,SAAtB,CAAgClC,MAAM,CAACU,IAAD,CAAtC,EAA8CX,OAAO,CAACoC,GAAD,CAArD,EAA4DpC,OAAO,CAACqC,GAAD,CAAnE,CAFK,CAAP;AAID;;AAEDC,EAAAA,SAAS,CAACC,KAAD,EAAiB;AACxB,WAAO,IAAIrC,WAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAeS,MAAf,CAAsBwB,SAAtB,CACEtC,OAAO,CAACuC,KAAD,CADT,EAEE,KAAKlC,SAAL,CAAemC,UAAf,CAA0BC,IAF5B,CAFK,CAAP;AAOD;;AApKmE","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n BlendMode,\n SkColor,\n SkMatrix,\n SkPoint,\n SkShader,\n TileMode,\n} from \"../types\";\nimport type { ShaderFactory } from \"../types/Shader/ShaderFactory\";\n\nimport { Host, toValue, ckEnum } from \"./Host\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\nexport class JsiSkShaderFactory extends Host implements ShaderFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeLinearGradient(\n start: SkPoint,\n end: SkPoint,\n colors: SkColor[],\n pos: number[] | null,\n mode: TileMode,\n localMatrix?: SkMatrix,\n flags?: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeLinearGradient(\n toValue(start),\n toValue(end),\n colors,\n pos,\n ckEnum(mode),\n localMatrix === undefined ? undefined : toValue(localMatrix),\n flags\n )\n );\n }\n\n MakeRadialGradient(\n center: SkPoint,\n radius: number,\n colors: SkColor[],\n pos: number[] | null,\n mode: TileMode,\n localMatrix?: SkMatrix,\n flags?: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeRadialGradient(\n toValue(center),\n radius,\n colors,\n pos,\n ckEnum(mode),\n localMatrix === undefined ? undefined : toValue(localMatrix),\n flags\n )\n );\n }\n\n MakeTwoPointConicalGradient(\n start: SkPoint,\n startRadius: number,\n end: SkPoint,\n endRadius: number,\n colors: SkColor[],\n pos: number[] | null,\n mode: TileMode,\n localMatrix?: SkMatrix,\n flags?: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeTwoPointConicalGradient(\n toValue(start),\n startRadius,\n toValue(end),\n endRadius,\n colors,\n pos,\n ckEnum(mode),\n localMatrix === undefined ? undefined : toValue(localMatrix),\n flags\n )\n );\n }\n\n MakeSweepGradient(\n cx: number,\n cy: number,\n colors: SkColor[],\n pos: number[] | null,\n mode: TileMode,\n localMatrix?: SkMatrix | null,\n flags?: number,\n startAngleInDegrees?: number,\n endAngleInDegrees?: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeSweepGradient(\n cx,\n cy,\n colors,\n pos,\n ckEnum(mode),\n localMatrix === undefined || localMatrix === null\n ? undefined\n : toValue(localMatrix),\n flags,\n startAngleInDegrees,\n endAngleInDegrees\n )\n );\n }\n\n MakeTurbulence(\n baseFreqX: number,\n baseFreqY: number,\n octaves: number,\n seed: number,\n tileW: number,\n tileH: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeTurbulence(\n baseFreqX,\n baseFreqY,\n octaves,\n seed,\n tileW,\n tileH\n )\n );\n }\n\n MakeFractalNoise(\n baseFreqX: number,\n baseFreqY: number,\n octaves: number,\n seed: number,\n tileW: number,\n tileH: number\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeFractalNoise(\n baseFreqX,\n baseFreqY,\n octaves,\n seed,\n tileW,\n tileH\n )\n );\n }\n\n MakeBlend(mode: BlendMode, one: SkShader, two: SkShader) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeBlend(ckEnum(mode), toValue(one), toValue(two))\n );\n }\n\n MakeColor(color: SkColor) {\n return new JsiSkShader(\n this.CanvasKit,\n this.CanvasKit.Shader.MakeColor(\n toValue(color),\n this.CanvasKit.ColorSpace.SRGB\n )\n );\n }\n}\n"]}
@@ -1,5 +1,28 @@
1
1
  import { ckEnum } from "./Host";
2
2
  import { JsiSkVertices } from "./JsiSkVertices";
3
+
4
+ const concat = function () {
5
+ let totalLength = 0;
6
+
7
+ for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) {
8
+ arrays[_key] = arguments[_key];
9
+ }
10
+
11
+ for (const arr of arrays) {
12
+ totalLength += arr.length;
13
+ }
14
+
15
+ const result = new Float32Array(totalLength);
16
+ let offset = 0;
17
+
18
+ for (const arr of arrays) {
19
+ result.set(arr, offset);
20
+ offset += arr.length;
21
+ }
22
+
23
+ return result;
24
+ };
25
+
3
26
  export const MakeVertices = (CanvasKit, mode, positions, textureCoordinates, colors, indices, isVolatile) => new JsiSkVertices(CanvasKit, CanvasKit.MakeVertices(ckEnum(mode), positions.map(_ref => {
4
27
  let {
5
28
  x,
@@ -12,5 +35,5 @@ export const MakeVertices = (CanvasKit, mode, positions, textureCoordinates, col
12
35
  y
13
36
  } = _ref2;
14
37
  return [x, y];
15
- }).flat(), colors, indices, isVolatile));
38
+ }).flat(), !colors ? null : colors.reduce((a, c) => concat(a, c)), indices, isVolatile));
16
39
  //# sourceMappingURL=JsiSkVerticesFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkVerticesFactory.ts"],"names":["ckEnum","JsiSkVertices","MakeVertices","CanvasKit","mode","positions","textureCoordinates","colors","indices","isVolatile","map","x","y","flat"],"mappings":"AAIA,SAASA,MAAT,QAAuB,QAAvB;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA,OAAO,MAAMC,YAAY,GAAG,CAC1BC,SAD0B,EAE1BC,IAF0B,EAG1BC,SAH0B,EAI1BC,kBAJ0B,EAK1BC,MAL0B,EAM1BC,OAN0B,EAO1BC,UAP0B,KAS1B,IAAIR,aAAJ,CACEE,SADF,EAEEA,SAAS,CAACD,YAAV,CACEF,MAAM,CAACI,IAAD,CADR,EAEEC,SAAS,CAACK,GAAV,CAAc;AAAA,MAAC;AAAEC,IAAAA,CAAF;AAAKC,IAAAA;AAAL,GAAD;AAAA,SAAc,CAACD,CAAD,EAAIC,CAAJ,CAAd;AAAA,CAAd,EAAoCC,IAApC,EAFF,EAGE,CAACP,kBAAkB,IAAI,EAAvB,EAA2BI,GAA3B,CAA+B;AAAA,MAAC;AAAEC,IAAAA,CAAF;AAAKC,IAAAA;AAAL,GAAD;AAAA,SAAc,CAACD,CAAD,EAAIC,CAAJ,CAAd;AAAA,CAA/B,EAAqDC,IAArD,EAHF,EAIEN,MAJF,EAKEC,OALF,EAMEC,UANF,CAFF,CATK","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkColor, SkPoint, VertexMode } from \"../types\";\n\nimport { ckEnum } from \"./Host\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\n\nexport const MakeVertices = (\n CanvasKit: CanvasKit,\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n) =>\n new JsiSkVertices(\n CanvasKit,\n CanvasKit.MakeVertices(\n ckEnum(mode),\n positions.map(({ x, y }) => [x, y]).flat(),\n (textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),\n colors,\n indices,\n isVolatile\n )\n );\n"]}
1
+ {"version":3,"sources":["JsiSkVerticesFactory.ts"],"names":["ckEnum","JsiSkVertices","concat","totalLength","arrays","arr","length","result","Float32Array","offset","set","MakeVertices","CanvasKit","mode","positions","textureCoordinates","colors","indices","isVolatile","map","x","y","flat","reduce","a","c"],"mappings":"AAIA,SAASA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IC,CAAJ,KAAUvB,MAAM,CAACsB,CAAD,EAAIC,CAAJ,CAA9B,CAJnB,EAKER,OALF,EAMEC,UANF,CAFF,CATK","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkColor, SkPoint, VertexMode } from \"../types\";\n\nimport { ckEnum } from \"./Host\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\n\nconst concat = (...arrays: Float32Array[]) => {\n let totalLength = 0;\n for (const arr of arrays) {\n totalLength += arr.length;\n }\n const result = new Float32Array(totalLength);\n let offset = 0;\n for (const arr of arrays) {\n result.set(arr, offset);\n offset += arr.length;\n }\n return result;\n};\n\nexport const MakeVertices = (\n CanvasKit: CanvasKit,\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n) =>\n new JsiSkVertices(\n CanvasKit,\n CanvasKit.MakeVertices(\n ckEnum(mode),\n positions.map(({ x, y }) => [x, y]).flat(),\n (textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),\n !colors ? null : colors.reduce((a, c) => concat(a, c)),\n indices,\n isVolatile\n )\n );\n"]}
@@ -15,7 +15,7 @@ import { JsiSkColorFilterFactory } from "./JsiSkColorFilterFactory";
15
15
  import { JsiSkTypefaceFactory } from "./JsiSkTypefaceFactory";
16
16
  import { JsiSkMaskFilterFactory } from "./JsiSkMaskFilterFactory";
17
17
  import { JsiSkRuntimeEffectFactory } from "./JsiSkRuntimeEffectFactory";
18
- import { JsiSkImageFilterFactory } from "./JsiImageFilterFactory";
18
+ import { JsiSkImageFilterFactory } from "./JsiSkImageFilterFactory";
19
19
  import { JsiSkShaderFactory } from "./JsiSkShaderFactory";
20
20
  import { JsiSkPathEffectFactory } from "./JsiSkPathEffectFactory";
21
21
  import { JsiSkDataFactory } from "./JsiSkDataFactory";
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkia.ts"],"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","toValue","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFontMgrFactory","JsiSkFont","MakeVertices","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","Paint","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","FontMgr","XYWHRect","width","height","Surface"],"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,OAAT,QAAwB,QAAxB;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,yBAAxC;AACA,SAASC,kBAAT,Q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sC,EAAAA,MAAM,EAAE,IAAIhD,kBAAJ,CAAuBU,SAAvB,CA7C+C;AA8CvDuC,EAAAA,UAAU,EAAE,IAAIhD,sBAAJ,CAA2BS,SAA3B,CA9C2C;AA+CvDF,EAAAA,YAAY,EAAEA,YAAY,CAAC0C,IAAb,CAAkB,IAAlB,EAAwBxC,SAAxB,CA/CyC;AAgDvDyC,EAAAA,IAAI,EAAE,IAAIjD,gBAAJ,CAAqBQ,SAArB,CAhDiD;AAiDvD0C,EAAAA,KAAK,EAAE,IAAIjD,iBAAJ,CAAsBO,SAAtB,CAjDgD;AAkDvD2C,EAAAA,GAAG,EAAE,IAAIjD,eAAJ,CAAoBM,SAApB,CAlDkD;AAmDvD4C,EAAAA,QAAQ,EAAE,IAAIjD,oBAAJ,CAAyBK,SAAzB,CAnD6C;AAoDvD6C,EAAAA,OAAO,EAAE,IAAIjD,mBAAJ,CAAwBI,SAAxB,CApD8C;AAqDvD8C,EAAAA,QAAQ,EAAE,CAAC5C,CAAD,EAAYC,CAAZ,EAAuB4C,KAAvB,EAAsCC,MAAtC,KAAyD;AACjE,WAAO,IAAI1E,SAAJ,CAAc0B,SAAd,EAAyBA,SAAS,CAAC8C,QAAV,CAAmB5C,CAAnB,EAAsBC,CAAtB,EAAyB4C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;AACD,GAvDsD;AAwDvDC,EAAAA,OAAO,EAAE,IAAIzE,mBAAJ,CAAwBwB,SAAxB;AAxD8C,CAAjC,CAAjB","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 { toValue } from \"./Host\";\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 \"./JsiImageFilterFactory\";\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 { JsiSkFontMgrFactory } from \"./JsiSkFontMgrFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\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, CanvasKit.RRectXY(toValue(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(toValue(path), forceClosed, resScale)\n ),\n Paint: () => new JsiSkPaint(CanvasKit, new CanvasKit.Paint()),\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: 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 : toValue(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 FontMgr: new JsiSkFontMgrFactory(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"]}
1
+ {"version":3,"sources":["JsiSkia.ts"],"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","toValue","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFontMgrFactory","JsiSkFont","MakeVertices","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","Paint","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","FontMgr","XYWHRect","width","height","Surface"],"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,OAAT,QAAwB,QAAxB;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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AAAA,MAAM,EAAE,IAAIhD,kBAAJ,CAAuBU,SAAvB,CA7C+C;AA8CvDuC,EAAAA,UAAU,EAAE,IAAIhD,sBAAJ,CAA2BS,SAA3B,CA9C2C;AA+CvDF,EAAAA,YAAY,EAAEA,YAAY,CAAC0C,IAAb,CAAkB,IAAlB,EAAwBxC,SAAxB,CA/CyC;AAgDvDyC,EAAAA,IAAI,EAAE,IAAIjD,gBAAJ,CAAqBQ,SAArB,CAhDiD;AAiDvD0C,EAAAA,KAAK,EAAE,IAAIjD,iBAAJ,CAAsBO,SAAtB,CAjDgD;AAkDvD2C,EAAAA,GAAG,EAAE,IAAIjD,eAAJ,CAAoBM,SAApB,CAlDkD;AAmDvD4C,EAAAA,QAAQ,EAAE,IAAIjD,oBAAJ,CAAyBK,SAAzB,CAnD6C;AAoDvD6C,EAAAA,OAAO,EAAE,IAAIjD,mBAAJ,CAAwBI,SAAxB,CApD8C;AAqDvD8C,EAAAA,QAAQ,EAAE,CAAC5C,CAAD,EAAYC,CAAZ,EAAuB4C,KAAvB,EAAsCC,MAAtC,KAAyD;AACjE,WAAO,IAAI1E,SAAJ,CAAc0B,SAAd,EAAyBA,SAAS,CAAC8C,QAAV,CAAmB5C,CAAnB,EAAsBC,CAAtB,EAAyB4C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;AACD,GAvDsD;AAwDvDC,EAAAA,OAAO,EAAE,IAAIzE,mBAAJ,CAAwBwB,SAAxB;AAxD8C,CAAjC,CAAjB","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 { toValue } from \"./Host\";\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 { JsiSkFontMgrFactory } from \"./JsiSkFontMgrFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\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, CanvasKit.RRectXY(toValue(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(toValue(path), forceClosed, resScale)\n ),\n Paint: () => new JsiSkPaint(CanvasKit, new CanvasKit.Paint()),\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: 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 : toValue(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 FontMgr: new JsiSkFontMgrFactory(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"]}
@@ -187,15 +187,15 @@ export class SkiaView extends React.Component {
187
187
  } = this.props;
188
188
  return /*#__PURE__*/React.createElement(View, _extends({}, viewProps, {
189
189
  onLayout: this.onLayout.bind(this)
190
- }), this.state.width > -1 ? /*#__PURE__*/React.createElement("canvas", {
190
+ }), /*#__PURE__*/React.createElement("canvas", {
191
191
  ref: this._canvasRef,
192
- width: `${this.state.width}px`,
193
- height: `${this.state.height}px`,
192
+ width: this.state.width,
193
+ height: this.state.height,
194
194
  onPointerDown: this.handleTouchStart.bind(this),
195
195
  onPointerMove: this.handleTouchMove.bind(this),
196
196
  onPointerUp: this.handleTouchEnd.bind(this),
197
197
  onPointerCancel: this.handleTouchCancel.bind(this)
198
- }) : null);
198
+ }));
199
199
  }
200
200
 
201
201
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["SkiaView.web.tsx"],"names":["React","View","JsiSkSurface","TouchType","SkiaView","Component","constructor","props","createRef","state","width","height","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","setState","nativeEvent","layout","_canvasRef","current","_surface","global","CanvasKit","MakeCanvasSurface","_canvas","getCanvas","requestRedraw","redraw","componentDidMount","componentWillUnmount","_unmounted","makeImageSnapshot","rect","_redrawRequests","onDraw","touches","_touches","info","timestamp","Date","now","ref","flush","requestAnimationFrame","bind","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","handleTouchStart","Start","handleTouchMove","Active","handleTouchEnd","Cancelled","handleTouchCancel","End","render","debug","viewProps"],"mappings":";;;;AAAA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,IAAT,QAAqB,cAArB;AAIA,SAASC,YAAT,QAA6B,0BAA7B;AAGA,SAASC,SAAT,QAA0B,SAA1B;AAEA,OAAO,MAAMC,QAAN,SAAuBJ,KAAK,CAACK,SAA7B,CAGL;AACAC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAAA;;AAChC,UAAMA,KAAN;;AADgC,sCAMM,IANN;;AAAA,8CAOY,EAPZ;;AAAA,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cAAc,CAACxD,GAAD,EAAoB;AAChC,SAAKqC,gBAAL,CAAsBrC,GAAtB,EAA2BhB,SAAS,CAACyE,SAArC;AACD;;AAEDC,EAAAA,iBAAiB,CAAC1D,GAAD,EAAoB;AACnC,SAAKqC,gBAAL,CAAsBrC,GAAtB,EAA2BhB,SAAS,CAAC2E,GAArC;AACD;;AAEDC,EAAAA,MAAM,GAAG;AACP,UAAM;AAAElE,MAAAA,IAAF;AAAQmE,MAAAA,KAAK,GAAG,KAAhB;AAAuB,SAAGC;AAA1B,QAAwC,KAAK1E,KAAnD;AACA,wBACE,oBAAC,IAAD,eAAU0E,SAAV;AAAqB,MAAA,QAAQ,EAAE,KAAK/D,QAAL,CAAc+B,IAAd,CAAmB,IAAnB;AAA/B,QACG,KAAKxC,KAAL,CAAWC,KAAX,GAAmB,CAAC,CAApB,gBACC;AACE,MAAA,GAAG,EAAE,KAAKa,UADZ;AAEE,MAAA,KAAK,EAAG,GAAE,KAAKd,KAAL,CAAWC,KAAM,IAF7B;AAGE,MAAA,MAAM,EAAG,GAAE,KAAKD,KAAL,CAAWE,MAAO,IAH/B;AAIE,MAAA,aAAa,EAAE,KAAK4D,gBAAL,CAAsBtB,IAAtB,CAA2B,IAA3B,CAJjB;AAKE,MAAA,aAAa,EAAE,KAAKwB,eAAL,CAAqBxB,IAArB,CAA0B,IAA1B,CALjB;AAME,MAAA,WAAW,EAAE,KAAK0B,cAAL,CAAoB1B,IAApB,CAAyB,IAAzB,CANf;AAOE,MAAA,eAAe,EAAE,KAAK4B,iBAAL,CAAuB5B,IAAvB,CAA4B,IAA5B;AAPnB,MADD,GAUG,IAXN,CADF;AAeD;;AA9KD","sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport { View } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\nimport type { DrawingInfo, DrawMode, SkiaViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nexport class SkiaView extends React.Component<\n SkiaViewProps,\n { width: number; height: number }\n> {\n constructor(props: SkiaViewProps) {\n super(props);\n this.state = { width: -1, height: -1 };\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef: React.RefObject<HTMLCanvasElement> = React.createRef();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private _unmounted = false;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayout(evt: LayoutChangeEvent) {\n this.setState({\n width: evt.nativeEvent.layout.width,\n height: evt.nativeEvent.layout.height,\n });\n // Reset canvas / surface on layout change\n if (this._canvasRef.current) {\n // Create surface\n this._surface = new JsiSkSurface(\n global.CanvasKit,\n global.CanvasKit.MakeCanvasSurface(this._canvasRef.current)!\n );\n // Get canvas and repaint\n if (this._surface) {\n this._canvas = this._surface.getCanvas();\n this.requestRedraw();\n this.redraw();\n }\n }\n }\n\n componentDidMount() {\n // Start render loop\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n this._surface = null;\n this._canvas = null;\n this._unmounted = true;\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private redraw() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (\n this._canvas &&\n this.props.onDraw &&\n this.state.height !== -1 &&\n this.state.width !== -1\n ) {\n const touches = [...this._touches];\n this._touches = [];\n const info: DrawingInfo = {\n height: this.state.height,\n width: this.state.width,\n timestamp: Date.now(),\n touches: [touches],\n };\n this.props.onDraw && this.props.onDraw(this._canvas!, info);\n this._surface?.ref.flush();\n }\n }\n // Always request a new redraw as long as we're not unmounted\n if (!this._unmounted) {\n requestAnimationFrame(this.redraw.bind(this));\n }\n }\n\n public requestRedraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.redraw();\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(_values: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.requestRedraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.requestRedraw();\n }\n\n handleTouchStart(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Start);\n }\n\n handleTouchMove(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Active);\n }\n\n handleTouchEnd(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Cancelled);\n }\n\n handleTouchCancel(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.End);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <View {...viewProps} onLayout={this.onLayout.bind(this)}>\n {this.state.width > -1 ? (\n <canvas\n ref={this._canvasRef}\n width={`${this.state.width}px`}\n height={`${this.state.height}px`}\n onPointerDown={this.handleTouchStart.bind(this)}\n onPointerMove={this.handleTouchMove.bind(this)}\n onPointerUp={this.handleTouchEnd.bind(this)}\n onPointerCancel={this.handleTouchCancel.bind(this)}\n />\n ) : null}\n </View>\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["SkiaView.web.tsx"],"names":["React","View","JsiSkSurface","TouchType","SkiaView","Component","constructor","props","createRef","state","width","height","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","setState","nativeEvent","layout","_canvasRef","current","_surface","global","CanvasKit","MakeCanvasSurface","_canvas","getCanvas","requestRedraw","redraw","componentDidMount","componentWillUnmount","_unmounted","makeImageSnapshot","rect","_redrawRequests","onDraw","touches","_touches","info","timestamp","Date","now","ref","flush","requestAnimationFrame","bind","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","handleTouchStart","Start","handleTouchMove","Active","handleTouchEnd","Cancelled","handleTouchCancel","End","render","debug","viewProps"],"mappings":";;;;AAAA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,IAAT,QAAqB,cAArB;AAIA,SAASC,YAAT,QAA6B,0BAA7B;AAGA,SAASC,SAAT,QAA0B,SAA1B;AAEA,OAAO,MAAMC,QAAN,SAAuBJ,KAAK,CAACK,SAA7B,CAGL;AACAC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAAA;;AAChC,UAAMA,KAAN;;AADgC,sCAMM,IANN;;AAAA,8CAOY,EAPZ;;AAAA,sCAQG,EARH;;AAAA,qCASC,IATD;;AAAA,qDAUuBP,KAAK,CAACQ,SAAN,EAVvB;;AAAA;;AAAA,6CAYR,CAZQ;;AAAA,wCAab,KAba;;AAEhC,SAAKC,KAAL,GAAa;AAAEC,MAAAA,KAAK,EAAE,CAAC,CAAV;AAAaC,MAAAA,MAAM,EAAE,CAAC;AAAtB,KAAb;AACA,S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,GAAG;AACP,UAAM;AAAElE,MAAAA,IAAF;AAAQmE,MAAAA,KAAK,GAAG,KAAhB;AAAuB,SAAGC;AAA1B,QAAwC,KAAK1E,KAAnD;AACA,wBACE,oBAAC,IAAD,eAAU0E,SAAV;AAAqB,MAAA,QAAQ,EAAE,KAAK/D,QAAL,CAAc+B,IAAd,CAAmB,IAAnB;AAA/B,qBACE;AACE,MAAA,GAAG,EAAE,KAAK1B,UADZ;AAEE,MAAA,KAAK,EAAE,KAAKd,KAAL,CAAWC,KAFpB;AAGE,MAAA,MAAM,EAAE,KAAKD,KAAL,CAAWE,MAHrB;AAIE,MAAA,aAAa,EAAE,KAAK4D,gBAAL,CAAsBtB,IAAtB,CAA2B,IAA3B,CAJjB;AAKE,MAAA,aAAa,EAAE,KAAKwB,eAAL,CAAqBxB,IAArB,CAA0B,IAA1B,CALjB;AAME,MAAA,WAAW,EAAE,KAAK0B,cAAL,CAAoB1B,IAApB,CAAyB,IAAzB,CANf;AAOE,MAAA,eAAe,EAAE,KAAK4B,iBAAL,CAAuB5B,IAAvB,CAA4B,IAA5B;AAPnB,MADF,CADF;AAaD;;AA5KD","sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport { View } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\nimport type { DrawingInfo, DrawMode, SkiaViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nexport class SkiaView extends React.Component<\n SkiaViewProps,\n { width: number; height: number }\n> {\n constructor(props: SkiaViewProps) {\n super(props);\n this.state = { width: -1, height: -1 };\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef: React.RefObject<HTMLCanvasElement> = React.createRef();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private _unmounted = false;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayout(evt: LayoutChangeEvent) {\n this.setState({\n width: evt.nativeEvent.layout.width,\n height: evt.nativeEvent.layout.height,\n });\n // Reset canvas / surface on layout change\n if (this._canvasRef.current) {\n // Create surface\n this._surface = new JsiSkSurface(\n global.CanvasKit,\n global.CanvasKit.MakeCanvasSurface(this._canvasRef.current)!\n );\n // Get canvas and repaint\n if (this._surface) {\n this._canvas = this._surface.getCanvas();\n this.requestRedraw();\n this.redraw();\n }\n }\n }\n\n componentDidMount() {\n // Start render loop\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n this._surface = null;\n this._canvas = null;\n this._unmounted = true;\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private redraw() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (\n this._canvas &&\n this.props.onDraw &&\n this.state.height !== -1 &&\n this.state.width !== -1\n ) {\n const touches = [...this._touches];\n this._touches = [];\n const info: DrawingInfo = {\n height: this.state.height,\n width: this.state.width,\n timestamp: Date.now(),\n touches: [touches],\n };\n this.props.onDraw && this.props.onDraw(this._canvas!, info);\n this._surface?.ref.flush();\n }\n }\n // Always request a new redraw as long as we're not unmounted\n if (!this._unmounted) {\n requestAnimationFrame(this.redraw.bind(this));\n }\n }\n\n public requestRedraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.redraw();\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(_values: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.requestRedraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.requestRedraw();\n }\n\n handleTouchStart(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Start);\n }\n\n handleTouchMove(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Active);\n }\n\n handleTouchEnd(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Cancelled);\n }\n\n handleTouchCancel(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.End);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <View {...viewProps} onLayout={this.onLayout.bind(this)}>\n <canvas\n ref={this._canvasRef}\n width={this.state.width}\n height={this.state.height}\n onPointerDown={this.handleTouchStart.bind(this)}\n onPointerMove={this.handleTouchMove.bind(this)}\n onPointerUp={this.handleTouchEnd.bind(this)}\n onPointerCancel={this.handleTouchCancel.bind(this)}\n />\n </View>\n );\n }\n}\n"]}
@@ -1,4 +1,6 @@
1
- import CanvasKitInit from "canvaskit-wasm";
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-expect-error
3
+ import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
2
4
  export const LoadSkia = async () => {
3
5
  const CanvasKit = await CanvasKitInit(); // The CanvasKit API is stored on the global object and used
4
6
  // to create the JsiSKApi in the Skia.web.ts file.
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["CanvasKitInit","LoadSkia","CanvasKit","global"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,gBAA1B;AAOA,OAAO,MAAMC,QAAQ,GAAG,YAAY;AAClC,QAAMC,SAAS,GAAG,MAAMF,aAAa,EAArC,CADkC,CAElC;AACA;;AACAG,EAAAA,MAAM,CAACD,SAAP,GAAmBA,SAAnB;AACD,CALM","sourcesContent":["import CanvasKitInit from \"canvaskit-wasm\";\nimport type { CanvasKit as CanvasKitType } from \"canvaskit-wasm\";\n\ndeclare global {\n var CanvasKit: CanvasKitType;\n}\n\nexport const LoadSkia = async () => {\n const CanvasKit = await CanvasKitInit();\n // The CanvasKit API is stored on the global object and used\n // to create the JsiSKApi in the Skia.web.ts file.\n global.CanvasKit = CanvasKit;\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["CanvasKitInit","LoadSkia","CanvasKit","global"],"mappings":"AAAA;AACA;AACA,OAAOA,aAAP,MAA0B,mCAA1B;AAOA,OAAO,MAAMC,QAAQ,GAAG,YAAY;AAClC,QAAMC,SAAS,GAAG,MAAMF,aAAa,EAArC,CADkC,CAElC;AACA;;AACAG,EAAAA,MAAM,CAACD,SAAP,GAAmBA,SAAnB;AACD,CALM","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type { CanvasKit as CanvasKitType } from \"canvaskit-wasm\";\n\ndeclare global {\n var CanvasKit: CanvasKitType;\n}\n\nexport const LoadSkia = async () => {\n const CanvasKit = await CanvasKitInit();\n // The CanvasKit API is stored on the global object and used\n // to create the JsiSKApi in the Skia.web.ts file.\n global.CanvasKit = CanvasKit;\n};\n"]}
@@ -3,8 +3,8 @@ import type { SkJSIInstance } from "../JsiInstance";
3
3
  import type { TileMode } from "../ImageFilter";
4
4
  import type { SkShader } from "../Shader";
5
5
  export declare enum FilterMode {
6
- Linear = 0,
7
- Nearest = 1
6
+ Nearest = 0,
7
+ Linear = 1
8
8
  }
9
9
  export declare enum MipmapMode {
10
10
  None = 0,
@@ -12,9 +12,9 @@ export declare enum MipmapMode {
12
12
  Linear = 2
13
13
  }
14
14
  export declare enum ImageFormat {
15
- PNG = 0,
16
- JPEG = 1,
17
- WEBP = 2
15
+ JPEG = 3,
16
+ PNG = 4,
17
+ WEBP = 6
18
18
  }
19
19
  export interface SkImage extends SkJSIInstance<"Image"> {
20
20
  /**
@@ -16,9 +16,9 @@ export declare enum StrokeCap {
16
16
  Square = 2
17
17
  }
18
18
  export declare enum StrokeJoin {
19
- Bevel = 0,
20
- Miter = 1,
21
- Round = 2
19
+ Miter = 0,
20
+ Round = 1,
21
+ Bevel = 2
22
22
  }
23
23
  export declare const isPaint: (obj: SkJSIInstance<string> | null) => obj is SkPaint;
24
24
  export interface SkPaint extends SkJSIInstance<"Paint"> {
@@ -38,8 +38,7 @@ export declare enum PathVerb {
38
38
  Quad = 2,
39
39
  Conic = 3,
40
40
  Cubic = 4,
41
- Close = 5,
42
- Done = 6
41
+ Close = 5
43
42
  }
44
43
  export declare type PathCommand = number[];
45
44
  export declare const isPath: (obj: SkJSIInstance<string> | null) => obj is SkPath;
@@ -6,6 +6,7 @@ export interface SkSLUniform {
6
6
  rows: number;
7
7
  /** The index into the uniforms array that this uniform begins. */
8
8
  slot: number;
9
+ isInteger: boolean;
9
10
  }
10
11
  export interface SkRuntimeShaderBuilder extends SkJSIInstance<"RuntimeShaderBuilder"> {
11
12
  setUniform(name: string, value: readonly number[]): void;
@@ -5,8 +5,8 @@ export declare class JsiSkImage extends HostObject<Image, "Image"> implements Sk
5
5
  constructor(CanvasKit: CanvasKit, ref: Image);
6
6
  height(): number;
7
7
  width(): number;
8
- makeShaderOptions(_tx: TileMode, _ty: TileMode, _fm: FilterMode, _mm: MipmapMode, _localMatrix?: SkMatrix): SkShader;
9
- makeShaderCubic(_tx: TileMode, _ty: TileMode, _B: number, _C: number, _localMatrix?: SkMatrix): SkShader;
8
+ makeShaderOptions(tx: TileMode, ty: TileMode, fm: FilterMode, mm: MipmapMode, localMatrix?: SkMatrix): SkShader;
9
+ makeShaderCubic(tx: TileMode, ty: TileMode, B: number, C: number, localMatrix?: SkMatrix): SkShader;
10
10
  encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;
11
- encodeToBase64(_fmt?: ImageFormat, _quality?: number): string;
11
+ encodeToBase64(fmt?: ImageFormat, quality?: number): string;
12
12
  }
@@ -1,5 +1,5 @@
1
1
  import type { CanvasKit, Paint } from "canvaskit-wasm";
2
- import type { BlendMode, SkColor, SkColorFilter, SkImageFilter, SkPaint, SkShader, StrokeCap, StrokeJoin, PaintStyle, SkMaskFilter, SkPathEffect } from "../types";
2
+ import type { StrokeJoin, BlendMode, SkColor, SkColorFilter, SkImageFilter, SkPaint, SkShader, StrokeCap, PaintStyle, SkMaskFilter, SkPathEffect } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  export declare class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
5
5
  constructor(CanvasKit: CanvasKit, ref: Paint);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "React Native Skia",
7
- "version": "0.1.132",
7
+ "version": "0.1.133",
8
8
  "description": "High-performance React Native Graphics using Skia",
9
9
  "main": "lib/module/index.js",
10
10
  "files": [
@@ -4,8 +4,8 @@ import type { TileMode } from "../ImageFilter";
4
4
  import type { SkShader } from "../Shader";
5
5
 
6
6
  export enum FilterMode {
7
- Linear,
8
7
  Nearest,
8
+ Linear,
9
9
  }
10
10
 
11
11
  export enum MipmapMode {
@@ -15,9 +15,9 @@ export enum MipmapMode {
15
15
  }
16
16
 
17
17
  export enum ImageFormat {
18
- PNG,
19
- JPEG,
20
- WEBP,
18
+ JPEG = 3,
19
+ PNG = 4,
20
+ WEBP = 6,
21
21
  }
22
22
 
23
23
  export interface SkImage extends SkJSIInstance<"Image"> {
@@ -20,9 +20,9 @@ export enum StrokeCap {
20
20
  }
21
21
 
22
22
  export enum StrokeJoin {
23
- Bevel,
24
23
  Miter,
25
24
  Round,
25
+ Bevel,
26
26
  }
27
27
 
28
28
  export const isPaint = (obj: SkJSIInstance<string> | null): obj is SkPaint =>
@@ -44,7 +44,6 @@ export enum PathVerb {
44
44
  Conic,
45
45
  Cubic,
46
46
  Close,
47
- Done,
48
47
  }
49
48
 
50
49
  export type PathCommand = number[];
@@ -7,6 +7,7 @@ export interface SkSLUniform {
7
7
  rows: number;
8
8
  /** The index into the uniforms array that this uniform begins. */
9
9
  slot: number;
10
+ isInteger: boolean;
10
11
  }
11
12
 
12
13
  export interface SkRuntimeShaderBuilder
@@ -40,11 +40,9 @@ export const processUniforms = (
40
40
  if (value === undefined) {
41
41
  throw new Error(`No value specified for uniform ${name}`);
42
42
  }
43
- let result: number | readonly number[];
44
- if (Array.isArray(value)) {
45
- result = value.flatMap(processValue);
46
- }
47
- result = processValue(value as UniformValue);
43
+ const result = Array.isArray(value)
44
+ ? value.flatMap(processValue)
45
+ : processValue(value as UniformValue);
48
46
  builder?.setUniform(name, typeof result === "number" ? [result] : result);
49
47
  return result;
50
48
  });
@@ -1,4 +1,4 @@
1
- import type { Canvas, Image, Paint, CanvasKit } from "canvaskit-wasm";
1
+ import type { Canvas, Image, CanvasKit, Paint } from "canvaskit-wasm";
2
2
 
3
3
  import type {
4
4
  BlendMode,
@@ -250,7 +250,7 @@ export class JsiSkCanvas
250
250
  ) {
251
251
  this.ref.drawGlyphs(
252
252
  glyphs,
253
- toValue(positions),
253
+ positions.map((p) => [p.x, p.y]).flat(),
254
254
  x,
255
255
  y,
256
256
  toValue(font),
@@ -9,10 +9,6 @@ export class JsiSkFontMgr
9
9
  implements SkFontMgr
10
10
  {
11
11
  constructor(CanvasKit: CanvasKit) {
12
- console.warn(
13
- // eslint-disable-next-line max-len
14
- "Using system fonts is deprecated. Please use the font property instead: https://shopify.github.io/react-native-skia/docs/text/fonts"
15
- );
16
12
  super(CanvasKit, null, "FontMgr");
17
13
  }
18
14
 
@@ -1,3 +1,4 @@
1
+ /*global btoa, atob*/
1
2
  import type { CanvasKit, Image } from "canvaskit-wasm";
2
3
 
3
4
  import type {
@@ -10,7 +11,8 @@ import type {
10
11
  TileMode,
11
12
  } from "../types";
12
13
 
13
- import { ckEnum, HostObject } from "./Host";
14
+ import { ckEnum, HostObject, toValue } from "./Host";
15
+ import { JsiSkShader } from "./JsiSkShader";
14
16
 
15
17
  export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
16
18
  constructor(CanvasKit: CanvasKit, ref: Image) {
@@ -26,26 +28,44 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
26
28
  }
27
29
 
28
30
  makeShaderOptions(
29
- _tx: TileMode,
30
- _ty: TileMode,
31
- _fm: FilterMode,
32
- _mm: MipmapMode,
33
- _localMatrix?: SkMatrix
31
+ tx: TileMode,
32
+ ty: TileMode,
33
+ fm: FilterMode,
34
+ mm: MipmapMode,
35
+ localMatrix?: SkMatrix
34
36
  ): SkShader {
35
- throw new Error("Not implemented yet");
37
+ return new JsiSkShader(
38
+ this.CanvasKit,
39
+ this.ref.makeShaderOptions(
40
+ ckEnum(tx),
41
+ ckEnum(ty),
42
+ ckEnum(fm),
43
+ ckEnum(mm),
44
+ localMatrix ? toValue(localMatrix) : undefined
45
+ )
46
+ );
36
47
  }
37
48
 
38
49
  makeShaderCubic(
39
- _tx: TileMode,
40
- _ty: TileMode,
41
- _B: number,
42
- _C: number,
43
- _localMatrix?: SkMatrix
50
+ tx: TileMode,
51
+ ty: TileMode,
52
+ B: number,
53
+ C: number,
54
+ localMatrix?: SkMatrix
44
55
  ): SkShader {
45
- throw new Error("Not implemented yet");
56
+ return new JsiSkShader(
57
+ this.CanvasKit,
58
+ this.ref.makeShaderCubic(
59
+ ckEnum(tx),
60
+ ckEnum(ty),
61
+ B,
62
+ C,
63
+ localMatrix ? toValue(localMatrix) : undefined
64
+ )
65
+ );
46
66
  }
47
67
 
48
- encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array {
68
+ encodeToBytes(fmt?: ImageFormat, quality?: number) {
49
69
  let result: Uint8Array | null;
50
70
  if (fmt && quality) {
51
71
  result = this.ref.encodeToBytes(ckEnum(fmt), quality);
@@ -60,7 +80,8 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
60
80
  return result;
61
81
  }
62
82
 
63
- encodeToBase64(_fmt?: ImageFormat, _quality?: number): string {
64
- throw new Error("Not implemented yet");
83
+ encodeToBase64(fmt?: ImageFormat, quality?: number) {
84
+ const bytes = this.encodeToBytes(fmt, quality);
85
+ return btoa(String.fromCharCode(...bytes));
65
86
  }
66
87
  }
@@ -1,6 +1,7 @@
1
1
  import type { CanvasKit, Paint } from "canvaskit-wasm";
2
2
 
3
3
  import type {
4
+ StrokeJoin,
4
5
  BlendMode,
5
6
  SkColor,
6
7
  SkColorFilter,
@@ -8,7 +9,6 @@ import type {
8
9
  SkPaint,
9
10
  SkShader,
10
11
  StrokeCap,
11
- StrokeJoin,
12
12
  PaintStyle,
13
13
  SkMaskFilter,
14
14
  SkPathEffect,