react-native-fast-image 9.0.2 → 9.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/README.md +12 -4
- package/android/src/main/java/com/dylanvann/fastimage/FastImageGlide.java +7 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java +12 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java +35 -16
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java +17 -1
- package/dist/index.cjs.js +22 -4
- 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 +30 -6
- package/dist/index.js +22 -4
- 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
package/README.md
CHANGED
|
@@ -539,15 +539,15 @@ await FastImage.preload(photos.map((uri) => ({ uri, memoryCache: false })))
|
|
|
539
539
|
|
|
540
540
|
### `clearMemoryCache()`
|
|
541
541
|
|
|
542
|
-
**Returns:** `Promise<
|
|
542
|
+
**Returns:** `Promise<ClearCacheResult>`
|
|
543
543
|
|
|
544
|
-
Removes every image from the memory cache, e.g. to free memory. They're decoded from the disk cache again when they're next shown.
|
|
544
|
+
Removes every image from the memory cache, e.g. to free memory. They're decoded from the disk cache again when they're next shown. Resolves with `{ ok: true }` once it's done, or `{ ok: false, error }` if it couldn't (Android: Glide failed to start). Never rejects. On the web, it does nothing (the browser manages its cache) and resolves with an error.
|
|
545
545
|
|
|
546
546
|
### `clearDiskCache()`
|
|
547
547
|
|
|
548
|
-
**Returns:** `Promise<
|
|
548
|
+
**Returns:** `Promise<ClearCacheResult>`
|
|
549
549
|
|
|
550
|
-
Removes every image from the disk cache, including the HTTP cache of `cache: 'web'` images, e.g. when a user logs out. They're downloaded again when they're next shown. There's no way to remove a single image: to load one again after it changed, change its [`cacheKey`](#sourcecachekey).
|
|
550
|
+
Removes every image from the disk cache, including the HTTP cache of `cache: 'web'` images, e.g. when a user logs out. They're downloaded again when they're next shown. There's no way to remove a single image: to load one again after it changed, change its [`cacheKey`](#sourcecachekey). Resolves like `clearMemoryCache`.
|
|
551
551
|
|
|
552
552
|
### `getCachePath(source)`
|
|
553
553
|
|
|
@@ -668,6 +668,14 @@ How fresh an image must be: see [`source.cache`](#sourcecache).
|
|
|
668
668
|
|
|
669
669
|
---
|
|
670
670
|
|
|
671
|
+
### `ClearCacheResult`
|
|
672
|
+
|
|
673
|
+
**Type:** `{ ok: true } | { ok: false; error: string }`
|
|
674
|
+
|
|
675
|
+
`clearMemoryCache`'s and `clearDiskCache`'s result: `ok` once the cache is cleared, or not `ok` with the error.
|
|
676
|
+
|
|
677
|
+
---
|
|
678
|
+
|
|
671
679
|
### `LoadResult`
|
|
672
680
|
|
|
673
681
|
**Type:** `{ ok: true; width: number; height: number } | { ok: false; error: string }`
|
|
@@ -37,6 +37,13 @@ final class FastImageGlide {
|
|
|
37
37
|
registered = glide;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// Whether Glide has started with FastImage's AppGlideModule or has
|
|
41
|
+
// FastImage's components: until then, none of FastImage's images are in
|
|
42
|
+
// its memory cache.
|
|
43
|
+
static boolean used() {
|
|
44
|
+
return appModule || registered != null;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
// Glide, with FastImage's components. Glide registers them if the app's
|
|
41
48
|
// generated Glide module lists FastImage's module, as FastImage's
|
|
42
49
|
// AppGlideModule's does. Another library's (e.g. expo-image's, which ships
|
|
@@ -23,10 +23,12 @@ import com.facebook.react.uimanager.SimpleViewManager;
|
|
|
23
23
|
import com.facebook.react.bridge.ReactContext;
|
|
24
24
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
25
25
|
import com.facebook.react.uimanager.PixelUtil;
|
|
26
|
+
import com.facebook.react.uimanager.PointerEvents;
|
|
26
27
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
27
28
|
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
|
|
28
29
|
|
|
29
30
|
import java.util.List;
|
|
31
|
+
import java.util.Locale;
|
|
30
32
|
import java.util.Map;
|
|
31
33
|
import java.util.WeakHashMap;
|
|
32
34
|
|
|
@@ -82,6 +84,16 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
82
84
|
.getResourceDrawable(view.getContext(), source));
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
// React Native's View manager handles pointerEvents; a SimpleViewManager
|
|
88
|
+
// doesn't. Parsed here: PointerEvents.parsePointerEvents isn't in every
|
|
89
|
+
// supported React Native version.
|
|
90
|
+
@ReactProp(name = "pointerEvents")
|
|
91
|
+
public void setPointerEvents(FastImageViewWithUrl view, @Nullable String pointerEvents) {
|
|
92
|
+
view.setPointerEvents(pointerEvents == null
|
|
93
|
+
? PointerEvents.AUTO
|
|
94
|
+
: PointerEvents.valueOf(pointerEvents.toUpperCase(Locale.US).replace('-', '_')));
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
@ReactProp(name = "tintColor", customType = "Color")
|
|
86
98
|
public void setTintColor(FastImageViewWithUrl view, @Nullable Integer color) {
|
|
87
99
|
if (color == null) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.dylanvann.fastimage;
|
|
2
2
|
|
|
3
|
-
import android.app.Activity;
|
|
4
3
|
import android.content.Context;
|
|
5
4
|
import android.graphics.BitmapFactory;
|
|
6
5
|
import android.graphics.drawable.Drawable;
|
|
@@ -566,32 +565,38 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
|
|
|
566
565
|
});
|
|
567
566
|
}
|
|
568
567
|
|
|
568
|
+
// The cache functions use the app's context, not the current Activity's:
|
|
569
|
+
// there may be no Activity while JS runs (e.g. after Android destroyed it
|
|
570
|
+
// in the background). Glide clears its memory cache on the main thread.
|
|
569
571
|
@ReactMethod
|
|
570
572
|
public void clearMemoryCache(final Promise promise) {
|
|
571
|
-
final
|
|
572
|
-
|
|
573
|
-
promise.resolve(null);
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
activity.runOnUiThread(new Runnable() {
|
|
573
|
+
final ReactApplicationContext context = getReactApplicationContext();
|
|
574
|
+
UiThreadUtil.runOnUiThread(new Runnable() {
|
|
578
575
|
@Override
|
|
579
576
|
public void run() {
|
|
580
|
-
|
|
581
|
-
|
|
577
|
+
try {
|
|
578
|
+
// Not before FastImage has used Glide: there's nothing of
|
|
579
|
+
// its in memory, and starting Glide here would set its
|
|
580
|
+
// disk cache size before a configureCache could.
|
|
581
|
+
if (FastImageGlide.used()) Glide.get(context).clearMemory();
|
|
582
|
+
promise.resolve(cleared());
|
|
583
|
+
} catch (RuntimeException e) {
|
|
584
|
+
promise.resolve(failure(e));
|
|
585
|
+
}
|
|
582
586
|
}
|
|
583
587
|
});
|
|
584
588
|
}
|
|
585
589
|
|
|
590
|
+
// On the native modules' thread: Glide clears its disk cache off the main
|
|
591
|
+
// thread.
|
|
586
592
|
@ReactMethod
|
|
587
593
|
public void clearDiskCache(Promise promise) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
594
|
+
try {
|
|
595
|
+
FastImageGlide.getRegistered(getReactApplicationContext()).clearDiskCache();
|
|
596
|
+
} catch (RuntimeException e) {
|
|
597
|
+
promise.resolve(failure(e));
|
|
591
598
|
return;
|
|
592
599
|
}
|
|
593
|
-
|
|
594
|
-
FastImageGlide.getRegistered(activity.getApplicationContext()).clearDiskCache();
|
|
595
600
|
// And the HTTP cache of `cache: 'web'` images, which Glide doesn't
|
|
596
601
|
// cache (set up when FastImage's components are registered).
|
|
597
602
|
try {
|
|
@@ -599,6 +604,20 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
|
|
|
599
604
|
} catch (IOException e) {
|
|
600
605
|
// Cleared as far as it could.
|
|
601
606
|
}
|
|
602
|
-
promise.resolve(
|
|
607
|
+
promise.resolve(cleared());
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
private static WritableMap cleared() {
|
|
611
|
+
WritableMap result = Arguments.createMap();
|
|
612
|
+
result.putBoolean("ok", true);
|
|
613
|
+
return result;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Glide failing to start, e.g. when an app's Glide module calls
|
|
617
|
+
// Glide.get() from registerComponents (#962): resolved as an error, not
|
|
618
|
+
// thrown, which would crash the app (on the main thread) or leave the
|
|
619
|
+
// promise unsettled.
|
|
620
|
+
private static WritableMap failure(RuntimeException e) {
|
|
621
|
+
return failure(e.getMessage() != null ? e.getMessage() : e.toString());
|
|
603
622
|
}
|
|
604
623
|
}
|
|
@@ -43,6 +43,8 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
43
43
|
import com.facebook.react.bridge.ReadableMap;
|
|
44
44
|
import com.facebook.react.bridge.WritableMap;
|
|
45
45
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
46
|
+
import com.facebook.react.uimanager.PointerEvents;
|
|
47
|
+
import com.facebook.react.uimanager.ReactPointerEventsView;
|
|
46
48
|
|
|
47
49
|
import java.util.ArrayList;
|
|
48
50
|
import java.util.Collections;
|
|
@@ -51,7 +53,7 @@ import java.util.Map;
|
|
|
51
53
|
|
|
52
54
|
import javax.annotation.Nonnull;
|
|
53
55
|
|
|
54
|
-
class FastImageViewWithUrl extends AppCompatImageView {
|
|
56
|
+
class FastImageViewWithUrl extends AppCompatImageView implements ReactPointerEventsView {
|
|
55
57
|
private boolean mNeedsReload = false;
|
|
56
58
|
private ReadableMap mSource = null;
|
|
57
59
|
private Drawable mDefaultSource = null;
|
|
@@ -66,6 +68,20 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
66
68
|
this.requestManager = requestManager;
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
// FastImage sends "none" when it has pointerEvents="box-none" (the image
|
|
72
|
+
// is part of the box, which doesn't take touches). React Native's touch
|
|
73
|
+
// handling only reads pointerEvents from a ReactPointerEventsView.
|
|
74
|
+
private PointerEvents mPointerEvents = PointerEvents.AUTO;
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
public PointerEvents getPointerEvents() {
|
|
78
|
+
return mPointerEvents;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void setPointerEvents(PointerEvents pointerEvents) {
|
|
82
|
+
mPointerEvents = pointerEvents;
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
public void setSource(@Nullable ReadableMap source) {
|
|
70
86
|
mNeedsReload = true;
|
|
71
87
|
mPropSource = source;
|
package/dist/index.cjs.js
CHANGED
|
@@ -111,13 +111,31 @@ function withoutCache(source) {
|
|
|
111
111
|
const { cache: _cache, ...rest } = source || {};
|
|
112
112
|
return rest;
|
|
113
113
|
}
|
|
114
|
-
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, transition, forwardedRef, onLayout, pointerEvents, ...viewProps }) {
|
|
114
|
+
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, transition, forwardedRef, onLayout, pointerEvents, hitSlop, onStartShouldSetResponder, onStartShouldSetResponderCapture, onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onResponderGrant, onResponderReject, onResponderStart, onResponderMove, onResponderEnd, onResponderRelease, onResponderTerminationRequest, onResponderTerminate, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, onTouchEndCapture, ...viewProps }) {
|
|
115
115
|
const { onClick, ...props } = viewProps;
|
|
116
116
|
const fallbackResult = (0, react.useRef)(void 0);
|
|
117
117
|
const wrapperProps = {
|
|
118
118
|
onLayout,
|
|
119
119
|
onClick,
|
|
120
|
-
pointerEvents
|
|
120
|
+
pointerEvents,
|
|
121
|
+
hitSlop,
|
|
122
|
+
onStartShouldSetResponder,
|
|
123
|
+
onStartShouldSetResponderCapture,
|
|
124
|
+
onMoveShouldSetResponder,
|
|
125
|
+
onMoveShouldSetResponderCapture,
|
|
126
|
+
onResponderGrant,
|
|
127
|
+
onResponderReject,
|
|
128
|
+
onResponderStart,
|
|
129
|
+
onResponderMove,
|
|
130
|
+
onResponderEnd,
|
|
131
|
+
onResponderRelease,
|
|
132
|
+
onResponderTerminationRequest,
|
|
133
|
+
onResponderTerminate,
|
|
134
|
+
onTouchStart,
|
|
135
|
+
onTouchMove,
|
|
136
|
+
onTouchEnd,
|
|
137
|
+
onTouchCancel,
|
|
138
|
+
onTouchEndCapture
|
|
121
139
|
};
|
|
122
140
|
const imageProps = {
|
|
123
141
|
...props,
|
|
@@ -227,8 +245,8 @@ FastImage.preload = (sources) => Promise.resolve(react_native.NativeModules.Fast
|
|
|
227
245
|
uri
|
|
228
246
|
};
|
|
229
247
|
}));
|
|
230
|
-
FastImage.clearMemoryCache = () => react_native.NativeModules.FastImageView.clearMemoryCache();
|
|
231
|
-
FastImage.clearDiskCache = () => react_native.NativeModules.FastImageView.clearDiskCache();
|
|
248
|
+
FastImage.clearMemoryCache = () => Promise.resolve(react_native.NativeModules.FastImageView.clearMemoryCache());
|
|
249
|
+
FastImage.clearDiskCache = () => Promise.resolve(react_native.NativeModules.FastImageView.clearDiskCache());
|
|
232
250
|
FastImage.configureCache = (limits = {}) => Promise.resolve(react_native.NativeModules.FastImageView.configureCache(limits));
|
|
233
251
|
FastImage.writeToCache = (source, file) => Array.isArray(source) ? Promise.resolve({
|
|
234
252
|
ok: false,
|
package/dist/index.cjs.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.cjs.web.js
CHANGED
|
@@ -239,8 +239,8 @@ FastImage.preload = (sources) => Promise.all(sources.map((source) => {
|
|
|
239
239
|
uri
|
|
240
240
|
}));
|
|
241
241
|
}));
|
|
242
|
-
FastImage.clearMemoryCache = () => Promise.resolve();
|
|
243
|
-
FastImage.clearDiskCache = () => Promise.resolve();
|
|
242
|
+
FastImage.clearMemoryCache = () => Promise.resolve(notSupported);
|
|
243
|
+
FastImage.clearDiskCache = () => Promise.resolve(notSupported);
|
|
244
244
|
FastImage.configureCache = () => Promise.resolve({});
|
|
245
245
|
FastImage.writeToCache = () => Promise.resolve(notSupported);
|
|
246
246
|
FastImage.getCachePath = () => Promise.resolve(notSupported);
|
|
@@ -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.
|
|
@@ -529,8 +539,18 @@ export interface FastImageStaticProperties {
|
|
|
529
539
|
priority: typeof priority;
|
|
530
540
|
cacheControl: typeof cacheControl;
|
|
531
541
|
preload: (sources: Source[]) => Promise<PreloadResult[]>;
|
|
532
|
-
|
|
533
|
-
|
|
542
|
+
/**
|
|
543
|
+
* Removes every image from the memory cache. Resolves once it's done, or
|
|
544
|
+
* not `ok` with the error if it couldn't (Android: Glide failed to
|
|
545
|
+
* start). Never rejects.
|
|
546
|
+
*/
|
|
547
|
+
clearMemoryCache: () => Promise<ClearCacheResult>;
|
|
548
|
+
/**
|
|
549
|
+
* Removes every image from the disk cache, and the HTTP cache of
|
|
550
|
+
* `cache: 'web'` images. Resolves once it's done, or not `ok` with the
|
|
551
|
+
* error if it couldn't (Android: Glide failed to start). Never rejects.
|
|
552
|
+
*/
|
|
553
|
+
clearDiskCache: () => Promise<ClearCacheResult>;
|
|
534
554
|
/**
|
|
535
555
|
* The path of the source's downloaded file in the disk cache, downloading
|
|
536
556
|
* it first if it isn't there (without decoding it). With
|
|
@@ -550,10 +570,14 @@ export interface FastImageStaticProperties {
|
|
|
550
570
|
/**
|
|
551
571
|
* Changes the cache's limits at runtime (only those given; 0 for no
|
|
552
572
|
* 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
|
-
*
|
|
573
|
+
* resolves with the limits in effect and the disk cache's size; without
|
|
574
|
+
* limits, it only resolves with them. iOS applies changes at once.
|
|
575
|
+
* Android only has `maxDiskSize`, applied when Glide starts: at once if
|
|
576
|
+
* it hasn't started yet in this launch, otherwise from the next launch.
|
|
577
|
+
* FastImage starts it when its first view is created (before the view has
|
|
578
|
+
* a source), and for `preload`, `getCachePath`, `writeToCache`,
|
|
579
|
+
* `clearDiskCache` and `configureCache` itself, even without limits (e.g.
|
|
580
|
+
* to read the disk cache's size).
|
|
557
581
|
*/
|
|
558
582
|
configureCache: (limits?: CacheLimits) => Promise<CacheState>;
|
|
559
583
|
}
|
package/dist/index.js
CHANGED
|
@@ -84,13 +84,31 @@ function withoutCache(source) {
|
|
|
84
84
|
const { cache: _cache, ...rest } = source || {};
|
|
85
85
|
return rest;
|
|
86
86
|
}
|
|
87
|
-
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, transition, forwardedRef, onLayout, pointerEvents, ...viewProps }) {
|
|
87
|
+
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, transition, forwardedRef, onLayout, pointerEvents, hitSlop, onStartShouldSetResponder, onStartShouldSetResponderCapture, onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onResponderGrant, onResponderReject, onResponderStart, onResponderMove, onResponderEnd, onResponderRelease, onResponderTerminationRequest, onResponderTerminate, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, onTouchEndCapture, ...viewProps }) {
|
|
88
88
|
const { onClick, ...props } = viewProps;
|
|
89
89
|
const fallbackResult = useRef(void 0);
|
|
90
90
|
const wrapperProps = {
|
|
91
91
|
onLayout,
|
|
92
92
|
onClick,
|
|
93
|
-
pointerEvents
|
|
93
|
+
pointerEvents,
|
|
94
|
+
hitSlop,
|
|
95
|
+
onStartShouldSetResponder,
|
|
96
|
+
onStartShouldSetResponderCapture,
|
|
97
|
+
onMoveShouldSetResponder,
|
|
98
|
+
onMoveShouldSetResponderCapture,
|
|
99
|
+
onResponderGrant,
|
|
100
|
+
onResponderReject,
|
|
101
|
+
onResponderStart,
|
|
102
|
+
onResponderMove,
|
|
103
|
+
onResponderEnd,
|
|
104
|
+
onResponderRelease,
|
|
105
|
+
onResponderTerminationRequest,
|
|
106
|
+
onResponderTerminate,
|
|
107
|
+
onTouchStart,
|
|
108
|
+
onTouchMove,
|
|
109
|
+
onTouchEnd,
|
|
110
|
+
onTouchCancel,
|
|
111
|
+
onTouchEndCapture
|
|
94
112
|
};
|
|
95
113
|
const imageProps = {
|
|
96
114
|
...props,
|
|
@@ -200,8 +218,8 @@ FastImage.preload = (sources) => Promise.resolve(NativeModules.FastImageView.pre
|
|
|
200
218
|
uri
|
|
201
219
|
};
|
|
202
220
|
}));
|
|
203
|
-
FastImage.clearMemoryCache = () => NativeModules.FastImageView.clearMemoryCache();
|
|
204
|
-
FastImage.clearDiskCache = () => NativeModules.FastImageView.clearDiskCache();
|
|
221
|
+
FastImage.clearMemoryCache = () => Promise.resolve(NativeModules.FastImageView.clearMemoryCache());
|
|
222
|
+
FastImage.clearDiskCache = () => Promise.resolve(NativeModules.FastImageView.clearDiskCache());
|
|
205
223
|
FastImage.configureCache = (limits = {}) => Promise.resolve(NativeModules.FastImageView.configureCache(limits));
|
|
206
224
|
FastImage.writeToCache = (source, file) => Array.isArray(source) ? Promise.resolve({
|
|
207
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
|
|