expo-image 1.3.1 → 1.3.3

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 CHANGED
@@ -10,6 +10,21 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 1.3.3 — 2023-09-15
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - 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))
18
+ - Fix 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))
19
+ - Fixed gif and awebp memory leak on Android. ([#24259](https://github.com/expo/expo/pull/24259) by [@jingpeng](https://github.com/jingpeng))
20
+ - Suppress "Operation cancelled by user during sending the request" error when the load request is canceled (interrupted) by a new one. ([#24279](https://github.com/expo/expo/pull/24279) by [@tsapeta](https://github.com/tsapeta))
21
+
22
+ ## 1.3.2 — 2023-07-12
23
+
24
+ ### 🐛 Bug fixes
25
+
26
+ - [iOS] Fixed `tintColor` prop not working for SVGs. ([#23418](https://github.com/expo/expo/pull/23418) by [@tsapeta](https://github.com/tsapeta))
27
+
13
28
  ## 1.3.1 — 2023-06-29
14
29
 
15
30
  ### 🐛 Bug fixes
@@ -50,7 +50,8 @@ android {
50
50
  minSdkVersion safeExtGet("minSdkVersion", 21)
51
51
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
52
52
  versionCode 1
53
- versionName "1.3.1"
53
+ versionName "1.3.3"
54
+ consumerProguardFiles("proguard-rules.pro")
54
55
  }
55
56
  lintOptions {
56
57
  abortOnError false
@@ -96,7 +97,7 @@ dependencies {
96
97
  kapt "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
97
98
  api 'com.caverock:androidsvg-aar:1.4'
98
99
 
99
- implementation "com.github.penfeizhou.android.animation:glide-plugin:2.24.0"
100
+ implementation "com.github.penfeizhou.android.animation:glide-plugin:2.28.0"
100
101
  implementation "com.github.bumptech.glide:avif-integration:${GLIDE_VERSION}"
101
102
 
102
103
  api 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
@@ -1,25 +1,28 @@
1
1
  # https://bumptech.github.io/glide/doc/download-setup.html#proguard
2
2
 
3
- -keep public class * implements com.bumptech.glide.module.LibraryGlideModule
3
+ -keep public class * extends com.bumptech.glide.module.LibraryGlideModule
4
4
  -keep public class * implements com.bumptech.glide.module.GlideModule
5
- -keep public class * extends com.bumptech.glide.module.AppGlideModule
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
- }
@@ -316,7 +316,12 @@ class ExpoImageViewWrapper(context: Context, appContext: AppContext) : ExpoView(
316
316
 
317
317
  firstView
318
318
  .recycleView()
319
- ?.clear(requestManager)
319
+ ?.apply {
320
+ // The current target is already bound to the view. We don't want to cancel it in that case.
321
+ if (this != target) {
322
+ clear(requestManager)
323
+ }
324
+ }
320
325
 
321
326
  configureView(firstView, target, resource, isPlaceholder)
322
327
  if (transitionDuration > 0) {
@@ -73,7 +73,7 @@ class ImageViewWrapperTarget(
73
73
  val isPlaceholder = if (request is ThumbnailRequestCoordinator) {
74
74
  (request as? ThumbnailRequestCoordinator)
75
75
  ?.getPrivateFullRequest()
76
- ?.isComplete != true
76
+ ?.isComplete == false
77
77
  } else {
78
78
  false
79
79
  }
@@ -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 getPrivateRequest("full")
8
+ return getPrivateFiled("full")
8
9
  }
9
10
 
10
- private fun ThumbnailRequestCoordinator.getPrivateRequest(name: String): Request? {
11
+ private fun <T> ThumbnailRequestCoordinator.getPrivateFiled(name: String): T? {
11
12
  return try {
12
13
  val filed = this.javaClass.getDeclaredField(name)
13
14
  filed.isAccessible = true
14
- filed.get(this) as Request
15
+ @Suppress("UNCHECKED_CAST")
16
+ filed.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
  }
@@ -54,7 +54,7 @@ public final class ImageModule: Module {
54
54
  }
55
55
 
56
56
  Prop("tintColor") { (view, tintColor: UIColor?) in
57
- view.imageTintColor = tintColor ?? .clear
57
+ view.imageTintColor = tintColor
58
58
  }
59
59
 
60
60
  Prop("priority") { (view, priority: ImagePriority?) in
@@ -37,7 +37,7 @@ public final class ImageView: ExpoView {
37
37
 
38
38
  var blurRadius: CGFloat = 0.0
39
39
 
40
- var imageTintColor: UIColor = .clear
40
+ var imageTintColor: UIColor?
41
41
 
42
42
  var cachePolicy: ImageCachePolicy = .disk
43
43
 
@@ -128,6 +128,18 @@ public final class ImageView: ExpoView {
128
128
  // incorrectly rendered images for resize modes that don't scale (`center` and `repeat`).
129
129
  context[.imageScaleFactor] = source.scale
130
130
 
131
+ // It seems that `UIImageView` can't tint some vector graphics. If the `tintColor` prop is specified,
132
+ // we tell the SVG coder to decode to a bitmap instead. This will become useless when we switch to SVGNative coder.
133
+ if imageTintColor != nil {
134
+ context[.imageDecodeOptions] = [
135
+ SDImageCoderOption.webImageContext: [
136
+ "svgPrefersBitmap": true,
137
+ "svgImageSize": sdImageView.bounds.size,
138
+ "svgImagePreserveAspectRatio": true
139
+ ]
140
+ ]
141
+ }
142
+
131
143
  if source.isCachingAllowed {
132
144
  let sdCacheType = cachePolicy.toSdCacheType().rawValue
133
145
  context[.originalQueryCacheType] = sdCacheType
@@ -185,7 +197,13 @@ public final class ImageView: ExpoView {
185
197
  _ imageUrl: URL?
186
198
  ) {
187
199
  if let error = error {
188
- onError(["error": error.localizedDescription])
200
+ let code = (error as NSError).code
201
+
202
+ // SDWebImage throws an error when loading operation is canceled (interrupted) by another load request.
203
+ // We do want to ignore that one and wait for the new request to load.
204
+ if code != SDWebImageError.cancelled.rawValue {
205
+ onError(["error": error.localizedDescription])
206
+ }
189
207
  return
190
208
  }
191
209
  guard finished else {
@@ -297,15 +315,14 @@ public final class ImageView: ExpoView {
297
315
  guard isViewEmpty || !hasAnySource, let placeholder = placeholderImage else {
298
316
  return
299
317
  }
300
- setImage(placeholder, contentFit: placeholderContentFit)
318
+ setImage(placeholder, contentFit: placeholderContentFit, isPlaceholder: true)
301
319
  }
302
320
 
303
321
  // MARK: - Processing
304
322
 
305
323
  private func createTransformPipeline() -> SDImagePipelineTransformer {
306
324
  let transformers: [SDImageTransformer] = [
307
- SDImageBlurTransformer(radius: blurRadius),
308
- SDImageTintTransformer(color: imageTintColor)
325
+ SDImageBlurTransformer(radius: blurRadius)
309
326
  ]
310
327
  return SDImagePipelineTransformer(transformers: transformers)
311
328
  }
@@ -338,17 +355,24 @@ public final class ImageView: ExpoView {
338
355
 
339
356
  UIView.transition(with: sdImageView, duration: seconds, options: options) { [weak self] in
340
357
  if let self = self {
341
- self.setImage(image, contentFit: self.contentFit)
358
+ self.setImage(image, contentFit: self.contentFit, isPlaceholder: false)
342
359
  }
343
360
  }
344
361
  } else {
345
- setImage(image, contentFit: contentFit)
362
+ setImage(image, contentFit: contentFit, isPlaceholder: false)
346
363
  }
347
364
  }
348
365
 
349
- private func setImage(_ image: UIImage?, contentFit: ContentFit) {
366
+ private func setImage(_ image: UIImage?, contentFit: ContentFit, isPlaceholder: Bool) {
350
367
  sdImageView.contentMode = contentFit.toContentMode()
351
- sdImageView.image = image
368
+
369
+ if let imageTintColor, !isPlaceholder {
370
+ sdImageView.tintColor = imageTintColor
371
+ sdImageView.image = image?.withRenderingMode(.alwaysTemplate)
372
+ } else {
373
+ sdImageView.tintColor = nil
374
+ sdImageView.image = image
375
+ }
352
376
 
353
377
  if enableLiveTextInteraction {
354
378
  analyzeImage()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-image",
3
3
  "title": "Expo Image",
4
- "version": "1.3.1",
4
+ "version": "1.3.3",
5
5
  "description": "A cross-platform, performant image component for React Native and Expo with Web support",
6
6
  "main": "build/index.js",
7
7
  "types": "build/index.d.ts",
@@ -33,5 +33,5 @@
33
33
  "peerDependencies": {
34
34
  "expo": "*"
35
35
  },
36
- "gitHead": "dce1880a2dc156f551847c78ac8bb4d2420e7ff3"
36
+ "gitHead": "0fa20c9cbad0c73a30089ffc09073e6d94a6dabb"
37
37
  }