@amazon-devices/expo-image 2.0.1758683737

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 (289) hide show
  1. package/.eslintrc.js +2 -0
  2. package/CHANGELOG.md +285 -0
  3. package/CMakeLists.txt +91 -0
  4. package/LICENSE +7 -0
  5. package/README.kepler.md +123 -0
  6. package/README.md +54 -0
  7. package/THIRD_PARTY_NOTICES.txt +24 -0
  8. package/android/build.gradle +124 -0
  9. package/android/proguard-rules.pro +28 -0
  10. package/android/src/main/AndroidManifest.xml +15 -0
  11. package/android/src/main/java/expo/modules/image/Exceptions.kt +9 -0
  12. package/android/src/main/java/expo/modules/image/ExpoImageAppGlideModule.kt +19 -0
  13. package/android/src/main/java/expo/modules/image/ExpoImageModule.kt +192 -0
  14. package/android/src/main/java/expo/modules/image/ExpoImageView.kt +220 -0
  15. package/android/src/main/java/expo/modules/image/ExpoImageViewWrapper.kt +652 -0
  16. package/android/src/main/java/expo/modules/image/GlideModel.kt +73 -0
  17. package/android/src/main/java/expo/modules/image/ImageUtils.kt +50 -0
  18. package/android/src/main/java/expo/modules/image/ImageViewWrapperTarget.kt +313 -0
  19. package/android/src/main/java/expo/modules/image/ResourceIdHelper.kt +47 -0
  20. package/android/src/main/java/expo/modules/image/ThumbnailRequestCoordinatorExtension.kt +21 -0
  21. package/android/src/main/java/expo/modules/image/YogaUtils.kt +20 -0
  22. package/android/src/main/java/expo/modules/image/blurhash/BlurHashFetcher.kt +32 -0
  23. package/android/src/main/java/expo/modules/image/blurhash/BlurhashDecoder.kt +189 -0
  24. package/android/src/main/java/expo/modules/image/blurhash/BlurhashModelLoader.kt +30 -0
  25. package/android/src/main/java/expo/modules/image/blurhash/BlurhashModelLoaderFactory.kt +14 -0
  26. package/android/src/main/java/expo/modules/image/blurhash/BlurhashModule.kt +17 -0
  27. package/android/src/main/java/expo/modules/image/dataurls/Base64DataFetcher.kt +27 -0
  28. package/android/src/main/java/expo/modules/image/dataurls/Base64ModelLoader.kt +24 -0
  29. package/android/src/main/java/expo/modules/image/dataurls/Base64ModelLoaderFactory.kt +12 -0
  30. package/android/src/main/java/expo/modules/image/dataurls/Base64Module.kt +16 -0
  31. package/android/src/main/java/expo/modules/image/drawing/OutlineProvider.kt +201 -0
  32. package/android/src/main/java/expo/modules/image/enums/ContentFit.kt +89 -0
  33. package/android/src/main/java/expo/modules/image/enums/ImageCacheType.kt +14 -0
  34. package/android/src/main/java/expo/modules/image/enums/Priority.kt +15 -0
  35. package/android/src/main/java/expo/modules/image/events/GlideRequestListener.kt +64 -0
  36. package/android/src/main/java/expo/modules/image/events/OkHttpProgressListener.kt +26 -0
  37. package/android/src/main/java/expo/modules/image/okhttp/ExpoImageOkHttpClientGlideModule.kt +80 -0
  38. package/android/src/main/java/expo/modules/image/okhttp/GlideUrlWrapperLoader.kt +55 -0
  39. package/android/src/main/java/expo/modules/image/records/CachePolicy.kt +10 -0
  40. package/android/src/main/java/expo/modules/image/records/ContentPosition.kt +89 -0
  41. package/android/src/main/java/expo/modules/image/records/ImageTransition.kt +8 -0
  42. package/android/src/main/java/expo/modules/image/records/SourceMap.kt +160 -0
  43. package/android/src/main/java/expo/modules/image/records/events.kt +25 -0
  44. package/android/src/main/java/expo/modules/image/svg/SVGDecoder.kt +33 -0
  45. package/android/src/main/java/expo/modules/image/svg/SVGDrawableTranscoder.kt +37 -0
  46. package/android/src/main/java/expo/modules/image/svg/SVGModule.kt +26 -0
  47. package/android/src/main/java/expo/modules/image/thumbhash/ThumbhashDecoder.kt +365 -0
  48. package/android/src/main/java/expo/modules/image/thumbhash/ThumbhashFetcher.kt +31 -0
  49. package/android/src/main/java/expo/modules/image/thumbhash/ThumbhashModelLoader.kt +26 -0
  50. package/android/src/main/java/expo/modules/image/thumbhash/ThumbhashModelLoaderFactory.kt +14 -0
  51. package/android/src/main/java/expo/modules/image/thumbhash/ThumbhashModule.kt +17 -0
  52. package/build/ExpoImage.d.ts +15 -0
  53. package/build/ExpoImage.d.ts.map +1 -0
  54. package/build/ExpoImage.js +75 -0
  55. package/build/ExpoImage.js.map +1 -0
  56. package/build/ExpoImage.kepler.d.ts +23 -0
  57. package/build/ExpoImage.kepler.d.ts.map +1 -0
  58. package/build/ExpoImage.kepler.js +71 -0
  59. package/build/ExpoImage.kepler.js.map +1 -0
  60. package/build/ExpoImage.web.d.ts +9 -0
  61. package/build/ExpoImage.web.d.ts.map +1 -0
  62. package/build/ExpoImage.web.js +90 -0
  63. package/build/ExpoImage.web.js.map +1 -0
  64. package/build/ExpoImageModules.d.ts +3 -0
  65. package/build/ExpoImageModules.d.ts.map +1 -0
  66. package/build/ExpoImageModules.js +4 -0
  67. package/build/ExpoImageModules.js.map +1 -0
  68. package/build/ExpoImageModules.kepler.d.ts +6 -0
  69. package/build/ExpoImageModules.kepler.d.ts.map +1 -0
  70. package/build/ExpoImageModules.kepler.js +5 -0
  71. package/build/ExpoImageModules.kepler.js.map +1 -0
  72. package/build/Image.d.ts +30 -0
  73. package/build/Image.d.ts.map +1 -0
  74. package/build/Image.js +49 -0
  75. package/build/Image.js.map +1 -0
  76. package/build/Image.types.d.ts +374 -0
  77. package/build/Image.types.d.ts.map +1 -0
  78. package/build/Image.types.js +2 -0
  79. package/build/Image.types.js.map +1 -0
  80. package/build/ImageBackground.d.ts +6 -0
  81. package/build/ImageBackground.d.ts.map +1 -0
  82. package/build/ImageBackground.js +13 -0
  83. package/build/ImageBackground.js.map +1 -0
  84. package/build/ImageViewNativeComponent.d.ts +20 -0
  85. package/build/ImageViewNativeComponent.d.ts.map +1 -0
  86. package/build/ImageViewNativeComponent.js +42 -0
  87. package/build/ImageViewNativeComponent.js.map +1 -0
  88. package/build/NativeImageLoaderKepler.d.ts +18 -0
  89. package/build/NativeImageLoaderKepler.d.ts.map +1 -0
  90. package/build/NativeImageLoaderKepler.js +3 -0
  91. package/build/NativeImageLoaderKepler.js.map +1 -0
  92. package/build/fabric/registerNativeComponent.d.ts +15 -0
  93. package/build/fabric/registerNativeComponent.d.ts.map +1 -0
  94. package/build/fabric/registerNativeComponent.js +47 -0
  95. package/build/fabric/registerNativeComponent.js.map +1 -0
  96. package/build/index.d.ts +4 -0
  97. package/build/index.d.ts.map +1 -0
  98. package/build/index.js +4 -0
  99. package/build/index.js.map +1 -0
  100. package/build/utils/AssetSourceResolver.web.d.ts +24 -0
  101. package/build/utils/AssetSourceResolver.web.d.ts.map +1 -0
  102. package/build/utils/AssetSourceResolver.web.js +67 -0
  103. package/build/utils/AssetSourceResolver.web.js.map +1 -0
  104. package/build/utils/blurhash/base83.d.ts +3 -0
  105. package/build/utils/blurhash/base83.d.ts.map +1 -0
  106. package/build/utils/blurhash/base83.js +103 -0
  107. package/build/utils/blurhash/base83.js.map +1 -0
  108. package/build/utils/blurhash/decode.d.ts +7 -0
  109. package/build/utils/blurhash/decode.d.ts.map +1 -0
  110. package/build/utils/blurhash/decode.js +92 -0
  111. package/build/utils/blurhash/decode.js.map +1 -0
  112. package/build/utils/blurhash/error.d.ts +4 -0
  113. package/build/utils/blurhash/error.d.ts.map +1 -0
  114. package/build/utils/blurhash/error.js +8 -0
  115. package/build/utils/blurhash/error.js.map +1 -0
  116. package/build/utils/blurhash/useBlurhash.d.ts +8 -0
  117. package/build/utils/blurhash/useBlurhash.d.ts.map +1 -0
  118. package/build/utils/blurhash/useBlurhash.js +64 -0
  119. package/build/utils/blurhash/useBlurhash.js.map +1 -0
  120. package/build/utils/blurhash/utils.d.ts +5 -0
  121. package/build/utils/blurhash/utils.d.ts.map +1 -0
  122. package/build/utils/blurhash/utils.js +21 -0
  123. package/build/utils/blurhash/utils.js.map +1 -0
  124. package/build/utils/resolveAssetSource.d.ts +3 -0
  125. package/build/utils/resolveAssetSource.d.ts.map +1 -0
  126. package/build/utils/resolveAssetSource.js +3 -0
  127. package/build/utils/resolveAssetSource.js.map +1 -0
  128. package/build/utils/resolveAssetSource.web.d.ts +9 -0
  129. package/build/utils/resolveAssetSource.web.d.ts.map +1 -0
  130. package/build/utils/resolveAssetSource.web.js +31 -0
  131. package/build/utils/resolveAssetSource.web.js.map +1 -0
  132. package/build/utils/resolveHashString.d.ts +14 -0
  133. package/build/utils/resolveHashString.d.ts.map +1 -0
  134. package/build/utils/resolveHashString.js +31 -0
  135. package/build/utils/resolveHashString.js.map +1 -0
  136. package/build/utils/resolveHashString.web.d.ts +20 -0
  137. package/build/utils/resolveHashString.web.d.ts.map +1 -0
  138. package/build/utils/resolveHashString.web.js +31 -0
  139. package/build/utils/resolveHashString.web.js.map +1 -0
  140. package/build/utils/resolveSources.d.ts +8 -0
  141. package/build/utils/resolveSources.d.ts.map +1 -0
  142. package/build/utils/resolveSources.js +45 -0
  143. package/build/utils/resolveSources.js.map +1 -0
  144. package/build/utils/thumbhash/thumbhash.d.ts +66 -0
  145. package/build/utils/thumbhash/thumbhash.d.ts.map +1 -0
  146. package/build/utils/thumbhash/thumbhash.js +338 -0
  147. package/build/utils/thumbhash/thumbhash.js.map +1 -0
  148. package/build/utils.d.ts +17 -0
  149. package/build/utils.d.ts.map +1 -0
  150. package/build/utils.js +85 -0
  151. package/build/utils.js.map +1 -0
  152. package/build/web/AnimationManager.d.ts +37 -0
  153. package/build/web/AnimationManager.d.ts.map +1 -0
  154. package/build/web/AnimationManager.js +155 -0
  155. package/build/web/AnimationManager.js.map +1 -0
  156. package/build/web/ColorTintFilter.d.ts +12 -0
  157. package/build/web/ColorTintFilter.d.ts.map +1 -0
  158. package/build/web/ColorTintFilter.js +30 -0
  159. package/build/web/ColorTintFilter.js.map +1 -0
  160. package/build/web/ImageWrapper.d.ts +5 -0
  161. package/build/web/ImageWrapper.d.ts.map +1 -0
  162. package/build/web/ImageWrapper.js +44 -0
  163. package/build/web/ImageWrapper.js.map +1 -0
  164. package/build/web/ImageWrapper.types.d.ts +29 -0
  165. package/build/web/ImageWrapper.types.d.ts.map +1 -0
  166. package/build/web/ImageWrapper.types.js +2 -0
  167. package/build/web/ImageWrapper.types.js.map +1 -0
  168. package/build/web/getImageWrapperEventHandler.d.ts +8 -0
  169. package/build/web/getImageWrapperEventHandler.d.ts.map +1 -0
  170. package/build/web/getImageWrapperEventHandler.js +25 -0
  171. package/build/web/getImageWrapperEventHandler.js.map +1 -0
  172. package/build/web/hooks.d.ts +13 -0
  173. package/build/web/hooks.d.ts.map +1 -0
  174. package/build/web/hooks.js +58 -0
  175. package/build/web/hooks.js.map +1 -0
  176. package/build/web/imageStyles.d.ts +2 -0
  177. package/build/web/imageStyles.d.ts.map +1 -0
  178. package/build/web/imageStyles.js +137 -0
  179. package/build/web/imageStyles.js.map +1 -0
  180. package/build/web/positioning.d.ts +11 -0
  181. package/build/web/positioning.d.ts.map +1 -0
  182. package/build/web/positioning.js +35 -0
  183. package/build/web/positioning.js.map +1 -0
  184. package/build/web/useSourceSelection.d.ts +14 -0
  185. package/build/web/useSourceSelection.d.ts.map +1 -0
  186. package/build/web/useSourceSelection.js +98 -0
  187. package/build/web/useSourceSelection.js.map +1 -0
  188. package/expo-module.config.json +9 -0
  189. package/ios/Blurhash.swift +326 -0
  190. package/ios/BlurhashLoader.swift +52 -0
  191. package/ios/ContentFit.swift +55 -0
  192. package/ios/ContentPosition.swift +108 -0
  193. package/ios/ExpoImage.podspec +30 -0
  194. package/ios/ImageCachePolicy.swift +24 -0
  195. package/ios/ImageCacheType.swift +21 -0
  196. package/ios/ImageModule.swift +127 -0
  197. package/ios/ImagePriority.swift +22 -0
  198. package/ios/ImageSource.swift +44 -0
  199. package/ios/ImageTransition.swift +67 -0
  200. package/ios/ImageUtils.swift +227 -0
  201. package/ios/ImageView.swift +469 -0
  202. package/ios/Loaders/PhotoLibraryAssetLoader.swift +146 -0
  203. package/ios/Thumbhash.swift +550 -0
  204. package/ios/ThumbhashLoader.swift +53 -0
  205. package/jest.config.js +3 -0
  206. package/kepler/ExpoImage.cpp +63 -0
  207. package/kepler/ExpoImage.h +29 -0
  208. package/kepler/ExpoImageCacheHandler.cpp +15 -0
  209. package/kepler/ExpoImageCacheHandler.h +28 -0
  210. package/kepler/ExpoImageComponent.cpp +579 -0
  211. package/kepler/ExpoImageComponent.h +199 -0
  212. package/kepler/ImageWrapper/BlurhashImageWrapper.cpp +37 -0
  213. package/kepler/ImageWrapper/BlurhashImageWrapper.h +23 -0
  214. package/kepler/ImageWrapper/CacheImageWrapper.cpp +80 -0
  215. package/kepler/ImageWrapper/CacheImageWrapper.h +41 -0
  216. package/kepler/ImageWrapper/HashImageWrapper.cpp +21 -0
  217. package/kepler/ImageWrapper/HashImageWrapper.h +22 -0
  218. package/kepler/ImageWrapper/ImageWrapper.cpp +24 -0
  219. package/kepler/ImageWrapper/ImageWrapper.h +33 -0
  220. package/kepler/ImageWrapper/LocalImageWrapper.cpp +61 -0
  221. package/kepler/ImageWrapper/LocalImageWrapper.h +30 -0
  222. package/kepler/ImageWrapper/ThumbhashImageWrapper.cpp +33 -0
  223. package/kepler/ImageWrapper/ThumbhashImageWrapper.h +20 -0
  224. package/kepler/KeplerImageViewComponent.h +64 -0
  225. package/kepler/KeplerInit.cpp +35 -0
  226. package/kepler/blurhash/common.h +32 -0
  227. package/kepler/blurhash/decode.cpp +187 -0
  228. package/kepler/blurhash/decode.h +58 -0
  229. package/kepler/contentposition/ImageContentPosition.cpp +86 -0
  230. package/kepler/contentposition/ImageContentPosition.h +48 -0
  231. package/kepler/enums/ImageContentFit.h +17 -0
  232. package/kepler/enums/ImagePriority.h +17 -0
  233. package/kepler/managers/ExpoImageManager.cpp +38 -0
  234. package/kepler/managers/ExpoImageManager.h +23 -0
  235. package/kepler/test/ExpoImage.cpp +73 -0
  236. package/kepler/test/ExpoImageComponent.cpp +290 -0
  237. package/kepler/test/blurhash/decode.cpp +39 -0
  238. package/kepler/test/contentposition/ImageContentPosition.cpp +100 -0
  239. package/kepler/test/managers/ExpoImageManager.cpp +39 -0
  240. package/kepler/test/thumbhash/decode.cpp +18 -0
  241. package/kepler/test/utils/LoaderDelegate.cpp +130 -0
  242. package/kepler/thumbhash/decode.cpp +166 -0
  243. package/kepler/thumbhash/decode.h +22 -0
  244. package/kepler/utils/PlaceholderImageLoaderDelegate.cpp +26 -0
  245. package/kepler/utils/PlaceholderImageLoaderDelegate.h +26 -0
  246. package/kepler/utils/PrefetchImageLoaderDelegate.cpp +55 -0
  247. package/kepler/utils/PrefetchImageLoaderDelegate.h +35 -0
  248. package/kepler/utils/SourceImageLoaderDelegate.cpp +47 -0
  249. package/kepler/utils/SourceImageLoaderDelegate.h +42 -0
  250. package/kepler/utils/SourceImageLoaderDelegateEmitter.cpp +15 -0
  251. package/kepler/utils/SourceImageLoaderDelegateEmitter.h +28 -0
  252. package/kepler-compatibility.json +8 -0
  253. package/package.json +1 -0
  254. package/react-native.config.js +22 -0
  255. package/src/ExpoImage.kepler.tsx +119 -0
  256. package/src/ExpoImage.tsx +119 -0
  257. package/src/ExpoImage.web.tsx +155 -0
  258. package/src/ExpoImageModules.kepler.ts +7 -0
  259. package/src/ExpoImageModules.ts +4 -0
  260. package/src/Image.tsx +82 -0
  261. package/src/Image.types.ts +450 -0
  262. package/src/ImageBackground.tsx +18 -0
  263. package/src/ImageViewNativeComponent.ts +59 -0
  264. package/src/NativeImageLoaderKepler.ts +22 -0
  265. package/src/fabric/registerNativeComponent.ts +70 -0
  266. package/src/index.ts +3 -0
  267. package/src/utils/AssetSourceResolver.web.ts +88 -0
  268. package/src/utils/blurhash/base83.ts +104 -0
  269. package/src/utils/blurhash/decode.ts +114 -0
  270. package/src/utils/blurhash/error.ts +7 -0
  271. package/src/utils/blurhash/useBlurhash.tsx +81 -0
  272. package/src/utils/blurhash/utils.ts +21 -0
  273. package/src/utils/resolveAssetSource.tsx +3 -0
  274. package/src/utils/resolveAssetSource.web.ts +40 -0
  275. package/src/utils/resolveHashString.tsx +36 -0
  276. package/src/utils/resolveHashString.web.tsx +33 -0
  277. package/src/utils/resolveSources.tsx +48 -0
  278. package/src/utils/thumbhash/thumbhash.ts +387 -0
  279. package/src/utils.ts +109 -0
  280. package/src/web/AnimationManager.tsx +224 -0
  281. package/src/web/ColorTintFilter.tsx +36 -0
  282. package/src/web/ImageWrapper.tsx +85 -0
  283. package/src/web/ImageWrapper.types.ts +36 -0
  284. package/src/web/getImageWrapperEventHandler.ts +29 -0
  285. package/src/web/hooks.ts +72 -0
  286. package/src/web/imageStyles.tsx +136 -0
  287. package/src/web/positioning.ts +48 -0
  288. package/src/web/useSourceSelection.ts +151 -0
  289. package/tsconfig.json +9 -0
@@ -0,0 +1,17 @@
1
+ import { ImageContentFit, ImageContentPosition, ImageContentPositionObject, ImageProps, ImageTransition } from './Image.types';
2
+ /**
3
+ * If the `contentFit` is not provided, it's resolved from the equivalent `resizeMode` prop
4
+ * that we support to provide compatibility with React Native Image.
5
+ */
6
+ export declare function resolveContentFit(contentFit?: ImageContentFit, resizeMode?: ImageProps['resizeMode']): ImageContentFit;
7
+ /**
8
+ * It resolves a stringified form of the `contentPosition` prop to an object,
9
+ * which is the only form supported in the native code.
10
+ */
11
+ export declare function resolveContentPosition(contentPosition?: ImageContentPosition): ImageContentPositionObject;
12
+ /**
13
+ * If `transition` or `fadeDuration` is a number, it's resolved to a cross dissolve transition with the given duration.
14
+ * When `fadeDuration` is used, it logs an appropriate deprecation warning.
15
+ */
16
+ export declare function resolveTransition(transition?: ImageProps['transition'], fadeDuration?: ImageProps['fadeDuration']): ImageTransition | null;
17
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,0BAA0B,EAE1B,UAAU,EACV,eAAe,EAChB,MAAM,eAAe,CAAC;AAMvB;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,CAAC,EAAE,eAAe,EAC5B,UAAU,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,GACpC,eAAe,CA0BjB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,CAAC,EAAE,oBAAoB,GACrC,0BAA0B,CAiC5B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,EACrC,YAAY,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,GACxC,eAAe,GAAG,IAAI,CAYxB"}
package/build/utils.js ADDED
@@ -0,0 +1,85 @@
1
+ let loggedResizeModeDeprecationWarning = false;
2
+ let loggedRepeatDeprecationWarning = false;
3
+ let loggedFadeDurationDeprecationWarning = false;
4
+ /**
5
+ * If the `contentFit` is not provided, it's resolved from the equivalent `resizeMode` prop
6
+ * that we support to provide compatibility with React Native Image.
7
+ */
8
+ export function resolveContentFit(contentFit, resizeMode) {
9
+ if (contentFit) {
10
+ return contentFit;
11
+ }
12
+ if (resizeMode) {
13
+ if (!loggedResizeModeDeprecationWarning) {
14
+ console.log('[expo-image]: Prop "resizeMode" is deprecated, use "contentFit" instead');
15
+ loggedResizeModeDeprecationWarning = true;
16
+ }
17
+ switch (resizeMode) {
18
+ case 'contain':
19
+ case 'cover':
20
+ return resizeMode;
21
+ case 'stretch':
22
+ return 'fill';
23
+ case 'center':
24
+ return 'scale-down';
25
+ case 'repeat':
26
+ if (!loggedRepeatDeprecationWarning) {
27
+ console.log('[expo-image]: Resize mode "repeat" is no longer supported');
28
+ loggedRepeatDeprecationWarning = true;
29
+ }
30
+ }
31
+ }
32
+ return 'cover';
33
+ }
34
+ /**
35
+ * It resolves a stringified form of the `contentPosition` prop to an object,
36
+ * which is the only form supported in the native code.
37
+ */
38
+ export function resolveContentPosition(contentPosition) {
39
+ if (typeof contentPosition === 'string') {
40
+ const contentPositionStringMappings = {
41
+ center: { top: '50%', left: '50%' },
42
+ top: { top: 0, left: '50%' },
43
+ right: { top: '50%', right: 0 },
44
+ bottom: { bottom: 0, left: '50%' },
45
+ left: { top: '50%', left: 0 },
46
+ 'top center': { top: 0, left: '50%' },
47
+ 'top right': { top: 0, right: 0 },
48
+ 'top left': { top: 0, left: 0 },
49
+ 'right center': { top: '50%', right: 0 },
50
+ 'right top': { top: 0, right: 0 },
51
+ 'right bottom': { bottom: 0, right: 0 },
52
+ 'bottom center': { bottom: 0, left: '50%' },
53
+ 'bottom right': { bottom: 0, right: 0 },
54
+ 'bottom left': { bottom: 0, left: 0 },
55
+ 'left center': { top: '50%', left: 0 },
56
+ 'left top': { top: 0, left: 0 },
57
+ 'left bottom': { bottom: 0, left: 0 },
58
+ };
59
+ const contentPositionObject = contentPositionStringMappings[contentPosition];
60
+ if (!contentPositionObject) {
61
+ console.warn(`[expo-image]: Content position "${contentPosition}" is invalid`);
62
+ return contentPositionStringMappings.center;
63
+ }
64
+ return contentPositionObject;
65
+ }
66
+ return contentPosition ?? { top: '50%', left: '50%' };
67
+ }
68
+ /**
69
+ * If `transition` or `fadeDuration` is a number, it's resolved to a cross dissolve transition with the given duration.
70
+ * When `fadeDuration` is used, it logs an appropriate deprecation warning.
71
+ */
72
+ export function resolveTransition(transition, fadeDuration) {
73
+ if (typeof transition === 'number') {
74
+ return { duration: transition };
75
+ }
76
+ if (!transition && typeof fadeDuration === 'number') {
77
+ if (!loggedFadeDurationDeprecationWarning) {
78
+ console.warn('[expo-image]: Prop "fadeDuration" is deprecated, use "transition" instead');
79
+ loggedFadeDurationDeprecationWarning = true;
80
+ }
81
+ return { duration: fadeDuration };
82
+ }
83
+ return transition ?? null;
84
+ }
85
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AASA,IAAI,kCAAkC,GAAG,KAAK,CAAC;AAC/C,IAAI,8BAA8B,GAAG,KAAK,CAAC;AAC3C,IAAI,oCAAoC,GAAG,KAAK,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA4B,EAC5B,UAAqC;IAErC,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,UAA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U,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACpD,IAAI,CAAC,oCAAoC,EAAE,CAAC;YAC1C,OAAO,CAAC,IAAI,CAAC,2EAA2E,CAAC,CAAC;YAC1F,oCAAoC,GAAG,IAAI,CAAC;QAC9C,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,UAAU,IAAI,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import {\n ImageContentFit,\n ImageContentPosition,\n ImageContentPositionObject,\n ImageContentPositionString,\n ImageProps,\n ImageTransition,\n} from './Image.types';\n\nlet loggedResizeModeDeprecationWarning = false;\nlet loggedRepeatDeprecationWarning = false;\nlet loggedFadeDurationDeprecationWarning = false;\n\n/**\n * If the `contentFit` is not provided, it's resolved from the equivalent `resizeMode` prop\n * that we support to provide compatibility with React Native Image.\n */\nexport function resolveContentFit(\n contentFit?: ImageContentFit,\n resizeMode?: ImageProps['resizeMode']\n): ImageContentFit {\n if (contentFit) {\n return contentFit;\n }\n if (resizeMode) {\n if (!loggedResizeModeDeprecationWarning) {\n console.log('[expo-image]: Prop \"resizeMode\" is deprecated, use \"contentFit\" instead');\n loggedResizeModeDeprecationWarning = true;\n }\n\n switch (resizeMode) {\n case 'contain':\n case 'cover':\n return resizeMode;\n case 'stretch':\n return 'fill';\n case 'center':\n return 'scale-down';\n case 'repeat':\n if (!loggedRepeatDeprecationWarning) {\n console.log('[expo-image]: Resize mode \"repeat\" is no longer supported');\n loggedRepeatDeprecationWarning = true;\n }\n }\n }\n return 'cover';\n}\n\n/**\n * It resolves a stringified form of the `contentPosition` prop to an object,\n * which is the only form supported in the native code.\n */\nexport function resolveContentPosition(\n contentPosition?: ImageContentPosition\n): ImageContentPositionObject {\n if (typeof contentPosition === 'string') {\n const contentPositionStringMappings: Record<\n ImageContentPositionString,\n ImageContentPositionObject\n > = {\n center: { top: '50%', left: '50%' },\n top: { top: 0, left: '50%' },\n right: { top: '50%', right: 0 },\n bottom: { bottom: 0, left: '50%' },\n left: { top: '50%', left: 0 },\n 'top center': { top: 0, left: '50%' },\n 'top right': { top: 0, right: 0 },\n 'top left': { top: 0, left: 0 },\n 'right center': { top: '50%', right: 0 },\n 'right top': { top: 0, right: 0 },\n 'right bottom': { bottom: 0, right: 0 },\n 'bottom center': { bottom: 0, left: '50%' },\n 'bottom right': { bottom: 0, right: 0 },\n 'bottom left': { bottom: 0, left: 0 },\n 'left center': { top: '50%', left: 0 },\n 'left top': { top: 0, left: 0 },\n 'left bottom': { bottom: 0, left: 0 },\n };\n const contentPositionObject = contentPositionStringMappings[contentPosition];\n\n if (!contentPositionObject) {\n console.warn(`[expo-image]: Content position \"${contentPosition}\" is invalid`);\n return contentPositionStringMappings.center;\n }\n return contentPositionObject;\n }\n return contentPosition ?? { top: '50%', left: '50%' };\n}\n\n/**\n * If `transition` or `fadeDuration` is a number, it's resolved to a cross dissolve transition with the given duration.\n * When `fadeDuration` is used, it logs an appropriate deprecation warning.\n */\nexport function resolveTransition(\n transition?: ImageProps['transition'],\n fadeDuration?: ImageProps['fadeDuration']\n): ImageTransition | null {\n if (typeof transition === 'number') {\n return { duration: transition };\n }\n if (!transition && typeof fadeDuration === 'number') {\n if (!loggedFadeDurationDeprecationWarning) {\n console.warn('[expo-image]: Prop \"fadeDuration\" is deprecated, use \"transition\" instead');\n loggedFadeDurationDeprecationWarning = true;\n }\n return { duration: fadeDuration };\n }\n return transition ?? null;\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { ImageTransition } from '../Image.types';
3
+ type Callbacks = {
4
+ onReady?: (() => void) | null;
5
+ onAnimationFinished?: (() => void) | null;
6
+ onMount?: (() => void) | null;
7
+ onError?: (() => void) | null;
8
+ };
9
+ export type AnimationManagerNode = [
10
+ key: string,
11
+ renderFunction: (renderProps: NonNullable<Callbacks>) => (className: string, style: React.CSSProperties) => React.ReactElement
12
+ ];
13
+ export declare function getAnimatorFromTransition(transition: ImageTransition | null | undefined): {
14
+ startingClass: string;
15
+ animateInClass: string;
16
+ animateOutClass: string;
17
+ containerClass: string;
18
+ timingFunction: string;
19
+ animationClass: string;
20
+ duration: number;
21
+ } | {
22
+ startingClass: string;
23
+ animateInClass: string;
24
+ animateOutClass: string;
25
+ containerClass: string;
26
+ timingFunction: "ease-in-out" | "ease-in" | "ease-out" | "linear" | null;
27
+ animationClass: "cross-dissolve" | "flip-from-top" | "flip-from-right" | "flip-from-bottom" | "flip-from-left" | "curl-up" | "curl-down";
28
+ duration: number;
29
+ } | null;
30
+ export default function AnimationManager({ children: renderFunction, initial, transition, recyclingKey, }: {
31
+ children: AnimationManagerNode;
32
+ initial: AnimationManagerNode | null;
33
+ transition: ImageTransition | null | undefined;
34
+ recyclingKey?: string | null | undefined;
35
+ }): React.JSX.Element;
36
+ export {};
37
+ //# sourceMappingURL=AnimationManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimationManager.d.ts","sourceRoot":"","sources":["../../src/web/AnimationManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,KAAK,SAAS,GAAG;IACf,OAAO,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9B,mBAAmB,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM;IACX,cAAc,EAAE,CACd,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,KAChC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,KAAK,CAAC,YAAY;CAC3E,CAAC;AAgDF,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS;;;;;;;;;;;;;;;;SA+BvF;AAUD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EAAE,cAAc,EACxB,OAAO,EACP,UAAU,EACV,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC1C,qBA4GA"}
@@ -0,0 +1,155 @@
1
+ import React from 'react';
2
+ const SUPPORTED_ANIMATIONS = [
3
+ 'cross-dissolve',
4
+ 'flip-from-left',
5
+ 'flip-from-right',
6
+ 'flip-from-top',
7
+ 'flip-from-bottom',
8
+ ];
9
+ function useAnimationManagerNode(node, initialStatus) {
10
+ const newNode = React.useMemo(() => {
11
+ if (!node) {
12
+ return null;
13
+ }
14
+ const [animationKey, renderFunction] = node;
15
+ // key, ReactElement, ref, callbacks
16
+ return {
17
+ animationKey,
18
+ persistedElement: renderFunction,
19
+ status: (initialStatus || 'mounted'),
20
+ };
21
+ }, [node?.[0]]);
22
+ return newNode;
23
+ }
24
+ function validateTimingFunctionForAnimation(animationClass, timingFunction) {
25
+ if (animationClass?.includes('flip')) {
26
+ if (timingFunction?.includes('ease')) {
27
+ return 'ease-in-out';
28
+ }
29
+ return 'linear';
30
+ }
31
+ return timingFunction || null;
32
+ }
33
+ function validateAnimationClass(effect) {
34
+ if (SUPPORTED_ANIMATIONS.includes(effect)) {
35
+ return effect;
36
+ }
37
+ return 'cross-dissolve';
38
+ }
39
+ export function getAnimatorFromTransition(transition) {
40
+ if (!transition?.duration) {
41
+ return null;
42
+ }
43
+ const animationClass = validateAnimationClass(transition.effect);
44
+ if (!animationClass) {
45
+ return {
46
+ startingClass: '',
47
+ animateInClass: '',
48
+ animateOutClass: '',
49
+ containerClass: '',
50
+ timingFunction: 'linear',
51
+ animationClass: '',
52
+ duration: 0,
53
+ };
54
+ }
55
+ const timingFunction = validateTimingFunctionForAnimation(animationClass, transition.timing);
56
+ const timingClass = `image-timing-${timingFunction}`;
57
+ return {
58
+ startingClass: `${animationClass}-start`,
59
+ animateInClass: [animationClass, 'transitioning', `${animationClass}-active`, timingClass].join(' '),
60
+ animateOutClass: [animationClass, `${animationClass}-end`, timingClass].join(' '),
61
+ containerClass: `${animationClass}-container`,
62
+ timingFunction,
63
+ animationClass,
64
+ duration: transition?.duration || 0,
65
+ };
66
+ }
67
+ export default function AnimationManager({ children: renderFunction, initial, transition, recyclingKey, }) {
68
+ const animation = getAnimatorFromTransition(transition);
69
+ const initialNode = useAnimationManagerNode(initial, 'active');
70
+ const [nodes, setNodes] = React.useState(initialNode ? [initialNode] : []);
71
+ const [prevRecyclingKey, setPrevRecyclingKey] = React.useState(recyclingKey ?? '');
72
+ if (prevRecyclingKey !== (recyclingKey ?? '')) {
73
+ setPrevRecyclingKey(recyclingKey ?? '');
74
+ setNodes(initialNode ? [initialNode] : []);
75
+ }
76
+ const removeAllNodesOfKeyExceptShowing = (key) => {
77
+ setNodes((n) => n.filter((node) => (key ? node.animationKey !== key : false) ||
78
+ node.status === 'in' ||
79
+ node.status === 'active'));
80
+ };
81
+ const newNode = useAnimationManagerNode(renderFunction);
82
+ React.useEffect(() => {
83
+ setNodes((n) => {
84
+ if (!newNode) {
85
+ return n;
86
+ }
87
+ const existingNodeIndex = n.findIndex((node) => node.animationKey === newNode.animationKey);
88
+ if (existingNodeIndex >= 0) {
89
+ if (animation) {
90
+ return n.map((n2) => n2.animationKey === newNode.animationKey
91
+ ? { ...newNode, status: 'in' }
92
+ : { ...n2, status: 'out' });
93
+ }
94
+ else {
95
+ return [{ ...newNode, status: 'in' }];
96
+ }
97
+ }
98
+ return [...n, newNode];
99
+ });
100
+ }, [newNode]);
101
+ function wrapNodeWithCallbacks(node) {
102
+ if (renderFunction[0] === node.animationKey) {
103
+ return renderFunction[1]({
104
+ onReady: () => {
105
+ if (animation) {
106
+ setNodes((nodes) => nodes.map((n) => (n === newNode ? { ...n, status: 'in' } : { ...n, status: 'out' })));
107
+ }
108
+ else {
109
+ setNodes([{ ...node, status: 'in' }]);
110
+ }
111
+ },
112
+ onAnimationFinished: () => {
113
+ setNodes([{ ...node, status: 'in' }]);
114
+ },
115
+ onError: () => {
116
+ setNodes((nodes) => nodes.map((n) => (n === node ? { ...n, status: 'errored' } : n)));
117
+ },
118
+ });
119
+ }
120
+ if (initial?.[0] === node.animationKey) {
121
+ return initial[1]({
122
+ onAnimationFinished: () => {
123
+ if (node.status === 'out') {
124
+ removeAllNodesOfKeyExceptShowing(node.animationKey);
125
+ }
126
+ },
127
+ onError: () => {
128
+ setNodes((nodes) => nodes.map((n) => (n === node ? { ...n, status: 'errored' } : n)));
129
+ },
130
+ });
131
+ }
132
+ return node.persistedElement({
133
+ onAnimationFinished: () => {
134
+ removeAllNodesOfKeyExceptShowing(node.animationKey);
135
+ },
136
+ });
137
+ }
138
+ const styles = {
139
+ transitionDuration: `${animation?.duration || 0}ms`,
140
+ transitionTimingFunction: animation?.timingFunction || 'linear',
141
+ };
142
+ const classes = {
143
+ in: animation?.animateInClass,
144
+ out: animation?.animateOutClass,
145
+ mounted: animation?.startingClass,
146
+ };
147
+ return (<>
148
+ {[...nodes]
149
+ .filter((n) => n.status !== 'errored')
150
+ .map((n) => (<div className={animation?.containerClass} key={n.animationKey}>
151
+ {wrapNodeWithCallbacks(n)(classes[n.status], styles)}
152
+ </div>))}
153
+ </>);
154
+ }
155
+ //# sourceMappingURL=AnimationManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimationManager.js","sourceRoot":"","sources":["../../src/web/AnimationManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAkB1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AEF,OAAO,CACL,EACE;MAAA,CAAC,CAAC,GAAG,KAAK,CAAC;aACR,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACV,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAC7D;YAAA,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CACtD;UAAA,EAAE,GAAG,CAAC,CACP,CAAC,CACN;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport { ImageTransition } from '../Image.types';\n\ntype Callbacks = {\n onReady?: (() => void) | null;\n onAnimationFinished?: (() => void) | null;\n onMount?: (() => void) | null;\n onError?: (() => void) | null;\n};\n\nexport type AnimationManagerNode = [\n key: string,\n renderFunction: (\n renderProps: NonNullable<Callbacks>\n ) => (className: string, style: React.CSSProperties) => React.ReactElement,\n];\n\nconst SUPPORTED_ANIMATIONS: ImageTransition['effect'][] = [\n 'cross-dissolve',\n 'flip-from-left',\n 'flip-from-right',\n 'flip-from-top',\n 'flip-from-bottom',\n];\n\ntype NodeStatus = 'mounted' | 'in' | 'active' | 'out' | 'errored';\n\nfunction useAnimationManagerNode(node: AnimationManagerNode | null, initialStatus?: NodeStatus) {\n const newNode = React.useMemo(() => {\n if (!node) {\n return null;\n }\n const [animationKey, renderFunction] = node;\n // key, ReactElement, ref, callbacks\n return {\n animationKey,\n persistedElement: renderFunction,\n status: (initialStatus || 'mounted') as NodeStatus,\n };\n }, [node?.[0]]);\n return newNode;\n}\n\nfunction validateTimingFunctionForAnimation(\n animationClass: ImageTransition['effect'],\n timingFunction: ImageTransition['timing']\n) {\n if (animationClass?.includes('flip')) {\n if (timingFunction?.includes('ease')) {\n return 'ease-in-out';\n }\n return 'linear';\n }\n return timingFunction || null;\n}\n\nfunction validateAnimationClass(effect: ImageTransition['effect']) {\n if (SUPPORTED_ANIMATIONS.includes(effect)) {\n return effect;\n }\n return 'cross-dissolve';\n}\n\nexport function getAnimatorFromTransition(transition: ImageTransition | null | undefined) {\n if (!transition?.duration) {\n return null;\n }\n const animationClass = validateAnimationClass(transition.effect);\n if (!animationClass) {\n return {\n startingClass: '',\n animateInClass: '',\n animateOutClass: '',\n containerClass: '',\n timingFunction: 'linear',\n animationClass: '',\n duration: 0,\n };\n }\n\n const timingFunction = validateTimingFunctionForAnimation(animationClass, transition.timing);\n const timingClass = `image-timing-${timingFunction}`;\n\n return {\n startingClass: `${animationClass}-start`,\n animateInClass: [animationClass, 'transitioning', `${animationClass}-active`, timingClass].join(\n ' '\n ),\n animateOutClass: [animationClass, `${animationClass}-end`, timingClass].join(' '),\n containerClass: `${animationClass}-container`,\n timingFunction,\n animationClass,\n duration: transition?.duration || 0,\n };\n}\n\ntype MountedAnimationNode = {\n animationKey: string;\n persistedElement: (\n renderProps: Callbacks\n ) => (className: string, style: React.CSSProperties) => React.ReactElement;\n status: NodeStatus;\n};\n\nexport default function AnimationManager({\n children: renderFunction,\n initial,\n transition,\n recyclingKey,\n}: {\n children: AnimationManagerNode;\n initial: AnimationManagerNode | null;\n transition: ImageTransition | null | undefined;\n recyclingKey?: string | null | undefined;\n}) {\n const animation = getAnimatorFromTransition(transition);\n\n const initialNode = useAnimationManagerNode(initial, 'active');\n\n const [nodes, setNodes] = React.useState<MountedAnimationNode[]>(\n initialNode ? [initialNode] : []\n );\n\n const [prevRecyclingKey, setPrevRecyclingKey] = React.useState<string>(recyclingKey ?? '');\n if (prevRecyclingKey !== (recyclingKey ?? '')) {\n setPrevRecyclingKey(recyclingKey ?? '');\n setNodes(initialNode ? [initialNode] : []);\n }\n\n const removeAllNodesOfKeyExceptShowing = (key?: string) => {\n setNodes((n) =>\n n.filter(\n (node) =>\n (key ? node.animationKey !== key : false) ||\n node.status === 'in' ||\n node.status === 'active'\n )\n );\n };\n\n const newNode = useAnimationManagerNode(renderFunction);\n\n React.useEffect(() => {\n setNodes((n) => {\n if (!newNode) {\n return n;\n }\n const existingNodeIndex = n.findIndex((node) => node.animationKey === newNode.animationKey);\n if (existingNodeIndex >= 0) {\n if (animation) {\n return n.map((n2) =>\n n2.animationKey === newNode.animationKey\n ? { ...newNode, status: 'in' }\n : { ...n2, status: 'out' }\n );\n } else {\n return [{ ...newNode, status: 'in' }];\n }\n }\n return [...n, newNode];\n });\n }, [newNode]);\n\n function wrapNodeWithCallbacks(node: MountedAnimationNode) {\n if (renderFunction[0] === node.animationKey) {\n return renderFunction[1]({\n onReady: () => {\n if (animation) {\n setNodes((nodes) =>\n nodes.map((n) => (n === newNode ? { ...n, status: 'in' } : { ...n, status: 'out' }))\n );\n } else {\n setNodes([{ ...node, status: 'in' }]);\n }\n },\n onAnimationFinished: () => {\n setNodes([{ ...node, status: 'in' }]);\n },\n onError: () => {\n setNodes((nodes) => nodes.map((n) => (n === node ? { ...n, status: 'errored' } : n)));\n },\n });\n }\n if (initial?.[0] === node.animationKey) {\n return initial[1]({\n onAnimationFinished: () => {\n if (node.status === 'out') {\n removeAllNodesOfKeyExceptShowing(node.animationKey);\n }\n },\n onError: () => {\n setNodes((nodes) => nodes.map((n) => (n === node ? { ...n, status: 'errored' } : n)));\n },\n });\n }\n return node.persistedElement({\n onAnimationFinished: () => {\n removeAllNodesOfKeyExceptShowing(node.animationKey);\n },\n });\n }\n const styles = {\n transitionDuration: `${animation?.duration || 0}ms`,\n transitionTimingFunction: animation?.timingFunction || 'linear',\n };\n const classes = {\n in: animation?.animateInClass,\n out: animation?.animateOutClass,\n mounted: animation?.startingClass,\n };\n\n return (\n <>\n {[...nodes]\n .filter((n) => n.status !== 'errored')\n .map((n) => (\n <div className={animation?.containerClass} key={n.animationKey}>\n {wrapNodeWithCallbacks(n)(classes[n.status], styles)}\n </div>\n ))}\n </>\n );\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export declare function getTintColorStyle(tintColor?: string | null): {
3
+ filter?: undefined;
4
+ } | {
5
+ filter: string;
6
+ };
7
+ type TintColorFilterProps = {
8
+ tintColor?: string | null;
9
+ };
10
+ export default function TintColorFilter({ tintColor }: TintColorFilterProps): React.JSX.Element | null;
11
+ export {};
12
+ //# sourceMappingURL=ColorTintFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorTintFilter.d.ts","sourceRoot":"","sources":["../../src/web/ColorTintFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;;;;EAO1D;AAED,KAAK,oBAAoB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,SAAS,EAAE,EAAE,oBAAoB,4BAc1E"}
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ export function getTintColorStyle(tintColor) {
4
+ if (!tintColor) {
5
+ return {};
6
+ }
7
+ return {
8
+ filter: `url(#expo-image-tint-${tintColor})`,
9
+ };
10
+ }
11
+ export default function TintColorFilter({ tintColor }) {
12
+ if (!tintColor) {
13
+ return null;
14
+ }
15
+ return (<svg style={styles.svg}>
16
+ <defs>
17
+ <filter id={`expo-image-tint-${tintColor}`} x="0" y="0" width="0" height="0">
18
+ <feFlood floodColor={tintColor} floodOpacity="1" result="flood"/>
19
+ <feComposite in="flood" in2="SourceAlpha" operator="in"/>
20
+ </filter>
21
+ </defs>
22
+ </svg>);
23
+ }
24
+ const styles = StyleSheet.create({
25
+ svg: {
26
+ width: 0,
27
+ height: 0,
28
+ },
29
+ });
30
+ //# sourceMappingURL=ColorTintFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorTintFilter.js","sourceRoot":"","sources":["../../src/web/ColorTintFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,UAAU,iBAAiB,CAAC,SAAyB;IACzD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,wBAAwB,SAAS,GAAG;KAC7C,CAAC;AACJ,CAAC;AAID,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,SAAS,EAAwB;IACzE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CACrB;MAAA,CAAC,IAAI,CACH;QAAA,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,mBAAmB,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAC1E;UAAA,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAC/D;UAAA,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,EACzD;QAAA,EAAE,MAAM,CACV;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,GAAG,EAAE;QACH,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACV;CACF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\n\nexport function getTintColorStyle(tintColor?: string | null) {\n if (!tintColor) {\n return {};\n }\n return {\n filter: `url(#expo-image-tint-${tintColor})`,\n };\n}\n\ntype TintColorFilterProps = { tintColor?: string | null };\n\nexport default function TintColorFilter({ tintColor }: TintColorFilterProps) {\n if (!tintColor) {\n return null;\n }\n return (\n <svg style={styles.svg}>\n <defs>\n <filter id={`expo-image-tint-${tintColor}`} x=\"0\" y=\"0\" width=\"0\" height=\"0\">\n <feFlood floodColor={tintColor} floodOpacity=\"1\" result=\"flood\" />\n <feComposite in=\"flood\" in2=\"SourceAlpha\" operator=\"in\" />\n </filter>\n </defs>\n </svg>\n );\n}\n\nconst styles = StyleSheet.create({\n svg: {\n width: 0,\n height: 0,\n },\n});\n"]}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ImageWrapperProps } from './ImageWrapper.types';
3
+ declare const ImageWrapper: React.ForwardRefExoticComponent<ImageWrapperProps & React.RefAttributes<HTMLImageElement>>;
4
+ export default ImageWrapper;
5
+ //# sourceMappingURL=ImageWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageWrapper.d.ts","sourceRoot":"","sources":["../../src/web/ImageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAqBzD,QAAA,MAAM,YAAY,4FA0DjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,44 @@
1
+ import React, { useEffect } from 'react';
2
+ import ColorTintFilter, { getTintColorStyle } from './ColorTintFilter';
3
+ import { getImageWrapperEventHandler } from './getImageWrapperEventHandler';
4
+ import { useHeaders, useImageHashes } from './hooks';
5
+ import { absoluteFilledPosition, getObjectPositionFromContentPositionObject } from './positioning';
6
+ function getFetchPriorityFromImagePriority(priority = 'normal') {
7
+ return priority && ['low', 'high'].includes(priority) ? priority : 'auto';
8
+ }
9
+ function getImgPropsFromSource(source) {
10
+ if (source && 'srcset' in source) {
11
+ return {
12
+ srcSet: source.srcset,
13
+ sizes: source.sizes,
14
+ };
15
+ }
16
+ return {};
17
+ }
18
+ const ImageWrapper = React.forwardRef(({ source, events, contentPosition, hashPlaceholderContentPosition, priority, style, hashPlaceholderStyle, tintColor, className, accessibilityLabel, cachePolicy, ...props }, ref) => {
19
+ useEffect(() => {
20
+ events?.onMount?.forEach((e) => e?.());
21
+ }, []);
22
+ // Thumbhash uri always has to start with 'thumbhash:/'
23
+ const { resolvedSource, isImageHash } = useImageHashes(source);
24
+ const objectPosition = getObjectPositionFromContentPositionObject(isImageHash ? hashPlaceholderContentPosition : contentPosition);
25
+ const sourceWithHeaders = useHeaders(resolvedSource, cachePolicy, events?.onError);
26
+ if (!sourceWithHeaders) {
27
+ return null;
28
+ }
29
+ return (<>
30
+ <ColorTintFilter tintColor={tintColor}/>
31
+ <img ref={ref} alt={accessibilityLabel} className={className} src={sourceWithHeaders?.uri || undefined} key={source?.uri} style={{
32
+ objectPosition,
33
+ ...absoluteFilledPosition,
34
+ ...getTintColorStyle(tintColor),
35
+ ...style,
36
+ ...(isImageHash ? hashPlaceholderStyle : {}),
37
+ }}
38
+ // @ts-ignore
39
+ // eslint-disable-next-line react/no-unknown-property
40
+ fetchpriority={getFetchPriorityFromImagePriority(priority || 'normal')} {...getImageWrapperEventHandler(events, sourceWithHeaders)} {...getImgPropsFromSource(source)} {...props}/>
41
+ </>);
42
+ });
43
+ export default ImageWrapper;
44
+ //# sourceMappingURL=ImageWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageWrapper.js","sourceRoot":"","sources":["../../src/web/ImageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAO,MAAM,OAAO,CAAC;AAE9C,OAAO,eAAe,EAAE,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,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,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,EACE;QAAA,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,EACtC;QAAA,CAAC,GAAG,CACF,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,GAAG,CAAC,CAAC,kBAAkB,CAAC,CACxB,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,GAAG,CAAC,CAAC,iBAAiB,EAAE,GAAG,IAAI,SAAS,CAAC,CACzC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CACjB,KAAK,CAAC,CAAC;YACL,cAAc;YACd,GAAG,sBAAsB;YACzB,GAAG,iBAAiB,CAAC,SAAS,CAAC;YAC/B,GAAG,KAAK;YACR,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7C,CAAC;IACF,aAAa;IACb,qDAAqD;IACrD,aAAa,CAAC,CAAC,iCAAiC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CACvE,IAAI,2BAA2B,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAC3D,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAClC,IAAI,KAAK,CAAC,EAEd;MAAA,GAAG,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import React, { useEffect, Ref } from 'react';\n\nimport ColorTintFilter, { getTintColorStyle } from './ColorTintFilter';\nimport { ImageWrapperProps } from './ImageWrapper.types';\nimport { getImageWrapperEventHandler } from './getImageWrapperEventHandler';\nimport { useHeaders, useImageHashes } from './hooks';\nimport { absoluteFilledPosition, getObjectPositionFromContentPositionObject } from './positioning';\nimport { SrcSetSource } from './useSourceSelection';\nimport { ImageNativeProps, ImageSource } from '../Image.types';\n\nfunction getFetchPriorityFromImagePriority(priority: ImageNativeProps['priority'] = 'normal') {\n return priority && ['low', 'high'].includes(priority) ? priority : 'auto';\n}\n\nfunction getImgPropsFromSource(source: ImageSource | SrcSetSource | null | undefined) {\n if (source && 'srcset' in source) {\n return {\n srcSet: source.srcset,\n sizes: source.sizes,\n };\n }\n return {};\n}\n\nconst ImageWrapper = React.forwardRef(\n (\n {\n source,\n events,\n contentPosition,\n hashPlaceholderContentPosition,\n priority,\n style,\n hashPlaceholderStyle,\n tintColor,\n className,\n accessibilityLabel,\n cachePolicy,\n ...props\n }: ImageWrapperProps,\n ref: Ref<HTMLImageElement>\n ) => {\n useEffect(() => {\n events?.onMount?.forEach((e) => e?.());\n }, []);\n\n // Thumbhash uri always has to start with 'thumbhash:/'\n const { resolvedSource, isImageHash } = useImageHashes(source);\n const objectPosition = getObjectPositionFromContentPositionObject(\n isImageHash ? hashPlaceholderContentPosition : contentPosition\n );\n\n const sourceWithHeaders = useHeaders(resolvedSource, cachePolicy, events?.onError);\n if (!sourceWithHeaders) {\n return null;\n }\n return (\n <>\n <ColorTintFilter tintColor={tintColor} />\n <img\n ref={ref}\n alt={accessibilityLabel}\n className={className}\n src={sourceWithHeaders?.uri || undefined}\n key={source?.uri}\n style={{\n objectPosition,\n ...absoluteFilledPosition,\n ...getTintColorStyle(tintColor),\n ...style,\n ...(isImageHash ? hashPlaceholderStyle : {}),\n }}\n // @ts-ignore\n // eslint-disable-next-line react/no-unknown-property\n fetchpriority={getFetchPriorityFromImagePriority(priority || 'normal')}\n {...getImageWrapperEventHandler(events, sourceWithHeaders)}\n {...getImgPropsFromSource(source)}\n {...props}\n />\n </>\n );\n }\n);\n\nexport default ImageWrapper;\n"]}
@@ -0,0 +1,29 @@
1
+ import { CSSProperties, SyntheticEvent } from 'react';
2
+ import { SrcSetSource } from './useSourceSelection';
3
+ import { ImageContentPositionObject, ImageProps, ImageSource } from '../Image.types';
4
+ export type OnErrorEvent = (({ source }: {
5
+ source: ImageSource | null;
6
+ }) => void) | undefined | null;
7
+ export type OnLoadEvent = ((event: SyntheticEvent<HTMLImageElement, Event>) => void) | undefined | null;
8
+ export type OnTransitionEndEvent = (() => void) | undefined | null;
9
+ export type OnMountEvent = (() => void) | undefined | null;
10
+ export type ImageWrapperEvents = {
11
+ onLoad?: OnLoadEvent[];
12
+ onError?: OnErrorEvent[];
13
+ onTransitionEnd?: OnTransitionEndEvent[];
14
+ onMount?: OnMountEvent[];
15
+ };
16
+ export type ImageWrapperProps = {
17
+ source?: ImageSource | SrcSetSource | null;
18
+ events?: ImageWrapperEvents;
19
+ contentPosition?: ImageContentPositionObject;
20
+ hashPlaceholderContentPosition?: ImageContentPositionObject;
21
+ priority?: string | null;
22
+ style: CSSProperties;
23
+ tintColor?: string | null;
24
+ hashPlaceholderStyle?: CSSProperties;
25
+ className?: string;
26
+ accessibilityLabel?: string;
27
+ cachePolicy?: ImageProps['cachePolicy'];
28
+ };
29
+ //# sourceMappingURL=ImageWrapper.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageWrapper.types.d.ts","sourceRoot":"","sources":["../../src/web/ImageWrapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErF,MAAM,MAAM,YAAY,GACpB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,KAAK,IAAI,CAAC,GACtD,SAAS,GACT,IAAI,CAAC;AACT,MAAM,MAAM,WAAW,GACnB,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC,GAC1D,SAAS,GACT,IAAI,CAAC;AACT,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;AAE3D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,eAAe,CAAC,EAAE,0BAA0B,CAAC;IAC7C,8BAA8B,CAAC,EAAE,0BAA0B,CAAC;IAC5D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC;CACzC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ImageWrapper.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageWrapper.types.js","sourceRoot":"","sources":["../../src/web/ImageWrapper.types.ts"],"names":[],"mappings":"","sourcesContent":["import { CSSProperties, SyntheticEvent } from 'react';\n\nimport { SrcSetSource } from './useSourceSelection';\nimport { ImageContentPositionObject, ImageProps, ImageSource } from '../Image.types';\n\nexport type OnErrorEvent =\n | (({ source }: { source: ImageSource | null }) => void)\n | undefined\n | null;\nexport type OnLoadEvent =\n | ((event: SyntheticEvent<HTMLImageElement, Event>) => void)\n | undefined\n | null;\nexport type OnTransitionEndEvent = (() => void) | undefined | null;\nexport type OnMountEvent = (() => void) | undefined | null;\n\nexport type ImageWrapperEvents = {\n onLoad?: OnLoadEvent[];\n onError?: OnErrorEvent[];\n onTransitionEnd?: OnTransitionEndEvent[];\n onMount?: OnMountEvent[];\n};\n\nexport type ImageWrapperProps = {\n source?: ImageSource | SrcSetSource | null;\n events?: ImageWrapperEvents;\n contentPosition?: ImageContentPositionObject;\n hashPlaceholderContentPosition?: ImageContentPositionObject;\n priority?: string | null;\n style: CSSProperties;\n tintColor?: string | null;\n hashPlaceholderStyle?: CSSProperties;\n className?: string;\n accessibilityLabel?: string;\n cachePolicy?: ImageProps['cachePolicy'];\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import { ImageWrapperEvents } from './ImageWrapper.types';
2
+ import { ImageSource } from '../Image.types';
3
+ export declare function getImageWrapperEventHandler(events: ImageWrapperEvents | undefined, source: ImageSource): {
4
+ onLoad: (event: any) => void;
5
+ onTransitionEnd: () => void | undefined;
6
+ onError: () => void;
7
+ };
8
+ //# sourceMappingURL=getImageWrapperEventHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getImageWrapperEventHandler.d.ts","sourceRoot":"","sources":["../../src/web/getImageWrapperEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,MAAM,EAAE,WAAW;;;;EAsBpB"}
@@ -0,0 +1,25 @@
1
+ import { isBlurhashString } from '../utils/resolveSources';
2
+ export function getImageWrapperEventHandler(events, source) {
3
+ return {
4
+ onLoad: (event) => {
5
+ if (typeof window !== 'undefined') {
6
+ // this ensures the animation will run, since the starting class is applied at least 1 frame before the target class set in the onLoad event callback
7
+ window.requestAnimationFrame(() => {
8
+ events?.onLoad?.forEach((e) => e?.(event));
9
+ });
10
+ }
11
+ else {
12
+ events?.onLoad?.forEach((e) => e?.(event));
13
+ }
14
+ },
15
+ onTransitionEnd: () => events?.onTransitionEnd?.forEach((e) => e?.()),
16
+ onError: () => {
17
+ // A temporary workaround for blurhash blobs throwing opaque errors when used in an img tag.
18
+ if (source?.uri && isBlurhashString(source?.uri)) {
19
+ return;
20
+ }
21
+ events?.onError?.forEach((e) => e?.({ source: source || null }));
22
+ },
23
+ };
24
+ }
25
+ //# sourceMappingURL=getImageWrapperEventHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getImageWrapperEventHandler.js","sourceRoot":"","sources":["../../src/web/getImageWrapperEventHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,UAAU,2BAA2B,CACzC,MAAsC,EACtC,MAAmB;IAEnB,OAAO;QACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;gBAClC,qJAAqJ;gBACrJ,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE;oBAChC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC7C,CAAC,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QACD,eAAe,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QACrE,OAAO,EAAE,GAAG,EAAE;YACZ,4FAA4F;YAC5F,IAAI,MAAM,EAAE,GAAG,IAAI,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;gBACjD,OAAO;YACT,CAAC;YACD,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;QACnE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { ImageWrapperEvents } from './ImageWrapper.types';\nimport { ImageSource } from '../Image.types';\nimport { isBlurhashString } from '../utils/resolveSources';\n\nexport function getImageWrapperEventHandler(\n events: ImageWrapperEvents | undefined,\n source: ImageSource\n) {\n return {\n onLoad: (event) => {\n if (typeof window !== 'undefined') {\n // this ensures the animation will run, since the starting class is applied at least 1 frame before the target class set in the onLoad event callback\n window.requestAnimationFrame(() => {\n events?.onLoad?.forEach((e) => e?.(event));\n });\n } else {\n events?.onLoad?.forEach((e) => e?.(event));\n }\n },\n onTransitionEnd: () => events?.onTransitionEnd?.forEach((e) => e?.()),\n onError: () => {\n // A temporary workaround for blurhash blobs throwing opaque errors when used in an img tag.\n if (source?.uri && isBlurhashString(source?.uri)) {\n return;\n }\n events?.onError?.forEach((e) => e?.({ source: source || null }));\n },\n };\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { OnErrorEvent } from './ImageWrapper.types';
2
+ import { ImageNativeProps, ImageSource } from '../Image.types';
3
+ export declare function useThumbhash(source: ImageSource | null | undefined): {
4
+ uri: string;
5
+ } | null;
6
+ export declare function useImageHashes(source: ImageSource | null | undefined): {
7
+ resolvedSource: ImageSource | {
8
+ uri: string;
9
+ } | null | undefined;
10
+ isImageHash: boolean;
11
+ };
12
+ export declare function useHeaders(source: ImageSource | null | undefined, cachePolicy: ImageNativeProps['cachePolicy'], onError?: OnErrorEvent[]): ImageSource | null | undefined;
13
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/web/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK/D,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS;;SAQlE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS;;;;;EAUpE;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EACtC,WAAW,EAAE,gBAAgB,CAAC,aAAa,CAAC,EAC5C,OAAO,CAAC,EAAE,YAAY,EAAE,GACvB,WAAW,GAAG,IAAI,GAAG,SAAS,CAqChC"}