react-native-fast-image 8.6.28 → 8.6.29
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 +26 -26
- package/dist/index.cjs.js +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/ios/FastImage/FFFastImageSource.h +4 -0
- package/ios/FastImage/FFFastImageSource.m +13 -0
- package/ios/FastImage/FFFastImageView.m +1 -10
- package/ios/FastImage/FFFastImageViewManager.m +17 -5
- package/package.json +8 -18
package/README.md
CHANGED
|
@@ -42,10 +42,10 @@ headers for images you'll generally get the sort of built in
|
|
|
42
42
|
caching behavior you'd have in a browser.
|
|
43
43
|
Even so many people have noticed:
|
|
44
44
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
45
|
+
- Flickering.
|
|
46
|
+
- Cache misses.
|
|
47
|
+
- Low performance loading from cache.
|
|
48
|
+
- Low performance in general.
|
|
49
49
|
|
|
50
50
|
`FastImage` is an `Image` replacement that solves these issues.
|
|
51
51
|
`FastImage` is a wrapper around
|
|
@@ -55,12 +55,12 @@ and
|
|
|
55
55
|
|
|
56
56
|
## Features
|
|
57
57
|
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
58
|
+
- [x] Aggressively cache images.
|
|
59
|
+
- [x] Add authorization headers.
|
|
60
|
+
- [x] Prioritize images.
|
|
61
|
+
- [x] Preload images.
|
|
62
|
+
- [x] GIF support.
|
|
63
|
+
- [x] Border radius.
|
|
64
64
|
|
|
65
65
|
## Usage
|
|
66
66
|
|
|
@@ -89,7 +89,7 @@ const YourImage = () => (
|
|
|
89
89
|
|
|
90
90
|
## Are you using Glide already using an AppGlideModule?
|
|
91
91
|
|
|
92
|
-
-
|
|
92
|
+
- [Are you using Glide already using an AppGlideModule?](docs/app-glide-module.md) (you might have problems if you don't read this)
|
|
93
93
|
|
|
94
94
|
## Are you using Proguard?
|
|
95
95
|
|
|
@@ -130,33 +130,33 @@ Headers to load the image with. e.g. `{ Authorization: 'someAuthToken' }`.
|
|
|
130
130
|
|
|
131
131
|
Indicates the load order priority of an image. Images with `FastImage.priority.high` will load before images in a similar context with low or normal priority.
|
|
132
132
|
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
133
|
+
- `FastImage.priority.low` - Low Priority.
|
|
134
|
+
- `FastImage.priority.normal` **(Default)** - Normal Priority.
|
|
135
|
+
- `FastImage.priority.high` - High Priority.
|
|
136
136
|
|
|
137
137
|
---
|
|
138
138
|
|
|
139
139
|
### `source.cache?: enum`
|
|
140
140
|
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
141
|
+
- `FastImage.cacheControl.immutable` - **(Default)** - Only updates if url changes.
|
|
142
|
+
- `FastImage.cacheControl.web` - Use headers and follow normal caching procedures.
|
|
143
|
+
- `FastImage.cacheControl.cacheOnly` - Only show images from cache, do not make any network requests.
|
|
144
144
|
|
|
145
145
|
---
|
|
146
146
|
|
|
147
147
|
### `defaultSource?: number`
|
|
148
148
|
|
|
149
|
-
-
|
|
150
|
-
-
|
|
149
|
+
- An asset loaded with `require(...)`.
|
|
150
|
+
- Note that like the built-in `Image` implementation, on Android `defaultSource` does not work in debug mode. This is due to the fact that assets are sent from the dev server, but RN's functions only know how to load it from `res`.
|
|
151
151
|
|
|
152
152
|
---
|
|
153
153
|
|
|
154
154
|
### `resizeMode?: enum`
|
|
155
155
|
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
156
|
+
- `FastImage.resizeMode.contain` - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).
|
|
157
|
+
- `FastImage.resizeMode.cover` **(Default)** - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
|
|
158
|
+
- `FastImage.resizeMode.stretch` - Scale width and height independently, This may change the aspect ratio of the src.
|
|
159
|
+
- `FastImage.resizeMode.center` - Do not scale the image, keep centered.
|
|
160
160
|
|
|
161
161
|
---
|
|
162
162
|
|
|
@@ -265,9 +265,9 @@ Thanks to [@mobinni](https://github.com/mobinni) for helping with the conceptual
|
|
|
265
265
|
|
|
266
266
|
## Licenses
|
|
267
267
|
|
|
268
|
-
-
|
|
269
|
-
-
|
|
270
|
-
-
|
|
268
|
+
- FastImage - MIT © [DylanVann](https://github.com/DylanVann)
|
|
269
|
+
- SDWebImage - `MIT`
|
|
270
|
+
- Glide - BSD, part MIT and Apache 2.0. See the [LICENSE](https://github.com/bumptech/glide/blob/master/LICENSE) file for details.
|
|
271
271
|
|
|
272
272
|
[build-badge]: https://github.com/DylanVann/react-native-fast-image/actions/workflows/ci.yml/badge.svg
|
|
273
273
|
[build]: https://github.com/DylanVann/react-native-fast-image/actions/workflows/ci.yml
|
package/dist/index.cjs.js
CHANGED
|
@@ -73,6 +73,15 @@ function tintColorFromStyle(style) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
return style && typeof style === 'object' ? style.tintColor : undefined;
|
|
76
|
+
} // A copy of the source without `cache`.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
function withoutCache(source) {
|
|
80
|
+
const {
|
|
81
|
+
cache: _cache,
|
|
82
|
+
...rest
|
|
83
|
+
} = source || {};
|
|
84
|
+
return rest;
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
function FastImageBase({
|
|
@@ -87,7 +96,6 @@ function FastImageBase({
|
|
|
87
96
|
style,
|
|
88
97
|
fallback,
|
|
89
98
|
children,
|
|
90
|
-
// eslint-disable-next-line no-shadow
|
|
91
99
|
resizeMode = 'cover',
|
|
92
100
|
forwardedRef,
|
|
93
101
|
// On the wrapper, so the layout is relative to the parent (the image view
|
|
@@ -121,9 +129,7 @@ function FastImageBase({
|
|
|
121
129
|
if (fallback) {
|
|
122
130
|
// Remove `cache`, which React Native's Image doesn't support. A
|
|
123
131
|
// require()d source is a number: pass it through (spreading it gave {}).
|
|
124
|
-
const cleanedSource = typeof source === 'number' ? source :
|
|
125
|
-
};
|
|
126
|
-
if (typeof cleanedSource === 'object') delete cleanedSource.cache;
|
|
132
|
+
const cleanedSource = typeof source === 'number' ? source : withoutCache(source);
|
|
127
133
|
const resolvedSource = reactNative.Image.resolveAssetSource(cleanedSource);
|
|
128
134
|
return /*#__PURE__*/React__default['default'].createElement(reactNative.View, _extends__default['default']({
|
|
129
135
|
style: [styles.imageContainer, style]
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAC/C,OAAO,EAMH,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,kBAAkB,EAElB,kBAAkB,EAClB,SAAS,EACZ,MAAM,cAAc,CAAA;AAKrB,aAAK,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAE3D,oBAAY,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEnE,QAAA,MAAM,UAAU;;;;;CAKN,CAAA;AAEV,oBAAY,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEhD,QAAA,MAAM,QAAQ;;;;CAIJ,CAAA;AAEV,oBAAY,KAAK,GAAG,WAAW,GAAG,KAAK,GAAG,WAAW,CAAA;AAErD,QAAA,MAAM,YAAY;;;;CAOR,CAAA;AAEV,oBAAY,MAAM,GAAG;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACnC,QAAQ,CAAC,EAAE,QAAQ,C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OAMG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAA;IAE7C;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;IAE7B;;;;OAIG;IAEH,SAAS,CAAC,EAAE,UAAU,CAAA;IAEtB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B;AAmKD,MAAM,WAAW,yBAAyB;IACtC,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,YAAY,EAAE,OAAO,YAAY,CAAA;IACjC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACpC,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACtC;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GAChD,yBAAqD,CAAA;AA8CzD,eAAe,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -66,6 +66,15 @@ function tintColorFromStyle(style) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
return style && typeof style === 'object' ? style.tintColor : undefined;
|
|
69
|
+
} // A copy of the source without `cache`.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
function withoutCache(source) {
|
|
73
|
+
const {
|
|
74
|
+
cache: _cache,
|
|
75
|
+
...rest
|
|
76
|
+
} = source || {};
|
|
77
|
+
return rest;
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
function FastImageBase({
|
|
@@ -80,7 +89,6 @@ function FastImageBase({
|
|
|
80
89
|
style,
|
|
81
90
|
fallback,
|
|
82
91
|
children,
|
|
83
|
-
// eslint-disable-next-line no-shadow
|
|
84
92
|
resizeMode = 'cover',
|
|
85
93
|
forwardedRef,
|
|
86
94
|
// On the wrapper, so the layout is relative to the parent (the image view
|
|
@@ -114,9 +122,7 @@ function FastImageBase({
|
|
|
114
122
|
if (fallback) {
|
|
115
123
|
// Remove `cache`, which React Native's Image doesn't support. A
|
|
116
124
|
// require()d source is a number: pass it through (spreading it gave {}).
|
|
117
|
-
const cleanedSource = typeof source === 'number' ? source :
|
|
118
|
-
};
|
|
119
|
-
if (typeof cleanedSource === 'object') delete cleanedSource.cache;
|
|
125
|
+
const cleanedSource = typeof source === 'number' ? source : withoutCache(source);
|
|
120
126
|
const resolvedSource = Image.resolveAssetSource(cleanedSource);
|
|
121
127
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
122
128
|
style: [styles.imageContainer, style]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
2
|
#import <UIKit/UIKit.h>
|
|
3
|
+
#import <SDWebImage/SDWebImageDownloaderRequestModifier.h>
|
|
3
4
|
|
|
4
5
|
typedef NS_ENUM(NSInteger, FFFPriority) {
|
|
5
6
|
FFFPriorityLow,
|
|
@@ -30,4 +31,7 @@ typedef NS_ENUM(NSInteger, FFFCacheControl) {
|
|
|
30
31
|
headers:(NSDictionary *)headers
|
|
31
32
|
cacheControl:(FFFCacheControl)cacheControl;
|
|
32
33
|
|
|
34
|
+
// Adds this source's headers to its image requests.
|
|
35
|
+
- (SDWebImageDownloaderRequestModifier *)requestModifier;
|
|
36
|
+
|
|
33
37
|
@end
|
|
@@ -17,4 +17,17 @@
|
|
|
17
17
|
return self;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
- (SDWebImageDownloaderRequestModifier *)requestModifier
|
|
21
|
+
{
|
|
22
|
+
NSDictionary* headers = _headers;
|
|
23
|
+
return [SDWebImageDownloaderRequestModifier requestModifierWithBlock: ^NSURLRequest* _Nullable (NSURLRequest* _Nonnull request) {
|
|
24
|
+
NSMutableURLRequest* mutableRequest = [request mutableCopy];
|
|
25
|
+
for (NSString* header in headers) {
|
|
26
|
+
NSString* value = headers[header];
|
|
27
|
+
[mutableRequest setValue: value forHTTPHeaderField: header];
|
|
28
|
+
}
|
|
29
|
+
return [mutableRequest copy];
|
|
30
|
+
}];
|
|
31
|
+
}
|
|
32
|
+
|
|
20
33
|
@end
|
|
@@ -185,16 +185,7 @@
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
// Set headers.
|
|
188
|
-
|
|
189
|
-
SDWebImageDownloaderRequestModifier* requestModifier = [SDWebImageDownloaderRequestModifier requestModifierWithBlock: ^NSURLRequest* _Nullable (NSURLRequest* _Nonnull request) {
|
|
190
|
-
NSMutableURLRequest* mutableRequest = [request mutableCopy];
|
|
191
|
-
for (NSString* header in headers) {
|
|
192
|
-
NSString* value = headers[header];
|
|
193
|
-
[mutableRequest setValue: value forHTTPHeaderField: header];
|
|
194
|
-
}
|
|
195
|
-
return [mutableRequest copy];
|
|
196
|
-
}];
|
|
197
|
-
SDWebImageContext* context = @{SDWebImageContextDownloadRequestModifier: requestModifier};
|
|
188
|
+
SDWebImageContext* context = @{SDWebImageContextDownloadRequestModifier: _source.requestModifier};
|
|
198
189
|
|
|
199
190
|
// Set priority.
|
|
200
191
|
SDWebImageOptions options = SDWebImageRetryFailed | SDWebImageHandleCookies;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#import <React/RCTLog.h>
|
|
4
4
|
|
|
5
5
|
#import <SDWebImage/SDImageCache.h>
|
|
6
|
+
#import <SDWebImage/SDWebImageManager.h>
|
|
6
7
|
#import <SDWebImage/SDWebImagePrefetcher.h>
|
|
7
8
|
|
|
8
9
|
@implementation FFFastImageViewManager
|
|
@@ -25,6 +26,7 @@ RCT_REMAP_VIEW_PROPERTY(tintColor, imageColor, UIColor)
|
|
|
25
26
|
|
|
26
27
|
RCT_EXPORT_METHOD(preload:(nonnull NSArray<FFFastImageSource *> *)sources)
|
|
27
28
|
{
|
|
29
|
+
SDWebImagePrefetcher *prefetcher = [SDWebImagePrefetcher sharedImagePrefetcher];
|
|
28
30
|
NSMutableArray *urls = [NSMutableArray arrayWithCapacity:sources.count];
|
|
29
31
|
|
|
30
32
|
[sources enumerateObjectsUsingBlock:^(FFFastImageSource * _Nonnull source, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
@@ -35,13 +37,23 @@ RCT_EXPORT_METHOD(preload:(nonnull NSArray<FFFastImageSource *> *)sources)
|
|
|
35
37
|
RCTLogWarn(@"FastImage.preload: skipping a source without a valid uri");
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
38
|
-
|
|
39
|
-
[
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
if (source.headers.count == 0) {
|
|
41
|
+
[urls addObject:source.url];
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Send the headers with this source's request only (setting them on
|
|
45
|
+
// the shared downloader sent them with every later request). The
|
|
46
|
+
// prefetcher can't take headers per request in SDWebImage 5.11 (its
|
|
47
|
+
// context is shared by all prefetches), so load it the way the
|
|
48
|
+
// prefetcher does, with the same options.
|
|
49
|
+
[[SDWebImageManager sharedManager] loadImageWithURL:source.url
|
|
50
|
+
options:prefetcher.options
|
|
51
|
+
context:@{SDWebImageContextDownloadRequestModifier: source.requestModifier}
|
|
52
|
+
progress:nil
|
|
53
|
+
completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {}];
|
|
42
54
|
}];
|
|
43
55
|
|
|
44
|
-
[
|
|
56
|
+
[prefetcher prefetchURLs:urls];
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
RCT_EXPORT_METHOD(clearMemoryCache:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-fast-image",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.29",
|
|
4
4
|
"description": "🚩 FastImage, performant React Native image component.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cache",
|
|
@@ -32,24 +32,14 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "dv-scripts build && cp src/index.js.flow dist/index.js.flow && cp src/index.js.flow dist/index.cjs.js.flow",
|
|
35
|
-
"lint": "
|
|
35
|
+
"lint": "oxlint",
|
|
36
36
|
"release": "dv-scripts release",
|
|
37
|
-
"test": "dv-scripts test"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"semi": false,
|
|
41
|
-
"singleQuote": true,
|
|
42
|
-
"tabWidth": 4,
|
|
43
|
-
"trailingComma": "all"
|
|
44
|
-
},
|
|
45
|
-
"eslintConfig": {
|
|
46
|
-
"extends": "dv-scripts"
|
|
37
|
+
"test": "dv-scripts test",
|
|
38
|
+
"format": "oxfmt",
|
|
39
|
+
"format:check": "oxfmt --check"
|
|
47
40
|
},
|
|
41
|
+
"packageManager": "bun@1.4.2",
|
|
48
42
|
"jest": {
|
|
49
|
-
"coveragePathIgnorePatterns": [
|
|
50
|
-
"ReactNativeFastImageExample*",
|
|
51
|
-
"ReactNativeFastImageExampleServer*"
|
|
52
|
-
],
|
|
53
43
|
"modulePathIgnorePatterns": [
|
|
54
44
|
"ReactNativeFastImageExample*",
|
|
55
45
|
"ReactNativeFastImageExampleServer*"
|
|
@@ -67,10 +57,10 @@
|
|
|
67
57
|
"@types/react-native": "^0.69.5",
|
|
68
58
|
"@types/react-test-renderer": "^17.0.1",
|
|
69
59
|
"dv-scripts": "^1.6.0",
|
|
70
|
-
"eslint-config-dv-scripts": "^1.1.1",
|
|
71
60
|
"maestro-runner": "1.1.27",
|
|
72
61
|
"metro-react-native-babel-preset": "^0.66.1",
|
|
73
|
-
"
|
|
62
|
+
"oxfmt": "0.70.0",
|
|
63
|
+
"oxlint": "1.85.0",
|
|
74
64
|
"react": "17.0.2",
|
|
75
65
|
"react-native": "0.64.2",
|
|
76
66
|
"react-test-renderer": "17.0.2",
|