@depup/react-native-fast-image 8.6.3-depup.0 → 8.13.1-depup.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 +2 -2
- package/RNFastImage.podspec +5 -2
- package/android/build.gradle +13 -0
- package/android/src/main/AndroidManifestNew.xml +3 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageCookieHandler.java +84 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageEvent.java +45 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageEvents.java +60 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageGif.java +110 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java +65 -5
- package/android/src/main/java/com/dylanvann/fastimage/FastImageRequestListener.java +65 -22
- package/android/src/main/java/com/dylanvann/fastimage/FastImageShadowNode.java +21 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java +21 -1
- package/android/src/main/java/com/dylanvann/fastimage/FastImageSourceSize.java +237 -0
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewConverter.java +14 -5
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java +66 -22
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewModule.java +130 -24
- package/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java +359 -39
- package/android/src/main/java/com/dylanvann/fastimage/FastImageWebGlideUrl.java +13 -0
- package/changes.json +1 -1
- package/dist/index.cjs.js +166 -130
- package/dist/index.cjs.js.flow +33 -2
- package/dist/index.d.ts +77 -22
- package/dist/index.js +141 -121
- package/dist/index.js.flow +33 -2
- package/ios/FastImage/FFFDownsampledImage.h +28 -0
- package/ios/FastImage/FFFDownsampledImage.m +169 -0
- package/ios/FastImage/FFFastImageSource.h +6 -0
- package/ios/FastImage/FFFastImageSource.m +13 -0
- package/ios/FastImage/FFFastImageView.h +17 -0
- package/ios/FastImage/FFFastImageView.m +498 -71
- package/ios/FastImage/FFFastImageViewManager.m +106 -8
- package/ios/FastImage/RCTConvert+FFFastImage.m +4 -1
- package/package.json +31 -43
- package/dist/index.d.ts.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,144 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let react = require("react");
|
|
24
|
+
react = __toESM(react);
|
|
25
|
+
let react_native = require("react-native");
|
|
26
|
+
//#region src/index.tsx
|
|
12
27
|
const resizeMode = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
contain: "contain",
|
|
29
|
+
cover: "cover",
|
|
30
|
+
stretch: "stretch",
|
|
31
|
+
center: "center"
|
|
17
32
|
};
|
|
18
33
|
const priority = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
low: "low",
|
|
35
|
+
normal: "normal",
|
|
36
|
+
high: "high"
|
|
22
37
|
};
|
|
23
38
|
const cacheControl = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
web: 'web',
|
|
28
|
-
// Only load from cache.
|
|
29
|
-
cacheOnly: 'cacheOnly'
|
|
39
|
+
immutable: "immutable",
|
|
40
|
+
web: "web",
|
|
41
|
+
cacheOnly: "cacheOnly"
|
|
30
42
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const resolved = reactNative.Image.resolveAssetSource(defaultSource);
|
|
40
|
-
|
|
41
|
-
if (resolved) {
|
|
42
|
-
return resolved.uri;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return null;
|
|
46
|
-
} // iOS or other number mapped assets
|
|
47
|
-
// In iOS the number is passed, and bridged automatically into a UIImage
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return defaultSource;
|
|
43
|
+
const resolveDefaultSource = (defaultSource) => {
|
|
44
|
+
if (!defaultSource) return null;
|
|
45
|
+
if (react_native.Platform.OS === "android") {
|
|
46
|
+
const resolved = react_native.Image.resolveAssetSource(defaultSource);
|
|
47
|
+
if (resolved) return resolved.uri;
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return defaultSource;
|
|
51
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
|
-
return /*#__PURE__*/React__default['default'].createElement(reactNative.View, {
|
|
76
|
-
style: [styles.imageContainer, style],
|
|
77
|
-
ref: forwardedRef
|
|
78
|
-
}, /*#__PURE__*/React__default['default'].createElement(reactNative.Image, _extends__default['default']({}, props, {
|
|
79
|
-
style: [reactNative.StyleSheet.absoluteFill, {
|
|
80
|
-
tintColor
|
|
81
|
-
}],
|
|
82
|
-
source: resolvedSource,
|
|
83
|
-
defaultSource: defaultSource,
|
|
84
|
-
onLoadStart: onLoadStart,
|
|
85
|
-
onProgress: onProgress,
|
|
86
|
-
onLoad: onLoad,
|
|
87
|
-
onError: onError,
|
|
88
|
-
onLoadEnd: onLoadEnd,
|
|
89
|
-
resizeMode: resizeMode
|
|
90
|
-
})), children);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const resolvedSource = reactNative.Image.resolveAssetSource(source);
|
|
94
|
-
const resolvedDefaultSource = resolveDefaultSource(defaultSource);
|
|
95
|
-
return /*#__PURE__*/React__default['default'].createElement(reactNative.View, {
|
|
96
|
-
style: [styles.imageContainer, style],
|
|
97
|
-
ref: forwardedRef
|
|
98
|
-
}, /*#__PURE__*/React__default['default'].createElement(FastImageView, _extends__default['default']({}, props, {
|
|
99
|
-
tintColor: tintColor,
|
|
100
|
-
style: reactNative.StyleSheet.absoluteFill,
|
|
101
|
-
source: resolvedSource,
|
|
102
|
-
defaultSource: resolvedDefaultSource,
|
|
103
|
-
onFastImageLoadStart: onLoadStart,
|
|
104
|
-
onFastImageProgress: onProgress,
|
|
105
|
-
onFastImageLoad: onLoad,
|
|
106
|
-
onFastImageError: onError,
|
|
107
|
-
onFastImageLoadEnd: onLoadEnd,
|
|
108
|
-
resizeMode: resizeMode
|
|
109
|
-
})), children);
|
|
52
|
+
function tintColorFromStyle(style) {
|
|
53
|
+
if (Array.isArray(style)) {
|
|
54
|
+
for (let i = style.length - 1; i >= 0; i--) {
|
|
55
|
+
const found = tintColorFromStyle(style[i]);
|
|
56
|
+
if (found !== void 0) return found;
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (typeof style === "number") {
|
|
61
|
+
const flattened = react_native.StyleSheet.flatten(style);
|
|
62
|
+
return flattened ? flattened.tintColor : void 0;
|
|
63
|
+
}
|
|
64
|
+
return style && typeof style === "object" ? style.tintColor : void 0;
|
|
65
|
+
}
|
|
66
|
+
function loopCount(loop) {
|
|
67
|
+
if (loop === void 0) return -1;
|
|
68
|
+
if (loop === true) return 0;
|
|
69
|
+
if (loop === false) return 1;
|
|
70
|
+
return Number.isFinite(loop) ? Math.max(1, Math.floor(loop)) : 0;
|
|
71
|
+
}
|
|
72
|
+
function withoutCache(source) {
|
|
73
|
+
const { cache: _cache, ...rest } = source || {};
|
|
74
|
+
return rest;
|
|
110
75
|
}
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
76
|
+
function FastImageBase({ source, defaultSource, tintColor, onLoadStart, onProgress, onLoad, onError, onLoadEnd, style, fallback, children, resizeMode = "cover", loop, forwardedRef, onLayout, pointerEvents, ...viewProps }) {
|
|
77
|
+
const { onClick, ...props } = viewProps;
|
|
78
|
+
const wrapperProps = {
|
|
79
|
+
onLayout,
|
|
80
|
+
onClick,
|
|
81
|
+
pointerEvents
|
|
82
|
+
};
|
|
83
|
+
const imageProps = {
|
|
84
|
+
...props,
|
|
85
|
+
pointerEvents: pointerEvents === "box-none" ? "none" : void 0
|
|
86
|
+
};
|
|
87
|
+
const resolvedTintColor = tintColor != null ? tintColor : tintColorFromStyle(style);
|
|
88
|
+
if (fallback) {
|
|
89
|
+
const cleanedSource = typeof source === "number" ? source : withoutCache(source);
|
|
90
|
+
const resolvedSource = react_native.Image.resolveAssetSource(cleanedSource);
|
|
91
|
+
return /* @__PURE__ */ react.default.createElement(react_native.View, {
|
|
92
|
+
style: [styles.imageContainer, style],
|
|
93
|
+
...wrapperProps,
|
|
94
|
+
ref: forwardedRef
|
|
95
|
+
}, /* @__PURE__ */ react.default.createElement(react_native.Image, {
|
|
96
|
+
...imageProps,
|
|
97
|
+
style: [styles.fallbackImage, { tintColor: resolvedTintColor }],
|
|
98
|
+
source: resolvedSource,
|
|
99
|
+
defaultSource,
|
|
100
|
+
onLoadStart,
|
|
101
|
+
onProgress,
|
|
102
|
+
onLoad,
|
|
103
|
+
onError,
|
|
104
|
+
onLoadEnd,
|
|
105
|
+
resizeMode
|
|
106
|
+
}), children);
|
|
107
|
+
}
|
|
108
|
+
const resolvedSource = react_native.Image.resolveAssetSource(source);
|
|
109
|
+
const resolvedDefaultSource = resolveDefaultSource(defaultSource);
|
|
110
|
+
return /* @__PURE__ */ react.default.createElement(react_native.View, {
|
|
111
|
+
style: [styles.imageContainer, style],
|
|
112
|
+
...wrapperProps,
|
|
113
|
+
ref: forwardedRef
|
|
114
|
+
}, /* @__PURE__ */ react.default.createElement(FastImageView, {
|
|
115
|
+
...imageProps,
|
|
116
|
+
tintColor: resolvedTintColor,
|
|
117
|
+
loopCount: loopCount(loop),
|
|
118
|
+
style: react_native.StyleSheet.absoluteFill,
|
|
119
|
+
source: resolvedSource,
|
|
120
|
+
defaultSource: resolvedDefaultSource,
|
|
121
|
+
onFastImageLoadStart: onLoadStart,
|
|
122
|
+
onFastImageProgress: onProgress,
|
|
123
|
+
onFastImageLoad: onLoad,
|
|
124
|
+
onFastImageError: onError,
|
|
125
|
+
onFastImageLoadEnd: onLoadEnd,
|
|
126
|
+
resizeMode
|
|
127
|
+
}), children);
|
|
128
|
+
}
|
|
129
|
+
const FastImageMemo = (0, react.memo)(FastImageBase);
|
|
130
|
+
const FastImageComponent = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ react.default.createElement(FastImageMemo, {
|
|
131
|
+
forwardedRef: ref,
|
|
132
|
+
...props
|
|
133
|
+
}));
|
|
134
|
+
FastImageComponent.displayName = "FastImage";
|
|
135
|
+
const noResult = {
|
|
136
|
+
ok: false,
|
|
137
|
+
error: "No result"
|
|
138
|
+
};
|
|
117
139
|
const FastImage = FastImageComponent;
|
|
118
140
|
FastImage.resizeMode = resizeMode;
|
|
119
141
|
FastImage.cacheControl = cacheControl;
|
|
120
142
|
FastImage.priority = priority;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
FastImage.preload = (sources) => Promise.resolve(react_native.NativeModules.FastImageView.preload(sources.map((s) => s || {}))).then((results) => sources.map((source, i) => {
|
|
144
|
+
var _results$i;
|
|
145
|
+
const uri = source ? source.uri : void 0;
|
|
146
|
+
const result = (_results$i = results === null || results === void 0 ? void 0 : results[i]) !== null && _results$i !== void 0 ? _results$i : noResult;
|
|
147
|
+
if (!result.ok) return {
|
|
148
|
+
...result,
|
|
149
|
+
uri
|
|
150
|
+
};
|
|
151
|
+
return typeof uri === "string" ? {
|
|
152
|
+
...result,
|
|
153
|
+
uri
|
|
154
|
+
} : {
|
|
155
|
+
ok: false,
|
|
156
|
+
error: "Invalid source: no uri",
|
|
157
|
+
uri
|
|
158
|
+
};
|
|
159
|
+
}));
|
|
160
|
+
FastImage.clearMemoryCache = () => react_native.NativeModules.FastImageView.clearMemoryCache();
|
|
161
|
+
FastImage.clearDiskCache = () => react_native.NativeModules.FastImageView.clearDiskCache();
|
|
162
|
+
const styles = react_native.StyleSheet.create({
|
|
163
|
+
fallbackImage: {
|
|
164
|
+
position: "absolute",
|
|
165
|
+
top: 0,
|
|
166
|
+
left: 0,
|
|
167
|
+
width: "100%",
|
|
168
|
+
height: "100%"
|
|
169
|
+
},
|
|
170
|
+
imageContainer: { overflow: "hidden" }
|
|
142
171
|
});
|
|
143
|
-
|
|
172
|
+
const FastImageView = (0, react_native.requireNativeComponent)("FastImageView", FastImage, { nativeOnly: {
|
|
173
|
+
onFastImageLoadStart: true,
|
|
174
|
+
onFastImageProgress: true,
|
|
175
|
+
onFastImageLoad: true,
|
|
176
|
+
onFastImageError: true,
|
|
177
|
+
onFastImageLoadEnd: true
|
|
178
|
+
} });
|
|
179
|
+
//#endregion
|
|
144
180
|
module.exports = FastImage;
|
package/dist/index.cjs.js.flow
CHANGED
|
@@ -7,9 +7,18 @@ export type OnLoadEvent = SyntheticEvent<
|
|
|
7
7
|
$ReadOnly<{
|
|
8
8
|
width: number,
|
|
9
9
|
height: number,
|
|
10
|
+
// The view's React tag. Missing on Android with the legacy architecture.
|
|
11
|
+
// TODO: make it required once the New Architecture is the minimum.
|
|
12
|
+
target?: number,
|
|
10
13
|
}>,
|
|
11
14
|
>
|
|
12
15
|
|
|
16
|
+
export type OnErrorEvent = SyntheticEvent<
|
|
17
|
+
$ReadOnly<{|
|
|
18
|
+
error: string,
|
|
19
|
+
|}>,
|
|
20
|
+
>
|
|
21
|
+
|
|
13
22
|
export type OnProgressEvent = SyntheticEvent<
|
|
14
23
|
$ReadOnly<{|
|
|
15
24
|
loaded: number,
|
|
@@ -40,7 +49,24 @@ export type ResizeModes = $Values<ResizeMode>
|
|
|
40
49
|
export type Priorities = $Values<Priority>
|
|
41
50
|
export type CacheControls = $Values<CacheControl>
|
|
42
51
|
|
|
43
|
-
export type
|
|
52
|
+
export type PreloadSuccess = {|
|
|
53
|
+
uri: string,
|
|
54
|
+
ok: true,
|
|
55
|
+
width: number,
|
|
56
|
+
height: number,
|
|
57
|
+
|}
|
|
58
|
+
|
|
59
|
+
export type PreloadFailure = {|
|
|
60
|
+
uri?: string,
|
|
61
|
+
ok: false,
|
|
62
|
+
error: string,
|
|
63
|
+
|}
|
|
64
|
+
|
|
65
|
+
export type PreloadResult = PreloadSuccess | PreloadFailure
|
|
66
|
+
|
|
67
|
+
export type PreloadFn = (
|
|
68
|
+
sources: Array<FastImageSource>,
|
|
69
|
+
) => Promise<Array<PreloadResult>>
|
|
44
70
|
export type FastImageSource = {
|
|
45
71
|
uri?: string,
|
|
46
72
|
headers?: Object,
|
|
@@ -50,7 +76,7 @@ export type FastImageSource = {
|
|
|
50
76
|
|
|
51
77
|
export type FastImageProps = $ReadOnly<{|
|
|
52
78
|
...ViewProps,
|
|
53
|
-
onError?: ?() => void,
|
|
79
|
+
onError?: ?(event: OnErrorEvent) => void,
|
|
54
80
|
onLoad?: ?(event: OnLoadEvent) => void,
|
|
55
81
|
onLoadEnd?: ?() => void,
|
|
56
82
|
onLoadStart?: ?() => void,
|
|
@@ -62,6 +88,11 @@ export type FastImageProps = $ReadOnly<{|
|
|
|
62
88
|
tintColor?: number | string,
|
|
63
89
|
resizeMode?: ?ResizeModes,
|
|
64
90
|
fallback?: ?boolean,
|
|
91
|
+
recyclingKey?: ?string,
|
|
92
|
+
loop?: ?(boolean | number),
|
|
93
|
+
imageRendering?: ?('auto' | 'smooth' | 'pixelated'),
|
|
94
|
+
paused?: ?boolean,
|
|
95
|
+
downsample?: ?boolean,
|
|
65
96
|
testID?: ?string,
|
|
66
97
|
|}>
|
|
67
98
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { LayoutChangeEvent, StyleProp, ViewStyle, ImageRequireSource, AccessibilityProps, ViewProps } from 'react-native';
|
|
3
|
+
type ColorValue = NonNullable<ViewStyle['backgroundColor']>;
|
|
4
|
+
export type ResizeMode = 'contain' | 'cover' | 'stretch' | 'center';
|
|
4
5
|
declare const resizeMode: {
|
|
5
|
-
readonly contain:
|
|
6
|
-
readonly cover:
|
|
7
|
-
readonly stretch:
|
|
8
|
-
readonly center:
|
|
6
|
+
readonly contain: 'contain';
|
|
7
|
+
readonly cover: 'cover';
|
|
8
|
+
readonly stretch: 'stretch';
|
|
9
|
+
readonly center: 'center';
|
|
9
10
|
};
|
|
10
|
-
export
|
|
11
|
+
export type Priority = 'low' | 'normal' | 'high';
|
|
11
12
|
declare const priority: {
|
|
12
|
-
readonly low:
|
|
13
|
-
readonly normal:
|
|
14
|
-
readonly high:
|
|
13
|
+
readonly low: 'low';
|
|
14
|
+
readonly normal: 'normal';
|
|
15
|
+
readonly high: 'high';
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
+
export type Cache = 'immutable' | 'web' | 'cacheOnly';
|
|
17
18
|
declare const cacheControl: {
|
|
18
|
-
readonly immutable:
|
|
19
|
-
readonly web:
|
|
20
|
-
readonly cacheOnly:
|
|
19
|
+
readonly immutable: 'immutable';
|
|
20
|
+
readonly web: 'web';
|
|
21
|
+
readonly cacheOnly: 'cacheOnly';
|
|
21
22
|
};
|
|
22
|
-
export
|
|
23
|
+
export type Source = {
|
|
23
24
|
uri?: string;
|
|
24
25
|
headers?: {
|
|
25
26
|
[key: string]: string;
|
|
@@ -31,6 +32,12 @@ export interface OnLoadEvent {
|
|
|
31
32
|
nativeEvent: {
|
|
32
33
|
width: number;
|
|
33
34
|
height: number;
|
|
35
|
+
target?: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface OnErrorEvent {
|
|
39
|
+
nativeEvent: {
|
|
40
|
+
error: string;
|
|
34
41
|
};
|
|
35
42
|
}
|
|
36
43
|
export interface OnProgressEvent {
|
|
@@ -39,17 +46,18 @@ export interface OnProgressEvent {
|
|
|
39
46
|
total: number;
|
|
40
47
|
};
|
|
41
48
|
}
|
|
42
|
-
export interface ImageStyle extends
|
|
49
|
+
export interface ImageStyle extends ViewStyle {
|
|
43
50
|
backfaceVisibility?: 'visible' | 'hidden';
|
|
44
51
|
borderBottomLeftRadius?: number;
|
|
45
52
|
borderBottomRightRadius?: number;
|
|
46
|
-
backgroundColor?:
|
|
47
|
-
borderColor?:
|
|
53
|
+
backgroundColor?: ColorValue;
|
|
54
|
+
borderColor?: ColorValue;
|
|
48
55
|
borderWidth?: number;
|
|
49
56
|
borderRadius?: number;
|
|
50
57
|
borderTopLeftRadius?: number;
|
|
51
58
|
borderTopRightRadius?: number;
|
|
52
|
-
overlayColor?:
|
|
59
|
+
overlayColor?: ColorValue;
|
|
60
|
+
tintColor?: ColorValue;
|
|
53
61
|
opacity?: number;
|
|
54
62
|
}
|
|
55
63
|
export interface FastImageProps extends AccessibilityProps, ViewProps {
|
|
@@ -57,10 +65,46 @@ export interface FastImageProps extends AccessibilityProps, ViewProps {
|
|
|
57
65
|
defaultSource?: ImageRequireSource;
|
|
58
66
|
resizeMode?: ResizeMode;
|
|
59
67
|
fallback?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* When `source` changes, the image showing stays until the new one has
|
|
70
|
+
* loaded. For views that get reused for other content, such as rows in
|
|
71
|
+
* FlashList or recyclerlistview, set this to something that identifies the
|
|
72
|
+
* content (e.g. the item's id): when it changes, the image is cleared
|
|
73
|
+
* right away instead, so a reused row doesn't show the previous row's
|
|
74
|
+
* image. Unlike changing `key`, the view is kept.
|
|
75
|
+
*/
|
|
76
|
+
recyclingKey?: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* How many times an animated image (GIF, animated WebP) plays: the file's
|
|
79
|
+
* own loop count by default, `true` to loop forever, `false` to play once,
|
|
80
|
+
* or a number of times. Changing it restarts the animation.
|
|
81
|
+
*/
|
|
82
|
+
loop?: boolean | number;
|
|
83
|
+
/**
|
|
84
|
+
* How the image is filtered when it's drawn smaller or larger than its
|
|
85
|
+
* size: `'auto'` (default, the platform's usual filtering), `'smooth'`
|
|
86
|
+
* (iOS only: keeps a large image drawn much smaller from looking jagged
|
|
87
|
+
* or noisy; uses more memory, see the README) or `'pixelated'` (sharp
|
|
88
|
+
* pixels, e.g. for pixel art).
|
|
89
|
+
*/
|
|
90
|
+
imageRendering?: 'auto' | 'smooth' | 'pixelated';
|
|
91
|
+
/**
|
|
92
|
+
* Pauses an animated image (GIF, and animated WebP on iOS) on the frame
|
|
93
|
+
* it's showing; `false` plays it again from there. Each image animates on
|
|
94
|
+
* its own, so pausing one doesn't pause others showing the same file.
|
|
95
|
+
*/
|
|
96
|
+
paused?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* iOS only. Decodes a large image at about the size it's shown at, so it
|
|
99
|
+
* takes much less memory. For images much larger than their views that
|
|
100
|
+
* you can't get at the right size (if you can, resize them on your server
|
|
101
|
+
* or with an image CDN instead). See the README.
|
|
102
|
+
*/
|
|
103
|
+
downsample?: boolean;
|
|
60
104
|
onLoadStart?(): void;
|
|
61
105
|
onProgress?(event: OnProgressEvent): void;
|
|
62
106
|
onLoad?(event: OnLoadEvent): void;
|
|
63
|
-
onError?(): void;
|
|
107
|
+
onError?(event: OnErrorEvent): void;
|
|
64
108
|
onLoadEnd?(): void;
|
|
65
109
|
/**
|
|
66
110
|
* onLayout function
|
|
@@ -90,14 +134,25 @@ export interface FastImageProps extends AccessibilityProps, ViewProps {
|
|
|
90
134
|
*/
|
|
91
135
|
children?: React.ReactNode;
|
|
92
136
|
}
|
|
137
|
+
export interface PreloadSuccess {
|
|
138
|
+
uri: string;
|
|
139
|
+
ok: true;
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
}
|
|
143
|
+
export interface PreloadFailure {
|
|
144
|
+
uri?: string;
|
|
145
|
+
ok: false;
|
|
146
|
+
error: string;
|
|
147
|
+
}
|
|
148
|
+
export type PreloadResult = PreloadSuccess | PreloadFailure;
|
|
93
149
|
export interface FastImageStaticProperties {
|
|
94
150
|
resizeMode: typeof resizeMode;
|
|
95
151
|
priority: typeof priority;
|
|
96
152
|
cacheControl: typeof cacheControl;
|
|
97
|
-
preload: (sources: Source[]) =>
|
|
153
|
+
preload: (sources: Source[]) => Promise<PreloadResult[]>;
|
|
98
154
|
clearMemoryCache: () => Promise<void>;
|
|
99
155
|
clearDiskCache: () => Promise<void>;
|
|
100
156
|
}
|
|
101
157
|
declare const FastImage: React.ComponentType<FastImageProps> & FastImageStaticProperties;
|
|
102
158
|
export default FastImage;
|
|
103
|
-
//# sourceMappingURL=index.d.ts.map
|