expo-image 3.0.0-canary-20250331-817737a → 3.0.0-canary-20250402-161f57b
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 +5 -0
- package/android/build.gradle +1 -1
- package/build/Image.types.d.ts +12 -0
- package/build/Image.types.d.ts.map +1 -1
- package/expo-module.config.json +7 -1
- package/ios/ExpoImage.podspec +2 -1
- package/ios/ImageModule.swift +1 -2
- package/ios/ImageSource.swift +3 -0
- package/ios/ImageUtils.swift +6 -18
- package/ios/ImageView.swift +11 -8
- package/ios/WebPCoder.swift +73 -0
- package/package.json +5 -4
- package/src/Image.types.ts +13 -0
- package/ios/ResizedAnimatedCoder.swift +0 -68
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
### 🎉 New features
|
|
10
10
|
|
|
11
11
|
- type-compatibility with react-native 0.77 ([#34027](https://github.com/expo/expo/pull/34027) by [@vonovak](https://github.com/vonovak))
|
|
12
|
+
- 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))
|
|
12
13
|
|
|
13
14
|
### 🐛 Bug fixes
|
|
14
15
|
|
|
@@ -21,6 +22,10 @@
|
|
|
21
22
|
- [Android] Started using expo modules gradle plugin. ([#34176](https://github.com/expo/expo/pull/34176) by [@lukmccall](https://github.com/lukmccall))
|
|
22
23
|
- [iOS] Fix warnings which will become errors in Swift 6. ([#35428](https://github.com/expo/expo/pull/35428) by [@behenate](https://github.com/behenate))
|
|
23
24
|
|
|
25
|
+
### 📚 3rd party library updates
|
|
26
|
+
|
|
27
|
+
- Bumped `SDWebImage` to 5.21.0. ([#35795](https://github.com/expo/expo/pull/35795) by [@kudo](https://github.com/kudo))
|
|
28
|
+
|
|
24
29
|
## 2.0.7 - 2025-03-26
|
|
25
30
|
|
|
26
31
|
### 🐛 Bug fixes
|
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 "
|
|
11
|
+
versionName "3.0.0-canary-20250402-161f57b"
|
|
12
12
|
consumerProguardFiles("proguard-rules.pro")
|
|
13
13
|
|
|
14
14
|
buildConfigField("boolean", "ALLOW_GLIDE_LOGS", project.properties.get("EXPO_ALLOW_GLIDE_LOGS", "false"))
|
package/build/Image.types.d.ts
CHANGED
|
@@ -59,6 +59,18 @@ export type ImageSource = {
|
|
|
59
59
|
* @platform ios
|
|
60
60
|
*/
|
|
61
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;
|
|
62
74
|
};
|
|
63
75
|
/**
|
|
64
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,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;I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AM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,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/expo-module.config.json
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
"modules": ["ImageModule"]
|
|
5
5
|
},
|
|
6
6
|
"android": {
|
|
7
|
-
"modules": ["expo.modules.image.ExpoImageModule"]
|
|
7
|
+
"modules": ["expo.modules.image.ExpoImageModule"],
|
|
8
|
+
"publication": {
|
|
9
|
+
"groupId": "BareExpo",
|
|
10
|
+
"artifactId": "expo.modules.image",
|
|
11
|
+
"version": "3.0.0-canary-20250402-161f57b",
|
|
12
|
+
"repository": "https://maven.pkg.github.com/expo/expo"
|
|
13
|
+
}
|
|
8
14
|
}
|
|
9
15
|
}
|
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/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
|
@@ -103,24 +103,7 @@ func shouldDownscale(image: UIImage, toSize size: CGSize, scale: Double) -> Bool
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
Resizes
|
|
107
|
-
*/
|
|
108
|
-
func resize(animatedImage image: UIImage, toSize size: CGSize, scale: Double) -> UIImage {
|
|
109
|
-
if image.sd_isAnimated,
|
|
110
|
-
let animatedImage = image as? AnimatedImage,
|
|
111
|
-
let actualCoder = animatedImage.animatedCoder {
|
|
112
|
-
let animatedCoder = ResizedAnimatedCoder(actualCoder: actualCoder, size: size, scale: scale)
|
|
113
|
-
if let result = AnimatedImage(animatedCoder: animatedCoder, scale: scale) {
|
|
114
|
-
return result
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// fallback to a resized static image
|
|
119
|
-
return resize(image: image, toSize: size, scale: scale)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
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.
|
|
124
107
|
*/
|
|
125
108
|
func resize(image: UIImage, toSize size: CGSize, scale: Double) -> UIImage {
|
|
126
109
|
let format = UIGraphicsImageRendererFormat()
|
|
@@ -190,6 +173,11 @@ func createSDWebImageContext(forSource source: ImageSource, cachePolicy: ImageCa
|
|
|
190
173
|
// which has better compatibility with the UIImage and fixes issues with the image duration.
|
|
191
174
|
context[.animatedImageClass] = AnimatedImage.self
|
|
192
175
|
|
|
176
|
+
// Passing useAppleWebpCodec into WebPCoder
|
|
177
|
+
context[.imageDecodeOptions] = [
|
|
178
|
+
imageCoderOptionUseAppleWebpCodec: source.useAppleWebpCodec
|
|
179
|
+
]
|
|
180
|
+
|
|
193
181
|
// Assets from the bundler have `scale` prop which needs to be passed to the context,
|
|
194
182
|
// otherwise they would be saved in cache with scale = 1.0 which may result in
|
|
195
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
|
}
|
|
@@ -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": "3.0.0-canary-
|
|
4
|
+
"version": "3.0.0-canary-20250402-161f57b",
|
|
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.5-canary-
|
|
31
|
+
"expo-module-scripts": "4.0.5-canary-20250402-161f57b"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"expo": "53.0.0-canary-
|
|
34
|
+
"expo": "53.0.0-canary-20250402-161f57b",
|
|
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": "161f57bb5f579c84f8fa0337ec596034e21760f6"
|
|
44
45
|
}
|
package/src/Image.types.ts
CHANGED
|
@@ -64,6 +64,19 @@ export type ImageSource = {
|
|
|
64
64
|
* @platform ios
|
|
65
65
|
*/
|
|
66
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;
|
|
67
80
|
};
|
|
68
81
|
|
|
69
82
|
/**
|
|
@@ -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
|
-
}
|