@shopify/react-native-skia 0.1.227 → 0.1.228

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. package/cpp/api/JsiSkCanvas.h +2 -1
  2. package/cpp/api/JsiSkMatrix.h +27 -11
  3. package/cpp/api/JsiSkTypeface.h +1 -0
  4. package/cpp/rnskia/dom/props/MatrixProp.h +14 -3
  5. package/lib/commonjs/dom/types/Common.d.ts +2 -2
  6. package/lib/commonjs/dom/types/Common.js.map +1 -1
  7. package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -0
  8. package/lib/commonjs/external/reanimated/interpolators.js +16 -3
  9. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  10. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -1
  11. package/lib/commonjs/external/reanimated/moduleWrapper.js +9 -7
  12. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  13. package/lib/commonjs/skia/core/Vector.d.ts +0 -5
  14. package/lib/commonjs/skia/core/Vector.js +1 -17
  15. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  16. package/lib/commonjs/skia/types/Matrix.d.ts +2 -13
  17. package/lib/commonjs/skia/types/Matrix.js +1 -16
  18. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  19. package/lib/commonjs/skia/types/Matrix4.d.ts +51 -0
  20. package/lib/commonjs/skia/types/Matrix4.js +111 -12
  21. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  22. package/lib/commonjs/skia/web/Host.d.ts +2 -3
  23. package/lib/commonjs/skia/web/Host.js +4 -12
  24. package/lib/commonjs/skia/web/Host.js.map +1 -1
  25. package/lib/commonjs/skia/web/JsiSkCanvas.js +12 -12
  26. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  27. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  28. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  29. package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
  30. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  32. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  33. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  34. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  35. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
  36. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  37. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  38. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  39. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
  40. package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
  41. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  43. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
  45. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  46. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
  47. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  49. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  51. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  52. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  53. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  54. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
  55. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  56. package/lib/module/dom/types/Common.d.ts +2 -2
  57. package/lib/module/dom/types/Common.js.map +1 -1
  58. package/lib/module/external/reanimated/interpolators.d.ts +1 -0
  59. package/lib/module/external/reanimated/interpolators.js +14 -4
  60. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  61. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
  62. package/lib/module/external/reanimated/moduleWrapper.js +7 -6
  63. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  64. package/lib/module/skia/core/Vector.d.ts +0 -5
  65. package/lib/module/skia/core/Vector.js +0 -13
  66. package/lib/module/skia/core/Vector.js.map +1 -1
  67. package/lib/module/skia/types/Matrix.d.ts +2 -13
  68. package/lib/module/skia/types/Matrix.js +0 -14
  69. package/lib/module/skia/types/Matrix.js.map +1 -1
  70. package/lib/module/skia/types/Matrix4.d.ts +51 -0
  71. package/lib/module/skia/types/Matrix4.js +90 -16
  72. package/lib/module/skia/types/Matrix4.js.map +1 -1
  73. package/lib/module/skia/web/Host.d.ts +2 -3
  74. package/lib/module/skia/web/Host.js +2 -7
  75. package/lib/module/skia/web/Host.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkCanvas.js +13 -13
  77. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  78. package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
  79. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  80. package/lib/module/skia/web/JsiSkFont.js +3 -3
  81. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  82. package/lib/module/skia/web/JsiSkImage.js +7 -7
  83. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  84. package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
  85. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  86. package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
  87. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
  89. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  90. package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
  91. package/lib/module/skia/web/JsiSkMatrix.js +6 -1
  92. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  93. package/lib/module/skia/web/JsiSkPaint.js +4 -4
  94. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  95. package/lib/module/skia/web/JsiSkPath.js +5 -5
  96. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  97. package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
  98. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  99. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  100. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  101. package/lib/module/skia/web/JsiSkPicture.js +2 -2
  102. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  103. package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
  104. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  105. package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
  106. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  107. package/lib/typescript/src/dom/types/Common.d.ts +2 -2
  108. package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
  109. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
  110. package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
  111. package/lib/typescript/src/skia/types/Matrix.d.ts +2 -13
  112. package/lib/typescript/src/skia/types/Matrix4.d.ts +51 -0
  113. package/lib/typescript/src/skia/web/Host.d.ts +2 -3
  114. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
  115. package/package.json +2 -1
  116. package/src/dom/types/Common.ts +3 -1
  117. package/src/external/reanimated/interpolators.ts +20 -5
  118. package/src/external/reanimated/moduleWrapper.ts +6 -0
  119. package/src/skia/core/Vector.ts +0 -7
  120. package/src/skia/types/Matrix.ts +2 -13
  121. package/src/skia/types/Matrix4.ts +96 -18
  122. package/src/skia/web/Host.ts +4 -3
  123. package/src/skia/web/JsiSkCanvas.ts +22 -15
  124. package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
  125. package/src/skia/web/JsiSkFont.ts +3 -3
  126. package/src/skia/web/JsiSkImage.ts +14 -11
  127. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  128. package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
  129. package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
  130. package/src/skia/web/JsiSkMatrix.ts +12 -3
  131. package/src/skia/web/JsiSkPaint.ts +4 -4
  132. package/src/skia/web/JsiSkPath.ts +8 -5
  133. package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
  134. package/src/skia/web/JsiSkPathFactory.ts +2 -2
  135. package/src/skia/web/JsiSkPicture.ts +4 -4
  136. package/src/skia/web/JsiSkShaderFactory.ts +6 -6
  137. package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
@@ -1,9 +1,13 @@
1
1
  import type { CanvasKit, Matrix3x3 } from "canvaskit-wasm";
2
2
 
3
- import type { SkMatrix } from "../types";
3
+ import { toMatrix3, type Matrix3, type Matrix4, type SkMatrix } from "../types";
4
4
 
5
5
  import { HostObject } from "./Host";
6
6
 
7
+ const isMatrixHostObject = (
8
+ obj: SkMatrix | number[] | Matrix4 | Matrix3
9
+ ): obj is SkMatrix => !Array.isArray(obj);
10
+
7
11
  export class JsiSkMatrix
8
12
  extends HostObject<Matrix3x3, "Matrix">
9
13
  implements SkMatrix
@@ -24,9 +28,14 @@ export class JsiSkMatrix
24
28
  // Do nothing - the matrix is represenetd by a Float32Array
25
29
  };
26
30
 
27
- concat(matrix: SkMatrix | number[]) {
31
+ concat(matrix: SkMatrix | number[] | Matrix4 | Matrix3) {
28
32
  this.preMultiply(
29
- Array.isArray(matrix) ? matrix : JsiSkMatrix.fromValue(matrix)
33
+ // eslint-disable-next-line no-nested-ternary
34
+ isMatrixHostObject(matrix)
35
+ ? JsiSkMatrix.fromValue(matrix)
36
+ : matrix.length === 16
37
+ ? toMatrix3(matrix as Matrix4)
38
+ : [...matrix]
30
39
  );
31
40
  return this;
32
41
  }
@@ -14,7 +14,7 @@ import type {
14
14
  SkPathEffect,
15
15
  } from "../types";
16
16
 
17
- import { HostObject, ckEnum } from "./Host";
17
+ import { HostObject, getEnum } from "./Host";
18
18
  import { JsiSkColorFilter } from "./JsiSkColorFilter";
19
19
  import { JsiSkImageFilter } from "./JsiSkImageFilter";
20
20
  import { JsiSkMaskFilter } from "./JsiSkMaskFilter";
@@ -75,7 +75,7 @@ export class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
75
75
  }
76
76
 
77
77
  setBlendMode(blendMode: BlendMode) {
78
- this.ref.setBlendMode(ckEnum(blendMode));
78
+ this.ref.setBlendMode(getEnum(this.CanvasKit.BlendMode, blendMode));
79
79
  }
80
80
 
81
81
  setColor(color: SkColor) {
@@ -103,11 +103,11 @@ export class JsiSkPaint extends HostObject<Paint, "Paint"> implements SkPaint {
103
103
  }
104
104
 
105
105
  setStrokeCap(cap: StrokeCap) {
106
- this.ref.setStrokeCap(ckEnum(cap));
106
+ this.ref.setStrokeCap(getEnum(this.CanvasKit.StrokeCap, cap));
107
107
  }
108
108
 
109
109
  setStrokeJoin(join: StrokeJoin) {
110
- this.ref.setStrokeJoin(ckEnum(join));
110
+ this.ref.setStrokeJoin(getEnum(this.CanvasKit.StrokeJoin, join));
111
111
  }
112
112
 
113
113
  setStrokeMiter(limit: number) {
@@ -13,7 +13,7 @@ import type {
13
13
  StrokeOpts,
14
14
  } from "../types";
15
15
 
16
- import { ckEnum, HostObject, optEnum } from "./Host";
16
+ import { getEnum, HostObject, optEnum } from "./Host";
17
17
  import { JsiSkPoint } from "./JsiSkPoint";
18
18
  import { JsiSkRect } from "./JsiSkRect";
19
19
  import { JsiSkRRect } from "./JsiSkRRect";
@@ -149,7 +149,7 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
149
149
  }
150
150
 
151
151
  setFillType(fill: FillType) {
152
- this.ref.setFillType(ckEnum(fill));
152
+ this.ref.setFillType(getEnum(this.CanvasKit.FillType, fill));
153
153
  return this;
154
154
  }
155
155
 
@@ -167,8 +167,8 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
167
167
  // eslint-disable-next-line camelcase
168
168
  miter_limit: opts.width,
169
169
  precision: opts.width,
170
- join: optEnum(opts.join),
171
- cap: optEnum(opts.cap),
170
+ join: optEnum(this.CanvasKit.StrokeJoin, opts.join),
171
+ cap: optEnum(this.CanvasKit.StrokeCap, opts.cap),
172
172
  }
173
173
  );
174
174
  return result === null ? result : this;
@@ -315,7 +315,10 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
315
315
  }
316
316
 
317
317
  op(path: SkPath, op: PathOp) {
318
- return this.ref.op(JsiSkPath.fromValue(path), ckEnum(op));
318
+ return this.ref.op(
319
+ JsiSkPath.fromValue(path),
320
+ getEnum(this.CanvasKit.PathOp, op)
321
+ );
319
322
  }
320
323
 
321
324
  simplify() {
@@ -8,7 +8,7 @@ import type {
8
8
  SkPathEffect,
9
9
  } from "../types";
10
10
 
11
- import { ckEnum, Host, NotImplementedOnRNWeb } from "./Host";
11
+ import { getEnum, Host, NotImplementedOnRNWeb } from "./Host";
12
12
  import { JsiSkMatrix } from "./JsiSkMatrix";
13
13
  import { JsiSkPath } from "./JsiSkPath";
14
14
  import { JsiSkPathEffect } from "./JsiSkPathEffect";
@@ -69,7 +69,7 @@ export class JsiSkPathEffectFactory extends Host implements PathEffectFactory {
69
69
  JsiSkPath.fromValue(path),
70
70
  advance,
71
71
  phase,
72
- ckEnum(style)
72
+ getEnum(this.CanvasKit.Path1DEffect, style)
73
73
  );
74
74
  if (pe === null) {
75
75
  return null;
@@ -3,7 +3,7 @@ import type { CanvasKit } from "canvaskit-wasm";
3
3
  import type { PathCommand, PathOp, SkFont, SkPath } from "../types";
4
4
  import type { PathFactory } from "../types/Path/PathFactory";
5
5
 
6
- import { Host, ckEnum, NotImplementedOnRNWeb } from "./Host";
6
+ import { Host, getEnum, NotImplementedOnRNWeb } from "./Host";
7
7
  import { JsiSkPath } from "./JsiSkPath";
8
8
 
9
9
  export class JsiSkPathFactory extends Host implements PathFactory {
@@ -27,7 +27,7 @@ export class JsiSkPathFactory extends Host implements PathFactory {
27
27
  const path = this.CanvasKit.Path.MakeFromOp(
28
28
  JsiSkPath.fromValue(one),
29
29
  JsiSkPath.fromValue(two),
30
- ckEnum(op)
30
+ getEnum(this.CanvasKit.PathOp, op)
31
31
  );
32
32
  if (path === null) {
33
33
  return null;
@@ -9,7 +9,7 @@ import type {
9
9
  SkMatrix,
10
10
  } from "../types";
11
11
 
12
- import { HostObject, ckEnum } from "./Host";
12
+ import { HostObject, getEnum } from "./Host";
13
13
  import { JsiSkShader } from "./JsiSkShader";
14
14
  import { JsiSkMatrix } from "./JsiSkMatrix";
15
15
  import { JsiSkRect } from "./JsiSkRect";
@@ -36,9 +36,9 @@ export class JsiSkPicture
36
36
  return new JsiSkShader(
37
37
  this.CanvasKit,
38
38
  this.ref.makeShader(
39
- ckEnum(tmx),
40
- ckEnum(tmy),
41
- ckEnum(mode),
39
+ getEnum(this.CanvasKit.TileMode, tmx),
40
+ getEnum(this.CanvasKit.TileMode, tmy),
41
+ getEnum(this.CanvasKit.FilterMode, mode),
42
42
  localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined,
43
43
  tileRect ? JsiSkRect.fromValue(this.CanvasKit, tileRect) : undefined
44
44
  )
@@ -10,7 +10,7 @@ import type {
10
10
  } from "../types";
11
11
  import type { ShaderFactory } from "../types/Shader/ShaderFactory";
12
12
 
13
- import { Host, ckEnum } from "./Host";
13
+ import { Host, getEnum } from "./Host";
14
14
  import { JsiSkMatrix } from "./JsiSkMatrix";
15
15
  import { JsiSkPoint } from "./JsiSkPoint";
16
16
  import { JsiSkShader } from "./JsiSkShader";
@@ -36,7 +36,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
36
36
  JsiSkPoint.fromValue(end),
37
37
  colors,
38
38
  pos,
39
- ckEnum(mode),
39
+ getEnum(this.CanvasKit.TileMode, mode),
40
40
  localMatrix === undefined
41
41
  ? undefined
42
42
  : JsiSkMatrix.fromValue(localMatrix),
@@ -61,7 +61,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
61
61
  radius,
62
62
  colors,
63
63
  pos,
64
- ckEnum(mode),
64
+ getEnum(this.CanvasKit.TileMode, mode),
65
65
  localMatrix === undefined
66
66
  ? undefined
67
67
  : JsiSkMatrix.fromValue(localMatrix),
@@ -90,7 +90,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
90
90
  endRadius,
91
91
  colors,
92
92
  pos,
93
- ckEnum(mode),
93
+ getEnum(this.CanvasKit.TileMode, mode),
94
94
  localMatrix === undefined
95
95
  ? undefined
96
96
  : JsiSkMatrix.fromValue(localMatrix),
@@ -117,7 +117,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
117
117
  cy,
118
118
  colors,
119
119
  pos,
120
- ckEnum(mode),
120
+ getEnum(this.CanvasKit.TileMode, mode),
121
121
  localMatrix === undefined || localMatrix === null
122
122
  ? undefined
123
123
  : JsiSkMatrix.fromValue(localMatrix),
@@ -174,7 +174,7 @@ export class JsiSkShaderFactory extends Host implements ShaderFactory {
174
174
  return new JsiSkShader(
175
175
  this.CanvasKit,
176
176
  this.CanvasKit.Shader.MakeBlend(
177
- ckEnum(mode),
177
+ getEnum(this.CanvasKit.BlendMode, mode),
178
178
  JsiSkShader.fromValue(one),
179
179
  JsiSkShader.fromValue(two)
180
180
  )
@@ -2,8 +2,8 @@ import type { CanvasKit } from "canvaskit-wasm";
2
2
 
3
3
  import type { SkColor, SkPoint, VertexMode } from "../types";
4
4
 
5
- import { ckEnum } from "./Host";
6
5
  import { JsiSkVertices } from "./JsiSkVertices";
6
+ import { getEnum } from "./Host";
7
7
 
8
8
  const concat = (...arrays: Float32Array[]) => {
9
9
  let totalLength = 0;
@@ -31,7 +31,7 @@ export const MakeVertices = (
31
31
  new JsiSkVertices(
32
32
  CanvasKit,
33
33
  CanvasKit.MakeVertices(
34
- ckEnum(mode),
34
+ getEnum(CanvasKit.VertexMode, mode),
35
35
  positions.map(({ x, y }) => [x, y]).flat(),
36
36
  (textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),
37
37
  !colors ? null : colors.reduce((a, c) => concat(a, c)),