@shopify/react-native-skia 0.1.227 → 0.1.229

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) 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/renderer/Canvas.js +7 -13
  14. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  15. package/lib/commonjs/skia/core/Vector.d.ts +0 -5
  16. package/lib/commonjs/skia/core/Vector.js +1 -17
  17. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  18. package/lib/commonjs/skia/types/Canvas.d.ts +2 -2
  19. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  20. package/lib/commonjs/skia/types/Matrix.d.ts +3 -13
  21. package/lib/commonjs/skia/types/Matrix.js +1 -16
  22. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  23. package/lib/commonjs/skia/types/Matrix4.d.ts +60 -1
  24. package/lib/commonjs/skia/types/Matrix4.js +159 -14
  25. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  26. package/lib/commonjs/skia/types/Path/Path.d.ts +2 -2
  27. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  28. package/lib/commonjs/skia/web/Host.d.ts +2 -3
  29. package/lib/commonjs/skia/web/Host.js +4 -12
  30. package/lib/commonjs/skia/web/Host.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkCanvas.js +12 -12
  32. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  33. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  34. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  35. package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
  36. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  37. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  38. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  39. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  40. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  41. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
  42. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  43. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  44. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  45. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
  46. package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
  47. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  49. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
  51. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  52. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
  53. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  54. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  55. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  56. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  57. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  58. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  59. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  60. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
  61. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  62. package/lib/module/dom/types/Common.d.ts +2 -2
  63. package/lib/module/dom/types/Common.js.map +1 -1
  64. package/lib/module/external/reanimated/interpolators.d.ts +1 -0
  65. package/lib/module/external/reanimated/interpolators.js +14 -4
  66. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  67. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
  68. package/lib/module/external/reanimated/moduleWrapper.js +7 -6
  69. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  70. package/lib/module/renderer/Canvas.js +7 -12
  71. package/lib/module/renderer/Canvas.js.map +1 -1
  72. package/lib/module/skia/core/Vector.d.ts +0 -5
  73. package/lib/module/skia/core/Vector.js +0 -13
  74. package/lib/module/skia/core/Vector.js.map +1 -1
  75. package/lib/module/skia/types/Canvas.d.ts +2 -2
  76. package/lib/module/skia/types/Canvas.js.map +1 -1
  77. package/lib/module/skia/types/Matrix.d.ts +3 -13
  78. package/lib/module/skia/types/Matrix.js +0 -14
  79. package/lib/module/skia/types/Matrix.js.map +1 -1
  80. package/lib/module/skia/types/Matrix4.d.ts +60 -1
  81. package/lib/module/skia/types/Matrix4.js +132 -18
  82. package/lib/module/skia/types/Matrix4.js.map +1 -1
  83. package/lib/module/skia/types/Path/Path.d.ts +2 -2
  84. package/lib/module/skia/types/Path/Path.js.map +1 -1
  85. package/lib/module/skia/web/Host.d.ts +2 -3
  86. package/lib/module/skia/web/Host.js +2 -7
  87. package/lib/module/skia/web/Host.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkCanvas.js +13 -13
  89. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  90. package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
  91. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  92. package/lib/module/skia/web/JsiSkFont.js +3 -3
  93. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  94. package/lib/module/skia/web/JsiSkImage.js +7 -7
  95. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  96. package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
  97. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  98. package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
  99. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  100. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
  101. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  102. package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
  103. package/lib/module/skia/web/JsiSkMatrix.js +6 -1
  104. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  105. package/lib/module/skia/web/JsiSkPaint.js +4 -4
  106. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  107. package/lib/module/skia/web/JsiSkPath.js +5 -5
  108. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  109. package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
  110. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  111. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  112. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  113. package/lib/module/skia/web/JsiSkPicture.js +2 -2
  114. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  115. package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
  116. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  117. package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
  118. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  119. package/lib/typescript/src/dom/types/Common.d.ts +2 -2
  120. package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
  121. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
  122. package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
  123. package/lib/typescript/src/skia/types/Canvas.d.ts +2 -2
  124. package/lib/typescript/src/skia/types/Matrix.d.ts +3 -13
  125. package/lib/typescript/src/skia/types/Matrix4.d.ts +60 -1
  126. package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -2
  127. package/lib/typescript/src/skia/web/Host.d.ts +2 -3
  128. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
  129. package/package.json +2 -1
  130. package/src/dom/types/Common.ts +2 -2
  131. package/src/external/reanimated/interpolators.ts +20 -5
  132. package/src/external/reanimated/moduleWrapper.ts +6 -0
  133. package/src/renderer/Canvas.tsx +6 -13
  134. package/src/skia/core/Vector.ts +0 -7
  135. package/src/skia/types/Canvas.ts +2 -2
  136. package/src/skia/types/Matrix.ts +4 -13
  137. package/src/skia/types/Matrix4.ts +190 -81
  138. package/src/skia/types/Path/Path.ts +2 -2
  139. package/src/skia/web/Host.ts +4 -3
  140. package/src/skia/web/JsiSkCanvas.ts +22 -15
  141. package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
  142. package/src/skia/web/JsiSkFont.ts +3 -3
  143. package/src/skia/web/JsiSkImage.ts +14 -11
  144. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  145. package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
  146. package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
  147. package/src/skia/web/JsiSkMatrix.ts +12 -3
  148. package/src/skia/web/JsiSkPaint.ts +4 -4
  149. package/src/skia/web/JsiSkPath.ts +8 -5
  150. package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
  151. package/src/skia/web/JsiSkPathFactory.ts +2 -2
  152. package/src/skia/web/JsiSkPicture.ts +4 -4
  153. package/src/skia/web/JsiSkShaderFactory.ts +6 -6
  154. package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
@@ -37,6 +37,7 @@
37
37
  #pragma clang diagnostic pop
38
38
 
39
39
  namespace RNSkia {
40
+
40
41
  namespace jsi = facebook::jsi;
41
42
 
42
43
  class JsiSkCanvas : public JsiSkHostObject {
@@ -524,7 +525,7 @@ public:
524
525
  if (!_canvas->readPixels(*info, bfrPtr, bytesPerRow, srcX, srcY)) {
525
526
  return jsi::Value::null();
526
527
  }
527
- return std::move(dest);
528
+ return dest;
528
529
  }
529
530
 
530
531
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkCanvas, drawPaint),
@@ -27,17 +27,33 @@ public:
27
27
  static SkMatrix getMatrix(jsi::Runtime &runtime, const jsi::Value &value) {
28
28
  const auto &object = value.asObject(runtime);
29
29
  const auto &array = object.asArray(runtime);
30
- auto scaleX = array.getValueAtIndex(runtime, 0).asNumber();
31
- auto skewX = array.getValueAtIndex(runtime, 1).asNumber();
32
- auto transX = array.getValueAtIndex(runtime, 2).asNumber();
33
- auto skewY = array.getValueAtIndex(runtime, 3).asNumber();
34
- auto scaleY = array.getValueAtIndex(runtime, 4).asNumber();
35
- auto transY = array.getValueAtIndex(runtime, 5).asNumber();
36
- auto pers0 = array.getValueAtIndex(runtime, 6).asNumber();
37
- auto pers1 = array.getValueAtIndex(runtime, 7).asNumber();
38
- auto pers2 = array.getValueAtIndex(runtime, 8).asNumber();
39
- return SkMatrix::MakeAll(scaleX, skewX, transX, skewY, scaleY, transY,
40
- pers0, pers1, pers2);
30
+ if (array.size(runtime) == 9) {
31
+ auto scaleX = array.getValueAtIndex(runtime, 0).asNumber();
32
+ auto skewX = array.getValueAtIndex(runtime, 1).asNumber();
33
+ auto transX = array.getValueAtIndex(runtime, 2).asNumber();
34
+ auto skewY = array.getValueAtIndex(runtime, 3).asNumber();
35
+ auto scaleY = array.getValueAtIndex(runtime, 4).asNumber();
36
+ auto transY = array.getValueAtIndex(runtime, 5).asNumber();
37
+ auto pers0 = array.getValueAtIndex(runtime, 6).asNumber();
38
+ auto pers1 = array.getValueAtIndex(runtime, 7).asNumber();
39
+ auto pers2 = array.getValueAtIndex(runtime, 8).asNumber();
40
+ return SkMatrix::MakeAll(scaleX, skewX, transX, skewY, scaleY, transY,
41
+ pers0, pers1, pers2);
42
+ } else if (array.size(runtime) == 16) {
43
+ auto m11 = array.getValueAtIndex(runtime, 0).asNumber();
44
+ auto m12 = array.getValueAtIndex(runtime, 1).asNumber();
45
+ auto m14 = array.getValueAtIndex(runtime, 3).asNumber();
46
+ auto m21 = array.getValueAtIndex(runtime, 4).asNumber();
47
+ auto m22 = array.getValueAtIndex(runtime, 5).asNumber();
48
+ auto m24 = array.getValueAtIndex(runtime, 7).asNumber();
49
+ auto m41 = array.getValueAtIndex(runtime, 12).asNumber();
50
+ auto m42 = array.getValueAtIndex(runtime, 13).asNumber();
51
+ auto m44 = array.getValueAtIndex(runtime, 15).asNumber();
52
+ return SkMatrix::MakeAll(m11, m12, m14, m21, m22, m24, m41, m42, m44);
53
+ }
54
+ throw jsi::JSError(runtime,
55
+ "Expected array of length 9 or 16 for matrix, got " +
56
+ std::to_string(array.size(runtime)));
41
57
  }
42
58
 
43
59
  JSI_HOST_FUNCTION(concat) {
@@ -13,6 +13,7 @@
13
13
  #pragma clang diagnostic ignored "-Wdocumentation"
14
14
 
15
15
  #include "SkFont.h"
16
+ #include "SkFontTypes.h"
16
17
  #include "SkTypeface.h"
17
18
 
18
19
  #pragma clang diagnostic pop
@@ -28,9 +28,20 @@ public:
28
28
  } else if (_matrixProp->isSet()) {
29
29
  auto values = _matrixProp->value().getAsArray();
30
30
  auto m3 = std::make_shared<SkMatrix>();
31
- for (size_t i = 0; i < values.size(); ++i) {
32
- auto a = values[i];
33
- m3->set(i, a.getAsNumber());
31
+ if (values.size() == 9) {
32
+ for (size_t i = 0; i < values.size(); ++i) {
33
+ auto a = values[i];
34
+ m3->set(i, a.getAsNumber());
35
+ }
36
+ } else {
37
+ SkM44 m4;
38
+ for (size_t i = 0; i < values.size(); ++i) {
39
+ auto obj = values[i];
40
+ m4.setRC(i / 4, i % 4, obj.getAsNumber());
41
+ }
42
+ auto m = m4.asM33();
43
+ m3->setAll(m.rc(0, 0), m.rc(0, 1), m.rc(0, 2), m.rc(1, 0), m.rc(1, 1),
44
+ m.rc(1, 2), m.rc(2, 0), m.rc(2, 1), m.rc(2, 2));
34
45
  }
35
46
  setDerivedValue(m3);
36
47
  }
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { BlendMode, Color, PaintStyle, SkMatrix, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms3d, Vector } from "../../skia/types";
2
+ import type { BlendMode, Color, InputMatrix, PaintStyle, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms3d, Vector } from "../../skia/types";
3
3
  export type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;
4
4
  export type PathDef = string | SkPath;
5
5
  export type ClipDef = SkRRect | SkRect | PathDef;
@@ -36,7 +36,7 @@ export type CircleDef = PointCircleDef | ScalarCircleDef;
36
36
  export interface TransformProps {
37
37
  transform?: Transforms3d;
38
38
  origin?: Vector;
39
- matrix?: SkMatrix | number[];
39
+ matrix?: InputMatrix;
40
40
  }
41
41
  export interface PaintProps extends ChildrenProps {
42
42
  color?: Color;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Common.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\n\nimport type {\n BlendMode,\n Color,\n PaintStyle,\n SkMatrix,\n SkPaint,\n SkPath,\n SkRect,\n SkRRect,\n StrokeCap,\n StrokeJoin,\n Transforms3d,\n Vector,\n} from \"../../skia/types\";\n\nexport type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;\n\nexport type PathDef = string | SkPath;\n\nexport type ClipDef = SkRRect | SkRect | PathDef;\n\nexport type Fit =\n | \"cover\"\n | \"contain\"\n | \"fill\"\n | \"fitHeight\"\n | \"fitWidth\"\n | \"none\"\n | \"scaleDown\";\n\nexport type Radius = number | Vector;\n\nexport interface ChildrenProps {\n children?: ReactNode | ReactNode[];\n}\n\nexport interface RectCtor {\n x?: number;\n y?: number;\n width: number;\n height: number;\n}\n\nexport interface RRectCtor extends RectCtor {\n r?: Radius;\n}\n\nexport type RectDef = RectCtor | { rect: SkRect };\nexport type RRectDef = RRectCtor | { rect: SkRRect };\n\nexport interface PointCircleDef {\n c?: Vector;\n r: number;\n}\n\nexport interface ScalarCircleDef {\n cx: number;\n cy: number;\n r: number;\n}\n\nexport type CircleDef = PointCircleDef | ScalarCircleDef;\n\nexport interface TransformProps {\n transform?: Transforms3d;\n origin?: Vector;\n matrix?: SkMatrix | number[];\n}\n\nexport interface PaintProps extends ChildrenProps {\n color?: Color;\n strokeWidth?: number;\n blendMode?: SkEnum<typeof BlendMode>;\n style?: SkEnum<typeof PaintStyle>;\n strokeJoin?: SkEnum<typeof StrokeJoin>;\n strokeCap?: SkEnum<typeof StrokeCap>;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n dither?: boolean;\n}\n\nexport interface GroupProps extends PaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: SkPaint | boolean;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Common.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\n\nimport type {\n BlendMode,\n Color,\n InputMatrix,\n PaintStyle,\n SkPaint,\n SkPath,\n SkRect,\n SkRRect,\n StrokeCap,\n StrokeJoin,\n Transforms3d,\n Vector,\n} from \"../../skia/types\";\n\nexport type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;\n\nexport type PathDef = string | SkPath;\n\nexport type ClipDef = SkRRect | SkRect | PathDef;\n\nexport type Fit =\n | \"cover\"\n | \"contain\"\n | \"fill\"\n | \"fitHeight\"\n | \"fitWidth\"\n | \"none\"\n | \"scaleDown\";\n\nexport type Radius = number | Vector;\n\nexport interface ChildrenProps {\n children?: ReactNode | ReactNode[];\n}\n\nexport interface RectCtor {\n x?: number;\n y?: number;\n width: number;\n height: number;\n}\n\nexport interface RRectCtor extends RectCtor {\n r?: Radius;\n}\n\nexport type RectDef = RectCtor | { rect: SkRect };\nexport type RRectDef = RRectCtor | { rect: SkRRect };\n\nexport interface PointCircleDef {\n c?: Vector;\n r: number;\n}\n\nexport interface ScalarCircleDef {\n cx: number;\n cy: number;\n r: number;\n}\n\nexport type CircleDef = PointCircleDef | ScalarCircleDef;\n\nexport interface TransformProps {\n transform?: Transforms3d;\n origin?: Vector;\n matrix?: InputMatrix;\n}\n\nexport interface PaintProps extends ChildrenProps {\n color?: Color;\n strokeWidth?: number;\n blendMode?: SkEnum<typeof BlendMode>;\n style?: SkEnum<typeof PaintStyle>;\n strokeJoin?: SkEnum<typeof StrokeJoin>;\n strokeCap?: SkEnum<typeof StrokeCap>;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n dither?: boolean;\n}\n\nexport interface GroupProps extends PaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: SkPaint | boolean;\n}\n"],"mappings":""}
@@ -1,6 +1,7 @@
1
1
  import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
2
2
  import type { SkPath, SkPoint } from "../../skia/types";
3
3
  export declare const notifyChange: (value: SharedValue<unknown>) => void;
4
+ export declare const usePathValue: (cb: (path: SkPath) => void) => SharedValue<SkPath>;
4
5
  export declare const useClock: () => SharedValue<number>;
5
6
  export declare const usePathInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPath[], options?: ExtrapolationType) => SharedValue<SkPath>;
6
7
  export declare const useVectorInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPoint[], options?: ExtrapolationType) => SharedValue<{
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useVectorInterpolation = exports.usePathInterpolation = exports.useClock = exports.notifyChange = void 0;
6
+ exports.useVectorInterpolation = exports.usePathValue = exports.usePathInterpolation = exports.useClock = exports.notifyChange = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
@@ -24,13 +24,26 @@ const notifyChange = value => {
24
24
 
25
25
  exports.notifyChange = notifyChange;
26
26
 
27
+ const usePathValue = cb => {
28
+ const pathInit = (0, _react.useMemo)(() => _skia.Skia.Path.Make(), []);
29
+ const path = (0, _moduleWrapper.useSharedValue)(pathInit);
30
+ (0, _moduleWrapper.useDerivedValue)(() => {
31
+ path.value.reset();
32
+ cb(path.value);
33
+ notifyChange(path);
34
+ });
35
+ return path;
36
+ };
37
+
38
+ exports.usePathValue = usePathValue;
39
+
27
40
  const useClock = () => {
28
41
  const clock = (0, _moduleWrapper.useSharedValue)(0);
29
- const callback = (0, _react.useRef)(info => {
42
+ const callback = (0, _react.useCallback)(info => {
30
43
  "worklet";
31
44
 
32
45
  clock.value = info.timeSinceFirstFrame;
33
- }).current;
46
+ }, [clock]);
34
47
  (0, _moduleWrapper.useFrameCallback)(callback);
35
48
  return clock;
36
49
  };
@@ -1 +1 @@
1
- {"version":3,"names":["notifyChange","value","_WORKLET","_value","useClock","clock","useSharedValue","callback","useRef","info","timeSinceFirstFrame","current","useFrameCallback","useInterpolator","factory","interpolator","input","output","options","init","useMemo","result","useAnimatedReaction","val","usePathInterpolation","outputRange","Skia","Path","Make","interpolatePaths","useVectorInterpolation","Point","interpolateVector"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useMemo, useRef } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useRef((info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n }).current;\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":";;;;;;;AAKA;;AAGA;;AACA;;AAEA;;AAMO,MAAMA,YAAY,GAAIC,KAAD,IAAiC;EAC3D;;EACA,IAAIC,QAAJ,EAAc;IACZ;IACCD,KAAD,CAAeE,MAAf,GAAwBF,KAAK,CAACA,KAA9B;EACD;AACF,CANM;;;;AAQA,MAAMG,QAAQ,GAAG,MAAM;EAC5B,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAe,CAAf,CAAd;EACA,MAAMC,QAAQ,GAAG,IAAAC,aAAA,EAAQC,IAAD,IAAqB;IAC3C;;IACAJ,KAAK,CAACJ,KAAN,GAAcQ,IAAI,CAACC,mBAAnB;EACD,CAHgB,EAGdC,OAHH;EAIA,IAAAC,+BAAA,EAAiBL,QAAjB;EACA,OAAOF,KAAP;AACD,CARM;AAUP;AACA;AACA;;;;;AASA,MAAMQ,eAAe,GAAG,CACtBC,OADsB,EAEtBb,KAFsB,EAGtBc,YAHsB,EAItBC,KAJsB,EAKtBC,MALsB,EAMtBC,OANsB,KAOnB;EACH;EACA,MAAMC,IAAI,GAAG,IAAAC,cAAA,EAAQ,MAAMN,OAAO,EAArB,EAAyB,EAAzB,CAAb;EACA,MAAMO,MAAM,GAAG,IAAAf,6BAAA,EAAea,IAAf,CAAf;EACA,IAAAG,kCAAA,EACE,MAAMrB,KAAK,CAACA,KADd,EAEGsB,GAAD,IAAS;IACPF,MAAM,CAACpB,KAAP,GAAec,YAAY,CAACQ,GAAD,EAAMP,KAAN,EAAaC,MAAb,EAAqBC,OAArB,EAA8BG,MAAM,CAACpB,KAArC,CAA3B;IACAD,YAAY,CAACqB,MAAD,CAAZ;EACD,CALH,EAME,CAACL,KAAD,EAAQC,MAAR,EAAgBC,OAAhB,CANF;EAQA,OAAOG,MAAP;AACD,CApBD;;AAsBO,MAAMG,oBAAoB,GAAG,CAClCvB,KADkC,EAElCe,KAFkC,EAGlCS,WAHkC,EAIlCP,OAJkC,KAMlCL,eAAe,CACb,MAAMa,UAAA,CAAKC,IAAL,CAAUC,IAAV,EADO,EAEb3B,KAFa,EAGb4B,2BAHa,EAIbb,KAJa,EAKbS,WALa,EAMbP,OANa,CANV;;;;AAeA,MAAMY,sBAAsB,GAAG,CACpC7B,KADoC,EAEpCe,KAFoC,EAGpCS,WAHoC,EAIpCP,OAJoC,KAMpCL,eAAe,CACb,MAAMa,UAAA,CAAKK,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEb9B,KAFa,EAGb+B,4BAHa,EAIbhB,KAJa,EAKbS,WALa,EAMbP,OANa,CANV"}
1
+ {"version":3,"names":["notifyChange","value","_WORKLET","_value","usePathValue","cb","pathInit","useMemo","Skia","Path","Make","path","useSharedValue","useDerivedValue","reset","useClock","clock","callback","useCallback","info","timeSinceFirstFrame","useFrameCallback","useInterpolator","factory","interpolator","input","output","options","init","result","useAnimatedReaction","val","usePathInterpolation","outputRange","interpolatePaths","useVectorInterpolation","Point","interpolateVector"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n useDerivedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const usePathValue = (cb: (path: SkPath) => void) => {\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const path = useSharedValue(pathInit);\n useDerivedValue(() => {\n path.value.reset();\n cb(path.value);\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":";;;;;;;AAKA;;AAGA;;AACA;;AAEA;;AAOO,MAAMA,YAAY,GAAIC,KAAD,IAAiC;EAC3D;;EACA,IAAIC,QAAJ,EAAc;IACZ;IACCD,KAAD,CAAeE,MAAf,GAAwBF,KAAK,CAACA,KAA9B;EACD;AACF,CANM;;;;AAQA,MAAMG,YAAY,GAAIC,EAAD,IAAgC;EAC1D,MAAMC,QAAQ,GAAG,IAAAC,cAAA,EAAQ,MAAMC,UAAA,CAAKC,IAAL,CAAUC,IAAV,EAAd,EAAgC,EAAhC,CAAjB;EACA,MAAMC,IAAI,GAAG,IAAAC,6BAAA,EAAeN,QAAf,CAAb;EACA,IAAAO,8BAAA,EAAgB,MAAM;IACpBF,IAAI,CAACV,KAAL,CAAWa,KAAX;IACAT,EAAE,CAACM,IAAI,CAACV,KAAN,CAAF;IACAD,YAAY,CAACW,IAAD,CAAZ;EACD,CAJD;EAKA,OAAOA,IAAP;AACD,CATM;;;;AAWA,MAAMI,QAAQ,GAAG,MAAM;EAC5B,MAAMC,KAAK,GAAG,IAAAJ,6BAAA,EAAe,CAAf,CAAd;EACA,MAAMK,QAAQ,GAAG,IAAAC,kBAAA,EACdC,IAAD,IAAqB;IACnB;;IACAH,KAAK,CAACf,KAAN,GAAckB,IAAI,CAACC,mBAAnB;EACD,CAJc,EAKf,CAACJ,KAAD,CALe,CAAjB;EAOA,IAAAK,+BAAA,EAAiBJ,QAAjB;EACA,OAAOD,KAAP;AACD,CAXM;AAaP;AACA;AACA;;;;;AASA,MAAMM,eAAe,GAAG,CACtBC,OADsB,EAEtBtB,KAFsB,EAGtBuB,YAHsB,EAItBC,KAJsB,EAKtBC,MALsB,EAMtBC,OANsB,KAOnB;EACH;EACA,MAAMC,IAAI,GAAG,IAAArB,cAAA,EAAQ,MAAMgB,OAAO,EAArB,EAAyB,EAAzB,CAAb;EACA,MAAMM,MAAM,GAAG,IAAAjB,6BAAA,EAAegB,IAAf,CAAf;EACA,IAAAE,kCAAA,EACE,MAAM7B,KAAK,CAACA,KADd,EAEG8B,GAAD,IAAS;IACPF,MAAM,CAAC5B,KAAP,GAAeuB,YAAY,CAACO,GAAD,EAAMN,KAAN,EAAaC,MAAb,EAAqBC,OAArB,EAA8BE,MAAM,CAAC5B,KAArC,CAA3B;IACAD,YAAY,CAAC6B,MAAD,CAAZ;EACD,CALH,EAME,CAACJ,KAAD,EAAQC,MAAR,EAAgBC,OAAhB,CANF;EAQA,OAAOE,MAAP;AACD,CApBD;;AAsBO,MAAMG,oBAAoB,GAAG,CAClC/B,KADkC,EAElCwB,KAFkC,EAGlCQ,WAHkC,EAIlCN,OAJkC,KAMlCL,eAAe,CACb,MAAMd,UAAA,CAAKC,IAAL,CAAUC,IAAV,EADO,EAEbT,KAFa,EAGbiC,2BAHa,EAIbT,KAJa,EAKbQ,WALa,EAMbN,OANa,CANV;;;;AAeA,MAAMQ,sBAAsB,GAAG,CACpClC,KADoC,EAEpCwB,KAFoC,EAGpCQ,WAHoC,EAIpCN,OAJoC,KAMpCL,eAAe,CACb,MAAMd,UAAA,CAAK4B,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEbnC,KAFa,EAGboC,4BAHa,EAIbZ,KAJa,EAKbQ,WALa,EAMbN,OANa,CANV"}
@@ -1,9 +1,10 @@
1
1
  import type { DependencyList } from "react";
2
- import type { FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
2
+ import type { DerivedValue, FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
3
3
  export declare const HAS_REANIMATED2: boolean;
4
4
  export declare const HAS_REANIMATED3: boolean;
5
5
  export declare function throwOnMissingReanimated(): void;
6
6
  export declare const useSharedValue: <T>(init: T, oneWayReadsOnly?: boolean) => SharedValue<T>;
7
+ export declare const useDerivedValue: <T>(processor: () => T, dependencies?: DependencyList) => DerivedValue<T>;
7
8
  export declare const useFrameCallback: (callback: (frameInfo: FrameInfo) => void, autostart?: boolean) => FrameCallback;
8
9
  export declare const startMapper: (worklet: () => void, inputs?: unknown[], outputs?: unknown[]) => number;
9
10
  export declare const stopMapper: (mapperID: number) => void;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.stopMapper = exports.startMapper = exports.runOnJS = exports.isSharedValue = exports.HAS_REANIMATED3 = exports.HAS_REANIMATED2 = void 0;
7
7
  exports.throwOnMissingReanimated = throwOnMissingReanimated;
8
- exports.useSharedValue = exports.useFrameCallback = exports.useAnimatedReaction = void 0;
8
+ exports.useSharedValue = exports.useFrameCallback = exports.useDerivedValue = exports.useAnimatedReaction = void 0;
9
9
 
10
- var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6;
10
+ var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7;
11
11
 
12
12
  /* eslint-disable @typescript-eslint/no-explicit-any */
13
13
  // This one is needed for the deprecated useSharedValue function
@@ -39,15 +39,17 @@ function throwOnMissingReanimated() {
39
39
 
40
40
  const useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || throwOnMissingReanimated;
41
41
  exports.useSharedValue = useSharedValue;
42
- const useFrameCallback = ((_Reanimated2 = Reanimated2) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.useFrameCallback) || throwOnMissingReanimated;
42
+ const useDerivedValue = ((_Reanimated2 = Reanimated2) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.useDerivedValue) || throwOnMissingReanimated;
43
+ exports.useDerivedValue = useDerivedValue;
44
+ const useFrameCallback = ((_Reanimated3 = Reanimated2) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.useFrameCallback) || throwOnMissingReanimated;
43
45
  exports.useFrameCallback = useFrameCallback;
44
- const startMapper = ((_Reanimated3 = Reanimated2) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.startMapper) || throwOnMissingReanimated;
46
+ const startMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.startMapper) || throwOnMissingReanimated;
45
47
  exports.startMapper = startMapper;
46
- const stopMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.stopMapper) || throwOnMissingReanimated;
48
+ const stopMapper = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.stopMapper) || throwOnMissingReanimated;
47
49
  exports.stopMapper = stopMapper;
48
- const runOnJS = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.runOnJS) || throwOnMissingReanimated;
50
+ const runOnJS = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.runOnJS) || throwOnMissingReanimated;
49
51
  exports.runOnJS = runOnJS;
50
- const useAnimatedReaction = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.useAnimatedReaction) || throwOnMissingReanimated;
52
+ const useAnimatedReaction = ((_Reanimated7 = Reanimated2) === null || _Reanimated7 === void 0 ? void 0 : _Reanimated7.useAnimatedReaction) || throwOnMissingReanimated;
51
53
  exports.useAnimatedReaction = useAnimatedReaction;
52
54
 
53
55
  const isSharedValue = value => {
@@ -1 +1 @@
1
- {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","useFrameCallback","startMapper","stopMapper","runOnJS","useAnimatedReaction","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA;AAQA;AACA;AAEA,IAAIA,WAAJ;AAEA,IAAIC,WAAJ;AACA,IAAIC,iBAAJ;;AAEA,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAD,CAArB;EACAD,iBAAiB,GAAGC,OAAO,CAAC,sCAAD,CAAP,CAAgDC,OAApE;;EACA,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAArB,IAAgCA,iBAAiB,CAACG,QAAlB,CAA2B,QAA3B,CADhB,CADnB,EAGE;IACAJ,WAAW,GAAGD,WAAd;EACD;AACF,CATD,CASE,OAAOM,CAAP,EAAU,CAAE;;AAEP,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;;AACA,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;;;AAEA,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;;AAEM,MAAMC,cAGM,GAAG,gBAAAX,WAAW,UAAX,kDAAaW,cAAb,KAA+BF,wBAH9C;;AAKA,MAAMG,gBAGK,GAAG,iBAAAZ,WAAW,UAAX,oDAAaY,gBAAb,KAAiCH,wBAH/C;;AAKA,MAAMI,WAIF,GAAG,iBAAAb,WAAW,UAAX,oDAAaa,WAAb,KAA4BJ,wBAJnC;;AAMA,MAAMK,UAAsC,GACjD,iBAAAd,WAAW,UAAX,oDAAac,UAAb,KAA2BL,wBADtB;;AAGA,MAAMM,OAAO,GAAG,iBAAAf,WAAW,UAAX,oDAAae,OAAb,KAAwBN,wBAAxC;;AAEA,MAAMO,mBAIJ,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,mBAAb,KAAoCP,wBAJzC;;;AAMA,MAAMQ,aAAa,GAAOC,KAAJ,IAAgD;EAC3E,OACE,CAAC,CAACA,KAAF,KACCjB,WAAW,GACRA,WAAW,CAACgB,aAAZ,CAA0BC,KAA1B,CADQ,GAEPA,KAAD,CAAeA,KAAf,KAAyBC,SAH7B,CADF;AAMD,CAPM"}
1
+ {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","useDerivedValue","useFrameCallback","startMapper","stopMapper","runOnJS","useAnimatedReaction","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n DerivedValue,\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useDerivedValue: <T>(\n processor: () => T,\n dependencies?: DependencyList\n) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA;AASA;AACA;AAEA,IAAIA,WAAJ;AAEA,IAAIC,WAAJ;AACA,IAAIC,iBAAJ;;AAEA,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAD,CAArB;EACAD,iBAAiB,GAAGC,OAAO,CAAC,sCAAD,CAAP,CAAgDC,OAApE;;EACA,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAArB,IAAgCA,iBAAiB,CAACG,QAAlB,CAA2B,QAA3B,CADhB,CADnB,EAGE;IACAJ,WAAW,GAAGD,WAAd;EACD;AACF,CATD,CASE,OAAOM,CAAP,EAAU,CAAE;;AAEP,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;;AACA,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;;;AAEA,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;;AAEM,MAAMC,cAGM,GAAG,gBAAAX,WAAW,UAAX,kDAAaW,cAAb,KAA+BF,wBAH9C;;AAKA,MAAMG,eAGO,GAAG,iBAAAZ,WAAW,UAAX,oDAAaY,eAAb,KAAgCH,wBAHhD;;AAKA,MAAMI,gBAGK,GAAG,iBAAAb,WAAW,UAAX,oDAAaa,gBAAb,KAAiCJ,wBAH/C;;AAKA,MAAMK,WAIF,GAAG,iBAAAd,WAAW,UAAX,oDAAac,WAAb,KAA4BL,wBAJnC;;AAMA,MAAMM,UAAsC,GACjD,iBAAAf,WAAW,UAAX,oDAAae,UAAb,KAA2BN,wBADtB;;AAGA,MAAMO,OAAO,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,OAAb,KAAwBP,wBAAxC;;AAEA,MAAMQ,mBAIJ,GAAG,iBAAAjB,WAAW,UAAX,oDAAaiB,mBAAb,KAAoCR,wBAJzC;;;AAMA,MAAMS,aAAa,GAAOC,KAAJ,IAAgD;EAC3E,OACE,CAAC,CAACA,KAAF,KACClB,WAAW,GACRA,WAAW,CAACiB,aAAZ,CAA0BC,KAA1B,CADQ,GAEPA,KAAD,CAAeA,KAAf,KAAyBC,SAH7B,CADF;AAMD,CAPM"}
@@ -9,9 +9,9 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _views = require("../views");
11
11
 
12
- var _Skia = require("../skia/Skia");
12
+ var _SkiaDomView = require("../views/SkiaDomView.web");
13
13
 
14
- var _types = require("../dom/types");
14
+ var _Skia = require("../skia/Skia");
15
15
 
16
16
  var _Reconciler = require("./Reconciler");
17
17
 
@@ -108,21 +108,15 @@ const Canvas = /*#__PURE__*/(0, _react.forwardRef)((_ref, forwardedRef) => {
108
108
  debug: debug
109
109
  }, props));
110
110
  } else {
111
- // This is for debugging
112
- const recorder = _Skia.Skia.PictureRecorder();
113
-
114
- const canvas = recorder.beginRecording(_Skia.Skia.XYWHRect(0, 0, 2_000_000, 2_000_000));
115
- const ctx = new _types.JsiDrawingContext(_Skia.Skia, canvas);
116
- root.dom.render(ctx);
117
- const picture = recorder.finishRecordingAsPicture();
118
- return /*#__PURE__*/_react.default.createElement(_views.SkiaPictureView // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ return /*#__PURE__*/_react.default.createElement(_SkiaDomView.SkiaDomView // eslint-disable-next-line @typescript-eslint/no-explicit-any
119
112
  , _extends({
120
113
  ref: ref,
121
114
  style: style,
115
+ root: root.dom,
116
+ onTouch: onTouch,
117
+ onLayout: onLayout,
122
118
  mode: mode,
123
- debug: debug,
124
- picture: picture,
125
- onLayout: onLayout
119
+ debug: debug
126
120
  }, props));
127
121
  }
128
122
  });
@@ -1 +1 @@
1
- {"version":3,"names":["useCanvasRef","useRef","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","isValue","current","value","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","getNativeId","id","nativeId","registerValues","values","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","NATIVE_DOM","dom","recorder","PictureRecorder","canvas","beginRecording","XYWHRect","ctx","JsiDrawingContext","picture","finishRecordingAsPicture","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView, SkiaPictureView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\nimport { isValue } from \"./processors\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (isValue(resultValue)) {\n resultValue.current = { width, height };\n } else if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n // This is for debugging\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(\n Skia.XYWHRect(0, 0, 2_000_000, 2_000_000)\n );\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n const picture = recorder.finishRecordingAsPicture();\n return (\n <SkiaPictureView\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n mode={mode}\n debug={debug}\n picture={picture}\n onLayout={onLayout}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":"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"}
1
+ {"version":3,"names":["useCanvasRef","useRef","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","isValue","current","value","Canvas","forwardRef","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","getNativeId","id","nativeId","registerValues","values","root","useMemo","SkiaRoot","Skia","useEffect","render","unmount","NATIVE_DOM","dom","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { SkiaDomView as SkiaDomViewWeb } from \"../views/SkiaDomView.web\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\nimport { isValue } from \"./processors\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (isValue(resultValue)) {\n resultValue.current = { width, height };\n } else if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaDomViewWeb\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":"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"}
@@ -5,8 +5,3 @@ export declare const neg: (a: Vector) => import("../types").SkPoint;
5
5
  export declare const add: (a: Vector, b: Vector) => import("../types").SkPoint;
6
6
  export declare const sub: (a: Vector, b: Vector) => import("../types").SkPoint;
7
7
  export declare const dist: (a: Vector, b: Vector) => number;
8
- export declare const translate: ({ x, y, }: Vector) => [{
9
- translateX: number;
10
- }, {
11
- translateY: number;
12
- }];
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.vec = exports.translate = exports.sub = exports.point = exports.neg = exports.dist = exports.add = void 0;
6
+ exports.vec = exports.sub = exports.point = exports.neg = exports.dist = exports.add = void 0;
7
7
 
8
8
  var _Skia = require("../Skia");
9
9
 
@@ -50,20 +50,4 @@ const dist = (a, b) => {
50
50
  };
51
51
 
52
52
  exports.dist = dist;
53
-
54
- const translate = _ref => {
55
- "worklet";
56
-
57
- let {
58
- x,
59
- y
60
- } = _ref;
61
- return [{
62
- translateX: x
63
- }, {
64
- translateY: y
65
- }];
66
- };
67
-
68
- exports.translate = translate;
69
53
  //# sourceMappingURL=Vector.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["vec","x","y","Skia","Point","point","neg","a","add","b","sub","dist","Math","hypot","translate","translateX","translateY"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => {\n \"worklet\";\n return Skia.Point(x, y ?? x);\n};\nexport const point = vec;\nexport const neg = (a: Vector) => {\n \"worklet\";\n return vec(-a.x, -a.y);\n};\nexport const add = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x + b.x, a.y + b.y);\n};\nexport const sub = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x - b.x, a.y - b.y);\n};\nexport const dist = (a: Vector, b: Vector) => {\n \"worklet\";\n return Math.hypot(a.x - b.x, a.y - b.y);\n};\nexport const translate = ({\n x,\n y,\n}: Vector): [{ translateX: number }, { translateY: number }] => {\n \"worklet\";\n return [{ translateX: x }, { translateY: y }];\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,GAAG,GAAG,YAAuB;EACxC;;EADwC,IAAtBC,CAAsB,uEAAlB,CAAkB;EAAA,IAAfC,CAAe;EAExC,OAAOC,UAAA,CAAKC,KAAL,CAAWH,CAAX,EAAcC,CAAC,IAAID,CAAnB,CAAP;AACD,CAHM;;;AAIA,MAAMI,KAAK,GAAGL,GAAd;;;AACA,MAAMM,GAAG,GAAIC,CAAD,IAAe;EAChC;;EACA,OAAOP,GAAG,CAAC,CAACO,CAAC,CAACN,CAAJ,EAAO,CAACM,CAAC,CAACL,CAAV,CAAV;AACD,CAHM;;;;AAIA,MAAMM,GAAG,GAAG,CAACD,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOT,GAAG,CAACO,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAT,EAAYM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAApB,CAAV;AACD,CAHM;;;;AAIA,MAAMQ,GAAG,GAAG,CAACH,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOT,GAAG,CAACO,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAT,EAAYM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAApB,CAAV;AACD,CAHM;;;;AAIA,MAAMS,IAAI,GAAG,CAACJ,CAAD,EAAYE,CAAZ,KAA0B;EAC5C;;EACA,OAAOG,IAAI,CAACC,KAAL,CAAWN,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAnB,EAAsBM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAA9B,CAAP;AACD,CAHM;;;;AAIA,MAAMY,SAAS,GAAG,QAGuC;EAC9D;;EAD8D,IAHtC;IACxBb,CADwB;IAExBC;EAFwB,CAGsC;EAE9D,OAAO,CAAC;IAAEa,UAAU,EAAEd;EAAd,CAAD,EAAoB;IAAEe,UAAU,EAAEd;EAAd,CAApB,CAAP;AACD,CANM"}
1
+ {"version":3,"names":["vec","x","y","Skia","Point","point","neg","a","add","b","sub","dist","Math","hypot"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => {\n \"worklet\";\n return Skia.Point(x, y ?? x);\n};\nexport const point = vec;\nexport const neg = (a: Vector) => {\n \"worklet\";\n return vec(-a.x, -a.y);\n};\nexport const add = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x + b.x, a.y + b.y);\n};\nexport const sub = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x - b.x, a.y - b.y);\n};\nexport const dist = (a: Vector, b: Vector) => {\n \"worklet\";\n return Math.hypot(a.x - b.x, a.y - b.y);\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,GAAG,GAAG,YAAuB;EACxC;;EADwC,IAAtBC,CAAsB,uEAAlB,CAAkB;EAAA,IAAfC,CAAe;EAExC,OAAOC,UAAA,CAAKC,KAAL,CAAWH,CAAX,EAAcC,CAAC,IAAID,CAAnB,CAAP;AACD,CAHM;;;AAIA,MAAMI,KAAK,GAAGL,GAAd;;;AACA,MAAMM,GAAG,GAAIC,CAAD,IAAe;EAChC;;EACA,OAAOP,GAAG,CAAC,CAACO,CAAC,CAACN,CAAJ,EAAO,CAACM,CAAC,CAACL,CAAV,CAAV;AACD,CAHM;;;;AAIA,MAAMM,GAAG,GAAG,CAACD,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOT,GAAG,CAACO,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAT,EAAYM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAApB,CAAV;AACD,CAHM;;;;AAIA,MAAMQ,GAAG,GAAG,CAACH,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOT,GAAG,CAACO,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAT,EAAYM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAApB,CAAV;AACD,CAHM;;;;AAIA,MAAMS,IAAI,GAAG,CAACJ,CAAD,EAAYE,CAAZ,KAA0B;EAC5C;;EACA,OAAOG,IAAI,CAACC,KAAL,CAAWN,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAnB,EAAsBM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAA9B,CAAP;AACD,CAHM"}
@@ -8,7 +8,7 @@ import type { SkColor } from "./Color";
8
8
  import type { SkRRect } from "./RRect";
9
9
  import type { BlendMode } from "./Paint/BlendMode";
10
10
  import type { SkPoint, PointMode } from "./Point";
11
- import type { SkMatrix } from "./Matrix";
11
+ import type { InputMatrix } from "./Matrix";
12
12
  import type { SkImageFilter } from "./ImageFilter";
13
13
  import type { SkVertices } from "./Vertices";
14
14
  import type { SkTextBlob } from "./TextBlob";
@@ -372,7 +372,7 @@ export interface SkCanvas {
372
372
  * Replaces current matrix with m premultiplied with the existing matrix.
373
373
  * @param m
374
374
  */
375
- concat(m: SkMatrix | number[]): void;
375
+ concat(m: InputMatrix): void;
376
376
  /**
377
377
  * Draws the given picture using the current clip, current matrix, and the provided paint.
378
378
  * @param skp
@@ -1 +1 @@
1
- {"version":3,"names":["ClipOp","SaveLayerFlag"],"sources":["Canvas.ts"],"sourcesContent":["import type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkFont } from \"./Font\";\nimport type { SkPath } from \"./Path\";\nimport type { SkImage, MipmapMode, FilterMode, ImageInfo } from \"./Image\";\nimport type { SkSVG } from \"./SVG\";\nimport type { SkColor } from \"./Color\";\nimport type { SkRRect } from \"./RRect\";\nimport type { BlendMode } from \"./Paint/BlendMode\";\nimport type { SkPoint, PointMode } from \"./Point\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { SkImageFilter } from \"./ImageFilter\";\nimport type { SkVertices } from \"./Vertices\";\nimport type { SkTextBlob } from \"./TextBlob\";\nimport type { SkPicture } from \"./Picture\";\n\nexport enum ClipOp {\n Difference,\n Intersect,\n}\n\nexport enum SaveLayerFlag {\n SaveLayerInitWithPrevious = 1 << 2,\n SaveLayerF16ColorType = 1 << 4,\n}\n\nexport interface SkCanvas {\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix, and optionally-provided paint.\n * @param img\n * @param left\n * @param top\n * @param paint\n */\n drawImage: (image: SkImage, x: number, y: number, paint?: SkPaint) => void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * @param img\n * @param src\n * @param dest\n * @param paint\n * @param fastSample - if false, will filter strictly within src.\n */\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param left\n * @param top\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the provided sampling options if necessary.\n * @param img\n * @param left\n * @param top\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the provided image stretched proportionally to fit into dst rectangle.\n * The center rectangle divides the image into nine sections: four sides, four corners, and\n * the center.\n * @param img\n * @param center\n * @param dest\n * @param filter - what technique to use when sampling the image\n * @param paint\n */\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param src\n * @param dest\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the provided sampling options if necessary.\n * @param img\n * @param src\n * @param dest\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /** Fills clip with SkPaint paint. SkPaint components, SkShader,\n SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;\n SkMaskFilter and SkPathEffect in paint are ignored.\n\n @param paint graphics state used to fill SkCanvas\n\n example: https://fiddle.skia.org/c/@Canvas_drawPaint\n */\n drawPaint: (paint: SkPaint) => void;\n\n /** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint stroke width describes the line thickness;\n SkPaint::Cap draws the end rounded or square;\n SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.\n\n @param x0 start of line segment on x-axis\n @param y0 start of line segment on y-axis\n @param x1 end of line segment on x-axis\n @param y1 end of line segment on y-axis\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawLine\n */\n drawLine: (\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n paint: SkPaint\n ) => void;\n /** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint::Style determines if rectangle is stroked or filled;\n if stroked, SkPaint stroke width describes the line thickness, and\n SkPaint::Join draws the corners rounded or square.\n\n @param rect rectangle to draw\n @param paint stroke or fill, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawRect\n */\n drawRect: (rect: SkRect, paint: SkPaint) => void;\n\n /**\n * Draws a circle at (cx, cy) with the given radius.\n * @param cx\n * @param cy\n * @param radius\n * @param paint\n */\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint): void;\n\n /**\n * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the\n * provided paint.\n * If paint contains an Shader and vertices does not contain texCoords, the shader\n * is mapped using the vertices' positions.\n * If vertices colors are defined in vertices, and Paint paint contains Shader,\n * BlendMode mode combines vertices colors with Shader.\n * @param verts\n * @param mode\n * @param paint\n */\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint): void;\n\n /**\n * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional\n * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]\n * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch\n * @param colors optional colors interpolated across the patch\n * @param texs optional shader coordinates interpolated across the patch\n * @param mode Specifies how shader and colors blend (if both are specified)\n * @param paint\n */\n drawPatch(\n cubics: readonly SkPoint[],\n colors?: readonly SkColor[] | null,\n texs?: readonly SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ): void;\n\n /**\n * Restores state to a previous stack value.\n * @param saveCount\n */\n restoreToCount(saveCount: number): void;\n\n /**\n * Draws the given points using the current clip, current matrix, and the provided paint.\n *\n * See Canvas.h for more on the mode and its interaction with paint.\n * @param mode\n * @param points\n * @param paint\n */\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;\n\n /** Draws arc using clip, SkMatrix, and SkPaint paint.\n\n Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus\n sweepAngle. startAngle and sweepAngle are in degrees.\n\n startAngle of zero places start point at the right middle edge of oval.\n A positive sweepAngle places arc end point clockwise from start point;\n a negative sweepAngle places arc end point counterclockwise from start point.\n sweepAngle may exceed 360 degrees, a full circle.\n If useCenter is true, draw a wedge that includes lines from oval\n center to arc end points. If useCenter is false, draw arc between end points.\n\n If SkRect oval is empty or sweepAngle is zero, nothing is drawn.\n\n @param oval SkRect bounds of oval containing arc to draw\n @param startAngle angle in degrees where arc begins\n @param sweepAngle sweep angle in degrees; positive is clockwise\n @param useCenter if true, include the center of the oval\n @param paint SkPaint stroke or fill, blend, color, and so on, used to draw\n */\n drawArc: (\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) => void;\n\n /**\n * Draws the given rectangle with rounded corners using the current clip, current matrix,\n * and the provided paint.\n * @param rrect\n * @param paint\n */\n drawRRect(rrect: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws RRect outer and inner using clip, Matrix, and Paint paint.\n * outer must contain inner or the drawing is undefined.\n * @param outer\n * @param inner\n * @param paint\n */\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws an oval bounded by the given rectangle using the current clip, current matrix,\n * and the provided paint.\n * @param oval\n * @param paint\n */\n drawOval(oval: SkRect, paint: SkPaint): void;\n\n /** Draws SkPath path using clip, SkMatrix, and SkPaint paint.\n SkPath contains an array of path contour, each of which may be open or closed.\n\n In paint: SkPaint::Style determines if SkRRect is stroked or filled:\n if filled, SkPath::FillType determines whether path contour describes inside or\n outside of fill; if stroked, SkPaint stroke width describes the line thickness,\n SkPaint::Cap describes line ends, and SkPaint::Join describes how\n corners are drawn.\n\n @param path SkPath to draw\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawPath\n */\n drawPath: (path: SkPath, paint: SkPaint) => void;\n\n /**\n * Draw the given text at the location (x, y) using the provided paint and font. The text will\n * be drawn as is; no shaping, left-to-right, etc.\n * @param str\n * @param x\n * @param y\n * @param paint\n * @param font\n */\n drawText(\n str: string,\n x: number,\n y: number,\n paint: SkPaint,\n font: SkFont\n ): void;\n\n /**\n * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the\n * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.\n * @param blob\n * @param x\n * @param y\n * @param paint\n */\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;\n\n /**\n * Draws a run of glyphs, at corresponding positions, in a given font.\n * @param glyphs the array of glyph IDs (Uint16TypedArray)\n * @param positions the array of x,y floats to position each glyph\n * @param x x-coordinate of the origin of the entire run\n * @param y y-coordinate of the origin of the entire run\n * @param font the font that contains the glyphs\n * @param paint\n */\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ): void;\n\n /**\n * Renders the SVG Dom object to the canvas. If width/height are omitted,\n * the SVG will be rendered to fit the canvas.\n */\n drawSvg: (svgDom: SkSVG, width?: number, height?: number) => void;\n /** Saves SkMatrix and clip.\n Calling restore() discards changes to SkMatrix and clip,\n restoring the SkMatrix and clip to their state when save() was called.\n\n SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),\n and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().\n\n Saved SkCanvas state is put on a stack; multiple calls to save() should be balance\n by an equal number of calls to restore().\n\n Call restoreToCount() with result to restore this and subsequent saves.\n\n @return depth of saved stack\n\n example: https://fiddle.skia.org/c/@Canvas_save\n */\n save: () => number;\n\n /**\n * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.\n * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.\n * It returns the height of the stack.\n * See Canvas.h for more.\n * @param paint\n * @param bounds\n * @param backdrop\n * @param flags\n */\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ): number;\n\n /** Removes changes to SkMatrix and clip since SkCanvas state was\n last saved. The state is removed from the stack.\n\n Does nothing if the stack is empty.\n\n example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore\n\n example: https://fiddle.skia.org/c/@Canvas_restore\n */\n restore: () => void;\n\n /**\n * Rotates the current matrix by the number of degrees.\n * @param rot - angle of rotation in degrees.\n * @param rx\n * @param ry\n */\n rotate(rotationInDegrees: number, rx: number, ry: number): void;\n\n /**\n * Scales the current matrix by sx on the x-axis and sy on the y-axis.\n * @param sx\n * @param sy\n */\n scale(sx: number, sy: number): void;\n\n /**\n * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx\n * skews the drawing right as y-axis values increase; a positive value of sy skews\n * the drawing down as x-axis values increase.\n * @param sx\n * @param sy\n */\n skew(sx: number, sy: number): void;\n\n /**\n * Translates Matrix by dx along the x-axis and dy along the y-axis.\n * @param dx\n * @param dy\n */\n translate(dx: number, dy: number): void;\n\n /**\n * Fills clip with the given color.\n * @param color\n * @param blendMode - defaults to SrcOver.\n */\n drawColor(color: SkColor, blendMode?: BlendMode): void;\n\n /**\n * Fills the current clip with the given color using Src BlendMode.\n * This has the effect of replacing all pixels contained by clip with color.\n * @param color\n */\n clear(color: SkColor): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and path,\n * with an aliased or anti-aliased clip edge.\n * @param path\n * @param op\n * @param doAntiAlias\n */\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rect,\n * with an aliased or anti-aliased clip edge.\n * @param rect\n * @param op\n * @param doAntiAlias\n */\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rrect,\n * with an aliased or anti-aliased clip edge.\n * @param rrect\n * @param op\n * @param doAntiAlias\n */\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces current matrix with m premultiplied with the existing matrix.\n * @param m\n */\n concat(m: SkMatrix | number[]): void;\n\n /**\n * Draws the given picture using the current clip, current matrix, and the provided paint.\n * @param skp\n */\n drawPicture(skp: SkPicture): void;\n\n /** Read Image pixels\n *\n * @param srcX - x-axis upper left corner of the rectangle to read from\n * @param srcY - y-axis upper left corner of the rectangle to read from\n * @param imageInfo - describes the pixel format and dimensions of the data to read into\n * @return Float32Array or Uint8Array with data or null if the read failed.\n */\n readPixels(\n srcX: number,\n srcY: number,\n imageInfo: ImageInfo\n ): Float32Array | Uint8Array | null;\n}\n"],"mappings":";;;;;;IAgBYA,M;;;WAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,sBAAAA,M;;IAKAC,a;;;WAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a"}
1
+ {"version":3,"names":["ClipOp","SaveLayerFlag"],"sources":["Canvas.ts"],"sourcesContent":["import type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkFont } from \"./Font\";\nimport type { SkPath } from \"./Path\";\nimport type { SkImage, MipmapMode, FilterMode, ImageInfo } from \"./Image\";\nimport type { SkSVG } from \"./SVG\";\nimport type { SkColor } from \"./Color\";\nimport type { SkRRect } from \"./RRect\";\nimport type { BlendMode } from \"./Paint/BlendMode\";\nimport type { SkPoint, PointMode } from \"./Point\";\nimport type { InputMatrix } from \"./Matrix\";\nimport type { SkImageFilter } from \"./ImageFilter\";\nimport type { SkVertices } from \"./Vertices\";\nimport type { SkTextBlob } from \"./TextBlob\";\nimport type { SkPicture } from \"./Picture\";\n\nexport enum ClipOp {\n Difference,\n Intersect,\n}\n\nexport enum SaveLayerFlag {\n SaveLayerInitWithPrevious = 1 << 2,\n SaveLayerF16ColorType = 1 << 4,\n}\n\nexport interface SkCanvas {\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix, and optionally-provided paint.\n * @param img\n * @param left\n * @param top\n * @param paint\n */\n drawImage: (image: SkImage, x: number, y: number, paint?: SkPaint) => void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * @param img\n * @param src\n * @param dest\n * @param paint\n * @param fastSample - if false, will filter strictly within src.\n */\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param left\n * @param top\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the provided sampling options if necessary.\n * @param img\n * @param left\n * @param top\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the provided image stretched proportionally to fit into dst rectangle.\n * The center rectangle divides the image into nine sections: four sides, four corners, and\n * the center.\n * @param img\n * @param center\n * @param dest\n * @param filter - what technique to use when sampling the image\n * @param paint\n */\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param src\n * @param dest\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the provided sampling options if necessary.\n * @param img\n * @param src\n * @param dest\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /** Fills clip with SkPaint paint. SkPaint components, SkShader,\n SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;\n SkMaskFilter and SkPathEffect in paint are ignored.\n\n @param paint graphics state used to fill SkCanvas\n\n example: https://fiddle.skia.org/c/@Canvas_drawPaint\n */\n drawPaint: (paint: SkPaint) => void;\n\n /** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint stroke width describes the line thickness;\n SkPaint::Cap draws the end rounded or square;\n SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.\n\n @param x0 start of line segment on x-axis\n @param y0 start of line segment on y-axis\n @param x1 end of line segment on x-axis\n @param y1 end of line segment on y-axis\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawLine\n */\n drawLine: (\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n paint: SkPaint\n ) => void;\n /** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint::Style determines if rectangle is stroked or filled;\n if stroked, SkPaint stroke width describes the line thickness, and\n SkPaint::Join draws the corners rounded or square.\n\n @param rect rectangle to draw\n @param paint stroke or fill, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawRect\n */\n drawRect: (rect: SkRect, paint: SkPaint) => void;\n\n /**\n * Draws a circle at (cx, cy) with the given radius.\n * @param cx\n * @param cy\n * @param radius\n * @param paint\n */\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint): void;\n\n /**\n * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the\n * provided paint.\n * If paint contains an Shader and vertices does not contain texCoords, the shader\n * is mapped using the vertices' positions.\n * If vertices colors are defined in vertices, and Paint paint contains Shader,\n * BlendMode mode combines vertices colors with Shader.\n * @param verts\n * @param mode\n * @param paint\n */\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint): void;\n\n /**\n * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional\n * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]\n * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch\n * @param colors optional colors interpolated across the patch\n * @param texs optional shader coordinates interpolated across the patch\n * @param mode Specifies how shader and colors blend (if both are specified)\n * @param paint\n */\n drawPatch(\n cubics: readonly SkPoint[],\n colors?: readonly SkColor[] | null,\n texs?: readonly SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ): void;\n\n /**\n * Restores state to a previous stack value.\n * @param saveCount\n */\n restoreToCount(saveCount: number): void;\n\n /**\n * Draws the given points using the current clip, current matrix, and the provided paint.\n *\n * See Canvas.h for more on the mode and its interaction with paint.\n * @param mode\n * @param points\n * @param paint\n */\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;\n\n /** Draws arc using clip, SkMatrix, and SkPaint paint.\n\n Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus\n sweepAngle. startAngle and sweepAngle are in degrees.\n\n startAngle of zero places start point at the right middle edge of oval.\n A positive sweepAngle places arc end point clockwise from start point;\n a negative sweepAngle places arc end point counterclockwise from start point.\n sweepAngle may exceed 360 degrees, a full circle.\n If useCenter is true, draw a wedge that includes lines from oval\n center to arc end points. If useCenter is false, draw arc between end points.\n\n If SkRect oval is empty or sweepAngle is zero, nothing is drawn.\n\n @param oval SkRect bounds of oval containing arc to draw\n @param startAngle angle in degrees where arc begins\n @param sweepAngle sweep angle in degrees; positive is clockwise\n @param useCenter if true, include the center of the oval\n @param paint SkPaint stroke or fill, blend, color, and so on, used to draw\n */\n drawArc: (\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) => void;\n\n /**\n * Draws the given rectangle with rounded corners using the current clip, current matrix,\n * and the provided paint.\n * @param rrect\n * @param paint\n */\n drawRRect(rrect: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws RRect outer and inner using clip, Matrix, and Paint paint.\n * outer must contain inner or the drawing is undefined.\n * @param outer\n * @param inner\n * @param paint\n */\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws an oval bounded by the given rectangle using the current clip, current matrix,\n * and the provided paint.\n * @param oval\n * @param paint\n */\n drawOval(oval: SkRect, paint: SkPaint): void;\n\n /** Draws SkPath path using clip, SkMatrix, and SkPaint paint.\n SkPath contains an array of path contour, each of which may be open or closed.\n\n In paint: SkPaint::Style determines if SkRRect is stroked or filled:\n if filled, SkPath::FillType determines whether path contour describes inside or\n outside of fill; if stroked, SkPaint stroke width describes the line thickness,\n SkPaint::Cap describes line ends, and SkPaint::Join describes how\n corners are drawn.\n\n @param path SkPath to draw\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawPath\n */\n drawPath: (path: SkPath, paint: SkPaint) => void;\n\n /**\n * Draw the given text at the location (x, y) using the provided paint and font. The text will\n * be drawn as is; no shaping, left-to-right, etc.\n * @param str\n * @param x\n * @param y\n * @param paint\n * @param font\n */\n drawText(\n str: string,\n x: number,\n y: number,\n paint: SkPaint,\n font: SkFont\n ): void;\n\n /**\n * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the\n * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.\n * @param blob\n * @param x\n * @param y\n * @param paint\n */\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;\n\n /**\n * Draws a run of glyphs, at corresponding positions, in a given font.\n * @param glyphs the array of glyph IDs (Uint16TypedArray)\n * @param positions the array of x,y floats to position each glyph\n * @param x x-coordinate of the origin of the entire run\n * @param y y-coordinate of the origin of the entire run\n * @param font the font that contains the glyphs\n * @param paint\n */\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ): void;\n\n /**\n * Renders the SVG Dom object to the canvas. If width/height are omitted,\n * the SVG will be rendered to fit the canvas.\n */\n drawSvg: (svgDom: SkSVG, width?: number, height?: number) => void;\n /** Saves SkMatrix and clip.\n Calling restore() discards changes to SkMatrix and clip,\n restoring the SkMatrix and clip to their state when save() was called.\n\n SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),\n and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().\n\n Saved SkCanvas state is put on a stack; multiple calls to save() should be balance\n by an equal number of calls to restore().\n\n Call restoreToCount() with result to restore this and subsequent saves.\n\n @return depth of saved stack\n\n example: https://fiddle.skia.org/c/@Canvas_save\n */\n save: () => number;\n\n /**\n * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.\n * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.\n * It returns the height of the stack.\n * See Canvas.h for more.\n * @param paint\n * @param bounds\n * @param backdrop\n * @param flags\n */\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ): number;\n\n /** Removes changes to SkMatrix and clip since SkCanvas state was\n last saved. The state is removed from the stack.\n\n Does nothing if the stack is empty.\n\n example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore\n\n example: https://fiddle.skia.org/c/@Canvas_restore\n */\n restore: () => void;\n\n /**\n * Rotates the current matrix by the number of degrees.\n * @param rot - angle of rotation in degrees.\n * @param rx\n * @param ry\n */\n rotate(rotationInDegrees: number, rx: number, ry: number): void;\n\n /**\n * Scales the current matrix by sx on the x-axis and sy on the y-axis.\n * @param sx\n * @param sy\n */\n scale(sx: number, sy: number): void;\n\n /**\n * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx\n * skews the drawing right as y-axis values increase; a positive value of sy skews\n * the drawing down as x-axis values increase.\n * @param sx\n * @param sy\n */\n skew(sx: number, sy: number): void;\n\n /**\n * Translates Matrix by dx along the x-axis and dy along the y-axis.\n * @param dx\n * @param dy\n */\n translate(dx: number, dy: number): void;\n\n /**\n * Fills clip with the given color.\n * @param color\n * @param blendMode - defaults to SrcOver.\n */\n drawColor(color: SkColor, blendMode?: BlendMode): void;\n\n /**\n * Fills the current clip with the given color using Src BlendMode.\n * This has the effect of replacing all pixels contained by clip with color.\n * @param color\n */\n clear(color: SkColor): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and path,\n * with an aliased or anti-aliased clip edge.\n * @param path\n * @param op\n * @param doAntiAlias\n */\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rect,\n * with an aliased or anti-aliased clip edge.\n * @param rect\n * @param op\n * @param doAntiAlias\n */\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rrect,\n * with an aliased or anti-aliased clip edge.\n * @param rrect\n * @param op\n * @param doAntiAlias\n */\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces current matrix with m premultiplied with the existing matrix.\n * @param m\n */\n concat(m: InputMatrix): void;\n\n /**\n * Draws the given picture using the current clip, current matrix, and the provided paint.\n * @param skp\n */\n drawPicture(skp: SkPicture): void;\n\n /** Read Image pixels\n *\n * @param srcX - x-axis upper left corner of the rectangle to read from\n * @param srcY - y-axis upper left corner of the rectangle to read from\n * @param imageInfo - describes the pixel format and dimensions of the data to read into\n * @return Float32Array or Uint8Array with data or null if the read failed.\n */\n readPixels(\n srcX: number,\n srcY: number,\n imageInfo: ImageInfo\n ): Float32Array | Uint8Array | null;\n}\n"],"mappings":";;;;;;IAgBYA,M;;;WAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,sBAAAA,M;;IAKAC,a;;;WAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a"}
@@ -1,20 +1,9 @@
1
1
  import type { SkJSIInstance } from "./JsiInstance";
2
2
  import type { SkCanvas } from "./Canvas";
3
- import type { Transforms3d } from "./Matrix4";
4
- export declare enum MatrixIndex {
5
- ScaleX = 0,
6
- SkewX = 1,
7
- TransX = 2,
8
- SkewY = 3,
9
- ScaleY = 4,
10
- TransY = 5,
11
- Persp0 = 6,
12
- Persp1 = 7,
13
- Persp2 = 8
14
- }
3
+ import type { Matrix3, Matrix4, Transforms3d } from "./Matrix4";
15
4
  export declare const isMatrix: (obj: unknown) => obj is SkMatrix;
16
5
  export interface SkMatrix extends SkJSIInstance<"Matrix"> {
17
- concat: (matrix: SkMatrix | number[]) => SkMatrix;
6
+ concat: (matrix: InputMatrix) => SkMatrix;
18
7
  translate: (x: number, y: number) => SkMatrix;
19
8
  scale: (x: number, y?: number) => SkMatrix;
20
9
  skew: (x: number, y: number) => SkMatrix;
@@ -26,6 +15,7 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
26
15
  identity: () => SkMatrix;
27
16
  get: () => number[];
28
17
  }
18
+ export type InputMatrix = SkMatrix | Matrix3 | Matrix4 | number[];
29
19
  export interface TransformProp {
30
20
  transform?: Transforms3d;
31
21
  }
@@ -3,25 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.toDegrees = exports.processTransform = exports.isMatrix = exports.MatrixIndex = void 0;
6
+ exports.toDegrees = exports.processTransform = exports.isMatrix = void 0;
7
7
 
8
8
  var _Matrix = require("./Matrix4");
9
9
 
10
- let MatrixIndex;
11
- exports.MatrixIndex = MatrixIndex;
12
-
13
- (function (MatrixIndex) {
14
- MatrixIndex[MatrixIndex["ScaleX"] = 0] = "ScaleX";
15
- MatrixIndex[MatrixIndex["SkewX"] = 1] = "SkewX";
16
- MatrixIndex[MatrixIndex["TransX"] = 2] = "TransX";
17
- MatrixIndex[MatrixIndex["SkewY"] = 3] = "SkewY";
18
- MatrixIndex[MatrixIndex["ScaleY"] = 4] = "ScaleY";
19
- MatrixIndex[MatrixIndex["TransY"] = 5] = "TransY";
20
- MatrixIndex[MatrixIndex["Persp0"] = 6] = "Persp0";
21
- MatrixIndex[MatrixIndex["Persp1"] = 7] = "Persp1";
22
- MatrixIndex[MatrixIndex["Persp2"] = 8] = "Persp2";
23
- })(MatrixIndex || (exports.MatrixIndex = MatrixIndex = {}));
24
-
25
10
  const isMatrix = obj => obj !== null && obj.__typename__ === "Matrix";
26
11
 
27
12
  exports.isMatrix = isMatrix;
@@ -1 +1 @@
1
- {"version":3,"names":["MatrixIndex","isMatrix","obj","__typename__","processTransform","m","transforms","m3","processTransform3d","concat","toDegrees","rad","Math","PI"],"sources":["Matrix.ts"],"sourcesContent":["import type { SkJSIInstance } from \"./JsiInstance\";\nimport type { SkCanvas } from \"./Canvas\";\nimport type { Transforms3d } from \"./Matrix4\";\nimport { processTransform3d } from \"./Matrix4\";\nexport enum MatrixIndex {\n ScaleX = 0,\n SkewX = 1,\n TransX = 2,\n SkewY = 3,\n ScaleY = 4,\n TransY = 5,\n Persp0 = 6,\n Persp1 = 7,\n Persp2 = 8,\n}\n\nexport const isMatrix = (obj: unknown): obj is SkMatrix =>\n obj !== null && (obj as SkJSIInstance<string>).__typename__ === \"Matrix\";\n\nexport interface SkMatrix extends SkJSIInstance<\"Matrix\"> {\n concat: (matrix: SkMatrix | number[]) => SkMatrix;\n translate: (x: number, y: number) => SkMatrix;\n scale: (x: number, y?: number) => SkMatrix;\n skew: (x: number, y: number) => SkMatrix;\n rotate: (theta: number) => SkMatrix;\n postTranslate: (x: number, y: number) => SkMatrix;\n postScale: (x: number, y?: number) => SkMatrix;\n postSkew: (x: number, y: number) => SkMatrix;\n postRotate: (theta: number) => SkMatrix;\n identity: () => SkMatrix;\n get: () => number[];\n}\n\nexport interface TransformProp {\n transform?: Transforms3d;\n}\n\nexport const processTransform = <T extends SkMatrix | SkCanvas>(\n m: T,\n transforms: Transforms3d\n) => {\n const m3 = processTransform3d(transforms);\n m.concat(m3);\n return m;\n};\n\nexport const toDegrees = (rad: number) => {\n return (rad * 180) / Math.PI;\n};\n"],"mappings":";;;;;;;AAGA;;IACYA,W;;;WAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W;;AAYL,MAAMC,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAiBA,GAAD,CAA+BC,YAA/B,KAAgD,QAD3D;;;;AAqBA,MAAMC,gBAAgB,GAAG,CAC9BC,CAD8B,EAE9BC,UAF8B,KAG3B;EACH,MAAMC,EAAE,GAAG,IAAAC,0BAAA,EAAmBF,UAAnB,CAAX;EACAD,CAAC,CAACI,MAAF,CAASF,EAAT;EACA,OAAOF,CAAP;AACD,CAPM;;;;AASA,MAAMK,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAQA,GAAG,GAAG,GAAP,GAAcC,IAAI,CAACC,EAA1B;AACD,CAFM"}
1
+ {"version":3,"names":["isMatrix","obj","__typename__","processTransform","m","transforms","m3","processTransform3d","concat","toDegrees","rad","Math","PI"],"sources":["Matrix.ts"],"sourcesContent":["import type { SkJSIInstance } from \"./JsiInstance\";\nimport type { SkCanvas } from \"./Canvas\";\nimport type { Matrix3, Matrix4, Transforms3d } from \"./Matrix4\";\nimport { processTransform3d } from \"./Matrix4\";\n\nexport const isMatrix = (obj: unknown): obj is SkMatrix =>\n obj !== null && (obj as SkJSIInstance<string>).__typename__ === \"Matrix\";\n\nexport interface SkMatrix extends SkJSIInstance<\"Matrix\"> {\n concat: (matrix: InputMatrix) => SkMatrix;\n translate: (x: number, y: number) => SkMatrix;\n scale: (x: number, y?: number) => SkMatrix;\n skew: (x: number, y: number) => SkMatrix;\n rotate: (theta: number) => SkMatrix;\n postTranslate: (x: number, y: number) => SkMatrix;\n postScale: (x: number, y?: number) => SkMatrix;\n postSkew: (x: number, y: number) => SkMatrix;\n postRotate: (theta: number) => SkMatrix;\n identity: () => SkMatrix;\n get: () => number[];\n}\n\nexport type InputMatrix = SkMatrix | Matrix3 | Matrix4 | number[];\n\nexport interface TransformProp {\n transform?: Transforms3d;\n}\n\nexport const processTransform = <T extends SkMatrix | SkCanvas>(\n m: T,\n transforms: Transforms3d\n) => {\n const m3 = processTransform3d(transforms);\n m.concat(m3);\n return m;\n};\n\nexport const toDegrees = (rad: number) => {\n return (rad * 180) / Math.PI;\n};\n"],"mappings":";;;;;;;AAGA;;AAEO,MAAMA,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAiBA,GAAD,CAA+BC,YAA/B,KAAgD,QAD3D;;;;AAuBA,MAAMC,gBAAgB,GAAG,CAC9BC,CAD8B,EAE9BC,UAF8B,KAG3B;EACH,MAAMC,EAAE,GAAG,IAAAC,0BAAA,EAAmBF,UAAnB,CAAX;EACAD,CAAC,CAACI,MAAF,CAASF,EAAT;EACA,OAAOF,CAAP;AACD,CAPM;;;;AASA,MAAMK,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAQA,GAAG,GAAG,GAAP,GAAcC,IAAI,CAACC,EAA1B;AACD,CAFM"}