react-native-fast-image 9.3.4 → 9.3.5

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/dist/index.cjs.js CHANGED
@@ -255,14 +255,15 @@ FastImage.resizeMode = resizeMode;
255
255
  FastImage.cacheControl = cacheControl;
256
256
  FastImage.priority = priority;
257
257
  const ONE_SOURCE = "Takes one source, not an array of sizes: pass the size to use";
258
- FastImage.preload = (sources) => Promise.resolve(react_native.NativeModules.FastImageView.preload(sources.map((s) => s && !Array.isArray(s) ? s : {}))).then((results) => sources.map((source, i) => {
258
+ const isSourceObject = (source) => typeof source === "object" && source !== null && !Array.isArray(source);
259
+ FastImage.preload = (sources) => Promise.resolve(react_native.NativeModules.FastImageView.preload(sources.map((s) => isSourceObject(s) ? s : {}))).then((results) => sources.map((source, i) => {
259
260
  var _results$i;
260
261
  if (Array.isArray(source)) return {
261
262
  ok: false,
262
263
  error: ONE_SOURCE,
263
264
  uri: void 0
264
265
  };
265
- const uri = source ? source.uri : void 0;
266
+ const uri = isSourceObject(source) ? source.uri : void 0;
266
267
  const result = (_results$i = results === null || results === void 0 ? void 0 : results[i]) !== null && _results$i !== void 0 ? _results$i : noResult;
267
268
  if (!result.ok) return {
268
269
  ...result,
@@ -283,11 +284,11 @@ FastImage.configureCache = (limits = {}) => Promise.resolve(react_native.NativeM
283
284
  FastImage.writeToCache = (source, file) => Array.isArray(source) ? Promise.resolve({
284
285
  ok: false,
285
286
  error: ONE_SOURCE
286
- }) : Promise.resolve(react_native.NativeModules.FastImageView.writeToCache(source || {}, file));
287
+ }) : Promise.resolve(react_native.NativeModules.FastImageView.writeToCache(isSourceObject(source) ? source : {}, file));
287
288
  FastImage.getCachePath = (source) => Array.isArray(source) ? Promise.resolve({
288
289
  ok: false,
289
290
  error: ONE_SOURCE
290
- }) : Promise.resolve(react_native.NativeModules.FastImageView.getCachePath(source || {}));
291
+ }) : Promise.resolve(react_native.NativeModules.FastImageView.getCachePath(isSourceObject(source) ? source : {}));
291
292
  const styles = react_native.StyleSheet.create({
292
293
  fallbackImage: {
293
294
  position: "absolute",
package/dist/index.js CHANGED
@@ -228,14 +228,15 @@ FastImage.resizeMode = resizeMode;
228
228
  FastImage.cacheControl = cacheControl;
229
229
  FastImage.priority = priority;
230
230
  const ONE_SOURCE = "Takes one source, not an array of sizes: pass the size to use";
231
- FastImage.preload = (sources) => Promise.resolve(NativeModules.FastImageView.preload(sources.map((s) => s && !Array.isArray(s) ? s : {}))).then((results) => sources.map((source, i) => {
231
+ const isSourceObject = (source) => typeof source === "object" && source !== null && !Array.isArray(source);
232
+ FastImage.preload = (sources) => Promise.resolve(NativeModules.FastImageView.preload(sources.map((s) => isSourceObject(s) ? s : {}))).then((results) => sources.map((source, i) => {
232
233
  var _results$i;
233
234
  if (Array.isArray(source)) return {
234
235
  ok: false,
235
236
  error: ONE_SOURCE,
236
237
  uri: void 0
237
238
  };
238
- const uri = source ? source.uri : void 0;
239
+ const uri = isSourceObject(source) ? source.uri : void 0;
239
240
  const result = (_results$i = results === null || results === void 0 ? void 0 : results[i]) !== null && _results$i !== void 0 ? _results$i : noResult;
240
241
  if (!result.ok) return {
241
242
  ...result,
@@ -256,11 +257,11 @@ FastImage.configureCache = (limits = {}) => Promise.resolve(NativeModules.FastIm
256
257
  FastImage.writeToCache = (source, file) => Array.isArray(source) ? Promise.resolve({
257
258
  ok: false,
258
259
  error: ONE_SOURCE
259
- }) : Promise.resolve(NativeModules.FastImageView.writeToCache(source || {}, file));
260
+ }) : Promise.resolve(NativeModules.FastImageView.writeToCache(isSourceObject(source) ? source : {}, file));
260
261
  FastImage.getCachePath = (source) => Array.isArray(source) ? Promise.resolve({
261
262
  ok: false,
262
263
  error: ONE_SOURCE
263
- }) : Promise.resolve(NativeModules.FastImageView.getCachePath(source || {}));
264
+ }) : Promise.resolve(NativeModules.FastImageView.getCachePath(isSourceObject(source) ? source : {}));
264
265
  const styles = StyleSheet.create({
265
266
  fallbackImage: {
266
267
  position: "absolute",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-fast-image",
3
- "version": "9.3.4",
3
+ "version": "9.3.5",
4
4
  "description": "FastImage, performant React Native image component.",
5
5
  "keywords": [
6
6
  "cache",