expo-image 1.4.1 → 1.5.1
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/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/android/build.gradle +11 -8
- package/build/ExpoImage.web.d.ts.map +1 -1
- package/build/ExpoImage.web.js.map +1 -1
- package/build/utils/resolveSources.d.ts.map +1 -1
- package/build/utils/resolveSources.js.map +1 -1
- package/build/web/AnimationManager.js.map +1 -1
- package/build/web/ImageWrapper.d.ts.map +1 -1
- package/build/web/ImageWrapper.js +3 -3
- package/build/web/ImageWrapper.js.map +1 -1
- package/build/web/ImageWrapper.types.d.ts +1 -1
- package/build/web/ImageWrapper.types.d.ts.map +1 -1
- package/build/web/ImageWrapper.types.js.map +1 -1
- package/build/web/getImageWrapperEventHandler.d.ts +1 -1
- package/build/web/getImageWrapperEventHandler.d.ts.map +1 -1
- package/build/web/getImageWrapperEventHandler.js.map +1 -1
- package/build/web/useSourceSelection.js +3 -1
- package/build/web/useSourceSelection.js.map +1 -1
- package/ios/ExpoImage.podspec +3 -3
- package/ios/ImageView.swift +7 -1
- package/package.json +2 -2
- package/src/ExpoImage.web.tsx +41 -43
- package/src/utils/resolveSources.tsx +1 -1
- package/src/web/AnimationManager.tsx +1 -1
- package/src/web/ImageWrapper.tsx +4 -4
- package/src/web/ImageWrapper.types.ts +1 -1
- package/src/web/getImageWrapperEventHandler.ts +1 -1
- package/src/web/useSourceSelection.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,23 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 1.5.1 — 2023-09-11
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Suppress "Operation cancelled by user during sending the request" error when the load request is canceled (interrupted) by a new one. ([#24279](https://github.com/expo/expo/pull/24279) by [@tsapeta](https://github.com/tsapeta))
|
|
18
|
+
- Fixed gif and awebp memory leak on Android. ([#24259](https://github.com/expo/expo/pull/24259) by [@jingpeng](https://github.com/jingpeng))
|
|
19
|
+
|
|
20
|
+
## 1.5.0 — 2023-09-04
|
|
21
|
+
|
|
22
|
+
### 🎉 New features
|
|
23
|
+
|
|
24
|
+
- Added support for React Native 0.73. ([#24018](https://github.com/expo/expo/pull/24018) by [@kudo](https://github.com/kudo))
|
|
25
|
+
|
|
26
|
+
### 💡 Others
|
|
27
|
+
|
|
28
|
+
- On iOS, bump SDWebImage versions. ([#23858](https://github.com/expo/expo/pull/23858) by [@alanjhughes](https://github.com/alanjhughes))
|
|
29
|
+
|
|
13
30
|
## 1.4.1 — 2023-08-02
|
|
14
31
|
|
|
15
32
|
_This version does not introduce any user-facing changes._
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ A cross-platform, performant image component for React Native and Expo.
|
|
|
39
39
|
|
|
40
40
|
# Installation
|
|
41
41
|
|
|
42
|
-
> Currently `expo-image` can be used only with [development builds](/
|
|
42
|
+
> Currently `expo-image` can be used only with [development builds](https://docs.expo.dev/develop/development-builds/introduction/), in Expo Go, and bare React Native apps with [configured Expo modules](https://docs.expo.dev/bare/installing-expo-modules/).
|
|
43
43
|
> It is not available with Snack yet.
|
|
44
44
|
|
|
45
45
|
Add the package to your dependencies with the following commands:
|
package/android/build.gradle
CHANGED
|
@@ -36,13 +36,16 @@ buildscript {
|
|
|
36
36
|
android {
|
|
37
37
|
compileSdkVersion safeExtGet("compileSdkVersion", 33)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
40
|
+
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
|
|
41
|
+
compileOptions {
|
|
42
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
43
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
44
|
+
}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
kotlinOptions {
|
|
47
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
48
|
+
}
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
namespace "expo.modules.image"
|
|
@@ -50,7 +53,7 @@ android {
|
|
|
50
53
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
51
54
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
52
55
|
versionCode 1
|
|
53
|
-
versionName "1.
|
|
56
|
+
versionName "1.5.1"
|
|
54
57
|
consumerProguardFiles("proguard-rules.pro")
|
|
55
58
|
}
|
|
56
59
|
lintOptions {
|
|
@@ -97,7 +100,7 @@ dependencies {
|
|
|
97
100
|
kapt "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
|
|
98
101
|
api 'com.caverock:androidsvg-aar:1.4'
|
|
99
102
|
|
|
100
|
-
implementation "com.github.penfeizhou.android.animation:glide-plugin:2.
|
|
103
|
+
implementation "com.github.penfeizhou.android.animation:glide-plugin:2.28.0"
|
|
101
104
|
implementation "com.github.bumptech.glide:avif-integration:${GLIDE_VERSION}"
|
|
102
105
|
|
|
103
106
|
api 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoImage.web.d.ts","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,eAAe,CAAC;AAQlF,eAAO,MAAM,eAAe;mBACX,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;wBAQb,QAAQ,OAAO,CAAC;sBAIlB,QAAQ,OAAO,CAAC;CAGzC,CAAC;AA+BF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ExpoImage.web.d.ts","sourceRoot":"","sources":["../src/ExpoImage.web.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,eAAe,CAAC;AAQlF,eAAO,MAAM,eAAe;mBACX,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;wBAQb,QAAQ,OAAO,CAAC;sBAIlB,QAAQ,OAAO,CAAC;CAGzC,CAAC;AA+BF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,eA8ElB"}
|
|
@@ -1 +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,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,OAAO,gBAA0C,MAAM,wBAAwB,CAAC;AAChF,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D,SAAS,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,IAAuB;QAC9B,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtD,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACxB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,EAAE,QAAQ,EAClB,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAC/E,8BAA8B,EAAE,eAAe,EAC/C,oBAAoB,EAAE,aAAa,EACnC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,GAC5C,CACH;KACJ,CAAC;IACF,OAAO,CACL,oBAAC,IAAI,IAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC;QAC3F,oBAAC,gBAAgB,IAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,IACvF,WAAW,CACK,CACd,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { View } from 'react-native-web';\n\nimport { ImageNativeProps, ImageSource, ImageLoadEventData } from './Image.types';\nimport AnimationManager, { AnimationManagerNode } from './web/AnimationManager';\nimport ImageWrapper from './web/ImageWrapper';\nimport loadStyle from './web/imageStyles';\nimport useSourceSelection from './web/useSourceSelection';\n\nloadStyle();\n\nexport const ExpoImageModule = {\n prefetch(urls: string | string[]): void {\n const urlsArray = Array.isArray(urls) ? urls : [urls];\n urlsArray.forEach((url) => {\n const img = new Image();\n img.src = url;\n });\n },\n\n async clearMemoryCache(): Promise<boolean> {\n return false;\n },\n\n async clearDiskCache(): Promise<boolean> {\n return false;\n },\n};\n\nfunction onLoadAdapter(onLoad?: (event: ImageLoadEventData) => void) {\n return (event: React.SyntheticEvent<HTMLImageElement, Event>) => {\n const target = event.target as HTMLImageElement;\n onLoad?.({\n source: {\n url: target.currentSrc,\n width: target.naturalWidth,\n height: target.naturalHeight,\n mediaType: null,\n },\n cacheType: 'none',\n });\n };\n}\n\nfunction onErrorAdapter(onError?: { (event: { error: string }): void }) {\n return ({ source }: { source?: ImageSource | null }) => {\n onError?.({\n error: `Failed to load image from url: ${source?.uri}`,\n });\n };\n}\n\n// Used for some transitions to mimic native animations\nconst setCssVariables = (element: HTMLElement, size: DOMRect) => {\n element?.style.setProperty('--expo-image-width', `${size.width}px`);\n element?.style.setProperty('--expo-image-height', `${size.height}px`);\n};\n\nexport default function ExpoImage({\n source,\n placeholder,\n contentFit,\n contentPosition,\n placeholderContentFit,\n onLoad,\n transition,\n onError,\n responsivePolicy,\n onLoadEnd,\n priority,\n blurRadius,\n recyclingKey,\n style,\n ...props\n}: ImageNativeProps) {\n const imagePlaceholderContentFit = placeholderContentFit || 'scale-down';\n const blurhashStyle = {\n objectFit: placeholderContentFit || contentFit,\n };\n const { containerRef, source: selectedSource } = useSourceSelection(\n source,\n responsivePolicy,\n setCssVariables\n );\n\n const initialNodeAnimationKey =\n (recyclingKey ? `${recyclingKey}-${placeholder?.[0]?.uri}` : placeholder?.[0]?.uri) ?? '';\n\n const initialNode: AnimationManagerNode | null = placeholder?.[0]?.uri\n ? [\n initialNodeAnimationKey,\n ({ onAnimationFinished }) =>\n (className, style) => (\n <ImageWrapper\n {...props}\n source={placeholder?.[0]}\n style={{\n objectFit: imagePlaceholderContentFit,\n ...(blurRadius ? { filter: `blur(${blurRadius}px)` } : {}),\n ...style,\n }}\n className={className}\n events={{\n onTransitionEnd: [onAnimationFinished],\n }}\n contentPosition={{ left: '50%', top: '50%' }}\n hashPlaceholderContentPosition={contentPosition}\n hashPlaceholderStyle={blurhashStyle}\n />\n ),\n ]\n : null;\n\n const currentNodeAnimationKey =\n (recyclingKey\n ? `${recyclingKey}-${selectedSource?.uri ?? placeholder?.[0]?.uri}`\n : selectedSource?.uri ?? placeholder?.[0]?.uri) ?? '';\n\n const currentNode: AnimationManagerNode = [\n currentNodeAnimationKey,\n ({ onAnimationFinished, onReady, onMount, onError: onErrorInner }) =>\n (className, style) => (\n <ImageWrapper\n {...props}\n source={selectedSource || placeholder?.[0]}\n events={{\n onError: [onErrorAdapter(onError), onLoadEnd, onErrorInner],\n onLoad: [onLoadAdapter(onLoad), onLoadEnd, onReady],\n onMount: [onMount],\n onTransitionEnd: [onAnimationFinished],\n }}\n style={{\n objectFit: selectedSource ? contentFit : imagePlaceholderContentFit,\n ...(blurRadius ? { filter: `blur(${blurRadius}px)` } : {}),\n ...style,\n }}\n className={className}\n priority={priority}\n contentPosition={selectedSource ? contentPosition : { top: '50%', left: '50%' }}\n hashPlaceholderContentPosition={contentPosition}\n hashPlaceholderStyle={blurhashStyle}\n accessibilityLabel={props.accessibilityLabel}\n />\n ),\n ];\n return (\n <View ref={containerRef} dataSet={{ expoimage: true }} style={[{ overflow: 'hidden' }, style]}>\n <AnimationManager transition={transition} recyclingKey={recyclingKey} initial={initialNode}>\n {currentNode}\n </AnimationManager>\n </View>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSources.d.ts","sourceRoot":"","sources":["../../src/utils/resolveSources.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveSources.d.ts","sourceRoot":"","sources":["../../src/utils/resolveSources.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAe,MAAM,gBAAgB,CAAC;AAE3E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAErD;AAID,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEtD;AA2BD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAKzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSources.js","sourceRoot":"","sources":["../../src/utils/resolveSources.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveSources.js","sourceRoot":"","sources":["../../src/utils/resolveSources.tsx"],"names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CAAC,OAA8B;IAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAkB,CAAC;KACpE;IACD,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAkB,CAAC;AACnE,CAAC","sourcesContent":["import resolveAssetSource from './resolveAssetSource';\nimport { resolveBlurhashString, resolveThumbhashString } from './resolveHashString';\nimport { ImageNativeProps, ImageProps, ImageSource } from '../Image.types';\n\nexport function isBlurhashString(str: string): boolean {\n return /^(blurhash:\\/)?[\\w#$%*+,\\-.:;=?@[\\]^_{}|~]+(\\/[\\d.]+)*$/.test(str);\n}\n\n// Base64 strings will be recognized as blurhash by default (to keep compatibility),\n// interpret as thumbhash only if correct uri scheme is provided\nexport function isThumbhashString(str: string): boolean {\n return str.startsWith('thumbhash:/');\n}\n\nfunction resolveSource(source?: ImageSource | string | number | null): ImageSource | null {\n if (typeof source === 'string') {\n if (isBlurhashString(source)) {\n return resolveBlurhashString(source);\n } else if (isThumbhashString(source)) {\n return resolveThumbhashString(source);\n }\n return { uri: source };\n }\n if (typeof source === 'number') {\n return resolveAssetSource(source);\n }\n if (typeof source === 'object' && (source?.blurhash || source?.thumbhash)) {\n const { blurhash, thumbhash, ...restSource } = source;\n const resolved = thumbhash\n ? resolveThumbhashString(thumbhash)\n : resolveBlurhashString(blurhash as string);\n return {\n ...resolved,\n ...restSource,\n };\n }\n return source ?? null;\n}\n\n/**\n * Resolves provided `source` prop to an array of objects expected by the native implementation.\n */\nexport function resolveSources(sources?: ImageProps['source']): ImageNativeProps['source'] {\n if (Array.isArray(sources)) {\n return sources.map(resolveSource).filter(Boolean) as ImageSource[];\n }\n return [resolveSource(sources)].filter(Boolean) as ImageSource[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimationManager.js","sourceRo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KAAK,SAAS,CAAC;SACrC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACV,6BAAK,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,YAAY,IAC3D,qBAAqB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAChD,CACP,CAAC,CACH,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport { ImageTransition } from '../Image.types';\n\ntype Callbacks = {\n onReady?: (() => void) | null;\n onAnimationFinished?: (() => void) | null;\n onMount?: (() => void) | null;\n onError?: (() => void) | null;\n};\n\nexport type AnimationManagerNode = [\n key: string,\n renderFunction: (\n renderProps: NonNullable<Callbacks>\n ) => (className: string, style: React.CSSProperties) => React.ReactElement\n];\n\nconst SUPPORTED_ANIMATIONS: ImageTransition['effect'][] = [\n 'cross-dissolve',\n 'flip-from-left',\n 'flip-from-right',\n 'flip-from-top',\n 'flip-from-bottom',\n];\n\ntype NodeStatus = 'mounted' | 'in' | 'active' | 'out' | 'errored';\n\nfunction useAnimationManagerNode(node: AnimationManagerNode | null, initialStatus?: NodeStatus) {\n const newNode = React.useMemo(() => {\n if (!node) {\n return null;\n }\n const [animationKey, renderFunction] = node;\n // key, ReactElement, ref, callbacks\n return {\n animationKey,\n persistedElement: renderFunction,\n status: (initialStatus || 'mounted') as NodeStatus,\n };\n }, [node?.[0]]);\n return newNode;\n}\n\nfunction validateTimingFunctionForAnimation(\n animationClass: ImageTransition['effect'],\n timingFunction: ImageTransition['timing']\n) {\n if (animationClass?.includes('flip')) {\n if (timingFunction?.includes('ease')) {\n return 'ease-in-out';\n }\n return 'linear';\n }\n return timingFunction || null;\n}\n\nfunction validateAnimationClass(effect: ImageTransition['effect']) {\n if (SUPPORTED_ANIMATIONS.includes(effect)) {\n return effect;\n }\n return 'cross-dissolve';\n}\n\nexport function getAnimatorFromTransition(transition: ImageTransition | null | undefined) {\n if (!transition?.duration) {\n return null;\n }\n const animationClass = validateAnimationClass(transition.effect);\n if (!animationClass) {\n return {\n startingClass: '',\n animateInClass: '',\n animateOutClass: '',\n containerClass: '',\n timingFunction: 'linear',\n animationClass: '',\n duration: 0,\n };\n }\n\n const timingFunction = validateTimingFunctionForAnimation(animationClass, transition.timing);\n const timingClass = `image-timing-${timingFunction}`;\n\n return {\n startingClass: `${animationClass}-start`,\n animateInClass: [animationClass, 'transitioning', `${animationClass}-active`, timingClass].join(\n ' '\n ),\n animateOutClass: [animationClass, `${animationClass}-end`, timingClass].join(' '),\n containerClass: `${animationClass}-container`,\n timingFunction,\n animationClass,\n duration: transition?.duration || 0,\n };\n}\n\ntype MountedAnimationNode = {\n animationKey: string;\n persistedElement: (\n renderProps: Callbacks\n ) => (className: string, style: React.CSSProperties) => React.ReactElement;\n status: NodeStatus;\n};\n\nexport default function AnimationManager({\n children: renderFunction,\n initial,\n transition,\n recyclingKey,\n}: {\n children: AnimationManagerNode;\n initial: AnimationManagerNode | null;\n transition: ImageTransition | null | undefined;\n recyclingKey?: string | null | undefined;\n}) {\n const animation = getAnimatorFromTransition(transition);\n\n const initialNode = useAnimationManagerNode(initial, 'active');\n\n const [nodes, setNodes] = React.useState<MountedAnimationNode[]>(\n initialNode ? [initialNode] : []\n );\n\n const [prevRecyclingKey, setPrevRecyclingKey] = React.useState<string>(recyclingKey ?? '');\n if (prevRecyclingKey !== (recyclingKey ?? '')) {\n setPrevRecyclingKey(recyclingKey ?? '');\n setNodes(initialNode ? [initialNode] : []);\n }\n\n const removeAllNodesOfKeyExceptShowing = (key?: string) => {\n setNodes((n) =>\n n.filter(\n (node) =>\n (key ? node.animationKey !== key : false) ||\n node.status === 'in' ||\n node.status === 'active'\n )\n );\n };\n\n const newNode = useAnimationManagerNode(renderFunction);\n\n React.useEffect(() => {\n setNodes((n) => {\n if (!newNode) {\n return n;\n }\n const existingNodeIndex = n.findIndex((node) => node.animationKey === newNode.animationKey);\n if (existingNodeIndex >= 0) {\n if (animation) {\n return n.map((n2) =>\n n2.animationKey === newNode.animationKey\n ? { ...newNode, status: 'in' }\n : { ...n2, status: 'out' }\n );\n } else {\n return [{ ...newNode, status: 'in' }];\n }\n }\n return [...n, newNode];\n });\n }, [newNode]);\n\n function wrapNodeWithCallbacks(node: MountedAnimationNode) {\n if (renderFunction[0] === node.animationKey) {\n return renderFunction[1]({\n onReady: () => {\n if (animation) {\n setNodes((nodes) =>\n nodes.map((n) => (n === newNode ? { ...n, status: 'in' } : { ...n, status: 'out' }))\n );\n } else {\n setNodes([{ ...node, status: 'in' }]);\n }\n },\n onAnimationFinished: () => {\n setNodes([{ ...node, status: 'in' }]);\n },\n onError: () => {\n setNodes((nodes) => nodes.map((n) => (n === node ? { ...n, status: 'errored' } : n)));\n },\n });\n }\n if (initial?.[0] === node.animationKey) {\n return initial[1]({\n onAnimationFinished: () => {\n if (node.status === 'out') {\n removeAllNodesOfKeyExceptShowing(node.animationKey);\n }\n },\n onError: () => {\n setNodes((nodes) => nodes.map((n) => (n === node ? { ...n, status: 'errored' } : n)));\n },\n });\n }\n return node.persistedElement({\n onAnimationFinished: () => {\n removeAllNodesOfKeyExceptShowing(node.animationKey);\n },\n });\n }\n const styles = {\n transitionDuration: `${animation?.duration || 0}ms`,\n transitionTimingFunction: animation?.timingFunction || 'linear',\n };\n const classes = {\n in: animation?.animateInClass,\n out: animation?.animateOutClass,\n mounted: animation?.startingClass,\n };\n\n return (\n <>\n {[...nodes]\n .filter((n) => n.status !== 'errored')\n .map((n) => (\n <div className={animation?.containerClass} key={n.animationKey}>\n {wrapNodeWithCallbacks(n)(classes[n.status], styles)}\n </div>\n ))}\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AnimationManager.js","sourceRoot":"","sources":["../../src/web/AnimationManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAkB1B,MAAM,oBAAoB,GAAgC;IACxD,gBAAgB;IAChB,gBAAgB;I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AY,IAC3D,qBAAqB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAChD,CACP,CAAC,CACH,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport { ImageTransition } from '../Image.types';\n\ntype Callbacks = {\n onReady?: (() => void) | null;\n onAnimationFinished?: (() => void) | null;\n onMount?: (() => void) | null;\n onError?: (() => void) | null;\n};\n\nexport type AnimationManagerNode = [\n key: string,\n renderFunction: (\n renderProps: NonNullable<Callbacks>\n ) => (className: string, style: React.CSSProperties) => React.ReactElement,\n];\n\nconst SUPPORTED_ANIMATIONS: ImageTransition['effect'][] = [\n 'cross-dissolve',\n 'flip-from-left',\n 'flip-from-right',\n 'flip-from-top',\n 'flip-from-bottom',\n];\n\ntype NodeStatus = 'mounted' | 'in' | 'active' | 'out' | 'errored';\n\nfunction useAnimationManagerNode(node: AnimationManagerNode | null, initialStatus?: NodeStatus) {\n const newNode = React.useMemo(() => {\n if (!node) {\n return null;\n }\n const [animationKey, renderFunction] = node;\n // key, ReactElement, ref, callbacks\n return {\n animationKey,\n persistedElement: renderFunction,\n status: (initialStatus || 'mounted') as NodeStatus,\n };\n }, [node?.[0]]);\n return newNode;\n}\n\nfunction validateTimingFunctionForAnimation(\n animationClass: ImageTransition['effect'],\n timingFunction: ImageTransition['timing']\n) {\n if (animationClass?.includes('flip')) {\n if (timingFunction?.includes('ease')) {\n return 'ease-in-out';\n }\n return 'linear';\n }\n return timingFunction || null;\n}\n\nfunction validateAnimationClass(effect: ImageTransition['effect']) {\n if (SUPPORTED_ANIMATIONS.includes(effect)) {\n return effect;\n }\n return 'cross-dissolve';\n}\n\nexport function getAnimatorFromTransition(transition: ImageTransition | null | undefined) {\n if (!transition?.duration) {\n return null;\n }\n const animationClass = validateAnimationClass(transition.effect);\n if (!animationClass) {\n return {\n startingClass: '',\n animateInClass: '',\n animateOutClass: '',\n containerClass: '',\n timingFunction: 'linear',\n animationClass: '',\n duration: 0,\n };\n }\n\n const timingFunction = validateTimingFunctionForAnimation(animationClass, transition.timing);\n const timingClass = `image-timing-${timingFunction}`;\n\n return {\n startingClass: `${animationClass}-start`,\n animateInClass: [animationClass, 'transitioning', `${animationClass}-active`, timingClass].join(\n ' '\n ),\n animateOutClass: [animationClass, `${animationClass}-end`, timingClass].join(' '),\n containerClass: `${animationClass}-container`,\n timingFunction,\n animationClass,\n duration: transition?.duration || 0,\n };\n}\n\ntype MountedAnimationNode = {\n animationKey: string;\n persistedElement: (\n renderProps: Callbacks\n ) => (className: string, style: React.CSSProperties) => React.ReactElement;\n status: NodeStatus;\n};\n\nexport default function AnimationManager({\n children: renderFunction,\n initial,\n transition,\n recyclingKey,\n}: {\n children: AnimationManagerNode;\n initial: AnimationManagerNode | null;\n transition: ImageTransition | null | undefined;\n recyclingKey?: string | null | undefined;\n}) {\n const animation = getAnimatorFromTransition(transition);\n\n const initialNode = useAnimationManagerNode(initial, 'active');\n\n const [nodes, setNodes] = React.useState<MountedAnimationNode[]>(\n initialNode ? [initialNode] : []\n );\n\n const [prevRecyclingKey, setPrevRecyclingKey] = React.useState<string>(recyclingKey ?? '');\n if (prevRecyclingKey !== (recyclingKey ?? '')) {\n setPrevRecyclingKey(recyclingKey ?? '');\n setNodes(initialNode ? [initialNode] : []);\n }\n\n const removeAllNodesOfKeyExceptShowing = (key?: string) => {\n setNodes((n) =>\n n.filter(\n (node) =>\n (key ? node.animationKey !== key : false) ||\n node.status === 'in' ||\n node.status === 'active'\n )\n );\n };\n\n const newNode = useAnimationManagerNode(renderFunction);\n\n React.useEffect(() => {\n setNodes((n) => {\n if (!newNode) {\n return n;\n }\n const existingNodeIndex = n.findIndex((node) => node.animationKey === newNode.animationKey);\n if (existingNodeIndex >= 0) {\n if (animation) {\n return n.map((n2) =>\n n2.animationKey === newNode.animationKey\n ? { ...newNode, status: 'in' }\n : { ...n2, status: 'out' }\n );\n } else {\n return [{ ...newNode, status: 'in' }];\n }\n }\n return [...n, newNode];\n });\n }, [newNode]);\n\n function wrapNodeWithCallbacks(node: MountedAnimationNode) {\n if (renderFunction[0] === node.animationKey) {\n return renderFunction[1]({\n onReady: () => {\n if (animation) {\n setNodes((nodes) =>\n nodes.map((n) => (n === newNode ? { ...n, status: 'in' } : { ...n, status: 'out' }))\n );\n } else {\n setNodes([{ ...node, status: 'in' }]);\n }\n },\n onAnimationFinished: () => {\n setNodes([{ ...node, status: 'in' }]);\n },\n onError: () => {\n setNodes((nodes) => nodes.map((n) => (n === node ? { ...n, status: 'errored' } : n)));\n },\n });\n }\n if (initial?.[0] === node.animationKey) {\n return initial[1]({\n onAnimationFinished: () => {\n if (node.status === 'out') {\n removeAllNodesOfKeyExceptShowing(node.animationKey);\n }\n },\n onError: () => {\n setNodes((nodes) => nodes.map((n) => (n === node ? { ...n, status: 'errored' } : n)));\n },\n });\n }\n return node.persistedElement({\n onAnimationFinished: () => {\n removeAllNodesOfKeyExceptShowing(node.animationKey);\n },\n });\n }\n const styles = {\n transitionDuration: `${animation?.duration || 0}ms`,\n transitionTimingFunction: animation?.timingFunction || 'linear',\n };\n const classes = {\n in: animation?.animateInClass,\n out: animation?.animateOutClass,\n mounted: animation?.startingClass,\n };\n\n return (\n <>\n {[...nodes]\n .filter((n) => n.status !== 'errored')\n .map((n) => (\n <div className={animation?.containerClass} key={n.animationKey}>\n {wrapNodeWithCallbacks(n)(classes[n.status], styles)}\n </div>\n ))}\n </>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageWrapper.d.ts","sourceRoot":"","sources":["../../src/web/ImageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ImageWrapper.d.ts","sourceRoot":"","sources":["../../src/web/ImageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkC,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAuBzD,QAAA,MAAM,YAAY,4FAqEjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useMemo } from 'react';
|
|
2
|
-
import { useBlurhash } from '../utils/blurhash/useBlurhash';
|
|
3
|
-
import { isBlurhashString, isThumbhashString } from '../utils/resolveSources';
|
|
4
|
-
import { thumbHashStringToDataURL } from '../utils/thumbhash/thumbhash';
|
|
5
2
|
import ColorTintFilter, { getTintColorStyle } from './ColorTintFilter';
|
|
6
3
|
import { getImageWrapperEventHandler } from './getImageWrapperEventHandler';
|
|
7
4
|
import { absoluteFilledPosition, getObjectPositionFromContentPositionObject } from './positioning';
|
|
5
|
+
import { useBlurhash } from '../utils/blurhash/useBlurhash';
|
|
6
|
+
import { isBlurhashString, isThumbhashString } from '../utils/resolveSources';
|
|
7
|
+
import { thumbHashStringToDataURL } from '../utils/thumbhash/thumbhash';
|
|
8
8
|
function getFetchPriorityFromImagePriority(priority = 'normal') {
|
|
9
9
|
return priority && ['low', 'high'].includes(priority) ? priority : 'auto';
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageWrapper.js","sourceRoot":"","sources":["../../src/web/ImageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAO,OAAO,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ImageWrapper.js","sourceRoot":"","sources":["../../src/web/ImageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAO,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,eAAe,EAAE,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,0CAA0C,EAAE,MAAM,eAAe,CAAC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KAC3C,qBAAqB,CAAC,MAAM,CAAC,KAC7B,KAAK,GACT,CACD,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import React, { useEffect, Ref, useMemo } from 'react';\n\nimport ColorTintFilter, { getTintColorStyle } from './ColorTintFilter';\nimport { ImageWrapperProps } from './ImageWrapper.types';\nimport { getImageWrapperEventHandler } from './getImageWrapperEventHandler';\nimport { absoluteFilledPosition, getObjectPositionFromContentPositionObject } from './positioning';\nimport { SrcSetSource } from './useSourceSelection';\nimport { ImageNativeProps, ImageSource } from '../Image.types';\nimport { useBlurhash } from '../utils/blurhash/useBlurhash';\nimport { isBlurhashString, isThumbhashString } from '../utils/resolveSources';\nimport { thumbHashStringToDataURL } from '../utils/thumbhash/thumbhash';\n\nfunction getFetchPriorityFromImagePriority(priority: ImageNativeProps['priority'] = 'normal') {\n return priority && ['low', 'high'].includes(priority) ? priority : 'auto';\n}\n\nfunction getImgPropsFromSource(source: ImageSource | SrcSetSource | null | undefined) {\n if (source && 'srcset' in source) {\n return {\n srcSet: source.srcset,\n sizes: source.sizes,\n };\n }\n return {};\n}\n\nconst ImageWrapper = React.forwardRef(\n (\n {\n source,\n events,\n contentPosition,\n hashPlaceholderContentPosition,\n priority,\n style,\n hashPlaceholderStyle,\n tintColor,\n className,\n accessibilityLabel,\n ...props\n }: ImageWrapperProps,\n ref: Ref<HTMLImageElement>\n ) => {\n useEffect(() => {\n events?.onMount?.forEach((e) => e?.());\n }, []);\n\n const isBlurhash = isBlurhashString(source?.uri || '');\n const isThumbhash = isThumbhashString(source?.uri || '');\n const isHash = isBlurhash || isThumbhash;\n\n // Thumbhash uri always has to start with 'thumbhash:/'\n const thumbhash = source?.uri?.replace(/thumbhash:\\//, '');\n const thumbhashUri = useMemo(\n () => (isThumbhash ? thumbHashStringToDataURL(thumbhash ?? '') : null),\n [thumbhash]\n );\n\n const blurhashUri = useBlurhash(isBlurhash ? source?.uri : null, source?.width, source?.height);\n if (!source) {\n return null;\n }\n\n const objectPosition = getObjectPositionFromContentPositionObject(\n isHash ? hashPlaceholderContentPosition : contentPosition\n );\n\n const uri = isHash ? blurhashUri ?? thumbhashUri : source?.uri;\n\n return (\n <>\n <ColorTintFilter tintColor={tintColor} />\n <img\n ref={ref}\n alt={accessibilityLabel}\n className={className}\n src={uri || undefined}\n key={source?.uri}\n style={{\n objectPosition,\n ...absoluteFilledPosition,\n ...getTintColorStyle(tintColor),\n ...(isHash ? hashPlaceholderStyle : {}),\n ...style,\n }}\n // @ts-ignore\n // eslint-disable-next-line react/no-unknown-property\n fetchpriority={getFetchPriorityFromImagePriority(priority || 'normal')}\n {...getImageWrapperEventHandler(events, source)}\n {...getImgPropsFromSource(source)}\n {...props}\n />\n </>\n );\n }\n);\n\nexport default ImageWrapper;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, SyntheticEvent } from 'react';
|
|
2
|
-
import { ImageContentPositionObject, ImageSource } from '../Image.types';
|
|
3
2
|
import { SrcSetSource } from './useSourceSelection';
|
|
3
|
+
import { ImageContentPositionObject, ImageSource } from '../Image.types';
|
|
4
4
|
export type ImageWrapperEvents = {
|
|
5
5
|
onLoad?: (((event: SyntheticEvent<HTMLImageElement, Event>) => void) | undefined | null)[];
|
|
6
6
|
onError?: ((({ source }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageWrapper.types.d.ts","sourceRoot":"","sources":["../../src/web/ImageWrapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ImageWrapper.types.d.ts","sourceRoot":"","sources":["../../src/web/ImageWrapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAA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":["import { CSSProperties, SyntheticEvent } from 'react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"ImageWrapper.types.js","sourceRoot":"","sources":["../../src/web/ImageWrapper.types.ts"],"names":[],"mappings":"","sourcesContent":["import { CSSProperties, SyntheticEvent } from 'react';\n\nimport { SrcSetSource } from './useSourceSelection';\nimport { ImageContentPositionObject, ImageSource } from '../Image.types';\n\nexport type ImageWrapperEvents = {\n onLoad?: (((event: SyntheticEvent<HTMLImageElement, Event>) => void) | undefined | null)[];\n onError?: ((({ source }: { source: ImageSource | null }) => void) | undefined | null)[];\n onTransitionEnd?: ((() => void) | undefined | null)[];\n onMount?: ((() => void) | undefined | null)[];\n};\n\nexport type ImageWrapperProps = {\n source?: ImageSource | SrcSetSource | null;\n events?: ImageWrapperEvents;\n contentPosition?: ImageContentPositionObject;\n hashPlaceholderContentPosition?: ImageContentPositionObject;\n priority?: string | null;\n style: CSSProperties;\n tintColor?: string | null;\n hashPlaceholderStyle?: CSSProperties;\n className?: string;\n accessibilityLabel?: string;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImageSource } from '../Image.types';
|
|
2
1
|
import { ImageWrapperEvents } from './ImageWrapper.types';
|
|
2
|
+
import { ImageSource } from '../Image.types';
|
|
3
3
|
export declare function getImageWrapperEventHandler(events: ImageWrapperEvents | undefined, source: ImageSource): {
|
|
4
4
|
onLoad: (event: any) => void;
|
|
5
5
|
onTransitionEnd: () => void | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImageWrapperEventHandler.d.ts","sourceRoot":"","sources":["../../src/web/getImageWrapperEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getImageWrapperEventHandler.d.ts","sourceRoot":"","sources":["../../src/web/getImageWrapperEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,MAAM,EAAE,WAAW;;;;EAgBpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImageWrapperEventHandler.js","sourceRoot":"","sources":["../../src/web/getImageWrapperEventHandler.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,2BAA2B,CACzC,MAAsC,EACtC,MAAmB;IAEnB,OAAO;QACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;gBACjC,qJAAqJ;gBACrJ,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE;oBAChC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC7C,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;aAC5C;QACH,CAAC;QACD,eAAe,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QACrE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;KAChF,CAAC;AACJ,CAAC","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getImageWrapperEventHandler.js","sourceRoot":"","sources":["../../src/web/getImageWrapperEventHandler.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,2BAA2B,CACzC,MAAsC,EACtC,MAAmB;IAEnB,OAAO;QACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;gBACjC,qJAAqJ;gBACrJ,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE;oBAChC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC7C,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;aAC5C;QACH,CAAC;QACD,eAAe,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;QACrE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;KAChF,CAAC;AACJ,CAAC","sourcesContent":["import { ImageWrapperEvents } from './ImageWrapper.types';\nimport { ImageSource } from '../Image.types';\n\nexport function getImageWrapperEventHandler(\n events: ImageWrapperEvents | undefined,\n source: ImageSource\n) {\n return {\n onLoad: (event) => {\n if (typeof window !== 'undefined') {\n // this ensures the animation will run, since the starting class is applied at least 1 frame before the target class set in the onLoad event callback\n window.requestAnimationFrame(() => {\n events?.onLoad?.forEach((e) => e?.(event));\n });\n } else {\n events?.onLoad?.forEach((e) => e?.(event));\n }\n },\n onTransitionEnd: () => events?.onTransitionEnd?.forEach((e) => e?.()),\n onError: () => events?.onError?.forEach((e) => e?.({ source: source || null })),\n };\n}\n"]}
|
|
@@ -46,7 +46,9 @@ function selectSource(sources, size, responsivePolicy) {
|
|
|
46
46
|
const srcset = staticSupportedSources
|
|
47
47
|
?.map((source) => `${source.uri} ${source.width}w`)
|
|
48
48
|
.join(', ');
|
|
49
|
-
const sizes = `${staticSupportedSources
|
|
49
|
+
const sizes = `${staticSupportedSources
|
|
50
|
+
?.map(getCSSMediaQueryForSource)
|
|
51
|
+
.join(', ')}, ${staticSupportedSources[staticSupportedSources.length - 1]?.width}px`;
|
|
50
52
|
return {
|
|
51
53
|
srcset,
|
|
52
54
|
sizes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSourceSelection.js","sourceRoot":"","sources":["../../src/web/useSourceSelection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE9E,SAAS,qBAAqB,CAC5B,OAAkC,EAClC,IAAoB;IAEpB,IAAI,OAAO,EAAE,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;KACnB;IACD,OAAO,CACL,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAClB,mEAAmE;QACnE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;SAC9C;QACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GACrB,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACtE,IAAI,KAAK,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,EAAE;YACnC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC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AO,CAAC,IAAI,CAAC,CAAC;QAEd,IAAI,gBAAgB,KAAK,MAAM,EAAE;YAC/B,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO;aACR;YACD,cAAc,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;gBACtD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;gBAChC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAa,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC;YACH,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SACzC;IACH,CAAC,EACD,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CACzC,CAAC;IAEF,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAE7D,OAAO,KAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,YAAY;QACZ,MAAM;KACP,CAAC,EACF,CAAC,MAAM,CAAC,CACT,CAAC;AACJ,CAAC","sourcesContent":["import React, { useState, useRef } from 'react';\n\nimport { ImageProps, ImageSource } from '../Image.types';\nimport { isBlurhashString, isThumbhashString } from '../utils/resolveSources';\n\nfunction findBestSourceForSize(\n sources: ImageSource[] | undefined,\n size: DOMRect | null\n): ImageSource | null {\n if (sources?.length === 1) {\n return sources[0];\n }\n return (\n [...(sources || [])]\n // look for the smallest image that's still larger then a container\n ?.map((source) => {\n if (!size) {\n return { source, penalty: 0, covers: false };\n }\n const { width, height } =\n typeof source === 'object' ? source : { width: null, height: null };\n if (width == null || height == null) {\n return { source, penalty: 0, covers: false };\n }\n if (width < size.width || height < size.height) {\n return {\n source,\n penalty: Math.max(size.width - width, size.height - height),\n covers: false,\n };\n }\n return { source, penalty: (width - size.width) * (height - size.height), covers: true };\n })\n .sort((a, b) => a.penalty - b.penalty)\n .sort((a, b) => Number(b.covers) - Number(a.covers))[0]?.source ?? null\n );\n}\n\nexport interface SrcSetSource extends ImageSource {\n srcset: string;\n sizes: string;\n // used as key and a fallback in case srcset is not supported\n uri: string;\n type: 'srcset';\n}\n\nfunction getCSSMediaQueryForSource(source: ImageSource) {\n return `(max-width: ${source.webMaxViewportWidth ?? source.width}px) ${source.width}px`;\n}\n\nfunction selectSource(\n sources: ImageSource[] | undefined,\n size: DOMRect | null,\n responsivePolicy: ImageProps['responsivePolicy']\n): ImageSource | SrcSetSource | null {\n if (sources == null || sources.length === 0) {\n return null;\n }\n\n if (responsivePolicy !== 'static') {\n return findBestSourceForSize(sources, size);\n }\n const staticSupportedSources = sources\n .filter(\n (s) => s.uri && s.width != null && !isBlurhashString(s.uri) && !isThumbhashString(s.uri)\n )\n .sort(\n (a, b) => (a.webMaxViewportWidth ?? a.width ?? 0) - (b.webMaxViewportWidth ?? b.width ?? 0)\n );\n\n if (staticSupportedSources.length === 0) {\n console.warn(\n \"You've set the `static` responsivePolicy but none of the sources have the `width` properties set. Make sure you set both `width` and `webMaxViewportWidth` for best results when using static responsiveness. Falling back to the `initial` policy.\"\n );\n return findBestSourceForSize(sources, size);\n }\n\n const srcset = staticSupportedSources\n ?.map((source) => `${source.uri} ${source.width}w`)\n .join(', ');\n const sizes = `${staticSupportedSources\n ?.map(getCSSMediaQueryForSource)\n .join(', ')}, ${staticSupportedSources[staticSupportedSources.length - 1]?.width}px`;\n return {\n srcset,\n sizes,\n uri: staticSupportedSources[staticSupportedSources.length - 1]?.uri ?? '',\n type: 'srcset',\n };\n}\n\ntype UseSourceSelectionReturn = {\n containerRef: (element: HTMLDivElement) => void;\n source: ImageSource | SrcSetSource | null;\n};\n\nexport default function useSourceSelection(\n sources?: ImageSource[],\n responsivePolicy: ImageProps['responsivePolicy'] = 'static',\n measurementCallback?: (target: HTMLElement, size: DOMRect) => void\n): UseSourceSelectionReturn {\n const hasMoreThanOneSource = (sources?.length ?? 0) > 1;\n // null - not calculated yet, DOMRect - size available\n const [size, setSize] = useState<null | DOMRect>(null);\n const resizeObserver = useRef<ResizeObserver | null>(null);\n\n React.useEffect(() => {\n return () => {\n resizeObserver.current?.disconnect();\n };\n }, []);\n\n const containerRef = React.useCallback(\n (element: HTMLDivElement) => {\n // we can't short circuit here since we need to read the size for better animated transitions\n if (!hasMoreThanOneSource && !measurementCallback) {\n return;\n }\n const rect = element?.getBoundingClientRect();\n measurementCallback?.(element, rect);\n setSize(rect);\n\n if (responsivePolicy === 'live') {\n resizeObserver.current?.disconnect();\n if (!element) {\n return;\n }\n resizeObserver.current = new ResizeObserver((entries) => {\n setSize(entries[0].contentRect);\n measurementCallback?.(entries[0].target as any, entries[0].contentRect);\n });\n resizeObserver.current.observe(element);\n }\n },\n [hasMoreThanOneSource, responsivePolicy]\n );\n\n const source = selectSource(sources, size, responsivePolicy);\n\n return React.useMemo(\n () => ({\n containerRef,\n source,\n }),\n [source]\n );\n}\n"]}
|
package/ios/ExpoImage.podspec
CHANGED
|
@@ -16,9 +16,9 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.static_framework = true
|
|
17
17
|
|
|
18
18
|
s.dependency 'ExpoModulesCore'
|
|
19
|
-
s.dependency 'SDWebImage', '~> 5.
|
|
20
|
-
s.dependency 'SDWebImageWebPCoder', '~> 0.
|
|
21
|
-
s.dependency 'SDWebImageAVIFCoder', '~> 0.10.
|
|
19
|
+
s.dependency 'SDWebImage', '~> 5.17.0'
|
|
20
|
+
s.dependency 'SDWebImageWebPCoder', '~> 0.13.0'
|
|
21
|
+
s.dependency 'SDWebImageAVIFCoder', '~> 0.10.1'
|
|
22
22
|
s.dependency 'SDWebImageSVGCoder', '~> 1.7.0'
|
|
23
23
|
|
|
24
24
|
# Swift/Objective-C compatibility
|
package/ios/ImageView.swift
CHANGED
|
@@ -197,7 +197,13 @@ public final class ImageView: ExpoView {
|
|
|
197
197
|
_ imageUrl: URL?
|
|
198
198
|
) {
|
|
199
199
|
if let error = error {
|
|
200
|
-
|
|
200
|
+
let code = (error as NSError).code
|
|
201
|
+
|
|
202
|
+
// SDWebImage throws an error when loading operation is canceled (interrupted) by another load request.
|
|
203
|
+
// We do want to ignore that one and wait for the new request to load.
|
|
204
|
+
if code != SDWebImageError.cancelled.rawValue {
|
|
205
|
+
onError(["error": error.localizedDescription])
|
|
206
|
+
}
|
|
201
207
|
return
|
|
202
208
|
}
|
|
203
209
|
guard finished else {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-image",
|
|
3
3
|
"title": "Expo Image",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
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",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"expo": "*"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "abdc0f504e6daa4da247db248bff24850083f673"
|
|
37
37
|
}
|
package/src/ExpoImage.web.tsx
CHANGED
|
@@ -90,25 +90,24 @@ export default function ExpoImage({
|
|
|
90
90
|
? [
|
|
91
91
|
initialNodeAnimationKey,
|
|
92
92
|
({ onAnimationFinished }) =>
|
|
93
|
-
(className, style) =>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
),
|
|
93
|
+
(className, style) => (
|
|
94
|
+
<ImageWrapper
|
|
95
|
+
{...props}
|
|
96
|
+
source={placeholder?.[0]}
|
|
97
|
+
style={{
|
|
98
|
+
objectFit: imagePlaceholderContentFit,
|
|
99
|
+
...(blurRadius ? { filter: `blur(${blurRadius}px)` } : {}),
|
|
100
|
+
...style,
|
|
101
|
+
}}
|
|
102
|
+
className={className}
|
|
103
|
+
events={{
|
|
104
|
+
onTransitionEnd: [onAnimationFinished],
|
|
105
|
+
}}
|
|
106
|
+
contentPosition={{ left: '50%', top: '50%' }}
|
|
107
|
+
hashPlaceholderContentPosition={contentPosition}
|
|
108
|
+
hashPlaceholderStyle={blurhashStyle}
|
|
109
|
+
/>
|
|
110
|
+
),
|
|
112
111
|
]
|
|
113
112
|
: null;
|
|
114
113
|
|
|
@@ -120,30 +119,29 @@ export default function ExpoImage({
|
|
|
120
119
|
const currentNode: AnimationManagerNode = [
|
|
121
120
|
currentNodeAnimationKey,
|
|
122
121
|
({ onAnimationFinished, onReady, onMount, onError: onErrorInner }) =>
|
|
123
|
-
(className, style) =>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
),
|
|
122
|
+
(className, style) => (
|
|
123
|
+
<ImageWrapper
|
|
124
|
+
{...props}
|
|
125
|
+
source={selectedSource || placeholder?.[0]}
|
|
126
|
+
events={{
|
|
127
|
+
onError: [onErrorAdapter(onError), onLoadEnd, onErrorInner],
|
|
128
|
+
onLoad: [onLoadAdapter(onLoad), onLoadEnd, onReady],
|
|
129
|
+
onMount: [onMount],
|
|
130
|
+
onTransitionEnd: [onAnimationFinished],
|
|
131
|
+
}}
|
|
132
|
+
style={{
|
|
133
|
+
objectFit: selectedSource ? contentFit : imagePlaceholderContentFit,
|
|
134
|
+
...(blurRadius ? { filter: `blur(${blurRadius}px)` } : {}),
|
|
135
|
+
...style,
|
|
136
|
+
}}
|
|
137
|
+
className={className}
|
|
138
|
+
priority={priority}
|
|
139
|
+
contentPosition={selectedSource ? contentPosition : { top: '50%', left: '50%' }}
|
|
140
|
+
hashPlaceholderContentPosition={contentPosition}
|
|
141
|
+
hashPlaceholderStyle={blurhashStyle}
|
|
142
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
143
|
+
/>
|
|
144
|
+
),
|
|
147
145
|
];
|
|
148
146
|
return (
|
|
149
147
|
<View ref={containerRef} dataSet={{ expoimage: true }} style={[{ overflow: 'hidden' }, style]}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ImageNativeProps, ImageProps, ImageSource } from '../Image.types';
|
|
2
1
|
import resolveAssetSource from './resolveAssetSource';
|
|
3
2
|
import { resolveBlurhashString, resolveThumbhashString } from './resolveHashString';
|
|
3
|
+
import { ImageNativeProps, ImageProps, ImageSource } from '../Image.types';
|
|
4
4
|
|
|
5
5
|
export function isBlurhashString(str: string): boolean {
|
|
6
6
|
return /^(blurhash:\/)?[\w#$%*+,\-.:;=?@[\]^_{}|~]+(\/[\d.]+)*$/.test(str);
|
|
@@ -13,7 +13,7 @@ export type AnimationManagerNode = [
|
|
|
13
13
|
key: string,
|
|
14
14
|
renderFunction: (
|
|
15
15
|
renderProps: NonNullable<Callbacks>
|
|
16
|
-
) => (className: string, style: React.CSSProperties) => React.ReactElement
|
|
16
|
+
) => (className: string, style: React.CSSProperties) => React.ReactElement,
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
const SUPPORTED_ANIMATIONS: ImageTransition['effect'][] = [
|
package/src/web/ImageWrapper.tsx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React, { useEffect, Ref, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { ImageNativeProps, ImageSource } from '../Image.types';
|
|
4
|
-
import { useBlurhash } from '../utils/blurhash/useBlurhash';
|
|
5
|
-
import { isBlurhashString, isThumbhashString } from '../utils/resolveSources';
|
|
6
|
-
import { thumbHashStringToDataURL } from '../utils/thumbhash/thumbhash';
|
|
7
3
|
import ColorTintFilter, { getTintColorStyle } from './ColorTintFilter';
|
|
8
4
|
import { ImageWrapperProps } from './ImageWrapper.types';
|
|
9
5
|
import { getImageWrapperEventHandler } from './getImageWrapperEventHandler';
|
|
10
6
|
import { absoluteFilledPosition, getObjectPositionFromContentPositionObject } from './positioning';
|
|
11
7
|
import { SrcSetSource } from './useSourceSelection';
|
|
8
|
+
import { ImageNativeProps, ImageSource } from '../Image.types';
|
|
9
|
+
import { useBlurhash } from '../utils/blurhash/useBlurhash';
|
|
10
|
+
import { isBlurhashString, isThumbhashString } from '../utils/resolveSources';
|
|
11
|
+
import { thumbHashStringToDataURL } from '../utils/thumbhash/thumbhash';
|
|
12
12
|
|
|
13
13
|
function getFetchPriorityFromImagePriority(priority: ImageNativeProps['priority'] = 'normal') {
|
|
14
14
|
return priority && ['low', 'high'].includes(priority) ? priority : 'auto';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, SyntheticEvent } from 'react';
|
|
2
2
|
|
|
3
|
-
import { ImageContentPositionObject, ImageSource } from '../Image.types';
|
|
4
3
|
import { SrcSetSource } from './useSourceSelection';
|
|
4
|
+
import { ImageContentPositionObject, ImageSource } from '../Image.types';
|
|
5
5
|
|
|
6
6
|
export type ImageWrapperEvents = {
|
|
7
7
|
onLoad?: (((event: SyntheticEvent<HTMLImageElement, Event>) => void) | undefined | null)[];
|
|
@@ -78,9 +78,9 @@ function selectSource(
|
|
|
78
78
|
const srcset = staticSupportedSources
|
|
79
79
|
?.map((source) => `${source.uri} ${source.width}w`)
|
|
80
80
|
.join(', ');
|
|
81
|
-
const sizes = `${staticSupportedSources
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const sizes = `${staticSupportedSources
|
|
82
|
+
?.map(getCSSMediaQueryForSource)
|
|
83
|
+
.join(', ')}, ${staticSupportedSources[staticSupportedSources.length - 1]?.width}px`;
|
|
84
84
|
return {
|
|
85
85
|
srcset,
|
|
86
86
|
sizes,
|