(source: ImageSource)
| 44 | configureCache(_: ImageCacheConfig): void {} |
| 45 | |
| 46 | async loadAsync(source: ImageSource): Promise<ImageRef> { |
| 47 | if (!source.uri) { |
| 48 | // TODO: Add support for sources without the uri, e.g. blurhash and thumbhash. |
| 49 | throw new Error('The image source must have the "uri" property defined'); |
| 50 | } |
| 51 | const response = await fetch(source.uri, { |
| 52 | headers: source.headers, |
| 53 | }); |
| 54 | |
| 55 | if (!response.ok) { |
| 56 | throw new Error(`Image request failed with the status code: ${response.status}`); |
| 57 | } |
| 58 | const blob = await response.blob(); |
| 59 | const imageObjectUrl = URL.createObjectURL(blob); |
| 60 | const image = await loadImageElementAsync(imageObjectUrl); |
| 61 | |
| 62 | return ImageRefWeb.init( |
| 63 | imageObjectUrl, |
| 64 | image.width, |
| 65 | image.height, |
| 66 | response.headers.get('Content-Type') |
| 67 | ); |
| 68 | } |
| 69 | |
| 70 | getCachePathAsync(_: string): Promise<string | null> { |
| 71 | return Promise.resolve(null); |
nothing calls this directly
no test coverage detected