@shopify/react-native-skia 0.1.225 → 0.1.227

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +3 -3
  2. package/cpp/api/JsiSkMatrix.h +8 -2
  3. package/cpp/api/JsiSkPictureRecorder.h +10 -3
  4. package/cpp/rnskia/dom/props/MatrixProp.h +8 -0
  5. package/cpp/rnskia/dom/props/TransformProp.h +76 -9
  6. package/lib/commonjs/animation/spring/runSpring.d.ts +3 -0
  7. package/lib/commonjs/animation/spring/runSpring.js +3 -0
  8. package/lib/commonjs/animation/spring/runSpring.js.map +1 -1
  9. package/lib/commonjs/animation/spring/useSpring.d.ts +3 -0
  10. package/lib/commonjs/animation/spring/useSpring.js +3 -0
  11. package/lib/commonjs/animation/spring/useSpring.js.map +1 -1
  12. package/lib/commonjs/animation/timing/runTiming.d.ts +3 -0
  13. package/lib/commonjs/animation/timing/runTiming.js +3 -0
  14. package/lib/commonjs/animation/timing/runTiming.js.map +1 -1
  15. package/lib/commonjs/animation/timing/useLoop.d.ts +3 -0
  16. package/lib/commonjs/animation/timing/useLoop.js +3 -0
  17. package/lib/commonjs/animation/timing/useLoop.js.map +1 -1
  18. package/lib/commonjs/animation/timing/useTiming.d.ts +3 -0
  19. package/lib/commonjs/animation/timing/useTiming.js +3 -0
  20. package/lib/commonjs/animation/timing/useTiming.js.map +1 -1
  21. package/lib/commonjs/dom/nodes/JsiSkDOM.js +2 -0
  22. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  23. package/lib/commonjs/dom/nodes/datatypes/Fitting.d.ts +5 -5
  24. package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
  25. package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +235 -75
  26. package/lib/commonjs/dom/nodes/datatypes/Gradient.js.map +1 -1
  27. package/lib/commonjs/dom/types/Common.d.ts +3 -3
  28. package/lib/commonjs/dom/types/Common.js.map +1 -1
  29. package/lib/commonjs/external/reanimated/interpolators.js +10 -4
  30. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  31. package/lib/commonjs/renderer/Canvas.js +34 -28
  32. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  33. package/lib/commonjs/renderer/components/Drawing.d.ts +5 -0
  34. package/lib/commonjs/renderer/components/Drawing.js +5 -0
  35. package/lib/commonjs/renderer/components/Drawing.js.map +1 -1
  36. package/lib/commonjs/renderer/components/shapes/FitBox.d.ts +5 -5
  37. package/lib/commonjs/skia/core/Matrix.d.ts +2 -2
  38. package/lib/commonjs/skia/core/Matrix.js.map +1 -1
  39. package/lib/commonjs/skia/core/Picture.d.ts +2 -2
  40. package/lib/commonjs/skia/core/Picture.js +12 -2
  41. package/lib/commonjs/skia/core/Picture.js.map +1 -1
  42. package/lib/commonjs/skia/core/Vector.d.ts +3 -3
  43. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  44. package/lib/commonjs/skia/types/Canvas.d.ts +1 -1
  45. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  46. package/lib/commonjs/skia/types/Matrix.d.ts +4 -9
  47. package/lib/commonjs/skia/types/Matrix.js +5 -56
  48. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  49. package/lib/commonjs/skia/types/Matrix4.d.ts +39 -0
  50. package/lib/commonjs/skia/types/Matrix4.js +213 -0
  51. package/lib/commonjs/skia/types/Matrix4.js.map +1 -0
  52. package/lib/commonjs/skia/types/Path/Path.d.ts +1 -1
  53. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  54. package/lib/commonjs/skia/types/Picture/PictureRecorder.d.ts +1 -1
  55. package/lib/commonjs/skia/types/Picture/PictureRecorder.js.map +1 -1
  56. package/lib/commonjs/skia/types/Rect.d.ts +1 -0
  57. package/lib/commonjs/skia/types/Rect.js +18 -0
  58. package/lib/commonjs/skia/types/Rect.js.map +1 -1
  59. package/lib/commonjs/skia/types/index.d.ts +1 -0
  60. package/lib/commonjs/skia/types/index.js +13 -0
  61. package/lib/commonjs/skia/types/index.js.map +1 -1
  62. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  63. package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -1
  64. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  65. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +1 -1
  66. package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
  67. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  68. package/lib/commonjs/skia/web/JsiSkPath.js +1 -1
  69. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  70. package/lib/commonjs/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  71. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +1 -1
  72. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
  73. package/lib/commonjs/values/api.d.ts +23 -2
  74. package/lib/commonjs/values/api.js +44 -1
  75. package/lib/commonjs/values/api.js.map +1 -1
  76. package/lib/commonjs/values/hooks/useClockValue.d.ts +3 -0
  77. package/lib/commonjs/values/hooks/useClockValue.js +3 -0
  78. package/lib/commonjs/values/hooks/useClockValue.js.map +1 -1
  79. package/lib/commonjs/values/hooks/useComputedValue.d.ts +3 -0
  80. package/lib/commonjs/values/hooks/useComputedValue.js +3 -0
  81. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  82. package/lib/commonjs/values/hooks/useValue.d.ts +3 -0
  83. package/lib/commonjs/values/hooks/useValue.js +3 -0
  84. package/lib/commonjs/values/hooks/useValue.js.map +1 -1
  85. package/lib/commonjs/values/hooks/useValueEffect.d.ts +3 -0
  86. package/lib/commonjs/values/hooks/useValueEffect.js +3 -0
  87. package/lib/commonjs/values/hooks/useValueEffect.js.map +1 -1
  88. package/lib/commonjs/values/types.d.ts +4 -4
  89. package/lib/commonjs/values/types.js.map +1 -1
  90. package/lib/commonjs/views/SkiaView.d.ts +5 -0
  91. package/lib/commonjs/views/SkiaView.js +9 -0
  92. package/lib/commonjs/views/SkiaView.js.map +1 -1
  93. package/lib/module/animation/spring/runSpring.d.ts +3 -0
  94. package/lib/module/animation/spring/runSpring.js +3 -0
  95. package/lib/module/animation/spring/runSpring.js.map +1 -1
  96. package/lib/module/animation/spring/useSpring.d.ts +3 -0
  97. package/lib/module/animation/spring/useSpring.js +3 -0
  98. package/lib/module/animation/spring/useSpring.js.map +1 -1
  99. package/lib/module/animation/timing/runTiming.d.ts +3 -0
  100. package/lib/module/animation/timing/runTiming.js +3 -0
  101. package/lib/module/animation/timing/runTiming.js.map +1 -1
  102. package/lib/module/animation/timing/useLoop.d.ts +3 -0
  103. package/lib/module/animation/timing/useLoop.js +3 -0
  104. package/lib/module/animation/timing/useLoop.js.map +1 -1
  105. package/lib/module/animation/timing/useTiming.d.ts +3 -0
  106. package/lib/module/animation/timing/useTiming.js +3 -0
  107. package/lib/module/animation/timing/useTiming.js.map +1 -1
  108. package/lib/module/dom/nodes/JsiSkDOM.js +2 -0
  109. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  110. package/lib/module/dom/nodes/datatypes/Fitting.d.ts +5 -5
  111. package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
  112. package/lib/module/dom/nodes/datatypes/Gradient.d.ts +235 -75
  113. package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
  114. package/lib/module/dom/types/Common.d.ts +3 -3
  115. package/lib/module/dom/types/Common.js.map +1 -1
  116. package/lib/module/external/reanimated/interpolators.js +11 -5
  117. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  118. package/lib/module/renderer/Canvas.js +35 -29
  119. package/lib/module/renderer/Canvas.js.map +1 -1
  120. package/lib/module/renderer/components/Drawing.d.ts +5 -0
  121. package/lib/module/renderer/components/Drawing.js +6 -0
  122. package/lib/module/renderer/components/Drawing.js.map +1 -1
  123. package/lib/module/renderer/components/shapes/FitBox.d.ts +5 -5
  124. package/lib/module/skia/core/Matrix.d.ts +2 -2
  125. package/lib/module/skia/core/Matrix.js.map +1 -1
  126. package/lib/module/skia/core/Picture.d.ts +2 -2
  127. package/lib/module/skia/core/Picture.js +12 -3
  128. package/lib/module/skia/core/Picture.js.map +1 -1
  129. package/lib/module/skia/core/Vector.d.ts +3 -3
  130. package/lib/module/skia/core/Vector.js.map +1 -1
  131. package/lib/module/skia/types/Canvas.d.ts +1 -1
  132. package/lib/module/skia/types/Canvas.js.map +1 -1
  133. package/lib/module/skia/types/Matrix.d.ts +4 -9
  134. package/lib/module/skia/types/Matrix.js +3 -57
  135. package/lib/module/skia/types/Matrix.js.map +1 -1
  136. package/lib/module/skia/types/Matrix4.d.ts +39 -0
  137. package/lib/module/skia/types/Matrix4.js +200 -0
  138. package/lib/module/skia/types/Matrix4.js.map +1 -0
  139. package/lib/module/skia/types/Path/Path.d.ts +1 -1
  140. package/lib/module/skia/types/Path/Path.js.map +1 -1
  141. package/lib/module/skia/types/Picture/PictureRecorder.d.ts +1 -1
  142. package/lib/module/skia/types/Picture/PictureRecorder.js.map +1 -1
  143. package/lib/module/skia/types/Rect.d.ts +1 -0
  144. package/lib/module/skia/types/Rect.js +9 -0
  145. package/lib/module/skia/types/Rect.js.map +1 -1
  146. package/lib/module/skia/types/index.d.ts +1 -0
  147. package/lib/module/skia/types/index.js +1 -0
  148. package/lib/module/skia/types/index.js.map +1 -1
  149. package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  150. package/lib/module/skia/web/JsiSkCanvas.js +1 -1
  151. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  152. package/lib/module/skia/web/JsiSkMatrix.d.ts +1 -1
  153. package/lib/module/skia/web/JsiSkMatrix.js +1 -1
  154. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  155. package/lib/module/skia/web/JsiSkPath.js +1 -1
  156. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  157. package/lib/module/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  158. package/lib/module/skia/web/JsiSkPictureRecorder.js +1 -1
  159. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  160. package/lib/module/values/api.d.ts +23 -2
  161. package/lib/module/values/api.js +44 -1
  162. package/lib/module/values/api.js.map +1 -1
  163. package/lib/module/values/hooks/useClockValue.d.ts +3 -0
  164. package/lib/module/values/hooks/useClockValue.js +3 -0
  165. package/lib/module/values/hooks/useClockValue.js.map +1 -1
  166. package/lib/module/values/hooks/useComputedValue.d.ts +3 -0
  167. package/lib/module/values/hooks/useComputedValue.js +3 -0
  168. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  169. package/lib/module/values/hooks/useValue.d.ts +3 -0
  170. package/lib/module/values/hooks/useValue.js +3 -0
  171. package/lib/module/values/hooks/useValue.js.map +1 -1
  172. package/lib/module/values/hooks/useValueEffect.d.ts +3 -0
  173. package/lib/module/values/hooks/useValueEffect.js +3 -0
  174. package/lib/module/values/hooks/useValueEffect.js.map +1 -1
  175. package/lib/module/values/types.d.ts +4 -4
  176. package/lib/module/values/types.js.map +1 -1
  177. package/lib/module/views/SkiaView.d.ts +5 -0
  178. package/lib/module/views/SkiaView.js +10 -0
  179. package/lib/module/views/SkiaView.js.map +1 -1
  180. package/lib/typescript/src/animation/spring/runSpring.d.ts +3 -0
  181. package/lib/typescript/src/animation/spring/useSpring.d.ts +3 -0
  182. package/lib/typescript/src/animation/timing/runTiming.d.ts +3 -0
  183. package/lib/typescript/src/animation/timing/useLoop.d.ts +3 -0
  184. package/lib/typescript/src/animation/timing/useTiming.d.ts +3 -0
  185. package/lib/typescript/src/dom/nodes/datatypes/Fitting.d.ts +5 -5
  186. package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +235 -75
  187. package/lib/typescript/src/dom/types/Common.d.ts +3 -3
  188. package/lib/typescript/src/renderer/components/Drawing.d.ts +5 -0
  189. package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +5 -5
  190. package/lib/typescript/src/skia/core/Matrix.d.ts +2 -2
  191. package/lib/typescript/src/skia/core/Picture.d.ts +2 -2
  192. package/lib/typescript/src/skia/core/Vector.d.ts +3 -3
  193. package/lib/typescript/src/skia/types/Canvas.d.ts +1 -1
  194. package/lib/typescript/src/skia/types/Matrix.d.ts +4 -9
  195. package/lib/typescript/src/skia/types/Matrix4.d.ts +39 -0
  196. package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -1
  197. package/lib/typescript/src/skia/types/Picture/PictureRecorder.d.ts +1 -1
  198. package/lib/typescript/src/skia/types/Rect.d.ts +1 -0
  199. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  200. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
  201. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +1 -1
  202. package/lib/typescript/src/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  203. package/lib/typescript/src/values/api.d.ts +23 -2
  204. package/lib/typescript/src/values/hooks/useClockValue.d.ts +3 -0
  205. package/lib/typescript/src/values/hooks/useComputedValue.d.ts +3 -0
  206. package/lib/typescript/src/values/hooks/useValue.d.ts +3 -0
  207. package/lib/typescript/src/values/hooks/useValueEffect.d.ts +3 -0
  208. package/lib/typescript/src/values/types.d.ts +4 -4
  209. package/lib/typescript/src/views/SkiaView.d.ts +5 -0
  210. package/package.json +1 -1
  211. package/src/animation/spring/runSpring.ts +3 -0
  212. package/src/animation/spring/useSpring.ts +3 -0
  213. package/src/animation/timing/runTiming.ts +3 -0
  214. package/src/animation/timing/useLoop.ts +3 -0
  215. package/src/animation/timing/useTiming.ts +3 -0
  216. package/src/dom/nodes/JsiSkDOM.ts +4 -0
  217. package/src/dom/nodes/datatypes/Fitting.ts +10 -2
  218. package/src/dom/nodes/datatypes/Gradient.ts +2 -2
  219. package/src/dom/types/Common.ts +3 -3
  220. package/src/external/reanimated/interpolators.ts +14 -6
  221. package/src/renderer/Canvas.tsx +41 -30
  222. package/src/renderer/components/Drawing.tsx +5 -0
  223. package/src/skia/core/Matrix.ts +2 -2
  224. package/src/skia/core/Picture.ts +11 -3
  225. package/src/skia/core/Vector.ts +5 -2
  226. package/src/skia/types/Canvas.ts +1 -1
  227. package/src/skia/types/Matrix.ts +7 -74
  228. package/src/skia/types/Matrix4.ts +266 -0
  229. package/src/skia/types/Path/Path.ts +1 -1
  230. package/src/skia/types/Picture/PictureRecorder.ts +1 -1
  231. package/src/skia/types/Rect.ts +14 -0
  232. package/src/skia/types/index.ts +1 -0
  233. package/src/skia/web/JsiSkCanvas.ts +2 -2
  234. package/src/skia/web/JsiSkMatrix.ts +4 -2
  235. package/src/skia/web/JsiSkPath.ts +1 -1
  236. package/src/skia/web/JsiSkPictureRecorder.ts +6 -2
  237. package/src/values/api.ts +55 -2
  238. package/src/values/hooks/useClockValue.ts +3 -0
  239. package/src/values/hooks/useComputedValue.ts +3 -0
  240. package/src/values/hooks/useValue.ts +3 -0
  241. package/src/values/hooks/useValueEffect.ts +3 -0
  242. package/src/values/types.ts +6 -6
  243. package/src/views/SkiaView.tsx +11 -0
@@ -1 +1 @@
1
- {"version":3,"names":["exhaustiveCheck","size","width","height","rect2rect","src","dst","scaleX","scaleY","translateX","x","translateY","y","fitRects","fit","rect","sizes","applyBoxFit","inscribe","halfWidthDelta","halfHeightDelta","input","output","Math","min","aspectRatio"],"sources":["Fitting.ts"],"sourcesContent":["import { exhaustiveCheck } from \"../../../renderer/typeddash\";\nimport type { SkRect } from \"../../../skia/types\";\nimport type { Fit } from \"../../types\";\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport const size = (width = 0, height = 0) => ({ width, height });\n\nexport const rect2rect = (src: SkRect, dst: SkRect) => {\n const scaleX = dst.width / src.width;\n const scaleY = dst.height / src.height;\n const translateX = dst.x - src.x * scaleX;\n const translateY = dst.y - src.y * scaleY;\n return [{ translateX }, { translateY }, { scaleX }, { scaleY }] as const;\n};\n\nexport const fitRects = (\n fit: Fit,\n rect: SkRect,\n { x, y, width, height }: SkRect\n) => {\n const sizes = applyBoxFit(\n fit,\n { width: rect.width, height: rect.height },\n { width, height }\n );\n const src = inscribe(sizes.src, rect);\n const dst = inscribe(sizes.dst, {\n x,\n y,\n width,\n height,\n });\n return { src, dst };\n};\n\nconst inscribe = (\n { width, height }: Size,\n rect: { x: number; y: number; width: number; height: number }\n) => {\n const halfWidthDelta = (rect.width - width) / 2.0;\n const halfHeightDelta = (rect.height - height) / 2.0;\n return {\n x: rect.x + halfWidthDelta,\n y: rect.y + halfHeightDelta,\n width,\n height,\n };\n};\n\nconst applyBoxFit = (fit: Fit, input: Size, output: Size) => {\n let src = size(),\n dst = size();\n if (\n input.height <= 0.0 ||\n input.width <= 0.0 ||\n output.height <= 0.0 ||\n output.width <= 0.0\n ) {\n return { src, dst };\n }\n switch (fit) {\n case \"fill\":\n src = input;\n dst = output;\n break;\n case \"contain\":\n src = input;\n if (output.width / output.height > src.width / src.height) {\n dst = size((src.width * output.height) / src.height, output.height);\n } else {\n dst = size(output.width, (src.height * output.width) / src.width);\n }\n break;\n case \"cover\":\n if (output.width / output.height > input.width / input.height) {\n src = size(input.width, (input.width * output.height) / output.width);\n } else {\n src = size((input.height * output.width) / output.height, input.height);\n }\n dst = output;\n break;\n case \"fitWidth\":\n src = size(input.width, (input.width * output.height) / output.width);\n dst = size(output.width, (src.height * output.width) / src.width);\n break;\n case \"fitHeight\":\n src = size((input.height * output.width) / output.height, input.height);\n dst = size((src.width * output.height) / src.height, output.height);\n break;\n case \"none\":\n src = size(\n Math.min(input.width, output.width),\n Math.min(input.height, output.height)\n );\n dst = src;\n break;\n case \"scaleDown\":\n src = input;\n dst = input;\n const aspectRatio = input.width / input.height;\n if (dst.height > output.height) {\n dst = size(output.height * aspectRatio, output.height);\n }\n if (dst.width > output.width) {\n dst = size(output.width, output.width / aspectRatio);\n }\n break;\n default:\n exhaustiveCheck(fit);\n }\n return { src, dst };\n};\n"],"mappings":"AAAA,SAASA,eAAT,QAAgC,6BAAhC;AASA,OAAO,MAAMC,IAAI,GAAG;EAAA,IAACC,KAAD,uEAAS,CAAT;EAAA,IAAYC,MAAZ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CACRsB,IAAI,CAACC,GAAL,CAASH,KAAK,CAACnB,KAAf,EAAsBoB,MAAM,CAACpB,KAA7B,CADQ,EAERqB,IAAI,CAACC,GAAL,CAASH,KAAK,CAAClB,MAAf,EAAuBmB,MAAM,CAACnB,MAA9B,CAFQ,CAAV;MAIAG,GAAG,GAAGD,GAAN;MACA;;IACF,KAAK,WAAL;MACEA,GAAG,GAAGgB,KAAN;MACAf,GAAG,GAAGe,KAAN;MACA,MAAMI,WAAW,GAAGJ,KAAK,CAACnB,KAAN,GAAcmB,KAAK,CAAClB,MAAxC;;MACA,IAAIG,GAAG,CAACH,MAAJ,GAAamB,MAAM,CAACnB,MAAxB,EAAgC;QAC9BG,GAAG,GAAGL,IAAI,CAACqB,MAAM,CAACnB,MAAP,GAAgBsB,WAAjB,EAA8BH,MAAM,CAACnB,MAArC,CAAV;MACD;;MACD,IAAIG,GAAG,CAACJ,KAAJ,GAAYoB,MAAM,CAACpB,KAAvB,EAA8B;QAC5BI,GAAG,GAAGL,IAAI,CAACqB,MAAM,CAACpB,KAAR,EAAeoB,MAAM,CAACpB,KAAP,GAAeuB,WAA9B,CAAV;MACD;;MACD;;IACF;MACEzB,eAAe,CAACc,GAAD,CAAf;EAhDJ;;EAkDA,OAAO;IAAET,GAAF;IAAOC;EAAP,CAAP;AACD,CA9DD"}
1
+ {"version":3,"names":["exhaustiveCheck","size","width","height","rect2rect","src","dst","scaleX","scaleY","translateX","x","translateY","y","fitRects","fit","rect","sizes","applyBoxFit","inscribe","halfWidthDelta","halfHeightDelta","input","output","Math","min","aspectRatio"],"sources":["Fitting.ts"],"sourcesContent":["import { exhaustiveCheck } from \"../../../renderer/typeddash\";\nimport type { SkRect } from \"../../../skia/types\";\nimport type { Fit } from \"../../types\";\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport const size = (width = 0, height = 0) => ({ width, height });\n\nexport const rect2rect = (\n src: SkRect,\n dst: SkRect\n): [\n { translateX: number },\n { translateY: number },\n { scaleX: number },\n { scaleY: number }\n] => {\n const scaleX = dst.width / src.width;\n const scaleY = dst.height / src.height;\n const translateX = dst.x - src.x * scaleX;\n const translateY = dst.y - src.y * scaleY;\n return [{ translateX }, { translateY }, { scaleX }, { scaleY }];\n};\n\nexport const fitRects = (\n fit: Fit,\n rect: SkRect,\n { x, y, width, height }: SkRect\n) => {\n const sizes = applyBoxFit(\n fit,\n { width: rect.width, height: rect.height },\n { width, height }\n );\n const src = inscribe(sizes.src, rect);\n const dst = inscribe(sizes.dst, {\n x,\n y,\n width,\n height,\n });\n return { src, dst };\n};\n\nconst inscribe = (\n { width, height }: Size,\n rect: { x: number; y: number; width: number; height: number }\n) => {\n const halfWidthDelta = (rect.width - width) / 2.0;\n const halfHeightDelta = (rect.height - height) / 2.0;\n return {\n x: rect.x + halfWidthDelta,\n y: rect.y + halfHeightDelta,\n width,\n height,\n };\n};\n\nconst applyBoxFit = (fit: Fit, input: Size, output: Size) => {\n let src = size(),\n dst = size();\n if (\n input.height <= 0.0 ||\n input.width <= 0.0 ||\n output.height <= 0.0 ||\n output.width <= 0.0\n ) {\n return { src, dst };\n }\n switch (fit) {\n case \"fill\":\n src = input;\n dst = output;\n break;\n case \"contain\":\n src = input;\n if (output.width / output.height > src.width / src.height) {\n dst = size((src.width * output.height) / src.height, output.height);\n } else {\n dst = size(output.width, (src.height * output.width) / src.width);\n }\n break;\n case \"cover\":\n if (output.width / output.height > input.width / input.height) {\n src = size(input.width, (input.width * output.height) / output.width);\n } else {\n src = size((input.height * output.width) / output.height, input.height);\n }\n dst = output;\n break;\n case \"fitWidth\":\n src = size(input.width, (input.width * output.height) / output.width);\n dst = size(output.width, (src.height * output.width) / src.width);\n break;\n case \"fitHeight\":\n src = size((input.height * output.width) / output.height, input.height);\n dst = size((src.width * output.height) / src.height, output.height);\n break;\n case \"none\":\n src = size(\n Math.min(input.width, output.width),\n Math.min(input.height, output.height)\n );\n dst = src;\n break;\n case \"scaleDown\":\n src = input;\n dst = input;\n const aspectRatio = input.width / input.height;\n if (dst.height > output.height) {\n dst = size(output.height * aspectRatio, output.height);\n }\n if (dst.width > output.width) {\n dst = size(output.width, output.width / aspectRatio);\n }\n break;\n default:\n exhaustiveCheck(fit);\n }\n return { src, dst };\n};\n"],"mappings":"AAAA,SAASA,eAAT,QAAgC,6BAAhC;AASA,OAAO,MAAMC,IAAI,GAAG;EAAA,IAACC,KAAD,uEAAS,CAAT;EAAA,IAAYC,MAAZ,uEAAqB,CAArB;EAAA,OAA4B;IAAED,KAAF;IAASC;EAAT,CAA5B;AAAA,CAAb;AAEP,OAAO,MAAMC,SAAS,GAAG,CACvBC,GADuB,EAEvBC,GAFuB,KAQpB;EACH,MAAMC,MAAM,GAAGD,GAAG,CAACJ,KAAJ,GAAYG,GAAG,CAACH,KAA/B;EACA,MAAMM,MAAM,GAAGF,GAAG,CAACH,MAAJ,GAAaE,GAAG,CAACF,MAAhC;EACA,MAAMM,UAAU,GAAGH,GAAG,CAACI,CAAJ,GAAQL,GAAG,CAACK,CAAJ,GAAQH,MAAnC;EACA,MAAMI,UAAU,GAAGL,GAAG,CAACM,CAAJ,GAAQP,GAAG,CAACO,CAAJ,GAAQJ,MAAnC;EACA,OAAO,CAAC;IAAEC;EAAF,CAAD,EAAiB;IAAEE;EAAF,CAAjB,EAAiC;IAAEJ;EAAF,CAAjC,EAA6C;IAAEC;EAAF,CAA7C,CAAP;AACD,CAdM;AAgBP,OAAO,MAAMK,QAAQ,GAAG,CACtBC,GADsB,EAEtBC,IAFsB,WAInB;EAAA,IADH;IAAEL,CAAF;IAAKE,CAAL;IAAQV,KAAR;IAAeC;EAAf,CACG;EACH,MAAMa,KAAK,GAAGC,WAAW,CACvBH,GADuB,EAEvB;IAAEZ,KAAK,EAAEa,IAAI,CAACb,KAAd;IAAqBC,MAAM,EAAEY,IAAI,CAACZ;EAAlC,CAFuB,EAGvB;IAAED,KAAF;IAASC;EAAT,CAHuB,CAAzB;EAKA,MAAME,GAAG,GAAGa,QAAQ,CAACF,KAAK,CAAC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CAACpB,KAAvB,GAAgCoB,MAAM,CAACnB,MAAxC,EAAgDkB,KAAK,CAAClB,MAAtD,CAAV;MACAG,GAAG,GAAGL,IAAI,CAAEI,GAAG,CAACH,KAAJ,GAAYoB,MAAM,CAACnB,MAApB,GAA8BE,GAAG,CAACF,MAAnC,EAA2CmB,MAAM,CAACnB,MAAlD,CAAV;MACA;;IACF,KAAK,MAAL;MACEE,GAAG,GAAGJ,IAAI,CACRsB,IAAI,CAACC,GAAL,CAASH,KAAK,CAACnB,KAAf,EAAsBoB,MAAM,CAACpB,KAA7B,CADQ,EAERqB,IAAI,CAACC,GAAL,CAASH,KAAK,CAAClB,MAAf,EAAuBmB,MAAM,CAACnB,MAA9B,CAFQ,CAAV;MAIAG,GAAG,GAAGD,GAAN;MACA;;IACF,KAAK,WAAL;MACEA,GAAG,GAAGgB,KAAN;MACAf,GAAG,GAAGe,KAAN;MACA,MAAMI,WAAW,GAAGJ,KAAK,CAACnB,KAAN,GAAcmB,KAAK,CAAClB,MAAxC;;MACA,IAAIG,GAAG,CAACH,MAAJ,GAAamB,MAAM,CAACnB,MAAxB,EAAgC;QAC9BG,GAAG,GAAGL,IAAI,CAACqB,MAAM,CAACnB,MAAP,GAAgBsB,WAAjB,EAA8BH,MAAM,CAACnB,MAArC,CAAV;MACD;;MACD,IAAIG,GAAG,CAACJ,KAAJ,GAAYoB,MAAM,CAACpB,KAAvB,EAA8B;QAC5BI,GAAG,GAAGL,IAAI,CAACqB,MAAM,CAACpB,KAAR,EAAeoB,MAAM,CAACpB,KAAP,GAAeuB,WAA9B,CAAV;MACD;;MACD;;IACF;MACEzB,eAAe,CAACc,GAAD,CAAf;EAhDJ;;EAkDA,OAAO;IAAET,GAAF;IAAOC;EAAP,CAAP;AACD,CA9DD"}
@@ -1,87 +1,247 @@
1
- import type { Skia, SkRect, Transforms2d, Vector } from "../../../skia/types";
1
+ import type { Skia, SkRect, Transforms3d, Vector } from "../../../skia/types";
2
2
  import { TileMode } from "../../../skia/types";
3
3
  import type { GradientProps, ImageShaderProps } from "../../types";
4
- export declare const transformOrigin: (origin: Vector, transform: Transforms2d) => (Pick<{
5
- readonly translateX: number;
6
- readonly translateY: number;
7
- readonly scale: number;
8
- readonly skewX: number;
9
- readonly skewY: number;
10
- readonly scaleX: number;
11
- readonly scaleY: number;
12
- readonly rotateZ: number;
13
- readonly rotate: number;
4
+ export declare const transformOrigin: (origin: Vector, transform: Transforms3d) => (Pick<{
5
+ translateX: number;
6
+ translateY: number;
7
+ translateZ: number;
8
+ translate: readonly [number, number] | readonly [number, number, number];
9
+ scale: number;
10
+ scaleX: number;
11
+ scaleY: number;
12
+ skewX: number;
13
+ skewY: number;
14
+ rotateZ: number;
15
+ rotate: number;
16
+ perspective: number;
17
+ rotateX: number;
18
+ rotateY: number;
19
+ matrix: import("../../../skia/types").Matrix4;
14
20
  }, "translateX"> | Pick<{
15
- readonly translateX: number;
16
- readonly translateY: number;
17
- readonly scale: number;
18
- readonly skewX: number;
19
- readonly skewY: number;
20
- readonly scaleX: number;
21
- readonly scaleY: number;
22
- readonly rotateZ: number;
23
- readonly rotate: number;
21
+ translateX: number;
22
+ translateY: number;
23
+ translateZ: number;
24
+ translate: readonly [number, number] | readonly [number, number, number];
25
+ scale: number;
26
+ scaleX: number;
27
+ scaleY: number;
28
+ skewX: number;
29
+ skewY: number;
30
+ rotateZ: number;
31
+ rotate: number;
32
+ perspective: number;
33
+ rotateX: number;
34
+ rotateY: number;
35
+ matrix: import("../../../skia/types").Matrix4;
24
36
  }, "translateY"> | Pick<{
25
- readonly translateX: number;
26
- readonly translateY: number;
27
- readonly scale: number;
28
- readonly skewX: number;
29
- readonly skewY: number;
30
- readonly scaleX: number;
31
- readonly scaleY: number;
32
- readonly rotateZ: number;
33
- readonly rotate: number;
37
+ translateX: number;
38
+ translateY: number;
39
+ translateZ: number;
40
+ translate: readonly [number, number] | readonly [number, number, number];
41
+ scale: number;
42
+ scaleX: number;
43
+ scaleY: number;
44
+ skewX: number;
45
+ skewY: number;
46
+ rotateZ: number;
47
+ rotate: number;
48
+ perspective: number;
49
+ rotateX: number;
50
+ rotateY: number;
51
+ matrix: import("../../../skia/types").Matrix4;
52
+ }, "translateZ"> | Pick<{
53
+ translateX: number;
54
+ translateY: number;
55
+ translateZ: number;
56
+ translate: readonly [number, number] | readonly [number, number, number];
57
+ scale: number;
58
+ scaleX: number;
59
+ scaleY: number;
60
+ skewX: number;
61
+ skewY: number;
62
+ rotateZ: number;
63
+ rotate: number;
64
+ perspective: number;
65
+ rotateX: number;
66
+ rotateY: number;
67
+ matrix: import("../../../skia/types").Matrix4;
68
+ }, "translate"> | Pick<{
69
+ translateX: number;
70
+ translateY: number;
71
+ translateZ: number;
72
+ translate: readonly [number, number] | readonly [number, number, number];
73
+ scale: number;
74
+ scaleX: number;
75
+ scaleY: number;
76
+ skewX: number;
77
+ skewY: number;
78
+ rotateZ: number;
79
+ rotate: number;
80
+ perspective: number;
81
+ rotateX: number;
82
+ rotateY: number;
83
+ matrix: import("../../../skia/types").Matrix4;
34
84
  }, "scale"> | Pick<{
35
- readonly translateX: number;
36
- readonly translateY: number;
37
- readonly scale: number;
38
- readonly skewX: number;
39
- readonly skewY: number;
40
- readonly scaleX: number;
41
- readonly scaleY: number;
42
- readonly rotateZ: number;
43
- readonly rotate: number;
85
+ translateX: number;
86
+ translateY: number;
87
+ translateZ: number;
88
+ translate: readonly [number, number] | readonly [number, number, number];
89
+ scale: number;
90
+ scaleX: number;
91
+ scaleY: number;
92
+ skewX: number;
93
+ skewY: number;
94
+ rotateZ: number;
95
+ rotate: number;
96
+ perspective: number;
97
+ rotateX: number;
98
+ rotateY: number;
99
+ matrix: import("../../../skia/types").Matrix4;
44
100
  }, "scaleX"> | Pick<{
45
- readonly translateX: number;
46
- readonly translateY: number;
47
- readonly scale: number;
48
- readonly skewX: number;
49
- readonly skewY: number;
50
- readonly scaleX: number;
51
- readonly scaleY: number;
52
- readonly rotateZ: number;
53
- readonly rotate: number;
101
+ translateX: number;
102
+ translateY: number;
103
+ translateZ: number;
104
+ translate: readonly [number, number] | readonly [number, number, number];
105
+ scale: number;
106
+ scaleX: number;
107
+ scaleY: number;
108
+ skewX: number;
109
+ skewY: number;
110
+ rotateZ: number;
111
+ rotate: number;
112
+ perspective: number;
113
+ rotateX: number;
114
+ rotateY: number;
115
+ matrix: import("../../../skia/types").Matrix4;
54
116
  }, "scaleY"> | Pick<{
55
- readonly translateX: number;
56
- readonly translateY: number;
57
- readonly scale: number;
58
- readonly skewX: number;
59
- readonly skewY: number;
60
- readonly scaleX: number;
61
- readonly scaleY: number;
62
- readonly rotateZ: number;
63
- readonly rotate: number;
117
+ translateX: number;
118
+ translateY: number;
119
+ translateZ: number;
120
+ translate: readonly [number, number] | readonly [number, number, number];
121
+ scale: number;
122
+ scaleX: number;
123
+ scaleY: number;
124
+ skewX: number;
125
+ skewY: number;
126
+ rotateZ: number;
127
+ rotate: number;
128
+ perspective: number;
129
+ rotateX: number;
130
+ rotateY: number;
131
+ matrix: import("../../../skia/types").Matrix4;
64
132
  }, "skewX"> | Pick<{
65
- readonly translateX: number;
66
- readonly translateY: number;
67
- readonly scale: number;
68
- readonly skewX: number;
69
- readonly skewY: number;
70
- readonly scaleX: number;
71
- readonly scaleY: number;
72
- readonly rotateZ: number;
73
- readonly rotate: number;
133
+ translateX: number;
134
+ translateY: number;
135
+ translateZ: number;
136
+ translate: readonly [number, number] | readonly [number, number, number];
137
+ scale: number;
138
+ scaleX: number;
139
+ scaleY: number;
140
+ skewX: number;
141
+ skewY: number;
142
+ rotateZ: number;
143
+ rotate: number;
144
+ perspective: number;
145
+ rotateX: number;
146
+ rotateY: number;
147
+ matrix: import("../../../skia/types").Matrix4;
74
148
  }, "skewY"> | Pick<{
75
- readonly translateX: number;
76
- readonly translateY: number;
77
- readonly scale: number;
78
- readonly skewX: number;
79
- readonly skewY: number;
80
- readonly scaleX: number;
81
- readonly scaleY: number;
82
- readonly rotateZ: number;
83
- readonly rotate: number;
84
- }, "rotate">)[];
149
+ translateX: number;
150
+ translateY: number;
151
+ translateZ: number;
152
+ translate: readonly [number, number] | readonly [number, number, number];
153
+ scale: number;
154
+ scaleX: number;
155
+ scaleY: number;
156
+ skewX: number;
157
+ skewY: number;
158
+ rotateZ: number;
159
+ rotate: number;
160
+ perspective: number;
161
+ rotateX: number;
162
+ rotateY: number;
163
+ matrix: import("../../../skia/types").Matrix4;
164
+ }, "perspective"> | Pick<{
165
+ translateX: number;
166
+ translateY: number;
167
+ translateZ: number;
168
+ translate: readonly [number, number] | readonly [number, number, number];
169
+ scale: number;
170
+ scaleX: number;
171
+ scaleY: number;
172
+ skewX: number;
173
+ skewY: number;
174
+ rotateZ: number;
175
+ rotate: number;
176
+ perspective: number;
177
+ rotateX: number;
178
+ rotateY: number;
179
+ matrix: import("../../../skia/types").Matrix4;
180
+ }, "rotateX"> | Pick<{
181
+ translateX: number;
182
+ translateY: number;
183
+ translateZ: number;
184
+ translate: readonly [number, number] | readonly [number, number, number];
185
+ scale: number;
186
+ scaleX: number;
187
+ scaleY: number;
188
+ skewX: number;
189
+ skewY: number;
190
+ rotateZ: number;
191
+ rotate: number;
192
+ perspective: number;
193
+ rotateX: number;
194
+ rotateY: number;
195
+ matrix: import("../../../skia/types").Matrix4;
196
+ }, "rotateY"> | Pick<{
197
+ translateX: number;
198
+ translateY: number;
199
+ translateZ: number;
200
+ translate: readonly [number, number] | readonly [number, number, number];
201
+ scale: number;
202
+ scaleX: number;
203
+ scaleY: number;
204
+ skewX: number;
205
+ skewY: number;
206
+ rotateZ: number;
207
+ rotate: number;
208
+ perspective: number;
209
+ rotateX: number;
210
+ rotateY: number;
211
+ matrix: import("../../../skia/types").Matrix4;
212
+ }, "rotateZ"> | Pick<{
213
+ translateX: number;
214
+ translateY: number;
215
+ translateZ: number;
216
+ translate: readonly [number, number] | readonly [number, number, number];
217
+ scale: number;
218
+ scaleX: number;
219
+ scaleY: number;
220
+ skewX: number;
221
+ skewY: number;
222
+ rotateZ: number;
223
+ rotate: number;
224
+ perspective: number;
225
+ rotateX: number;
226
+ rotateY: number;
227
+ matrix: import("../../../skia/types").Matrix4;
228
+ }, "rotate"> | Pick<{
229
+ translateX: number;
230
+ translateY: number;
231
+ translateZ: number;
232
+ translate: readonly [number, number] | readonly [number, number, number];
233
+ scale: number;
234
+ scaleX: number;
235
+ scaleY: number;
236
+ skewX: number;
237
+ skewY: number;
238
+ rotateZ: number;
239
+ rotate: number;
240
+ perspective: number;
241
+ rotateX: number;
242
+ rotateY: number;
243
+ matrix: import("../../../skia/types").Matrix4;
244
+ }, "matrix">)[];
85
245
  export declare const processGradientProps: (Skia: Skia, { colors, positions, mode, flags, ...transform }: GradientProps) => {
86
246
  colors: Float32Array[];
87
247
  positions: number[] | null;
@@ -1 +1 @@
1
- {"version":3,"names":["TileMode","enumKey","processTransformProps","transformOrigin","origin","transform","translateX","x","translateY","y","processGradientProps","Skia","colors","positions","mode","flags","localMatrix","Matrix","map","color","Color","getRect","props","width","height","rect","undefined","XYWHRect"],"sources":["Gradient.ts"],"sourcesContent":["import type { Skia, SkRect, Transforms2d, Vector } from \"../../../skia/types\";\nimport { TileMode } from \"../../../skia/types\";\nimport type { GradientProps, ImageShaderProps } from \"../../types\";\n\nimport { enumKey } from \"./Enum\";\nimport { processTransformProps } from \"./Transform\";\n\nexport const transformOrigin = (origin: Vector, transform: Transforms2d) => [\n { translateX: origin.x },\n { translateY: origin.y },\n ...transform,\n { translateX: -origin.x },\n { translateY: -origin.y },\n];\n\nexport const processGradientProps = (\n Skia: Skia,\n { colors, positions, mode, flags, ...transform }: GradientProps\n) => {\n const localMatrix = Skia.Matrix();\n processTransformProps(localMatrix, transform);\n return {\n colors: colors.map((color) => Skia.Color(color)),\n positions: positions ?? null,\n mode: TileMode[enumKey(mode ?? \"clamp\")],\n flags,\n localMatrix,\n };\n};\n\nexport const getRect = (\n Skia: Skia,\n props: Omit<ImageShaderProps, \"tx\" | \"ty\" | \"fm\" | \"mm\" | \"fit\" | \"image\">\n): SkRect | undefined => {\n const { x, y, width, height } = props;\n if (props.rect) {\n return props.rect;\n } else if (\n x !== undefined &&\n y !== undefined &&\n width !== undefined &&\n height !== undefined\n ) {\n return Skia.XYWHRect(x, y, width, height);\n } else {\n return undefined;\n }\n};\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,qBAAzB;AAGA,SAASC,OAAT,QAAwB,QAAxB;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA,OAAO,MAAMC,eAAe,GAAG,CAACC,MAAD,EAAiBC,SAAjB,KAA6C,CAC1E;EAAEC,UAAU,EAAEF,MAAM,CAACG;AAArB,CAD0E,EAE1E;EAAEC,UAAU,EAAEJ,MAAM,CAACK;AAArB,CAF0E,EAG1E,GAAGJ,SAHuE,EAI1E;EAAEC,UAAU,EAAE,CAACF,MAAM,CAACG;AAAtB,CAJ0E,EAK1E;EAAEC,UAAU,EAAE,CAACJ,MAAM,CAACK;AAAtB,CAL0E,CAArE;AAQP,OAAO,MAAMC,oBAAoB,GAAG,CAClCC,IADkC,WAG/B;EAAA,IADH;IAAEC,MAAF;IAAUC,SAAV;IAAqBC,IAArB;IAA2BC,KAA3B;IAAkC,GAAGV;EAArC,CACG;EACH,MAAMW,WAAW,GAAGL,IAAI,CAACM,MAAL,EAApB;EACAf,qBAAqB,CAACc,WAAD,EAAcX,SAAd,CAArB;EACA,OAAO;IACLO,MAAM,EAAEA,MAAM,CAACM,GAAP,CAAYC,KAAD,IAAWR,IAAI,CAACS,KAAL,CAAWD,KAAX,CAAtB,CADH;IAELN,SAAS,EAAEA,SAAF,aAAEA,SAAF,cAAEA,SAAF,GAAe,IAFnB;IAGLC,IAAI,EAAEd,QAAQ,CAACC,OAAO,CAACa,IAAD,aAACA,IAAD,cAACA,IAAD,GAAS,OAAT,CAAR,CAHT;IAILC,KAJK;IAKLC;EALK,CAAP;AAOD,CAbM;AAeP,OAAO,MAAMK,OAAO,GAAG,CACrBV,IADqB,EAErBW,KAFqB,KAGE;EACvB,MAAM;IAAEf,CAAF;IAAKE,CAAL;IAAQc,KAAR;IAAeC;EAAf,IAA0BF,KAAhC;;EACA,IAAIA,KAAK,CAACG,IAAV,EAAgB;IACd,OAAOH,KAAK,CAACG,IAAb;EACD,CAFD,MAEO,IACLlB,CAAC,KAAKmB,SAAN,IACAjB,CAAC,KAAKiB,SADN,IAEAH,KAAK,KAAKG,SAFV,IAGAF,MAAM,KAAKE,SAJN,EAKL;IACA,OAAOf,IAAI,CAACgB,QAAL,CAAcpB,CAAd,EAAiBE,CAAjB,EAAoBc,KAApB,EAA2BC,MAA3B,CAAP;EACD,CAPM,MAOA;IACL,OAAOE,SAAP;EACD;AACF,CAjBM"}
1
+ {"version":3,"names":["TileMode","enumKey","processTransformProps","transformOrigin","origin","transform","translateX","x","translateY","y","processGradientProps","Skia","colors","positions","mode","flags","localMatrix","Matrix","map","color","Color","getRect","props","width","height","rect","undefined","XYWHRect"],"sources":["Gradient.ts"],"sourcesContent":["import type { Skia, SkRect, Transforms3d, Vector } from \"../../../skia/types\";\nimport { TileMode } from \"../../../skia/types\";\nimport type { GradientProps, ImageShaderProps } from \"../../types\";\n\nimport { enumKey } from \"./Enum\";\nimport { processTransformProps } from \"./Transform\";\n\nexport const transformOrigin = (origin: Vector, transform: Transforms3d) => [\n { translateX: origin.x },\n { translateY: origin.y },\n ...transform,\n { translateX: -origin.x },\n { translateY: -origin.y },\n];\n\nexport const processGradientProps = (\n Skia: Skia,\n { colors, positions, mode, flags, ...transform }: GradientProps\n) => {\n const localMatrix = Skia.Matrix();\n processTransformProps(localMatrix, transform);\n return {\n colors: colors.map((color) => Skia.Color(color)),\n positions: positions ?? null,\n mode: TileMode[enumKey(mode ?? \"clamp\")],\n flags,\n localMatrix,\n };\n};\n\nexport const getRect = (\n Skia: Skia,\n props: Omit<ImageShaderProps, \"tx\" | \"ty\" | \"fm\" | \"mm\" | \"fit\" | \"image\">\n): SkRect | undefined => {\n const { x, y, width, height } = props;\n if (props.rect) {\n return props.rect;\n } else if (\n x !== undefined &&\n y !== undefined &&\n width !== undefined &&\n height !== undefined\n ) {\n return Skia.XYWHRect(x, y, width, height);\n } else {\n return undefined;\n }\n};\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,qBAAzB;AAGA,SAASC,OAAT,QAAwB,QAAxB;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA,OAAO,MAAMC,eAAe,GAAG,CAACC,MAAD,EAAiBC,SAAjB,KAA6C,CAC1E;EAAEC,UAAU,EAAEF,MAAM,CAACG;AAArB,CAD0E,EAE1E;EAAEC,UAAU,EAAEJ,MAAM,CAACK;AAArB,CAF0E,EAG1E,GAAGJ,SAHuE,EAI1E;EAAEC,UAAU,EAAE,CAACF,MAAM,CAACG;AAAtB,CAJ0E,EAK1E;EAAEC,UAAU,EAAE,CAACJ,MAAM,CAACK;AAAtB,CAL0E,CAArE;AAQP,OAAO,MAAMC,oBAAoB,GAAG,CAClCC,IADkC,WAG/B;EAAA,IADH;IAAEC,MAAF;IAAUC,SAAV;IAAqBC,IAArB;IAA2BC,KAA3B;IAAkC,GAAGV;EAArC,CACG;EACH,MAAMW,WAAW,GAAGL,IAAI,CAACM,MAAL,EAApB;EACAf,qBAAqB,CAACc,WAAD,EAAcX,SAAd,CAArB;EACA,OAAO;IACLO,MAAM,EAAEA,MAAM,CAACM,GAAP,CAAYC,KAAD,IAAWR,IAAI,CAACS,KAAL,CAAWD,KAAX,CAAtB,CADH;IAELN,SAAS,EAAEA,SAAF,aAAEA,SAAF,cAAEA,SAAF,GAAe,IAFnB;IAGLC,IAAI,EAAEd,QAAQ,CAACC,OAAO,CAACa,IAAD,aAACA,IAAD,cAACA,IAAD,GAAS,OAAT,CAAR,CAHT;IAILC,KAJK;IAKLC;EALK,CAAP;AAOD,CAbM;AAeP,OAAO,MAAMK,OAAO,GAAG,CACrBV,IADqB,EAErBW,KAFqB,KAGE;EACvB,MAAM;IAAEf,CAAF;IAAKE,CAAL;IAAQc,KAAR;IAAeC;EAAf,IAA0BF,KAAhC;;EACA,IAAIA,KAAK,CAACG,IAAV,EAAgB;IACd,OAAOH,KAAK,CAACG,IAAb;EACD,CAFD,MAEO,IACLlB,CAAC,KAAKmB,SAAN,IACAjB,CAAC,KAAKiB,SADN,IAEAH,KAAK,KAAKG,SAFV,IAGAF,MAAM,KAAKE,SAJN,EAKL;IACA,OAAOf,IAAI,CAACgB,QAAL,CAAcpB,CAAd,EAAiBE,CAAjB,EAAoBc,KAApB,EAA2BC,MAA3B,CAAP;EACD,CAPM,MAOA;IACL,OAAOE,SAAP;EACD;AACF,CAjBM"}
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { BlendMode, Color, PaintStyle, SkMatrix, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms2d, Vector } from "../../skia/types";
2
+ import type { BlendMode, Color, 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;
@@ -34,9 +34,9 @@ export interface ScalarCircleDef {
34
34
  }
35
35
  export type CircleDef = PointCircleDef | ScalarCircleDef;
36
36
  export interface TransformProps {
37
- transform?: Transforms2d;
37
+ transform?: Transforms3d;
38
38
  origin?: Vector;
39
- matrix?: SkMatrix;
39
+ matrix?: SkMatrix | 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 Transforms2d,\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?: Transforms2d;\n origin?: Vector;\n matrix?: SkMatrix;\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 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,17 +1,23 @@
1
- import { useMemo } from "react";
1
+ import { useMemo, useRef } from "react";
2
2
  import { interpolatePaths, interpolateVector } from "../../animation";
3
3
  import { Skia } from "../../skia";
4
4
  import { useAnimatedReaction, useFrameCallback, useSharedValue } from "./moduleWrapper";
5
5
  export const notifyChange = value => {
6
- "worklet"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ "worklet";
7
7
 
8
- value._value = value.value;
8
+ if (_WORKLET) {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ value._value = value.value;
11
+ }
9
12
  };
10
13
  export const useClock = () => {
11
14
  const clock = useSharedValue(0);
12
- useFrameCallback(info => {
15
+ const callback = useRef(info => {
16
+ "worklet";
17
+
13
18
  clock.value = info.timeSinceFirstFrame;
14
- });
19
+ }).current;
20
+ useFrameCallback(callback);
15
21
  return clock;
16
22
  };
17
23
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","interpolatePaths","interpolateVector","Skia","useAnimatedReaction","useFrameCallback","useSharedValue","notifyChange","value","_value","useClock","clock","info","timeSinceFirstFrame","useInterpolator","factory","interpolator","input","output","options","init","result","val","usePathInterpolation","outputRange","Path","Make","useVectorInterpolation","Point"],"sources":["interpolators.ts"],"sourcesContent":["import type { ExtrapolationType, SharedValue } from \"react-native-reanimated\";\nimport { 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} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n useFrameCallback((info) => {\n clock.value = info.timeSinceFirstFrame;\n });\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":"AACA,SAASA,OAAT,QAAwB,OAAxB;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,UAD2D,CAE3D;;EACCA,KAAD,CAAeC,MAAf,GAAwBD,KAAK,CAACA,KAA9B;AACD,CAJM;AAMP,OAAO,MAAME,QAAQ,GAAG,MAAM;EAC5B,MAAMC,KAAK,GAAGL,cAAc,CAAC,CAAD,CAA5B;EACAD,gBAAgB,CAAEO,IAAD,IAAU;IACzBD,KAAK,CAACH,KAAN,GAAcI,IAAI,CAACC,mBAAnB;EACD,CAFe,CAAhB;EAGA,OAAOF,KAAP;AACD,CANM;AAQP;AACA;AACA;;AASA,MAAMG,eAAe,GAAG,CACtBC,OADsB,EAEtBP,KAFsB,EAGtBQ,YAHsB,EAItBC,KAJsB,EAKtBC,MALsB,EAMtBC,OANsB,KAOnB;EACH;EACA,MAAMC,IAAI,GAAGpB,OAAO,CAAC,MAAMe,OAAO,EAAd,EAAkB,EAAlB,CAApB;EACA,MAAMM,MAAM,GAAGf,cAAc,CAACc,IAAD,CAA7B;EACAhB,mBAAmB,CACjB,MAAMI,KAAK,CAACA,KADK,EAEhBc,GAAD,IAAS;IACPD,MAAM,CAACb,KAAP,GAAeQ,YAAY,CAACM,GAAD,EAAML,KAAN,EAAaC,MAAb,EAAqBC,OAArB,EAA8BE,MAAM,CAACb,KAArC,CAA3B;IACAD,YAAY,CAACc,MAAD,CAAZ;EACD,CALgB,EAMjB,CAACJ,KAAD,EAAQC,MAAR,EAAgBC,OAAhB,CANiB,CAAnB;EAQA,OAAOE,MAAP;AACD,CApBD;;AAsBA,OAAO,MAAME,oBAAoB,GAAG,CAClCf,KADkC,EAElCS,KAFkC,EAGlCO,WAHkC,EAIlCL,OAJkC,KAMlCL,eAAe,CACb,MAAMX,IAAI,CAACsB,IAAL,CAAUC,IAAV,EADO,EAEblB,KAFa,EAGbP,gBAHa,EAIbgB,KAJa,EAKbO,WALa,EAMbL,OANa,CANV;AAeP,OAAO,MAAMQ,sBAAsB,GAAG,CACpCnB,KADoC,EAEpCS,KAFoC,EAGpCO,WAHoC,EAIpCL,OAJoC,KAMpCL,eAAe,CACb,MAAMX,IAAI,CAACyB,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEbpB,KAFa,EAGbN,iBAHa,EAIbe,KAJa,EAKbO,WALa,EAMbL,OANa,CANV"}
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;IAC3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 -1,34 +1,37 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { useEffect, useCallback, useMemo, forwardRef, useRef, useLayoutEffect } from "react";
4
- import { SkiaDomView, SkiaView } from "../views";
3
+ import React, { useEffect, useCallback, useMemo, forwardRef, useRef } from "react";
4
+ import { SkiaDomView, SkiaPictureView } from "../views";
5
5
  import { Skia } from "../skia/Skia";
6
6
  import { JsiDrawingContext } from "../dom/types";
7
- import { useValue } from "../values";
8
7
  import { SkiaRoot } from "./Reconciler";
9
8
  import { NATIVE_DOM } from "./HostComponents";
10
9
  import { isValue } from "./processors";
11
10
  export const useCanvasRef = () => useRef(null);
12
11
 
13
- const useOnSizeEvent = resultValue => {
14
- const onSize = useValue({
15
- width: 0,
16
- height: 0
17
- });
18
- useLayoutEffect(() => {
19
- if (!resultValue) {
20
- return;
12
+ const useOnSizeEvent = (resultValue, onLayout) => {
13
+ return useCallback(event => {
14
+ if (onLayout) {
15
+ onLayout(event);
21
16
  }
22
17
 
23
- return onSize.addListener(newValue => {
24
- if (isValue(resultValue)) {
25
- resultValue.current = newValue;
26
- } else {
27
- resultValue.value = newValue;
28
- }
29
- });
30
- }, [resultValue, onSize]);
31
- return onSize;
18
+ const {
19
+ width,
20
+ height
21
+ } = event.nativeEvent.layout;
22
+
23
+ if (isValue(resultValue)) {
24
+ resultValue.current = {
25
+ width,
26
+ height
27
+ };
28
+ } else if (resultValue) {
29
+ resultValue.value = {
30
+ width,
31
+ height
32
+ };
33
+ }
34
+ }, [onLayout, resultValue]);
32
35
  };
33
36
 
34
37
  export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
@@ -39,9 +42,10 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
39
42
  mode,
40
43
  onTouch,
41
44
  onSize: _onSize,
45
+ onLayout: _onLayout,
42
46
  ...props
43
47
  } = _ref;
44
- const onSize = useOnSizeEvent(_onSize);
48
+ const onLayout = useOnSizeEvent(_onSize, _onLayout);
45
49
  const innerRef = useCanvasRef();
46
50
  const ref = useCombinedRefs(forwardedRef, innerRef);
47
51
  const redraw = useCallback(() => {
@@ -79,23 +83,25 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
79
83
  style: style,
80
84
  root: root.dom,
81
85
  onTouch: onTouch,
82
- onSize: onSize,
86
+ onLayout: onLayout,
83
87
  mode: mode,
84
88
  debug: debug
85
89
  }, props));
86
90
  } else {
87
- return /*#__PURE__*/React.createElement(SkiaView // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
+ // This is for debugging
92
+ const recorder = Skia.PictureRecorder();
93
+ const canvas = recorder.beginRecording(Skia.XYWHRect(0, 0, 2_000_000, 2_000_000));
94
+ const ctx = new JsiDrawingContext(Skia, canvas);
95
+ root.dom.render(ctx);
96
+ const picture = recorder.finishRecordingAsPicture();
97
+ return /*#__PURE__*/React.createElement(SkiaPictureView // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
98
  , _extends({
89
99
  ref: ref,
90
100
  style: style,
91
101
  mode: mode,
92
102
  debug: debug,
93
- onSize: onSize,
94
- onDraw: (canvas, info) => {
95
- onTouch && onTouch(info.touches);
96
- const ctx = new JsiDrawingContext(Skia, canvas);
97
- root.dom.render(ctx);
98
- }
103
+ picture: picture,
104
+ onLayout: onLayout
99
105
  }, props));
100
106
  }
101
107
  });
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","useLayoutEffect","SkiaDomView","SkiaView","Skia","JsiDrawingContext","useValue","SkiaRoot","NATIVE_DOM","isValue","useCanvasRef","useOnSizeEvent","resultValue","onSize","width","height","addListener","newValue","current","value","Canvas","forwardedRef","children","style","debug","mode","onTouch","_onSize","props","innerRef","ref","useCombinedRefs","redraw","getNativeId","id","nativeId","registerValues","values","root","render","unmount","dom","canvas","info","touches","ctx","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n useLayoutEffect,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\n\nimport { SkiaDomView, SkiaView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\nimport { JsiDrawingContext } from \"../dom/types\";\nimport { useValue } from \"../values\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\nimport { isValue } from \"./processors\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (resultValue: SkiaBaseViewProps[\"onSize\"]) => {\n const onSize = useValue({\n width: 0,\n height: 0,\n });\n\n useLayoutEffect(() => {\n if (!resultValue) {\n return;\n }\n return onSize.addListener((newValue) => {\n if (isValue(resultValue)) {\n resultValue.current = newValue;\n } else {\n resultValue.value = newValue;\n }\n });\n }, [resultValue, onSize]);\n\n return onSize;\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize: _onSize, ...props },\n forwardedRef\n ) => {\n const onSize = useOnSizeEvent(_onSize);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaView\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n mode={mode}\n debug={debug}\n onSize={onSize}\n onDraw={(canvas, info) => {\n onTouch && onTouch(info.touches);\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n }}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,EAIEC,UAJF,EAKEC,MALF,EAMEC,eANF,QAOO,OAPP;AAgBA,SAASC,WAAT,EAAsBC,QAAtB,QAAsC,UAAtC;AACA,SAASC,IAAT,QAAqB,cAArB;AAGA,SAASC,iBAAT,QAAkC,cAAlC;AACA,SAASC,QAAT,QAAyB,WAAzB;AAEA,SAASC,QAAT,QAAyB,cA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,IAAI,EAAEE,IAJR;MAKE,KAAK,EAAED,KALT;MAME,MAAM,EAAEX,MANV;MAOE,MAAM,EAAE,CAAC6B,MAAD,EAASC,IAAT,KAAkB;QACxBjB,OAAO,IAAIA,OAAO,CAACiB,IAAI,CAACC,OAAN,CAAlB;QACA,MAAMC,GAAG,GAAG,IAAIxC,iBAAJ,CAAsBD,IAAtB,EAA4BsC,MAA5B,CAAZ;QACAJ,IAAI,CAACG,GAAL,CAASF,MAAT,CAAgBM,GAAhB;MACD;IAXH,GAYMjB,KAZN,EADF;EAgBD;AACF,CAvE6B,CAAzB;AA0EP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAe,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGpD,KAAK,CAACK,MAAN,CAAgB,IAAhB,CAAlB;EACAL,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpBkD,IAAI,CAACE,OAAL,CAAclB,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACiB,SAAS,CAAC7B,OAAX,CAAH;QACD,CAFD,MAEO;UACLY,GAAG,CAACZ,OAAJ,GAAc6B,SAAS,CAAC7B,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAAC4B,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
1
+ {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","SkiaPictureView","Skia","JsiDrawingContext","SkiaRoot","NATIVE_DOM","isValue","useCanvasRef","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","current","value","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","getNativeId","id","nativeId","registerValues","values","root","render","unmount","dom","recorder","PictureRecorder","canvas","beginRecording","XYWHRect","ctx","picture","finishRecordingAsPicture","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView, SkiaPictureView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\nimport { isValue } from \"./processors\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (isValue(resultValue)) {\n resultValue.current = { width, height };\n } else if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n // This is for debugging\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(\n Skia.XYWHRect(0, 0, 2_000_000, 2_000_000)\n );\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n const picture = recorder.finishRecordingAsPicture();\n return (\n <SkiaPictureView\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n mode={mode}\n debug={debug}\n picture={picture}\n onLayout={onLayout}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,EAIEC,UAJF,EAKEC,MALF,QAMO,OANP;AAgBA,SAASC,WAAT,EAAsBC,eAAtB,QAA6C,UAA7C;AACA,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import type { CustomDrawingNodeProps } from "../../dom/types";
3
+ /**
4
+ * @deprecated If you are looking to use the Skia imperative API, you can use:
5
+ * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
6
+ * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
7
+ */
3
8
  export declare const Drawing: (props: CustomDrawingNodeProps) => React.JSX.Element;