Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<h1 align="center">
🚩 UNSUPPORTED FORK! The orgininal repo https://github.com/DylanVann/react-native-fast-image is not supported anymore. This repo fixed a critical problem for iOS 17 muntius/react-native-fast-image, but didn't update the releases or npm registry. This repo just includes the built dist folder so that it can be installed with npm by adding "react-native-fast-image": "github:nReality/react-native-fast-image" to package.json
</h1>

<h1 align="center">
🚩 FastImage
</h1>
Expand Down
137 changes: 137 additions & 0 deletions dist/index.cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
'use strict';

var _extends = require('@babel/runtime/helpers/extends');
var React = require('react');
var reactNative = require('react-native');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const resizeMode = {
contain: 'contain',
cover: 'cover',
stretch: 'stretch',
center: 'center'
};
const priority = {
low: 'low',
normal: 'normal',
high: 'high'
};
const cacheControl = {
// Ignore headers, use uri as cache key, fetch only if not in cache.
immutable: 'immutable',
// Respect http headers, no aggressive caching.
web: 'web',
// Only load from cache.
cacheOnly: 'cacheOnly'
};
const resolveDefaultSource = defaultSource => {
if (!defaultSource) {
return null;
}
if (reactNative.Platform.OS === 'android') {
// Android receives a URI string, and resolves into a Drawable using RN's methods.
const resolved = reactNative.Image.resolveAssetSource(defaultSource);
if (resolved) {
return resolved.uri;
}
return null;
}
// iOS or other number mapped assets
// In iOS the number is passed, and bridged automatically into a UIImage
return defaultSource;
};
function FastImageBase({
source,
defaultSource,
tintColor,
blurRadius,
onLoadStart,
onProgress,
onLoad,
onError,
onLoadEnd,
style,
fallback,
children,
// eslint-disable-next-line no-shadow
resizeMode = 'cover',
forwardedRef,
...props
}) {
if (fallback) {
const cleanedSource = {
...source
};
delete cleanedSource.cache;
const resolvedSource = reactNative.Image.resolveAssetSource(cleanedSource);
return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
style: [styles.imageContainer, style],
ref: forwardedRef
}, /*#__PURE__*/React__default["default"].createElement(reactNative.Image, _extends__default["default"]({}, props, {
style: [reactNative.StyleSheet.absoluteFill, {
tintColor
}],
source: resolvedSource,
defaultSource: defaultSource,
onLoadStart: onLoadStart,
onProgress: onProgress,
onLoad: onLoad,
onError: onError,
onLoadEnd: onLoadEnd,
resizeMode: resizeMode,
blurRadius: blurRadius
})), children);
}
const resolvedSource = reactNative.Image.resolveAssetSource(source);
const resolvedDefaultSource = resolveDefaultSource(defaultSource);
return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
style: [styles.imageContainer, style],
ref: forwardedRef
}, /*#__PURE__*/React__default["default"].createElement(FastImageView, _extends__default["default"]({}, props, {
tintColor: tintColor,
style: reactNative.StyleSheet.absoluteFill,
source: resolvedSource,
defaultSource: resolvedDefaultSource,
onFastImageLoadStart: onLoadStart,
onFastImageProgress: onProgress,
onFastImageLoad: onLoad,
onFastImageError: onError,
onFastImageLoadEnd: onLoadEnd,
resizeMode: resizeMode,
blurRadius: blurRadius
})), children);
}
const FastImageMemo = /*#__PURE__*/React.memo(FastImageBase);
const FastImageComponent = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React__default["default"].createElement(FastImageMemo, _extends__default["default"]({
forwardedRef: ref
}, props)));
FastImageComponent.displayName = 'FastImage';
const FastImage = FastImageComponent;
FastImage.resizeMode = resizeMode;
FastImage.cacheControl = cacheControl;
FastImage.priority = priority;
FastImage.preload = sources => reactNative.NativeModules.FastImageView.preload(sources);
FastImage.clearMemoryCache = () => reactNative.NativeModules.FastImageView.clearMemoryCache();
FastImage.clearDiskCache = () => reactNative.NativeModules.FastImageView.clearDiskCache();
const styles = reactNative.StyleSheet.create({
imageContainer: {
overflow: 'hidden'
}
});

// Types of requireNativeComponent are not correct.
const FastImageView = reactNative.requireNativeComponent('FastImageView', FastImage, {
nativeOnly: {
onFastImageLoadStart: true,
onFastImageProgress: true,
onFastImageLoad: true,
onFastImageError: true,
onFastImageLoadEnd: true
}
});

module.exports = FastImage;
77 changes: 77 additions & 0 deletions dist/index.cjs.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// @flow

import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes'
import type { SyntheticEvent } from 'react-native/Libraries/Types/CoreEventTypes'

export type OnLoadEvent = SyntheticEvent<
$ReadOnly<{
width: number,
height: number,
}>
>

export type OnProgressEvent = SyntheticEvent<
$ReadOnly<{|
loaded: number,
total: number,
|}>
>

export type ResizeMode = $ReadOnly<{|
contain: 'contain',
cover: 'cover',
stretch: 'stretch',
center: 'center',
|}>

export type Priority = $ReadOnly<{|
low: 'low',
normal: 'normal',
high: 'high',
|}>

export type CacheControl = $ReadOnly<{|
immutable: 'immutable',
web: 'web',
cacheOnly: 'cacheOnly',
|}>

export type ResizeModes = $Values<ResizeMode>
export type Priorities = $Values<Priority>
export type CacheControls = $Values<CacheControl>

export type PreloadFn = (sources: Array<FastImageSource>) => void
export type FastImageSource = {
uri?: string,
headers?: Object,
priority?: Priorities,
cache?: CacheControls,
cacheKeyIgnoreURLParams?: boolean,
}

export type FastImageProps = $ReadOnly<{|
...ViewProps,
onError?: ?() => void,
onLoad?: ?(event: OnLoadEvent) => void,
onLoadEnd?: ?() => void,
onLoadStart?: ?() => void,
onProgress?: ?(event: OnProgressEvent) => void,

source?: ?(FastImageSource | number),
defaultSource?: ?number,

tintColor?: number | string,
blurRadius?: number,
resizeMode?: ?ResizeModes,
fallback?: ?boolean,
testID?: ?string,
|}>

declare export default class FastImage extends React$Component<FastImageProps> {
static resizeMode: ResizeMode;
static priority: Priority;
static cacheControl: CacheControl;
static preload: PreloadFn;
static clearMemoryCache: () => Promise<void>;
static clearDiskCache: () => Promise<void>;
}
111 changes: 111 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React from 'react';
import { AccessibilityProps, ColorValue, FlexStyle, ImageRequireSource, LayoutChangeEvent, ShadowStyleIOS, StyleProp, TransformsStyle, ViewProps } from 'react-native';
export type ResizeMode = 'contain' | 'cover' | 'stretch' | 'center';
declare const resizeMode: {
readonly contain: "contain";
readonly cover: "cover";
readonly stretch: "stretch";
readonly center: "center";
};
export type Priority = 'low' | 'normal' | 'high';
declare const priority: {
readonly low: "low";
readonly normal: "normal";
readonly high: "high";
};
export type Cache = 'immutable' | 'web' | 'cacheOnly';
declare const cacheControl: {
readonly immutable: "immutable";
readonly web: "web";
readonly cacheOnly: "cacheOnly";
};
export type Source = {
uri?: string;
headers?: {
[key: string]: string;
};
priority?: Priority;
cache?: Cache;
cacheKeyIgnoreURLParams?: boolean;
blurRadius?: number;
};
export interface OnLoadEvent {
nativeEvent: {
width: number;
height: number;
};
}
export interface OnProgressEvent {
nativeEvent: {
loaded: number;
total: number;
};
}
export interface ImageStyle extends FlexStyle, TransformsStyle, ShadowStyleIOS {
backfaceVisibility?: 'visible' | 'hidden';
borderBottomLeftRadius?: number;
borderBottomRightRadius?: number;
backgroundColor?: string;
borderColor?: string;
borderWidth?: number;
borderRadius?: number;
borderTopLeftRadius?: number;
borderTopRightRadius?: number;
overlayColor?: string;
opacity?: number;
}
export interface FastImageProps extends AccessibilityProps, ViewProps {
source?: Source | ImageRequireSource;
defaultSource?: ImageRequireSource;
resizeMode?: ResizeMode;
fallback?: boolean;
onLoadStart?(): void;
onProgress?(event: OnProgressEvent): void;
onLoad?(event: OnLoadEvent): void;
onError?(): void;
onLoadEnd?(): void;
/**
* onLayout function
*
* Invoked on mount and layout changes with
*
* {nativeEvent: { layout: {x, y, width, height}}}.
*/
onLayout?: (event: LayoutChangeEvent) => void;
/**
*
* Style
*/
style?: StyleProp<ImageStyle>;
/**
* TintColor
*
* If supplied, changes the color of all the non-transparent pixels to the given color.
*/
tintColor?: ColorValue;
/**
* BlurRadius
*
* The blur radius of the blur filter added to the image.
*/
blurRadius?: number;
/**
* A unique identifier for this element to be used in UI Automation testing scripts.
*/
testID?: string;
/**
* Render children within the image.
*/
children?: React.ReactNode;
}
export interface FastImageStaticProperties {
resizeMode: typeof resizeMode;
priority: typeof priority;
cacheControl: typeof cacheControl;
preload: (sources: Source[]) => void;
clearMemoryCache: () => Promise<void>;
clearDiskCache: () => Promise<void>;
}
declare const FastImage: React.ComponentType<FastImageProps> & FastImageStaticProperties;
export default FastImage;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading