expo-image 2.1.0-canary-20250221-ef26fed → 2.1.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 +41 -2
- package/android/build.gradle +1 -1
- package/build/ExpoImage.web.d.ts.map +1 -1
- package/build/Image.types.d.ts +13 -2
- package/build/Image.types.d.ts.map +1 -1
- package/build/utils.d.ts +1 -1
- package/build/utils.d.ts.map +1 -1
- package/build/web/useSourceSelection.d.ts +2 -2
- package/build/web/useSourceSelection.d.ts.map +1 -1
- package/ios/ExpoImage.podspec +2 -1
- package/ios/ImageCacheType.swift +3 -0
- package/ios/ImageModule.swift +1 -2
- package/ios/ImageSource.swift +3 -0
- package/ios/ImageUtils.swift +9 -18
- package/ios/ImageView.swift +25 -9
- package/ios/WebPCoder.swift +73 -0
- package/package.json +5 -4
- package/src/ExpoImage.web.tsx +2 -1
- package/src/Image.types.ts +14 -2
- package/src/utils.ts +1 -1
- package/src/web/ImageWrapper.tsx +1 -1
- package/src/web/useSourceSelection.ts +2 -2
- package/ios/ResizedAnimatedCoder.swift +0 -68
package/CHANGELOG.md
CHANGED
|
@@ -6,18 +6,57 @@
|
|
|
6
6
|
|
|
7
7
|
### 🎉 New features
|
|
8
8
|
|
|
9
|
+
### 🐛 Bug fixes
|
|
10
|
+
|
|
11
|
+
### 💡 Others
|
|
12
|
+
|
|
13
|
+
## 2.1.0 — 2025-04-04
|
|
14
|
+
|
|
15
|
+
### 🛠 Breaking changes
|
|
16
|
+
|
|
17
|
+
- upgrade RN to 0.78 ([#35050](https://github.com/expo/expo/pull/35050) by [@vonovak](https://github.com/vonovak))
|
|
18
|
+
|
|
19
|
+
### 🎉 New features
|
|
20
|
+
|
|
9
21
|
- type-compatibility with react-native 0.77 ([#34027](https://github.com/expo/expo/pull/34027) by [@vonovak](https://github.com/vonovak))
|
|
22
|
+
- Added `ImageSource.useAppleWebpCodec` on iOS to allow using libwebp codec for better animation performance on some images. ([#35802](https://github.com/expo/expo/pull/35802) by [@kudo](https://github.com/kudo))
|
|
10
23
|
|
|
11
24
|
### 🐛 Bug fixes
|
|
12
25
|
|
|
26
|
+
- Rename `fetchpriority` prop to `fetchPriority` to silence web error. ([#35411](https://github.com/expo/expo/pull/35411) by [@EvanBacon](https://github.com/EvanBacon))
|
|
13
27
|
- Fixed `tintColor="currentColor"` conflicts on web. ([#34604](https://github.com/expo/expo/pull/34604) by [@bradleyayers](https://github.com/bradleyayers))
|
|
14
|
-
- [Android] Add headers to `loadAsync` requests. ([#34767](https://github.com/expo/expo/pull/34767) by [@alanjhughes](https://github.com/alanjhughes))
|
|
15
|
-
- [Android] Fixes a regression in `loadAsync` from [#34767](https://github.com/expo/expo/pull/34767). ([#34965](https://github.com/expo/expo/pull/34965) by [@alanjhughes](https://github.com/alanjhughes))
|
|
16
28
|
|
|
17
29
|
### 💡 Others
|
|
18
30
|
|
|
19
31
|
- Update `ImageProps` type so `children` are omitted. ([#33210](https://github.com/expo/expo/pull/33210) by [@ashaller2017](https://github.com/ashaller2017))
|
|
20
32
|
- [Android] Started using expo modules gradle plugin. ([#34176](https://github.com/expo/expo/pull/34176) by [@lukmccall](https://github.com/lukmccall))
|
|
33
|
+
- [iOS] Fix warnings which will become errors in Swift 6. ([#35428](https://github.com/expo/expo/pull/35428) by [@behenate](https://github.com/behenate))
|
|
34
|
+
|
|
35
|
+
### 📚 3rd party library updates
|
|
36
|
+
|
|
37
|
+
- Bumped `SDWebImage` to 5.21.0. ([#35795](https://github.com/expo/expo/pull/35795) by [@kudo](https://github.com/kudo))
|
|
38
|
+
|
|
39
|
+
## 2.0.7 - 2025-03-26
|
|
40
|
+
|
|
41
|
+
### 🐛 Bug fixes
|
|
42
|
+
|
|
43
|
+
- [iOS] Fixed image be cropped with `contentPosition` on New Architecture mode. ([#35630](https://github.com/expo/expo/pull/35630) by [@kudo](https://github.com/kudo))
|
|
44
|
+
|
|
45
|
+
## 2.0.6 - 2025-02-19
|
|
46
|
+
|
|
47
|
+
### 🐛 Bug fixes
|
|
48
|
+
|
|
49
|
+
- [Android] Fixes a regression in `loadAsync` from [#34767](https://github.com/expo/expo/pull/34767). ([#34965](https://github.com/expo/expo/pull/34965) by [@alanjhughes](https://github.com/alanjhughes)) ([#34767](https://github.com/expo/expo/pull/34767), [#34965](https://github.com/expo/expo/pull/34965) by [@alanjhughes](https://github.com/alanjhughes))
|
|
50
|
+
|
|
51
|
+
## 2.0.5 - 2025-02-10
|
|
52
|
+
|
|
53
|
+
### 🐛 Bug fixes
|
|
54
|
+
|
|
55
|
+
- [Android] Add headers to `loadAsync` requests. ([#34767](https://github.com/expo/expo/pull/34767) by [@alanjhughes](https://github.com/alanjhughes))
|
|
56
|
+
|
|
57
|
+
## 2.0.4 - 2025-01-10
|
|
58
|
+
|
|
59
|
+
_This version does not introduce any user-facing changes._
|
|
21
60
|
|
|
22
61
|
## 2.0.3 - 2024-11-29
|
|
23
62
|
|
package/android/build.gradle
CHANGED
|
@@ -8,7 +8,7 @@ android {
|
|
|
8
8
|
namespace "expo.modules.image"
|
|
9
9
|
defaultConfig {
|
|
10
10
|
versionCode 1
|
|
11
|
-
versionName "2.0
|
|
11
|
+
versionName "2.1.0"
|
|
12
12
|
consumerProguardFiles("proguard-rules.pro")
|
|
13
13
|
|
|
14
14
|
buildConfigField("boolean", "ALLOW_GLIDE_LOGS", project.properties.get("EXPO_ALLOW_GLIDE_LOGS", "false"))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoImage.web.d.ts","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,gBAAgB,EAA6C,MAAM,eAAe,CAAC;AAsDjG,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,MAAM,EACN,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,KAAK,EACL,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ExpoImage.web.d.ts","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,gBAAgB,EAA6C,MAAM,eAAe,CAAC;AAsDjG,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,MAAM,EACN,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,KAAK,EACL,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,gBAAgB,qBAqFlB"}
|
package/build/Image.types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { NativeModule, SharedRef } from 'expo';
|
|
2
|
-
import type { SharedRef as SharedRefType } from 'expo/types';
|
|
1
|
+
import type { NativeModule, SharedRef, SharedRefType } from 'expo';
|
|
3
2
|
import { ImageStyle as RNImageStyle, ViewProps, StyleProp, ViewStyle, View } from 'react-native';
|
|
4
3
|
import ExpoImage from './ExpoImage';
|
|
5
4
|
export type ImageSource = {
|
|
@@ -60,6 +59,18 @@ export type ImageSource = {
|
|
|
60
59
|
* @platform ios
|
|
61
60
|
*/
|
|
62
61
|
isAnimated?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether to use the Apple system WebP codec.
|
|
64
|
+
*
|
|
65
|
+
* When set to `true`, use the Apple system WebP codec from `SDWebImageAWebPCoder`.
|
|
66
|
+
* When set to `false`, use the libwebp codec from `SDWebImageWebPCoder`.
|
|
67
|
+
* The Apple system WebP codec is faster and uses less memory, but it has some issues with animated WebP images.
|
|
68
|
+
* @see https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#awebp-coder
|
|
69
|
+
*
|
|
70
|
+
* @default true
|
|
71
|
+
* @platform ios
|
|
72
|
+
*/
|
|
73
|
+
useAppleWebpCodec?: boolean;
|
|
63
74
|
};
|
|
64
75
|
/**
|
|
65
76
|
* @hidden
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.types.d.ts","sourceRoot":"","sources":["../src/Image.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"Image.types.d.ts","sourceRoot":"","sources":["../src/Image.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACnE,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IA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H,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACjD,CAAC"}
|
package/build/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SharedRefType } from 'expo';
|
|
2
2
|
import { type ImageResizeMode } from 'react-native';
|
|
3
3
|
import { ImageContentFit, ImageContentPosition, ImageContentPositionObject, ImageProps, ImageTransition } from './Image.types';
|
|
4
4
|
/**
|
package/build/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,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,eAAe,GAC3B,eAAe,CAgCjB;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;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,CAEtE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SharedRefType } from 'expo';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ImageSource } from '../Image.types';
|
|
4
4
|
export interface SrcSetSource extends ImageSource {
|
|
@@ -7,5 +7,5 @@ export interface SrcSetSource extends ImageSource {
|
|
|
7
7
|
uri: string;
|
|
8
8
|
type: 'srcset';
|
|
9
9
|
}
|
|
10
|
-
export default function useSourceSelection(sources: ImageSource[] | SharedRefType<'image'> | undefined, responsivePolicy: "live" | "initial" | "static" | undefined, containerRef: React.
|
|
10
|
+
export default function useSourceSelection(sources: ImageSource[] | SharedRefType<'image'> | undefined, responsivePolicy: "live" | "initial" | "static" | undefined, containerRef: React.RefObject<HTMLDivElement | null>, measurementCallback?: ((target: HTMLElement, size: DOMRect) => void) | null): ImageSource | SrcSetSource | SharedRefType<'image'> | null;
|
|
11
11
|
//# sourceMappingURL=useSourceSelection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSourceSelection.d.ts","sourceRoot":"","sources":["../../src/web/useSourceSelection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useSourceSelection.d.ts","sourceRoot":"","sources":["../../src/web/useSourceSelection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAqCzD,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IAEd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,QAAQ,CAAC;CAChB;AAmDD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,OAAO,EAAE,WAAW,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,SAAS,EAC3D,gBAAgB,2CAA2C,EAC3D,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,EACpD,mBAAmB,GAAE,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAW,GAChF,WAAW,GAAG,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,IAAI,CA+B5D"}
|
package/ios/ExpoImage.podspec
CHANGED
|
@@ -19,9 +19,10 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.static_framework = true
|
|
20
20
|
|
|
21
21
|
s.dependency 'ExpoModulesCore'
|
|
22
|
-
s.dependency 'SDWebImage', '~> 5.
|
|
22
|
+
s.dependency 'SDWebImage', '~> 5.21.0'
|
|
23
23
|
s.dependency 'SDWebImageAVIFCoder', '~> 0.11.0'
|
|
24
24
|
s.dependency 'SDWebImageSVGCoder', '~> 1.7.0'
|
|
25
|
+
s.dependency 'SDWebImageWebPCoder', '~> 0.14.6'
|
|
25
26
|
s.dependency 'libavif/libdav1d'
|
|
26
27
|
|
|
27
28
|
# Swift/Objective-C compatibility
|
package/ios/ImageCacheType.swift
CHANGED
|
@@ -16,6 +16,9 @@ enum ImageCacheType: String, Enumerable {
|
|
|
16
16
|
return .disk
|
|
17
17
|
case .memory:
|
|
18
18
|
return .memory
|
|
19
|
+
@unknown default:
|
|
20
|
+
log.error("Unhandled `SDImageCacheType` value: \(sdImageCacheType), returning `none` as fallback. Add the missing case as soon as possible.")
|
|
21
|
+
return .none
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
}
|
package/ios/ImageModule.swift
CHANGED
|
@@ -209,8 +209,7 @@ public final class ImageModule: Module {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
static func registerCoders() {
|
|
212
|
-
|
|
213
|
-
SDImageCodersManager.shared.addCoder(SDImageAWebPCoder.shared)
|
|
212
|
+
SDImageCodersManager.shared.addCoder(WebPCoder.shared)
|
|
214
213
|
SDImageCodersManager.shared.addCoder(SDImageAVIFCoder.shared)
|
|
215
214
|
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
|
216
215
|
SDImageCodersManager.shared.addCoder(SDImageHEICCoder.shared)
|
package/ios/ImageSource.swift
CHANGED
package/ios/ImageUtils.swift
CHANGED
|
@@ -21,6 +21,9 @@ func cacheTypeToString(_ cacheType: SDImageCacheType) -> String {
|
|
|
21
21
|
case .memory, .all:
|
|
22
22
|
// `all` doesn't make much sense, so we treat it as `memory`.
|
|
23
23
|
return "memory"
|
|
24
|
+
@unknown default:
|
|
25
|
+
log.error("Unhandled `SDImageCacheType` value: \(cacheType), returning `none` as fallback. Add the missing case as soon as possible.")
|
|
26
|
+
return "none"
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
|
|
@@ -100,24 +103,7 @@ func shouldDownscale(image: UIImage, toSize size: CGSize, scale: Double) -> Bool
|
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
/**
|
|
103
|
-
Resizes
|
|
104
|
-
*/
|
|
105
|
-
func resize(animatedImage image: UIImage, toSize size: CGSize, scale: Double) -> UIImage {
|
|
106
|
-
if image.sd_isAnimated,
|
|
107
|
-
let animatedImage = image as? AnimatedImage,
|
|
108
|
-
let actualCoder = animatedImage.animatedCoder {
|
|
109
|
-
let animatedCoder = ResizedAnimatedCoder(actualCoder: actualCoder, size: size, scale: scale)
|
|
110
|
-
if let result = AnimatedImage(animatedCoder: animatedCoder, scale: scale) {
|
|
111
|
-
return result
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// fallback to a resized static image
|
|
116
|
-
return resize(image: image, toSize: size, scale: scale)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
Resizes a still image to fit in the given size and scale.
|
|
106
|
+
Resizes a static image to fit in the given size and scale.
|
|
121
107
|
*/
|
|
122
108
|
func resize(image: UIImage, toSize size: CGSize, scale: Double) -> UIImage {
|
|
123
109
|
let format = UIGraphicsImageRendererFormat()
|
|
@@ -187,6 +173,11 @@ func createSDWebImageContext(forSource source: ImageSource, cachePolicy: ImageCa
|
|
|
187
173
|
// which has better compatibility with the UIImage and fixes issues with the image duration.
|
|
188
174
|
context[.animatedImageClass] = AnimatedImage.self
|
|
189
175
|
|
|
176
|
+
// Passing useAppleWebpCodec into WebPCoder
|
|
177
|
+
context[.imageDecodeOptions] = [
|
|
178
|
+
imageCoderOptionUseAppleWebpCodec: source.useAppleWebpCodec
|
|
179
|
+
]
|
|
180
|
+
|
|
190
181
|
// Assets from the bundler have `scale` prop which needs to be passed to the context,
|
|
191
182
|
// otherwise they would be saved in cache with scale = 1.0 which may result in
|
|
192
183
|
// incorrectly rendered images for resize modes that don't scale (`center` and `repeat`).
|
package/ios/ImageView.swift
CHANGED
|
@@ -139,13 +139,10 @@ public final class ImageView: ExpoView {
|
|
|
139
139
|
// It seems that `UIImageView` can't tint some vector graphics. If the `tintColor` prop is specified,
|
|
140
140
|
// we tell the SVG coder to decode to a bitmap instead. This will become useless when we switch to SVGNative coder.
|
|
141
141
|
if imageTintColor != nil {
|
|
142
|
-
context[.imageDecodeOptions]
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"svgImagePreserveAspectRatio": true
|
|
147
|
-
]
|
|
148
|
-
]
|
|
142
|
+
var decodeOptions = context[.imageDecodeOptions] as? [SDImageCoderOption: Any] ?? [:]
|
|
143
|
+
decodeOptions[.decodeThumbnailPixelSize] = sdImageView.bounds.size
|
|
144
|
+
decodeOptions[.decodePreserveAspectRatio] = true
|
|
145
|
+
context[.imageDecodeOptions] = decodeOptions
|
|
149
146
|
}
|
|
150
147
|
|
|
151
148
|
// Some loaders (e.g. PhotoLibraryAssetLoader) may need to know the screen scale.
|
|
@@ -348,9 +345,15 @@ public final class ImageView: ExpoView {
|
|
|
348
345
|
guard let image = image, !bounds.isEmpty else {
|
|
349
346
|
return nil
|
|
350
347
|
}
|
|
348
|
+
sdImageView.animationTransformer = nil
|
|
351
349
|
// Downscale the image only when necessary
|
|
352
350
|
if allowDownscaling && shouldDownscale(image: image, toSize: idealSize, scale: scale) {
|
|
353
|
-
|
|
351
|
+
if image.sd_isAnimated {
|
|
352
|
+
let size = idealSize * scale
|
|
353
|
+
sdImageView.animationTransformer = SDImageResizingTransformer(size: size, scaleMode: .fill)
|
|
354
|
+
return image
|
|
355
|
+
}
|
|
356
|
+
return resize(image: image, toSize: idealSize, scale: scale)
|
|
354
357
|
}
|
|
355
358
|
return image
|
|
356
359
|
}
|
|
@@ -362,7 +365,20 @@ public final class ImageView: ExpoView {
|
|
|
362
365
|
*/
|
|
363
366
|
private func applyContentPosition(contentSize: CGSize, containerSize: CGSize) {
|
|
364
367
|
let offset = contentPosition.offset(contentSize: contentSize, containerSize: containerSize)
|
|
365
|
-
sdImageView.layer.
|
|
368
|
+
if sdImageView.layer.mask != nil {
|
|
369
|
+
// In New Architecture mode, React Native adds a mask layer to image subviews.
|
|
370
|
+
// When moving the layer frame, we must move the mask layer with a compensation value.
|
|
371
|
+
// This prevents the layer from being cropped.
|
|
372
|
+
// See https://github.com/expo/expo/issues/34201
|
|
373
|
+
// and https://github.com/facebook/react-native/blob/c72d4c5ee97/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L1066-L1076
|
|
374
|
+
CATransaction.begin()
|
|
375
|
+
CATransaction.setDisableActions(true)
|
|
376
|
+
sdImageView.layer.frame.origin = offset
|
|
377
|
+
sdImageView.layer.mask?.frame.origin = CGPoint(x: -offset.x, y: -offset.y)
|
|
378
|
+
CATransaction.commit()
|
|
379
|
+
} else {
|
|
380
|
+
sdImageView.layer.frame.origin = offset
|
|
381
|
+
}
|
|
366
382
|
}
|
|
367
383
|
|
|
368
384
|
internal func renderSourceImage(_ image: UIImage?) {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import SDWebImage
|
|
4
|
+
import SDWebImageWebPCoder
|
|
5
|
+
|
|
6
|
+
internal let imageCoderOptionUseAppleWebpCodec = SDImageCoderOption(rawValue: "useAppleWebpCodec")
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
A composite WebP coder that uses either `SDImageAWebPCoder` or `SDImageWebPCoder`
|
|
10
|
+
based on the passed `imageCoderOptionUseAppleWebpCodec` option.
|
|
11
|
+
*/
|
|
12
|
+
internal final class WebPCoder: NSObject, SDAnimatedImageCoder {
|
|
13
|
+
static let shared = WebPCoder()
|
|
14
|
+
|
|
15
|
+
private var useAppleWebpCodec: Bool = true
|
|
16
|
+
private var instantiatedCoder: SDAnimatedImageCoder?
|
|
17
|
+
private var coder: SDAnimatedImageCoder {
|
|
18
|
+
if let instantiatedCoder {
|
|
19
|
+
return instantiatedCoder
|
|
20
|
+
}
|
|
21
|
+
return self.useAppleWebpCodec ? SDImageAWebPCoder.shared : SDImageWebPCoder.shared
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override init() {
|
|
25
|
+
super.init()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// MARK: - SDAnimatedImageCoder implementations
|
|
29
|
+
|
|
30
|
+
convenience init(animatedImageData data: Data?, options: [SDImageCoderOption: Any]? = nil) {
|
|
31
|
+
self.init()
|
|
32
|
+
self.useAppleWebpCodec = options?[imageCoderOptionUseAppleWebpCodec] as? Bool ?? true
|
|
33
|
+
self.instantiatedCoder = self.useAppleWebpCodec
|
|
34
|
+
? SDImageAWebPCoder.init(animatedImageData: data, options: options)
|
|
35
|
+
: SDImageWebPCoder.init(animatedImageData: data, options: options)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func canDecode(from data: Data?) -> Bool {
|
|
39
|
+
return self.coder.canDecode(from: data)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func decodedImage(with data: Data?, options: [SDImageCoderOption: Any]? = nil) -> UIImage? {
|
|
43
|
+
return self.coder.decodedImage(with: data, options: options)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func canEncode(to format: SDImageFormat) -> Bool {
|
|
47
|
+
return self.coder.canEncode(to: format)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
func encodedData(with image: UIImage?, format: SDImageFormat, options: [SDImageCoderOption: Any]? = nil) -> Data? {
|
|
51
|
+
return self.coder.encodedData(with: image, format: format, options: options)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var animatedImageData: Data? {
|
|
55
|
+
return self.coder.animatedImageData
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var animatedImageFrameCount: UInt {
|
|
59
|
+
return self.coder.animatedImageFrameCount
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var animatedImageLoopCount: UInt {
|
|
63
|
+
return self.coder.animatedImageLoopCount
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func animatedImageFrame(at index: UInt) -> UIImage? {
|
|
67
|
+
return self.coder.animatedImageFrame(at: index)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
func animatedImageDuration(at index: UInt) -> TimeInterval {
|
|
71
|
+
return self.coder.animatedImageDuration(at: index)
|
|
72
|
+
}
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-image",
|
|
3
3
|
"title": "Expo Image",
|
|
4
|
-
"version": "2.1.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "A cross-platform, performant image component for React Native and Expo with Web support",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"expo-module-scripts": "4.0
|
|
31
|
+
"expo-module-scripts": "^4.1.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"expo": "
|
|
34
|
+
"expo": "*",
|
|
35
35
|
"react": "*",
|
|
36
36
|
"react-native": "*",
|
|
37
37
|
"react-native-web": "*"
|
|
@@ -40,5 +40,6 @@
|
|
|
40
40
|
"react-native-web": {
|
|
41
41
|
"optional": true
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "68b8233002dc678934ba40cbade7fbc80e71aeff"
|
|
44
45
|
}
|
package/src/ExpoImage.web.tsx
CHANGED
|
@@ -85,7 +85,8 @@ export default function ExpoImage({
|
|
|
85
85
|
const selectedSource = useSourceSelection(
|
|
86
86
|
source,
|
|
87
87
|
responsivePolicy,
|
|
88
|
-
|
|
88
|
+
// @ts-expect-error: vonovak this cast is a workaround
|
|
89
|
+
containerViewRef as React.RefObject<HTMLDivElement | null>,
|
|
89
90
|
isFlipTransition(transition) ? setCssVariablesForFlipTransitions : null
|
|
90
91
|
);
|
|
91
92
|
|
package/src/Image.types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { NativeModule, SharedRef } from 'expo';
|
|
2
|
-
import type { SharedRef as SharedRefType } from 'expo/types';
|
|
1
|
+
import type { NativeModule, SharedRef, SharedRefType } from 'expo';
|
|
3
2
|
import { ImageStyle as RNImageStyle, ViewProps, StyleProp, ViewStyle, View } from 'react-native';
|
|
4
3
|
|
|
5
4
|
import ExpoImage from './ExpoImage';
|
|
@@ -65,6 +64,19 @@ export type ImageSource = {
|
|
|
65
64
|
* @platform ios
|
|
66
65
|
*/
|
|
67
66
|
isAnimated?: boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Whether to use the Apple system WebP codec.
|
|
70
|
+
*
|
|
71
|
+
* When set to `true`, use the Apple system WebP codec from `SDWebImageAWebPCoder`.
|
|
72
|
+
* When set to `false`, use the libwebp codec from `SDWebImageWebPCoder`.
|
|
73
|
+
* The Apple system WebP codec is faster and uses less memory, but it has some issues with animated WebP images.
|
|
74
|
+
* @see https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#awebp-coder
|
|
75
|
+
*
|
|
76
|
+
* @default true
|
|
77
|
+
* @platform ios
|
|
78
|
+
*/
|
|
79
|
+
useAppleWebpCodec?: boolean;
|
|
68
80
|
};
|
|
69
81
|
|
|
70
82
|
/**
|
package/src/utils.ts
CHANGED
package/src/web/ImageWrapper.tsx
CHANGED
|
@@ -74,7 +74,7 @@ const ImageWrapper = React.forwardRef(
|
|
|
74
74
|
}}
|
|
75
75
|
// @ts-ignore
|
|
76
76
|
// eslint-disable-next-line react/no-unknown-property
|
|
77
|
-
|
|
77
|
+
fetchPriority={getFetchPriorityFromImagePriority(priority || 'normal')}
|
|
78
78
|
{...getImageWrapperEventHandler(events, sourceWithHeaders)}
|
|
79
79
|
{...getImgPropsFromSource(source)}
|
|
80
80
|
{...props}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SharedRefType } from 'expo';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import { ImageProps, ImageSource } from '../Image.types';
|
|
@@ -98,7 +98,7 @@ function selectSource(
|
|
|
98
98
|
export default function useSourceSelection(
|
|
99
99
|
sources: ImageSource[] | SharedRefType<'image'> | undefined,
|
|
100
100
|
responsivePolicy: ImageProps['responsivePolicy'] = 'static',
|
|
101
|
-
containerRef: React.
|
|
101
|
+
containerRef: React.RefObject<HTMLDivElement | null>,
|
|
102
102
|
measurementCallback: ((target: HTMLElement, size: DOMRect) => void) | null = null
|
|
103
103
|
): ImageSource | SrcSetSource | SharedRefType<'image'> | null {
|
|
104
104
|
const hasMoreThanOneSource = (Array.isArray(sources) ? sources.length : 0) > 1;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// Copyright 2024-present 650 Industries. All rights reserved.
|
|
2
|
-
|
|
3
|
-
import SDWebImage
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
An animated image resizer that adjusts an already loaded `SDAnimatedImage`.
|
|
7
|
-
This is not a formal SDWebImage coder; it's used solely to leverage the SDWebImage loading pipeline.
|
|
8
|
-
*/
|
|
9
|
-
internal final class ResizedAnimatedCoder: NSObject, SDAnimatedImageCoder {
|
|
10
|
-
private let actualCoder: SDAnimatedImageCoder
|
|
11
|
-
private let size: CGSize
|
|
12
|
-
private let scale: Double
|
|
13
|
-
|
|
14
|
-
// swiftlint:disable:next unavailable_function
|
|
15
|
-
init(animatedImageData data: Data?, options: [SDImageCoderOption: Any]? = nil) {
|
|
16
|
-
fatalError("Unsupported initializer")
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
init(actualCoder: SDAnimatedImageCoder, size: CGSize, scale: Double) {
|
|
20
|
-
self.actualCoder = actualCoder
|
|
21
|
-
self.size = size
|
|
22
|
-
self.scale = scale
|
|
23
|
-
super.init()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// MARK: - SDImageCoder implementations
|
|
27
|
-
|
|
28
|
-
func canDecode(from data: Data?) -> Bool {
|
|
29
|
-
return actualCoder.canDecode(from: data)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
func decodedImage(with data: Data?, options: [SDImageCoderOption: Any]? = nil) -> UIImage? {
|
|
33
|
-
return actualCoder.decodedImage(with: data, options: options)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
func canEncode(to format: SDImageFormat) -> Bool {
|
|
37
|
-
return actualCoder.canEncode(to: format)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
func encodedData(with image: UIImage?, format: SDImageFormat, options: [SDImageCoderOption: Any]? = nil) -> Data? {
|
|
41
|
-
return actualCoder.encodedData(with: image, format: format, options: options)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// MARK: - SDAnimatedImageProvider implementations
|
|
45
|
-
|
|
46
|
-
var animatedImageData: Data? {
|
|
47
|
-
return actualCoder.animatedImageData
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
var animatedImageFrameCount: UInt {
|
|
51
|
-
return actualCoder.animatedImageFrameCount
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var animatedImageLoopCount: UInt {
|
|
55
|
-
return actualCoder.animatedImageLoopCount
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
func animatedImageFrame(at index: UInt) -> UIImage? {
|
|
59
|
-
guard let frame = actualCoder.animatedImageFrame(at: index) else {
|
|
60
|
-
return nil
|
|
61
|
-
}
|
|
62
|
-
return resize(image: frame, toSize: self.size, scale: self.scale)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
func animatedImageDuration(at index: UInt) -> TimeInterval {
|
|
66
|
-
return actualCoder.animatedImageDuration(at: index)
|
|
67
|
-
}
|
|
68
|
-
}
|