expo-image 2.0.1 → 2.0.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 +13 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/expo/modules/image/ExpoImageModule.kt +3 -7
- package/android/src/main/java/expo/modules/image/ExpoImageViewWrapper.kt +4 -2
- package/android/src/main/java/expo/modules/image/ImageLoadTask.kt +21 -27
- package/build/Image.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Image.tsx +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,19 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 2.0.3 — 2024-11-29
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- [Android] Fixed `useImage` causing a native crash when uri is unresolvable. ([#33268](https://github.com/expo/expo/pull/33268) by [@lukmccall](https://github.com/lukmccall))
|
|
18
|
+
- [Android] Fixes adding a blurhash placeholder to `Image` or `ImageBackground` causing blurry version of the image. ([#33272](https://github.com/expo/expo/pull/33272) by [@lukmccall](https://github.com/lukmccall))
|
|
19
|
+
|
|
20
|
+
## 2.0.2 — 2024-11-22
|
|
21
|
+
|
|
22
|
+
### 💡 Others
|
|
23
|
+
|
|
24
|
+
- Add a warning when `children` are passed to `Image`. ([#33139](https://github.com/expo/expo/pull/33139) by [@alanjhughes](https://github.com/alanjhughes))
|
|
25
|
+
|
|
13
26
|
## 2.0.1 — 2024-11-19
|
|
14
27
|
|
|
15
28
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -18,7 +18,7 @@ android {
|
|
|
18
18
|
namespace "expo.modules.image"
|
|
19
19
|
defaultConfig {
|
|
20
20
|
versionCode 1
|
|
21
|
-
versionName "2.0.
|
|
21
|
+
versionName "2.0.3"
|
|
22
22
|
consumerProguardFiles("proguard-rules.pro")
|
|
23
23
|
|
|
24
24
|
buildConfigField("boolean", "ALLOW_GLIDE_LOGS", project.properties.get("EXPO_ALLOW_GLIDE_LOGS", "false"))
|
|
@@ -31,15 +31,13 @@ import expo.modules.image.records.SourceMap
|
|
|
31
31
|
import expo.modules.kotlin.Promise
|
|
32
32
|
import expo.modules.kotlin.apifeatures.EitherType
|
|
33
33
|
import expo.modules.kotlin.exception.Exceptions
|
|
34
|
+
import expo.modules.kotlin.functions.Coroutine
|
|
34
35
|
import expo.modules.kotlin.functions.Queues
|
|
35
36
|
import expo.modules.kotlin.modules.Module
|
|
36
37
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
37
38
|
import expo.modules.kotlin.sharedobjects.SharedRef
|
|
38
39
|
import expo.modules.kotlin.types.EitherOfThree
|
|
39
40
|
import expo.modules.kotlin.types.toKClass
|
|
40
|
-
import kotlinx.coroutines.CoroutineScope
|
|
41
|
-
import kotlinx.coroutines.Dispatchers
|
|
42
|
-
import kotlinx.coroutines.launch
|
|
43
41
|
|
|
44
42
|
class ExpoImageModule : Module() {
|
|
45
43
|
override fun definition() = ModuleDefinition {
|
|
@@ -110,10 +108,8 @@ class ExpoImageModule : Module() {
|
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
AsyncFunction("loadAsync") { source: SourceMap, options: ImageLoadOptions
|
|
114
|
-
|
|
115
|
-
ImageLoadTask(appContext, source, options ?: ImageLoadOptions()).load(promise)
|
|
116
|
-
}
|
|
111
|
+
AsyncFunction("loadAsync") Coroutine { source: SourceMap, options: ImageLoadOptions? ->
|
|
112
|
+
ImageLoadTask(appContext, source, options ?: ImageLoadOptions()).load()
|
|
117
113
|
}
|
|
118
114
|
|
|
119
115
|
Class(Image::class) {
|
|
@@ -540,8 +540,10 @@ class ExpoImageViewWrapper(context: Context, appContext: AppContext) : ExpoView(
|
|
|
540
540
|
}
|
|
541
541
|
newTarget.placeholderContentFit = newPlaceholderContentFit
|
|
542
542
|
|
|
543
|
-
thumbnail(
|
|
544
|
-
.
|
|
543
|
+
thumbnail(
|
|
544
|
+
requestManager.load(placeholderModel.getGlideModel())
|
|
545
|
+
.apply(placeholderSource.createGlideOptions(context))
|
|
546
|
+
)
|
|
545
547
|
}
|
|
546
548
|
.downsample(downsampleStrategy)
|
|
547
549
|
.addListener(GlideRequestListener(WeakReference(this)))
|
|
@@ -1,42 +1,36 @@
|
|
|
1
1
|
package expo.modules.image
|
|
2
2
|
|
|
3
|
-
import android.graphics.drawable.Drawable
|
|
4
3
|
import com.bumptech.glide.Glide
|
|
5
4
|
import expo.modules.image.records.ImageLoadOptions
|
|
6
5
|
import expo.modules.image.records.SourceMap
|
|
7
6
|
import expo.modules.kotlin.AppContext
|
|
8
|
-
import expo.modules.kotlin.Promise
|
|
9
7
|
import expo.modules.kotlin.exception.Exceptions
|
|
10
8
|
import kotlinx.coroutines.Dispatchers
|
|
11
|
-
import kotlinx.coroutines.Job
|
|
12
|
-
import kotlinx.coroutines.async
|
|
13
|
-
import kotlinx.coroutines.coroutineScope
|
|
14
9
|
import kotlinx.coroutines.withContext
|
|
15
10
|
|
|
16
|
-
open class ImageLoadTask(
|
|
17
|
-
private
|
|
11
|
+
open class ImageLoadTask(
|
|
12
|
+
private val appContext: AppContext,
|
|
13
|
+
private val source: SourceMap,
|
|
14
|
+
private val options: ImageLoadOptions
|
|
15
|
+
) {
|
|
16
|
+
suspend fun load(): Image {
|
|
17
|
+
val context =
|
|
18
|
+
this@ImageLoadTask.appContext.reactContext ?: throw Exceptions.ReactContextLost()
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.centerInside()
|
|
29
|
-
.submit(options.maxWidth, options.maxHeight)
|
|
30
|
-
.get()
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
task = deferred
|
|
34
|
-
try {
|
|
35
|
-
val bitmap: Drawable = deferred.await()
|
|
36
|
-
promise.resolve(Image(bitmap))
|
|
37
|
-
} catch (e: Exception) {
|
|
38
|
-
promise.reject(ImageLoadFailed(e))
|
|
20
|
+
try {
|
|
21
|
+
val bitmap = withContext(Dispatchers.IO) {
|
|
22
|
+
Glide
|
|
23
|
+
.with(context)
|
|
24
|
+
.asDrawable()
|
|
25
|
+
.load(source.uri)
|
|
26
|
+
.centerInside()
|
|
27
|
+
.submit(options.maxWidth, options.maxHeight)
|
|
28
|
+
.get()
|
|
39
29
|
}
|
|
30
|
+
|
|
31
|
+
return Image(bitmap)
|
|
32
|
+
} catch (e: Exception) {
|
|
33
|
+
throw ImageLoadFailed(e)
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
}
|
package/build/Image.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../src/Image.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../src/Image.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,MAAM,eAAe,CAAC;AAQvB,qBAAa,KAAM,SAAQ,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC;IACxD,aAAa,MAAC;IACd,gBAAgB,MAAC;gBACL,KAAK,KAAA;IAOjB,gBAAgB,YAMd;IAEF;;OAEG;IACH,MAAM,CAAC,KAAK,kBAAqB;IAEjC;;;;;;;;;;OAUG;WACU,QAAQ,CACnB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,WAAW,CAAC,EAAE,oBAAoB,CAAC,aAAa,CAAC,GAChD,OAAO,CAAC,OAAO,CAAC;IACnB;;;;;;;;;;OAUG;WACU,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAoBhG;;;;;;;OAOG;WACU,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjD;;;;;;;OAOG;WACU,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/C;;;;;;;;;OASG;WACU,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIxE;;;;;;;OAOG;WACU,qBAAqB,CAChC,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GACvE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIzB;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC;;;;;;OAMG;WACU,SAAS,CACpB,MAAM,EAAE,WAAW,GAAG,MAAM,EAC5B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,QAAQ,CAAC;IAKpB,MAAM;CA8CP"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-image",
|
|
3
3
|
"title": "Expo Image",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
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",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"optional": true
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "728158f99d680cf64fb06f08301d3806c18c6f63"
|
|
45
45
|
}
|
package/src/Image.tsx
CHANGED
|
@@ -17,6 +17,7 @@ import { resolveContentFit, resolveContentPosition, resolveTransition } from './
|
|
|
17
17
|
import { resolveSource, resolveSources } from './utils/resolveSources';
|
|
18
18
|
|
|
19
19
|
let loggedDefaultSourceDeprecationWarning = false;
|
|
20
|
+
let loggedRenderingChildrenWarning = false;
|
|
20
21
|
|
|
21
22
|
export class Image extends React.PureComponent<ImageProps> {
|
|
22
23
|
nativeViewRef;
|
|
@@ -198,6 +199,13 @@ export class Image extends React.PureComponent<ImageProps> {
|
|
|
198
199
|
loggedDefaultSourceDeprecationWarning = true;
|
|
199
200
|
}
|
|
200
201
|
|
|
202
|
+
if (restProps.children && !loggedRenderingChildrenWarning) {
|
|
203
|
+
console.warn(
|
|
204
|
+
'The <Image> component does not support children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.'
|
|
205
|
+
);
|
|
206
|
+
loggedRenderingChildrenWarning = true;
|
|
207
|
+
}
|
|
208
|
+
|
|
201
209
|
return (
|
|
202
210
|
<ExpoImage
|
|
203
211
|
{...restProps}
|