expo-media-library 18.2.0 → 18.3.0-canary-20250919-7a31b96

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.
Files changed (79) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/medialibrary/next/MediaLibraryNextModule.kt +22 -12
  4. package/android/src/main/java/expo/modules/medialibrary/next/extensions/resolver/AlbumExtensions.kt +9 -0
  5. package/android/src/main/java/expo/modules/medialibrary/next/extensions/resolver/AssetExtensions.kt +2 -5
  6. package/android/src/main/java/expo/modules/medialibrary/next/objects/album/AlbumQuery.kt +22 -0
  7. package/android/src/main/java/expo/modules/medialibrary/next/objects/asset/delegates/AssetLegacyDelegate.kt +8 -3
  8. package/android/src/main/java/expo/modules/medialibrary/next/objects/asset/delegates/AssetModernDelegate.kt +8 -3
  9. package/android/src/main/java/expo/modules/medialibrary/next/objects/asset/factories/AssetLegacyFactory.kt +1 -1
  10. package/android/src/main/java/expo/modules/medialibrary/next/objects/query/MediaStoreQueryFormatter.kt +9 -3
  11. package/android/src/main/java/expo/modules/medialibrary/next/objects/query/Query.kt +0 -1
  12. package/android/src/main/java/expo/modules/medialibrary/next/objects/wrappers/MimeType.kt +10 -3
  13. package/android/src/main/java/expo/modules/medialibrary/next/objects/wrappers/RelativePath.kt +2 -1
  14. package/build/next/index.d.ts +10 -1
  15. package/build/next/index.d.ts.map +1 -1
  16. package/build/next/index.js +16 -2
  17. package/build/next/index.js.map +1 -1
  18. package/build/next/types/Album.d.ts +38 -17
  19. package/build/next/types/Album.d.ts.map +1 -1
  20. package/build/next/types/Album.js.map +1 -1
  21. package/build/next/types/Asset.d.ts +19 -24
  22. package/build/next/types/Asset.d.ts.map +1 -1
  23. package/build/next/types/Asset.js.map +1 -1
  24. package/build/next/types/Query.d.ts +1 -0
  25. package/build/next/types/Query.d.ts.map +1 -1
  26. package/build/next/types/Query.js.map +1 -1
  27. package/expo-module.config.json +1 -1
  28. package/ios/next/MediaLibraryNextModule.swift +10 -2
  29. package/ios/next/extensions/DateExtensions.swift +8 -0
  30. package/ios/next/objects/Query/PredicateBuilder.swift +1 -1
  31. package/ios/next/objects/asset/Asset.swift +2 -2
  32. package/ios/next/repository/AssetCollectionRepository.swift +12 -0
  33. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/{18.2.0/expo.modules.medialibrary-18.2.0-sources.jar → 18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar} +0 -0
  34. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar.md5 +1 -0
  35. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar.sha1 +1 -0
  36. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar.sha256 +1 -0
  37. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar.sha512 +1 -0
  38. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar +0 -0
  39. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar.md5 +1 -0
  40. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar.sha1 +1 -0
  41. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar.sha256 +1 -0
  42. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar.sha512 +1 -0
  43. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/{18.2.0/expo.modules.medialibrary-18.2.0.module → 18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module} +22 -22
  44. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module.md5 +1 -0
  45. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module.sha1 +1 -0
  46. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module.sha256 +1 -0
  47. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module.sha512 +1 -0
  48. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/{18.2.0/expo.modules.medialibrary-18.2.0.pom → 18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom} +1 -1
  49. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom.md5 +1 -0
  50. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom.sha1 +1 -0
  51. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom.sha256 +1 -0
  52. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom.sha512 +1 -0
  53. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml +4 -4
  54. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml.md5 +1 -1
  55. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml.sha1 +1 -1
  56. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml.sha256 +1 -1
  57. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml.sha512 +1 -1
  58. package/package.json +4 -5
  59. package/src/next/index.ts +19 -2
  60. package/src/next/types/Album.ts +39 -21
  61. package/src/next/types/Asset.ts +28 -18
  62. package/src/next/types/Query.ts +1 -0
  63. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0-sources.jar.md5 +0 -1
  64. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0-sources.jar.sha1 +0 -1
  65. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0-sources.jar.sha256 +0 -1
  66. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0-sources.jar.sha512 +0 -1
  67. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar +0 -0
  68. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar.md5 +0 -1
  69. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar.sha1 +0 -1
  70. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar.sha256 +0 -1
  71. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar.sha512 +0 -1
  72. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.module.md5 +0 -1
  73. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.module.sha1 +0 -1
  74. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.module.sha256 +0 -1
  75. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.module.sha512 +0 -1
  76. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.pom.md5 +0 -1
  77. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.pom.sha1 +0 -1
  78. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.pom.sha256 +0 -1
  79. package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -6,10 +6,17 @@
6
6
 
7
7
  ### 🎉 New features
8
8
 
9
+ - [next] Add `Album.get(title)` ([#39717](https://github.com/expo/expo/pull/39717) by [@Wenszel](https://github.com/Wenszel))
10
+
9
11
  ### 🐛 Bug fixes
10
12
 
13
+ - [next][android] Change default root directory to Pictures ([#39716](https://github.com/expo/expo/pull/39716) by [@Wenszel](https://github.com/Wenszel))
14
+ - [next] Fix `asset.getModificationTime` to return milliseconds ([#39715](https://github.com/expo/expo/pull/39715) by [@Wenszel](https://github.com/Wenszel))
15
+
11
16
  ### 💡 Others
12
17
 
18
+ - [next] Add documentation ([#39754](https://github.com/expo/expo/pull/39754) by [@Wenszel](https://github.com/Wenszel))
19
+
13
20
  ## 18.2.0 — 2025-09-16
14
21
 
15
22
  ### 🎉 New features
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '18.2.0'
7
+ version = '18.3.0-canary-20250919-7a31b96'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.medialibrary"
11
11
  defaultConfig {
12
12
  versionCode 37
13
- versionName "18.2.0"
13
+ versionName "18.3.0-canary-20250919-7a31b96"
14
14
  }
15
15
  }
16
16
 
@@ -11,6 +11,7 @@ import expo.modules.kotlin.modules.ModuleDefinition
11
11
  import expo.modules.kotlin.types.Either
12
12
  import expo.modules.kotlin.types.toKClass
13
13
  import expo.modules.medialibrary.next.objects.album.Album
14
+ import expo.modules.medialibrary.next.objects.album.AlbumQuery
14
15
  import expo.modules.medialibrary.next.objects.asset.Asset
15
16
  import expo.modules.medialibrary.next.objects.album.factories.AlbumModernFactory
16
17
  import expo.modules.medialibrary.next.objects.album.factories.AlbumLegacyFactory
@@ -38,6 +39,10 @@ class MediaLibraryNextModule : Module() {
38
39
  MediaStorePermissionsDelegate(appContext)
39
40
  }
40
41
 
42
+ private val albumQuery by lazy {
43
+ AlbumQuery(context)
44
+ }
45
+
41
46
  private val albumFactory by lazy {
42
47
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
43
48
  AlbumModernFactory(assetFactory, context)
@@ -164,29 +169,29 @@ class MediaLibraryNextModule : Module() {
164
169
  self.album(album)
165
170
  }
166
171
 
167
- Function("eq") { self: Query, field: AssetField, value: Either<MediaType, Int> ->
168
- self.eq(field, MediaStoreQueryFormatter.parse(value))
172
+ Function("eq") { self: Query, field: AssetField, value: Either<MediaType, Long> ->
173
+ self.eq(field, MediaStoreQueryFormatter.parse(field, value))
169
174
  }
170
175
 
171
- Function("within") { self: Query, field: AssetField, values: List<Either<MediaType, Int>> ->
172
- val stringValues = values.map { value -> MediaStoreQueryFormatter.parse(value) }
176
+ Function("within") { self: Query, field: AssetField, values: List<Either<MediaType, Long>> ->
177
+ val stringValues = values.map { value -> MediaStoreQueryFormatter.parse(field, value) }
173
178
  self.within(field, stringValues)
174
179
  }
175
180
 
176
- Function("gt") { self: Query, field: AssetField, value: Int ->
177
- self.gt(field, MediaStoreQueryFormatter.parse(value))
181
+ Function("gt") { self: Query, field: AssetField, value: Long ->
182
+ self.gt(field, MediaStoreQueryFormatter.parse(field, value))
178
183
  }
179
184
 
180
- Function("gte") { self: Query, field: AssetField, value: Int ->
181
- self.gte(field, MediaStoreQueryFormatter.parse(value))
185
+ Function("gte") { self: Query, field: AssetField, value: Long ->
186
+ self.gte(field, MediaStoreQueryFormatter.parse(field, value))
182
187
  }
183
188
 
184
- Function("lt") { self: Query, field: AssetField, value: Int ->
185
- self.lt(field, MediaStoreQueryFormatter.parse(value))
189
+ Function("lt") { self: Query, field: AssetField, value: Long ->
190
+ self.lt(field, MediaStoreQueryFormatter.parse(field, value))
186
191
  }
187
192
 
188
- Function("lte") { self: Query, field: AssetField, value: Int ->
189
- self.lte(field, MediaStoreQueryFormatter.parse(value))
193
+ Function("lte") { self: Query, field: AssetField, value: Long ->
194
+ self.lte(field, MediaStoreQueryFormatter.parse(field, value))
190
195
  }
191
196
 
192
197
  Function("orderBy") { self: Query, sortDescriptorRef: Either<AssetField, SortDescriptor> ->
@@ -221,6 +226,11 @@ class MediaLibraryNextModule : Module() {
221
226
  return@Coroutine albumFactory.createFromFilePaths(name, assetPaths)
222
227
  }
223
228
 
229
+ AsyncFunction("getAlbum") Coroutine { title: String ->
230
+ systemPermissionsDelegate.requireSystemPermissions(false)
231
+ albumQuery.getAlbum(title)
232
+ }
233
+
224
234
  AsyncFunction("deleteAlbums") Coroutine { albums: List<Album> ->
225
235
  systemPermissionsDelegate.requireSystemPermissions(true)
226
236
  albums.forEach { album -> album.delete() }
@@ -48,6 +48,15 @@ suspend fun ContentResolver.queryAlbumId(relativePath: RelativePath): String? =
48
48
  arrayOf(relativePath.value)
49
49
  )
50
50
 
51
+ suspend fun ContentResolver.queryAlbumId(name: String): String? =
52
+ queryOne(
53
+ EXTERNAL_CONTENT_URI,
54
+ MediaStore.Files.FileColumns.BUCKET_ID,
55
+ Cursor::getString,
56
+ "${MediaStore.MediaColumns.BUCKET_DISPLAY_NAME} = ?",
57
+ arrayOf(name)
58
+ )
59
+
51
60
  suspend fun ContentResolver.queryAlbumAssetsContentUris(bucketId: String): List<Uri> =
52
61
  withContext(Dispatchers.IO) {
53
62
  val projection = arrayOf(
@@ -17,8 +17,8 @@ import kotlinx.coroutines.withContext
17
17
  suspend fun ContentResolver.queryAssetDisplayName(contentUri: Uri): String? =
18
18
  queryOne(contentUri, MediaStore.MediaColumns.DISPLAY_NAME, Cursor::getString)
19
19
 
20
- suspend fun ContentResolver.queryGetCreationTime(contentUri: Uri): Long? =
21
- queryOne(contentUri, MediaStore.MediaColumns.DATE_TAKEN, Cursor::getLong)
20
+ suspend fun ContentResolver.queryAssetCreationTime(contentUri: Uri): Long? =
21
+ queryOne(contentUri, MediaStore.Images.Media.DATE_TAKEN, Cursor::getLong)
22
22
 
23
23
  suspend fun ContentResolver.queryAssetModificationTime(contentUri: Uri): Long? =
24
24
  queryOne(contentUri, MediaStore.MediaColumns.DATE_MODIFIED, Cursor::getLong)
@@ -38,9 +38,6 @@ suspend fun ContentResolver.queryAssetPath(contentUri: Uri): String? =
38
38
  suspend fun ContentResolver.queryAssetBucketId(contentUri: Uri): Int? =
39
39
  queryOne(contentUri, MediaStore.MediaColumns.BUCKET_ID, Cursor::getInt)
40
40
 
41
- suspend fun ContentResolver.queryAssetMediaType(contentUri: Uri): Int? =
42
- queryOne(contentUri, MediaStore.Files.FileColumns.MEDIA_TYPE, Cursor::getInt)
43
-
44
41
  suspend fun ContentResolver.insertPendingAsset(
45
42
  displayName: String,
46
43
  mimeType: MimeType,
@@ -0,0 +1,22 @@
1
+ package expo.modules.medialibrary.next.objects.album
2
+
3
+ import android.content.Context
4
+ import expo.modules.medialibrary.next.exceptions.ContentResolverNotObtainedException
5
+ import expo.modules.medialibrary.next.extensions.getOrThrow
6
+ import expo.modules.medialibrary.next.extensions.resolver.queryAlbumId
7
+ import java.lang.ref.WeakReference
8
+
9
+ class AlbumQuery(context: Context) {
10
+ private val contextRef = WeakReference(context)
11
+
12
+ private val contentResolver
13
+ get() = contextRef
14
+ .getOrThrow()
15
+ .contentResolver ?: throw ContentResolverNotObtainedException()
16
+
17
+ suspend fun getAlbum(title: String): Album? {
18
+ val id = contentResolver.queryAlbumId(title)
19
+ ?: return null
20
+ return Album(id, contextRef.getOrThrow())
21
+ }
22
+ }
@@ -19,7 +19,7 @@ import expo.modules.medialibrary.next.extensions.resolver.queryAssetHeight
19
19
  import expo.modules.medialibrary.next.extensions.resolver.queryAssetModificationTime
20
20
  import expo.modules.medialibrary.next.extensions.resolver.queryAssetPath
21
21
  import expo.modules.medialibrary.next.extensions.resolver.queryAssetWidth
22
- import expo.modules.medialibrary.next.extensions.resolver.queryGetCreationTime
22
+ import expo.modules.medialibrary.next.extensions.resolver.queryAssetCreationTime
23
23
  import expo.modules.medialibrary.next.extensions.safeCopy
24
24
  import expo.modules.medialibrary.next.extensions.safeMove
25
25
  import expo.modules.medialibrary.next.objects.wrappers.RelativePath
@@ -30,6 +30,8 @@ import kotlinx.coroutines.Dispatchers
30
30
  import kotlinx.coroutines.withContext
31
31
  import java.io.File
32
32
  import java.lang.ref.WeakReference
33
+ import kotlin.time.DurationUnit
34
+ import kotlin.time.toDuration
33
35
 
34
36
  @DeprecatedSinceApi(Build.VERSION_CODES.Q)
35
37
  class AssetLegacyDelegate(contentUri: Uri, context: Context) : AssetDelegate {
@@ -50,7 +52,7 @@ class AssetLegacyDelegate(contentUri: Uri, context: Context) : AssetDelegate {
50
52
 
51
53
  override suspend fun getCreationTime(): Long? {
52
54
  return contentResolver
53
- .queryGetCreationTime(contentUri)
55
+ .queryAssetCreationTime(contentUri)
54
56
  .takeIf { it != 0L }
55
57
  }
56
58
 
@@ -98,7 +100,10 @@ class AssetLegacyDelegate(contentUri: Uri, context: Context) : AssetDelegate {
98
100
  MediaType.fromContentUri(contentUri)
99
101
 
100
102
  override suspend fun getModificationTime(): Long? =
101
- contentResolver.queryAssetModificationTime(contentUri).takeIf { it != 0L }
103
+ contentResolver.queryAssetModificationTime(contentUri)
104
+ ?.takeIf { it != 0L }
105
+ ?.toDuration(DurationUnit.SECONDS)
106
+ ?.inWholeMilliseconds
102
107
 
103
108
  override suspend fun getMimeType(): MimeType {
104
109
  return contentResolver.getType(contentUri)?.let { MimeType(it) }
@@ -18,7 +18,7 @@ import expo.modules.medialibrary.next.extensions.resolver.queryAssetHeight
18
18
  import expo.modules.medialibrary.next.extensions.resolver.queryAssetModificationTime
19
19
  import expo.modules.medialibrary.next.extensions.resolver.queryAssetPath
20
20
  import expo.modules.medialibrary.next.extensions.resolver.queryAssetWidth
21
- import expo.modules.medialibrary.next.extensions.resolver.queryGetCreationTime
21
+ import expo.modules.medialibrary.next.extensions.resolver.queryAssetCreationTime
22
22
  import expo.modules.medialibrary.next.extensions.resolver.updateRelativePath
23
23
  import expo.modules.medialibrary.next.objects.wrappers.RelativePath
24
24
  import expo.modules.medialibrary.next.objects.asset.Asset
@@ -28,6 +28,8 @@ import kotlinx.coroutines.Dispatchers
28
28
  import kotlinx.coroutines.withContext
29
29
  import java.io.File
30
30
  import java.lang.ref.WeakReference
31
+ import kotlin.time.DurationUnit
32
+ import kotlin.time.toDuration
31
33
 
32
34
  @RequiresApi(Build.VERSION_CODES.Q)
33
35
  class AssetModernDelegate(override val contentUri: Uri, context: Context) : AssetDelegate {
@@ -40,7 +42,7 @@ class AssetModernDelegate(override val contentUri: Uri, context: Context) : Asse
40
42
 
41
43
  override suspend fun getCreationTime(): Long? {
42
44
  return contentResolver
43
- .queryGetCreationTime(contentUri)
45
+ .queryAssetCreationTime(contentUri)
44
46
  .takeIf { it != 0L }
45
47
  }
46
48
 
@@ -88,7 +90,10 @@ class AssetModernDelegate(override val contentUri: Uri, context: Context) : Asse
88
90
  MediaType.fromContentUri(contentUri)
89
91
 
90
92
  override suspend fun getModificationTime(): Long? =
91
- contentResolver.queryAssetModificationTime(contentUri).takeIf { it != 0L }
93
+ contentResolver.queryAssetModificationTime(contentUri)
94
+ ?.takeIf { it != 0L }
95
+ ?.toDuration(DurationUnit.SECONDS)
96
+ ?.inWholeMilliseconds
92
97
 
93
98
  override suspend fun getUri(): Uri {
94
99
  // e.g. storage/emulated/0/Android/data/expo/files/[ROOT_ALBUM]/[ALBUM_NAME]
@@ -35,7 +35,7 @@ class AssetLegacyFactory(context: Context) : AssetFactory {
35
35
  val baseDir = if (relativePath != null) {
36
36
  File(relativePath.toFilePath())
37
37
  } else {
38
- mimeType.externalStoragePublicDirectory()
38
+ mimeType.externalStorageAssetDirectory()
39
39
  }
40
40
  baseDir.mkdirs()
41
41
 
@@ -3,18 +3,24 @@ package expo.modules.medialibrary.next.objects.query
3
3
  import expo.modules.kotlin.apifeatures.EitherType
4
4
  import expo.modules.kotlin.types.Either
5
5
  import expo.modules.medialibrary.next.objects.wrappers.MediaType
6
+ import expo.modules.medialibrary.next.records.AssetField
7
+ import kotlin.time.DurationUnit
8
+ import kotlin.time.toDuration
6
9
 
7
10
  @OptIn(EitherType::class)
8
11
  class MediaStoreQueryFormatter {
9
12
  companion object {
10
- fun parse(value: Either<MediaType, Int>): String {
13
+ fun parse(field: AssetField, value: Either<MediaType, Long>): String {
11
14
  if (value.`is`(MediaType::class)) {
12
15
  return parse(value.get(MediaType::class))
13
16
  }
14
- return parse(value.get(Int::class))
17
+ return parse(field, value.get(Long::class))
15
18
  }
16
19
 
17
- fun parse(value: Int): String {
20
+ fun parse(field: AssetField, value: Long): String {
21
+ if (field == AssetField.MODIFICATION_TIME) {
22
+ return value.toDuration(DurationUnit.MILLISECONDS).inWholeSeconds.toString()
23
+ }
18
24
  return value.toString()
19
25
  }
20
26
 
@@ -32,7 +32,6 @@ class Query(context: Context) : SharedObject() {
32
32
  private val args = mutableListOf<String>()
33
33
  private val orderBy = mutableListOf<SortDescriptor>()
34
34
 
35
- private var album: Album? = null
36
35
  private var limit: Int? = null
37
36
  private var offset: Int? = null
38
37
 
@@ -24,15 +24,22 @@ value class MimeType(val value: String?) {
24
24
  fun isVideo(): Boolean = type == "video"
25
25
  fun isAudio(): Boolean = type == "audio"
26
26
 
27
- fun rootDirectory(): String = when {
27
+ fun assetRootDirectory(): String = when {
28
28
  value == null -> Environment.DIRECTORY_DCIM
29
29
  isImage() || isVideo() -> Environment.DIRECTORY_DCIM
30
30
  isAudio() -> Environment.DIRECTORY_MUSIC
31
31
  else -> Environment.DIRECTORY_DCIM
32
32
  }
33
33
 
34
- fun externalStoragePublicDirectory(): File =
35
- Environment.getExternalStoragePublicDirectory(rootDirectory())
34
+ fun albumRootDirectory(): String = when {
35
+ value == null -> Environment.DIRECTORY_PICTURES
36
+ isImage() || isVideo() -> Environment.DIRECTORY_PICTURES
37
+ isAudio() -> Environment.DIRECTORY_MUSIC
38
+ else -> Environment.DIRECTORY_PICTURES
39
+ }
40
+
41
+ fun externalStorageAssetDirectory(): File =
42
+ Environment.getExternalStoragePublicDirectory(assetRootDirectory())
36
43
 
37
44
  fun mediaCollectionUri(): Uri = when {
38
45
  value == null -> EXTERNAL_CONTENT_URI
@@ -21,10 +21,11 @@ value class RelativePath(val value: String) {
21
21
 
22
22
  companion object {
23
23
  fun create(mimeType: MimeType, albumName: String? = null): RelativePath {
24
- val rootDirectory = mimeType.rootDirectory()
25
24
  if (albumName != null) {
25
+ val rootDirectory = mimeType.albumRootDirectory()
26
26
  return RelativePath("$rootDirectory/$albumName/")
27
27
  }
28
+ val rootDirectory = mimeType.assetRootDirectory()
28
29
  return RelativePath("$rootDirectory/")
29
30
  }
30
31
  }
@@ -11,7 +11,16 @@ export declare class Asset extends ExpoMediaLibraryNext.Asset {
11
11
  export declare class Album extends ExpoMediaLibraryNext.Album {
12
12
  static create(name: string, assetsRefs: string[] | Asset[], moveAssets?: boolean): Promise<Album>;
13
13
  static delete(albums: Album[], deleteAssets?: boolean): Promise<void>;
14
- static getAll(): Promise<Album[]>;
14
+ static get(title: string): Promise<Album | null>;
15
15
  }
16
+ /**
17
+ * Asks the user to grant permissions for accessing media in user's media library.
18
+ * @param writeOnly
19
+ * @param granularPermissions - A list of [`GranularPermission`](#granularpermission) values. This parameter has an
20
+ * effect only on Android 13 and newer. By default, `expo-media-library` will ask for all possible permissions.
21
+ *
22
+ * > When using granular permissions with a custom config plugin configuration, make sure that all the requested permissions are included in the plugin.
23
+ * @return A promise that fulfils with [`PermissionResponse`](#permissionresponse) object.
24
+ */
16
25
  export declare function requestPermissionsAsync(writeOnly?: boolean, granularPermissions?: GranularPermission[]): Promise<PermissionResponse>;
17
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAG5E,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,cAAc,0BAA0B,CAAC;AAEzC,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;CAAG;AAExD,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAG9D,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C;AAED,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAC9B,UAAU,GAAE,OAAc,GACzB,OAAO,CAAC,KAAK,CAAC;IAMjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5E,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAGlC;AAED,wBAAsB,uBAAuB,CAC3C,SAAS,GAAE,OAAe,EAC1B,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,GACzC,OAAO,CAAC,kBAAkB,CAAC,CAQ7B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAG5E,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,cAAc,0BAA0B,CAAC;AAEzC,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;CAAG;AAExD,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IAEnD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAK9D,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C;AAED,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IAEnD,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAC9B,UAAU,GAAE,OAAc,GACzB,OAAO,CAAC,KAAK,CAAC;IAQjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5E,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAGjD;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,GAAE,OAAe,EAC1B,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,GACzC,OAAO,CAAC,kBAAkB,CAAC,CAQ7B"}
@@ -5,20 +5,24 @@ export * from './MediaLibraryNext.types';
5
5
  export class Query extends ExpoMediaLibraryNext.Query {
6
6
  }
7
7
  export class Asset extends ExpoMediaLibraryNext.Asset {
8
+ // @hidden
8
9
  static create(filePath, album) {
9
10
  return ExpoMediaLibraryNext.createAsset(filePath, album);
10
11
  }
12
+ // @hidden
11
13
  static delete(assets) {
12
14
  return ExpoMediaLibraryNext.deleteAssets(assets);
13
15
  }
14
16
  }
15
17
  export class Album extends ExpoMediaLibraryNext.Album {
18
+ // @hidden
16
19
  static create(name, assetsRefs, moveAssets = true) {
17
20
  if (Platform.OS === 'ios') {
18
21
  return ExpoMediaLibraryNext.createAlbum(name, assetsRefs);
19
22
  }
20
23
  return ExpoMediaLibraryNext.createAlbum(name, assetsRefs, moveAssets);
21
24
  }
25
+ // @hidden
22
26
  static delete(albums, deleteAssets = false) {
23
27
  if (Platform.OS === 'ios') {
24
28
  return ExpoMediaLibraryNext.deleteAlbums(albums, deleteAssets);
@@ -27,10 +31,20 @@ export class Album extends ExpoMediaLibraryNext.Album {
27
31
  return ExpoMediaLibraryNext.deleteAlbums(albums);
28
32
  }
29
33
  }
30
- static getAll() {
31
- return ExpoMediaLibraryNext.getAllAlbums();
34
+ // @hidden
35
+ static get(title) {
36
+ return ExpoMediaLibraryNext.getAlbum(title);
32
37
  }
33
38
  }
39
+ /**
40
+ * Asks the user to grant permissions for accessing media in user's media library.
41
+ * @param writeOnly
42
+ * @param granularPermissions - A list of [`GranularPermission`](#granularpermission) values. This parameter has an
43
+ * effect only on Android 13 and newer. By default, `expo-media-library` will ask for all possible permissions.
44
+ *
45
+ * > When using granular permissions with a custom config plugin configuration, make sure that all the requested permissions are included in the plugin.
46
+ * @return A promise that fulfils with [`PermissionResponse`](#permissionresponse) object.
47
+ */
34
48
  export async function requestPermissionsAsync(writeOnly = false, granularPermissions) {
35
49
  if (!ExpoMediaLibraryNext.requestPermissionsAsync) {
36
50
  throw new UnavailabilityError('MediaLibrary', 'requestPermissionsAsync');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAG1D,cAAc,0BAA0B,CAAC;AAEzC,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;CAAG;AAExD,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,MAAM,CAAC,MAAM,CAAC,QAAgB,EAAE,KAAa;QAC3C,OAAO,oBAAoB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,MAAe;QAC3B,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CACF;AAED,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,MAAM,CAAC,MAAM,CACX,IAAY,EACZ,UAA8B,EAC9B,aAAsB,IAAI;QAE1B,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,oBAAoB,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,oBAAoB,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,MAAe,EAAE,eAAwB,KAAK;QAC1D,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,MAAM,CAAC,MAAM;QACX,OAAO,oBAAoB,CAAC,YAAY,EAAE,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,YAAqB,KAAK,EAC1B,mBAA0C;IAE1C,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,EAAE,CAAC;QAClD,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,MAAM,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,MAAM,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { PermissionResponse, UnavailabilityError } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExpoMediaLibraryNext from './ExpoMediaLibraryNext';\nimport { GranularPermission } from './types/GranularPermission';\n\nexport * from './MediaLibraryNext.types';\n\nexport class Query extends ExpoMediaLibraryNext.Query {}\n\nexport class Asset extends ExpoMediaLibraryNext.Asset {\n static create(filePath: string, album?: Album): Promise<Asset> {\n return ExpoMediaLibraryNext.createAsset(filePath, album);\n }\n static delete(assets: Asset[]): Promise<void> {\n return ExpoMediaLibraryNext.deleteAssets(assets);\n }\n}\n\nexport class Album extends ExpoMediaLibraryNext.Album {\n static create(\n name: string,\n assetsRefs: string[] | Asset[],\n moveAssets: boolean = true\n ): Promise<Album> {\n if (Platform.OS === 'ios') {\n return ExpoMediaLibraryNext.createAlbum(name, assetsRefs);\n }\n return ExpoMediaLibraryNext.createAlbum(name, assetsRefs, moveAssets);\n }\n static delete(albums: Album[], deleteAssets: boolean = false): Promise<void> {\n if (Platform.OS === 'ios') {\n return ExpoMediaLibraryNext.deleteAlbums(albums, deleteAssets);\n } else {\n return ExpoMediaLibraryNext.deleteAlbums(albums);\n }\n }\n static getAll(): Promise<Album[]> {\n return ExpoMediaLibraryNext.getAllAlbums();\n }\n}\n\nexport async function requestPermissionsAsync(\n writeOnly: boolean = false,\n granularPermissions?: GranularPermission[]\n): Promise<PermissionResponse> {\n if (!ExpoMediaLibraryNext.requestPermissionsAsync) {\n throw new UnavailabilityError('MediaLibrary', 'requestPermissionsAsync');\n }\n if (Platform.OS === 'android') {\n return await ExpoMediaLibraryNext.requestPermissionsAsync(writeOnly, granularPermissions);\n }\n return await ExpoMediaLibraryNext.requestPermissionsAsync(writeOnly);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAG1D,cAAc,0BAA0B,CAAC;AAEzC,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;CAAG;AAExD,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,UAAU;IACV,MAAM,CAAC,MAAM,CAAC,QAAgB,EAAE,KAAa;QAC3C,OAAO,oBAAoB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED,UAAU;IACV,MAAM,CAAC,MAAM,CAAC,MAAe;QAC3B,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CACF;AAED,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,UAAU;IACV,MAAM,CAAC,MAAM,CACX,IAAY,EACZ,UAA8B,EAC9B,aAAsB,IAAI;QAE1B,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,oBAAoB,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,oBAAoB,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACxE,CAAC;IAED,UAAU;IACV,MAAM,CAAC,MAAM,CAAC,MAAe,EAAE,eAAwB,KAAK;QAC1D,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,UAAU;IACV,MAAM,CAAC,GAAG,CAAC,KAAa;QACtB,OAAO,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,YAAqB,KAAK,EAC1B,mBAA0C;IAE1C,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,EAAE,CAAC;QAClD,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,MAAM,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,MAAM,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { PermissionResponse, UnavailabilityError } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExpoMediaLibraryNext from './ExpoMediaLibraryNext';\nimport { GranularPermission } from './types/GranularPermission';\n\nexport * from './MediaLibraryNext.types';\n\nexport class Query extends ExpoMediaLibraryNext.Query {}\n\nexport class Asset extends ExpoMediaLibraryNext.Asset {\n // @hidden\n static create(filePath: string, album?: Album): Promise<Asset> {\n return ExpoMediaLibraryNext.createAsset(filePath, album);\n }\n\n // @hidden\n static delete(assets: Asset[]): Promise<void> {\n return ExpoMediaLibraryNext.deleteAssets(assets);\n }\n}\n\nexport class Album extends ExpoMediaLibraryNext.Album {\n // @hidden\n static create(\n name: string,\n assetsRefs: string[] | Asset[],\n moveAssets: boolean = true\n ): Promise<Album> {\n if (Platform.OS === 'ios') {\n return ExpoMediaLibraryNext.createAlbum(name, assetsRefs);\n }\n return ExpoMediaLibraryNext.createAlbum(name, assetsRefs, moveAssets);\n }\n\n // @hidden\n static delete(albums: Album[], deleteAssets: boolean = false): Promise<void> {\n if (Platform.OS === 'ios') {\n return ExpoMediaLibraryNext.deleteAlbums(albums, deleteAssets);\n } else {\n return ExpoMediaLibraryNext.deleteAlbums(albums);\n }\n }\n\n // @hidden\n static get(title: string): Promise<Album | null> {\n return ExpoMediaLibraryNext.getAlbum(title);\n }\n}\n\n/**\n * Asks the user to grant permissions for accessing media in user's media library.\n * @param writeOnly\n * @param granularPermissions - A list of [`GranularPermission`](#granularpermission) values. This parameter has an\n * effect only on Android 13 and newer. By default, `expo-media-library` will ask for all possible permissions.\n *\n * > When using granular permissions with a custom config plugin configuration, make sure that all the requested permissions are included in the plugin.\n * @return A promise that fulfils with [`PermissionResponse`](#permissionresponse) object.\n */\nexport async function requestPermissionsAsync(\n writeOnly: boolean = false,\n granularPermissions?: GranularPermission[]\n): Promise<PermissionResponse> {\n if (!ExpoMediaLibraryNext.requestPermissionsAsync) {\n throw new UnavailabilityError('MediaLibrary', 'requestPermissionsAsync');\n }\n if (Platform.OS === 'android') {\n return await ExpoMediaLibraryNext.requestPermissionsAsync(writeOnly, granularPermissions);\n }\n return await ExpoMediaLibraryNext.requestPermissionsAsync(writeOnly);\n}\n"]}
@@ -2,10 +2,9 @@ import { Asset } from './Asset';
2
2
  /**
3
3
  * Represents a media album (collection of assets) on the device.
4
4
  *
5
- * An `Album` groups together media assets (images, videos, or audio files).
6
- * Albums typically correspond to folders in the device’s gallery or media store.
7
- *
5
+ * An {@link Album} groups together media assets (images, videos, or audio files).
8
6
  * To create a new album, use {@link Album.create}.
7
+ * To fetch an existing album, use {@link Album.get}.
9
8
  */
10
9
  export declare class Album {
11
10
  /**
@@ -15,11 +14,11 @@ export declare class Album {
15
14
  constructor(id: string);
16
15
  /**
17
16
  * Unique identifier of the album.
18
- * Can be used to re-instantiate an `Album` later or to query related objects.
17
+ * Can be used to re-instantiate an {@link Album} later.
19
18
  */
20
19
  id: string;
21
20
  /**
22
- * Retrieves all assets contained in this album.
21
+ * Retrieves all assets contained in the album.
23
22
  * @returns A promise resolving to an array of {@link Asset} objects.
24
23
  *
25
24
  * @example
@@ -31,6 +30,7 @@ export declare class Album {
31
30
  getAssets(): Promise<Asset[]>;
32
31
  /**
33
32
  * Gets the display title (name) of the album.
33
+ * Note that album titles are not guaranteed to be unique.
34
34
  * @returns A promise resolving to the album’s title string.
35
35
  *
36
36
  * @example
@@ -42,9 +42,10 @@ export declare class Album {
42
42
  getTitle(): Promise<string>;
43
43
  /**
44
44
  * Permanently deletes the album from the device.
45
- * Depending on platform and options, this may also delete contained assets.
46
- *
45
+ * On Android, it deletes the album and all its assets.
46
+ * On iOS, it deletes the album but keeps the assets in the main library.
47
47
  * @returns A promise that resolves once the deletion has completed.
48
+ * @throws An exception if the deletion fails or the album could not be found.
48
49
  *
49
50
  * @example
50
51
  * ```ts
@@ -53,7 +54,7 @@ export declare class Album {
53
54
  */
54
55
  delete(): Promise<void>;
55
56
  /**
56
- * Adds a given asset to this album.
57
+ * Adds an asset to the album.
57
58
  * @param asset - The {@link Asset} to add.
58
59
  * @returns A promise that resolves once the asset has been added.
59
60
  *
@@ -65,12 +66,12 @@ export declare class Album {
65
66
  */
66
67
  add(asset: Asset): Promise<void>;
67
68
  /**
68
- * Creates a new album with a given name and optional assets.
69
- * If an album with the same name already exists, behavior may depend on the platform.
69
+ * A static function. Creates a new album with a given name and assets.
70
+ * On Android, if assets are provided and `moveAssets` is true, the assets will be moved into the new album. If false or not supported, the assets will be copied.
70
71
  *
71
- * @param title - Name of the new album.
72
- * @param assetsOrPaths - Optional list of {@link Asset} objects or file paths to include.
73
- * @param deleteOriginalAsset - Whether to copy assets into the album (if supported). Defaults to `false`.
72
+ * @param name - Name of the new album.
73
+ * @param assetsRefs - List of {@link Asset} objects or file paths (file:///...) to include.
74
+ * @param moveAssets - On Android, whether to move assets into the album.
74
75
  * @returns A promise resolving to the created {@link Album}.
75
76
  *
76
77
  * @example
@@ -79,13 +80,33 @@ export declare class Album {
79
80
  * console.log(await album.getTitle()); // "My Album"
80
81
  * ```
81
82
  */
82
- static create(title: string, assetsOrPaths?: (Asset | string)[], deleteOriginalAsset?: boolean): Promise<Album>;
83
+ static create(name: string, assetsRefs: string[] | Asset[], moveAssets: boolean): Promise<Album>;
83
84
  /**
84
- * Deletes multiple albums at once.
85
+ * A static function. Deletes multiple albums at once.
85
86
  * @param albums - An array of {@link Album} instances to delete.
86
- * @param deleteAssets - If `true`, also deletes assets contained in these albums (if supported).
87
+ * @param deleteAssets - Whether to delete the assets in the albums as well.
87
88
  * @returns A promise that resolves once the albums have been deleted.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const album = await Album.create("My Album", [asset]);
93
+ * await Album.delete([album]);
94
+ * ```
95
+ */
96
+ static delete(albums: Album[], deleteAssets: boolean): Promise<void>;
97
+ /**
98
+ * A static function. Retrieves an album by its title.
99
+ * @param title - The title of the album to retrieve.
100
+ * @return A promise resolving to the {@link Album} if found, or `null` if not found.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const album = await Album.get("Camera");
105
+ * if (album) {
106
+ * console.log(await album.getTitle()); // "Camera"
107
+ * }
108
+ * ```
88
109
  */
89
- static deleteMany(albums: Album[], deleteAssets?: boolean): Promise<void>;
110
+ static get(title: string): Promise<Album | null>;
90
111
  }
91
112
  //# sourceMappingURL=Album.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Album.d.ts","sourceRoot":"","sources":["../../../src/next/types/Album.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB;;;OAGG;gBACS,EAAE,EAAE,MAAM;IAEtB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;;;;;OASG;IACH,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAE7B;;;;;;;;;OASG;IACH,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAE3B;;;;;;;;;;OAUG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,MAAM,CACX,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,EAAE,EAClC,mBAAmB,CAAC,EAAE,OAAO,GAC5B,OAAO,CAAC,KAAK,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC1E"}
1
+ {"version":3,"file":"Album.d.ts","sourceRoot":"","sources":["../../../src/next/types/Album.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB;;;OAGG;gBACS,EAAE,EAAE,MAAM;IAEtB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;;;;;OASG;IACH,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAE7B;;;;;;;;;;OAUG;IACH,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAE3B;;;;;;;;;;;OAWG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;IAEhG;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAEpE;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CACjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"Album.js","sourceRoot":"","sources":["../../../src/next/types/Album.ts"],"names":[],"mappings":"","sourcesContent":["import { Asset } from './Asset';\n\n/**\n * Represents a media album (collection of assets) on the device.\n *\n * An `Album` groups together media assets (images, videos, or audio files).\n * Albums typically correspond to folders in the device’s gallery or media store.\n *\n * To create a new album, use {@link Album.create}.\n */\nexport declare class Album {\n /**\n * Reinitialize an instance of an album with a given ID.\n * @param id - The unique identifier of the album.\n */\n constructor(id: string);\n\n /**\n * Unique identifier of the album.\n * Can be used to re-instantiate an `Album` later or to query related objects.\n */\n id: string;\n\n /**\n * Retrieves all assets contained in this album.\n * @returns A promise resolving to an array of {@link Asset} objects.\n *\n * @example\n * ```ts\n * const assets = await album.getAssets();\n * console.log(assets.length);\n * ```\n */\n getAssets(): Promise<Asset[]>;\n\n /**\n * Gets the display title (name) of the album.\n * @returns A promise resolving to the album’s title string.\n *\n * @example\n * ```ts\n * const title = await album.getTitle();\n * console.log(title); // \"Camera\"\n * ```\n */\n getTitle(): Promise<string>;\n\n /**\n * Permanently deletes the album from the device.\n * Depending on platform and options, this may also delete contained assets.\n *\n * @returns A promise that resolves once the deletion has completed.\n *\n * @example\n * ```ts\n * await album.delete();\n * ```\n */\n delete(): Promise<void>;\n\n /**\n * Adds a given asset to this album.\n * @param asset - The {@link Asset} to add.\n * @returns A promise that resolves once the asset has been added.\n *\n * @example\n * ```ts\n * const asset = await Asset.create(\"file:///path/to/photo.png\");\n * await album.add(asset);\n * ```\n */\n add(asset: Asset): Promise<void>;\n\n /**\n * Creates a new album with a given name and optional assets.\n * If an album with the same name already exists, behavior may depend on the platform.\n *\n * @param title - Name of the new album.\n * @param assetsOrPaths - Optional list of {@link Asset} objects or file paths to include.\n * @param deleteOriginalAsset - Whether to copy assets into the album (if supported). Defaults to `false`.\n * @returns A promise resolving to the created {@link Album}.\n *\n * @example\n * ```ts\n * const album = await Album.create(\"My Album\", [asset]);\n * console.log(await album.getTitle()); // \"My Album\"\n * ```\n */\n static create(\n title: string,\n assetsOrPaths?: (Asset | string)[],\n deleteOriginalAsset?: boolean\n ): Promise<Album>;\n\n /**\n * Deletes multiple albums at once.\n * @param albums - An array of {@link Album} instances to delete.\n * @param deleteAssets - If `true`, also deletes assets contained in these albums (if supported).\n * @returns A promise that resolves once the albums have been deleted.\n */\n static deleteMany(albums: Album[], deleteAssets?: boolean): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"Album.js","sourceRoot":"","sources":["../../../src/next/types/Album.ts"],"names":[],"mappings":"","sourcesContent":["import { Asset } from './Asset';\n\n/**\n * Represents a media album (collection of assets) on the device.\n *\n * An {@link Album} groups together media assets (images, videos, or audio files).\n * To create a new album, use {@link Album.create}.\n * To fetch an existing album, use {@link Album.get}.\n */\nexport declare class Album {\n /**\n * Reinitialize an instance of an album with a given ID.\n * @param id - The unique identifier of the album.\n */\n constructor(id: string);\n\n /**\n * Unique identifier of the album.\n * Can be used to re-instantiate an {@link Album} later.\n */\n id: string;\n\n /**\n * Retrieves all assets contained in the album.\n * @returns A promise resolving to an array of {@link Asset} objects.\n *\n * @example\n * ```ts\n * const assets = await album.getAssets();\n * console.log(assets.length);\n * ```\n */\n getAssets(): Promise<Asset[]>;\n\n /**\n * Gets the display title (name) of the album.\n * Note that album titles are not guaranteed to be unique.\n * @returns A promise resolving to the album’s title string.\n *\n * @example\n * ```ts\n * const title = await album.getTitle();\n * console.log(title); // \"Camera\"\n * ```\n */\n getTitle(): Promise<string>;\n\n /**\n * Permanently deletes the album from the device.\n * On Android, it deletes the album and all its assets.\n * On iOS, it deletes the album but keeps the assets in the main library.\n * @returns A promise that resolves once the deletion has completed.\n * @throws An exception if the deletion fails or the album could not be found.\n *\n * @example\n * ```ts\n * await album.delete();\n * ```\n */\n delete(): Promise<void>;\n\n /**\n * Adds an asset to the album.\n * @param asset - The {@link Asset} to add.\n * @returns A promise that resolves once the asset has been added.\n *\n * @example\n * ```ts\n * const asset = await Asset.create(\"file:///path/to/photo.png\");\n * await album.add(asset);\n * ```\n */\n add(asset: Asset): Promise<void>;\n\n /**\n * A static function. Creates a new album with a given name and assets.\n * On Android, if assets are provided and `moveAssets` is true, the assets will be moved into the new album. If false or not supported, the assets will be copied.\n *\n * @param name - Name of the new album.\n * @param assetsRefs - List of {@link Asset} objects or file paths (file:///...) to include.\n * @param moveAssets - On Android, whether to move assets into the album.\n * @returns A promise resolving to the created {@link Album}.\n *\n * @example\n * ```ts\n * const album = await Album.create(\"My Album\", [asset]);\n * console.log(await album.getTitle()); // \"My Album\"\n * ```\n */\n static create(name: string, assetsRefs: string[] | Asset[], moveAssets: boolean): Promise<Album>;\n\n /**\n * A static function. Deletes multiple albums at once.\n * @param albums - An array of {@link Album} instances to delete.\n * @param deleteAssets - Whether to delete the assets in the albums as well.\n * @returns A promise that resolves once the albums have been deleted.\n *\n * @example\n * ```ts\n * const album = await Album.create(\"My Album\", [asset]);\n * await Album.delete([album]);\n * ```\n */\n static delete(albums: Album[], deleteAssets: boolean): Promise<void>;\n\n /**\n * A static function. Retrieves an album by its title.\n * @param title - The title of the album to retrieve.\n * @return A promise resolving to the {@link Album} if found, or `null` if not found.\n *\n * @example\n * ```ts\n * const album = await Album.get(\"Camera\");\n * if (album) {\n * console.log(await album.getTitle()); // \"Camera\"\n * }\n * ```\n */\n static get(title: string): Promise<Album | null>;\n}\n"]}