@symbiote-native/media-library 0.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/LICENSE +21 -0
- package/README.md +284 -0
- package/build/angular/index.d.ts +1 -0
- package/build/angular/index.js +1 -0
- package/build/core/index.d.ts +3 -0
- package/build/core/index.js +3 -0
- package/build/core/media-library.d.ts +94 -0
- package/build/core/media-library.js +284 -0
- package/build/core/native-module.d.ts +29 -0
- package/build/core/native-module.js +3 -0
- package/build/core/types.d.ts +126 -0
- package/build/core/types.js +1 -0
- package/build/next/album.d.ts +9 -0
- package/build/next/album.js +12 -0
- package/build/next/asset.d.ts +13 -0
- package/build/next/asset.js +34 -0
- package/build/next/index.d.ts +24 -0
- package/build/next/index.js +44 -0
- package/build/next/native-module.d.ts +78 -0
- package/build/next/native-module.js +2 -0
- package/build/next/query.d.ts +13 -0
- package/build/next/query.js +16 -0
- package/build/next/types.d.ts +92 -0
- package/build/next/types.js +30 -0
- package/build-ngc/angular/index.d.ts +1 -0
- package/build-ngc/angular/index.js +2 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/next/album.d.ts +9 -0
- package/build-ngc/next/album.js +13 -0
- package/build-ngc/next/album.js.map +1 -0
- package/build-ngc/next/asset.d.ts +13 -0
- package/build-ngc/next/asset.js +35 -0
- package/build-ngc/next/asset.js.map +1 -0
- package/build-ngc/next/index.d.ts +24 -0
- package/build-ngc/next/index.js +45 -0
- package/build-ngc/next/index.js.map +1 -0
- package/build-ngc/next/native-module.d.ts +78 -0
- package/build-ngc/next/native-module.js +3 -0
- package/build-ngc/next/native-module.js.map +1 -0
- package/build-ngc/next/query.d.ts +13 -0
- package/build-ngc/next/query.js +17 -0
- package/build-ngc/next/query.js.map +1 -0
- package/build-ngc/next/types.d.ts +92 -0
- package/build-ngc/next/types.js +31 -0
- package/build-ngc/next/types.js.map +1 -0
- package/native-link.json +34 -0
- package/package.json +154 -0
- package/src/angular/index.ts +1 -0
- package/src/core/index.ts +7 -0
- package/src/core/media-library.ts +443 -0
- package/src/core/native-module.ts +80 -0
- package/src/core/types.ts +163 -0
- package/src/next/album.ts +13 -0
- package/src/next/asset.ts +51 -0
- package/src/next/index.ts +82 -0
- package/src/next/native-module.ts +116 -0
- package/src/next/query.ts +17 -0
- package/src/next/types.ts +106 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 A. Prokopenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# @symbiote-native/media-library
|
|
2
|
+
|
|
3
|
+
A wrapper package for [SymbioteNative](../../README.md) that makes
|
|
4
|
+
[`expo-media-library`](https://github.com/expo/expo/tree/main/packages/expo-media-library) usable
|
|
5
|
+
from **every** adapter — React, Vue, Svelte, Solid, and Angular.
|
|
6
|
+
|
|
7
|
+
**Both of upstream's surfaces are ported, matching upstream's own layout.** The default export is
|
|
8
|
+
the modern, shared-object API — `Query`/`Asset`/`Album` classes built on JSI shared objects
|
|
9
|
+
(`expo-modules-core`'s `SharedObject`), upstream's own default entry as of SDK 57. The legacy,
|
|
10
|
+
function-based API is available at the `./legacy` subpath, reachable in the real upstream package
|
|
11
|
+
as `expo-media-library/legacy`. See [Legacy API (`/legacy`)](#legacy-api-legacy) below.
|
|
12
|
+
|
|
13
|
+
Reads, saves, and organizes the device's photo/video library — assets, albums, permissions
|
|
14
|
+
(including the granular Android 13+ and limited-access iOS/Android 14+ pickers), and
|
|
15
|
+
library-change events.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
**New app:**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx @symbiote-native/cli new my-app --media-library
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Existing SymbioteNative app:**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx @symbiote-native/cli add --media-library
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Either way: installs `@symbiote-native/media-library` and wires the native autolinking
|
|
32
|
+
automatically — see [`@symbiote-native/cli`](../cli).
|
|
33
|
+
|
|
34
|
+
<details>
|
|
35
|
+
<summary>Manual install (no CLI — installing and wiring native autolinking by hand)</summary>
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @symbiote-native/media-library
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`expo-media-library` and `expo-modules-core` come along as regular dependencies, pinned to exact
|
|
42
|
+
versions — never install them yourself, and never add the `expo` meta-package to your project.
|
|
43
|
+
|
|
44
|
+
## Required one-time step: native autolinking wiring
|
|
45
|
+
|
|
46
|
+
Same one-time step as every other `expo-modules-core` package this project ships — see
|
|
47
|
+
[`@symbiote-native/local-auth`'s README](../local-auth/README.md#required-one-time-step-native-autolinking-wiring)
|
|
48
|
+
and the `symbiote-expo-native-module` project skill.
|
|
49
|
+
|
|
50
|
+
`native-link.json` declares two iOS `Info.plist` usage-description keys
|
|
51
|
+
(`NSPhotoLibraryUsageDescription`, `NSPhotoLibraryAddUsageDescription`) with generic default
|
|
52
|
+
text — override either by setting the same key yourself before or after install
|
|
53
|
+
(`@symbiote-native/expo-modules-link`'s patcher is additive-only). It also sets
|
|
54
|
+
`android:requestLegacyExternalStorage="true"` on your app's `<application>` tag — required by
|
|
55
|
+
upstream's own config plugin for scoped-storage compatibility on Android 10+.
|
|
56
|
+
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
**Android runtime permissions are NOT added automatically, by the CLI or otherwise** — add
|
|
60
|
+
whichever of these your app actually needs to your own `AndroidManifest.xml`, the same opt-in
|
|
61
|
+
shape [`@symbiote-native/location`](../location) uses for background location:
|
|
62
|
+
|
|
63
|
+
```xml
|
|
64
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
65
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
66
|
+
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
|
|
67
|
+
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
|
68
|
+
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
|
69
|
+
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
|
70
|
+
<!-- only if reading GPS location out of an asset's EXIF data -->
|
|
71
|
+
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`READ_MEDIA_IMAGES`/`READ_MEDIA_VIDEO`/`READ_MEDIA_AUDIO` are the granular Android 13+
|
|
75
|
+
permissions — pass the matching subset as `requestPermissionsAsync(false, [...])`'s second
|
|
76
|
+
argument; omitting one here means Android silently refuses that grant regardless of what the app
|
|
77
|
+
asks for at runtime.
|
|
78
|
+
|
|
79
|
+
## Shape
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
src/next/ query.ts / asset.ts / album.ts (Query/Asset/Album shared-object classes) /
|
|
83
|
+
native-module.ts / types.ts — the default, shared-object surface. See "API" below.
|
|
84
|
+
src/core/ media-library.ts (every legacy function + the three useXPermissions hooks),
|
|
85
|
+
native-module.ts, types.ts. See "Legacy API" below.
|
|
86
|
+
src/angular/ @symbiote-native/media-library/angular — export * from '../next'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`./react`, `./vue`, `./svelte`, and `./solid` are `exports`-map aliases straight onto `src/next/`
|
|
90
|
+
— `Query`/`Asset`/`Album` carry no children/ref/render fields, so there is nothing to split per
|
|
91
|
+
framework. `./angular` stays a physical file/subpath since Angular ships through a separate
|
|
92
|
+
`ngc`/AOT build (`build-ngc/`). `./legacy` is one subpath shared by every adapter, for the same
|
|
93
|
+
reason — plain async functions have no framework-specific shape either.
|
|
94
|
+
|
|
95
|
+
## Use it
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import {
|
|
99
|
+
Query,
|
|
100
|
+
Asset,
|
|
101
|
+
Album,
|
|
102
|
+
AssetField,
|
|
103
|
+
requestPermissionsAsync,
|
|
104
|
+
} from '@symbiote-native/media-library';
|
|
105
|
+
|
|
106
|
+
const { granted } = await requestPermissionsAsync(false, ['photo']);
|
|
107
|
+
if (granted) {
|
|
108
|
+
const asset = await Asset.create(photoUri);
|
|
109
|
+
const album = await Album.create('My Album', [asset]);
|
|
110
|
+
|
|
111
|
+
const recentPhotos = await new Query()
|
|
112
|
+
.eq(AssetField.MEDIA_TYPE, 'image' as never)
|
|
113
|
+
.orderBy(AssetField.CREATION_TIME)
|
|
114
|
+
.limit(20)
|
|
115
|
+
.exe();
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Identical import surface on every adapter — `@symbiote-native/media-library/react`, `/vue`,
|
|
120
|
+
`/svelte`, `/solid`, `/angular` all re-export the same classes.
|
|
121
|
+
|
|
122
|
+
## API
|
|
123
|
+
|
|
124
|
+
### `Query`
|
|
125
|
+
|
|
126
|
+
Builder pattern — every filter/sort method returns the same instance for chaining.
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
new Query()
|
|
130
|
+
.eq(field, value) / .within(field, value[]) / .gt(field, value) / .gte(field, value) /
|
|
131
|
+
.lt(field, value) / .lte(field, value) // AssetField-keyed filters
|
|
132
|
+
.limit(n) / .offset(n)
|
|
133
|
+
.orderBy(sortDescriptor | AssetField)
|
|
134
|
+
.album(album: Album)
|
|
135
|
+
.exe(): Promise<Asset[]>
|
|
136
|
+
.exeForMetadata(): Promise<AssetMetadata[]> // lightweight fields only
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### `Asset`
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
new Asset(id: string)
|
|
143
|
+
static create(filePath, album?): Promise<Asset>
|
|
144
|
+
static delete(assets: Asset[]): Promise<void>
|
|
145
|
+
|
|
146
|
+
.id
|
|
147
|
+
.getCreationTime() / .getModificationTime(): Promise<number | null>
|
|
148
|
+
.getDuration(): Promise<number | null> // audio/video only
|
|
149
|
+
.getFilename() / .getUri(): Promise<string>
|
|
150
|
+
.getWidth() / .getHeight(): Promise<number>
|
|
151
|
+
.getMediaType(): Promise<MediaType>
|
|
152
|
+
.getShape(): Promise<Shape | null>
|
|
153
|
+
.getInfo(): Promise<AssetInfo>
|
|
154
|
+
.getAlbums(): Promise<Album[]>
|
|
155
|
+
.getLocation(): Promise<Location | null> // android needs ACCESS_MEDIA_LOCATION
|
|
156
|
+
.getExif(): Promise<Record<string, unknown>>
|
|
157
|
+
.getFavorite(): Promise<boolean> / .setFavorite(isFavorite): Promise<void>
|
|
158
|
+
.delete(): Promise<void>
|
|
159
|
+
.getMediaSubtypes(): Promise<MediaSubtype[]> // ios only
|
|
160
|
+
.getLivePhotoVideoUri(): Promise<string | null> // ios only
|
|
161
|
+
.getIsInCloud(): Promise<boolean> // ios only
|
|
162
|
+
.getOrientation(): Promise<number | null> // ios only
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### `Album`
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
new Album(id: string)
|
|
169
|
+
static create(name, assetsRefs, moveAssets?): Promise<Album>
|
|
170
|
+
static delete(albums: Album[], deleteAssets?): Promise<void>
|
|
171
|
+
static get(title): Promise<Album | null>
|
|
172
|
+
static getAll(): Promise<Album[]>
|
|
173
|
+
|
|
174
|
+
.id
|
|
175
|
+
.getAssets(): Promise<Asset[]>
|
|
176
|
+
.getTitle(): Promise<string>
|
|
177
|
+
.add(assets: Asset | Asset[]): Promise<void>
|
|
178
|
+
.removeAssets(assets: Asset[]): Promise<void> // ios only
|
|
179
|
+
.delete(): Promise<void>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Permissions and change events
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
requestPermissionsAsync(writeOnly?, granularPermissions?) /
|
|
186
|
+
getPermissionsAsync(writeOnly?, granularPermissions?): Promise<PermissionResponse>
|
|
187
|
+
usePermissions(options?)
|
|
188
|
+
presentPermissionsPicker(mediaTypes?): Promise<void> // android 14+ / ios
|
|
189
|
+
addListener(listener) / removeAllListeners(): void
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Plus `AssetField`, `MediaType`, `MediaSubtype` runtime enums and every `I*` type, ported from
|
|
193
|
+
upstream's default-entry types with this repo's `I`-prefix convention for exported types
|
|
194
|
+
(`ts-js-best-practices`).
|
|
195
|
+
|
|
196
|
+
### Errors
|
|
197
|
+
|
|
198
|
+
No custom JS error-class hierarchy — every native exception surfaces as an ordinary thrown `Error`
|
|
199
|
+
or rejected `Promise`, same as every other native module wrapper in this repo.
|
|
200
|
+
|
|
201
|
+
| Trigger | When |
|
|
202
|
+
| ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
203
|
+
| Calling an `Asset`/`Album` method on an ID that no longer exists on the device | Native `Exception` — "could not be found" |
|
|
204
|
+
| `Asset.getMediaSubtypes()`/`.getLivePhotoVideoUri()`/`.getIsInCloud()`/`.getOrientation()` on Android | `UnavailabilityError` — thrown synchronously, iOS only |
|
|
205
|
+
| `Album.removeAssets()` on Android | Native `Exception` — an Android asset belongs to one album; delete it or add it to another instead |
|
|
206
|
+
| `getLocation()` on Android without `ACCESS_MEDIA_LOCATION` | Rejects — needs that runtime permission |
|
|
207
|
+
|
|
208
|
+
## Legacy API (`/legacy`)
|
|
209
|
+
|
|
210
|
+
Upstream's original function-based surface — plain async functions over `expo-modules-core`
|
|
211
|
+
instead of JSI shared objects.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
import {
|
|
215
|
+
requestPermissionsAsync,
|
|
216
|
+
createAssetAsync,
|
|
217
|
+
getAssetsAsync,
|
|
218
|
+
addListener,
|
|
219
|
+
} from '@symbiote-native/media-library/legacy';
|
|
220
|
+
|
|
221
|
+
const { granted } = await requestPermissionsAsync(false, ['photo']);
|
|
222
|
+
if (granted) {
|
|
223
|
+
const asset = await createAssetAsync(photoUri);
|
|
224
|
+
const page = await getAssetsAsync({ first: 20, mediaType: 'photo' });
|
|
225
|
+
|
|
226
|
+
const subscription = addListener(event => {
|
|
227
|
+
console.log('library changed', event.hasIncrementalChanges);
|
|
228
|
+
});
|
|
229
|
+
// later: subscription.remove();
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Legacy API reference
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
isAvailableAsync(): Promise<boolean>
|
|
237
|
+
requestPermissionsAsync(writeOnly?, granularPermissions?) / getPermissionsAsync(writeOnly?, granularPermissions?): Promise<IMediaLibraryPermissionResponse>
|
|
238
|
+
usePermissions(options?)
|
|
239
|
+
presentPermissionsPickerAsync(mediaTypes?): Promise<void> // android 14+ / ios
|
|
240
|
+
createAssetAsync(localUri, album?): Promise<IMediaLibraryAsset>
|
|
241
|
+
saveToLibraryAsync(localUri): Promise<void>
|
|
242
|
+
addAssetsToAlbumAsync(assets, album, copy?): Promise<boolean>
|
|
243
|
+
removeAssetsFromAlbumAsync(assets, album): Promise<boolean>
|
|
244
|
+
deleteAssetsAsync(assets): Promise<boolean>
|
|
245
|
+
getAssetInfoAsync(asset, options?): Promise<IMediaLibraryAssetInfo>
|
|
246
|
+
getAssetContentUriAsync(asset): Promise<string> // android
|
|
247
|
+
getAlbumsAsync(options?) / getAlbumAsync(title): Promise<IMediaLibraryAlbum[] | IMediaLibraryAlbum>
|
|
248
|
+
createAlbumAsync(albumName, asset?, copyAsset?, initialAssetLocalUri?): Promise<IMediaLibraryAlbum>
|
|
249
|
+
deleteAlbumsAsync(albums, deleteAssets?): Promise<boolean>
|
|
250
|
+
getAssetsAsync(options?): Promise<IMediaLibraryPagedInfo<IMediaLibraryAsset>>
|
|
251
|
+
addListener(listener) / removeAllListeners(): void
|
|
252
|
+
getMomentsAsync(): Promise<IMediaLibraryAlbum[]> // ios
|
|
253
|
+
migrateAlbumIfNeededAsync(album) / albumNeedsMigrationAsync(album): Promise<void | boolean> // android R+
|
|
254
|
+
setAssetFavoriteAsync(asset, isFavorite): Promise<boolean> // ios
|
|
255
|
+
MediaType, SortBy // runtime constants, from native
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Plus every `IMediaLibrary*` type, ported from upstream's `legacy/MediaLibrary.ts` with this
|
|
259
|
+
repo's `I`-prefix convention for exported types (`ts-js-best-practices`).
|
|
260
|
+
|
|
261
|
+
### Legacy notes
|
|
262
|
+
|
|
263
|
+
- **`sortBy`'s single-tuple form must be double-nested — an upstream quirk, ported verbatim.**
|
|
264
|
+
`getAssetsAsync({ sortBy: [['creationTime', true]] })` sorts by one key ascending; the
|
|
265
|
+
unnested `sortBy: ['creationTime', true]` is read as two independent (and here, invalid) sort
|
|
266
|
+
keys, because upstream's own `arrayize()` helper passes any array through unchanged rather than
|
|
267
|
+
distinguishing "one tuple" from "several keys". See `media-library.test.ts` and the
|
|
268
|
+
`UPSTREAM-BUG` comment on `getAssetsAsync`.
|
|
269
|
+
- **`getAssetContentUriAsync` is Android-only** — a plain `content://` URI, still useful even
|
|
270
|
+
though the modern `Asset`/`Query` API above ports the shared-object surface it used to bridge to.
|
|
271
|
+
- **`getMomentsAsync` and `setAssetFavoriteAsync` are iOS-only**; `getAssetContentUriAsync`,
|
|
272
|
+
`migrateAlbumIfNeededAsync`, and `albumNeedsMigrationAsync` are Android-only or Android-R+-only.
|
|
273
|
+
Each throws (or, for the migration pair, resolves a safe default) on the wrong platform, matching
|
|
274
|
+
upstream.
|
|
275
|
+
- **No Expo Go warning.** Upstream logs a one-time console warning about reduced Expo Go
|
|
276
|
+
permissions; this project never runs under Expo Go (`<examples_vs_dot_examples>` in root
|
|
277
|
+
CLAUDE.md), so the check and the warning are dropped rather than ported.
|
|
278
|
+
|
|
279
|
+
## Test it
|
|
280
|
+
|
|
281
|
+
No Fabric/Descriptor angle at all — every function here is a pure async-function surface plus one
|
|
282
|
+
native change-event listener, never a view or per-instance state. Tests inject a fake native-module
|
|
283
|
+
object in place of the real `requireNativeModule` resolution and fire the wired listener directly
|
|
284
|
+
(`src/core/media-library.test.ts`, `src/next/next.test.ts`) — no `installFabric()`, no ViewConfig.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../next';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../next/index.js';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { IGranularPermission, IMediaLibraryAlbum, IMediaLibraryAlbumRef, IMediaLibraryAlbumsOptions, IMediaLibraryAsset, IMediaLibraryAssetInfo, IMediaLibraryAssetInfoQueryOptions, IMediaLibraryAssetRef, IMediaLibraryAssetsChangeEvent, IMediaLibraryAssetsOptions, IMediaLibraryMediaTypeObject, IMediaLibraryMediaTypeFilter, IMediaLibraryPagedInfo, IMediaLibraryPermissionResponse, IMediaLibrarySortByObject } from './types';
|
|
2
|
+
export declare const MediaType: IMediaLibraryMediaTypeObject;
|
|
3
|
+
export declare const SortBy: IMediaLibrarySortByObject;
|
|
4
|
+
export declare function isAvailableAsync(): Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* @param granularPermissions Only has an effect on Android 13+. Defaults to every possible
|
|
7
|
+
* permission — make sure your app manifest requests everything you pass here.
|
|
8
|
+
*/
|
|
9
|
+
export declare function requestPermissionsAsync(writeOnly?: boolean, granularPermissions?: IGranularPermission[]): Promise<IMediaLibraryPermissionResponse>;
|
|
10
|
+
export declare function getPermissionsAsync(writeOnly?: boolean, granularPermissions?: IGranularPermission[]): Promise<IMediaLibraryPermissionResponse>;
|
|
11
|
+
type IMediaLibraryPermissionHookOptions = {
|
|
12
|
+
writeOnly?: boolean;
|
|
13
|
+
granularPermissions?: IGranularPermission[];
|
|
14
|
+
};
|
|
15
|
+
export declare const usePermissions: (options?: import("expo-modules-core").PermissionHookOptions<IMediaLibraryPermissionHookOptions> | undefined) => [IMediaLibraryPermissionResponse | null, () => Promise<IMediaLibraryPermissionResponse>, () => Promise<IMediaLibraryPermissionResponse>];
|
|
16
|
+
/**
|
|
17
|
+
* Lets the user update which assets your app has access to. Only a no-op unless the user
|
|
18
|
+
* previously granted `'limited'` access.
|
|
19
|
+
* @platform android 14+
|
|
20
|
+
* @platform ios
|
|
21
|
+
*/
|
|
22
|
+
export declare function presentPermissionsPickerAsync(mediaTypes?: IMediaLibraryMediaTypeFilter[]): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an asset from an existing local file — the common case is a picture just taken by a
|
|
25
|
+
* camera. Requires write permission.
|
|
26
|
+
* @param localUri Must contain an extension. On Android it must be a local path (`file:///…`).
|
|
27
|
+
* @param album If provided, the asset is added to this album on creation.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createAssetAsync(localUri: string, album?: IMediaLibraryAlbumRef): Promise<IMediaLibraryAsset>;
|
|
30
|
+
/**
|
|
31
|
+
* Saves the file at `localUri` to the user's library. Unlike `createAssetAsync`, does not
|
|
32
|
+
* return the created asset. On iOS 11+ this can be called without the read/write permission as
|
|
33
|
+
* long as `Info.plist` carries `NSPhotoLibraryAddUsageDescription`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function saveToLibraryAsync(localUri: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* On Android, copies assets from their current album into the given one by default — pass
|
|
38
|
+
* `copy: false` to move them instead. Copied assets show up twice in `getAssetsAsync`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function addAssetsToAlbumAsync(assets: IMediaLibraryAssetRef[] | IMediaLibraryAssetRef, album: IMediaLibraryAlbumRef, copy?: boolean): Promise<boolean>;
|
|
41
|
+
/** On Android, an empty album is deleted automatically once its last asset is removed. */
|
|
42
|
+
export declare function removeAssetsFromAlbumAsync(assets: IMediaLibraryAssetRef[] | IMediaLibraryAssetRef, album: IMediaLibraryAlbumRef): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* iOS removes the asset from every album it belongs to (behind a system confirmation dialog);
|
|
45
|
+
* Android keeps other albums' copies (an asset is strictly tied to one album there).
|
|
46
|
+
*/
|
|
47
|
+
export declare function deleteAssetsAsync(assets: IMediaLibraryAssetRef[] | IMediaLibraryAssetRef): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* GPS location, local URI and EXIF metadata. Prefer this only when you need more than the
|
|
50
|
+
* fields already on `Asset` — it costs more than a plain list query.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getAssetInfoAsync(asset: IMediaLibraryAssetRef, options?: IMediaLibraryAssetInfoQueryOptions): Promise<IMediaLibraryAssetInfo>;
|
|
53
|
+
/** @platform android */
|
|
54
|
+
export declare function getAssetContentUriAsync(asset: IMediaLibraryAssetRef): Promise<string>;
|
|
55
|
+
/**
|
|
56
|
+
* @return Depending on Android version, the root storage directory may be listed as an album
|
|
57
|
+
* titled `"0"`, or not listed at all.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getAlbumsAsync({ includeSmartAlbums, }?: IMediaLibraryAlbumsOptions): Promise<IMediaLibraryAlbum[]>;
|
|
60
|
+
export declare function getAlbumAsync(title: string): Promise<IMediaLibraryAlbum>;
|
|
61
|
+
/**
|
|
62
|
+
* `asset` (or `initialAssetLocalUri`) is required on Android — an empty album cannot be
|
|
63
|
+
* created on that platform.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createAlbumAsync(albumName: string, asset?: IMediaLibraryAssetRef, copyAsset?: boolean, initialAssetLocalUri?: string): Promise<IMediaLibraryAlbum>;
|
|
66
|
+
/**
|
|
67
|
+
* iOS keeps the assets in the main library unless `deleteAssets` is set; Android always drops
|
|
68
|
+
* an album's assets along with it.
|
|
69
|
+
*/
|
|
70
|
+
export declare function deleteAlbumsAsync(albums: IMediaLibraryAlbumRef[] | IMediaLibraryAlbumRef, deleteAssets?: boolean): Promise<boolean>;
|
|
71
|
+
export declare function getAssetsAsync(assetsOptions?: IMediaLibraryAssetsOptions): Promise<IMediaLibraryPagedInfo<IMediaLibraryAsset>>;
|
|
72
|
+
/**
|
|
73
|
+
* @param listener Fired on Android with an empty object; on iOS with a real
|
|
74
|
+
* `MediaLibraryAssetsChangeEvent`, and also whenever the user updates per-asset access via
|
|
75
|
+
* `presentPermissionsPickerAsync()`.
|
|
76
|
+
*/
|
|
77
|
+
export declare function addListener(listener: (event: IMediaLibraryAssetsChangeEvent) => void): import("expo-modules-core").EventSubscription;
|
|
78
|
+
export declare function removeAllListeners(): void;
|
|
79
|
+
/**
|
|
80
|
+
* A "moment" is a group of assets taken around the same place and time.
|
|
81
|
+
* @platform ios
|
|
82
|
+
*/
|
|
83
|
+
export declare function getMomentsAsync(): Promise<IMediaLibraryAlbum[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Moves an album's content into the scoped-storage media directories, only where needed
|
|
86
|
+
* (Android R+, and only if the app lacks write permission to the album folder). No-op on iOS,
|
|
87
|
+
* web, and Android below R, or if the app already has write access.
|
|
88
|
+
*/
|
|
89
|
+
export declare function migrateAlbumIfNeededAsync(album: IMediaLibraryAlbumRef): Promise<void>;
|
|
90
|
+
/** Always `false` on iOS, web, and Android below R. */
|
|
91
|
+
export declare function albumNeedsMigrationAsync(album: IMediaLibraryAlbumRef): Promise<boolean>;
|
|
92
|
+
/** Adds or removes the asset from the system "Favorites" smart album. @platform ios */
|
|
93
|
+
export declare function setAssetFavoriteAsync(asset: IMediaLibraryAssetRef, isFavorite: boolean): Promise<boolean>;
|
|
94
|
+
export {};
|