@shopify/react-native-skia 0.1.227 → 0.1.228

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. package/cpp/api/JsiSkCanvas.h +2 -1
  2. package/cpp/api/JsiSkMatrix.h +27 -11
  3. package/cpp/api/JsiSkTypeface.h +1 -0
  4. package/cpp/rnskia/dom/props/MatrixProp.h +14 -3
  5. package/lib/commonjs/dom/types/Common.d.ts +2 -2
  6. package/lib/commonjs/dom/types/Common.js.map +1 -1
  7. package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -0
  8. package/lib/commonjs/external/reanimated/interpolators.js +16 -3
  9. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  10. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -1
  11. package/lib/commonjs/external/reanimated/moduleWrapper.js +9 -7
  12. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  13. package/lib/commonjs/skia/core/Vector.d.ts +0 -5
  14. package/lib/commonjs/skia/core/Vector.js +1 -17
  15. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  16. package/lib/commonjs/skia/types/Matrix.d.ts +2 -13
  17. package/lib/commonjs/skia/types/Matrix.js +1 -16
  18. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  19. package/lib/commonjs/skia/types/Matrix4.d.ts +51 -0
  20. package/lib/commonjs/skia/types/Matrix4.js +111 -12
  21. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  22. package/lib/commonjs/skia/web/Host.d.ts +2 -3
  23. package/lib/commonjs/skia/web/Host.js +4 -12
  24. package/lib/commonjs/skia/web/Host.js.map +1 -1
  25. package/lib/commonjs/skia/web/JsiSkCanvas.js +12 -12
  26. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  27. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  28. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  29. package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
  30. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  32. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  33. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  34. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  35. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
  36. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  37. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  38. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  39. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
  40. package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
  41. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  43. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
  45. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  46. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
  47. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  49. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  51. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  52. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  53. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  54. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
  55. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  56. package/lib/module/dom/types/Common.d.ts +2 -2
  57. package/lib/module/dom/types/Common.js.map +1 -1
  58. package/lib/module/external/reanimated/interpolators.d.ts +1 -0
  59. package/lib/module/external/reanimated/interpolators.js +14 -4
  60. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  61. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
  62. package/lib/module/external/reanimated/moduleWrapper.js +7 -6
  63. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  64. package/lib/module/skia/core/Vector.d.ts +0 -5
  65. package/lib/module/skia/core/Vector.js +0 -13
  66. package/lib/module/skia/core/Vector.js.map +1 -1
  67. package/lib/module/skia/types/Matrix.d.ts +2 -13
  68. package/lib/module/skia/types/Matrix.js +0 -14
  69. package/lib/module/skia/types/Matrix.js.map +1 -1
  70. package/lib/module/skia/types/Matrix4.d.ts +51 -0
  71. package/lib/module/skia/types/Matrix4.js +90 -16
  72. package/lib/module/skia/types/Matrix4.js.map +1 -1
  73. package/lib/module/skia/web/Host.d.ts +2 -3
  74. package/lib/module/skia/web/Host.js +2 -7
  75. package/lib/module/skia/web/Host.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkCanvas.js +13 -13
  77. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  78. package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
  79. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  80. package/lib/module/skia/web/JsiSkFont.js +3 -3
  81. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  82. package/lib/module/skia/web/JsiSkImage.js +7 -7
  83. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  84. package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
  85. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  86. package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
  87. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
  89. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  90. package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
  91. package/lib/module/skia/web/JsiSkMatrix.js +6 -1
  92. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  93. package/lib/module/skia/web/JsiSkPaint.js +4 -4
  94. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  95. package/lib/module/skia/web/JsiSkPath.js +5 -5
  96. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  97. package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
  98. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  99. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  100. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  101. package/lib/module/skia/web/JsiSkPicture.js +2 -2
  102. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  103. package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
  104. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  105. package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
  106. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  107. package/lib/typescript/src/dom/types/Common.d.ts +2 -2
  108. package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
  109. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
  110. package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
  111. package/lib/typescript/src/skia/types/Matrix.d.ts +2 -13
  112. package/lib/typescript/src/skia/types/Matrix4.d.ts +51 -0
  113. package/lib/typescript/src/skia/web/Host.d.ts +2 -3
  114. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
  115. package/package.json +2 -1
  116. package/src/dom/types/Common.ts +3 -1
  117. package/src/external/reanimated/interpolators.ts +20 -5
  118. package/src/external/reanimated/moduleWrapper.ts +6 -0
  119. package/src/skia/core/Vector.ts +0 -7
  120. package/src/skia/types/Matrix.ts +2 -13
  121. package/src/skia/types/Matrix4.ts +96 -18
  122. package/src/skia/web/Host.ts +4 -3
  123. package/src/skia/web/JsiSkCanvas.ts +22 -15
  124. package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
  125. package/src/skia/web/JsiSkFont.ts +3 -3
  126. package/src/skia/web/JsiSkImage.ts +14 -11
  127. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  128. package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
  129. package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
  130. package/src/skia/web/JsiSkMatrix.ts +12 -3
  131. package/src/skia/web/JsiSkPaint.ts +4 -4
  132. package/src/skia/web/JsiSkPath.ts +8 -5
  133. package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
  134. package/src/skia/web/JsiSkPathFactory.ts +2 -2
  135. package/src/skia/web/JsiSkPicture.ts +4 -4
  136. package/src/skia/web/JsiSkShaderFactory.ts +6 -6
  137. package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
@@ -1,7 +1,7 @@
1
- import { useMemo, useRef } from "react";
1
+ import { useCallback, useMemo } from "react";
2
2
  import { interpolatePaths, interpolateVector } from "../../animation";
3
3
  import { Skia } from "../../skia";
4
- import { useAnimatedReaction, useFrameCallback, useSharedValue } from "./moduleWrapper";
4
+ import { useAnimatedReaction, useFrameCallback, useSharedValue, useDerivedValue } from "./moduleWrapper";
5
5
  export const notifyChange = value => {
6
6
  "worklet";
7
7
 
@@ -10,13 +10,23 @@ export const notifyChange = value => {
10
10
  value._value = value.value;
11
11
  }
12
12
  };
13
+ export const usePathValue = cb => {
14
+ const pathInit = useMemo(() => Skia.Path.Make(), []);
15
+ const path = useSharedValue(pathInit);
16
+ useDerivedValue(() => {
17
+ path.value.reset();
18
+ cb(path.value);
19
+ notifyChange(path);
20
+ });
21
+ return path;
22
+ };
13
23
  export const useClock = () => {
14
24
  const clock = useSharedValue(0);
15
- const callback = useRef(info => {
25
+ const callback = useCallback(info => {
16
26
  "worklet";
17
27
 
18
28
  clock.value = info.timeSinceFirstFrame;
19
- }).current;
29
+ }, [clock]);
20
30
  useFrameCallback(callback);
21
31
  return clock;
22
32
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useRef","interpolatePaths","interpolateVector","Skia","useAnimatedReaction","useFrameCallback","useSharedValue","notifyChange","value","_WORKLET","_value","useClock","clock","callback","info","timeSinceFirstFrame","current","useInterpolator","factory","interpolator","input","output","options","init","result","val","usePathInterpolation","outputRange","Path","Make","useVectorInterpolation","Point"],"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,SAASA,OAAT,EAAkBC,MAAlB,QAAgC,OAAhC;AAGA,SAASC,gBAAT,EAA2BC,iBAA3B,QAAoD,iBAApD;AACA,SAASC,IAAT,QAAqB,YAArB;AAEA,SACEC,mBADF,EAEEC,gBAFF,EAGEC,cAHF,QAIO,iBAJP;AAMA,OAAO,MAAMC,YAAY,GAAIC,KAAD,IAAiC;EAC3D;;EACA,IAAIC,QAAJ,EAAc;IACZ;IACCD,KAAD,CAAeE,MAAf,GAAwBF,KAAK,CAACA,KAA9B;EACD;AACF,CANM;AAQP,OAAO,MAAMG,QAAQ,GAAG,MAAM;EAC5B,MAAMC,KAAK,GAAGN,cAAc,CAAC,CAAD,CAA5B;EACA,MAAMO,QAAQ,GAAGb,MAAM,CAAEc,IAAD,IAAqB;IAC3C;;IACAF,KAAK,CAACJ,KAAN,GAAcM,IAAI,CAACC,mBAAnB;EACD,CAHsB,CAAN,CAGdC,OAHH;EAIAX,gBAAgB,CAACQ,QAAD,CAAhB;EACA,OAAOD,KAAP;AACD,CARM;AAUP;AACA;AACA;;AASA,MAAMK,eAAe,GAAG,CACtBC,OADsB,EAEtBV,KAFsB,EAGtBW,YAHsB,EAItBC,KAJsB,EAKtBC,MALsB,EAMtBC,OANsB,KAOnB;EACH;EACA,MAAMC,IAAI,GAAGxB,OAAO,CAAC,MAAMmB,OAAO,EAAd,EAAkB,EAAlB,CAApB;EACA,MAAMM,MAAM,GAAGlB,cAAc,CAACiB,IAAD,CAA7B;EACAnB,mBAAmB,CACjB,MAAMI,KAAK,CAACA,KADK,EAEhBiB,GAAD,IAAS;IACPD,MAAM,CAAChB,KAAP,GAAeW,YAAY,CAACM,GAAD,EAAML,KAAN,EAAaC,MAAb,EAAqBC,OAArB,EAA8BE,MAAM,CAAChB,KAArC,CAA3B;IACAD,YAAY,CAACiB,MAAD,CAAZ;EACD,CALgB,EAMjB,CAACJ,KAAD,EAAQC,MAAR,EAAgBC,OAAhB,CANiB,CAAnB;EAQA,OAAOE,MAAP;AACD,CApBD;;AAsBA,OAAO,MAAME,oBAAoB,GAAG,CAClClB,KADkC,EAElCY,KAFkC,EAGlCO,WAHkC,EAIlCL,OAJkC,KAMlCL,eAAe,CACb,MAAMd,IAAI,CAACyB,IAAL,CAAUC,IAAV,EADO,EAEbrB,KAFa,EAGbP,gBAHa,EAIbmB,KAJa,EAKbO,WALa,EAMbL,OANa,CANV;AAeP,OAAO,MAAMQ,sBAAsB,GAAG,CACpCtB,KADoC,EAEpCY,KAFoC,EAGpCO,WAHoC,EAIpCL,OAJoC,KAMpCL,eAAe,CACb,MAAMd,IAAI,CAAC4B,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEbvB,KAFa,EAGbN,iBAHa,EAIbkB,KAJa,EAKbO,WALa,EAMbL,OANa,CANV"}
1
+ {"version":3,"names":["useCallback","useMemo","interpolatePaths","interpolateVector","Skia","useAnimatedReaction","useFrameCallback","useSharedValue","useDerivedValue","notifyChange","value","_WORKLET","_value","usePathValue","cb","pathInit","Path","Make","path","reset","useClock","clock","callback","info","timeSinceFirstFrame","useInterpolator","factory","interpolator","input","output","options","init","result","val","usePathInterpolation","outputRange","useVectorInterpolation","Point"],"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,SAASA,WAAT,EAAsBC,OAAtB,QAAqC,OAArC;AAGA,SAASC,gBAAT,EAA2BC,iBAA3B,QAAoD,iBAApD;AACA,SAASC,IAAT,QAAqB,YAArB;AAEA,SACEC,mBADF,EAEEC,gBAFF,EA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IACPD,MAAM,CAACtB,KAAP,GAAeiB,YAAY,CAACM,GAAD,EAAML,KAAN,EAAaC,MAAb,EAAqBC,OAArB,EAA8BE,MAAM,CAACtB,KAArC,CAA3B;IACAD,YAAY,CAACuB,MAAD,CAAZ;EACD,CALgB,EAMjB,CAACJ,KAAD,EAAQC,MAAR,EAAgBC,OAAhB,CANiB,CAAnB;EAQA,OAAOE,MAAP;AACD,CApBD;;AAsBA,OAAO,MAAME,oBAAoB,GAAG,CAClCxB,KADkC,EAElCkB,KAFkC,EAGlCO,WAHkC,EAIlCL,OAJkC,KAMlCL,eAAe,CACb,MAAMrB,IAAI,CAACY,IAAL,CAAUC,IAAV,EADO,EAEbP,KAFa,EAGbR,gBAHa,EAIb0B,KAJa,EAKbO,WALa,EAMbL,OANa,CANV;AAeP,OAAO,MAAMM,sBAAsB,GAAG,CACpC1B,KADoC,EAEpCkB,KAFoC,EAGpCO,WAHoC,EAIpCL,OAJoC,KAMpCL,eAAe,CACb,MAAMrB,IAAI,CAACiC,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEb3B,KAFa,EAGbP,iBAHa,EAIbyB,KAJa,EAKbO,WALa,EAMbL,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;
@@ -1,4 +1,4 @@
1
- var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6;
1
+ var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7;
2
2
 
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
4
  // This one is needed for the deprecated useSharedValue function
@@ -25,11 +25,12 @@ export function throwOnMissingReanimated() {
25
25
  }
26
26
  }
27
27
  export const useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || throwOnMissingReanimated;
28
- export const useFrameCallback = ((_Reanimated2 = Reanimated2) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.useFrameCallback) || throwOnMissingReanimated;
29
- export const startMapper = ((_Reanimated3 = Reanimated2) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.startMapper) || throwOnMissingReanimated;
30
- export const stopMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.stopMapper) || throwOnMissingReanimated;
31
- export const runOnJS = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.runOnJS) || throwOnMissingReanimated;
32
- export const useAnimatedReaction = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.useAnimatedReaction) || throwOnMissingReanimated;
28
+ export const useDerivedValue = ((_Reanimated2 = Reanimated2) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.useDerivedValue) || throwOnMissingReanimated;
29
+ export const useFrameCallback = ((_Reanimated3 = Reanimated2) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.useFrameCallback) || throwOnMissingReanimated;
30
+ export const startMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.startMapper) || throwOnMissingReanimated;
31
+ export const stopMapper = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.stopMapper) || throwOnMissingReanimated;
32
+ export const runOnJS = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.runOnJS) || throwOnMissingReanimated;
33
+ export const useAnimatedReaction = ((_Reanimated7 = Reanimated2) === null || _Reanimated7 === void 0 ? void 0 : _Reanimated7.useAnimatedReaction) || throwOnMissingReanimated;
33
34
  export const isSharedValue = value => {
34
35
  return !!value && (Reanimated3 ? Reanimated3.isSharedValue(value) : value.value !== undefined);
35
36
  };
@@ -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;;AAEd,OAAO,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;AACP,OAAO,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;AAEP,OAAO,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;AAED,OAAO,MAAMC,cAGM,GAAG,gBAAAX,WAAW,UAAX,kDAAaW,cAAb,KAA+BF,wBAH9C;AAKP,OAAO,MAAMG,gBAGK,GAAG,iBAAAZ,WAAW,UAAX,oDAAaY,gBAAb,KAAiCH,wBAH/C;AAKP,OAAO,MAAMI,WAIF,GAAG,iBAAAb,WAAW,UAAX,oDAAaa,WAAb,KAA4BJ,wBAJnC;AAMP,OAAO,MAAMK,UAAsC,GACjD,iBAAAd,WAAW,UAAX,oDAAac,UAAb,KAA2BL,wBADtB;AAGP,OAAO,MAAMM,OAAO,GAAG,iBAAAf,WAAW,UAAX,oDAAae,OAAb,KAAwBN,wBAAxC;AAEP,OAAO,MAAMO,mBAIJ,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,mBAAb,KAAoCP,wBAJzC;AAMP,OAAO,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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: 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
- }];
@@ -27,17 +27,4 @@ export const dist = (a, b) => {
27
27
 
28
28
  return Math.hypot(a.x - b.x, a.y - b.y);
29
29
  };
30
- export const translate = _ref => {
31
- "worklet";
32
-
33
- let {
34
- x,
35
- y
36
- } = _ref;
37
- return [{
38
- translateX: x
39
- }, {
40
- translateY: y
41
- }];
42
- };
43
30
  //# sourceMappingURL=Vector.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Skia","vec","x","y","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,SAASA,IAAT,QAAqB,SAArB;AAGA,OAAO,MAAMC,GAAG,GAAG,YAAuB;EACxC;;EADwC,IAAtBC,CAAsB,uEAAlB,CAAkB;EAAA,IAAfC,CAAe;EAExC,OAAOH,IAAI,CAACI,KAAL,CAAWF,CAAX,EAAcC,CAAd,aAAcA,CAAd,cAAcA,CAAd,GAAmBD,CAAnB,CAAP;AACD,CAHM;AAIP,OAAO,MAAMG,KAAK,GAAGJ,GAAd;AACP,OAAO,MAAMK,GAAG,GAAIC,CAAD,IAAe;EAChC;;EACA,OAAON,GAAG,CAAC,CAACM,CAAC,CAACL,CAAJ,EAAO,CAACK,CAAC,CAACJ,CAAV,CAAV;AACD,CAHM;AAIP,OAAO,MAAMK,GAAG,GAAG,CAACD,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAT,EAAYK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAApB,CAAV;AACD,CAHM;AAIP,OAAO,MAAMO,GAAG,GAAG,CAACH,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAT,EAAYK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAApB,CAAV;AACD,CAHM;AAIP,OAAO,MAAMQ,IAAI,GAAG,CAACJ,CAAD,EAAYE,CAAZ,KAA0B;EAC5C;;EACA,OAAOG,IAAI,CAACC,KAAL,CAAWN,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAnB,EAAsBK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAA9B,CAAP;AACD,CAHM;AAIP,OAAO,MAAMW,SAAS,GAAG,QAGuC;EAC9D;;EAD8D,IAHtC;IACxBZ,CADwB;IAExBC;EAFwB,CAGsC;EAE9D,OAAO,CAAC;IAAEY,UAAU,EAAEb;EAAd,CAAD,EAAoB;IAAEc,UAAU,EAAEb;EAAd,CAApB,CAAP;AACD,CANM"}
1
+ {"version":3,"names":["Skia","vec","x","y","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,SAASA,IAAT,QAAqB,SAArB;AAGA,OAAO,MAAMC,GAAG,GAAG,YAAuB;EACxC;;EADwC,IAAtBC,CAAsB,uEAAlB,CAAkB;EAAA,IAAfC,CAAe;EAExC,OAAOH,IAAI,CAACI,KAAL,CAAWF,CAAX,EAAcC,CAAd,aAAcA,CAAd,cAAcA,CAAd,GAAmBD,CAAnB,CAAP;AACD,CAHM;AAIP,OAAO,MAAMG,KAAK,GAAGJ,GAAd;AACP,OAAO,MAAMK,GAAG,GAAIC,CAAD,IAAe;EAChC;;EACA,OAAON,GAAG,CAAC,CAACM,CAAC,CAACL,CAAJ,EAAO,CAACK,CAAC,CAACJ,CAAV,CAAV;AACD,CAHM;AAIP,OAAO,MAAMK,GAAG,GAAG,CAACD,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAT,EAAYK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAApB,CAAV;AACD,CAHM;AAIP,OAAO,MAAMO,GAAG,GAAG,CAACH,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAT,EAAYK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAApB,CAAV;AACD,CAHM;AAIP,OAAO,MAAMQ,IAAI,GAAG,CAACJ,CAAD,EAAYE,CAAZ,KAA0B;EAC5C;;EACA,OAAOG,IAAI,CAACC,KAAL,CAAWN,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAnB,EAAsBK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,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;
@@ -1,18 +1,4 @@
1
1
  import { processTransform3d } from "./Matrix4";
2
- export let MatrixIndex;
3
-
4
- (function (MatrixIndex) {
5
- MatrixIndex[MatrixIndex["ScaleX"] = 0] = "ScaleX";
6
- MatrixIndex[MatrixIndex["SkewX"] = 1] = "SkewX";
7
- MatrixIndex[MatrixIndex["TransX"] = 2] = "TransX";
8
- MatrixIndex[MatrixIndex["SkewY"] = 3] = "SkewY";
9
- MatrixIndex[MatrixIndex["ScaleY"] = 4] = "ScaleY";
10
- MatrixIndex[MatrixIndex["TransY"] = 5] = "TransY";
11
- MatrixIndex[MatrixIndex["Persp0"] = 6] = "Persp0";
12
- MatrixIndex[MatrixIndex["Persp1"] = 7] = "Persp1";
13
- MatrixIndex[MatrixIndex["Persp2"] = 8] = "Persp2";
14
- })(MatrixIndex || (MatrixIndex = {}));
15
-
16
2
  export const isMatrix = obj => obj !== null && obj.__typename__ === "Matrix";
17
3
  export const processTransform = (m, transforms) => {
18
4
  const m3 = processTransform3d(transforms);
@@ -1 +1 @@
1
- {"version":3,"names":["processTransform3d","MatrixIndex","isMatrix","obj","__typename__","processTransform","m","transforms","m3","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,SAASA,kBAAT,QAAmC,WAAnC;AACA,WAAYC,WAAZ;;WAAYA,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,KAAAA,W;;AAYZ,OAAO,MAAMC,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAiBA,GAAD,CAA+BC,YAA/B,KAAgD,QAD3D;AAqBP,OAAO,MAAMC,gBAAgB,GAAG,CAC9BC,CAD8B,EAE9BC,UAF8B,KAG3B;EACH,MAAMC,EAAE,GAAGR,kBAAkB,CAACO,UAAD,CAA7B;EACAD,CAAC,CAACG,MAAF,CAASD,EAAT;EACA,OAAOF,CAAP;AACD,CAPM;AASP,OAAO,MAAMI,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAQA,GAAG,GAAG,GAAP,GAAcC,IAAI,CAACC,EAA1B;AACD,CAFM"}
1
+ {"version":3,"names":["processTransform3d","isMatrix","obj","__typename__","processTransform","m","transforms","m3","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,SAASA,kBAAT,QAAmC,WAAnC;AAEA,OAAO,MAAMC,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAiBA,GAAD,CAA+BC,YAA/B,KAAgD,QAD3D;AAqBP,OAAO,MAAMC,gBAAgB,GAAG,CAC9BC,CAD8B,EAE9BC,UAF8B,KAG3B;EACH,MAAMC,EAAE,GAAGP,kBAAkB,CAACM,UAAD,CAA7B;EACAD,CAAC,CAACG,MAAF,CAASD,EAAT;EACA,OAAOF,CAAP;AACD,CAPM;AASP,OAAO,MAAMI,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
  */
@@ -13,20 +13,21 @@ export const Matrix4 = () => {
13
13
 
14
14
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
15
15
  };
16
+ /**
17
+ * @worklet
18
+ */
16
19
 
17
- const translate = (x, y, z) => {
20
+ export const translate = function (x, y) {
18
21
  "worklet";
19
22
 
23
+ let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
20
24
  return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];
21
25
  };
26
+ /**
27
+ * @worklet
28
+ */
22
29
 
23
- const scale = (sx, sy, sz) => {
24
- "worklet";
25
-
26
- return [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];
27
- };
28
-
29
- const perspective = p => {
30
+ export const perspective = p => {
30
31
  "worklet";
31
32
 
32
33
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];
@@ -57,12 +58,6 @@ const rotatedUnitSinCos = (axisVec, sinAngle, cosAngle) => {
57
58
  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];
58
59
  };
59
60
 
60
- const rotate = (axis, value) => {
61
- "worklet";
62
-
63
- return rotatedUnitSinCos(normalizeVec(axis), Math.sin(value), Math.cos(value));
64
- };
65
-
66
61
  const matrixVecMul4 = (m, v) => {
67
62
  "worklet";
68
63
 
@@ -80,8 +75,11 @@ export const mapPoint3d = (m, v) => {
80
75
  const r = matrixVecMul4(m, [...v, 1]);
81
76
  return [r[0] / r[3], r[1] / r[3], r[2] / r[3]];
82
77
  };
78
+ /**
79
+ * @worklet
80
+ */
83
81
 
84
- const multiply4 = (a, b) => {
82
+ export const multiply4 = (a, b) => {
85
83
  "worklet";
86
84
 
87
85
  const result = new Array(16).fill(0);
@@ -106,16 +104,92 @@ const skewX = angle => {
106
104
 
107
105
  return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
108
106
  };
107
+ /**
108
+ * @worklet
109
+ */
109
110
 
110
- const toMatrix3 = m => {
111
+
112
+ export const toMatrix3 = m => {
111
113
  "worklet";
112
114
 
113
115
  return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];
114
116
  };
117
+
118
+ const rotate = (axis, value) => {
119
+ "worklet";
120
+
121
+ return rotatedUnitSinCos(normalizeVec(axis), Math.sin(value), Math.cos(value));
122
+ };
123
+ /**
124
+ * @worklet
125
+ */
126
+
127
+
128
+ export const pivot = (m, p) => {
129
+ "worklet";
130
+
131
+ return multiply4(translate(p.x, p.y), multiply4(m, translate(-p.x, -p.y)));
132
+ };
133
+ /**
134
+ * @worklet
135
+ */
136
+
137
+ export const scale = function (sx, sy) {
138
+ "worklet";
139
+
140
+ let sz = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
141
+ let p = arguments.length > 3 ? arguments[3] : undefined;
142
+ const m4 = [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];
143
+
144
+ if (p) {
145
+ return pivot(m4, p);
146
+ }
147
+
148
+ return m4;
149
+ };
150
+
151
+ const rotateAxis = (axis, angle, p) => {
152
+ "worklet";
153
+
154
+ const result = rotate(axis, angle);
155
+
156
+ if (p) {
157
+ return pivot(result, p);
158
+ }
159
+
160
+ return result;
161
+ };
162
+ /**
163
+ * @worklet
164
+ */
165
+
166
+
167
+ export const rotateZ = (value, p) => {
168
+ "worklet";
169
+
170
+ return rotateAxis([0, 0, 1], value, p);
171
+ };
115
172
  /**
116
173
  * @worklet
117
174
  */
118
175
 
176
+ export const rotateX = (value, p) => {
177
+ "worklet";
178
+
179
+ return rotateAxis([1, 0, 0], value, p);
180
+ };
181
+ /**
182
+ * @worklet
183
+ */
184
+
185
+ export const rotateY = (value, p) => {
186
+ "worklet";
187
+
188
+ return rotateAxis([0, 1, 0], value, p);
189
+ };
190
+ /**
191
+ * @worklet
192
+ */
119
193
 
120
194
  export const processTransform3d = transforms => {
121
195
  "worklet";
@@ -1 +1 @@
1
- {"version":3,"names":["exhaustiveCheck","a","Error","Matrix4","translate","x","y","z","scale","sx","sy","sz","perspective","p","normalizeVec","vec","length","Math","sqrt","rotatedUnitSinCos","axisVec","sinAngle","cosAngle","c","s","t","rotate","axis","value","sin","cos","matrixVecMul4","m","v","vx","vy","vz","vw","mapPoint3d","r","multiply4","b","result","Array","fill","i","j","skewY","angle","tan","skewX","toMatrix3","processTransform3d","transforms","reduce","acc","val","key","Object","keys","transform"],"sources":["Matrix4.ts"],"sourcesContent":["type Vec2 = readonly [number, number];\ntype Vec3 = readonly [number, number, number];\ntype Vec4 = readonly [number, number, number, number];\n\nexport type Matrix4 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\ntype Transform3dName =\n | \"translateX\"\n | \"translateY\"\n | \"translateZ\"\n | \"translate\"\n | \"scale\"\n | \"scaleX\"\n | \"scaleY\"\n | \"skewX\"\n | \"skewY\"\n | \"rotateZ\"\n | \"rotate\"\n | \"perspective\"\n | \"rotateX\"\n | \"rotateY\"\n | \"matrix\";\n\ntype Transformations = {\n [Name in Transform3dName]: Name extends \"matrix\"\n ? Matrix4\n : Name extends \"translate\"\n ? Vec3 | Vec2\n : number;\n};\n\ntype Transform3d =\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"translateZ\">\n | Pick<Transformations, \"translate\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"perspective\">\n | Pick<Transformations, \"rotateX\">\n | Pick<Transformations, \"rotateY\">\n | Pick<Transformations, \"rotateZ\">\n | Pick<Transformations, \"rotate\">\n | Pick<Transformations, \"matrix\">;\n\nexport type Transforms3d = Transform3d[];\n\nconst exhaustiveCheck = (a: never): never => {\n \"worklet\";\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n/**\n * @worklet\n */\nexport const Matrix4 = (): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst translate = (x: number, y: number, z: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];\n};\n\nconst scale = (sx: number, sy: number, sz: number): Matrix4 => {\n \"worklet\";\n return [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];\n};\n\nconst perspective = (p: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];\n};\n\nconst normalizeVec = (vec: Vec3): Vec3 => {\n \"worklet\";\n const [x, y, z] = vec;\n const length = Math.sqrt(x * x + y * y + z * z);\n // Check for zero length to avoid division by zero\n if (length === 0) {\n return [0, 0, 0];\n }\n return [x / length, y / length, z / length];\n};\n\nconst rotatedUnitSinCos = (\n axisVec: Vec3,\n sinAngle: number,\n cosAngle: number\n): Matrix4 => {\n \"worklet\";\n const x = axisVec[0];\n const y = axisVec[1];\n const z = axisVec[2];\n const c = cosAngle;\n const s = sinAngle;\n const t = 1 - c;\n return [\n t * x * x + c,\n t * x * y - s * z,\n t * x * z + s * y,\n 0,\n t * x * y + s * z,\n t * y * y + c,\n t * y * z - s * x,\n 0,\n t * x * z - s * y,\n t * y * z + s * x,\n t * z * z + c,\n 0,\n 0,\n 0,\n 0,\n 1,\n ];\n};\n\nconst rotate = (axis: Vec3, value: number) => {\n \"worklet\";\n return rotatedUnitSinCos(\n normalizeVec(axis),\n Math.sin(value),\n Math.cos(value)\n );\n};\n\nconst matrixVecMul4 = (m: Matrix4, v: Vec4) => {\n \"worklet\";\n const [vx, vy, vz, vw] = v;\n return [\n vx * m[0] + vy * m[4] + vz * m[8] + vw * m[12],\n vx * m[1] + vy * m[5] + vz * m[9] + vw * m[13],\n vx * m[2] + vy * m[6] + vz * m[10] + vw * m[14],\n vx * m[3] + vy * m[7] + vz * m[11] + vw * m[15],\n ];\n};\n\n/**\n * @worklet\n */\nexport const mapPoint3d = (m: Matrix4, v: Vec3) => {\n \"worklet\";\n const r = matrixVecMul4(m, [...v, 1]);\n return [r[0] / r[3], r[1] / r[3], r[2] / r[3]] as const;\n};\n\nconst multiply4 = (a: Matrix4, b: Matrix4): Matrix4 => {\n \"worklet\";\n const result = new Array(16).fill(0);\n for (let i = 0; i < 4; i++) {\n for (let j = 0; j < 4; j++) {\n result[i * 4 + j] =\n a[i * 4] * b[j] +\n a[i * 4 + 1] * b[j + 4] +\n a[i * 4 + 2] * b[j + 8] +\n a[i * 4 + 3] * b[j + 12];\n }\n }\n return result as unknown as Matrix4;\n};\n\nconst skewY = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst skewX = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst toMatrix3 = (m: Matrix4) => {\n \"worklet\";\n return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];\n};\n\n/**\n * @worklet\n */\nexport const processTransform3d = (transforms: Transforms3d) => {\n \"worklet\";\n return toMatrix3(\n transforms.reduce((acc, val) => {\n const key = Object.keys(val)[0] as Transform3dName;\n const transform = val as Pick<Transformations, typeof key>;\n if (key === \"translateX\") {\n const value = transform[key];\n return multiply4(acc, translate(value, 0, 0));\n }\n if (key === \"translate\") {\n const [x, y, z = 0] = transform[key];\n return multiply4(acc, translate(x, y, z));\n }\n if (key === \"translateY\") {\n const value = transform[key];\n return multiply4(acc, translate(0, value, 0));\n }\n if (key === \"translateZ\") {\n const value = transform[key];\n return multiply4(acc, translate(0, 0, value));\n }\n if (key === \"scale\") {\n const value = transform[key];\n return multiply4(acc, scale(value, value, 1));\n }\n if (key === \"scaleX\") {\n const value = transform[key];\n return multiply4(acc, scale(value, 1, 1));\n }\n if (key === \"scaleY\") {\n const value = transform[key];\n return multiply4(acc, scale(1, value, 1));\n }\n if (key === \"skewX\") {\n const value = transform[key];\n return multiply4(acc, skewX(value));\n }\n if (key === \"skewY\") {\n const value = transform[key];\n return multiply4(acc, skewY(value));\n }\n if (key === \"rotateX\") {\n const value = transform[key];\n return multiply4(acc, rotate([1, 0, 0], value));\n }\n if (key === \"rotateY\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 1, 0], value));\n }\n if (key === \"perspective\") {\n const value = transform[key];\n return multiply4(acc, perspective(value));\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 0, 1], value));\n }\n if (key === \"matrix\") {\n const value = transform[key];\n return multiply4(acc, value);\n }\n return exhaustiveCheck(key);\n }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ACD;;IACD,IAAI6B,GAAG,KAAK,SAAZ,EAAuB;MACrB,MAAM7B,KAAK,GAAGgC,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOjB,SAAS,CAACe,GAAD,EAAM7B,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAD,EAAYE,KAAZ,CAAZ,CAAhB;IACD;;IACD,IAAI6B,GAAG,KAAK,aAAZ,EAA2B;MACzB,MAAM7B,KAAK,GAAGgC,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOjB,SAAS,CAACe,GAAD,EAAM3C,WAAW,CAACgB,KAAD,CAAjB,CAAhB;IACD;;IACD,IAAI6B,GAAG,KAAK,QAAR,IAAoBA,GAAG,KAAK,SAAhC,EAA2C;MACzC,MAAM7B,KAAK,GAAGgC,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOjB,SAAS,CAACe,GAAD,EAAM7B,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAD,EAAYE,KAAZ,CAAZ,CAAhB;IACD;;IACD,IAAI6B,GAAG,KAAK,QAAZ,EAAsB;MACpB,MAAM7B,KAAK,GAAGgC,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOjB,SAAS,CAACe,GAAD,EAAM3B,KAAN,CAAhB;IACD;;IACD,OAAO5B,eAAe,CAACyD,GAAD,CAAtB;EACD,CA5DD,EA4DGtD,OAAO,EA5DV,CADc,CAAhB;AA+DD,CAjEM"}
1
+ {"version":3,"names":["exhaustiveCheck","a","Error","Matrix4","translate","x","y","z","perspective","p","normalizeVec","vec","length","Math","sqrt","rotatedUnitSinCos","axisVec","sinAngle","cosAngle","c","s","t","matrixVecMul4","m","v","vx","vy","vz","vw","mapPoint3d","r","multiply4","b","result","Array","fill","i","j","skewY","angle","tan","skewX","toMatrix3","rotate","axis","value","sin","cos","pivot","scale","sx","sy","sz","m4","rotateAxis","rotateZ","rotateX","rotateY","processTransform3d","transforms","reduce","acc","val","key","Object","keys","transform"],"sources":["Matrix4.ts"],"sourcesContent":["type Point = { x: number; y: number };\ntype Vec2 = readonly [number, number];\ntype Vec3 = readonly [number, number, number];\ntype Vec4 = readonly [number, number, number, number];\n\nexport type Matrix3 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\nexport type Matrix4 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\ntype Transform3dName =\n | \"translateX\"\n | \"translateY\"\n | \"translateZ\"\n | \"translate\"\n | \"scale\"\n | \"scaleX\"\n | \"scaleY\"\n | \"skewX\"\n | \"skewY\"\n | \"rotateZ\"\n | \"rotate\"\n | \"perspective\"\n | \"rotateX\"\n | \"rotateY\"\n | \"matrix\";\n\ntype Transformations = {\n [Name in Transform3dName]: Name extends \"matrix\"\n ? Matrix4\n : Name extends \"translate\"\n ? Vec3 | Vec2\n : number;\n};\n\ntype Transform3d =\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"translateZ\">\n | Pick<Transformations, \"translate\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"perspective\">\n | Pick<Transformations, \"rotateX\">\n | Pick<Transformations, \"rotateY\">\n | Pick<Transformations, \"rotateZ\">\n | Pick<Transformations, \"rotate\">\n | Pick<Transformations, \"matrix\">;\n\nexport type Transforms3d = Transform3d[];\n\nconst exhaustiveCheck = (a: never): never => {\n \"worklet\";\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n/**\n * @worklet\n */\nexport const Matrix4 = (): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const translate = (x: number, y: number, z: number = 0): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const perspective = (p: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];\n};\n\nconst normalizeVec = (vec: Vec3): Vec3 => {\n \"worklet\";\n const [x, y, z] = vec;\n const length = Math.sqrt(x * x + y * y + z * z);\n // Check for zero length to avoid division by zero\n if (length === 0) {\n return [0, 0, 0];\n }\n return [x / length, y / length, z / length];\n};\n\nconst rotatedUnitSinCos = (\n axisVec: Vec3,\n sinAngle: number,\n cosAngle: number\n): Matrix4 => {\n \"worklet\";\n const x = axisVec[0];\n const y = axisVec[1];\n const z = axisVec[2];\n const c = cosAngle;\n const s = sinAngle;\n const t = 1 - c;\n return [\n t * x * x + c,\n t * x * y - s * z,\n t * x * z + s * y,\n 0,\n t * x * y + s * z,\n t * y * y + c,\n t * y * z - s * x,\n 0,\n t * x * z - s * y,\n t * y * z + s * x,\n t * z * z + c,\n 0,\n 0,\n 0,\n 0,\n 1,\n ];\n};\n\nconst matrixVecMul4 = (m: Matrix4, v: Vec4) => {\n \"worklet\";\n const [vx, vy, vz, vw] = v;\n return [\n vx * m[0] + vy * m[4] + vz * m[8] + vw * m[12],\n vx * m[1] + vy * m[5] + vz * m[9] + vw * m[13],\n vx * m[2] + vy * m[6] + vz * m[10] + vw * m[14],\n vx * m[3] + vy * m[7] + vz * m[11] + vw * m[15],\n ];\n};\n\n/**\n * @worklet\n */\nexport const mapPoint3d = (m: Matrix4, v: Vec3) => {\n \"worklet\";\n const r = matrixVecMul4(m, [...v, 1]);\n return [r[0] / r[3], r[1] / r[3], r[2] / r[3]] as const;\n};\n\n/**\n * @worklet\n */\nexport const multiply4 = (a: Matrix4, b: Matrix4): Matrix4 => {\n \"worklet\";\n const result = new Array(16).fill(0);\n for (let i = 0; i < 4; i++) {\n for (let j = 0; j < 4; j++) {\n result[i * 4 + j] =\n a[i * 4] * b[j] +\n a[i * 4 + 1] * b[j + 4] +\n a[i * 4 + 2] * b[j + 8] +\n a[i * 4 + 3] * b[j + 12];\n }\n }\n return result as unknown as Matrix4;\n};\n\nconst skewY = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst skewX = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const toMatrix3 = (m: Matrix4) => {\n \"worklet\";\n return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];\n};\n\nconst rotate = (axis: Vec3, value: number) => {\n \"worklet\";\n return rotatedUnitSinCos(\n normalizeVec(axis),\n Math.sin(value),\n Math.cos(value)\n );\n};\n\n/**\n * @worklet\n */\nexport const pivot = (m: Matrix4, p: Point) => {\n \"worklet\";\n return multiply4(translate(p.x, p.y), multiply4(m, translate(-p.x, -p.y)));\n};\n\n/**\n * @worklet\n */\nexport const scale = (\n sx: number,\n sy: number,\n sz: number = 1,\n p?: Point\n): Matrix4 => {\n \"worklet\";\n const m4: Matrix4 = [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];\n if (p) {\n return pivot(m4, p);\n }\n return m4;\n};\n\nconst rotateAxis = (axis: Vec3, angle: number, p?: Point) => {\n \"worklet\";\n const result = rotate(axis, angle);\n if (p) {\n return pivot(result, p);\n }\n return result;\n};\n\n/**\n * @worklet\n */\nexport const rotateZ = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([0, 0, 1], value, p);\n};\n\n/**\n * @worklet\n */\nexport const rotateX = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([1, 0, 0], value, p);\n};\n\n/**\n * @worklet\n */\nexport const rotateY = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([0, 1, 0], value, p);\n};\n\n/**\n * @worklet\n */\nexport const processTransform3d = (transforms: Transforms3d) => {\n \"worklet\";\n return toMatrix3(\n transforms.reduce((acc, val) => {\n const key = Object.keys(val)[0] as Transform3dName;\n const transform = val as Pick<Transformations, typeof key>;\n if (key === \"translateX\") {\n const value = transform[key];\n return multiply4(acc, translate(value, 0, 0));\n }\n if (key === \"translate\") {\n const [x, y, z = 0] = transform[key];\n return multiply4(acc, translate(x, y, z));\n }\n if (key === \"translateY\") {\n const value = transform[key];\n return multiply4(acc, translate(0, value, 0));\n }\n if (key === \"translateZ\") {\n const value = transform[key];\n return multiply4(acc, translate(0, 0, value));\n }\n if (key === \"scale\") {\n const value = transform[key];\n return multiply4(acc, scale(value, value, 1));\n }\n if (key === \"scaleX\") {\n const value = transform[key];\n return multiply4(acc, scale(value, 1, 1));\n }\n if (key === \"scaleY\") {\n const value = transform[key];\n return multiply4(acc, scale(1, value, 1));\n }\n if (key === \"skewX\") {\n const value = transform[key];\n return multiply4(acc, skewX(value));\n }\n if (key === \"skewY\") {\n const value = transform[key];\n return multiply4(acc, skewY(value));\n }\n if (key === \"rotateX\") {\n const value = transform[key];\n return multiply4(acc, rotate([1, 0, 0], value));\n }\n if (key === \"rotateY\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 1, 0], value));\n }\n if (key === \"perspective\") {\n const value = transform[key];\n return multiply4(acc, perspective(value));\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 0, 1], value));\n }\n if (key === \"matrix\") {\n const value = transform[key];\n return multiply4(acc, value);\n }\n return exhaustiveCheck(key);\n }, Matrix4())\n );\n};\n"],"mappings":"AAgFA,MAAMA,eAAe,GAAIC,CAAD,IAAqB;EAC3C;;EACA,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAHD;AAKA;AACA;AACA;;;AACA,OAAO,MAAME,OAAO,GAAG,MA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EAAI,CAAJ,EAAO,CAAP,CAAD,EAAYE,KAAZ,CAAZ,CAAhB;IACD;;IACD,IAAIkB,GAAG,KAAK,SAAZ,EAAuB;MACrB,MAAMlB,KAAK,GAAGqB,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOhC,SAAS,CAAC8B,GAAD,EAAMlB,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAD,EAAYE,KAAZ,CAAZ,CAAhB;IACD;;IACD,IAAIkB,GAAG,KAAK,aAAZ,EAA2B;MACzB,MAAMlB,KAAK,GAAGqB,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOhC,SAAS,CAAC8B,GAAD,EAAMrD,WAAW,CAACqC,KAAD,CAAjB,CAAhB;IACD;;IACD,IAAIkB,GAAG,KAAK,QAAR,IAAoBA,GAAG,KAAK,SAAhC,EAA2C;MACzC,MAAMlB,KAAK,GAAGqB,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOhC,SAAS,CAAC8B,GAAD,EAAMlB,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAD,EAAYE,KAAZ,CAAZ,CAAhB;IACD;;IACD,IAAIkB,GAAG,KAAK,QAAZ,EAAsB;MACpB,MAAMlB,KAAK,GAAGqB,SAAS,CAACH,GAAD,CAAvB;MACA,OAAOhC,SAAS,CAAC8B,GAAD,EAAMhB,KAAN,CAAhB;IACD;;IACD,OAAO7C,eAAe,CAAC+D,GAAD,CAAtB;EACD,CA5DD,EA4DG5D,OAAO,EA5DV,CADc,CAAhB;AA+DD,CAjEM"}
@@ -16,6 +16,5 @@ export declare abstract class BaseHostObject<T, N extends string> extends Host i
16
16
  export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
17
17
  static fromValue<T>(value: SkJSIInstance<string>): T;
18
18
  }
19
- export declare const getCkEnum: (e: EmbindEnum, v: number) => EmbindEnumEntity;
20
- export declare const ckEnum: (value: number) => EmbindEnumEntity;
21
- export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
19
+ export declare const getEnum: (e: EmbindEnum, v: number) => EmbindEnumEntity;
20
+ export declare const optEnum: (e: EmbindEnum, value: number | undefined) => EmbindEnumEntity | undefined;
@@ -33,16 +33,11 @@ export class HostObject extends BaseHostObject {
33
33
  }
34
34
 
35
35
  }
36
- export const getCkEnum = (e, v) => Object.values(e).find(_ref => {
36
+ export const getEnum = (e, v) => Object.values(e).find(_ref => {
37
37
  let {
38
38
  value
39
39
  } = _ref;
40
40
  return value === v;
41
41
  });
42
- export const ckEnum = value => ({
43
- value
44
- });
45
- export const optEnum = value => value === undefined ? undefined : {
46
- value
47
- };
42
+ export const optEnum = (e, value) => value === undefined ? undefined : getEnum(e, value);
48
43
  //# sourceMappingURL=Host.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","BaseHostObject","ref","typename","__typename__","HostObject","fromValue","value","getCkEnum","e","v","Object","values","find","ckEnum","optEnum","undefined"],"sources":["Host.ts"],"sourcesContent":["import type { CanvasKit, EmbindEnumEntity, EmbindEnum } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport class NotImplementedOnRNWeb extends Error {\n constructor(msg?: string) {\n super(msg ?? \"Not implemented on React Native Web\");\n }\n}\n\nexport abstract class Host {\n readonly CanvasKit: CanvasKit;\n\n constructor(CanvasKit: CanvasKit) {\n this.CanvasKit = CanvasKit;\n }\n}\n\nexport abstract class BaseHostObject<T, N extends string>\n extends Host\n implements SkJSIInstance<N>\n{\n readonly __typename__: N;\n ref: T;\n\n constructor(CanvasKit: CanvasKit, ref: T, typename: N) {\n super(CanvasKit);\n this.ref = ref;\n this.__typename__ = typename;\n }\n\n abstract dispose(): void;\n}\n\nexport abstract class HostObject<T, N extends string> extends BaseHostObject<\n T,\n N\n> {\n static fromValue<T>(value: SkJSIInstance<string>) {\n return (value as HostObject<T, string>).ref;\n }\n}\n\nexport const getCkEnum = (e: EmbindEnum, v: number): EmbindEnumEntity =>\n Object.values(e).find(({ value }) => value === v);\nexport const ckEnum = (value: number): EmbindEnumEntity => ({ value });\nexport const optEnum = (\n value: number | undefined\n): EmbindEnumEntity | undefined =>\n value === undefined ? undefined : { value };\n"],"mappings":";;AAIA,OAAO,MAAMA,qBAAN,SAAoCC,KAApC,CAA0C;EAC/CC,WAAW,CAACC,GAAD,EAAe;IACxB,MAAMA,GAAN,aAAMA,GAAN,cAAMA,GAAN,GAAa,qCAAb;EACD;;AAH8C;AAMjD,OAAO,MAAeC,IAAf,CAAoB;EAGzBF,WAAW,CAACG,SAAD,EAAuB;IAAA;;IAChC,KAAKA,SAAL,GAAiBA,SAAjB;EACD;;AALwB;AAQ3B,OAAO,MAAeC,cAAf,SACGF,IADH,CAGP;EAIEF,WAAW,CAACG,SAAD,EAAuBE,GAAvB,EAA+BC,QAA/B,EAA4C;IACrD,MAAMH,SAAN;;IADqD;;IAAA;;IAErD,KAAKE,GAAL,GAAWA,GAAX;IACA,KAAKE,YAAL,GAAoBD,QAApB;EACD;;AARH;AAaA,OAAO,MAAeE,UAAf,SAAuDJ,cAAvD,CAGL;EACgB,OAATK,SAAS,CAAIC,KAAJ,EAAkC;IAChD,OAAQA,KAAD,CAAiCL,GAAxC;EACD;;AAHD;AAMF,OAAO,MAAMM,SAAS,GAAG,CAACC,CAAD,EAAgBC,CAAhB,KACvBC,MAAM,CAACC,MAAP,CAAcH,CAAd,EAAiBI,IAAjB,CAAsB;EAAA,IAAC;IAAEN;EAAF,CAAD;EAAA,OAAeA,KAAK,KAAKG,CAAzB;AAAA,CAAtB,CADK;AAEP,OAAO,MAAMI,MAAM,GAAIP,KAAD,KAAsC;EAAEA;AAAF,CAAtC,CAAf;AACP,OAAO,MAAMQ,OAAO,GAClBR,KADqB,IAGrBA,KAAK,KAAKS,SAAV,GAAsBA,SAAtB,GAAkC;EAAET;AAAF,CAH7B"}
1
+ {"version":3,"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","BaseHostObject","ref","typename","__typename__","HostObject","fromValue","value","getEnum","e","v","Object","values","find","optEnum","undefined"],"sources":["Host.ts"],"sourcesContent":["import type { CanvasKit, EmbindEnumEntity, EmbindEnum } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport class NotImplementedOnRNWeb extends Error {\n constructor(msg?: string) {\n super(msg ?? \"Not implemented on React Native Web\");\n }\n}\n\nexport abstract class Host {\n readonly CanvasKit: CanvasKit;\n\n constructor(CanvasKit: CanvasKit) {\n this.CanvasKit = CanvasKit;\n }\n}\n\nexport abstract class BaseHostObject<T, N extends string>\n extends Host\n implements SkJSIInstance<N>\n{\n readonly __typename__: N;\n ref: T;\n\n constructor(CanvasKit: CanvasKit, ref: T, typename: N) {\n super(CanvasKit);\n this.ref = ref;\n this.__typename__ = typename;\n }\n\n abstract dispose(): void;\n}\n\nexport abstract class HostObject<T, N extends string> extends BaseHostObject<\n T,\n N\n> {\n static fromValue<T>(value: SkJSIInstance<string>) {\n return (value as HostObject<T, string>).ref;\n }\n}\n\nexport const getEnum = (e: EmbindEnum, v: number): EmbindEnumEntity =>\n Object.values(e).find(({ value }) => value === v);\n\nexport const optEnum = (\n e: EmbindEnum,\n value: number | undefined\n): EmbindEnumEntity | undefined =>\n value === undefined ? undefined : getEnum(e, value);\n"],"mappings":";;AAIA,OAAO,MAAMA,qBAAN,SAAoCC,KAApC,CAA0C;EAC/CC,WAAW,CAACC,GAAD,EAAe;IACxB,MAAMA,GAAN,aAAMA,GAAN,cAAMA,GAAN,GAAa,qCAAb;EACD;;AAH8C;AAMjD,OAAO,MAAeC,IAAf,CAAoB;EAGzBF,WAAW,CAACG,SAAD,EAAuB;IAAA;;IAChC,KAAKA,SAAL,GAAiBA,SAAjB;EACD;;AALwB;AAQ3B,OAAO,MAAeC,cAAf,SACGF,IADH,CAGP;EAIEF,WAAW,CAACG,SAAD,EAAuBE,GAAvB,EAA+BC,QAA/B,EAA4C;IACrD,MAAMH,SAAN;;IADqD;;IAAA;;IAErD,KAAKE,GAAL,GAAWA,GAAX;IACA,KAAKE,YAAL,GAAoBD,QAApB;EACD;;AARH;AAaA,OAAO,MAAeE,UAAf,SAAuDJ,cAAvD,CAGL;EACgB,OAATK,SAAS,CAAIC,KAAJ,EAAkC;IAChD,OAAQA,KAAD,CAAiCL,GAAxC;EACD;;AAHD;AAMF,OAAO,MAAMM,OAAO,GAAG,CAACC,CAAD,EAAgBC,CAAhB,KACrBC,MAAM,CAACC,MAAP,CAAcH,CAAd,EAAiBI,IAAjB,CAAsB;EAAA,IAAC;IAAEN;EAAF,CAAD;EAAA,OAAeA,KAAK,KAAKG,CAAzB;AAAA,CAAtB,CADK;AAGP,OAAO,MAAMI,OAAO,GAAG,CACrBL,CADqB,EAErBF,KAFqB,KAIrBA,KAAK,KAAKQ,SAAV,GAAsBA,SAAtB,GAAkCP,OAAO,CAACC,CAAD,EAAIF,KAAJ,CAJpC"}