react-native-fast-image 9.0.3 → 9.2.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/README.md +14 -6
- package/android/build.gradle +12 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageGlide.java +7 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java +23 -156
- package/android/src/main/java/com/dylanvann/fastimage/FastImageProgressListener.java +4 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageRequestListener.java +1 -4
- package/android/src/main/java/com/dylanvann/fastimage/FastImageSharedDownloads.java +948 -196
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java +128 -28
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java +44 -22
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java +85 -60
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.flow +4 -2
- package/dist/index.cjs.web.js +2 -2
- package/dist/index.cjs.web.js.flow +4 -2
- package/dist/index.d.ts +33 -7
- package/dist/index.js +2 -2
- package/dist/index.js.flow +4 -2
- package/dist/index.web.js +2 -2
- package/dist/index.web.js.flow +4 -2
- package/ios/FastImage/FFFastImageViewManager.m +2 -2
- package/package.json +1 -1
|
@@ -73,6 +73,8 @@ export type CachePathResult =
|
|
|
73
73
|
| {| ok: true, path: string |}
|
|
74
74
|
| {| ok: false, error: string |}
|
|
75
75
|
|
|
76
|
+
export type ClearCacheResult = {| ok: true |} | {| ok: false, error: string |}
|
|
77
|
+
|
|
76
78
|
export type Transition = $ReadOnly<{|
|
|
77
79
|
duration?: ?number,
|
|
78
80
|
betweenImages?: ?boolean,
|
|
@@ -147,8 +149,8 @@ declare export default class FastImage extends React$Component<FastImageProps> {
|
|
|
147
149
|
static priority: Priority;
|
|
148
150
|
static cacheControl: CacheControl;
|
|
149
151
|
static preload: PreloadFn;
|
|
150
|
-
static clearMemoryCache: () => Promise<
|
|
151
|
-
static clearDiskCache: () => Promise<
|
|
152
|
+
static clearMemoryCache: () => Promise<ClearCacheResult>;
|
|
153
|
+
static clearDiskCache: () => Promise<ClearCacheResult>;
|
|
152
154
|
static getCachePath: (source: FastImageSource) => Promise<CachePathResult>;
|
|
153
155
|
static configureCache: (limits?: CacheLimits) => Promise<CacheState>;
|
|
154
156
|
static writeToCache: (
|
package/dist/index.d.ts
CHANGED
|
@@ -208,6 +208,16 @@ export type CachePathResult = {
|
|
|
208
208
|
ok: false;
|
|
209
209
|
error: string;
|
|
210
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* `clearMemoryCache`'s and `clearDiskCache`'s result: `ok` once the cache is
|
|
213
|
+
* cleared, or not `ok` with the error.
|
|
214
|
+
*/
|
|
215
|
+
export type ClearCacheResult = {
|
|
216
|
+
ok: true;
|
|
217
|
+
} | {
|
|
218
|
+
ok: false;
|
|
219
|
+
error: string;
|
|
220
|
+
};
|
|
211
221
|
/**
|
|
212
222
|
* `onProgress`'s event: `nativeEvent` has the bytes `loaded` and the `total`,
|
|
213
223
|
* and `progress`, `loaded / total` from 0 to 1.
|
|
@@ -454,7 +464,9 @@ export interface FastImageProps extends AccessibilityProps, ViewProps {
|
|
|
454
464
|
onLoad?(event: OnLoadEvent): void;
|
|
455
465
|
/**
|
|
456
466
|
* Called on an image fetching error, with a message describing it (e.g.
|
|
457
|
-
* the HTTP status code).
|
|
467
|
+
* the HTTP status code). On iOS and Android, a download that gets nothing
|
|
468
|
+
* from the server for 15 seconds fails too (on Android, unless the app's
|
|
469
|
+
* OkHttp client has timeouts of its own).
|
|
458
470
|
*
|
|
459
471
|
* @example
|
|
460
472
|
* ```jsx
|
|
@@ -529,8 +541,18 @@ export interface FastImageStaticProperties {
|
|
|
529
541
|
priority: typeof priority;
|
|
530
542
|
cacheControl: typeof cacheControl;
|
|
531
543
|
preload: (sources: Source[]) => Promise<PreloadResult[]>;
|
|
532
|
-
|
|
533
|
-
|
|
544
|
+
/**
|
|
545
|
+
* Removes every image from the memory cache. Resolves once it's done, or
|
|
546
|
+
* not `ok` with the error if it couldn't (Android: Glide failed to
|
|
547
|
+
* start). Never rejects.
|
|
548
|
+
*/
|
|
549
|
+
clearMemoryCache: () => Promise<ClearCacheResult>;
|
|
550
|
+
/**
|
|
551
|
+
* Removes every image from the disk cache, and the HTTP cache of
|
|
552
|
+
* `cache: 'web'` images. Resolves once it's done, or not `ok` with the
|
|
553
|
+
* error if it couldn't (Android: Glide failed to start). Never rejects.
|
|
554
|
+
*/
|
|
555
|
+
clearDiskCache: () => Promise<ClearCacheResult>;
|
|
534
556
|
/**
|
|
535
557
|
* The path of the source's downloaded file in the disk cache, downloading
|
|
536
558
|
* it first if it isn't there (without decoding it). With
|
|
@@ -550,10 +572,14 @@ export interface FastImageStaticProperties {
|
|
|
550
572
|
/**
|
|
551
573
|
* Changes the cache's limits at runtime (only those given; 0 for no
|
|
552
574
|
* limit, null to go back to the app's native config) and saves them, then
|
|
553
|
-
* resolves with the limits in effect and the disk cache's size
|
|
554
|
-
* limits, only resolves. iOS applies changes at once.
|
|
555
|
-
* `maxDiskSize`, applied when Glide starts: at once if
|
|
556
|
-
*
|
|
575
|
+
* resolves with the limits in effect and the disk cache's size; without
|
|
576
|
+
* limits, it only resolves with them. iOS applies changes at once.
|
|
577
|
+
* Android only has `maxDiskSize`, applied when Glide starts: at once if
|
|
578
|
+
* it hasn't started yet in this launch, otherwise from the next launch.
|
|
579
|
+
* FastImage starts it when its first view is created (before the view has
|
|
580
|
+
* a source), and for `preload`, `getCachePath`, `writeToCache`,
|
|
581
|
+
* `clearDiskCache` and `configureCache` itself, even without limits (e.g.
|
|
582
|
+
* to read the disk cache's size).
|
|
557
583
|
*/
|
|
558
584
|
configureCache: (limits?: CacheLimits) => Promise<CacheState>;
|
|
559
585
|
}
|
package/dist/index.js
CHANGED
|
@@ -218,8 +218,8 @@ FastImage.preload = (sources) => Promise.resolve(NativeModules.FastImageView.pre
|
|
|
218
218
|
uri
|
|
219
219
|
};
|
|
220
220
|
}));
|
|
221
|
-
FastImage.clearMemoryCache = () => NativeModules.FastImageView.clearMemoryCache();
|
|
222
|
-
FastImage.clearDiskCache = () => NativeModules.FastImageView.clearDiskCache();
|
|
221
|
+
FastImage.clearMemoryCache = () => Promise.resolve(NativeModules.FastImageView.clearMemoryCache());
|
|
222
|
+
FastImage.clearDiskCache = () => Promise.resolve(NativeModules.FastImageView.clearDiskCache());
|
|
223
223
|
FastImage.configureCache = (limits = {}) => Promise.resolve(NativeModules.FastImageView.configureCache(limits));
|
|
224
224
|
FastImage.writeToCache = (source, file) => Array.isArray(source) ? Promise.resolve({
|
|
225
225
|
ok: false,
|
package/dist/index.js.flow
CHANGED
|
@@ -73,6 +73,8 @@ export type CachePathResult =
|
|
|
73
73
|
| {| ok: true, path: string |}
|
|
74
74
|
| {| ok: false, error: string |}
|
|
75
75
|
|
|
76
|
+
export type ClearCacheResult = {| ok: true |} | {| ok: false, error: string |}
|
|
77
|
+
|
|
76
78
|
export type Transition = $ReadOnly<{|
|
|
77
79
|
duration?: ?number,
|
|
78
80
|
betweenImages?: ?boolean,
|
|
@@ -147,8 +149,8 @@ declare export default class FastImage extends React$Component<FastImageProps> {
|
|
|
147
149
|
static priority: Priority;
|
|
148
150
|
static cacheControl: CacheControl;
|
|
149
151
|
static preload: PreloadFn;
|
|
150
|
-
static clearMemoryCache: () => Promise<
|
|
151
|
-
static clearDiskCache: () => Promise<
|
|
152
|
+
static clearMemoryCache: () => Promise<ClearCacheResult>;
|
|
153
|
+
static clearDiskCache: () => Promise<ClearCacheResult>;
|
|
152
154
|
static getCachePath: (source: FastImageSource) => Promise<CachePathResult>;
|
|
153
155
|
static configureCache: (limits?: CacheLimits) => Promise<CacheState>;
|
|
154
156
|
static writeToCache: (
|
package/dist/index.web.js
CHANGED
|
@@ -212,8 +212,8 @@ FastImage.preload = (sources) => Promise.all(sources.map((source) => {
|
|
|
212
212
|
uri
|
|
213
213
|
}));
|
|
214
214
|
}));
|
|
215
|
-
FastImage.clearMemoryCache = () => Promise.resolve();
|
|
216
|
-
FastImage.clearDiskCache = () => Promise.resolve();
|
|
215
|
+
FastImage.clearMemoryCache = () => Promise.resolve(notSupported);
|
|
216
|
+
FastImage.clearDiskCache = () => Promise.resolve(notSupported);
|
|
217
217
|
FastImage.configureCache = () => Promise.resolve({});
|
|
218
218
|
FastImage.writeToCache = () => Promise.resolve(notSupported);
|
|
219
219
|
FastImage.getCachePath = () => Promise.resolve(notSupported);
|
package/dist/index.web.js.flow
CHANGED
|
@@ -73,6 +73,8 @@ export type CachePathResult =
|
|
|
73
73
|
| {| ok: true, path: string |}
|
|
74
74
|
| {| ok: false, error: string |}
|
|
75
75
|
|
|
76
|
+
export type ClearCacheResult = {| ok: true |} | {| ok: false, error: string |}
|
|
77
|
+
|
|
76
78
|
export type Transition = $ReadOnly<{|
|
|
77
79
|
duration?: ?number,
|
|
78
80
|
betweenImages?: ?boolean,
|
|
@@ -147,8 +149,8 @@ declare export default class FastImage extends React$Component<FastImageProps> {
|
|
|
147
149
|
static priority: Priority;
|
|
148
150
|
static cacheControl: CacheControl;
|
|
149
151
|
static preload: PreloadFn;
|
|
150
|
-
static clearMemoryCache: () => Promise<
|
|
151
|
-
static clearDiskCache: () => Promise<
|
|
152
|
+
static clearMemoryCache: () => Promise<ClearCacheResult>;
|
|
153
|
+
static clearDiskCache: () => Promise<ClearCacheResult>;
|
|
152
154
|
static getCachePath: (source: FastImageSource) => Promise<CachePathResult>;
|
|
153
155
|
static configureCache: (limits?: CacheLimits) => Promise<CacheState>;
|
|
154
156
|
static writeToCache: (
|
|
@@ -467,7 +467,7 @@ RCT_EXPORT_METHOD(configureCache:(NSDictionary *)limits
|
|
|
467
467
|
RCT_EXPORT_METHOD(clearMemoryCache:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
468
468
|
{
|
|
469
469
|
[SDImageCache.sharedImageCache clearMemory];
|
|
470
|
-
resolve(
|
|
470
|
+
resolve(@{@"ok": @YES});
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
RCT_EXPORT_METHOD(clearDiskCache:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
@@ -475,7 +475,7 @@ RCT_EXPORT_METHOD(clearDiskCache:(RCTPromiseResolveBlock)resolve reject:(RCTProm
|
|
|
475
475
|
// And the HTTP cache of `cache: 'web'` images.
|
|
476
476
|
[FFFastImageSource.webURLCache removeAllCachedResponses];
|
|
477
477
|
[SDImageCache.sharedImageCache clearDiskOnCompletion:^(){
|
|
478
|
-
resolve(
|
|
478
|
+
resolve(@{@"ok": @YES});
|
|
479
479
|
}];
|
|
480
480
|
}
|
|
481
481
|
|