@shopify/react-native-skia 0.1.227 → 0.1.228

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/cpp/api/JsiSkCanvas.h +2 -1
  2. package/cpp/api/JsiSkMatrix.h +27 -11
  3. package/cpp/api/JsiSkTypeface.h +1 -0
  4. package/cpp/rnskia/dom/props/MatrixProp.h +14 -3
  5. package/lib/commonjs/dom/types/Common.d.ts +2 -2
  6. package/lib/commonjs/dom/types/Common.js.map +1 -1
  7. package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -0
  8. package/lib/commonjs/external/reanimated/interpolators.js +16 -3
  9. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  10. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -1
  11. package/lib/commonjs/external/reanimated/moduleWrapper.js +9 -7
  12. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  13. package/lib/commonjs/skia/core/Vector.d.ts +0 -5
  14. package/lib/commonjs/skia/core/Vector.js +1 -17
  15. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  16. package/lib/commonjs/skia/types/Matrix.d.ts +2 -13
  17. package/lib/commonjs/skia/types/Matrix.js +1 -16
  18. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  19. package/lib/commonjs/skia/types/Matrix4.d.ts +51 -0
  20. package/lib/commonjs/skia/types/Matrix4.js +111 -12
  21. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  22. package/lib/commonjs/skia/web/Host.d.ts +2 -3
  23. package/lib/commonjs/skia/web/Host.js +4 -12
  24. package/lib/commonjs/skia/web/Host.js.map +1 -1
  25. package/lib/commonjs/skia/web/JsiSkCanvas.js +12 -12
  26. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  27. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  28. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  29. package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
  30. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  32. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  33. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  34. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  35. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
  36. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  37. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  38. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  39. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
  40. package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
  41. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  43. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
  45. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  46. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
  47. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  49. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  51. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  52. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  53. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  54. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
  55. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  56. package/lib/module/dom/types/Common.d.ts +2 -2
  57. package/lib/module/dom/types/Common.js.map +1 -1
  58. package/lib/module/external/reanimated/interpolators.d.ts +1 -0
  59. package/lib/module/external/reanimated/interpolators.js +14 -4
  60. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  61. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
  62. package/lib/module/external/reanimated/moduleWrapper.js +7 -6
  63. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  64. package/lib/module/skia/core/Vector.d.ts +0 -5
  65. package/lib/module/skia/core/Vector.js +0 -13
  66. package/lib/module/skia/core/Vector.js.map +1 -1
  67. package/lib/module/skia/types/Matrix.d.ts +2 -13
  68. package/lib/module/skia/types/Matrix.js +0 -14
  69. package/lib/module/skia/types/Matrix.js.map +1 -1
  70. package/lib/module/skia/types/Matrix4.d.ts +51 -0
  71. package/lib/module/skia/types/Matrix4.js +90 -16
  72. package/lib/module/skia/types/Matrix4.js.map +1 -1
  73. package/lib/module/skia/web/Host.d.ts +2 -3
  74. package/lib/module/skia/web/Host.js +2 -7
  75. package/lib/module/skia/web/Host.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkCanvas.js +13 -13
  77. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  78. package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
  79. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  80. package/lib/module/skia/web/JsiSkFont.js +3 -3
  81. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  82. package/lib/module/skia/web/JsiSkImage.js +7 -7
  83. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  84. package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
  85. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  86. package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
  87. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
  89. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  90. package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
  91. package/lib/module/skia/web/JsiSkMatrix.js +6 -1
  92. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  93. package/lib/module/skia/web/JsiSkPaint.js +4 -4
  94. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  95. package/lib/module/skia/web/JsiSkPath.js +5 -5
  96. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  97. package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
  98. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  99. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  100. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  101. package/lib/module/skia/web/JsiSkPicture.js +2 -2
  102. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  103. package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
  104. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  105. package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
  106. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  107. package/lib/typescript/src/dom/types/Common.d.ts +2 -2
  108. package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
  109. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
  110. package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
  111. package/lib/typescript/src/skia/types/Matrix.d.ts +2 -13
  112. package/lib/typescript/src/skia/types/Matrix4.d.ts +51 -0
  113. package/lib/typescript/src/skia/web/Host.d.ts +2 -3
  114. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
  115. package/package.json +2 -1
  116. package/src/dom/types/Common.ts +3 -1
  117. package/src/external/reanimated/interpolators.ts +20 -5
  118. package/src/external/reanimated/moduleWrapper.ts +6 -0
  119. package/src/skia/core/Vector.ts +0 -7
  120. package/src/skia/types/Matrix.ts +2 -13
  121. package/src/skia/types/Matrix4.ts +96 -18
  122. package/src/skia/web/Host.ts +4 -3
  123. package/src/skia/web/JsiSkCanvas.ts +22 -15
  124. package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
  125. package/src/skia/web/JsiSkFont.ts +3 -3
  126. package/src/skia/web/JsiSkImage.ts +14 -11
  127. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  128. package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
  129. package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
  130. package/src/skia/web/JsiSkMatrix.ts +12 -3
  131. package/src/skia/web/JsiSkPaint.ts +4 -4
  132. package/src/skia/web/JsiSkPath.ts +8 -5
  133. package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
  134. package/src/skia/web/JsiSkPathFactory.ts +2 -2
  135. package/src/skia/web/JsiSkPicture.ts +4 -4
  136. package/src/skia/web/JsiSkShaderFactory.ts +6 -6
  137. package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
@@ -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, Matrix3, Matrix4, PaintStyle, SkMatrix, 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?: SkMatrix | Matrix4 | Matrix3 | number[];
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 Matrix3,\n Matrix4,\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 | Matrix4 | Matrix3 | 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,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"}
@@ -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"}
@@ -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: SkMatrix | Matrix4 | Matrix3 | number[]) => 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;
@@ -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: SkMatrix | Matrix4 | Matrix3 | 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;;AAEO,MAAMA,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,5 +1,20 @@
1
+ type Point = {
2
+ x: number;
3
+ y: number;
4
+ };
1
5
  type Vec2 = readonly [number, number];
2
6
  type Vec3 = readonly [number, number, number];
7
+ export type Matrix3 = readonly [
8
+ number,
9
+ number,
10
+ number,
11
+ number,
12
+ number,
13
+ number,
14
+ number,
15
+ number,
16
+ number
17
+ ];
3
18
  export type Matrix4 = readonly [
4
19
  number,
5
20
  number,
@@ -28,10 +43,46 @@ export type Transforms3d = Transform3d[];
28
43
  * @worklet
29
44
  */
30
45
  export declare const Matrix4: () => Matrix4;
46
+ /**
47
+ * @worklet
48
+ */
49
+ export declare const translate: (x: number, y: number, z?: number) => Matrix4;
50
+ /**
51
+ * @worklet
52
+ */
53
+ export declare const perspective: (p: number) => Matrix4;
31
54
  /**
32
55
  * @worklet
33
56
  */
34
57
  export declare const mapPoint3d: (m: Matrix4, v: Vec3) => readonly [number, number, number];
58
+ /**
59
+ * @worklet
60
+ */
61
+ export declare const multiply4: (a: Matrix4, b: Matrix4) => Matrix4;
62
+ /**
63
+ * @worklet
64
+ */
65
+ export declare const toMatrix3: (m: Matrix4) => number[];
66
+ /**
67
+ * @worklet
68
+ */
69
+ export declare const pivot: (m: Matrix4, p: Point) => Matrix4;
70
+ /**
71
+ * @worklet
72
+ */
73
+ export declare const scale: (sx: number, sy: number, sz?: number, p?: Point) => Matrix4;
74
+ /**
75
+ * @worklet
76
+ */
77
+ export declare const rotateZ: (value: number, p?: Point) => Matrix4;
78
+ /**
79
+ * @worklet
80
+ */
81
+ export declare const rotateX: (value: number, p?: Point) => Matrix4;
82
+ /**
83
+ * @worklet
84
+ */
85
+ export declare const rotateY: (value: number, p?: Point) => Matrix4;
35
86
  /**
36
87
  * @worklet
37
88
  */
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.processTransform3d = exports.mapPoint3d = exports.Matrix4 = void 0;
6
+ exports.translate = exports.toMatrix3 = exports.scale = exports.rotateZ = exports.rotateY = exports.rotateX = exports.processTransform3d = exports.pivot = exports.perspective = exports.multiply4 = exports.mapPoint3d = exports.Matrix4 = void 0;
7
7
 
8
8
  const exhaustiveCheck = a => {
9
9
  "worklet";
@@ -20,20 +20,25 @@ const Matrix4 = () => {
20
20
 
21
21
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
22
22
  };
23
+ /**
24
+ * @worklet
25
+ */
26
+
23
27
 
24
28
  exports.Matrix4 = Matrix4;
25
29
 
26
- const translate = (x, y, z) => {
30
+ const translate = function (x, y) {
27
31
  "worklet";
28
32
 
33
+ let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
29
34
  return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];
30
35
  };
36
+ /**
37
+ * @worklet
38
+ */
31
39
 
32
- const scale = (sx, sy, sz) => {
33
- "worklet";
34
40
 
35
- return [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];
36
- };
41
+ exports.translate = translate;
37
42
 
38
43
  const perspective = p => {
39
44
  "worklet";
@@ -41,6 +46,8 @@ const perspective = p => {
41
46
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];
42
47
  };
43
48
 
49
+ exports.perspective = perspective;
50
+
44
51
  const normalizeVec = vec => {
45
52
  "worklet";
46
53
 
@@ -66,12 +73,6 @@ const rotatedUnitSinCos = (axisVec, sinAngle, cosAngle) => {
66
73
  return [t * x * x + c, t * x * y - s * z, t * x * z + s * y, 0, t * x * y + s * z, t * y * y + c, t * y * z - s * x, 0, t * x * z - s * y, t * y * z + s * x, t * z * z + c, 0, 0, 0, 0, 1];
67
74
  };
68
75
 
69
- const rotate = (axis, value) => {
70
- "worklet";
71
-
72
- return rotatedUnitSinCos(normalizeVec(axis), Math.sin(value), Math.cos(value));
73
- };
74
-
75
76
  const matrixVecMul4 = (m, v) => {
76
77
  "worklet";
77
78
 
@@ -89,6 +90,10 @@ const mapPoint3d = (m, v) => {
89
90
  const r = matrixVecMul4(m, [...v, 1]);
90
91
  return [r[0] / r[3], r[1] / r[3], r[2] / r[3]];
91
92
  };
93
+ /**
94
+ * @worklet
95
+ */
96
+
92
97
 
93
98
  exports.mapPoint3d = mapPoint3d;
94
99
 
@@ -106,6 +111,8 @@ const multiply4 = (a, b) => {
106
111
  return result;
107
112
  };
108
113
 
114
+ exports.multiply4 = multiply4;
115
+
109
116
  const skewY = angle => {
110
117
  "worklet";
111
118
 
@@ -117,17 +124,109 @@ const skewX = angle => {
117
124
 
118
125
  return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
119
126
  };
127
+ /**
128
+ * @worklet
129
+ */
130
+
120
131
 
121
132
  const toMatrix3 = m => {
122
133
  "worklet";
123
134
 
124
135
  return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];
125
136
  };
137
+
138
+ exports.toMatrix3 = toMatrix3;
139
+
140
+ const rotate = (axis, value) => {
141
+ "worklet";
142
+
143
+ return rotatedUnitSinCos(normalizeVec(axis), Math.sin(value), Math.cos(value));
144
+ };
145
+ /**
146
+ * @worklet
147
+ */
148
+
149
+
150
+ const pivot = (m, p) => {
151
+ "worklet";
152
+
153
+ return multiply4(translate(p.x, p.y), multiply4(m, translate(-p.x, -p.y)));
154
+ };
155
+ /**
156
+ * @worklet
157
+ */
158
+
159
+
160
+ exports.pivot = pivot;
161
+
162
+ const scale = function (sx, sy) {
163
+ "worklet";
164
+
165
+ let sz = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
166
+ let p = arguments.length > 3 ? arguments[3] : undefined;
167
+ const m4 = [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];
168
+
169
+ if (p) {
170
+ return pivot(m4, p);
171
+ }
172
+
173
+ return m4;
174
+ };
175
+
176
+ exports.scale = scale;
177
+
178
+ const rotateAxis = (axis, angle, p) => {
179
+ "worklet";
180
+
181
+ const result = rotate(axis, angle);
182
+
183
+ if (p) {
184
+ return pivot(result, p);
185
+ }
186
+
187
+ return result;
188
+ };
189
+ /**
190
+ * @worklet
191
+ */
192
+
193
+
194
+ const rotateZ = (value, p) => {
195
+ "worklet";
196
+
197
+ return rotateAxis([0, 0, 1], value, p);
198
+ };
199
+ /**
200
+ * @worklet
201
+ */
202
+
203
+
204
+ exports.rotateZ = rotateZ;
205
+
206
+ const rotateX = (value, p) => {
207
+ "worklet";
208
+
209
+ return rotateAxis([1, 0, 0], value, p);
210
+ };
126
211
  /**
127
212
  * @worklet
128
213
  */
129
214
 
130
215
 
216
+ exports.rotateX = rotateX;
217
+
218
+ const rotateY = (value, p) => {
219
+ "worklet";
220
+
221
+ return rotateAxis([0, 1, 0], value, p);
222
+ };
223
+ /**
224
+ * @worklet
225
+ */
226
+
227
+
228
+ exports.rotateY = rotateY;
229
+
131
230
  const processTransform3d = transforms => {
132
231
  "worklet";
133
232