expo-image 0.1.0 → 0.2.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.
@@ -45,7 +45,7 @@ android {
45
45
  minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
46
46
  targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
47
47
  versionCode 1
48
- versionName "0.1.0"
48
+ versionName "0.2.0"
49
49
  }
50
50
  lintOptions {
51
51
  abortOnError false
@@ -0,0 +1,4 @@
1
+ import { ImageProps } from './Image';
2
+ declare const ExpoImageModule: any;
3
+ export { ExpoImageModule };
4
+ export default function ExpoImage({ source, style, defaultSource, loadingIndicatorSource, ...props }: ImageProps): JSX.Element;
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import { Image, requireNativeComponent, NativeModules, StyleSheet, Platform, processColor, } from 'react-native';
3
+ const NativeExpoImage = requireNativeComponent('ExpoImage');
4
+ const ExpoImageModule = NativeModules.ExpoImageModule;
5
+ export { ExpoImageModule };
6
+ export default function ExpoImage({ source, style, defaultSource, loadingIndicatorSource, ...props }) {
7
+ const resolvedSource = Image.resolveAssetSource(source ?? {});
8
+ const resolvedStyle = StyleSheet.flatten([style]);
9
+ const resolvedPlaceholder = Image.resolveAssetSource(defaultSource ?? loadingIndicatorSource ?? {});
10
+ // If both are specified, we default to use default source
11
+ if (defaultSource && loadingIndicatorSource) {
12
+ console.warn("<Image> component can't have both defaultSource and loadingIndicatorSource at the same time. Defaulting to defaultSource");
13
+ }
14
+ // When possible, pass through the intrinsic size of the asset to the Yoga layout
15
+ // system. While this is also possible in native code, doing it here is more efficient
16
+ // as the yoga node gets initialized with the correct size from the start.
17
+ // In native code, there is a separation between the layout (shadow) nodes and
18
+ // actual views. Views that update the intrinsic content-size in Yoga trigger
19
+ // additional layout passes, which we want to prevent.
20
+ if (!Array.isArray(resolvedSource)) {
21
+ const { width, height } = resolvedSource;
22
+ resolvedStyle.width = resolvedStyle.width ?? width;
23
+ resolvedStyle.height = resolvedStyle.height ?? height;
24
+ }
25
+ // Shadows behave different on iOS, Android & Web.
26
+ // Android uses the `elevation` prop, whereas iOS
27
+ // and web use the regular `shadow...` props.
28
+ let hasShadows = false;
29
+ if (Platform.OS === 'android') {
30
+ delete resolvedStyle.shadowColor;
31
+ delete resolvedStyle.shadowOffset;
32
+ delete resolvedStyle.shadowOpacity;
33
+ delete resolvedStyle.shadowRadius;
34
+ hasShadows = !!resolvedStyle.elevation;
35
+ }
36
+ else {
37
+ delete resolvedStyle.elevation;
38
+ hasShadows = !!resolvedStyle.shadowColor;
39
+ }
40
+ // Shadows are rendered quite differently on iOS, Android and web.
41
+ // - iOS renders the shadow along the transparent contours of the image.
42
+ // - Android renders an underlay which extends to the inside of the bounds.
43
+ // - Web renders the shadow only on the outside of the bounds.
44
+ // To achieve a consistent appearance on all platforms, it is highly recommended
45
+ // to set a background-color on the Image when using shadows. This will ensure
46
+ // consistent rendering on all platforms and mitigate Androids drawing artefacts.
47
+ if (hasShadows) {
48
+ const processedColor = processColor(resolvedStyle.backgroundColor);
49
+ const bkColor = typeof processedColor === 'number' ? processedColor : 0;
50
+ const alpha = bkColor >> 24;
51
+ if (alpha !== -1 && alpha !== 255) {
52
+ // To silence this warning, set background-color to a fully transparent color
53
+ console.warn(`"expo-image" Shadows may not be rendered correctly for the transparent parts of images. Set "backgroundColor" to a non-transparent color when using a shadow.`);
54
+ }
55
+ }
56
+ return (React.createElement(NativeExpoImage, { ...props, source: resolvedSource, style: resolvedStyle, defaultSource: resolvedPlaceholder }));
57
+ }
58
+ //# sourceMappingURL=ExpoImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoImage.js","sourceRoot":"","sources":["../src/ExpoImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,EACL,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,QAAQ,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,aAAa,CAAC;QACnC,OAAO,aAAa,CAAC,YAAY,CAAC;QAClC,UAAU,GAAG,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC;KACxC;SAAM;QACL,OAAO,aAAa,CAAC,SAAS,CAAC;QAC/B,UAAU,GAAG,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC;KAC1C;IAED,kEAAkE;IAClE,wEAAwE;IACxE,2EAA2E;IAC3E,8DAA8D;IAC9D,gFAAgF;IAChF,8EAA8E;IAC9E,iFAAiF;IACjF,IAAI,UAAU,EAAE;QACd,MAAM,cAAc,GAAG,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACnE,MAAM,OAAO,GAAW,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;QAChF,MAAM,KAAK,GAAG,OAAO,IAAI,EAAE,CAAC;QAC5B,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,GAAG,EAAE;YACjC,6EAA6E;YAC7E,OAAO,CAAC,IAAI,CACV,+JAA+J,CAChK,CAAC;SACH;KACF;IAED,OAAO,CACL,oBAAC,eAAe,OACV,KAAK,EACT,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,aAAa,EACpB,aAAa,EAAE,mBAAmB,GAClC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport {\n Image,\n requireNativeComponent,\n NativeModules,\n StyleSheet,\n Platform,\n processColor,\n} from 'react-native';\n\nimport { ImageProps } from './Image';\n\ntype NativeExpoImageProps = ImageProps;\n\nconst NativeExpoImage = requireNativeComponent<NativeExpoImageProps>('ExpoImage');\n\nconst ExpoImageModule = NativeModules.ExpoImageModule;\n\nexport { ExpoImageModule };\n\nexport default function ExpoImage({\n source,\n style,\n defaultSource,\n loadingIndicatorSource,\n ...props\n}: ImageProps) {\n const resolvedSource = Image.resolveAssetSource(source ?? {});\n const resolvedStyle = StyleSheet.flatten([style]);\n const resolvedPlaceholder = Image.resolveAssetSource(\n defaultSource ?? loadingIndicatorSource ?? {}\n );\n\n // If both are specified, we default to use default source\n if (defaultSource && loadingIndicatorSource) {\n console.warn(\n \"<Image> component can't have both defaultSource and loadingIndicatorSource at the same time. Defaulting to defaultSource\"\n );\n }\n\n // When possible, pass through the intrinsic size of the asset to the Yoga layout\n // system. While this is also possible in native code, doing it here is more efficient\n // as the yoga node gets initialized with the correct size from the start.\n // In native code, there is a separation between the layout (shadow) nodes and\n // actual views. Views that update the intrinsic content-size in Yoga trigger\n // additional layout passes, which we want to prevent.\n if (!Array.isArray(resolvedSource)) {\n const { width, height } = resolvedSource;\n resolvedStyle.width = resolvedStyle.width ?? width;\n resolvedStyle.height = resolvedStyle.height ?? height;\n }\n\n // Shadows behave different on iOS, Android & Web.\n // Android uses the `elevation` prop, whereas iOS\n // and web use the regular `shadow...` props.\n let hasShadows = false;\n if (Platform.OS === 'android') {\n delete resolvedStyle.shadowColor;\n delete resolvedStyle.shadowOffset;\n delete resolvedStyle.shadowOpacity;\n delete resolvedStyle.shadowRadius;\n hasShadows = !!resolvedStyle.elevation;\n } else {\n delete resolvedStyle.elevation;\n hasShadows = !!resolvedStyle.shadowColor;\n }\n\n // Shadows are rendered quite differently on iOS, Android and web.\n // - iOS renders the shadow along the transparent contours of the image.\n // - Android renders an underlay which extends to the inside of the bounds.\n // - Web renders the shadow only on the outside of the bounds.\n // To achieve a consistent appearance on all platforms, it is highly recommended\n // to set a background-color on the Image when using shadows. This will ensure\n // consistent rendering on all platforms and mitigate Androids drawing artefacts.\n if (hasShadows) {\n const processedColor = processColor(resolvedStyle.backgroundColor);\n const bkColor: number = typeof processedColor === 'number' ? processedColor : 0;\n const alpha = bkColor >> 24;\n if (alpha !== -1 && alpha !== 255) {\n // To silence this warning, set background-color to a fully transparent color\n console.warn(\n `\"expo-image\" Shadows may not be rendered correctly for the transparent parts of images. Set \"backgroundColor\" to a non-transparent color when using a shadow.`\n );\n }\n }\n\n return (\n <NativeExpoImage\n {...props}\n source={resolvedSource}\n style={resolvedStyle}\n defaultSource={resolvedPlaceholder}\n />\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ImageProps } from './Image';
2
+ export default function ExpoImage({ source, ...props }: ImageProps): JSX.Element;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { Image } from 'react-native';
3
+ export default function ExpoImage({ source, ...props }) {
4
+ const resolvedSource = source ?? {};
5
+ // @ts-expect-error - expo-image is being reworked so these types should be revisited
6
+ return React.createElement(Image, { ...props, source: resolvedSource });
7
+ }
8
+ //# sourceMappingURL=ExpoImage.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoImage.web.js","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,EAAc;IAChE,MAAM,cAAc,GAAG,MAAM,IAAI,EAAE,CAAC;IAEpC,qFAAqF;IACrF,OAAO,oBAAC,KAAK,OAAK,KAAK,EAAE,MAAM,EAAE,cAAc,GAAI,CAAC;AACtD,CAAC","sourcesContent":["import React from 'react';\nimport { Image } from 'react-native';\n\nimport { ImageProps } from './Image';\n\nexport default function ExpoImage({ source, ...props }: ImageProps) {\n const resolvedSource = source ?? {};\n\n // @ts-expect-error - expo-image is being reworked so these types should be revisited\n return <Image {...props} source={resolvedSource} />;\n}\n"]}
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import { AccessibilityProps, ImageResizeMode, ImageSourcePropType, ImageStyle as RNImageStyle, NativeSyntheticEvent, StyleProp } from 'react-native';
3
+ import { ImageErrorEventData, ImageLoadEventData, ImageLoadProgressEventData } from './Image.types';
4
+ interface ImageStyle extends RNImageStyle {
5
+ elevation?: number;
6
+ }
7
+ export interface ImageProps extends AccessibilityProps {
8
+ source?: ImageSourcePropType | null;
9
+ style?: StyleProp<ImageStyle>;
10
+ defaultSource?: ImageSourcePropType | null;
11
+ loadingIndicatorSource?: ImageSourcePropType | null;
12
+ resizeMode?: ImageResizeMode;
13
+ /**
14
+ * @Android only
15
+ */
16
+ blurRadius?: number;
17
+ fadeDuration?: number;
18
+ onLoadStart?: () => void;
19
+ onProgress?: (event: NativeSyntheticEvent<ImageLoadProgressEventData>) => void;
20
+ onLoad?: (event: NativeSyntheticEvent<ImageLoadEventData>) => void;
21
+ onError?: (error: NativeSyntheticEvent<ImageErrorEventData>) => void;
22
+ onLoadEnd?: () => void;
23
+ }
24
+ interface ImageState {
25
+ onLoad: ImageProps['onLoad'];
26
+ onError: ImageProps['onError'];
27
+ }
28
+ export default class Image extends React.Component<ImageProps, ImageState> {
29
+ static getDerivedStateFromProps(props: ImageProps): {
30
+ onLoad: ((event: NativeSyntheticEvent<ImageLoadEventData>) => void) | undefined;
31
+ onError: ((error: NativeSyntheticEvent<ImageErrorEventData>) => void) | undefined;
32
+ };
33
+ /**
34
+ * **Available on @Android only.** Caching the image that can be later used in ImageView
35
+ * @return an empty promise.
36
+ */
37
+ static prefetch(url: string): Promise<void>;
38
+ state: {
39
+ onLoad: undefined;
40
+ onError: undefined;
41
+ };
42
+ render(): JSX.Element;
43
+ }
44
+ export {};
package/build/Image.js ADDED
@@ -0,0 +1,48 @@
1
+ import { Platform, UnavailabilityError } from 'expo-modules-core';
2
+ import React from 'react';
3
+ import { StyleSheet, } from 'react-native';
4
+ import ExpoImage, { ExpoImageModule } from './ExpoImage';
5
+ const DEFAULT_RESIZE_MODE = 'cover';
6
+ export default class Image extends React.Component {
7
+ static getDerivedStateFromProps(props) {
8
+ return {
9
+ onLoad: props.onLoadEnd
10
+ ? (e) => {
11
+ if (props.onLoad) {
12
+ props.onLoad(e);
13
+ }
14
+ props.onLoadEnd();
15
+ }
16
+ : props.onLoad,
17
+ onError: props.onLoadEnd
18
+ ? (e) => {
19
+ if (props.onError) {
20
+ props.onError(e);
21
+ }
22
+ props.onLoadEnd();
23
+ }
24
+ : props.onError,
25
+ };
26
+ }
27
+ /**
28
+ * **Available on @Android only.** Caching the image that can be later used in ImageView
29
+ * @return an empty promise.
30
+ */
31
+ static async prefetch(url) {
32
+ if (Platform.OS !== 'android') {
33
+ throw new UnavailabilityError('Image', 'prefetch');
34
+ }
35
+ return await ExpoImageModule.prefetch(url);
36
+ }
37
+ state = {
38
+ onLoad: undefined,
39
+ onError: undefined,
40
+ };
41
+ render() {
42
+ const { style, resizeMode: resizeModeProp, ...restProps } = this.props;
43
+ const { resizeMode: resizeModeStyle, ...restStyle } = StyleSheet.flatten([style]) || {};
44
+ const resizeMode = resizeModeProp ?? resizeModeStyle ?? DEFAULT_RESIZE_MODE;
45
+ return (React.createElement(ExpoImage, { ...restProps, style: restStyle, resizeMode: resizeMode, onLoad: this.state.onLoad, onError: this.state.onError }));
46
+ }
47
+ }
48
+ //# sourceMappingURL=Image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Image.js","sourceRoot":"","sources":["../src/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAOL,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,SAAS,EAAE,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGzD,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAmCpC,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,KAAK,CAAC,SAAiC;IACxE,MAAM,CAAC,wBAAwB,CAAC,KAAiB;QAC/C,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,SAAS;gBACrB,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;oBACJ,IAAI,KAAK,CAAC,MAAM,EAAE;wBAChB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;q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CACF","sourcesContent":["import { Platform, UnavailabilityError } from 'expo-modules-core';\nimport React from 'react';\nimport {\n AccessibilityProps,\n ImageResizeMode,\n ImageSourcePropType,\n ImageStyle as RNImageStyle,\n NativeSyntheticEvent,\n StyleProp,\n StyleSheet,\n} from 'react-native';\n\nimport ExpoImage, { ExpoImageModule } from './ExpoImage';\nimport { ImageErrorEventData, ImageLoadEventData, ImageLoadProgressEventData } from './Image.types';\n\nconst DEFAULT_RESIZE_MODE = 'cover';\n\ninterface ImageStyle extends RNImageStyle {\n elevation?: number;\n}\n\nexport interface ImageProps extends AccessibilityProps {\n // On one hand we want to pass resolved source to native module.\n // On the other hand, react-native-web doesn't expose a resolveAssetSource\n // function, so we can't use it there. So we pass the unresolved source\n // to \"native components\" and they decide whether to resolve the value\n // or not.\n source?: ImageSourcePropType | null;\n style?: StyleProp<ImageStyle>;\n defaultSource?: ImageSourcePropType | null;\n loadingIndicatorSource?: ImageSourcePropType | null;\n resizeMode?: ImageResizeMode;\n /**\n * @Android only\n */\n blurRadius?: number;\n fadeDuration?: number;\n\n onLoadStart?: () => void;\n onProgress?: (event: NativeSyntheticEvent<ImageLoadProgressEventData>) => void;\n onLoad?: (event: NativeSyntheticEvent<ImageLoadEventData>) => void;\n onError?: (error: NativeSyntheticEvent<ImageErrorEventData>) => void;\n onLoadEnd?: () => void;\n}\n\ninterface ImageState {\n onLoad: ImageProps['onLoad'];\n onError: ImageProps['onError'];\n}\n\nexport default class Image extends React.Component<ImageProps, ImageState> {\n static getDerivedStateFromProps(props: ImageProps) {\n return {\n onLoad: props.onLoadEnd\n ? (e) => {\n if (props.onLoad) {\n props.onLoad(e);\n }\n props.onLoadEnd!();\n }\n : props.onLoad,\n onError: props.onLoadEnd\n ? (e) => {\n if (props.onError) {\n props.onError(e);\n }\n props.onLoadEnd!();\n }\n : props.onError,\n };\n }\n\n /**\n * **Available on @Android only.** Caching the image that can be later used in ImageView\n * @return an empty promise.\n */\n static async prefetch(url: string): Promise<void> {\n if (Platform.OS !== 'android') {\n throw new UnavailabilityError('Image', 'prefetch');\n }\n return await ExpoImageModule.prefetch(url);\n }\n\n state = {\n onLoad: undefined,\n onError: undefined,\n };\n\n render() {\n const { style, resizeMode: resizeModeProp, ...restProps } = this.props;\n\n const { resizeMode: resizeModeStyle, ...restStyle } = StyleSheet.flatten([style]) || {};\n const resizeMode = resizeModeProp ?? resizeModeStyle ?? DEFAULT_RESIZE_MODE;\n\n return (\n <ExpoImage\n {...restProps}\n style={restStyle}\n resizeMode={resizeMode}\n onLoad={this.state.onLoad}\n onError={this.state.onError}\n />\n );\n }\n}\n"]}
@@ -0,0 +1,41 @@
1
+ export declare enum ImageCacheType {
2
+ UNKNOWN = 0,
3
+ NONE = 1,
4
+ DISK = 2,
5
+ MEMORY = 3
6
+ }
7
+ export interface ImageLoadEventData {
8
+ cacheType?: ImageCacheType;
9
+ source: {
10
+ url: string;
11
+ width: number;
12
+ height: number;
13
+ mediaType?: string | null;
14
+ };
15
+ }
16
+ export interface ImageLoadProgressEventData {
17
+ loaded: number;
18
+ total: number;
19
+ }
20
+ interface AndroidThrowable {
21
+ class: string;
22
+ cause: AndroidThrowable | null;
23
+ message: string;
24
+ }
25
+ interface AndroidGlideException extends AndroidThrowable {
26
+ origin: AndroidThrowable | null;
27
+ causes: AndroidThrowable[] | null;
28
+ }
29
+ export interface ImageErrorEventData {
30
+ error: string;
31
+ ios?: {
32
+ code: number;
33
+ domain: string;
34
+ description: string;
35
+ helpAnchor: string | null;
36
+ failureReason: string | null;
37
+ recoverySuggestion: string | null;
38
+ };
39
+ android?: AndroidGlideException | null;
40
+ }
41
+ export {};
@@ -0,0 +1,8 @@
1
+ export var ImageCacheType;
2
+ (function (ImageCacheType) {
3
+ ImageCacheType[ImageCacheType["UNKNOWN"] = 0] = "UNKNOWN";
4
+ ImageCacheType[ImageCacheType["NONE"] = 1] = "NONE";
5
+ ImageCacheType[ImageCacheType["DISK"] = 2] = "DISK";
6
+ ImageCacheType[ImageCacheType["MEMORY"] = 3] = "MEMORY";
7
+ })(ImageCacheType || (ImageCacheType = {}));
8
+ //# sourceMappingURL=Image.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Image.types.js","sourceRoot":"","sources":["../src/Image.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,yDAAW,CAAA;IACX,mDAAQ,CAAA;IACR,mDAAQ,CAAA;IACR,uDAAU,CAAA;AACZ,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB","sourcesContent":["export enum ImageCacheType {\n UNKNOWN = 0,\n NONE = 1,\n DISK = 2,\n MEMORY = 3,\n}\n\nexport interface ImageLoadEventData {\n cacheType?: ImageCacheType;\n source: {\n url: string;\n width: number;\n height: number;\n mediaType?: string | null;\n };\n}\n\nexport interface ImageLoadProgressEventData {\n loaded: number;\n total: number;\n}\n\ninterface AndroidThrowable {\n class: string;\n cause: AndroidThrowable | null;\n message: string;\n}\n\ninterface AndroidGlideException extends AndroidThrowable {\n origin: AndroidThrowable | null;\n causes: AndroidThrowable[] | null;\n}\n\nexport interface ImageErrorEventData {\n error: string;\n ios?: {\n code: number;\n domain: string;\n description: string;\n helpAnchor: string | null;\n failureReason: string | null;\n recoverySuggestion: string | null;\n };\n android?: AndroidGlideException | null;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import Image from './Image';
2
+ export * from './Image.types';
3
+ export default Image;
package/build/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import Image from './Image';
2
+ export * from './Image.types';
3
+ export default Image;
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,eAAe,KAAK,CAAC","sourcesContent":["import Image from './Image';\nexport * from './Image.types';\nexport default Image;\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-image",
3
3
  "title": "Expo Image",
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "description": "A cross-platform, performant image component for React Native and Expo with Web support",
6
6
  "main": "build/index.js",
7
7
  "types": "build/index.d.ts",
@@ -26,8 +26,12 @@
26
26
  ],
27
27
  "author": "650 Industries, Inc.",
28
28
  "license": "MIT",
29
+ "dependencies": {},
29
30
  "devDependencies": {
30
31
  "expo-module-scripts": "^2.0.0"
31
32
  },
32
- "gitHead": "b2384f7dfa01d2455f771fd7c94169e15ed76aad"
33
+ "peerDependencies": {
34
+ "expo": "*"
35
+ },
36
+ "gitHead": "2e5c6983b86d5ecfca028ba64002897d8adc2cc4"
33
37
  }