@shopify/react-native-skia 0.1.213 → 0.1.214

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLHelper.h +3 -2
  2. package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.cpp +9 -2
  3. package/cpp/api/JsiSkSurface.h +4 -1
  4. package/cpp/skia/include/android/GrAHardwareBufferUtils.h +99 -0
  5. package/cpp/skia/include/android/SkHeifDecoder.h +10 -3
  6. package/cpp/skia/include/codec/SkAvifDecoder.h +1 -0
  7. package/cpp/skia/include/codec/SkBmpDecoder.h +1 -0
  8. package/cpp/skia/include/codec/SkCodec.h +4 -3
  9. package/cpp/skia/include/codec/SkEncodedImageFormat.h +0 -3
  10. package/cpp/skia/include/codec/SkGifDecoder.h +1 -0
  11. package/cpp/skia/include/codec/SkIcoDecoder.h +1 -0
  12. package/cpp/skia/include/codec/SkJpegDecoder.h +1 -0
  13. package/cpp/skia/include/codec/SkJpegxlDecoder.h +1 -0
  14. package/cpp/skia/include/codec/SkPngDecoder.h +1 -0
  15. package/cpp/skia/include/codec/SkRawDecoder.h +1 -0
  16. package/cpp/skia/include/codec/SkWbmpDecoder.h +1 -0
  17. package/cpp/skia/include/codec/SkWebpDecoder.h +1 -0
  18. package/cpp/skia/include/config/SkUserConfig.h +0 -2
  19. package/cpp/skia/include/core/SkBitmap.h +8 -8
  20. package/cpp/skia/include/core/SkCanvas.h +37 -50
  21. package/cpp/skia/include/core/SkCapabilities.h +2 -7
  22. package/cpp/skia/include/core/SkColor.h +1 -1
  23. package/cpp/skia/include/core/SkColorFilter.h +6 -0
  24. package/cpp/skia/include/core/SkColorTable.h +3 -0
  25. package/cpp/skia/include/core/SkColorType.h +2 -0
  26. package/cpp/skia/include/core/SkContourMeasure.h +12 -8
  27. package/cpp/skia/include/core/SkDocument.h +1 -0
  28. package/cpp/skia/include/core/SkFont.h +11 -2
  29. package/cpp/skia/include/core/SkFontMgr.h +2 -3
  30. package/cpp/skia/include/core/SkGraphics.h +3 -13
  31. package/cpp/skia/include/core/SkImage.h +57 -111
  32. package/cpp/skia/include/core/SkImageFilter.h +6 -1
  33. package/cpp/skia/include/core/SkImageGenerator.h +8 -0
  34. package/cpp/skia/include/core/SkImageInfo.h +0 -2
  35. package/cpp/skia/include/core/SkM44.h +7 -3
  36. package/cpp/skia/include/core/SkMallocPixelRef.h +4 -1
  37. package/cpp/skia/include/core/SkMatrix.h +17 -17
  38. package/cpp/skia/include/core/SkMesh.h +71 -61
  39. package/cpp/skia/include/core/SkMilestone.h +1 -1
  40. package/cpp/skia/include/core/SkOverdrawCanvas.h +25 -0
  41. package/cpp/skia/include/core/SkPaint.h +1 -1
  42. package/cpp/skia/include/core/SkPath.h +12 -4
  43. package/cpp/skia/include/core/SkPathMeasure.h +3 -4
  44. package/cpp/skia/include/core/SkPicture.h +19 -6
  45. package/cpp/skia/include/core/SkPictureRecorder.h +6 -6
  46. package/cpp/skia/include/core/SkPixmap.h +2 -3
  47. package/cpp/skia/include/core/SkRRect.h +1 -1
  48. package/cpp/skia/include/core/SkRect.h +107 -110
  49. package/cpp/skia/include/core/SkRefCnt.h +1 -1
  50. package/cpp/skia/include/core/SkRegion.h +7 -1
  51. package/cpp/skia/include/core/SkSerialProcs.h +14 -0
  52. package/cpp/skia/include/core/SkShader.h +9 -0
  53. package/cpp/skia/include/core/SkStream.h +9 -9
  54. package/cpp/skia/include/core/SkString.h +1 -1
  55. package/cpp/skia/include/core/SkSurface.h +14 -25
  56. package/cpp/skia/include/core/SkTextBlob.h +17 -4
  57. package/cpp/skia/include/core/SkTiledImageUtils.h +28 -0
  58. package/cpp/skia/include/core/SkTypeface.h +7 -2
  59. package/cpp/skia/include/core/SkTypes.h +4 -12
  60. package/cpp/skia/include/docs/SkPDFDocument.h +17 -3
  61. package/cpp/skia/include/effects/SkImageFilters.h +73 -24
  62. package/cpp/skia/include/effects/SkRuntimeEffect.h +20 -51
  63. package/cpp/skia/include/gpu/GpuTypes.h +13 -0
  64. package/cpp/skia/include/gpu/GrBackendSurface.h +95 -262
  65. package/cpp/skia/include/gpu/GrContextOptions.h +7 -1
  66. package/cpp/skia/include/gpu/GrDirectContext.h +138 -128
  67. package/cpp/skia/include/gpu/GrRecordingContext.h +9 -4
  68. package/cpp/skia/include/gpu/GrSurfaceInfo.h +0 -24
  69. package/cpp/skia/include/gpu/GrTypes.h +16 -1
  70. package/cpp/skia/include/gpu/GrYUVABackendTextures.h +4 -4
  71. package/cpp/skia/include/gpu/d3d/GrD3DTypes.h +2 -2
  72. package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +44 -12
  73. package/cpp/skia/include/gpu/ganesh/SkMeshGanesh.h +57 -0
  74. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +2 -1
  75. package/cpp/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h +58 -0
  76. package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +29 -0
  77. package/cpp/skia/include/gpu/ganesh/mtl/SkSurfaceMetal.h +1 -1
  78. package/cpp/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h +67 -0
  79. package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -2
  80. package/cpp/skia/include/gpu/graphite/BackendTexture.h +14 -3
  81. package/cpp/skia/include/gpu/graphite/Context.h +93 -13
  82. package/cpp/skia/include/gpu/graphite/ContextOptions.h +19 -8
  83. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +23 -0
  84. package/cpp/skia/include/gpu/graphite/Image.h +56 -0
  85. package/cpp/skia/include/gpu/graphite/ImageProvider.h +5 -0
  86. package/cpp/skia/include/gpu/graphite/Recorder.h +26 -9
  87. package/cpp/skia/include/gpu/graphite/Recording.h +7 -5
  88. package/cpp/skia/include/gpu/graphite/TextureInfo.h +8 -0
  89. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +2 -2
  90. package/cpp/skia/include/gpu/mtl/GrMtlTypes.h +2 -2
  91. package/cpp/skia/include/gpu/vk/GrVkTypes.h +4 -3
  92. package/cpp/skia/include/ports/SkCFObject.h +1 -1
  93. package/cpp/skia/include/private/SkGainmapInfo.h +4 -13
  94. package/cpp/skia/include/private/SkJpegGainmapEncoder.h +1 -24
  95. package/cpp/skia/include/private/SkWeakRefCnt.h +1 -1
  96. package/cpp/skia/include/private/base/SkAnySubclass.h +73 -0
  97. package/cpp/skia/include/private/base/SkAssert.h +106 -12
  98. package/cpp/skia/include/private/base/SkAttributes.h +0 -12
  99. package/cpp/skia/include/private/base/SkFeatures.h +0 -3
  100. package/cpp/skia/include/private/base/SkFloatingPoint.h +58 -105
  101. package/cpp/skia/include/private/base/SkSpan_impl.h +18 -12
  102. package/cpp/skia/include/private/base/SkTArray.h +22 -17
  103. package/cpp/skia/include/private/base/SkTDArray.h +5 -6
  104. package/cpp/skia/include/private/base/SkTemplates.h +50 -30
  105. package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +5 -2
  106. package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +2 -2
  107. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +13 -8
  108. package/cpp/skia/include/private/chromium/SkDiscardableMemory.h +1 -1
  109. package/cpp/skia/include/private/chromium/SkImageChromium.h +16 -3
  110. package/cpp/skia/include/private/chromium/Slug.h +11 -4
  111. package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +1 -1
  112. package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +6 -9
  113. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +29 -13
  114. package/cpp/skia/include/private/gpu/ganesh/GrVkTypesPriv.h +2 -28
  115. package/cpp/skia/include/private/gpu/graphite/ContextOptionsPriv.h +34 -0
  116. package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +6 -0
  117. package/cpp/skia/include/private/gpu/graphite/MtlGraphiteTypesPriv.h +8 -0
  118. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +10 -0
  119. package/cpp/skia/include/utils/SkBase64.h +2 -2
  120. package/cpp/skia/include/utils/SkNWayCanvas.h +1 -11
  121. package/cpp/skia/include/utils/SkNoDrawCanvas.h +0 -2
  122. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +1 -2
  123. package/cpp/skia/include/utils/SkShadowUtils.h +15 -1
  124. package/cpp/skia/include/utils/SkTextUtils.h +1 -1
  125. package/cpp/skia/modules/skparagraph/include/Paragraph.h +107 -1
  126. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +3 -2
  127. package/cpp/skia/modules/skparagraph/include/ParagraphStyle.h +4 -0
  128. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +5 -3
  129. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +4 -0
  130. package/cpp/skia/src/core/SkChecksum.h +2 -1
  131. package/cpp/skia/src/core/SkPathPriv.h +1 -1
  132. package/cpp/skia/src/core/SkTHash.h +19 -9
  133. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +3 -1
  134. package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +1 -1
  135. package/lib/commonjs/dom/nodes/datatypes/Rect.js +5 -1
  136. package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
  137. package/lib/commonjs/external/reanimated/index.d.ts +1 -0
  138. package/lib/commonjs/external/reanimated/index.js +13 -0
  139. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  140. package/lib/commonjs/external/reanimated/moduleWrapper.js +3 -8
  141. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  142. package/lib/commonjs/external/reanimated/renderHelpers.js +46 -1
  143. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  144. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +2 -0
  145. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +26 -0
  146. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +1 -0
  147. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +2 -5
  148. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
  149. package/lib/commonjs/skia/types/MaskFilter.js +4 -0
  150. package/lib/commonjs/skia/types/MaskFilter.js.map +1 -1
  151. package/lib/commonjs/skia/web/JsiSkPicture.js +2 -1
  152. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  153. package/lib/commonjs/views/SkiaBaseWebView.js +1 -1
  154. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  155. package/lib/commonjs/views/types.js +3 -0
  156. package/lib/commonjs/views/types.js.map +1 -1
  157. package/lib/module/dom/nodes/datatypes/Rect.js +5 -1
  158. package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
  159. package/lib/module/external/reanimated/index.d.ts +1 -0
  160. package/lib/module/external/reanimated/index.js +1 -0
  161. package/lib/module/external/reanimated/index.js.map +1 -1
  162. package/lib/module/external/reanimated/moduleWrapper.js +1 -9
  163. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  164. package/lib/module/external/reanimated/renderHelpers.js +48 -2
  165. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  166. package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +2 -0
  167. package/lib/module/external/reanimated/useDerivedValueOnJS.js +15 -0
  168. package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +1 -0
  169. package/lib/module/external/reanimated/useSharedValueEffect.js +3 -6
  170. package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
  171. package/lib/module/skia/types/MaskFilter.js +3 -0
  172. package/lib/module/skia/types/MaskFilter.js.map +1 -1
  173. package/lib/module/views/types.js +3 -0
  174. package/lib/module/views/types.js.map +1 -1
  175. package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
  176. package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +2 -0
  177. package/libs/android/arm64-v8a/libskia.a +0 -0
  178. package/libs/android/arm64-v8a/libskottie.a +0 -0
  179. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  180. package/libs/android/arm64-v8a/libsksg.a +0 -0
  181. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  182. package/libs/android/arm64-v8a/libskunicode.a +0 -0
  183. package/libs/android/arm64-v8a/libsvg.a +0 -0
  184. package/libs/android/armeabi-v7a/libskia.a +0 -0
  185. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  186. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  187. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  188. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  189. package/libs/android/armeabi-v7a/libskunicode.a +0 -0
  190. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  191. package/libs/android/x86/libskia.a +0 -0
  192. package/libs/android/x86/libskottie.a +0 -0
  193. package/libs/android/x86/libskparagraph.a +0 -0
  194. package/libs/android/x86/libsksg.a +0 -0
  195. package/libs/android/x86/libskshaper.a +0 -0
  196. package/libs/android/x86/libskunicode.a +0 -0
  197. package/libs/android/x86/libsvg.a +0 -0
  198. package/libs/android/x86_64/libskia.a +0 -0
  199. package/libs/android/x86_64/libskottie.a +0 -0
  200. package/libs/android/x86_64/libskparagraph.a +0 -0
  201. package/libs/android/x86_64/libsksg.a +0 -0
  202. package/libs/android/x86_64/libskshaper.a +0 -0
  203. package/libs/android/x86_64/libskunicode.a +0 -0
  204. package/libs/android/x86_64/libsvg.a +0 -0
  205. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  206. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  207. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  208. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  209. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  210. package/libs/ios/libskparagraph.xcframework/Info.plist +5 -5
  211. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  212. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  213. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  214. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  215. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  216. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  217. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  218. package/libs/ios/libskunicode.xcframework/Info.plist +5 -5
  219. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
  220. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
  221. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  222. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  223. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  224. package/package.json +1 -1
  225. package/react-native-skia.podspec +1 -1
  226. package/src/dom/nodes/datatypes/Rect.ts +6 -2
  227. package/src/external/reanimated/index.ts +1 -0
  228. package/src/external/reanimated/moduleWrapper.ts +6 -10
  229. package/src/external/reanimated/renderHelpers.ts +41 -1
  230. package/src/external/reanimated/useDerivedValueOnJS.ts +24 -0
  231. package/src/external/reanimated/useSharedValueEffect.ts +4 -7
  232. package/cpp/skia/include/core/SkDeferredDisplayList.h +0 -15
  233. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +0 -15
  234. package/cpp/skia/include/core/SkPromiseImageTexture.h +0 -20
  235. package/cpp/skia/include/core/SkSurfaceCharacterization.h +0 -15
  236. package/cpp/skia/include/core/SkTime.h +0 -63
  237. package/cpp/skia/include/effects/SkOpPathEffect.h +0 -43
  238. package/cpp/skia/include/effects/SkStrokeAndFillPathEffect.h +0 -28
  239. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +0 -32
  240. package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +0 -95
  241. package/cpp/skia/include/private/SkBitmaskEnum.h +0 -59
  242. package/cpp/skia/include/private/SkSLDefines.h +0 -64
  243. package/cpp/skia/include/private/SkShadowFlags.h +0 -27
  244. package/cpp/skia/include/private/gpu/ganesh/GrDawnTypesPriv.h +0 -26
  245. /package/cpp/skia/{include/private/base → src/core}/SkPathEnums.h +0 -0
@@ -124,6 +124,9 @@ struct ParagraphStyle {
124
124
  bool getReplaceTabCharacters() const { return fReplaceTabCharacters; }
125
125
  void setReplaceTabCharacters(bool value) { fReplaceTabCharacters = value; }
126
126
 
127
+ bool getApplyRoundingHack() const { return fApplyRoundingHack; }
128
+ void setApplyRoundingHack(bool value) { fApplyRoundingHack = value; }
129
+
127
130
  private:
128
131
  StrutStyle fStrutStyle;
129
132
  TextStyle fDefaultTextStyle;
@@ -136,6 +139,7 @@ private:
136
139
  TextHeightBehavior fTextHeightBehavior;
137
140
  bool fHintingIsOn;
138
141
  bool fReplaceTabCharacters;
142
+ bool fApplyRoundingHack = true;
139
143
  };
140
144
  } // namespace textlayout
141
145
  } // namespace skia
@@ -2,14 +2,16 @@
2
2
  #ifndef TypefaceFontProvider_DEFINED
3
3
  #define TypefaceFontProvider_DEFINED
4
4
 
5
+ #include "include/core/SkFontMgr.h"
6
+ #include "include/core/SkFontStyle.h"
7
+ #include "include/core/SkStream.h"
8
+ #include "include/core/SkString.h"
5
9
  #include "include/private/base/SkTArray.h"
6
10
  #include "src/core/SkTHash.h"
11
+
7
12
  #include <string>
8
13
  #include <unordered_map>
9
14
  #include <vector>
10
- #include "include/core/SkFontMgr.h"
11
- #include "include/core/SkStream.h"
12
- #include "include/core/SkString.h"
13
15
 
14
16
  namespace skia {
15
17
  namespace textlayout {
@@ -116,9 +116,13 @@ private:
116
116
  bool parseLengthUnitToken(SkSVGLength::Unit*);
117
117
  bool parseNamedColorToken(SkColor*);
118
118
  bool parseHexColorToken(SkColor*);
119
+ bool parseColorComponentScalarToken(int32_t*);
120
+ bool parseColorComponentIntegralToken(int32_t*);
121
+ bool parseColorComponentFractionalToken(int32_t*);
119
122
  bool parseColorComponentToken(int32_t*);
120
123
  bool parseColorToken(SkColor*);
121
124
  bool parseRGBColorToken(SkColor*);
125
+ bool parseRGBAColorToken(SkColor*);
122
126
  bool parseSVGColor(SkSVGColor*, SkSVGColor::Vars&&);
123
127
  bool parseSVGColorType(SkSVGColorType*);
124
128
  bool parseFuncIRI(SkSVGFuncIRI*);
@@ -9,9 +9,10 @@
9
9
  #define SkChecksum_DEFINED
10
10
 
11
11
  #include "include/core/SkString.h"
12
- #include "include/core/SkTypes.h"
13
12
  #include "include/private/base/SkAPI.h"
14
13
 
14
+ #include <cstddef>
15
+ #include <cstdint>
15
16
  #include <string>
16
17
  #include <string_view>
17
18
  #include <type_traits>
@@ -19,7 +19,7 @@
19
19
  #include "include/private/SkIDChangeListener.h"
20
20
  #include "include/private/SkPathRef.h"
21
21
  #include "include/private/base/SkDebug.h"
22
- #include "include/private/base/SkPathEnums.h"
22
+ #include "src/core/SkPathEnums.h"
23
23
 
24
24
  #include <cstdint>
25
25
  #include <iterator>
@@ -9,11 +9,12 @@
9
9
  #define SkTHash_DEFINED
10
10
 
11
11
  #include "include/core/SkTypes.h"
12
- #include "include/private/base/SkTemplates.h"
13
12
  #include "src/core/SkChecksum.h"
14
13
 
15
14
  #include <initializer_list>
15
+ #include <memory>
16
16
  #include <new>
17
+ #include <type_traits>
17
18
  #include <utility>
18
19
 
19
20
  namespace skia_private {
@@ -40,7 +41,7 @@ public:
40
41
  if (this != &that) {
41
42
  fCount = that.fCount;
42
43
  fCapacity = that.fCapacity;
43
- fSlots.reset(that.fCapacity);
44
+ fSlots.reset(new Slot[that.fCapacity]);
44
45
  for (int i = 0; i < fCapacity; i++) {
45
46
  fSlots[i] = that.fSlots[i];
46
47
  }
@@ -147,8 +148,8 @@ public:
147
148
 
148
149
  fCount = 0;
149
150
  fCapacity = capacity;
150
- AutoTArray<Slot> oldSlots = std::move(fSlots);
151
- fSlots = AutoTArray<Slot>(capacity);
151
+ std::unique_ptr<Slot[]> oldSlots = std::move(fSlots);
152
+ fSlots.reset(new Slot[capacity]);
152
153
 
153
154
  for (int i = 0; i < oldCapacity; i++) {
154
155
  Slot& s = oldSlots[i];
@@ -413,7 +414,7 @@ private:
413
414
 
414
415
  int fCount = 0,
415
416
  fCapacity = 0;
416
- AutoTArray<Slot> fSlots;
417
+ std::unique_ptr<Slot[]> fSlots;
417
418
  };
418
419
 
419
420
  // Maps K->V. A more user-friendly wrapper around THashTable, suitable for most use cases.
@@ -488,15 +489,24 @@ public:
488
489
  }
489
490
 
490
491
  // Call fn on every key/value pair in the table. You may mutate the value but not the key.
491
- template <typename Fn> // f(K, V*) or f(const K&, V*)
492
+ template <typename Fn, // f(K, V*) or f(const K&, V*)
493
+ std::enable_if_t<std::is_invocable_v<Fn, K, V*>>* = nullptr>
492
494
  void foreach(Fn&& fn) {
493
- fTable.foreach([&fn](Pair* p){ fn(p->first, &p->second); });
495
+ fTable.foreach([&fn](Pair* p) { fn(p->first, &p->second); });
494
496
  }
495
497
 
496
498
  // Call fn on every key/value pair in the table. You may not mutate anything.
497
- template <typename Fn> // f(K, V), f(const K&, V), f(K, const V&) or f(const K&, const V&).
499
+ template <typename Fn, // f(K, V), f(const K&, V), f(K, const V&) or f(const K&, const V&).
500
+ std::enable_if_t<std::is_invocable_v<Fn, K, V>>* = nullptr>
498
501
  void foreach(Fn&& fn) const {
499
- fTable.foreach([&fn](const Pair& p){ fn(p.first, p.second); });
502
+ fTable.foreach([&fn](const Pair& p) { fn(p.first, p.second); });
503
+ }
504
+
505
+ // Call fn on every key/value pair in the table. You may not mutate anything.
506
+ template <typename Fn, // f(Pair), or f(const Pair&)
507
+ std::enable_if_t<std::is_invocable_v<Fn, Pair>>* = nullptr>
508
+ void foreach(Fn&& fn) const {
509
+ fTable.foreach([&fn](const Pair& p) { fn(p); });
500
510
  }
501
511
 
502
512
  // Dereferencing an iterator gives back a key-value pair, suitable for structured binding.
@@ -88,7 +88,9 @@ bool RNSkMetalCanvasProvider::renderToCanvas(
88
88
  SkCanvas *canvas = skSurface->getCanvas();
89
89
  cb(canvas);
90
90
 
91
- skSurface->flushAndSubmit();
91
+ if (auto dContext = GrAsDirectContext(skSurface->recordingContext())) {
92
+ dContext->flushAndSubmit();
93
+ }
92
94
 
93
95
  id<MTLCommandBuffer> commandBuffer(
94
96
  [ThreadContextHolder::ThreadSkiaMetalContext
@@ -65,7 +65,7 @@ SkiaMetalSurfaceFactory::makeWindowedSurface(id<MTLTexture> texture, int width,
65
65
  GrMtlTextureInfo fbInfo;
66
66
  fbInfo.fTexture.retain((__bridge void *)texture);
67
67
 
68
- GrBackendRenderTarget backendRT(width, height, 1, fbInfo);
68
+ GrBackendRenderTarget backendRT(width, height, fbInfo);
69
69
 
70
70
  auto skSurface = SkSurfaces::WrapBackendRenderTarget(
71
71
  ThreadContextHolder::ThreadSkiaMetalContext.skContext.get(), backendRT,
@@ -8,7 +8,11 @@ exports.processRect = exports.processRRect = exports.isEdge = void 0;
8
8
  var _Radius = require("./Radius");
9
9
 
10
10
  /* eslint-disable @typescript-eslint/no-explicit-any */
11
- const isEdge = (pos, b) => pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height; // We have an issue to check property existence on JSI backed instances
11
+ const isEdge = (pos, b) => {
12
+ "worklet";
13
+
14
+ return pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height;
15
+ }; // We have an issue to check property existence on JSI backed instances
12
16
 
13
17
 
14
18
  exports.isEdge = isEdge;
@@ -1 +1 @@
1
- {"version":3,"names":["isEdge","pos","b","x","y","width","height","isRRectCtor","def","rect","undefined","isRectCtor","processRect","Skia","XYWHRect","processRRect","r","processRadius","RRectXY"],"sources":["Rect.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Skia, SkRect, Vector } from \"../../../skia/types\";\nimport type { RectCtor, RectDef, RRectCtor, RRectDef } from \"../../types\";\n\nimport { processRadius } from \"./Radius\";\n\nexport const isEdge = (pos: Vector, b: SkRect) =>\n pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height;\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor =>\n (def as any).rect === undefined;\n\nexport const processRect = (Skia: Skia, def: RectDef) => {\n if (isRectCtor(def)) {\n return Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (Skia: Skia, def: RRectDef) => {\n if (isRRectCtor(def)) {\n const r = processRadius(Skia, def.r ?? 0);\n return Skia.RRectXY(\n Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height),\n r.x,\n r.y\n );\n } else {\n return def.rect;\n }\n};\n"],"mappings":";;;;;;;AAIA;;AAJA;AAMO,MAAMA,MAAM,GAAG,CAACC,GAAD,EAAcC,CAAd,KACpBD,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACC,CAAZ,IAAiBF,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACE,CAA7B,IAAkCH,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACG,KAA9C,IAAuDJ,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACI,MAD9D,C,CAGP;;;;;AACA,MAAMC,WAAW,GAAIC,GAAD,IACjBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB,C,CAEA;;;AACA,MAAMC,UAAU,GAAIH,GAAD,IAChBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB;;AAGO,MAAME,WAAW,GAAG,CAACC,IAAD,EAAaL,GAAb,KAA8B;EACvD,IAAIG,UAAU,CAACH,GAAD,CAAd,EAAqB;IACnB,OAAOK,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,CAAJ,IAAS,CAAvB,EAA0BK,GAAG,CAACJ,CAAJ,IAAS,CAAnC,EAAsCI,GAAG,CAACH,KAA1C,EAAiDG,GAAG,CAACF,MAArD,CAAP;EACD,CAFD,MAEO;IACL,OAAOE,GAAG,CAACC,IAAX;EACD;AACF,CANM;;;;AAQA,MAAMM,YAAY,GAAG,CAACF,IAAD,EAAaL,GAAb,KAA+B;EACzD,IAAID,WAAW,CAACC,GAAD,CAAf,EAAsB;IACpB,MAAMQ,CAAC,GAAG,IAAAC,qBAAA,EAAcJ,IAAd,EAAoBL,GAAG,CAACQ,CAAJ,IAAS,CAA7B,CAAV;IACA,OAAOH,IAAI,CAACK,OAAL,CACLL,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,CAAJ,IAAS,CAAvB,EAA0BK,GAAG,CAACJ,CAAJ,IAAS,CAAnC,EAAsCI,GAAG,CAACH,KAA1C,EAAiDG,GAAG,CAACF,MAArD,CADK,EAELU,CAAC,CAACb,CAFG,EAGLa,CAAC,CAACZ,CAHG,CAAP;EAKD,CAPD,MAOO;IACL,OAAOI,GAAG,CAACC,IAAX;EACD;AACF,CAXM"}
1
+ {"version":3,"names":["isEdge","pos","b","x","y","width","height","isRRectCtor","def","rect","undefined","isRectCtor","processRect","Skia","XYWHRect","processRRect","r","processRadius","RRectXY"],"sources":["Rect.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Skia, SkRect, Vector } from \"../../../skia/types\";\nimport type { RectCtor, RectDef, RRectCtor, RRectDef } from \"../../types\";\n\nimport { processRadius } from \"./Radius\";\n\nexport const isEdge = (pos: Vector, b: SkRect) => {\n \"worklet\";\n return (\n pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height\n );\n};\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor =>\n (def as any).rect === undefined;\n\nexport const processRect = (Skia: Skia, def: RectDef) => {\n if (isRectCtor(def)) {\n return Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (Skia: Skia, def: RRectDef) => {\n if (isRRectCtor(def)) {\n const r = processRadius(Skia, def.r ?? 0);\n return Skia.RRectXY(\n Skia.XYWHRect(def.x ?? 0, def.y ?? 0, def.width, def.height),\n r.x,\n r.y\n );\n } else {\n return def.rect;\n }\n};\n"],"mappings":";;;;;;;AAIA;;AAJA;AAMO,MAAMA,MAAM,GAAG,CAACC,GAAD,EAAcC,CAAd,KAA4B;EAChD;;EACA,OACED,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACC,CAAZ,IAAiBF,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACE,CAA7B,IAAkCH,GAAG,CAACE,CAAJ,KAAUD,CAAC,CAACG,KAA9C,IAAuDJ,GAAG,CAACG,CAAJ,KAAUF,CAAC,CAACI,MADrE;AAGD,CALM,C,CAOP;;;;;AACA,MAAMC,WAAW,GAAIC,GAAD,IACjBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB,C,CAEA;;;AACA,MAAMC,UAAU,GAAIH,GAAD,IAChBA,GAAD,CAAaC,IAAb,KAAsBC,SADxB;;AAGO,MAAME,WAAW,GAAG,CAACC,IAAD,EAAaL,GAAb,KAA8B;EACvD,IAAIG,UAAU,CAACH,GAAD,CAAd,EAAqB;IACnB,OAAOK,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,CAAJ,IAAS,CAAvB,EAA0BK,GAAG,CAACJ,CAAJ,IAAS,CAAnC,EAAsCI,GAAG,CAACH,KAA1C,EAAiDG,GAAG,CAACF,MAArD,CAAP;EACD,CAFD,MAEO;IACL,OAAOE,GAAG,CAACC,IAAX;EACD;AACF,CANM;;;;AAQA,MAAMM,YAAY,GAAG,CAACF,IAAD,EAAaL,GAAb,KAA+B;EACzD,IAAID,WAAW,CAACC,GAAD,CAAf,EAAsB;IACpB,MAAMQ,CAAC,GAAG,IAAAC,qBAAA,EAAcJ,IAAd,EAAoBL,GAAG,CAACQ,CAAJ,IAAS,CAA7B,CAAV;IACA,OAAOH,IAAI,CAACK,OAAL,CACLL,IAAI,CAACC,QAAL,CAAcN,GAAG,CAACL,CAAJ,IAAS,CAAvB,EAA0BK,GAAG,CAACJ,CAAJ,IAAS,CAAnC,EAAsCI,GAAG,CAACH,KAA1C,EAAiDG,GAAG,CAACF,MAArD,CADK,EAELU,CAAC,CAACb,CAFG,EAGLa,CAAC,CAACZ,CAHG,CAAP;EAKD,CAPD,MAOO;IACL,OAAOI,GAAG,CAACC,IAAX;EACD;AACF,CAXM"}
@@ -1,2 +1,3 @@
1
1
  export * from "./useSharedValueEffect";
2
+ export * from "./useDerivedValueOnJS";
2
3
  export * from "./renderHelpers";
@@ -17,6 +17,19 @@ Object.keys(_useSharedValueEffect).forEach(function (key) {
17
17
  });
18
18
  });
19
19
 
20
+ var _useDerivedValueOnJS = require("./useDerivedValueOnJS");
21
+
22
+ Object.keys(_useDerivedValueOnJS).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _useDerivedValueOnJS[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _useDerivedValueOnJS[key];
29
+ }
30
+ });
31
+ });
32
+
20
33
  var _renderHelpers = require("./renderHelpers");
21
34
 
22
35
  Object.keys(_renderHelpers).forEach(function (key) {
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useSharedValueEffect\";\nexport * from \"./renderHelpers\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useSharedValueEffect\";\nexport * from \"./useDerivedValueOnJS\";\nexport * from \"./renderHelpers\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -10,6 +10,8 @@ exports.useSharedValue = exports.useFrameCallback = void 0;
10
10
  var _react = require("react");
11
11
 
12
12
  var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5;
13
+ /* eslint-disable @typescript-eslint/no-explicit-any */
14
+
13
15
 
14
16
  // This one is needed for the deprecated useSharedValue function
15
17
  // We can remove it once we remove the deprecation
@@ -39,12 +41,6 @@ function throwOnMissingReanimated() {
39
41
  }
40
42
  }
41
43
 
42
- function throwOnMissingReanimated3() {
43
- if (!HAS_REANIMATED3) {
44
- throw new Error(`Reanimated version ${reanimatedVersion} is not supported, please upgrade to 3.0.0 or newer.`);
45
- }
46
- }
47
-
48
44
  const useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || (value => (0, _react.useMemo)(() => ({
49
45
  value
50
46
  }), [value]));
@@ -60,8 +56,7 @@ const runOnJS = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void
60
56
  exports.runOnJS = runOnJS;
61
57
 
62
58
  const isSharedValue = value => {
63
- throwOnMissingReanimated3();
64
- return !!value && Reanimated3.isSharedValue(value);
59
+ return !!value && (Reanimated3 ? Reanimated3.isSharedValue(value) : value.value !== undefined);
65
60
  };
66
61
 
67
62
  exports.isSharedValue = isSharedValue;
@@ -1 +1 @@
1
- {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","throwOnMissingReanimated3","useSharedValue","value","useMemo","useFrameCallback","startMapper","stopMapper","runOnJS","isSharedValue"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useMemo } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion =\n // eslint-disable-next-line import/extensions\n require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nfunction throwOnMissingReanimated3() {\n if (!HAS_REANIMATED3) {\n throw new Error(\n `Reanimated version ${reanimatedVersion} is not supported, please upgrade to 3.0.0 or newer.`\n );\n }\n}\n\nexport const useSharedValue =\n Reanimated2?.useSharedValue ||\n ((value: number) => useMemo(() => ({ value }), [value]));\nexport const useFrameCallback: (...args: any[]) => any =\n Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper = Reanimated2?.startMapper || throwOnMissingReanimated;\nexport const stopMapper = Reanimated2?.stopMapper || throwOnMissingReanimated;\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const isSharedValue = <T>(\n value: unknown\n): value is SharedValueType<T> => {\n throwOnMissingReanimated3();\n return !!value && Reanimated3.isSharedValue(value);\n};\n"],"mappings":";;;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AACA,MAAMU,aAAa,GACxBN,KAD2B,IAEK;EAChCF,yBAAyB;EACzB,OAAO,CAAC,CAACE,KAAF,IAAWZ,WAAW,CAACkB,aAAZ,CAA0BN,KAA1B,CAAlB;AACD,CALM"}
1
+ {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","value","useMemo","useFrameCallback","startMapper","stopMapper","runOnJS","isSharedValue","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useMemo } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion =\n // eslint-disable-next-line import/extensions\n require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue =\n Reanimated2?.useSharedValue ||\n ((value: number) => useMemo(() => ({ value }), [value]));\nexport const useFrameCallback: (...args: any[]) => any =\n Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper = Reanimated2?.startMapper || throwOnMissingReanimated;\nexport const stopMapper = Reanimated2?.stopMapper || throwOnMissingReanimated;\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const isSharedValue = <T>(\n value: unknown\n): value is SharedValueType<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;;;;;;;;AACA;;;AADA;;;AAKA;AACA;AAEA,IAAIA,WAAJ;AAEA,IAAIC,WAAJ;AACA,IAAIC,iBAAJ;;AAEA,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAD,CAArB;EACAD,iBAAiB,GACf;EACAC,OAAO,CAAC,sCAAD,CAAP,CAAgDC,OAFlD;;EAGA,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAArB,IAAgCA,iBAAiB,CAACG,QAAlB,CAA2B,QAA3B,CADhB,CADnB,EAGE;IACAJ,WAAW,GAAGD,WAAd;EACD;AACF,CAXD,CAWE,OAAOM,CAAP,EAAU,CAAE;;AAEP,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;;AACA,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;;;AAEA,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;;AAEM,MAAMC,cAAc,GACzB,gBAAAX,WAAW,UAAX,kDAAaW,cAAb,MACEC,KAAD,IAAmB,IAAAC,cAAA,EAAQ,OAAO;EAAED;AAAF,CAAP,CAAR,EAA2B,CAACA,KAAD,CAA3B,CADpB,CADK;;;AAGA,MAAME,gBAAyC,GACpD,iBAAAd,WAAW,UAAX,oDAAac,gBAAb,KAAiCL,wBAD5B;;AAGA,MAAMM,WAAW,GAAG,iBAAAf,WAAW,UAAX,oDAAae,WAAb,KAA4BN,wBAAhD;;AACA,MAAMO,UAAU,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,UAAb,KAA2BP,wBAA9C;;AACA,MAAMQ,OAAO,GAAG,iBAAAjB,WAAW,UAAX,oDAAaiB,OAAb,KAAwBR,wBAAxC;;;AACA,MAAMS,aAAa,GACxBN,KAD2B,IAEK;EAChC,OACE,CAAC,CAACA,KAAF,KACCX,WAAW,GACRA,WAAW,CAACiB,aAAZ,CAA0BN,KAA1B,CADQ,GAEPA,KAAD,CAAeA,KAAf,KAAyBO,SAH7B,CADF;AAMD,CATM"}
@@ -14,7 +14,7 @@ var _moduleWrapper = require("./moduleWrapper");
14
14
  const _bindings = new WeakMap();
15
15
 
16
16
  function extractReanimatedProps(props) {
17
- if (!_moduleWrapper.HAS_REANIMATED3) {
17
+ if (!_moduleWrapper.HAS_REANIMATED3 && !_moduleWrapper.HAS_REANIMATED2) {
18
18
  return [props, {}];
19
19
  }
20
20
 
@@ -39,7 +39,52 @@ function extractReanimatedProps(props) {
39
39
  return [otherProps, reanimatedProps];
40
40
  }
41
41
 
42
+ function bindReanimatedProps2(container, node, reanimatedProps) {
43
+ const sharedValues = Object.values(reanimatedProps);
44
+
45
+ const previousMapperId = _bindings.get(node);
46
+
47
+ if (previousMapperId !== undefined) {
48
+ (0, _moduleWrapper.stopMapper)(previousMapperId);
49
+ }
50
+
51
+ if (sharedValues.length > 0) {
52
+ const viewId = container.getNativeId();
53
+ const {
54
+ SkiaViewApi
55
+ } = global;
56
+
57
+ const updateProps = () => {
58
+ for (const propName in reanimatedProps) {
59
+ node && node.setProp(propName, reanimatedProps[propName].value);
60
+ } // On React Native we use the SkiaViewApi to redraw because it can
61
+ // run on the worklet thread (container.redraw can't)
62
+ // if SkiaViewApi is undefined, we are on web and container.redraw()
63
+ // can safely be invoked
64
+
65
+
66
+ if (SkiaViewApi) {
67
+ SkiaViewApi.requestRedraw(viewId);
68
+ } else {
69
+ container.redraw();
70
+ }
71
+ };
72
+
73
+ const mapperId = (0, _moduleWrapper.startMapper)(() => {
74
+ "worklet";
75
+
76
+ (0, _moduleWrapper.runOnJS)(updateProps)();
77
+ }, sharedValues);
78
+
79
+ _bindings.set(node, mapperId);
80
+ }
81
+ }
82
+
42
83
  function bindReanimatedProps(container, node, reanimatedProps) {
84
+ if (_moduleWrapper.HAS_REANIMATED2) {
85
+ return bindReanimatedProps2(container, node, reanimatedProps);
86
+ }
87
+
43
88
  if (!_moduleWrapper.HAS_REANIMATED3) {
44
89
  return;
45
90
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_bindings","WeakMap","extractReanimatedProps","props","HAS_REANIMATED3","reanimatedProps","otherProps","propName","propValue","isSharedValue","value","bindReanimatedProps","container","node","sharedValues","Object","values","previousMapperId","get","undefined","stopMapper","length","viewId","getNativeId","SkiaViewApi","global","mapperId","startMapper","setProp","requestRedraw","redraw","set"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable reanimated/js-function-in-worklet */\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport {\n startMapper,\n stopMapper,\n isSharedValue,\n HAS_REANIMATED3,\n} from \"./moduleWrapper\";\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED3) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (!HAS_REANIMATED3) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = startMapper(() => {\n \"worklet\";\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":";;;;;;;;AAMA;;AANA;;AACA;AAYA,MAAMA,SAAS,GAAG,IAAIC,OAAJ,EAAlB;;AAEO,SAASC,sBAAT,CAAgCC,KAAhC,EAA2D;EAChE,IAAI,CAACC,8BAAL,EAAsB;IACpB,OAAO,CAACD,KAAD,EAAQ,EAAR,CAAP;EACD;;EACD,MAAME,eAAe,GAAG,EAAxB;EACA,MAAMC,UAAU,GAAG,EAAnB;;EACA,KAAK,MAAMC,QAAX,IAAuBJ,KAAvB,EAA8B;IAC5B,IAAII,QAAQ,KAAK,UAAjB,EAA6B;MAC3B;IACD;;IACD,MAAMC,SAAS,GAAGL,KAAK,CAACI,QAAD,CAAvB;;IACA,IAAI,IAAAE,4BAAA,EAAcD,SAAd,CAAJ,EAA8B;MAC5BH,eAAe,CAACE,QAAD,CAAf,GAA4BC,SAA5B;MACAF,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAS,CAACE,KAAjC;IACD,CAHD,MAGO;MACLJ,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAvB;IACD;EACF;;EACD,OAAO,CAACF,UAAD,EAAaD,eAAb,CAAP;AACD;;AAEM,SAASM,mBAAT,CACLC,SADK,EAELC,IAFK,EAGLR,eAHK,EAIL;EACA,IAAI,CAACD,8BAAL,EAAsB;IACpB;EACD;;EACD,MAAMU,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcX,eAAd,CAArB;;EACA,MAAMY,gBAAgB,GAAGjB,SAAS,CAACkB,GAAV,CAAcL,IAAd,CAAzB;;EACA,IAAII,gBAAgB,KAAKE,SAAzB,EAAoC;IAClC,IAAAC,yBAAA,EAAWH,gBAAX;EACD;;EACD,IAAIH,YAAY,CAACO,MAAb,GAAsB,CAA1B,EAA6B;IAC3B,MAAMC,MAAM,GAAGV,SAAS,CAACW,WAAV,EAAf;IACA,MAAM;MAAEC;IAAF,IAAkBC,MAAxB;IACA,MAAMC,QAAQ,GAAG,IAAAC,0BAAA,EAAY,MAAM;MACjC;;MACA,KAAK,MAAMpB,QAAX,IAAuBF,eAAvB,EAAwC;QACtCQ,IAAI,IAAIA,IAAI,CAACe,OAAL,CAAarB,QAAb,EAAuBF,eAAe,CAACE,QAAD,CAAf,CAA0BG,KAAjD,CAAR;MACD,CAJgC,CAKjC;MACA;MACA;MACA;;;MACA,IAAIc,WAAJ,EAAiB;QACfA,WAAW,CAACK,aAAZ,CAA0BP,MAA1B;MACD,CAFD,MAEO;QACLV,SAAS,CAACkB,MAAV;MACD;IACF,CAdgB,EAcdhB,YAdc,CAAjB;;IAeAd,SAAS,CAAC+B,GAAV,CAAclB,IAAd,EAAoBa,QAApB;EACD;AACF"}
1
+ {"version":3,"names":["_bindings","WeakMap","extractReanimatedProps","props","HAS_REANIMATED3","HAS_REANIMATED2","reanimatedProps","otherProps","propName","propValue","isSharedValue","value","bindReanimatedProps2","container","node","sharedValues","Object","values","previousMapperId","get","undefined","stopMapper","length","viewId","getNativeId","SkiaViewApi","global","updateProps","setProp","requestRedraw","redraw","mapperId","startMapper","runOnJS","set","bindReanimatedProps"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable reanimated/js-function-in-worklet */\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport {\n startMapper,\n stopMapper,\n isSharedValue,\n HAS_REANIMATED3,\n HAS_REANIMATED2,\n runOnJS,\n} from \"./moduleWrapper\";\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nfunction bindReanimatedProps2(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const updateProps = () => {\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n };\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(updateProps)();\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (HAS_REANIMATED2) {\n return bindReanimatedProps2(container, node, reanimatedProps);\n }\n if (!HAS_REANIMATED3) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = startMapper(() => {\n \"worklet\";\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":";;;;;;;;AAMA;;AANA;;AACA;AAcA,MAAMA,SAAS,GAAG,IAAIC,OAAJ,EAAlB;;AAEO,SAASC,sBAAT,CAAgCC,KAAhC,EAA2D;EAChE,IAAI,CAACC,8BAAD,IAAoB,CAACC,8BAAzB,EAA0C;IACxC,OAAO,CAACF,KAAD,EAAQ,EAAR,CAAP;EACD;;EACD,MAAMG,eAAe,GAAG,EAAxB;EACA,MAAMC,UAAU,GAAG,EAAnB;;EACA,KAAK,MAAMC,QAAX,IAAuBL,KAAvB,EAA8B;IAC5B,IAAIK,QAAQ,KAAK,UAAjB,EAA6B;MAC3B;IACD;;IACD,MAAMC,SAAS,GAAGN,KAAK,CAACK,QAAD,CAAvB;;IACA,IAAI,IAAAE,4BAAA,EAAcD,SAAd,CAAJ,EAA8B;MAC5BH,eAAe,CAACE,QAAD,CAAf,GAA4BC,SAA5B;MACAF,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAS,CAACE,KAAjC;IACD,CAHD,MAGO;MACLJ,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAvB;IACD;EACF;;EACD,OAAO,CAACF,UAAD,EAAaD,eAAb,CAAP;AACD;;AAED,SAASM,oBAAT,CACEC,SADF,EAEEC,IAFF,EAGER,eAHF,EAIE;EACA,MAAMS,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcX,eAAd,CAArB;;EACA,MAAMY,gBAAgB,GAAGlB,SAAS,CAACmB,GAAV,CAAcL,IAAd,CAAzB;;EACA,IAAII,gBAAgB,KAAKE,SAAzB,EAAoC;IAClC,IAAAC,yBAAA,EAAWH,gBAAX;EACD;;EACD,IAAIH,YAAY,CAACO,MAAb,GAAsB,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AAQ,GAAG,IAAAC,0BAAA,EAAY,MAAM;MACjC;;MACA,KAAK,MAAMxB,QAAX,IAAuBF,eAAvB,EAAwC;QACtCQ,IAAI,IAAIA,IAAI,CAACc,OAAL,CAAapB,QAAb,EAAuBF,eAAe,CAACE,QAAD,CAAf,CAA0BG,KAAjD,CAAR;MACD,CAJgC,CAKjC;MACA;MACA;MACA;;;MACA,IAAIc,WAAJ,EAAiB;QACfA,WAAW,CAACI,aAAZ,CAA0BN,MAA1B;MACD,CAFD,MAEO;QACLV,SAAS,CAACiB,MAAV;MACD;IACF,CAdgB,EAcdf,YAdc,CAAjB;;IAeAf,SAAS,CAACkC,GAAV,CAAcpB,IAAd,EAAoBiB,QAApB;EACD;AACF"}
@@ -0,0 +1,2 @@
1
+ import { type DependencyList } from "react";
2
+ export declare const useDerivedValueOnJS: (fn: () => any, deps?: DependencyList) => any;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useDerivedValueOnJS = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _moduleWrapper = require("./moduleWrapper");
11
+
12
+ const useDerivedValueOnJS = (fn, deps) => {
13
+ const value = (0, _moduleWrapper.useSharedValue)(fn());
14
+ (0, _react.useEffect)(() => {
15
+ const mapperId = (0, _moduleWrapper.startMapper)(() => {
16
+ "worklet";
17
+
18
+ (0, _moduleWrapper.runOnJS)(fn)();
19
+ }, deps);
20
+ return () => (0, _moduleWrapper.stopMapper)(mapperId);
21
+ }, [deps, fn]);
22
+ return value;
23
+ };
24
+
25
+ exports.useDerivedValueOnJS = useDerivedValueOnJS;
26
+ //# sourceMappingURL=useDerivedValueOnJS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useDerivedValueOnJS","fn","deps","value","useSharedValue","useEffect","mapperId","startMapper","runOnJS","stopMapper"],"sources":["useDerivedValueOnJS.ts"],"sourcesContent":["import { useEffect, type DependencyList } from \"react\";\n\nimport {\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\nexport const useDerivedValueOnJS = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fn: () => any,\n deps?: DependencyList\n) => {\n const value = useSharedValue(fn());\n useEffect(() => {\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(fn)();\n }, deps);\n return () => stopMapper(mapperId);\n }, [deps, fn]);\n return value;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAOO,MAAMA,mBAAmB,GAAG,CAEjCC,EAFiC,EAGjCC,IAHiC,KAI9B;EACH,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAeH,EAAE,EAAjB,CAAd;EACA,IAAAI,gBAAA,EAAU,MAAM;IACd,MAAMC,QAAQ,GAAG,IAAAC,0BAAA,EAAY,MAAM;MACjC;;MACA,IAAAC,sBAAA,EAAQP,EAAR;IACD,CAHgB,EAGdC,IAHc,CAAjB;IAIA,OAAO,MAAM,IAAAO,yBAAA,EAAWH,QAAX,CAAb;EACD,CAND,EAMG,CAACJ,IAAD,EAAOD,EAAP,CANH;EAOA,OAAOE,KAAP;AACD,CAdM"}
@@ -20,11 +20,8 @@ const useSharedValueEffect = function (cb, value) {
20
20
  values[_key - 2] = arguments[_key];
21
21
  }
22
22
 
23
- if (_moduleWrapper.HAS_REANIMATED3) {
24
- console.warn(`useSharedValueEffect() is deprecated with Reanimated 3, you can use Reanimated values directly.
25
- Learn more at https://shopify.github.io/react-native-skia/docs/animations/reanimated.`);
26
- }
27
-
23
+ console.warn(`useSharedValueEffect() is deprecated and will be removed in the next release
24
+ Learn more at https://shopify.github.io/react-native-skia/docs/animations/animations.`);
28
25
  const input = (0, _moduleWrapper.useSharedValue)(0);
29
26
  (0, _react.useEffect)(() => {
30
27
  if (!_moduleWrapper.HAS_REANIMATED2) {
@@ -1 +1 @@
1
- {"version":3,"names":["useSharedValueEffect","cb","value","values","HAS_REANIMATED3","console","warn","input","useSharedValue","useEffect","HAS_REANIMATED2","mapperId","startMapper","runOnJS","stopMapper","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED2,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n HAS_REANIMATED3,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n if (HAS_REANIMATED3) {\n console.warn(\n `useSharedValueEffect() is deprecated with Reanimated 3, you can use Reanimated values directly.\nLearn more at https://shopify.github.io/react-native-skia/docs/animations/reanimated.`\n );\n }\n const input = useSharedValue(0);\n\n useEffect(() => {\n if (!HAS_REANIMATED2) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AASA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACH,IAAIC,8BAAJ,EAAqB;IACnBC,OAAO,CAACC,IAAR,CACG;AACP,sFAFI;EAID;;EACD,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAe,CAAf,CAAd;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACd,IAAI,CAACC,8BAAL,EAAsB;MACpBL,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAMK,QAAQ,GAAG,IAAAC,0BAAA,EACf,MAAM;QACJ;;QACA,IAAAC,sBAAA,EAAQZ,EAAR;MACD,CAJc,EAKf,CAACC,KAAD,EAAQ,GAAGC,MAAX,CALe,EAMf,CAACI,KAAD,CANe,CAAjB,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIO,yBAAA,IAAcH,QAAQ,KAAKI,SAA/B,EAA0C;UACxC,IAAAD,yBAAA,EAAWH,QAAX;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBD,EAwBG,CAACJ,KAAD,EAAQL,KAAR,EAAe,GAAGC,MAAlB,CAxBH;AAyBD,CAtCM"}
1
+ {"version":3,"names":["useSharedValueEffect","cb","value","values","console","warn","input","useSharedValue","useEffect","HAS_REANIMATED2","mapperId","startMapper","runOnJS","stopMapper","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED2,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n console.warn(\n `useSharedValueEffect() is deprecated and will be removed in the next release\nLearn more at https://shopify.github.io/react-native-skia/docs/animations/animations.`\n );\n const input = useSharedValue(0);\n\n useEffect(() => {\n if (!HAS_REANIMATED2) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACHC,OAAO,CAACC,IAAR,CACG;AACL,sFAFE;EAIA,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAe,CAAf,CAAd;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACd,IAAI,CAACC,8BAAL,EAAsB;MACpBL,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAMK,QAAQ,GAAG,IAAAC,0BAAA,EACf,MAAM;QACJ;;QACA,IAAAC,sBAAA,EAAQX,EAAR;MACD,CAJc,EAKf,CAACC,KAAD,EAAQ,GAAGC,MAAX,CALe,EAMf,CAACG,KAAD,CANe,CAAjB,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIO,yBAAA,IAAcH,QAAQ,KAAKI,SAA/B,EAA0C;UACxC,IAAAD,yBAAA,EAAWH,QAAX;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBD,EAwBG,CAACJ,KAAD,EAAQJ,KAAR,EAAe,GAAGC,MAAlB,CAxBH;AAyBD,CApCM"}
@@ -15,6 +15,10 @@ exports.BlurStyle = BlurStyle;
15
15
  })(BlurStyle || (exports.BlurStyle = BlurStyle = {}));
16
16
 
17
17
  const isMaskFilter = obj => obj !== null && obj.__typename__ === "MaskFilter";
18
+ /**
19
+ * See SkMaskFilter.h for more details.
20
+ */
21
+
18
22
 
19
23
  exports.isMaskFilter = isMaskFilter;
20
24
  //# sourceMappingURL=MaskFilter.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BlurStyle","isMaskFilter","obj","__typename__"],"sources":["MaskFilter.ts"],"sourcesContent":["import type { SkJSIInstance } from \"./JsiInstance\";\n\nexport enum BlurStyle {\n Normal, //!< fuzzy inside and outside\n Solid, //!< solid inside, fuzzy outside\n Outer, //!< nothing inside, fuzzy outside\n Inner, //!< fuzzy inside, nothing outside\n}\n\nexport const isMaskFilter = (\n obj: SkJSIInstance<string> | null\n): obj is SkMaskFilter => obj !== null && obj.__typename__ === \"MaskFilter\";\n\nexport type SkMaskFilter = SkJSIInstance<\"MaskFilter\">;\n\n/**\n * See SkMaskFilter.h for more details.\n */\nexport interface MaskFilterFactory {\n /**\n * Create a blur maskfilter\n * @param style\n * @param sigma - Standard deviation of the Gaussian blur to apply. Must be > 0.\n * @param respectCTM - if true the blur's sigma is modified by the CTM.\n */\n MakeBlur(style: BlurStyle, sigma: number, respectCTM: boolean): SkMaskFilter;\n}\n"],"mappings":";;;;;;IAEYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;AAOL,MAAMC,YAAY,GACvBC,GAD0B,IAEFA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,YAFxD"}
1
+ {"version":3,"names":["BlurStyle","isMaskFilter","obj","__typename__"],"sources":["MaskFilter.ts"],"sourcesContent":["import type { SkJSIInstance } from \"./JsiInstance\";\n\nexport enum BlurStyle {\n Normal, //!< fuzzy inside and outside\n Solid, //!< solid inside, fuzzy outside\n Outer, //!< nothing inside, fuzzy outside\n Inner, //!< fuzzy inside, nothing outside\n}\n\nexport const isMaskFilter = (\n obj: SkJSIInstance<string> | null\n): obj is SkMaskFilter => obj !== null && obj.__typename__ === \"MaskFilter\";\n\nexport type SkMaskFilter = SkJSIInstance<\"MaskFilter\">;\n\n/**\n * See SkMaskFilter.h for more details.\n */\nexport interface MaskFilterFactory {\n /**\n * Create a blur maskfilter\n * @param style\n * @param sigma - Standard deviation of the Gaussian blur to apply. Must be > 0.\n * @param respectCTM - if true the blur's sigma is modified by the CTM.\n */\n MakeBlur(style: BlurStyle, sigma: number, respectCTM: boolean): SkMaskFilter;\n}\n"],"mappings":";;;;;;IAEYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;AAOL,MAAMC,YAAY,GACvBC,GAD0B,IAEFA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,YAFxD;AAMP;AACA;AACA"}
@@ -13,7 +13,8 @@ var _JsiSkMatrix = require("./JsiSkMatrix");
13
13
 
14
14
  var _JsiSkRect = require("./JsiSkRect");
15
15
 
16
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } // TODO: suggest to rename SkPicture to Picture for consistency
17
+
17
18
 
18
19
  class JsiSkPicture extends _Host.HostObject {
19
20
  constructor(CanvasKit, ref) {
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkPicture","HostObject","constructor","CanvasKit","ref","delete","makeShader","tmx","tmy","mode","localMatrix","tileRect","JsiSkShader","ckEnum","JsiSkMatrix","fromValue","undefined","JsiSkRect","serialize"],"sources":["JsiSkPicture.ts"],"sourcesContent":["// TODO: suggest to rename SkPicture to Picture for consistency\nimport type { CanvasKit, SkPicture as Picture } from \"canvaskit-wasm\";\n\nimport type {\n FilterMode,\n SkRect,\n TileMode,\n SkPicture,\n SkMatrix,\n} from \"../types\";\n\nimport { HostObject, ckEnum } from \"./Host\";\nimport { JsiSkShader } from \"./JsiSkShader\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkPicture\n extends HostObject<Picture, \"Picture\">\n implements SkPicture\n{\n constructor(CanvasKit: CanvasKit, ref: Picture) {\n super(CanvasKit, ref, \"Picture\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n makeShader(\n tmx: TileMode,\n tmy: TileMode,\n mode: FilterMode,\n localMatrix?: SkMatrix,\n tileRect?: SkRect\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShader(\n ckEnum(tmx),\n ckEnum(tmy),\n ckEnum(mode),\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined,\n tileRect ? JsiSkRect.fromValue(this.CanvasKit, tileRect) : undefined\n )\n );\n }\n\n serialize() {\n return this.ref.serialize();\n }\n}\n"],"mappings":";;;;;;;AAWA;;AACA;;AACA;;AACA;;;;AAEO,MAAMA,YAAN,SACGC,gBADH,CAGP;EACEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAqC;IAC9C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,SAAtB;;IAD8C,iCAItC,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAN+C;EAE/C;;EAMDC,UAAU,CACRC,GADQ,EAERC,GAFQ,EAGRC,IAHQ,EAIRC,WAJQ,EAKRC,QALQ,EAMR;IACA,OAAO,IAAIC,wBAAJ,CACL,KAAKT,SADA,EAEL,KAAKC,GAAL,CAASE,UAAT,CACE,IAAAO,YAAA,EAAON,GAAP,CADF,EAEE,IAAAM,YAAA,EAAOL,GAAP,CAFF,EAGE,IAAAK,YAAA,EAAOJ,IAAP,CAHF,EAIEC,WAAW,GAAGI,wBAAA,CAAYC,SAAZ,CAAsBL,WAAtB,CAAH,GAAwCM,SAJrD,EAKEL,QAAQ,GAAGM,oBAAA,CAAUF,SAAV,CAAoB,KAAKZ,SAAzB,EAAoCQ,QAApC,CAAH,GAAmDK,SAL7D,CAFK,CAAP;EAUD;;EAEDE,SAAS,GAAG;IACV,OAAO,KAAKd,GAAL,CAASc,SAAT,EAAP;EACD;;AA9BH"}
1
+ {"version":3,"names":["JsiSkPicture","HostObject","constructor","CanvasKit","ref","delete","makeShader","tmx","tmy","mode","localMatrix","tileRect","JsiSkShader","ckEnum","JsiSkMatrix","fromValue","undefined","JsiSkRect","serialize"],"sources":["JsiSkPicture.ts"],"sourcesContent":["// TODO: suggest to rename SkPicture to Picture for consistency\nimport type { CanvasKit, SkPicture as Picture } from \"canvaskit-wasm\";\n\nimport type {\n FilterMode,\n SkRect,\n TileMode,\n SkPicture,\n SkMatrix,\n} from \"../types\";\n\nimport { HostObject, ckEnum } from \"./Host\";\nimport { JsiSkShader } from \"./JsiSkShader\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkPicture\n extends HostObject<Picture, \"Picture\">\n implements SkPicture\n{\n constructor(CanvasKit: CanvasKit, ref: Picture) {\n super(CanvasKit, ref, \"Picture\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n makeShader(\n tmx: TileMode,\n tmy: TileMode,\n mode: FilterMode,\n localMatrix?: SkMatrix,\n tileRect?: SkRect\n ) {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShader(\n ckEnum(tmx),\n ckEnum(tmy),\n ckEnum(mode),\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined,\n tileRect ? JsiSkRect.fromValue(this.CanvasKit, tileRect) : undefined\n )\n );\n }\n\n serialize() {\n return this.ref.serialize();\n }\n}\n"],"mappings":";;;;;;;AAWA;;AACA;;AACA;;AACA;;kNAdA;;;AAgBO,MAAMA,YAAN,SACGC,gBADH,CAGP;EACEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAqC;IAC9C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,SAAtB;;IAD8C,iCAItC,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAN+C;EAE/C;;EAMDC,UAAU,CACRC,GADQ,EAERC,GAFQ,EAGRC,IAHQ,EAIRC,WAJQ,EAKRC,QALQ,EAMR;IACA,OAAO,IAAIC,wBAAJ,CACL,KAAKT,SADA,EAEL,KAAKC,GAAL,CAASE,UAAT,CACE,IAAAO,YAAA,EAAON,GAAP,CADF,EAEE,IAAAM,YAAA,EAAOL,GAAP,CAFF,EAGE,IAAAK,YAAA,EAAOJ,IAAP,CAHF,EAIEC,WAAW,GAAGI,wBAAA,CAAYC,SAAZ,CAAsBL,WAAtB,CAAH,GAAwCM,SAJrD,EAKEL,QAAQ,GAAGM,oBAAA,CAAUF,SAAV,CAAoB,KAAKZ,SAAzB,EAAoCQ,QAApC,CAAH,GAAmDK,SAL7D,CAFK,CAAP;EAUD;;EAEDE,SAAS,GAAG;IACV,OAAO,KAAKd,GAAL,CAASc,SAAT,EAAP;EACD;;AA9BH"}
@@ -17,7 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
 
18
18
  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); }
19
19
 
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /* global HTMLCanvasElement */
21
21
 
22
22
  const pd = _Platform.Platform.PixelRatio;
23
23
 
@@ -1 +1 @@
1
- {"version":3,"names":["pd","Platform","PixelRatio","SkiaBaseWebView","React","Component","constructor","props","createRef","createTouchHandler","TouchType","Start","Active","Cancelled","End","onLayoutEvent","bind","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","evt","CanvasKit","global","canvas","_canvasRef","current","width","clientWidth","height","clientHeight","surface","MakeWebGLCanvasSurface","Error","_surface","JsiSkSurface","_canvas","getCanvas","redraw","onLayout","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","getContext","getExtension","loseContext","makeImageSnapshot","rect","clear","TRANSPARENT","renderInCanvas","ref","flush","_redrawRequests","touches","_touches","Float32Array","of","save","scale","restore","requestAnimationFrame","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","timestamp","Date","now","render","debug","viewProps","display","flex","onStart","onActive","onEnd","onCancel"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\n\nimport type { DrawMode, SkiaBaseViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst pd = Platform.PixelRatio;\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayoutEvent(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n // Reset canvas / surface on layout change\n const canvas = this._canvasRef.current;\n if (canvas) {\n this.width = canvas.clientWidth;\n this.height = canvas.clientHeight;\n canvas.width = this.width * pd;\n canvas.height = this.height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\n // eslint-disable-next-line max-len\n // https://stackoverflow.com/questions/23598471/how-do-i-clean-up-and-unload-a-webgl-canvas-context-from-gpu-after-use\n // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context\n // We delete the context, only if the context has been intialized\n if (this._surface) {\n this._canvasRef.current\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!, []);\n this._surface?.ref.flush();\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(\n canvas: SkCanvas,\n touches: TouchInfo[]\n ): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const touches = [...this._touches];\n this._touches = [];\n const canvas = this._canvas!;\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n this.renderInCanvas(canvas, touches);\n canvas.restore();\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.tick();\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(_values: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.redraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.redraw();\n }\n\n createTouchHandler(touchType: TouchType) {\n return (evt: PointerEvent) => this.handleTouchEvent(evt, touchType);\n }\n\n private onStart = this.createTouchHandler(TouchType.Start);\n private onActive = this.createTouchHandler(TouchType.Active);\n private onCancel = this.createTouchHandler(TouchType.Cancelled);\n private onEnd = this.createTouchHandler(TouchType.End);\n private onLayout = this.onLayoutEvent.bind(this);\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <Platform.View {...viewProps} onLayout={this.onLayout}>\n <canvas\n ref={this._canvasRef}\n style={{ display: \"flex\", flex: 1 }}\n onPointerDown={this.onStart}\n onPointerMove={this.onActive}\n onPointerUp={this.onEnd}\n onPointerCancel={this.onCancel}\n onPointerLeave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KAAKC,QANxB;MAOE,cAAc,EAAE,KAAKD,KAPvB;MAQE,YAAY,EAAE,KAAKA;IARrB,EADF,CADF;EAcD;;AA7L+B"}
1
+ {"version":3,"names":["pd","Platform","PixelRatio","SkiaBaseWebView","React","Component","constructor","props","createRef","createTouchHandler","TouchType","Start","Active","Cancelled","End","onLayoutEvent","bind","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","evt","CanvasKit","global","canvas","_canvasRef","current","width","clientWidth","height","clientHeight","surface","MakeWebGLCanvasSurface","Error","_surface","JsiSkSurface","_canvas","getCanvas","redraw","onLayout","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","getContext","getExtension","loseContext","makeImageSnapshot","rect","clear","TRANSPARENT","renderInCanvas","ref","flush","_redrawRequests","touches","_touches","Float32Array","of","save","scale","restore","requestAnimationFrame","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","timestamp","Date","now","render","debug","viewProps","display","flex","onStart","onActive","onEnd","onCancel"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\n\nimport type { DrawMode, SkiaBaseViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst pd = Platform.PixelRatio;\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayoutEvent(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n // Reset canvas / surface on layout change\n const canvas = this._canvasRef.current;\n if (canvas) {\n this.width = canvas.clientWidth;\n this.height = canvas.clientHeight;\n canvas.width = this.width * pd;\n canvas.height = this.height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\n // eslint-disable-next-line max-len\n // https://stackoverflow.com/questions/23598471/how-do-i-clean-up-and-unload-a-webgl-canvas-context-from-gpu-after-use\n // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context\n // We delete the context, only if the context has been intialized\n if (this._surface) {\n this._canvasRef.current\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!, []);\n this._surface?.ref.flush();\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(\n canvas: SkCanvas,\n touches: TouchInfo[]\n ): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const touches = [...this._touches];\n this._touches = [];\n const canvas = this._canvas!;\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n this.renderInCanvas(canvas, touches);\n canvas.restore();\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.tick();\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(_values: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.redraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.redraw();\n }\n\n createTouchHandler(touchType: TouchType) {\n return (evt: PointerEvent) => this.handleTouchEvent(evt, touchType);\n }\n\n private onStart = this.createTouchHandler(TouchType.Start);\n private onActive = this.createTouchHandler(TouchType.Active);\n private onCancel = this.createTouchHandler(TouchType.Cancelled);\n private onEnd = this.createTouchHandler(TouchType.End);\n private onLayout = this.onLayoutEvent.bind(this);\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <Platform.View {...viewProps} onLayout={this.onLayout}>\n <canvas\n ref={this._canvasRef}\n style={{ display: \"flex\", flex: 1 }}\n onPointerDown={this.onStart}\n onPointerMove={this.onActive}\n onPointerUp={this.onEnd}\n onPointerCancel={this.onCancel}\n onPointerLeave={this.onEnd}\n onPointerOut={this.onEnd}\n />\n </Platform.View>\n );\n }\n}\n"],"mappings":";;;;;;;AACA;;AAMA;;AACA;;AAGA;;;;;;kNAXA;;AAaA,MAAMA,EAAE,GAAGC,kBAAA,CAASC,UAApB;;AAEO,MAAeC,eAAf,SAEGC,cAAA,CAAMC,SAFT,CAE2B;EAChCC,WAAW,CAACC,KAAD,EAAgB;IACzB,MAAMA,KAAN;;IADyB,kCAKa,IALb;;IAAA,0CAMmB,EANnB;;IAAA,kCAOU,EAPV;;IAAA,iCAQQ,IARR;;IAAA,iDASNH,cAAA,CAAMI,SAAN,EATM;;IAAA;;IAAA,yCAWD,CAXC;;IAAA,mCAYP,CAZO;;IAAA,+BAcT,CAdS;;IAAA,gCAeR,CAfQ;;IAAA,iCAsKT,KAAKC,kBAAL,CAAwBC,gBAAA,CAAUC,KAAlC,CAtKS;;IAAA,kCAuKR,KAAKF,kBAAL,CAAwBC,gBAAA,CAAUE,MAAlC,CAvKQ;;IAAA,kCAwKR,KAAKH,kBAAL,CAAwBC,gBAAA,CAAUG,SAAlC,CAxKQ;;IAAA,+BAyKX,KAAKJ,kBAAL,CAAwBC,gBAAA,CAAUI,GAAlC,CAzKW;;IAAA,kCA0KR,KAAKC,aAAL,CAAmBC,IAAnB,CAAwB,IAAxB,CA1KQ;;IAEzB,KAAKC,KAAL,GAAaV,KAAK,CAACW,IAAN,IAAc,SAA3B;EACD;;EAcOC,cAAc,GAAG;IACvB,KAAKC,gBAAL,CAAsBC,OAAtB,CAA+BC,CAAD,IAAOA,CAAC,EAAtC;;IACA,KAAKF,gBAAL,GAAwB,EAAxB;EACD;;EAEOL,aAAa,CAACQ,G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AAKd,UADZ;MAEE,KAAK,EAAE;QAAEoE,OAAO,EAAE,MAAX;QAAmBC,IAAI,EAAE;MAAzB,CAFT;MAGE,aAAa,EAAE,KAAKC,OAHtB;MAIE,aAAa,EAAE,KAAKC,QAJtB;MAKE,WAAW,EAAE,KAAKC,KALpB;MAME,eAAe,EAAE,KAAKC,QANxB;MAOE,cAAc,EAAE,KAAKD,KAPvB;MAQE,YAAY,EAAE,KAAKA;IARrB,EADF,CADF;EAcD;;AA7L+B"}
@@ -13,4 +13,7 @@ exports.TouchType = TouchType;
13
13
  TouchType[TouchType["End"] = 2] = "End";
14
14
  TouchType[TouchType["Cancelled"] = 3] = "Cancelled";
15
15
  })(TouchType || (exports.TouchType = TouchType = {}));
16
+ /**
17
+ * Listener interface for value changes
18
+ */
16
19
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["TouchType"],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\n\nimport type { GroupProps, RenderNode } from \"../dom/types\";\nimport type {\n SkCanvas,\n SkImage,\n SkPicture,\n SkRect,\n SkSize,\n} from \"../skia/types\";\nimport type { SkiaMutableValue, SkiaValue } from \"../values\";\nimport type { SharedValueType } from \"../renderer/processors/Animations/Animations\";\n\nexport type DrawMode = \"continuous\" | \"default\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n mode?: DrawMode;\n debug?: boolean;\n};\n\nexport enum TouchType {\n Start,\n Active,\n End,\n Cancelled,\n}\n\nexport interface TouchInfo {\n x: number;\n y: number;\n force: number;\n type: TouchType;\n id: number;\n timestamp: number;\n}\n\nexport interface DrawingInfo {\n width: number;\n height: number;\n timestamp: number;\n touches: Array<Array<TouchInfo>>;\n}\n\nexport type ExtendedTouchInfo = TouchInfo & {\n // points per second\n velocityX: number;\n velocityY: number;\n};\n\nexport type TouchHandlers = {\n onStart?: (touchInfo: TouchInfo) => void;\n onActive?: (touchInfo: ExtendedTouchInfo) => void;\n onEnd?: (touchInfo: ExtendedTouchInfo) => void;\n};\n\nexport type TouchHandler = (touchInfo: Array<Array<TouchInfo>>) => void;\n\nexport type RNSkiaDrawCallback = (canvas: SkCanvas, info: DrawingInfo) => void;\n\n/**\n * Listener interface for value changes\n */\nexport interface ValueListener {\n addListener: (callback: () => void) => number;\n removeListener: (id: number) => void;\n}\n\nexport interface ISkiaViewApi {\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n callJsiMethod: <T extends Array<unknown>>(\n nativeId: number,\n name: string,\n ...args: T\n ) => void;\n registerValuesInView: (\n nativeId: number,\n values: SkiaValue<unknown>[]\n ) => () => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * Sets the drawing mode for the skia view. There are two drawing\n * modes, \"continuous\" and \"default\", where the continuous mode will\n * continuously redraw the view, and the default mode will only\n * redraw when any of the regular react properties are changed like\n * sizes and margins.\n */\n mode?: DrawMode;\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SkiaMutableValue<SkSize> | SharedValueType<SkSize>;\n}\n\nexport interface SkiaDrawViewProps extends SkiaBaseViewProps {\n /**\n * Draw callback. Will be called whenever the view is invalidated and\n * needs to redraw. This is either caused by a change in a react\n * property, a touch event, or a call to redraw. If the view is in\n * continuous mode the callback will be called 60 frames per second\n * by the native view.\n */\n onDraw?: RNSkiaDrawCallback;\n}\n\nexport interface SkiaPictureViewProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewProps extends SkiaBaseViewProps {\n root?: RenderNode<GroupProps>;\n onTouch?: TouchHandler;\n}\n"],"mappings":";;;;;;IAoBYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S"}
1
+ {"version":3,"names":["TouchType"],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\n\nimport type { GroupProps, RenderNode } from \"../dom/types\";\nimport type {\n SkCanvas,\n SkImage,\n SkPicture,\n SkRect,\n SkSize,\n} from \"../skia/types\";\nimport type { SkiaMutableValue, SkiaValue } from \"../values\";\nimport type { SharedValueType } from \"../renderer/processors/Animations/Animations\";\n\nexport type DrawMode = \"continuous\" | \"default\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n mode?: DrawMode;\n debug?: boolean;\n};\n\nexport enum TouchType {\n Start,\n Active,\n End,\n Cancelled,\n}\n\nexport interface TouchInfo {\n x: number;\n y: number;\n force: number;\n type: TouchType;\n id: number;\n timestamp: number;\n}\n\nexport interface DrawingInfo {\n width: number;\n height: number;\n timestamp: number;\n touches: Array<Array<TouchInfo>>;\n}\n\nexport type ExtendedTouchInfo = TouchInfo & {\n // points per second\n velocityX: number;\n velocityY: number;\n};\n\nexport type TouchHandlers = {\n onStart?: (touchInfo: TouchInfo) => void;\n onActive?: (touchInfo: ExtendedTouchInfo) => void;\n onEnd?: (touchInfo: ExtendedTouchInfo) => void;\n};\n\nexport type TouchHandler = (touchInfo: Array<Array<TouchInfo>>) => void;\n\nexport type RNSkiaDrawCallback = (canvas: SkCanvas, info: DrawingInfo) => void;\n\n/**\n * Listener interface for value changes\n */\nexport interface ValueListener {\n addListener: (callback: () => void) => number;\n removeListener: (id: number) => void;\n}\n\nexport interface ISkiaViewApi {\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n callJsiMethod: <T extends Array<unknown>>(\n nativeId: number,\n name: string,\n ...args: T\n ) => void;\n registerValuesInView: (\n nativeId: number,\n values: SkiaValue<unknown>[]\n ) => () => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * Sets the drawing mode for the skia view. There are two drawing\n * modes, \"continuous\" and \"default\", where the continuous mode will\n * continuously redraw the view, and the default mode will only\n * redraw when any of the regular react properties are changed like\n * sizes and margins.\n */\n mode?: DrawMode;\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SkiaMutableValue<SkSize> | SharedValueType<SkSize>;\n}\n\nexport interface SkiaDrawViewProps extends SkiaBaseViewProps {\n /**\n * Draw callback. Will be called whenever the view is invalidated and\n * needs to redraw. This is either caused by a change in a react\n * property, a touch event, or a call to redraw. If the view is in\n * continuous mode the callback will be called 60 frames per second\n * by the native view.\n */\n onDraw?: RNSkiaDrawCallback;\n}\n\nexport interface SkiaPictureViewProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewProps extends SkiaBaseViewProps {\n root?: RenderNode<GroupProps>;\n onTouch?: TouchHandler;\n}\n"],"mappings":";;;;;;IAoBYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;AAuCZ;AACA;AACA"}
@@ -1,6 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { processRadius } from "./Radius";
3
- export const isEdge = (pos, b) => pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height; // We have an issue to check property existence on JSI backed instances
3
+ export const isEdge = (pos, b) => {
4
+ "worklet";
5
+
6
+ return pos.x === b.x || pos.y === b.y || pos.x === b.width || pos.y === b.height;
7
+ }; // We have an issue to check property existence on JSI backed instances
4
8
 
5
9
  const isRRectCtor = def => def.rect === undefined; // We have an issue to check property existence on JSI backed instances
6
10