-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathWebImageFactory.nitro.ts
More file actions
111 lines (98 loc) · 3.16 KB
/
WebImageFactory.nitro.ts
File metadata and controls
111 lines (98 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import type { Image, ImageLoader } from 'react-native-nitro-image'
import type { HybridObject } from 'react-native-nitro-modules'
export type AsyncImagePriority = 'low' | 'default' | 'high'
export interface AsyncImageLoadOptions {
/**
* Specifies the priority of the image download.
* @default 'default'
*/
priority?: AsyncImagePriority
/**
* Forces a cache refresh even if the URL is changed.
* Use this if you cannot make your URLs static.
* @default false
*/
forceRefresh?: boolean
/**
* A custom cache key to use for the image. By default, the URL is used as a cache key.
* For customized access control/caching, provide a custom cache key.
* @default The URL of the image.
*/
cacheKey?: string
/**
* Allows the Image download to continue even when the app is backgrounded.
* @default false
*/
continueInBackground?: boolean
/**
* Enable to allow untrusted SSL certificates.
* @default false
*/
allowInvalidSSLCertificates?: boolean
/**
* Scales down larger images to respect the device's memory constraints (max. 60 MB, or 4096x4096)
* @default false
*/
scaleDownLargeImages?: boolean
/**
* By default, cached images are queried from memory **asynchronously** to avoid UI lag.
* If this flag is enabled, images are queried **synchronously** from memory.
* @default false
*/
queryMemoryDataSync?: boolean
/**
* By default, cached images are queried from disk **asynchronously** to avoid UI lag.
* If this flag is enabled, images are queried **synchronously** from disk.
* @default false
*/
queryDiskDataSync?: boolean
/**
* By default, images are decoded from binary data to actual image representations.
* Disabling this might speed up downloads, but could increase memory usage.
* @default true
*/
decodeImage?: boolean
/**
* By default, images can be rendered using hardware textures,
* which is more efficient compared to a software implementation.
*
* If you run into issues with the hardware renderer, disable `allowHardware`.
* @platform Android
* @default true
*/
allowHardware?: boolean
/**
* By default, images are decoded and displayed once the entire
* image data has been fetched.
*
* To progressively display an image as it loads (web-style),
* enable {@linkcode progressive}.
* @platform iOS
* @default false
*/
progressive?: boolean
}
export interface WebImageFactory
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
/**
* Create a deferred {@linkcode ImageLoader} that loads the {@linkcode Image}
* from the given {@linkcode url}.
*/
createWebImageLoader(
url: string,
options?: AsyncImageLoadOptions,
): ImageLoader
/**
* Fetches data from the given {@linkcode url} and decode it into an {@linkcode Image}.
* This is async and can throw.
*/
loadFromURLAsync(url: string, options?: AsyncImageLoadOptions): Promise<Image>
/**
* Pre-loads the {@linkcode Image} at the given {@linkcode url}
* and store it in cache.
*
* If the preload succeeds, the next call to
* {@linkcode loadFromURLAsync} will be a cache hit.
*/
preload(url: string): void
}