expo-image 1.3.2 → 1.4.0
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.
- package/CHANGELOG.md +18 -2
- package/android/build.gradle +2 -1
- package/android/proguard-rules.pro +11 -8
- package/android/src/main/java/expo/modules/image/ExpoImageViewWrapper.kt +7 -4
- package/android/src/main/java/expo/modules/image/ImageViewWrapperTarget.kt +1 -1
- package/android/src/main/java/expo/modules/image/ThumbnailRequestCoordinatorExtension.kt +8 -5
- package/android/src/main/java/expo/modules/image/svg/SVGDrawableTranscoder.kt +2 -1
- package/build/ExpoImage.web.d.ts +1 -1
- package/build/ExpoImage.web.d.ts.map +1 -1
- package/build/ExpoImage.web.js +5 -14
- package/build/ExpoImage.web.js.map +1 -1
- package/build/Image.types.d.ts +21 -6
- package/build/Image.types.d.ts.map +1 -1
- package/build/Image.types.js.map +1 -1
- package/build/web/ColorTintFilter.d.ts +11 -0
- package/build/web/ColorTintFilter.d.ts.map +1 -0
- package/build/web/ColorTintFilter.js +27 -0
- package/build/web/ColorTintFilter.js.map +1 -0
- package/build/web/ImageWrapper.d.ts +3 -20
- package/build/web/ImageWrapper.d.ts.map +1 -1
- package/build/web/ImageWrapper.js +28 -53
- package/build/web/ImageWrapper.js.map +1 -1
- package/build/web/ImageWrapper.types.d.ts +24 -0
- package/build/web/ImageWrapper.types.d.ts.map +1 -0
- package/build/web/ImageWrapper.types.js +2 -0
- package/build/web/ImageWrapper.types.js.map +1 -0
- package/build/web/getImageWrapperEventHandler.d.ts +8 -0
- package/build/web/getImageWrapperEventHandler.d.ts.map +1 -0
- package/build/web/getImageWrapperEventHandler.js +18 -0
- package/build/web/getImageWrapperEventHandler.js.map +1 -0
- package/build/web/{style.d.ts → imageStyles.d.ts} +1 -1
- package/build/web/imageStyles.d.ts.map +1 -0
- package/build/web/{style.js → imageStyles.js} +30 -29
- package/build/web/imageStyles.js.map +1 -0
- package/build/web/positioning.d.ts +11 -0
- package/build/web/positioning.d.ts.map +1 -0
- package/build/web/positioning.js +35 -0
- package/build/web/positioning.js.map +1 -0
- package/build/web/useSourceSelection.d.ts +10 -2
- package/build/web/useSourceSelection.d.ts.map +1 -1
- package/build/web/useSourceSelection.js +37 -5
- package/build/web/useSourceSelection.js.map +1 -1
- package/package.json +2 -2
- package/src/ExpoImage.web.tsx +6 -16
- package/src/Image.types.ts +21 -6
- package/src/web/ColorTintFilter.tsx +36 -0
- package/src/web/ImageWrapper.tsx +48 -95
- package/src/web/ImageWrapper.types.ts +24 -0
- package/src/web/getImageWrapperEventHandler.ts +22 -0
- package/src/web/{style.tsx → imageStyles.tsx} +29 -28
- package/src/web/positioning.ts +48 -0
- package/src/web/useSourceSelection.ts +68 -6
- package/android/src/main/java/expo/modules/image/svg/SVGDrawable.kt +0 -11
- package/android/src/main/java/expo/modules/image/svg/SVGSoftwareLayerSetter.kt +0 -39
- package/build/web/style.d.ts.map +0 -1
- package/build/web/style.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,13 +10,29 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 1.
|
|
13
|
+
## 1.4.0 — 2023-07-28
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- [Web] Add support for `tintColor` prop on web. ([#23434](https://github.com/expo/expo/pull/23434) by [@aleqsio](https://github.com/aleqsio))
|
|
18
|
+
- [Web] Add support for static image responsiveness using `srcset` attributes. ([#22088](https://github.com/expo/expo/pull/22088) by [@aleqsio](https://github.com/aleqsio))
|
|
19
|
+
|
|
20
|
+
### 🐛 Bug fixes
|
|
21
|
+
|
|
22
|
+
- Fixed placeholders aren't always replaced by full-size images on Android. ([#23705](https://github.com/expo/expo/pull/23705) by [@lukmccall](https://github.com/lukmccall))
|
|
23
|
+
- Fixed the image components rendering incorrect assets when the Proguard is enabled on Android. ([#23704](https://github.com/expo/expo/pull/23704) by [@lukmccall](https://github.com/lukmccall))
|
|
24
|
+
|
|
25
|
+
### 💡 Others
|
|
26
|
+
|
|
27
|
+
- [Web] Refactored and split some functions for better readability. ([#23465](https://github.com/expo/expo/pull/23465) by [@aleqsio](https://github.com/aleqsio))
|
|
28
|
+
|
|
29
|
+
## 1.3.2 - 2023-07-12
|
|
14
30
|
|
|
15
31
|
### 🐛 Bug fixes
|
|
16
32
|
|
|
17
33
|
- [iOS] Fixed `tintColor` prop not working for SVGs. ([#23418](https://github.com/expo/expo/pull/23418) by [@tsapeta](https://github.com/tsapeta))
|
|
18
34
|
|
|
19
|
-
## 1.3.1
|
|
35
|
+
## 1.3.1 - 2023-06-29
|
|
20
36
|
|
|
21
37
|
### 🐛 Bug fixes
|
|
22
38
|
|
package/android/build.gradle
CHANGED
|
@@ -50,7 +50,8 @@ android {
|
|
|
50
50
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
51
51
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
52
52
|
versionCode 1
|
|
53
|
-
versionName "1.
|
|
53
|
+
versionName "1.4.0"
|
|
54
|
+
consumerProguardFiles("proguard-rules.pro")
|
|
54
55
|
}
|
|
55
56
|
lintOptions {
|
|
56
57
|
abortOnError false
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
# https://bumptech.github.io/glide/doc/download-setup.html#proguard
|
|
2
2
|
|
|
3
|
-
-keep public class *
|
|
3
|
+
-keep public class * extends com.bumptech.glide.module.LibraryGlideModule
|
|
4
4
|
-keep public class * implements com.bumptech.glide.module.GlideModule
|
|
5
|
-
-keep
|
|
5
|
+
-keep class * extends com.bumptech.glide.module.AppGlideModule {
|
|
6
|
+
<init>(...);
|
|
7
|
+
}
|
|
6
8
|
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
|
|
7
9
|
**[] $VALUES;
|
|
8
10
|
public *;
|
|
9
11
|
}
|
|
12
|
+
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
|
|
13
|
+
*** rewind();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
-keep public class com.bumptech.glide.request.ThumbnailRequestCoordinator {
|
|
17
|
+
*;
|
|
18
|
+
}
|
|
10
19
|
|
|
11
20
|
-dontwarn com.bumptech.glide.load.resource.bitmap.VideoDecoder
|
|
12
21
|
|
|
13
22
|
# https://bumptech.github.io/glide/doc/configuration.html#applications
|
|
14
23
|
|
|
15
|
-
-keep public class * extends com.bumptech.glide.module.AppGlideModule
|
|
16
|
-
-keep public class expo.modules.image.svg.SVGModule
|
|
17
24
|
-keep class com.bumptech.glide.GeneratedAppGlideModuleImpl
|
|
18
25
|
|
|
19
26
|
-keep public class com.bumptech.glide.integration.webp.WebpImage { *; }
|
|
20
27
|
-keep public class com.bumptech.glide.integration.webp.WebpFrame { *; }
|
|
21
28
|
-keep public class com.bumptech.glide.integration.webp.WebpBitmapFactory { *; }
|
|
22
|
-
|
|
23
|
-
-keep public class com.bumptech.glide.requestThumbnailRequestCoordinator {
|
|
24
|
-
*;
|
|
25
|
-
}
|
|
@@ -32,7 +32,6 @@ import expo.modules.image.records.ImageLoadEvent
|
|
|
32
32
|
import expo.modules.image.records.ImageProgressEvent
|
|
33
33
|
import expo.modules.image.records.ImageTransition
|
|
34
34
|
import expo.modules.image.records.SourceMap
|
|
35
|
-
import expo.modules.image.svg.SVGSoftwareLayerSetter
|
|
36
35
|
import expo.modules.kotlin.AppContext
|
|
37
36
|
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
38
37
|
import expo.modules.kotlin.views.ExpoView
|
|
@@ -316,7 +315,12 @@ class ExpoImageViewWrapper(context: Context, appContext: AppContext) : ExpoView(
|
|
|
316
315
|
|
|
317
316
|
firstView
|
|
318
317
|
.recycleView()
|
|
319
|
-
?.
|
|
318
|
+
?.apply {
|
|
319
|
+
// The current target is already bound to the view. We don't want to cancel it in that case.
|
|
320
|
+
if (this != target) {
|
|
321
|
+
clear(requestManager)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
320
324
|
|
|
321
325
|
configureView(firstView, target, resource, isPlaceholder)
|
|
322
326
|
if (transitionDuration > 0) {
|
|
@@ -643,7 +647,6 @@ class ExpoImageViewWrapper(context: Context, appContext: AppContext) : ExpoView(
|
|
|
643
647
|
return cachedRequestManager
|
|
644
648
|
}
|
|
645
649
|
|
|
646
|
-
private fun createNewRequestManager(activity: Activity): RequestManager =
|
|
647
|
-
Glide.with(activity).addDefaultRequestListener(SVGSoftwareLayerSetter())
|
|
650
|
+
private fun createNewRequestManager(activity: Activity): RequestManager = Glide.with(activity)
|
|
648
651
|
}
|
|
649
652
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
package expo.modules.image
|
|
2
2
|
|
|
3
|
+
import android.util.Log
|
|
3
4
|
import com.bumptech.glide.request.Request
|
|
4
5
|
import com.bumptech.glide.request.ThumbnailRequestCoordinator
|
|
5
6
|
|
|
6
7
|
fun ThumbnailRequestCoordinator.getPrivateFullRequest(): Request? {
|
|
7
|
-
return
|
|
8
|
+
return getPrivateField("full")
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
private fun ThumbnailRequestCoordinator.
|
|
11
|
+
private fun <T> ThumbnailRequestCoordinator.getPrivateField(name: String): T? {
|
|
11
12
|
return try {
|
|
12
|
-
val
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
val field = this.javaClass.getDeclaredField(name)
|
|
14
|
+
field.isAccessible = true
|
|
15
|
+
@Suppress("UNCHECKED_CAST")
|
|
16
|
+
field.get(this) as T
|
|
15
17
|
} catch (e: Throwable) {
|
|
18
|
+
Log.e("ExpoImage", "Couldn't receive the `$name` field", e)
|
|
16
19
|
null
|
|
17
20
|
}
|
|
18
21
|
}
|
|
@@ -2,6 +2,7 @@ package expo.modules.image.svg
|
|
|
2
2
|
|
|
3
3
|
import android.graphics.Picture
|
|
4
4
|
import android.graphics.drawable.Drawable
|
|
5
|
+
import android.graphics.drawable.PictureDrawable
|
|
5
6
|
import com.bumptech.glide.load.Options
|
|
6
7
|
import com.bumptech.glide.load.engine.Resource
|
|
7
8
|
import com.bumptech.glide.load.resource.SimpleResource
|
|
@@ -17,7 +18,7 @@ import com.caverock.androidsvg.SVG
|
|
|
17
18
|
class SVGDrawableTranscoder : ResourceTranscoder<SVG?, Drawable> {
|
|
18
19
|
override fun transcode(toTranscode: Resource<SVG?>, options: Options): Resource<Drawable> {
|
|
19
20
|
val picture = toTranscode.get().renderToPicture()
|
|
20
|
-
val drawable: Drawable =
|
|
21
|
+
val drawable: Drawable = PictureDrawable(picture)
|
|
21
22
|
return SimpleResource(drawable)
|
|
22
23
|
}
|
|
23
24
|
}
|
package/build/ExpoImage.web.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export declare const ExpoImageModule: {
|
|
|
4
4
|
clearMemoryCache(): Promise<boolean>;
|
|
5
5
|
clearDiskCache(): Promise<boolean>;
|
|
6
6
|
};
|
|
7
|
-
export default function ExpoImage({ source, placeholder, contentFit, contentPosition, placeholderContentFit, onLoad, transition, onError, responsivePolicy, onLoadEnd, priority, blurRadius, recyclingKey, ...props }: ImageNativeProps): JSX.Element;
|
|
7
|
+
export default function ExpoImage({ source, placeholder, contentFit, contentPosition, placeholderContentFit, onLoad, transition, onError, responsivePolicy, onLoadEnd, priority, blurRadius, recyclingKey, style, ...props }: ImageNativeProps): JSX.Element;
|
|
8
8
|
//# sourceMappingURL=ExpoImage.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoImage.web.d.ts","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoImage.web.d.ts","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,eAAe,CAAC;AAQlF,eAAO,MAAM,eAAe;mBACX,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;wBAQb,QAAQ,OAAO,CAAC;sBAIlB,QAAQ,OAAO,CAAC;CAGzC,CAAC;AA+BF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,eAgFlB"}
|
package/build/ExpoImage.web.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { View } from 'react-native-web';
|
|
2
3
|
import AnimationManager from './web/AnimationManager';
|
|
3
4
|
import ImageWrapper from './web/ImageWrapper';
|
|
4
|
-
import loadStyle from './web/
|
|
5
|
+
import loadStyle from './web/imageStyles';
|
|
5
6
|
import useSourceSelection from './web/useSourceSelection';
|
|
6
7
|
loadStyle();
|
|
7
8
|
export const ExpoImageModule = {
|
|
@@ -40,12 +41,12 @@ function onErrorAdapter(onError) {
|
|
|
40
41
|
});
|
|
41
42
|
};
|
|
42
43
|
}
|
|
44
|
+
// Used for some transitions to mimic native animations
|
|
43
45
|
const setCssVariables = (element, size) => {
|
|
44
46
|
element?.style.setProperty('--expo-image-width', `${size.width}px`);
|
|
45
47
|
element?.style.setProperty('--expo-image-height', `${size.height}px`);
|
|
46
48
|
};
|
|
47
|
-
export default function ExpoImage({ source, placeholder, contentFit, contentPosition, placeholderContentFit, onLoad, transition, onError, responsivePolicy, onLoadEnd, priority, blurRadius, recyclingKey, ...props }) {
|
|
48
|
-
const { aspectRatio, backgroundColor, transform, borderColor, ...style } = props.style ?? {};
|
|
49
|
+
export default function ExpoImage({ source, placeholder, contentFit, contentPosition, placeholderContentFit, onLoad, transition, onError, responsivePolicy, onLoadEnd, priority, blurRadius, recyclingKey, style, ...props }) {
|
|
49
50
|
const imagePlaceholderContentFit = placeholderContentFit || 'scale-down';
|
|
50
51
|
const blurhashStyle = {
|
|
51
52
|
objectFit: placeholderContentFit || contentFit,
|
|
@@ -80,17 +81,7 @@ export default function ExpoImage({ source, placeholder, contentFit, contentPosi
|
|
|
80
81
|
...style,
|
|
81
82
|
}, className: className, priority: priority, contentPosition: selectedSource ? contentPosition : { top: '50%', left: '50%' }, hashPlaceholderContentPosition: contentPosition, hashPlaceholderStyle: blurhashStyle, accessibilityLabel: props.accessibilityLabel })),
|
|
82
83
|
];
|
|
83
|
-
return (React.createElement(
|
|
84
|
-
// @ts-expect-error
|
|
85
|
-
style: {
|
|
86
|
-
aspectRatio: String(aspectRatio),
|
|
87
|
-
backgroundColor: backgroundColor?.toString(),
|
|
88
|
-
transform: transform?.toString(),
|
|
89
|
-
borderColor: borderColor?.toString(),
|
|
90
|
-
position: 'relative',
|
|
91
|
-
overflow: 'hidden',
|
|
92
|
-
...style,
|
|
93
|
-
} },
|
|
84
|
+
return (React.createElement(View, { ref: containerRef, dataSet: { expoimage: true }, style: [{ overflow: 'hidden' }, style] },
|
|
94
85
|
React.createElement(AnimationManager, { transition: transition, recyclingKey: recyclingKey, initial: initialNode }, currentNode)));
|
|
95
86
|
}
|
|
96
87
|
//# sourceMappingURL=ExpoImage.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoImage.web.js","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoImage.web.js","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,OAAO,gBAA0C,MAAM,wBAAwB,CAAC;AAChF,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D,SAAS,EAAE,CAAC;A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QAAQ,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,GAAG,KAAK;aACT,EACD,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAC/E,8BAA8B,EAAE,eAAe,EAC/C,oBAAoB,EAAE,aAAa,EACnC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,GAC5C,CACH;KACN,CAAC;IACF,OAAO,CACL,oBAAC,IAAI,IAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC;QAC3F,oBAAC,gBAAgB,IAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,IACvF,WAAW,CACK,CACd,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { View } from 'react-native-web';\n\nimport { ImageNativeProps, ImageSource, ImageLoadEventData } from './Image.types';\nimport AnimationManager, { AnimationManagerNode } from './web/AnimationManager';\nimport ImageWrapper from './web/ImageWrapper';\nimport loadStyle from './web/imageStyles';\nimport useSourceSelection from './web/useSourceSelection';\n\nloadStyle();\n\nexport const ExpoImageModule = {\n prefetch(urls: string | string[]): void {\n const urlsArray = Array.isArray(urls) ? urls : [urls];\n urlsArray.forEach((url) => {\n const img = new Image();\n img.src = url;\n });\n },\n\n async clearMemoryCache(): Promise<boolean> {\n return false;\n },\n\n async clearDiskCache(): Promise<boolean> {\n return false;\n },\n};\n\nfunction onLoadAdapter(onLoad?: (event: ImageLoadEventData) => void) {\n return (event: React.SyntheticEvent<HTMLImageElement, Event>) => {\n const target = event.target as HTMLImageElement;\n onLoad?.({\n source: {\n url: target.currentSrc,\n width: target.naturalWidth,\n height: target.naturalHeight,\n mediaType: null,\n },\n cacheType: 'none',\n });\n };\n}\n\nfunction onErrorAdapter(onError?: { (event: { error: string }): void }) {\n return ({ source }: { source?: ImageSource | null }) => {\n onError?.({\n error: `Failed to load image from url: ${source?.uri}`,\n });\n };\n}\n\n// Used for some transitions to mimic native animations\nconst setCssVariables = (element: HTMLElement, size: DOMRect) => {\n element?.style.setProperty('--expo-image-width', `${size.width}px`);\n element?.style.setProperty('--expo-image-height', `${size.height}px`);\n};\n\nexport default function ExpoImage({\n source,\n placeholder,\n contentFit,\n contentPosition,\n placeholderContentFit,\n onLoad,\n transition,\n onError,\n responsivePolicy,\n onLoadEnd,\n priority,\n blurRadius,\n recyclingKey,\n style,\n ...props\n}: ImageNativeProps) {\n const imagePlaceholderContentFit = placeholderContentFit || 'scale-down';\n const blurhashStyle = {\n objectFit: placeholderContentFit || contentFit,\n };\n const { containerRef, source: selectedSource } = useSourceSelection(\n source,\n responsivePolicy,\n setCssVariables\n );\n\n const initialNodeAnimationKey =\n (recyclingKey ? `${recyclingKey}-${placeholder?.[0]?.uri}` : placeholder?.[0]?.uri) ?? '';\n\n const initialNode: AnimationManagerNode | null = placeholder?.[0]?.uri\n ? [\n initialNodeAnimationKey,\n ({ onAnimationFinished }) =>\n (className, style) =>\n (\n <ImageWrapper\n {...props}\n source={placeholder?.[0]}\n style={{\n objectFit: imagePlaceholderContentFit,\n ...(blurRadius ? { filter: `blur(${blurRadius}px)` } : {}),\n ...style,\n }}\n className={className}\n events={{\n onTransitionEnd: [onAnimationFinished],\n }}\n contentPosition={{ left: '50%', top: '50%' }}\n hashPlaceholderContentPosition={contentPosition}\n hashPlaceholderStyle={blurhashStyle}\n />\n ),\n ]\n : null;\n\n const currentNodeAnimationKey =\n (recyclingKey\n ? `${recyclingKey}-${selectedSource?.uri ?? placeholder?.[0]?.uri}`\n : selectedSource?.uri ?? placeholder?.[0]?.uri) ?? '';\n\n const currentNode: AnimationManagerNode = [\n currentNodeAnimationKey,\n ({ onAnimationFinished, onReady, onMount, onError: onErrorInner }) =>\n (className, style) =>\n (\n <ImageWrapper\n {...props}\n source={selectedSource || placeholder?.[0]}\n events={{\n onError: [onErrorAdapter(onError), onLoadEnd, onErrorInner],\n onLoad: [onLoadAdapter(onLoad), onLoadEnd, onReady],\n onMount: [onMount],\n onTransitionEnd: [onAnimationFinished],\n }}\n style={{\n objectFit: selectedSource ? contentFit : imagePlaceholderContentFit,\n ...(blurRadius ? { filter: `blur(${blurRadius}px)` } : {}),\n ...style,\n }}\n className={className}\n priority={priority}\n contentPosition={selectedSource ? contentPosition : { top: '50%', left: '50%' }}\n hashPlaceholderContentPosition={contentPosition}\n hashPlaceholderStyle={blurhashStyle}\n accessibilityLabel={props.accessibilityLabel}\n />\n ),\n ];\n return (\n <View ref={containerRef} dataSet={{ expoimage: true }} style={[{ overflow: 'hidden' }, style]}>\n <AnimationManager transition={transition} recyclingKey={recyclingKey} initial={initialNode}>\n {currentNode}\n </AnimationManager>\n </View>\n );\n}\n"]}
|
package/build/Image.types.d.ts
CHANGED
|
@@ -38,6 +38,14 @@ export type ImageSource = {
|
|
|
38
38
|
* If not provided, the `uri` is used also as the cache key.
|
|
39
39
|
*/
|
|
40
40
|
cacheKey?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The max width of the viewport for which this source should be selected.
|
|
43
|
+
* Has no effect if `source` prop is not an array or has only 1 element.
|
|
44
|
+
* Has no effect if `responsivePolicy` is not set to `static`.
|
|
45
|
+
* Ignored if `blurhash` or `thumbhash` is provided (image hashes are never selected if passed in an array).
|
|
46
|
+
* @platform web
|
|
47
|
+
*/
|
|
48
|
+
webMaxViewportWidth?: number;
|
|
41
49
|
};
|
|
42
50
|
/**
|
|
43
51
|
* @hidden
|
|
@@ -113,8 +121,6 @@ export interface ImageProps extends ViewProps {
|
|
|
113
121
|
* The color is applied to every non-transparent pixel, causing the image’s shape to adopt that color.
|
|
114
122
|
* This effect is not applied to placeholders.
|
|
115
123
|
* @default null
|
|
116
|
-
* @platform android
|
|
117
|
-
* @platform ios
|
|
118
124
|
*/
|
|
119
125
|
tintColor?: string | null;
|
|
120
126
|
/**
|
|
@@ -140,12 +146,21 @@ export interface ImageProps extends ViewProps {
|
|
|
140
146
|
*/
|
|
141
147
|
cachePolicy?: 'none' | 'disk' | 'memory' | 'memory-disk' | /** @hidden */ null;
|
|
142
148
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
149
|
+
* Controls the selection of the image source based on the container or viewport size on the web.
|
|
150
|
+
*
|
|
151
|
+
* If set to `'static'`, the browser selects the correct source based on user's viewport width. Works with static rendering.
|
|
152
|
+
* Make sure to set the `'webMaxViewportWidth'` property on each source for best results.
|
|
153
|
+
* For example, if an image occupies 1/3 of the screen width, set the `'webMaxViewportWidth'` to 3x the image width.
|
|
154
|
+
* The source with the largest `'webMaxViewportWidth'` is used even for larger viewports.
|
|
155
|
+
*
|
|
156
|
+
* If set to `'initial'`, the component will select the correct source during mount based on container size. Does not work with static rendering.
|
|
157
|
+
*
|
|
158
|
+
* If set to `'live'`, the component will select the correct source on every resize based on container size. Does not work with static rendering.
|
|
159
|
+
*
|
|
160
|
+
* @default 'static'
|
|
146
161
|
* @platform web
|
|
147
162
|
*/
|
|
148
|
-
responsivePolicy?: 'live' | 'initial';
|
|
163
|
+
responsivePolicy?: 'live' | 'initial' | 'static';
|
|
149
164
|
/**
|
|
150
165
|
* Changing this prop resets the image view content to blank or a placeholder before loading and rendering the final image.
|
|
151
166
|
* This is especially useful for any kinds of recycling views like [FlashList](https://github.com/shopify/flash-list)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.types.d.ts","sourceRoot":"","sources":["../src/Image.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3F,MAAM,MAAM,WAAW,GAAG;IAC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CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAE3D;;;;;;OAMG;IACH,MAAM,CAAC,EACH,gBAAgB,GAChB,eAAe,GACf,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,SAAS,GACT,WAAW,GACX,IAAI,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;IACtC,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
|
package/build/Image.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.types.js","sourceRoot":"","sources":["../src/Image.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ImageStyle as RNImageStyle, ViewProps, StyleProp, ViewStyle } from 'react-native';\n\nexport type ImageSource = {\n /**\n * A string representing the resource identifier for the image,\n * which could be an http address, a local file path, or the name of a static image resource.\n */\n uri?: string;\n /**\n * An object representing the HTTP headers to send along with the request for a remote image.\n * @platform android\n * @platform ios\n */\n headers?: Record<string, string>;\n /**\n * Can be specified if known at build time, in which case the value\n * will be used to set the default `<Image/>` component dimension\n */\n width?: number;\n /**\n * Can be specified if known at build time, in which case the value\n * will be used to set the default `<Image/>` component dimension\n */\n height?: number;\n\n /**\n * The blurhash string to use to generate the image. You can read more about the blurhash\n * on [`woltapp/blurhash`](https://github.com/woltapp/blurhash) repo. Ignored when `uri` is provided.\n * When using the blurhash, you should also provide `width` and `height` (higher values reduce performance),\n * otherwise their default value is `16`.\n */\n blurhash?: string;\n\n /**\n * The thumbhash string to use to generate the image placeholder. You can read more about thumbhash\n * on the [`thumbhash website`](https://evanw.github.io/thumbhash/). Ignored when `uri` is provided.\n */\n thumbhash?: string;\n\n /**\n * The cache key used to query and store this specific image.\n * If not provided, the `uri` is used also as the cache key.\n */\n cacheKey?: string;\n};\n\n/**\n * @hidden\n */\nexport type ImageStyle = RNImageStyle;\n\n/**\n * Determines how the image should be resized to fit its container.\n * @hidden Described in the {@link ImageProps['contentFit']}\n */\nexport type ImageContentFit = 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';\n\n/**\n * Some props are from React Native Image that Expo Image supports (more or less) for easier migration,\n * but all of them are deprecated and might be removed in the future.\n */\nexport interface ImageProps extends ViewProps {\n /** @hidden */\n style?: StyleProp<RNImageStyle>;\n\n /**\n * The image source, either a remote URL, a local file resource or a number that is the result of the `require()` function.\n * When provided as an array of sources, the source that fits best into the container size and is closest to the screen scale\n * will be chosen. In this case it is important to provide `width`, `height` and `scale` properties.\n */\n source?: ImageSource | string | number | ImageSource[] | string[] | null;\n\n /**\n * An image to display while loading the proper image and no image has been displayed yet or the source is unset.\n */\n placeholder?: ImageSource | string | number | ImageSource[] | string[] | null;\n\n /**\n * Determines how the image should be resized to fit its container. This property tells the image to fill the container\n * in a variety of ways; such as \"preserve that aspect ratio\" or \"stretch up and take up as much space as possible\".\n * It mirrors the CSS [`object-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) property.\n *\n * - `'cover'` - The image is sized to maintain its aspect ratio while filling the container box.\n * If the image's aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit.\n *\n * - `'contain'` - The image is scaled down or up to maintain its aspect ratio while fitting within the container box.\n *\n * - `'fill'` - The image is sized to entirely fill the container box. If necessary, the image will be stretched or squished to fit.\n *\n * - `'none'` - The image is not resized and is centered by default.\n * When specified, the exact position can be controlled with [`contentPosition`](#contentposition) prop.\n *\n * - `'scale-down'` - The image is sized as if `none` or `contain` were specified, whichever would result in a smaller concrete image size.\n *\n * @default 'cover'\n */\n contentFit?: ImageContentFit;\n\n /**\n * Determines how the placeholder should be resized to fit its container\n * @hidden Described in the {@link ImageProps['contentFit']}\n * @default 'scale-down'\n */\n placeholderContentFit?: ImageContentFit;\n\n /**\n * It is used together with [`contentFit`](#contentfit) to specify how the image should be positioned with x/y coordinates inside its own container.\n * An equivalent of the CSS [`object-position`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) property.\n * @default 'center'\n */\n contentPosition?: ImageContentPosition;\n\n /**\n * Describes how the image view should transition the contents when switching the image source.\\\n * If provided as a number, it is the duration in milliseconds of the `'cross-dissolve'` effect.\n */\n transition?: ImageTransition | number | null;\n\n /**\n * The radius of the blur in points, `0` means no blur effect.\n * This effect is not applied to placeholders.\n * @default 0\n */\n blurRadius?: number;\n\n /**\n * A color used to tint template images (a bitmap image where only the opacity matters).\n * The color is applied to every non-transparent pixel, causing the image’s shape to adopt that color.\n * This effect is not applied to placeholders.\n * @default null\n * @platform android\n * @platform ios\n */\n tintColor?: string | null;\n\n /**\n * Priorities for completing loads. If more than one load is queued at a time,\n * the load with the higher priority will be started first.\n * Priorities are considered best effort, there are no guarantees about the order in which loads will start or finish.\n * @default 'normal'\n */\n priority?: 'low' | 'normal' | 'high' | null;\n\n /**\n * Determines whether to cache the image and where: on the disk, in the memory or both.\n *\n * - `'none'` - Image is not cached at all.\n *\n * - `'disk'` - Image is queried from the disk cache if exists, otherwise it's downloaded and then stored on the disk.\n *\n * - `'memory'` - Image is cached in memory. Might be useful when you render a high-resolution picture many times.\n * Memory cache may be purged very quickly to prevent high memory usage and the risk of out of memory exceptions.\n *\n * - `'memory-disk'` - Image is cached in memory, but with a fallback to the disk cache.\n *\n * @default 'disk'\n */\n cachePolicy?: 'none' | 'disk' | 'memory' | 'memory-disk' | /** @hidden */ null;\n\n /**\n * Determines whether to choose image source based on container size only on mount or on every resize.\n * Use `initial` to improve performance.\n * @default \"live\"\n * @platform web\n */\n responsivePolicy?: 'live' | 'initial';\n\n /**\n * Changing this prop resets the image view content to blank or a placeholder before loading and rendering the final image.\n * This is especially useful for any kinds of recycling views like [FlashList](https://github.com/shopify/flash-list)\n * to prevent showing the previous source before the new one fully loads.\n * @default null\n * @platform android\n * @platform ios\n */\n recyclingKey?: string | null;\n\n /**\n * Called when the image starts to load.\n */\n onLoadStart?: () => void;\n\n /**\n * Called when the image load completes successfully.\n */\n onLoad?: (event: ImageLoadEventData) => void;\n\n /**\n * Called when the image is loading. Can be called multiple times before the image has finished loading.\n * The event object provides details on how many bytes were loaded so far and what's the expected total size.\n */\n onProgress?: (event: ImageProgressEventData) => void;\n\n /**\n * Called on an image fetching error.\n */\n onError?: (event: ImageErrorEventData) => void;\n\n /**\n * Called when the image load either succeeds or fails.\n */\n onLoadEnd?: () => void;\n\n // DEPRECATED\n\n /**\n * @deprecated Provides compatibility for [`defaultSource` from React Native Image](https://reactnative.dev/docs/image#defaultsource).\n * Use [`placeholder`](#placeholder) prop instead.\n */\n defaultSource?: ImageSource | null;\n\n /**\n * @deprecated Provides compatibility for [`loadingIndicatorSource` from React Native Image](https://reactnative.dev/docs/image#loadingindicatorsource).\n * Use [`placeholder`](#placeholder) prop instead.\n */\n loadingIndicatorSource?: ImageSource | null;\n\n /**\n * @deprecated Provides compatibility for [`resizeMode` from React Native Image](https://reactnative.dev/docs/image#resizemode).\n * Note that `\"repeat\"` option is not supported at all.\n * Use the more powerful [`contentFit`](#contentfit) and [`contentPosition`](#contentposition) props instead.\n */\n resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center';\n\n /**\n * @deprecated Provides compatibility for [`fadeDuration` from React Native Image](https://reactnative.dev/docs/image#fadeduration-android).\n * Instead use [`transition`](#transition) with the provided duration.\n */\n fadeDuration?: number;\n\n /**\n * Whether this View should be focusable with a non-touch input device and receive focus with a hardware keyboard.\n * @default false\n * @platform android\n */\n focusable?: boolean;\n\n /**\n * When true, indicates that the view is an accessibility element.\n * When a view is an accessibility element, it groups its children into a single selectable component.\n *\n * On Android, the `accessible` property will be translated into the native `isScreenReaderFocusable`,\n * so it's only affecting the screen readers behaviour.\n * @default false\n * @platform android\n * @platform ios\n */\n accessible?: boolean;\n\n /**\n * The text that's read by the screen reader when the user interacts with the image. Sets the the `alt` tag on web which is used for web crawlers and link traversal.\n * @default undefined\n */\n accessibilityLabel?: string;\n\n /**\n * The text that's read by the screen reader when the user interacts with the image. Sets the the `alt` tag on web which is used for web crawlers and link traversal. Is an alias for `accessibilityLabel`.\n *\n * @alias accessibilityLabel\n * @default undefined\n */\n alt?: string;\n\n /**\n * Enables Live Text interaction with the image. Check official [Apple documentation](https://developer.apple.com/documentation/visionkit/enabling_live_text_interactions_with_images) for more details.\n * @default false\n * @platform ios 16.0+\n */\n enableLiveTextInteraction?: boolean;\n\n /**\n * Whether the image should be downscaled to match the size of the view container.\n * Turning off this functionality could negatively impact the application's performance, particularly when working with large assets.\n * However, it would result in smoother image resizing, and end-users would always have access to the highest possible asset quality.\n *\n * Downscaling is never used when the `contentFit` prop is set to `none` or `fill`.\n * @default true\n * @platform android\n */\n allowDownscaling?: boolean;\n}\n\n/**\n * It narrows down some props to types expected by the native/web side.\n * @hidden\n */\nexport interface ImageNativeProps extends ImageProps {\n style?: RNImageStyle;\n source?: ImageSource[];\n placeholder?: ImageSource[];\n contentPosition?: ImageContentPositionObject;\n transition?: ImageTransition | null;\n}\n\n/**\n * A value that represents the relative position of a single axis.\n *\n * If `number`, it is a distance in points (logical pixels) from the respective edge.\\\n * If `string`, it must be a percentage value where `'100%'` is the difference in size between the container and the image along the respective axis,\n * or `'center'` which is an alias for `'50%'` that is the default value. You can read more regarding percentages on the MDN docs for\n * [`background-position`](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position#regarding_percentages) that describes this concept well.\n */\nexport type ImageContentPositionValue = number | string | `${number}%` | `${number}` | 'center';\n\n// eslint-disable\n// prettier-ignore\n/**\n * Specifies the position of the image inside its container. One value controls the x-axis and the second value controls the y-axis.\n *\n * Additionally, it supports stringified shorthand form that specifies the edges to which to align the image content:\\\n * `'center'`, `'top'`, `'right'`, `'bottom'`, `'left'`, `'top center'`, `'top right'`, `'top left'`, `'right center'`, `'right top'`,\n * `'right bottom'`, `'bottom center'`, `'bottom right'`, `'bottom left'`, `'left center'`, `'left top'`, `'left bottom'`.\\\n * If only one keyword is provided, then the other dimension is set to `'center'` (`'50%'`), so the image is placed in the middle of the specified edge.\\\n * As an example, `'top right'` is the same as `{ top: 0, right: 0 }` and `'bottom'` is the same as `{ bottom: 0, left: '50%' }`.\n */\nexport type ImageContentPosition =\n /**\n * An object that positions the image relatively to the top-right corner.\n */\n {\n top?: ImageContentPositionValue;\n right?: ImageContentPositionValue;\n } |\n /**\n * An object that positions the image relatively to the top-left corner.\n */\n {\n top?: ImageContentPositionValue;\n left?: ImageContentPositionValue;\n } |\n /**\n * An object that positions the image relatively to the bottom-right corner.\n */\n {\n bottom?: ImageContentPositionValue;\n right?: ImageContentPositionValue;\n } |\n /**\n * An object that positions the image relatively to the bottom-left corner.\n */\n {\n bottom?: ImageContentPositionValue;\n left?: ImageContentPositionValue;\n }\n | ImageContentPositionString;\n// eslint-enable\n\nexport interface ImageBackgroundProps extends Omit<ImageProps, 'style'> {\n /** The style of the image container */\n style?: StyleProp<ViewStyle> | undefined;\n /** Style object for the image */\n imageStyle?: StyleProp<RNImageStyle> | undefined;\n /** @hidden */\n children?: React.ReactNode | undefined;\n}\n\n/**\n * @hidden It's described as part of {@link ImageContentPosition}.\n */\nexport type ImageContentPositionString =\n | 'center'\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | 'top center'\n | 'top right'\n | 'top left'\n | 'right center'\n | 'right top'\n | 'right bottom'\n | 'bottom center'\n | 'bottom right'\n | 'bottom left'\n | 'left center'\n | 'left top'\n | 'left bottom';\n\ntype OnlyObject<T> = T extends object ? T : never;\n\n/**\n * @hidden It's a conditional type that matches only objects of {@link ImageContentPosition}.\n */\nexport type ImageContentPositionObject = OnlyObject<ImageContentPosition>;\n\n/**\n * An object that describes the smooth transition when switching the image source.\n */\nexport type ImageTransition = {\n /**\n * The duration of the transition in milliseconds.\n * @default 0\n */\n duration?: number;\n\n /**\n * Specifies the speed curve of the transition effect and how intermediate values are calculated.\n * @default 'ease-in-out'\n */\n timing?: 'ease-in-out' | 'ease-in' | 'ease-out' | 'linear';\n\n /**\n * An animation effect used for transition.\n * @default 'cross-dissolve'\n *\n * On Android, only `'cross-dissolve'` is supported.\n * On Web, `'curl-up'` and `'curl-down'` effects are not supported.\n */\n effect?:\n | 'cross-dissolve'\n | 'flip-from-top'\n | 'flip-from-right'\n | 'flip-from-bottom'\n | 'flip-from-left'\n | 'curl-up'\n | 'curl-down'\n | null;\n};\n\nexport type ImageLoadEventData = {\n cacheType: 'none' | 'disk' | 'memory';\n source: {\n url: string;\n width: number;\n height: number;\n mediaType: string | null;\n };\n};\n\nexport type ImageProgressEventData = {\n loaded: number;\n total: number;\n};\n\nexport type ImageErrorEventData = {\n error: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Image.types.js","sourceRoot":"","sources":["../src/Image.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ImageStyle as RNImageStyle, ViewProps, StyleProp, ViewStyle } from 'react-native';\n\nexport type ImageSource = {\n /**\n * A string representing the resource identifier for the image,\n * which could be an http address, a local file path, or the name of a static image resource.\n */\n uri?: string;\n /**\n * An object representing the HTTP headers to send along with the request for a remote image.\n * @platform android\n * @platform ios\n */\n headers?: Record<string, string>;\n /**\n * Can be specified if known at build time, in which case the value\n * will be used to set the default `<Image/>` component dimension\n */\n width?: number;\n /**\n * Can be specified if known at build time, in which case the value\n * will be used to set the default `<Image/>` component dimension\n */\n height?: number;\n\n /**\n * The blurhash string to use to generate the image. You can read more about the blurhash\n * on [`woltapp/blurhash`](https://github.com/woltapp/blurhash) repo. Ignored when `uri` is provided.\n * When using the blurhash, you should also provide `width` and `height` (higher values reduce performance),\n * otherwise their default value is `16`.\n */\n blurhash?: string;\n\n /**\n * The thumbhash string to use to generate the image placeholder. You can read more about thumbhash\n * on the [`thumbhash website`](https://evanw.github.io/thumbhash/). Ignored when `uri` is provided.\n */\n thumbhash?: string;\n\n /**\n * The cache key used to query and store this specific image.\n * If not provided, the `uri` is used also as the cache key.\n */\n cacheKey?: string;\n /**\n * The max width of the viewport for which this source should be selected.\n * Has no effect if `source` prop is not an array or has only 1 element.\n * Has no effect if `responsivePolicy` is not set to `static`.\n * Ignored if `blurhash` or `thumbhash` is provided (image hashes are never selected if passed in an array).\n * @platform web\n */\n webMaxViewportWidth?: number;\n};\n\n/**\n * @hidden\n */\nexport type ImageStyle = RNImageStyle;\n\n/**\n * Determines how the image should be resized to fit its container.\n * @hidden Described in the {@link ImageProps['contentFit']}\n */\nexport type ImageContentFit = 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';\n\n/**\n * Some props are from React Native Image that Expo Image supports (more or less) for easier migration,\n * but all of them are deprecated and might be removed in the future.\n */\nexport interface ImageProps extends ViewProps {\n /** @hidden */\n style?: StyleProp<RNImageStyle>;\n\n /**\n * The image source, either a remote URL, a local file resource or a number that is the result of the `require()` function.\n * When provided as an array of sources, the source that fits best into the container size and is closest to the screen scale\n * will be chosen. In this case it is important to provide `width`, `height` and `scale` properties.\n */\n source?: ImageSource | string | number | ImageSource[] | string[] | null;\n\n /**\n * An image to display while loading the proper image and no image has been displayed yet or the source is unset.\n */\n placeholder?: ImageSource | string | number | ImageSource[] | string[] | null;\n\n /**\n * Determines how the image should be resized to fit its container. This property tells the image to fill the container\n * in a variety of ways; such as \"preserve that aspect ratio\" or \"stretch up and take up as much space as possible\".\n * It mirrors the CSS [`object-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) property.\n *\n * - `'cover'` - The image is sized to maintain its aspect ratio while filling the container box.\n * If the image's aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit.\n *\n * - `'contain'` - The image is scaled down or up to maintain its aspect ratio while fitting within the container box.\n *\n * - `'fill'` - The image is sized to entirely fill the container box. If necessary, the image will be stretched or squished to fit.\n *\n * - `'none'` - The image is not resized and is centered by default.\n * When specified, the exact position can be controlled with [`contentPosition`](#contentposition) prop.\n *\n * - `'scale-down'` - The image is sized as if `none` or `contain` were specified, whichever would result in a smaller concrete image size.\n *\n * @default 'cover'\n */\n contentFit?: ImageContentFit;\n\n /**\n * Determines how the placeholder should be resized to fit its container\n * @hidden Described in the {@link ImageProps['contentFit']}\n * @default 'scale-down'\n */\n placeholderContentFit?: ImageContentFit;\n\n /**\n * It is used together with [`contentFit`](#contentfit) to specify how the image should be positioned with x/y coordinates inside its own container.\n * An equivalent of the CSS [`object-position`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) property.\n * @default 'center'\n */\n contentPosition?: ImageContentPosition;\n\n /**\n * Describes how the image view should transition the contents when switching the image source.\\\n * If provided as a number, it is the duration in milliseconds of the `'cross-dissolve'` effect.\n */\n transition?: ImageTransition | number | null;\n\n /**\n * The radius of the blur in points, `0` means no blur effect.\n * This effect is not applied to placeholders.\n * @default 0\n */\n blurRadius?: number;\n\n /**\n * A color used to tint template images (a bitmap image where only the opacity matters).\n * The color is applied to every non-transparent pixel, causing the image’s shape to adopt that color.\n * This effect is not applied to placeholders.\n * @default null\n */\n tintColor?: string | null;\n\n /**\n * Priorities for completing loads. If more than one load is queued at a time,\n * the load with the higher priority will be started first.\n * Priorities are considered best effort, there are no guarantees about the order in which loads will start or finish.\n * @default 'normal'\n */\n priority?: 'low' | 'normal' | 'high' | null;\n\n /**\n * Determines whether to cache the image and where: on the disk, in the memory or both.\n *\n * - `'none'` - Image is not cached at all.\n *\n * - `'disk'` - Image is queried from the disk cache if exists, otherwise it's downloaded and then stored on the disk.\n *\n * - `'memory'` - Image is cached in memory. Might be useful when you render a high-resolution picture many times.\n * Memory cache may be purged very quickly to prevent high memory usage and the risk of out of memory exceptions.\n *\n * - `'memory-disk'` - Image is cached in memory, but with a fallback to the disk cache.\n *\n * @default 'disk'\n */\n cachePolicy?: 'none' | 'disk' | 'memory' | 'memory-disk' | /** @hidden */ null;\n\n /**\n * Controls the selection of the image source based on the container or viewport size on the web.\n *\n * If set to `'static'`, the browser selects the correct source based on user's viewport width. Works with static rendering.\n * Make sure to set the `'webMaxViewportWidth'` property on each source for best results.\n * For example, if an image occupies 1/3 of the screen width, set the `'webMaxViewportWidth'` to 3x the image width.\n * The source with the largest `'webMaxViewportWidth'` is used even for larger viewports.\n *\n * If set to `'initial'`, the component will select the correct source during mount based on container size. Does not work with static rendering.\n *\n * If set to `'live'`, the component will select the correct source on every resize based on container size. Does not work with static rendering.\n *\n * @default 'static'\n * @platform web\n */\n responsivePolicy?: 'live' | 'initial' | 'static';\n\n /**\n * Changing this prop resets the image view content to blank or a placeholder before loading and rendering the final image.\n * This is especially useful for any kinds of recycling views like [FlashList](https://github.com/shopify/flash-list)\n * to prevent showing the previous source before the new one fully loads.\n * @default null\n * @platform android\n * @platform ios\n */\n recyclingKey?: string | null;\n\n /**\n * Called when the image starts to load.\n */\n onLoadStart?: () => void;\n\n /**\n * Called when the image load completes successfully.\n */\n onLoad?: (event: ImageLoadEventData) => void;\n\n /**\n * Called when the image is loading. Can be called multiple times before the image has finished loading.\n * The event object provides details on how many bytes were loaded so far and what's the expected total size.\n */\n onProgress?: (event: ImageProgressEventData) => void;\n\n /**\n * Called on an image fetching error.\n */\n onError?: (event: ImageErrorEventData) => void;\n\n /**\n * Called when the image load either succeeds or fails.\n */\n onLoadEnd?: () => void;\n\n // DEPRECATED\n\n /**\n * @deprecated Provides compatibility for [`defaultSource` from React Native Image](https://reactnative.dev/docs/image#defaultsource).\n * Use [`placeholder`](#placeholder) prop instead.\n */\n defaultSource?: ImageSource | null;\n\n /**\n * @deprecated Provides compatibility for [`loadingIndicatorSource` from React Native Image](https://reactnative.dev/docs/image#loadingindicatorsource).\n * Use [`placeholder`](#placeholder) prop instead.\n */\n loadingIndicatorSource?: ImageSource | null;\n\n /**\n * @deprecated Provides compatibility for [`resizeMode` from React Native Image](https://reactnative.dev/docs/image#resizemode).\n * Note that `\"repeat\"` option is not supported at all.\n * Use the more powerful [`contentFit`](#contentfit) and [`contentPosition`](#contentposition) props instead.\n */\n resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center';\n\n /**\n * @deprecated Provides compatibility for [`fadeDuration` from React Native Image](https://reactnative.dev/docs/image#fadeduration-android).\n * Instead use [`transition`](#transition) with the provided duration.\n */\n fadeDuration?: number;\n\n /**\n * Whether this View should be focusable with a non-touch input device and receive focus with a hardware keyboard.\n * @default false\n * @platform android\n */\n focusable?: boolean;\n\n /**\n * When true, indicates that the view is an accessibility element.\n * When a view is an accessibility element, it groups its children into a single selectable component.\n *\n * On Android, the `accessible` property will be translated into the native `isScreenReaderFocusable`,\n * so it's only affecting the screen readers behaviour.\n * @default false\n * @platform android\n * @platform ios\n */\n accessible?: boolean;\n\n /**\n * The text that's read by the screen reader when the user interacts with the image. Sets the the `alt` tag on web which is used for web crawlers and link traversal.\n * @default undefined\n */\n accessibilityLabel?: string;\n\n /**\n * The text that's read by the screen reader when the user interacts with the image. Sets the the `alt` tag on web which is used for web crawlers and link traversal. Is an alias for `accessibilityLabel`.\n *\n * @alias accessibilityLabel\n * @default undefined\n */\n alt?: string;\n\n /**\n * Enables Live Text interaction with the image. Check official [Apple documentation](https://developer.apple.com/documentation/visionkit/enabling_live_text_interactions_with_images) for more details.\n * @default false\n * @platform ios 16.0+\n */\n enableLiveTextInteraction?: boolean;\n\n /**\n * Whether the image should be downscaled to match the size of the view container.\n * Turning off this functionality could negatively impact the application's performance, particularly when working with large assets.\n * However, it would result in smoother image resizing, and end-users would always have access to the highest possible asset quality.\n *\n * Downscaling is never used when the `contentFit` prop is set to `none` or `fill`.\n * @default true\n * @platform android\n */\n allowDownscaling?: boolean;\n}\n\n/**\n * It narrows down some props to types expected by the native/web side.\n * @hidden\n */\nexport interface ImageNativeProps extends ImageProps {\n style?: RNImageStyle;\n source?: ImageSource[];\n placeholder?: ImageSource[];\n contentPosition?: ImageContentPositionObject;\n transition?: ImageTransition | null;\n}\n\n/**\n * A value that represents the relative position of a single axis.\n *\n * If `number`, it is a distance in points (logical pixels) from the respective edge.\\\n * If `string`, it must be a percentage value where `'100%'` is the difference in size between the container and the image along the respective axis,\n * or `'center'` which is an alias for `'50%'` that is the default value. You can read more regarding percentages on the MDN docs for\n * [`background-position`](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position#regarding_percentages) that describes this concept well.\n */\nexport type ImageContentPositionValue = number | string | `${number}%` | `${number}` | 'center';\n\n// eslint-disable\n// prettier-ignore\n/**\n * Specifies the position of the image inside its container. One value controls the x-axis and the second value controls the y-axis.\n *\n * Additionally, it supports stringified shorthand form that specifies the edges to which to align the image content:\\\n * `'center'`, `'top'`, `'right'`, `'bottom'`, `'left'`, `'top center'`, `'top right'`, `'top left'`, `'right center'`, `'right top'`,\n * `'right bottom'`, `'bottom center'`, `'bottom right'`, `'bottom left'`, `'left center'`, `'left top'`, `'left bottom'`.\\\n * If only one keyword is provided, then the other dimension is set to `'center'` (`'50%'`), so the image is placed in the middle of the specified edge.\\\n * As an example, `'top right'` is the same as `{ top: 0, right: 0 }` and `'bottom'` is the same as `{ bottom: 0, left: '50%' }`.\n */\nexport type ImageContentPosition =\n /**\n * An object that positions the image relatively to the top-right corner.\n */\n {\n top?: ImageContentPositionValue;\n right?: ImageContentPositionValue;\n } |\n /**\n * An object that positions the image relatively to the top-left corner.\n */\n {\n top?: ImageContentPositionValue;\n left?: ImageContentPositionValue;\n } |\n /**\n * An object that positions the image relatively to the bottom-right corner.\n */\n {\n bottom?: ImageContentPositionValue;\n right?: ImageContentPositionValue;\n } |\n /**\n * An object that positions the image relatively to the bottom-left corner.\n */\n {\n bottom?: ImageContentPositionValue;\n left?: ImageContentPositionValue;\n }\n | ImageContentPositionString;\n// eslint-enable\n\nexport interface ImageBackgroundProps extends Omit<ImageProps, 'style'> {\n /** The style of the image container */\n style?: StyleProp<ViewStyle> | undefined;\n /** Style object for the image */\n imageStyle?: StyleProp<RNImageStyle> | undefined;\n /** @hidden */\n children?: React.ReactNode | undefined;\n}\n\n/**\n * @hidden It's described as part of {@link ImageContentPosition}.\n */\nexport type ImageContentPositionString =\n | 'center'\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | 'top center'\n | 'top right'\n | 'top left'\n | 'right center'\n | 'right top'\n | 'right bottom'\n | 'bottom center'\n | 'bottom right'\n | 'bottom left'\n | 'left center'\n | 'left top'\n | 'left bottom';\n\ntype OnlyObject<T> = T extends object ? T : never;\n\n/**\n * @hidden It's a conditional type that matches only objects of {@link ImageContentPosition}.\n */\nexport type ImageContentPositionObject = OnlyObject<ImageContentPosition>;\n\n/**\n * An object that describes the smooth transition when switching the image source.\n */\nexport type ImageTransition = {\n /**\n * The duration of the transition in milliseconds.\n * @default 0\n */\n duration?: number;\n\n /**\n * Specifies the speed curve of the transition effect and how intermediate values are calculated.\n * @default 'ease-in-out'\n */\n timing?: 'ease-in-out' | 'ease-in' | 'ease-out' | 'linear';\n\n /**\n * An animation effect used for transition.\n * @default 'cross-dissolve'\n *\n * On Android, only `'cross-dissolve'` is supported.\n * On Web, `'curl-up'` and `'curl-down'` effects are not supported.\n */\n effect?:\n | 'cross-dissolve'\n | 'flip-from-top'\n | 'flip-from-right'\n | 'flip-from-bottom'\n | 'flip-from-left'\n | 'curl-up'\n | 'curl-down'\n | null;\n};\n\nexport type ImageLoadEventData = {\n cacheType: 'none' | 'disk' | 'memory';\n source: {\n url: string;\n width: number;\n height: number;\n mediaType: string | null;\n };\n};\n\nexport type ImageProgressEventData = {\n loaded: number;\n total: number;\n};\n\nexport type ImageErrorEventData = {\n error: string;\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function getTintColorStyle(tintColor?: string | null): {
|
|
2
|
+
filter?: undefined;
|
|
3
|
+
} | {
|
|
4
|
+
filter: string;
|
|
5
|
+
};
|
|
6
|
+
type TintColorFilterProps = {
|
|
7
|
+
tintColor?: string | null;
|
|
8
|
+
};
|
|
9
|
+
export default function TintColorFilter({ tintColor }: TintColorFilterProps): JSX.Element | null;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=ColorTintFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorTintFilter.d.ts","sourceRoot":"","sources":["../../src/web/ColorTintFilter.tsx"],"names":[],"mappings":"AAGA,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,sBAc1E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 (React.createElement("svg", { style: styles.svg },
|
|
16
|
+
React.createElement("defs", null,
|
|
17
|
+
React.createElement("filter", { id: `expo-image-tint-${tintColor}`, x: "0", y: "0", width: "0", height: "0" },
|
|
18
|
+
React.createElement("feFlood", { floodColor: tintColor, floodOpacity: "1", result: "flood" }),
|
|
19
|
+
React.createElement("feComposite", { in: "flood", in2: "SourceAlpha", operator: "in" })))));
|
|
20
|
+
}
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
svg: {
|
|
23
|
+
width: 0,
|
|
24
|
+
height: 0,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
//# 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;QACd,OAAO,EAAE,CAAC;KACX;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;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CACL,6BAAK,KAAK,EAAE,MAAM,CAAC,GAAG;QACpB;YACE,gCAAQ,EAAE,EAAE,mBAAmB,SAAS,EAAE,EAAE,CAAC,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,EAAC,KAAK,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG;gBAC1E,iCAAS,UAAU,EAAE,SAAS,EAAE,YAAY,EAAC,GAAG,EAAC,MAAM,EAAC,OAAO,GAAG;gBAClE,qCAAa,EAAE,EAAC,OAAO,EAAC,GAAG,EAAC,aAAa,EAAC,QAAQ,EAAC,IAAI,GAAG,CACnD,CACJ,CACH,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"]}
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
declare const ImageWrapper: React.ForwardRefExoticComponent<
|
|
4
|
-
source?: ImageSource | null | undefined;
|
|
5
|
-
events?: {
|
|
6
|
-
onLoad?: (((event: SyntheticEvent<HTMLImageElement, Event>) => void) | null | undefined)[] | undefined;
|
|
7
|
-
onError?: ((({ source }: {
|
|
8
|
-
source: ImageSource | null;
|
|
9
|
-
}) => void) | null | undefined)[] | undefined;
|
|
10
|
-
onTransitionEnd?: ((() => void) | null | undefined)[] | undefined;
|
|
11
|
-
onMount?: ((() => void) | null | undefined)[] | undefined;
|
|
12
|
-
} | undefined;
|
|
13
|
-
contentPosition?: ImageContentPositionObject | undefined;
|
|
14
|
-
hashPlaceholderContentPosition?: ImageContentPositionObject | undefined;
|
|
15
|
-
priority?: string | null | undefined;
|
|
16
|
-
style: CSSProperties;
|
|
17
|
-
hashPlaceholderStyle?: React.CSSProperties | undefined;
|
|
18
|
-
className?: string | undefined;
|
|
19
|
-
accessibilityLabel?: string | undefined;
|
|
20
|
-
} & React.RefAttributes<HTMLImageElement>>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ImageWrapperProps } from './ImageWrapper.types';
|
|
3
|
+
declare const ImageWrapper: React.ForwardRefExoticComponent<ImageWrapperProps & React.RefAttributes<HTMLImageElement>>;
|
|
21
4
|
export default ImageWrapper;
|
|
22
5
|
//# sourceMappingURL=ImageWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageWrapper.d.ts","sourceRoot":"","sources":["../../src/web/ImageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ImageWrapper.d.ts","sourceRoot":"","sources":["../../src/web/ImageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkC,MAAM,OAAO,CAAC;AAOvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAmBzD,QAAA,MAAM,YAAY,4FAqEjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -2,37 +2,22 @@ import React, { useEffect, useMemo } from 'react';
|
|
|
2
2
|
import { useBlurhash } from '../utils/blurhash/useBlurhash';
|
|
3
3
|
import { isBlurhashString, isThumbhashString } from '../utils/resolveSources';
|
|
4
4
|
import { thumbHashStringToDataURL } from '../utils/thumbhash/thumbhash';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return trimmedValue;
|
|
9
|
-
}
|
|
10
|
-
return `${trimmedValue}px`;
|
|
11
|
-
}
|
|
12
|
-
function getObjectPositionFromContentPositionObject(contentPosition) {
|
|
13
|
-
const resolvedPosition = { ...contentPosition };
|
|
14
|
-
if (!resolvedPosition) {
|
|
15
|
-
return '50% 50%';
|
|
16
|
-
}
|
|
17
|
-
if (resolvedPosition.top == null && resolvedPosition.bottom == null) {
|
|
18
|
-
resolvedPosition.top = '50%';
|
|
19
|
-
}
|
|
20
|
-
if (resolvedPosition.left == null && resolvedPosition.right == null) {
|
|
21
|
-
resolvedPosition.left = '50%';
|
|
22
|
-
}
|
|
23
|
-
return (['top', 'bottom', 'left', 'right']
|
|
24
|
-
.map((key) => {
|
|
25
|
-
if (key in resolvedPosition) {
|
|
26
|
-
return `${key} ${ensureUnit(resolvedPosition[key])}`;
|
|
27
|
-
}
|
|
28
|
-
return '';
|
|
29
|
-
})
|
|
30
|
-
.join(' ') || '50% 50%');
|
|
31
|
-
}
|
|
5
|
+
import ColorTintFilter, { getTintColorStyle } from './ColorTintFilter';
|
|
6
|
+
import { getImageWrapperEventHandler } from './getImageWrapperEventHandler';
|
|
7
|
+
import { absoluteFilledPosition, getObjectPositionFromContentPositionObject } from './positioning';
|
|
32
8
|
function getFetchPriorityFromImagePriority(priority = 'normal') {
|
|
33
9
|
return priority && ['low', 'high'].includes(priority) ? priority : 'auto';
|
|
34
10
|
}
|
|
35
|
-
|
|
11
|
+
function getImgPropsFromSource(source) {
|
|
12
|
+
if (source && 'srcset' in source) {
|
|
13
|
+
return {
|
|
14
|
+
srcSet: source.srcset,
|
|
15
|
+
sizes: source.sizes,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
const ImageWrapper = React.forwardRef(({ source, events, contentPosition, hashPlaceholderContentPosition, priority, style, hashPlaceholderStyle, tintColor, className, accessibilityLabel, ...props }, ref) => {
|
|
36
21
|
useEffect(() => {
|
|
37
22
|
events?.onMount?.forEach((e) => e?.());
|
|
38
23
|
}, []);
|
|
@@ -43,33 +28,23 @@ const ImageWrapper = React.forwardRef(({ source, events, contentPosition, hashPl
|
|
|
43
28
|
const thumbhash = source?.uri?.replace(/thumbhash:\//, '');
|
|
44
29
|
const thumbhashUri = useMemo(() => (isThumbhash ? thumbHashStringToDataURL(thumbhash ?? '') : null), [thumbhash]);
|
|
45
30
|
const blurhashUri = useBlurhash(isBlurhash ? source?.uri : null, source?.width, source?.height);
|
|
31
|
+
if (!source) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
46
34
|
const objectPosition = getObjectPositionFromContentPositionObject(isHash ? hashPlaceholderContentPosition : contentPosition);
|
|
47
35
|
const uri = isHash ? blurhashUri ?? thumbhashUri : source?.uri;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
// eslint-disable-next-line react/no-unknown-property
|
|
62
|
-
fetchpriority: getFetchPriorityFromImagePriority(priority || 'normal'), onLoad: (event) => {
|
|
63
|
-
if (typeof window !== 'undefined') {
|
|
64
|
-
// 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
|
|
65
|
-
window.requestAnimationFrame(() => {
|
|
66
|
-
events?.onLoad?.forEach((e) => e?.(event));
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
events?.onLoad?.forEach((e) => e?.(event));
|
|
71
|
-
}
|
|
72
|
-
}, onTransitionEnd: () => events?.onTransitionEnd?.forEach((e) => e?.()), onError: () => events?.onError?.forEach((e) => e?.({ source: source || null })) }));
|
|
36
|
+
return (React.createElement(React.Fragment, null,
|
|
37
|
+
React.createElement(ColorTintFilter, { tintColor: tintColor }),
|
|
38
|
+
React.createElement("img", { ref: ref, alt: accessibilityLabel, className: className, src: uri || undefined, key: source?.uri, style: {
|
|
39
|
+
objectPosition,
|
|
40
|
+
...absoluteFilledPosition,
|
|
41
|
+
...getTintColorStyle(tintColor),
|
|
42
|
+
...(isHash ? hashPlaceholderStyle : {}),
|
|
43
|
+
...style,
|
|
44
|
+
},
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
47
|
+
fetchpriority: getFetchPriorityFromImagePriority(priority || 'normal'), ...getImageWrapperEventHandler(events, source), ...getImgPropsFromSource(source), ...props })));
|
|
73
48
|
});
|
|
74
49
|
export default ImageWrapper;
|
|
75
50
|
//# sourceMappingURL=ImageWrapper.js.map
|