@shopify/react-native-skia 0.1.140 → 0.1.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +2 -2
  2. package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +1 -1
  3. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +15 -16
  4. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +2 -2
  5. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +69 -27
  6. package/cpp/api/JsiSkPathFactory.h +1 -1
  7. package/cpp/api/JsiSkPicture.h +7 -1
  8. package/cpp/rnskia/RNSkDrawView.cpp +66 -66
  9. package/cpp/rnskia/RNSkDrawView.h +22 -6
  10. package/cpp/rnskia/RNSkJsiViewApi.h +2 -2
  11. package/cpp/rnskia/values/RNSkComputedValue.h +10 -7
  12. package/cpp/rnskia/values/RNSkReadonlyValue.h +21 -2
  13. package/cpp/rnskia/values/RNSkValue.h +1 -0
  14. package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +1 -1
  15. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +2 -2
  16. package/ios/RNSkia-iOS/SkiaDrawView.mm +4 -0
  17. package/lib/commonjs/mock/index.js +3 -1
  18. package/lib/commonjs/mock/index.js.map +1 -1
  19. package/lib/commonjs/renderer/DependencyManager.js +1 -1
  20. package/lib/commonjs/renderer/DependencyManager.js.map +1 -1
  21. package/lib/commonjs/renderer/components/Blend.js +20 -5
  22. package/lib/commonjs/renderer/components/Blend.js.map +1 -1
  23. package/lib/commonjs/renderer/components/imageFilters/Morphology.js +1 -1
  24. package/lib/commonjs/renderer/components/imageFilters/Morphology.js.map +1 -1
  25. package/lib/commonjs/renderer/components/imageFilters/Shadow.js +1 -1
  26. package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -1
  27. package/lib/commonjs/renderer/processors/Animations/Animations.js +18 -5
  28. package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
  29. package/lib/commonjs/skia/core/Data.js +10 -22
  30. package/lib/commonjs/skia/core/Data.js.map +1 -1
  31. package/lib/commonjs/skia/core/Font.js +2 -3
  32. package/lib/commonjs/skia/core/Font.js.map +1 -1
  33. package/lib/commonjs/skia/core/Image.js.map +1 -1
  34. package/lib/commonjs/skia/core/SVG.js.map +1 -1
  35. package/lib/commonjs/skia/core/Typeface.js.map +1 -1
  36. package/lib/commonjs/skia/types/Data/Data.js +5 -0
  37. package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
  38. package/lib/commonjs/skia/web/Host.js +12 -21
  39. package/lib/commonjs/skia/web/Host.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkCanvas.js +50 -28
  41. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +4 -4
  43. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkFont.js +7 -3
  45. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  46. package/lib/commonjs/skia/web/JsiSkImage.js +4 -2
  47. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkImageFactory.js +4 -2
  49. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +61 -19
  51. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  52. package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
  53. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  54. package/lib/commonjs/skia/web/JsiSkPaint.js +15 -6
  55. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  56. package/lib/commonjs/skia/web/JsiSkPath.js +16 -60
  57. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  58. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +7 -3
  59. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  60. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  61. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  62. package/lib/commonjs/skia/web/JsiSkPicture.js +5 -1
  63. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  64. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +3 -1
  65. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
  66. package/lib/commonjs/skia/web/JsiSkPoint.js +9 -1
  67. package/lib/commonjs/skia/web/JsiSkPoint.js.map +1 -1
  68. package/lib/commonjs/skia/web/JsiSkRRect.js +9 -1
  69. package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
  70. package/lib/commonjs/skia/web/JsiSkRSXform.js.map +1 -1
  71. package/lib/commonjs/skia/web/JsiSkRect.js +3 -3
  72. package/lib/commonjs/skia/web/JsiSkRect.js.map +1 -1
  73. package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js +4 -2
  74. package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  75. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +10 -6
  76. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  77. package/lib/commonjs/skia/web/JsiSkSurface.js +3 -1
  78. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  79. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +8 -4
  80. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  81. package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js +1 -1
  82. package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js.map +1 -1
  83. package/lib/commonjs/skia/web/JsiSkia.js +12 -6
  84. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  85. package/lib/commonjs/values/hooks/useComputedValue.js +6 -2
  86. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  87. package/lib/commonjs/values/index.js +13 -0
  88. package/lib/commonjs/values/index.js.map +1 -1
  89. package/lib/commonjs/values/selector.js +24 -0
  90. package/lib/commonjs/values/selector.js.map +1 -0
  91. package/lib/commonjs/values/web/RNSkComputedValue.js +8 -0
  92. package/lib/commonjs/values/web/RNSkComputedValue.js.map +1 -1
  93. package/lib/commonjs/values/web/RNSkReadonlyValue.js +4 -0
  94. package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -1
  95. package/lib/commonjs/views/useTouchHandler.js +13 -20
  96. package/lib/commonjs/views/useTouchHandler.js.map +1 -1
  97. package/lib/module/mock/index.js +2 -1
  98. package/lib/module/mock/index.js.map +1 -1
  99. package/lib/module/renderer/DependencyManager.js +2 -2
  100. package/lib/module/renderer/DependencyManager.js.map +1 -1
  101. package/lib/module/renderer/components/Blend.js +21 -5
  102. package/lib/module/renderer/components/Blend.js.map +1 -1
  103. package/lib/module/renderer/components/imageFilters/Morphology.js +1 -1
  104. package/lib/module/renderer/components/imageFilters/Morphology.js.map +1 -1
  105. package/lib/module/renderer/components/imageFilters/Shadow.js +1 -1
  106. package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -1
  107. package/lib/module/renderer/processors/Animations/Animations.js +13 -4
  108. package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
  109. package/lib/module/skia/core/Data.js +10 -20
  110. package/lib/module/skia/core/Data.js.map +1 -1
  111. package/lib/module/skia/core/Font.js +2 -3
  112. package/lib/module/skia/core/Font.js.map +1 -1
  113. package/lib/module/skia/core/Image.js.map +1 -1
  114. package/lib/module/skia/core/SVG.js.map +1 -1
  115. package/lib/module/skia/core/Typeface.js.map +1 -1
  116. package/lib/module/skia/types/Data/Data.js +1 -1
  117. package/lib/module/skia/types/Data/Data.js.map +1 -1
  118. package/lib/module/skia/web/Host.js +9 -9
  119. package/lib/module/skia/web/Host.js.map +1 -1
  120. package/lib/module/skia/web/JsiSkCanvas.js +40 -29
  121. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  122. package/lib/module/skia/web/JsiSkColorFilterFactory.js +5 -5
  123. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  124. package/lib/module/skia/web/JsiSkFont.js +6 -4
  125. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  126. package/lib/module/skia/web/JsiSkImage.js +4 -3
  127. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  128. package/lib/module/skia/web/JsiSkImageFactory.js +4 -3
  129. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  130. package/lib/module/skia/web/JsiSkImageFilterFactory.js +61 -20
  131. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  132. package/lib/module/skia/web/JsiSkMatrix.js +2 -2
  133. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  134. package/lib/module/skia/web/JsiSkPaint.js +11 -7
  135. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  136. package/lib/module/skia/web/JsiSkPath.js +15 -62
  137. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  138. package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -4
  139. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  140. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  141. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  142. package/lib/module/skia/web/JsiSkPicture.js +4 -2
  143. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  144. package/lib/module/skia/web/JsiSkPictureRecorder.js +3 -2
  145. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  146. package/lib/module/skia/web/JsiSkPoint.js +10 -2
  147. package/lib/module/skia/web/JsiSkPoint.js.map +1 -1
  148. package/lib/module/skia/web/JsiSkRRect.js +10 -2
  149. package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
  150. package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
  151. package/lib/module/skia/web/JsiSkRect.js +4 -4
  152. package/lib/module/skia/web/JsiSkRect.js.map +1 -1
  153. package/lib/module/skia/web/JsiSkRuntimeEffect.js +4 -3
  154. package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
  155. package/lib/module/skia/web/JsiSkShaderFactory.js +9 -7
  156. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  157. package/lib/module/skia/web/JsiSkSurface.js +3 -2
  158. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  159. package/lib/module/skia/web/JsiSkTextBlobFactory.js +7 -5
  160. package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  161. package/lib/module/skia/web/JsiSkTypefaceFactory.js +2 -2
  162. package/lib/module/skia/web/JsiSkTypefaceFactory.js.map +1 -1
  163. package/lib/module/skia/web/JsiSkia.js +10 -5
  164. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  165. package/lib/module/values/hooks/useComputedValue.js +7 -3
  166. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  167. package/lib/module/values/index.js +1 -0
  168. package/lib/module/values/index.js.map +1 -1
  169. package/lib/module/values/selector.js +15 -0
  170. package/lib/module/values/selector.js.map +1 -0
  171. package/lib/module/values/web/RNSkComputedValue.js +8 -0
  172. package/lib/module/values/web/RNSkComputedValue.js.map +1 -1
  173. package/lib/module/values/web/RNSkReadonlyValue.js +4 -0
  174. package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -1
  175. package/lib/module/views/useTouchHandler.js +12 -19
  176. package/lib/module/views/useTouchHandler.js.map +1 -1
  177. package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +7 -2
  178. package/lib/typescript/src/skia/core/Data.d.ts +3 -5
  179. package/lib/typescript/src/skia/core/Font.d.ts +2 -2
  180. package/lib/typescript/src/skia/core/Image.d.ts +2 -2
  181. package/lib/typescript/src/skia/core/SVG.d.ts +2 -2
  182. package/lib/typescript/src/skia/core/Typeface.d.ts +2 -2
  183. package/lib/typescript/src/skia/types/Data/Data.d.ts +10 -3
  184. package/lib/typescript/src/skia/types/Picture/Picture.d.ts +2 -1
  185. package/lib/typescript/src/skia/web/Host.d.ts +5 -7
  186. package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +8 -8
  187. package/lib/typescript/src/skia/web/JsiSkPoint.d.ts +3 -2
  188. package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +3 -2
  189. package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +1 -2
  190. package/lib/typescript/src/skia/web/JsiSkRect.d.ts +3 -3
  191. package/lib/typescript/src/skia/web/JsiSkTextBlobFactory.d.ts +2 -1
  192. package/lib/typescript/src/values/index.d.ts +1 -0
  193. package/lib/typescript/src/values/selector.d.ts +14 -0
  194. package/lib/typescript/src/values/types.d.ts +4 -0
  195. package/lib/typescript/src/values/web/RNSkComputedValue.d.ts +1 -0
  196. package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +1 -0
  197. package/package.json +6 -6
  198. package/src/mock/index.ts +2 -1
  199. package/src/renderer/DependencyManager.tsx +5 -2
  200. package/src/renderer/components/Blend.tsx +25 -5
  201. package/src/renderer/components/imageFilters/Morphology.tsx +2 -2
  202. package/src/renderer/components/imageFilters/Shadow.tsx +2 -2
  203. package/src/renderer/processors/Animations/Animations.ts +27 -5
  204. package/src/skia/core/Data.ts +20 -51
  205. package/src/skia/core/Font.ts +4 -5
  206. package/src/skia/core/Image.ts +2 -2
  207. package/src/skia/core/SVG.ts +2 -2
  208. package/src/skia/core/Typeface.ts +2 -2
  209. package/src/skia/types/Data/Data.ts +11 -1
  210. package/src/skia/types/Picture/Picture.ts +2 -1
  211. package/src/skia/web/Host.ts +11 -21
  212. package/src/skia/web/JsiSkCanvas.ts +99 -56
  213. package/src/skia/web/JsiSkColorFilterFactory.ts +15 -5
  214. package/src/skia/web/JsiSkFont.ts +11 -4
  215. package/src/skia/web/JsiSkImage.ts +4 -3
  216. package/src/skia/web/JsiSkImageFactory.ts +6 -3
  217. package/src/skia/web/JsiSkImageFilterFactory.ts +124 -52
  218. package/src/skia/web/JsiSkMatrix.ts +4 -2
  219. package/src/skia/web/JsiSkPaint.ts +11 -7
  220. package/src/skia/web/JsiSkPath.ts +30 -56
  221. package/src/skia/web/JsiSkPathEffectFactory.ts +10 -5
  222. package/src/skia/web/JsiSkPathFactory.ts +3 -3
  223. package/src/skia/web/JsiSkPicture.ts +5 -3
  224. package/src/skia/web/JsiSkPictureRecorder.ts +3 -2
  225. package/src/skia/web/JsiSkPoint.ts +12 -2
  226. package/src/skia/web/JsiSkRRect.ts +16 -2
  227. package/src/skia/web/JsiSkRSXform.ts +1 -1
  228. package/src/skia/web/JsiSkRect.ts +4 -7
  229. package/src/skia/web/JsiSkRuntimeEffect.ts +9 -4
  230. package/src/skia/web/JsiSkShaderFactory.ts +24 -15
  231. package/src/skia/web/JsiSkSurface.ts +7 -2
  232. package/src/skia/web/JsiSkTextBlobFactory.ts +14 -8
  233. package/src/skia/web/JsiSkTypefaceFactory.tsx +4 -2
  234. package/src/skia/web/JsiSkia.ts +17 -5
  235. package/src/values/hooks/useComputedValue.ts +6 -3
  236. package/src/values/index.ts +1 -0
  237. package/src/values/selector.ts +24 -0
  238. package/src/values/types.ts +4 -0
  239. package/src/values/web/RNSkComputedValue.ts +6 -0
  240. package/src/values/web/RNSkReadonlyValue.ts +4 -0
  241. package/src/views/useTouchHandler.ts +15 -21
@@ -1 +1 @@
1
- {"version":3,"sources":["useTouchHandler.ts"],"names":["useCallback","useRef","PixelRatio","TouchType","useInternalTouchHandler","handlers","deps","multiTouch","prevTouchInfoRef","prevVelocityRef","history","forEach","touches","i","length","touch","timeDiffseconds","timestamp","current","id","distX","x","distY","y","type","Start","End","Cancelled","get","extendedTouchInfo","velocityX","velocityY","onStart","Active","onActive","onEnd","useTouchHandler","useMultiTouchHandler"],"mappings":"AACA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,OAApC;AACA,SAASC,UAAT,QA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A;AACLxB,UAAAA,QAAQ,CAAC6B,QAAT,IAAqB7B,QAAQ,CAAC6B,QAAT,CAAkBL,iBAAlB,CAArB;AACAxB,UAAAA,QAAQ,CAAC8B,KAAT,IAAkB9B,QAAQ,CAAC8B,KAAT,CAAeN,iBAAf,CAAlB;AACD;AACF;AACF,KArDD,EAFuD,CAwDvD;AACD,GAzDiB,EAyDfvB,IAzDe,CAAlB;AA0DD,CApED;AAsEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAM8B,eAAe,GAAG,UAC7B/B,QAD6B,EAGZ;AAAA,MADjBC,IACiB,uEADM,EACN;AACjB,SAAOF,uBAAuB,CAACC,QAAD,EAAWC,IAAX,EAAiB,KAAjB,CAA9B;AACD,CALM;AAOP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAM+B,oBAAoB,GAAG,UAClChC,QADkC,EAGjB;AAAA,MADjBC,IACiB,uEADM,EACN;AACjB,SAAOF,uBAAuB,CAACC,QAAD,EAAWC,IAAX,EAAiB,IAAjB,CAA9B;AACD,CALM","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport { PixelRatio } from \"react-native\";\n\nimport type {\n ExtendedTouchInfo,\n TouchHandlers,\n TouchHandler,\n TouchInfo,\n} from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst useInternalTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = [],\n multiTouch = false\n): TouchHandler => {\n const prevTouchInfoRef = useRef<{ [key: number]: TouchInfo }>({});\n const prevVelocityRef = useRef<{ [key: number]: { x: number; y: number } }>(\n {}\n );\n\n return useCallback((history: Array<Array<TouchInfo>>) => {\n // Process all items in the current touch history\n history.forEach((touches) => {\n // Enumerate touches\n for (let i = 0; i < touches.length; i++) {\n if (!multiTouch && i > 0) {\n break;\n }\n\n const touch = touches[i];\n\n // Calculate the velocity from the previous touch.\n const timeDiffseconds =\n touch.timestamp -\n (prevTouchInfoRef.current[touch.id]?.timestamp ?? touch.timestamp);\n\n const distX =\n touch.x - (prevTouchInfoRef.current[touch.id]?.x ?? touch.x);\n const distY =\n touch.y - (prevTouchInfoRef.current[touch.id]?.y ?? touch.y);\n\n if (\n touch.type !== TouchType.Start &&\n touch.type !== TouchType.End &&\n touch.type !== TouchType.Cancelled\n ) {\n if (timeDiffseconds > 0) {\n prevVelocityRef.current[touch.id] = {\n x: distX / timeDiffseconds / PixelRatio.get(),\n y: distY / timeDiffseconds / PixelRatio.get(),\n };\n } else {\n prevVelocityRef.current[touch.id] = { x: 0, y: 0 };\n }\n }\n\n const extendedTouchInfo: ExtendedTouchInfo = {\n ...touch,\n velocityX: prevVelocityRef.current[touch.id].x,\n velocityY: prevVelocityRef.current[touch.id].y,\n };\n\n // Save previous touch\n prevTouchInfoRef.current[touch.id] = touch;\n\n if (touch.type === TouchType.Start) {\n delete prevVelocityRef.current[touch.id];\n handlers.onStart && handlers.onStart(touch);\n } else if (touch.type === TouchType.Active) {\n handlers.onActive && handlers.onActive(extendedTouchInfo);\n } else {\n handlers.onActive && handlers.onActive(extendedTouchInfo);\n handlers.onEnd && handlers.onEnd(extendedTouchInfo);\n }\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n\n/**\n * Provides a callback for handling touch events in the Skia View.\n * This touch handler only handles single touches.\n * @param handlers Callbacks for the different touch states\n * @param deps optional Dependency array to update the handlers\n * @returns A function that can be used from within the onDraw callback to\n * update and handle touch events. Call it with the touches property from\n * the info object.\n */\nexport const useTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = []\n): TouchHandler => {\n return useInternalTouchHandler(handlers, deps, false);\n};\n\n/**\n * Provides a callback for handling touch events in the Skia View.\n * This touch handler handles multiple touches.\n * @param handlers Callbacks for the different touch states\n * @param deps optional Dependency array to update the handlers\n * @returns A function that can be used from within the onDraw callback to\n * update and handle touch events. Call it with the touches property from\n * the info object.\n */\nexport const useMultiTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = []\n): TouchHandler => {\n return useInternalTouchHandler(handlers, deps, true);\n};\n"]}
1
+ {"version":3,"sources":["useTouchHandler.ts"],"names":["useCallback","useRef","PixelRatio","TouchType","useInternalTouchHandler","handlers","deps","multiTouch","prevTouchInfoRef","prevVelocityRef","history","forEach","touches","i","length","touch","prevTouch","current","id","timeDiffseconds","timestamp","distX","x","distY","y","type","Start","End","Cancelled","get","extendedTouchInfo","velocityX","velocityY","onStart","Active","onActive","onEnd","useTouchHandler","useMultiTouchHandler"],"mappings":"AACA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,OAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AAUA,SAASC,SAAT,QAA0B,SAA1B;;AAEA,MAAMC,uBAAuB,GAAG,UAC9BC,QAD8B,EAIb;AAAA,MAFjBC,IAEiB,uEAFM,EAEN;AAAA,MADjBC,UACiB,uEADJ,KACI;AACjB,QAAMC,gBAAgB,GAAGP,MAAM,CAA2C,EAA3C,CAA/B;AACA,QAAMQ,eAAe,GAAGR,MAAM,CAAwC,EAAxC,CAA9B;AAEA,SAAOD,WAAW,CAAEU,OAAD,IAAsC;AACvD;AACAA,IAAAA,OAAO,CAACC,OAAR,CAAiBC,OAAD,IAAa;AAC3B;AACA,WAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,OAAO,CAACE,MAA5B,EAAoCD,CAAC,EAArC,EAAyC;AAAA;;AACvC,YAAI,CAACN,UAAD,IAAeM,CAAC,GAAG,CAAvB,EAA0B;AACxB;AACD;;AAED,cAAME,KAAK,GAAGH,OAAO,CAACC,CAAD,CAArB;AACA,cAAMG,SAAS,GAAGR,gBAAgB,CAACS,OAAjB,CAAyBF,KAAK,CAACG,EAA/B,CAAlB,CANuC,CAOvC;;AACA,cAAMC,eAAe,GACnBJ,KAAK,CAACK,SAAN,uDACCZ,gBAAgB,CAACS,OAAjB,CAAyBF,KAAK,CAACG,EAA/B,CADD,2DACC,uB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jB,eAAe,CAACQ,OAAhB,CAAwBF,KAAK,CAACG,EAA9B,CAAP;AACAb,UAAAA,QAAQ,CAAC4B,OAAT,IAAoB5B,QAAQ,CAAC4B,OAAT,CAAiBlB,KAAjB,CAApB;AACD,SAHD,MAGO,IAAIA,KAAK,CAACU,IAAN,KAAetB,SAAS,CAAC+B,MAA7B,EAAqC;AAC1C7B,UAAAA,QAAQ,CAAC8B,QAAT,IAAqB9B,QAAQ,CAAC8B,QAAT,CAAkBL,iBAAlB,CAArB;AACD,SAFM,MAEA;AACLzB,UAAAA,QAAQ,CAAC+B,KAAT,IAAkB/B,QAAQ,CAAC+B,KAAT,CAAeN,iBAAf,CAAlB;AACD;AACF;AACF,KA/CD,EAFuD,CAkDvD;AACD,GAnDiB,EAmDfxB,IAnDe,CAAlB;AAoDD,CA5DD;AA8DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAM+B,eAAe,GAAG,UAC7BhC,QAD6B,EAGZ;AAAA,MADjBC,IACiB,uEADM,EACN;AACjB,SAAOF,uBAAuB,CAACC,QAAD,EAAWC,IAAX,EAAiB,KAAjB,CAA9B;AACD,CALM;AAOP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMgC,oBAAoB,GAAG,UAClCjC,QADkC,EAGjB;AAAA,MADjBC,IACiB,uEADM,EACN;AACjB,SAAOF,uBAAuB,CAACC,QAAD,EAAWC,IAAX,EAAiB,IAAjB,CAA9B;AACD,CALM","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport { PixelRatio } from \"react-native\";\n\nimport type { Vector } from \"../skia/types\";\n\nimport type {\n ExtendedTouchInfo,\n TouchHandlers,\n TouchHandler,\n TouchInfo,\n} from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst useInternalTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = [],\n multiTouch = false\n): TouchHandler => {\n const prevTouchInfoRef = useRef<{ [key: number]: TouchInfo | undefined }>({});\n const prevVelocityRef = useRef<{ [key: number]: Vector | undefined }>({});\n\n return useCallback((history: Array<Array<TouchInfo>>) => {\n // Process all items in the current touch history\n history.forEach((touches) => {\n // Enumerate touches\n for (let i = 0; i < touches.length; i++) {\n if (!multiTouch && i > 0) {\n break;\n }\n\n const touch = touches[i];\n const prevTouch = prevTouchInfoRef.current[touch.id];\n // Calculate the velocity from the previous touch.\n const timeDiffseconds =\n touch.timestamp -\n (prevTouchInfoRef.current[touch.id]?.timestamp ?? touch.timestamp);\n\n const distX = touch.x - (prevTouch?.x ?? touch.x);\n const distY = touch.y - (prevTouch?.y ?? touch.y);\n\n if (\n touch.type !== TouchType.Start &&\n touch.type !== TouchType.End &&\n touch.type !== TouchType.Cancelled &&\n timeDiffseconds > 0\n ) {\n prevVelocityRef.current[touch.id] = {\n x: distX / timeDiffseconds / PixelRatio.get(),\n y: distY / timeDiffseconds / PixelRatio.get(),\n };\n }\n\n const extendedTouchInfo: ExtendedTouchInfo = {\n ...touch,\n velocityX: prevVelocityRef.current[touch.id]?.x ?? 0,\n velocityY: prevVelocityRef.current[touch.id]?.y ?? 0,\n };\n\n // Save previous touch\n prevTouchInfoRef.current[touch.id] = touch;\n\n if (touch.type === TouchType.Start) {\n delete prevVelocityRef.current[touch.id];\n handlers.onStart && handlers.onStart(touch);\n } else if (touch.type === TouchType.Active) {\n handlers.onActive && handlers.onActive(extendedTouchInfo);\n } else {\n handlers.onEnd && handlers.onEnd(extendedTouchInfo);\n }\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n\n/**\n * Provides a callback for handling touch events in the Skia View.\n * This touch handler only handles single touches.\n * @param handlers Callbacks for the different touch states\n * @param deps optional Dependency array to update the handlers\n * @returns A function that can be used from within the onDraw callback to\n * update and handle touch events. Call it with the touches property from\n * the info object.\n */\nexport const useTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = []\n): TouchHandler => {\n return useInternalTouchHandler(handlers, deps, false);\n};\n\n/**\n * Provides a callback for handling touch events in the Skia View.\n * This touch handler handles multiple touches.\n * @param handlers Callbacks for the different touch states\n * @param deps optional Dependency array to update the handlers\n * @returns A function that can be used from within the onDraw callback to\n * update and handle touch events. Call it with the touches property from\n * the info object.\n */\nexport const useMultiTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = []\n): TouchHandler => {\n return useInternalTouchHandler(handlers, deps, true);\n};\n"]}
@@ -1,7 +1,12 @@
1
- import type { SkiaValue } from "../../../values";
1
+ import type { SkiaSelector, SkiaValue } from "../../../values";
2
2
  export declare const isValue: (value: unknown) => value is SkiaValue<unknown>;
3
+ export declare const isSelector: <T, R>(value: unknown) => value is {
4
+ selector: (v: T) => R;
5
+ value: SkiaValue<T>;
6
+ };
3
7
  export declare const isAnimated: <T>(props: AnimatedProps<T>) => boolean;
4
8
  export declare const materialize: <T>(props: AnimatedProps<T>) => T;
9
+ export declare type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
5
10
  export declare type AnimatedProps<T> = {
6
- [K in keyof T]: T[K] | SkiaValue<T[K]>;
11
+ [K in keyof T]: AnimatedProp<T[K]>;
7
12
  };
@@ -1,5 +1,3 @@
1
- import type { DependencyList } from "react";
2
- import type { SkData, DataSource } from "../types";
3
- export declare const useDataCollection: <T>(sources: DataSource[], factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => (T | null)[] | null;
4
- export declare const useRawData: <T>(source: DataSource | null | undefined, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => T | null;
5
- export declare const useData: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => SkData | null;
1
+ import type { SkData, DataSourceParam } from "../types";
2
+ export declare const useRawData: <T>(source: DataSourceParam, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined) => T | null;
3
+ export declare const useData: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkData | null;
@@ -1,5 +1,5 @@
1
- import type { DataSource, SkFont } from "../types";
1
+ import type { DataSourceParam } from "../types";
2
2
  /**
3
3
  * Returns a Skia Font object
4
4
  * */
5
- export declare const useFont: (font: DataSource | null | undefined, size?: number | undefined, onError?: ((err: Error) => void) | undefined) => SkFont | null;
5
+ export declare const useFont: (font: DataSourceParam, size?: number | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkFont | null;
@@ -1,5 +1,5 @@
1
- import type { DataSource } from "../types";
1
+ import type { DataSourceParam } from "../types";
2
2
  /**
3
3
  * Returns a Skia Image object
4
4
  * */
5
- export declare const useImage: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkImage | null;
5
+ export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkImage | null;
@@ -1,2 +1,2 @@
1
- import type { DataSource } from "../types";
2
- export declare const useSVG: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkSVG | null;
1
+ import type { DataSourceParam } from "../types";
2
+ export declare const useSVG: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkSVG | null;
@@ -1,5 +1,5 @@
1
- import type { DataSource } from "../types";
1
+ import type { DataSourceParam } from "../types";
2
2
  /**
3
3
  * Returns a Skia Typeface object
4
4
  * */
5
- export declare const useTypeface: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkTypeface | null;
5
+ export declare const useTypeface: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkTypeface | null;
@@ -1,5 +1,12 @@
1
- /// <reference types="node" />
2
- /// <reference types="react-native" />
3
1
  import type { SkJSIInstance } from "../JsiInstance";
4
2
  export declare type SkData = SkJSIInstance<"Data">;
5
- export declare type DataSource = ReturnType<typeof require> | string | Uint8Array;
3
+ declare type RNModule = number;
4
+ declare type ESModule = {
5
+ __esModule: true;
6
+ default: string;
7
+ };
8
+ export declare type DataModule = RNModule | ESModule;
9
+ export declare type DataSource = DataModule | string | Uint8Array;
10
+ export declare type DataSourceParam = DataSource | null | undefined;
11
+ export declare const isRNModule: (mod: DataModule) => mod is number;
12
+ export {};
@@ -3,7 +3,8 @@ import type { TileMode } from "../ImageFilter";
3
3
  import type { SkRect } from "../Rect";
4
4
  import type { SkShader } from "../Shader";
5
5
  import type { SkMatrix } from "../Matrix";
6
- export interface SkPicture {
6
+ import type { SkJSIInstance } from "../JsiInstance";
7
+ export interface SkPicture extends SkJSIInstance<"Picture"> {
7
8
  /**
8
9
  * Returns a new shader that will draw with this picture.
9
10
  *
@@ -1,21 +1,19 @@
1
1
  import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
2
2
  import type { SkJSIInstance } from "../types";
3
3
  export declare class NotImplementedOnRNWeb extends Error {
4
- constructor();
4
+ constructor(msg?: string);
5
5
  }
6
6
  export declare abstract class Host {
7
7
  readonly CanvasKit: CanvasKit;
8
8
  constructor(CanvasKit: CanvasKit);
9
9
  }
10
- export declare abstract class HostObject<T, N extends string> extends Host implements SkJSIInstance<N> {
10
+ export declare abstract class BaseHostObject<T, N extends string> extends Host implements SkJSIInstance<N> {
11
11
  readonly __typename__: N;
12
12
  readonly ref: T;
13
13
  constructor(CanvasKit: CanvasKit, ref: T, typename: N);
14
14
  }
15
- export declare type NonNullish = {};
16
- export declare const toOptionalValue: <T>(value: NonNullish | undefined | null) => T | null | undefined;
17
- export declare const toUndefinedableValue: <T>(value: NonNullish | undefined) => T | undefined;
18
- export declare const toNullableValue: <T>(value: NonNullish | null) => T | null;
19
- export declare const toValue: <T>(value: NonNullish) => T;
15
+ export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
16
+ static fromValue<T>(value: SkJSIInstance<string>): T;
17
+ }
20
18
  export declare const ckEnum: (value: number) => EmbindEnumEntity;
21
19
  export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
@@ -4,16 +4,16 @@ import { Host } from "./Host";
4
4
  import { JsiSkImageFilter } from "./JsiSkImageFilter";
5
5
  export declare class JsiSkImageFilterFactory extends Host implements ImageFilterFactory {
6
6
  constructor(CanvasKit: CanvasKit);
7
- MakeOffset(_dx: number, _dy: number, _input: SkImageFilter | null): SkImageFilter;
8
- MakeDisplacementMap(_channelX: ColorChannel, _channelY: ColorChannel, _scale: number, _in1: SkImageFilter, _input: SkImageFilter | null): SkImageFilter;
9
- MakeShader(_shader: SkShader, _input: SkImageFilter | null): SkImageFilter;
7
+ MakeOffset(dx: number, dy: number, input: SkImageFilter | null): JsiSkImageFilter;
8
+ MakeDisplacementMap(channelX: ColorChannel, channelY: ColorChannel, scale: number, in1: SkImageFilter, input: SkImageFilter | null): SkImageFilter;
9
+ MakeShader(shader: SkShader, _input: SkImageFilter | null): SkImageFilter;
10
10
  MakeBlur(sigmaX: number, sigmaY: number, mode: TileMode, input: SkImageFilter | null): JsiSkImageFilter;
11
11
  MakeColorFilter(cf: SkColorFilter, input: SkImageFilter | null): JsiSkImageFilter;
12
12
  MakeCompose(outer: SkImageFilter | null, inner: SkImageFilter | null): JsiSkImageFilter;
13
- MakeDropShadow(_dx: number, _dy: number, _sigmaX: number, _sigmaY: number, _color: SkColor, _input: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
14
- MakeDropShadowOnly(_dx: number, _dy: number, _sigmaX: number, _sigmaY: number, _color: SkColor, _input: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
15
- MakeErode(_rx: number, _ry: number, _input: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
16
- MakeDilate(_rx: number, _ry: number, _input: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
17
- MakeBlend(_mode: BlendMode, _background: SkImageFilter, _foreground: SkImageFilter | null, _cropRect?: SkRect): SkImageFilter;
13
+ MakeDropShadow(dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
14
+ MakeDropShadowOnly(dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
15
+ MakeErode(rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
16
+ MakeDilate(rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
17
+ MakeBlend(mode: BlendMode, background: SkImageFilter, foreground: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
18
18
  MakeRuntimeShader(_builder: SkRuntimeShaderBuilder, _childShaderName: string | null, _input: SkImageFilter | null): SkImageFilter;
19
19
  }
@@ -1,7 +1,8 @@
1
1
  import type { CanvasKit, Point } from "canvaskit-wasm";
2
2
  import type { SkPoint } from "../types";
3
- import { HostObject } from "./Host";
4
- export declare class JsiSkPoint extends HostObject<Point, "Point"> implements SkPoint {
3
+ import { BaseHostObject } from "./Host";
4
+ export declare class JsiSkPoint extends BaseHostObject<Point, "Point"> implements SkPoint {
5
+ static fromValue(point: SkPoint): Float32Array;
5
6
  constructor(CanvasKit: CanvasKit, ref: Point);
6
7
  get x(): number;
7
8
  get y(): number;
@@ -1,8 +1,9 @@
1
1
  import type { CanvasKit, RRect } from "canvaskit-wasm";
2
2
  import type { SkRRect } from "../types";
3
- import { HostObject } from "./Host";
3
+ import { BaseHostObject } from "./Host";
4
4
  import { JsiSkRect } from "./JsiSkRect";
5
- export declare class JsiSkRRect extends HostObject<RRect, "RRect"> implements SkRRect {
5
+ export declare class JsiSkRRect extends BaseHostObject<RRect, "RRect"> implements SkRRect {
6
+ static fromValue(CanvasKit: CanvasKit, rect: SkRRect): Float32Array;
6
7
  constructor(CanvasKit: CanvasKit, ref: RRect);
7
8
  get rx(): number;
8
9
  get ry(): number;
@@ -1,8 +1,7 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
2
  import type { SkRSXform } from "../types";
3
3
  import { HostObject } from "./Host";
4
- declare type RSXform = Float32Array;
4
+ export declare type RSXform = Float32Array;
5
5
  export declare class JsiSkRSXform extends HostObject<RSXform, "RSXform"> implements SkRSXform {
6
6
  constructor(CanvasKit: CanvasKit, ref: RSXform);
7
7
  }
8
- export {};
@@ -1,8 +1,8 @@
1
1
  import type { CanvasKit, Rect } from "canvaskit-wasm";
2
2
  import type { SkRect } from "../types";
3
- import { HostObject } from "./Host";
4
- export declare class JsiSkRect extends HostObject<Rect, "Rect"> implements SkRect {
5
- static fromValue(CanvasKit: CanvasKit, rect: SkRect): JsiSkRect;
3
+ import { BaseHostObject } from "./Host";
4
+ export declare class JsiSkRect extends BaseHostObject<Rect, "Rect"> implements SkRect {
5
+ static fromValue(CanvasKit: CanvasKit, rect: SkRect): Float32Array;
6
6
  constructor(CanvasKit: CanvasKit, ref: Rect);
7
7
  get x(): number;
8
8
  get y(): number;
@@ -1,6 +1,7 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
- import type { SkFont, SkRSXform } from "../types";
2
+ import type { SkFont } from "../types";
3
3
  import type { TextBlobFactory } from "../types/TextBlob";
4
+ import type { SkRSXform } from "../types/RSXform";
4
5
  import { Host } from "./Host";
5
6
  import { JsiSkTextBlob } from "./JsiSkTextBlob";
6
7
  export declare class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
@@ -1,3 +1,4 @@
1
1
  export * from "./types";
2
2
  export * from "./hooks";
3
3
  export * from "./api";
4
+ export * from "./selector";
@@ -0,0 +1,14 @@
1
+ import type { SkiaValue } from "./types";
2
+ export declare type SkiaSelector<TReturn, TInput = unknown> = {
3
+ value: SkiaValue<TInput>;
4
+ selector: (v: TInput) => TReturn;
5
+ };
6
+ /**
7
+ * Wraps a Skia Value with a selector function. The selector function can access the
8
+ * inner values of the Skia Value so that we can dynamically ready array values and
9
+ * object values when doing animations in Skia.
10
+ * @param value Dependant value
11
+ * @param selector Selector function to calculate new value from the Skia Value's value
12
+ * @returns A descriptor that will be used by the reconciler to calculate the value
13
+ */
14
+ export declare const Selector: <TInput, TReturn>(value: SkiaValue<TInput>, selector: (v: TInput) => TReturn) => SkiaSelector<TReturn, TInput>;
@@ -8,6 +8,10 @@ export interface SkiaValue<T = number> {
8
8
  * Returns unsubscribe method.
9
9
  */
10
10
  addListener: (cb: (value: T) => void) => () => void;
11
+ /**
12
+ * Invalidates the value. Has different meaning depending on the type of the value.
13
+ */
14
+ __invalidate: () => void;
11
15
  /**
12
16
  * Field to make typechecking easier
13
17
  */
@@ -6,4 +6,5 @@ export declare class RNSkComputedValue<T> extends RNSkReadonlyValue<T> {
6
6
  private _callback;
7
7
  private _unsubscribers;
8
8
  unsubscribe(): void;
9
+ __invalidate(): void;
9
10
  }
@@ -8,4 +8,5 @@ export declare class RNSkReadonlyValue<T> implements SkiaValue<T> {
8
8
  readonly __typename__ = "RNSkValue";
9
9
  get current(): T;
10
10
  addListener(cb: (value: T) => void): () => void;
11
+ __invalidate(): void;
11
12
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.140",
10
+ "version": "0.1.143",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "scripts": {
39
39
  "tsc": "tsc --noEmit",
40
- "lint": "eslint . --ext .ts,.tsx --max-warnings 0",
40
+ "lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
41
41
  "test": "jest",
42
42
  "postinstall": "node scripts/install-npm.js",
43
43
  "build": "bob build"
@@ -75,21 +75,21 @@
75
75
  }
76
76
  },
77
77
  "devDependencies": {
78
- "@types/jest": "^27.0.3",
78
+ "@types/jest": "^28.1.6",
79
79
  "@types/react-native": "^0.65.0",
80
80
  "@types/react-reconciler": "^0.26.4",
81
81
  "eslint": "8.21.0",
82
82
  "eslint-config-react-native-wcandillon": "3.9.0",
83
83
  "eslint-plugin-reanimated": "2.0.0",
84
- "jest": "^27.4.3",
84
+ "jest": "28.1.3",
85
85
  "react": "17.0.2",
86
86
  "react-native": "0.66.2",
87
87
  "react-native-builder-bob": "^0.18.2",
88
- "ts-jest": "^27.0.7",
88
+ "ts-jest": "^28.0.7",
89
89
  "typescript": "^4.6.4"
90
90
  },
91
91
  "dependencies": {
92
- "canvaskit-wasm": "^0.35.0",
92
+ "canvaskit-wasm": "^0.36.0",
93
93
  "react-reconciler": "^0.26.2"
94
94
  },
95
95
  "eslintIgnore": [
package/src/mock/index.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  import type { Color, Skia as SkiaApi, SkRect, Vector } from "../skia/types";
4
4
  import * as Values from "../values/web";
5
5
  import * as ValuesHooks from "../values/hooks";
6
+ import { Selector } from "../values/selector";
6
7
  import * as BaseSkia from "../skia/types";
7
8
  import type * as SkiaExports from "../skia";
8
9
  import type * as ExternalExports from "../external";
@@ -46,7 +47,6 @@ export const Mock: typeof SkiaExports &
46
47
  Skia,
47
48
  ...BaseSkia,
48
49
  // 2. Hooks
49
- useDataCollection: Noop,
50
50
  useRawData: Noop,
51
51
  useData: Noop,
52
52
  useFont: Noop,
@@ -87,6 +87,7 @@ export const Mock: typeof SkiaExports &
87
87
  // ValueExports
88
88
  ...Values,
89
89
  ...ValuesHooks,
90
+ Selector,
90
91
  // Animations
91
92
  ...timingFunctions,
92
93
  ...springFunctions,
@@ -3,7 +3,7 @@ import type { RefObject } from "react";
3
3
  import type { SkiaView } from "../views";
4
4
  import type { SkiaValue } from "../values";
5
5
 
6
- import { isValue } from "./processors";
6
+ import { isSelector, isValue } from "./processors";
7
7
  import type { Node } from "./nodes";
8
8
 
9
9
  type Unsubscribe = () => void;
@@ -29,7 +29,10 @@ export class DependencyManager {
29
29
  }
30
30
 
31
31
  subscribeNode(node: Node, props: Props) {
32
- const values = Object.values(props).filter(isValue);
32
+ const values = Object.values(props)
33
+ .filter((v) => isValue(v) || isSelector(v))
34
+ .map((v) => (isSelector(v) ? v.value : (v as SkiaValue<unknown>)));
35
+
33
36
  if (values.length > 0) {
34
37
  this.subscriptions.set(node, { values, unsubscribe: null });
35
38
  }
@@ -1,10 +1,21 @@
1
1
  import type { ReactNode } from "react";
2
2
  import React from "react";
3
3
 
4
+ import type { SkImageFilter, SkShader } from "../../skia/types";
4
5
  import { isImageFilter, BlendMode, isShader } from "../../skia/types";
5
6
  import { createDeclaration } from "../nodes";
6
7
  import type { AnimatedProps, SkEnum } from "../processors";
7
8
  import { enumKey } from "../processors/Paint";
9
+ import type { DeclarationResult } from "../nodes/Declaration";
10
+
11
+ const childrenAreImageFilters = (
12
+ children: DeclarationResult[]
13
+ ): children is SkImageFilter[] =>
14
+ children.every((child) => isImageFilter(child));
15
+
16
+ const childrenAreShaders = (
17
+ children: DeclarationResult[]
18
+ ): children is SkShader[] => children.every((child) => isShader(child));
8
19
 
9
20
  interface BlendProps {
10
21
  mode: SkEnum<typeof BlendMode>;
@@ -13,12 +24,21 @@ interface BlendProps {
13
24
 
14
25
  const onDeclare = createDeclaration<BlendProps>(
15
26
  ({ mode }, children, { Skia }) => {
16
- const [inner, outer] = children;
17
27
  const blend = BlendMode[enumKey(mode)];
18
- if (isImageFilter(outer) && isImageFilter(inner)) {
19
- return Skia.ImageFilter.MakeBlend(blend, outer, inner);
20
- } else if (isShader(outer) && isShader(inner)) {
21
- return Skia.Shader.MakeBlend(blend, outer, inner);
28
+ if (childrenAreImageFilters(children)) {
29
+ return children.reverse().reduce<SkImageFilter | null>((inner, outer) => {
30
+ if (inner === null) {
31
+ return outer;
32
+ }
33
+ return Skia.ImageFilter.MakeBlend(blend, outer, inner);
34
+ }, null);
35
+ } else if (childrenAreShaders(children)) {
36
+ return children.reverse().reduce<SkShader | null>((inner, outer) => {
37
+ if (inner === null) {
38
+ return outer;
39
+ }
40
+ return Skia.Shader.MakeBlend(blend, outer, inner);
41
+ }, null);
22
42
  }
23
43
  throw new Error("<Blend /> can only blend Shaders or ImageFilters");
24
44
  }
@@ -18,8 +18,8 @@ const onDeclare = createDeclaration<MorphologyProps>(
18
18
  const r = processRadius(Skia, radius);
19
19
  const factory =
20
20
  operator === "dilate"
21
- ? Skia.ImageFilter.MakeDilate
22
- : Skia.ImageFilter.MakeErode;
21
+ ? Skia.ImageFilter.MakeDilate.bind(Skia.ImageFilter)
22
+ : Skia.ImageFilter.MakeErode.bind(Skia.ImageFilter);
23
23
  return factory(r.x, r.y, input);
24
24
  }
25
25
  );
@@ -30,8 +30,8 @@ const onDeclare = createDeclaration<ShadowProps>(
30
30
  factory = MakeInnerShadow.bind(null, Skia, shadowOnly);
31
31
  } else {
32
32
  factory = shadowOnly
33
- ? Skia.ImageFilter.MakeDropShadowOnly
34
- : Skia.ImageFilter.MakeDropShadow;
33
+ ? Skia.ImageFilter.MakeDropShadowOnly.bind(Skia.ImageFilter)
34
+ : Skia.ImageFilter.MakeDropShadow.bind(Skia.ImageFilter);
35
35
  }
36
36
  return factory(dx, dy, blur, blur, color, input);
37
37
  }
@@ -1,4 +1,4 @@
1
- import type { SkiaValue } from "../../../values";
1
+ import type { SkiaSelector, SkiaValue } from "../../../values";
2
2
  import { mapKeys } from "../../typeddash";
3
3
 
4
4
  export const isValue = (value: unknown): value is SkiaValue<unknown> => {
@@ -17,6 +17,24 @@ export const isValue = (value: unknown): value is SkiaValue<unknown> => {
17
17
  return false;
18
18
  };
19
19
 
20
+ export const isSelector = <T, R>(
21
+ value: unknown
22
+ ): value is {
23
+ selector: (v: T) => R;
24
+ value: SkiaValue<T>;
25
+ } => {
26
+ if (value) {
27
+ return (
28
+ typeof value === "object" &&
29
+ "selector" in value &&
30
+ "value" in value &&
31
+ (value as Record<string, unknown>).selector !== undefined &&
32
+ (value as Record<string, unknown>).value !== undefined
33
+ );
34
+ }
35
+ return false;
36
+ };
37
+
20
38
  export const isAnimated = <T>(props: AnimatedProps<T>) => {
21
39
  for (const value of Object.values(props)) {
22
40
  if (isValue(value)) {
@@ -29,14 +47,18 @@ export const isAnimated = <T>(props: AnimatedProps<T>) => {
29
47
  export const materialize = <T>(props: AnimatedProps<T>) => {
30
48
  const result = { ...props };
31
49
  mapKeys(props).forEach((key) => {
32
- const value = props[key];
33
- if (isValue(value)) {
34
- result[key] = (value as SkiaValue<T[typeof key]>).current;
50
+ const prop = props[key];
51
+ if (isValue(prop)) {
52
+ result[key] = (prop as SkiaValue<T[typeof key]>).current;
53
+ } else if (isSelector(prop)) {
54
+ result[key] = prop.selector(prop.value.current) as T[typeof key];
35
55
  }
36
56
  });
37
57
  return result as T;
38
58
  };
39
59
 
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ export type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
40
62
  export type AnimatedProps<T> = {
41
- [K in keyof T]: T[K] | SkiaValue<T[K]>;
63
+ [K in keyof T]: AnimatedProp<T[K]>;
42
64
  };
@@ -1,14 +1,14 @@
1
- import type { DependencyList } from "react";
2
- import { useRef, useEffect, useState } from "react";
3
- import { Image, Platform } from "react-native";
1
+ import { useEffect, useState } from "react";
2
+ import { Image } from "react-native";
4
3
 
5
4
  import { Skia } from "../Skia";
6
- import type { SkData, DataSource } from "../types";
5
+ import { isRNModule } from "../types";
6
+ import type { SkData, DataModule, DataSourceParam } from "../types";
7
7
 
8
- const resolveAsset = (source: ReturnType<typeof require>) => {
9
- return Platform.OS === "web"
10
- ? source.default
11
- : Image.resolveAssetSource(source).uri;
8
+ const resolveAsset = (source: DataModule) => {
9
+ return isRNModule(source)
10
+ ? Image.resolveAssetSource(source).uri
11
+ : source.default;
12
12
  };
13
13
 
14
14
  const factoryWrapper = <T>(
@@ -25,19 +25,12 @@ const factoryWrapper = <T>(
25
25
  }
26
26
  };
27
27
 
28
- const loadDataCollection = <T>(
29
- sources: DataSource[],
30
- factory: (data: SkData) => T,
31
- onError?: (err: Error) => void
32
- ): Promise<(T | null)[]> =>
33
- Promise.all(sources.map((source) => loadData(source, factory, onError)));
34
-
35
28
  const loadData = <T>(
36
- source: DataSource,
29
+ source: DataSourceParam,
37
30
  factory: (data: SkData) => T,
38
31
  onError?: (err: Error) => void
39
32
  ): Promise<T | null> => {
40
- if (source === null) {
33
+ if (source === null || source === undefined) {
41
34
  return new Promise((resolve) => resolve(null));
42
35
  } else if (source instanceof Uint8Array) {
43
36
  return new Promise((resolve) =>
@@ -50,51 +43,27 @@ const loadData = <T>(
50
43
  );
51
44
  }
52
45
  };
53
-
54
- type Source = DataSource | null | undefined;
55
-
56
46
  const useLoading = <T>(
57
- source: Source,
58
- loader: () => Promise<T | null>,
59
- deps: DependencyList = []
47
+ source: DataSourceParam,
48
+ loader: () => Promise<T | null>
60
49
  ) => {
61
50
  const [data, setData] = useState<T | null>(null);
62
- const prevSourceRef = useRef<Source>();
63
51
  useEffect(() => {
64
- if (prevSourceRef.current !== source) {
65
- prevSourceRef.current = source;
66
- loader().then(setData);
67
- } else {
68
- setData(null);
69
- }
52
+ loader().then(setData);
70
53
  // eslint-disable-next-line react-hooks/exhaustive-deps
71
- }, deps);
54
+ }, [source]);
72
55
  return data;
73
56
  };
74
57
 
75
- export const useDataCollection = <T>(
76
- sources: DataSource[],
77
- factory: (data: SkData) => T,
78
- onError?: (err: Error) => void,
79
- deps?: DependencyList
80
- ) =>
81
- useLoading(
82
- sources,
83
- () => loadDataCollection(sources, factory, onError),
84
- deps
85
- );
86
-
87
58
  export const useRawData = <T>(
88
- source: DataSource | null | undefined,
59
+ source: DataSourceParam,
89
60
  factory: (data: SkData) => T,
90
- onError?: (err: Error) => void,
91
- deps?: DependencyList
92
- ) => useLoading(source, () => loadData(source, factory, onError), deps);
61
+ onError?: (err: Error) => void
62
+ ) => useLoading(source, () => loadData(source, factory, onError));
93
63
 
94
64
  const identity = (data: SkData) => data;
95
65
 
96
66
  export const useData = (
97
- source: DataSource | null | undefined,
98
- onError?: (err: Error) => void,
99
- deps?: DependencyList
100
- ) => useRawData(source, identity, onError, deps);
67
+ source: DataSourceParam,
68
+ onError?: (err: Error) => void
69
+ ) => useRawData(source, identity, onError);