@office-iss/react-native-win32 0.81.2 → 0.82.0-preview.2
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/.flowconfig +3 -11
- package/CHANGELOG.json +118 -43
- package/CHANGELOG.md +45 -27
- package/IntegrationTests/IntegrationTestsApp.js +2 -2
- package/IntegrationTests/LayoutEventsTest.js +3 -3
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -3
- package/Libraries/Alert/RCTAlertManager.android.js +4 -2
- package/Libraries/Animated/Animated.d.ts +2 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedExports.js.flow +1 -0
- package/Libraries/Animated/AnimatedImplementation.js +4 -2
- package/Libraries/Animated/AnimatedMock.js +1 -1
- package/Libraries/Animated/Easing.js +2 -0
- package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
- package/Libraries/Animated/animations/Animation.js +19 -20
- package/Libraries/Animated/animations/TimingAnimation.js +2 -0
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
- package/Libraries/Animated/components/AnimatedSectionList.js +1 -1
- package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
- package/Libraries/Animated/nodes/AnimatedNode.js +14 -7
- package/Libraries/Animated/nodes/AnimatedObject.js +7 -7
- package/Libraries/Animated/nodes/AnimatedProps.js +32 -32
- package/Libraries/Animated/nodes/AnimatedStyle.js +23 -21
- package/Libraries/Animated/nodes/AnimatedTransform.js +6 -6
- package/Libraries/Animated/nodes/AnimatedValue.js +18 -26
- package/Libraries/AppState/AppState.js +8 -4
- package/Libraries/BatchedBridge/BatchedBridge.js +1 -0
- package/Libraries/BatchedBridge/MessageQueue.js +5 -0
- package/Libraries/BatchedBridge/NativeModules.js +1 -1
- package/Libraries/Blob/BlobManager.js +1 -1
- package/Libraries/Blob/URLSearchParams.js +2 -0
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -2
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -2
- package/Libraries/Components/Button.js +1 -1
- package/Libraries/Components/Button.win32.js +1 -1
- package/Libraries/Components/Pressable/Pressable.js +10 -1
- package/Libraries/Components/Pressable/Pressable.win32.js +9 -0
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +13 -4
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +2 -2
- package/Libraries/Components/Switch/Switch.js +1 -1
- package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
- package/Libraries/Components/TextInput/TextInput.flow.win32.js +12 -5
- package/Libraries/Components/TextInput/TextInput.js +14 -5
- package/Libraries/Components/TextInput/TextInput.win32.js +15 -7
- package/Libraries/Components/TextInput/TextInputState.js +1 -1
- package/Libraries/Components/TextInput/TextInputState.win32.js +1 -1
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +2 -3
- package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
- package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +3 -3
- package/Libraries/Components/View/View.js +81 -167
- package/Libraries/Components/View/View.win32.js +3 -1
- package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
- package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +1 -1
- package/Libraries/Core/ExceptionsManager.js +4 -2
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
- package/Libraries/Core/ReactNativeVersion.js +37 -10
- package/Libraries/Core/Timers/JSTimers.js +4 -1
- package/Libraries/Core/Timers/NativeTiming.js +1 -0
- package/Libraries/Core/Timers/immediateShim.js +2 -1
- package/Libraries/Core/Timers/queueMicrotask.js +1 -0
- package/Libraries/Core/setUpPerformance.js +3 -4
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
- package/Libraries/Image/Image.android.js +327 -111
- package/Libraries/Image/Image.ios.js +6 -1
- package/Libraries/Image/Image.win32.js +6 -1
- package/Libraries/Image/ImageSourceUtils.js +8 -2
- package/Libraries/Image/assetPaths.js +1 -1
- package/Libraries/Image/resolveAssetSource.js +1 -1
- package/Libraries/Image/resolveAssetSource.win32.js +6 -7
- package/Libraries/Interaction/InteractionManager.js +118 -167
- package/Libraries/Interaction/PanResponder.js +7 -52
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -0
- package/Libraries/Lists/FlatList.js +5 -6
- package/Libraries/LogBox/Data/LogBoxData.js +5 -2
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +2 -2
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +1 -1
- package/Libraries/Modal/Modal.js +3 -3
- package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
- package/Libraries/NativeComponent/ViewConfig.js +2 -2
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +20 -5
- package/Libraries/Network/convertRequestBody.js +1 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
- package/Libraries/Pressability/HoverState.js +2 -0
- package/Libraries/Pressability/HoverState.win32.js +2 -0
- package/Libraries/Pressability/Pressability.js +1 -1
- package/Libraries/Pressability/Pressability.win32.js +1 -1
- package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
- package/Libraries/ReactNative/AppRegistryImpl.js +4 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
- package/Libraries/ReactNative/RendererImplementation.js +116 -116
- package/Libraries/ReactNative/UIManager.js +3 -3
- package/Libraries/ReactNative/renderApplication.js +1 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +38 -35
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +51 -22
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +54 -24
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +36 -33
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5 -5
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5 -5
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
- package/Libraries/Share/Share.js +4 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +4 -0
- package/Libraries/StyleSheet/StyleSheet.d.ts +7 -22
- package/Libraries/StyleSheet/StyleSheetExports.js +2 -8
- package/Libraries/StyleSheet/StyleSheetExports.js.flow +11 -18
- package/Libraries/StyleSheet/flattenStyle.js +2 -2
- package/Libraries/StyleSheet/processAspectRatio.js +2 -0
- package/Libraries/StyleSheet/processFilter.js +5 -5
- package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
- package/Libraries/Text/Text.js +534 -234
- package/Libraries/Text/Text.win32.js +647 -274
- package/Libraries/Text/TextNativeComponent.js +2 -2
- package/Libraries/Text/TextNativeComponent.win32.js +2 -2
- package/Libraries/Utilities/Appearance.d.ts +3 -5
- package/Libraries/Utilities/Appearance.js +5 -17
- package/Libraries/Utilities/HMRClient.js +2 -1
- package/Libraries/Utilities/Platform.android.js +3 -3
- package/Libraries/Utilities/Platform.d.ts +1 -0
- package/Libraries/Utilities/Platform.ios.js +1 -1
- package/Libraries/Utilities/Platform.win32.js +3 -3
- package/Libraries/Utilities/PlatformTypes.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
- package/Libraries/Utilities/SceneTracker.js +1 -1
- package/Libraries/Utilities/codegenNativeCommands.js +1 -1
- package/Libraries/Utilities/codegenNativeComponent.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +32 -0
- package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
- package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
- package/Libraries/Utilities/useMergeRefs.js +1 -1
- package/Libraries/WebSocket/WebSocketInterceptor.js +2 -0
- package/Libraries/promiseRejectionTrackingOptions.js +17 -31
- package/Libraries/vendor/emitter/EventEmitter.js +1 -1
- package/flow/bom.js.flow +223 -1
- package/flow/prettier.js.flow +14 -0
- package/index.js +14 -2
- package/index.win32.js +16 -2
- package/jest/local-setup.js +2 -2
- package/jest/mock.js +1 -1
- package/jest/mockComponent.js +9 -9
- package/jest/mockNativeComponent.js +3 -2
- package/jest/mocks/Modal.js +1 -1
- package/jest/mocks/ScrollView.js +1 -1
- package/jest/mocks/ViewNativeComponent.js +1 -1
- package/jest/setup.js +23 -12
- package/overrides.json +23 -23
- package/package.json +28 -27
- package/saveAssetPlugin.js +2 -2
- package/src/private/animated/NativeAnimatedHelper.js +16 -5
- package/src/private/animated/NativeAnimatedHelper.win32.js +16 -5
- package/src/private/animated/createAnimatedPropsHook.js +11 -60
- package/src/private/animated/createAnimatedPropsMemoHook.js +8 -54
- package/src/private/components/virtualview/VirtualView.js +43 -12
- package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +93 -0
- package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
- package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
- package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +85 -52
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +15 -6
- package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
- package/src/private/setup/{setUpPerformanceObserver.js → setUpPerformanceModern.js} +43 -18
- package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -0
- package/src/private/types/HostInstance.js +4 -1
- package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
- package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
- package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +15 -12
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +14 -11
- package/src/private/webapis/geometry/DOMRectList.js +2 -2
- package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +19 -74
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +0 -4
- package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
- package/src/private/webapis/performance/EventTiming.js +40 -25
- package/src/private/webapis/performance/LongTasks.js +35 -2
- package/src/private/webapis/performance/Performance.js +347 -166
- package/src/private/webapis/performance/PerformanceEntry.js +40 -23
- package/src/private/webapis/performance/PerformanceObserver.js +37 -29
- package/src/private/webapis/performance/ReactNativeStartupTiming.js +3 -24
- package/src/private/webapis/performance/ResourceTiming.js +29 -18
- package/src/private/webapis/performance/UserTiming.js +92 -34
- package/src/private/webapis/performance/UserTimingExtensibility.js.flow +38 -0
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -4
- package/src/private/webapis/performance/internals/Utilities.js +9 -0
- package/src/private/webapis/performance/specs/NativePerformance.js +23 -23
- package/src/private/webapis/structuredClone/structuredClone.js +10 -10
- package/src-win/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
- package/Libraries/Interaction/InteractionManagerStub.js +0 -184
- package/Libraries/Interaction/TaskQueue.js +0 -183
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -31
|
@@ -12,8 +12,10 @@ import type {HostInstance} from '../../src/private/types/HostInstance';
|
|
|
12
12
|
import type {ImageStyleProp} from '../StyleSheet/StyleSheet';
|
|
13
13
|
import type {RootTag} from '../Types/RootTagTypes';
|
|
14
14
|
import type {ImageProps} from './ImageProps';
|
|
15
|
+
import type {ImageSourceHeaders} from './ImageSourceUtils';
|
|
15
16
|
import type {AbstractImageAndroid, ImageAndroid} from './ImageTypes.flow';
|
|
16
17
|
|
|
18
|
+
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
17
19
|
import flattenStyle from '../StyleSheet/flattenStyle';
|
|
18
20
|
import StyleSheet from '../StyleSheet/StyleSheet';
|
|
19
21
|
import TextAncestorContext from '../Text/TextAncestorContext';
|
|
@@ -31,6 +33,7 @@ import NativeImageLoaderAndroid, {
|
|
|
31
33
|
import resolveAssetSource from './resolveAssetSource';
|
|
32
34
|
import TextInlineImageNativeComponent from './TextInlineImageNativeComponent';
|
|
33
35
|
import * as React from 'react';
|
|
36
|
+
import {use} from 'react';
|
|
34
37
|
|
|
35
38
|
let _requestId = 1;
|
|
36
39
|
function generateRequestId() {
|
|
@@ -121,6 +124,12 @@ async function queryCache(
|
|
|
121
124
|
return NativeImageLoaderAndroid.queryCache(urls);
|
|
122
125
|
}
|
|
123
126
|
|
|
127
|
+
const EMPTY_IMAGE_SOURCE = {
|
|
128
|
+
uri: undefined,
|
|
129
|
+
width: undefined,
|
|
130
|
+
height: undefined,
|
|
131
|
+
};
|
|
132
|
+
|
|
124
133
|
/**
|
|
125
134
|
* A React component for displaying different types of images,
|
|
126
135
|
* including network images, static resources, temporary local images, and
|
|
@@ -128,137 +137,344 @@ async function queryCache(
|
|
|
128
137
|
*
|
|
129
138
|
* See https://reactnative.dev/docs/image
|
|
130
139
|
*/
|
|
131
|
-
let
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
140
|
+
let _BaseImage;
|
|
141
|
+
if (ReactNativeFeatureFlags.reduceDefaultPropsInImage()) {
|
|
142
|
+
let BaseImage: AbstractImageAndroid = ({
|
|
143
|
+
ref: forwardedRef,
|
|
144
|
+
alt,
|
|
145
|
+
accessible,
|
|
146
|
+
'aria-labelledby': ariaLabelledBy,
|
|
147
|
+
'aria-busy': ariaBusy,
|
|
148
|
+
'aria-checked': ariaChecked,
|
|
149
|
+
'aria-disabled': ariaDisabled,
|
|
150
|
+
'aria-expanded': ariaExpanded,
|
|
151
|
+
'aria-hidden': ariaHidden,
|
|
152
|
+
'aria-label': ariaLabel,
|
|
153
|
+
'aria-selected': ariaSelected,
|
|
154
|
+
accessibilityLabel,
|
|
155
|
+
accessibilityLabelledBy,
|
|
156
|
+
accessibilityState,
|
|
157
|
+
defaultSource,
|
|
158
|
+
loadingIndicatorSource,
|
|
159
|
+
children,
|
|
160
|
+
source,
|
|
161
|
+
src,
|
|
162
|
+
style,
|
|
163
|
+
crossOrigin,
|
|
164
|
+
referrerPolicy,
|
|
165
|
+
srcSet,
|
|
166
|
+
onLoadStart,
|
|
167
|
+
onLoad,
|
|
168
|
+
onLoadEnd,
|
|
169
|
+
onError,
|
|
170
|
+
width,
|
|
171
|
+
height,
|
|
172
|
+
resizeMode,
|
|
173
|
+
...restProps
|
|
174
|
+
}: {
|
|
175
|
+
ref?: React.RefSetter<HostInstance>,
|
|
176
|
+
...ImageProps,
|
|
177
|
+
}) => {
|
|
178
|
+
let source_ =
|
|
179
|
+
getImageSourcesFromImageProps({
|
|
180
|
+
crossOrigin,
|
|
181
|
+
referrerPolicy,
|
|
182
|
+
src,
|
|
183
|
+
srcSet,
|
|
184
|
+
width,
|
|
185
|
+
height,
|
|
186
|
+
source,
|
|
187
|
+
}) || EMPTY_IMAGE_SOURCE;
|
|
188
|
+
const defaultSource_ = resolveAssetSource(defaultSource);
|
|
189
|
+
const loadingIndicatorSource_ = resolveAssetSource(loadingIndicatorSource);
|
|
153
190
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
191
|
+
if (children != null) {
|
|
192
|
+
throw new Error(
|
|
193
|
+
'The <Image> component cannot contain children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.',
|
|
194
|
+
);
|
|
195
|
+
}
|
|
159
196
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
sources = source;
|
|
165
|
-
} else {
|
|
166
|
-
const {uri} = source;
|
|
167
|
-
if (uri === '') {
|
|
168
|
-
console.warn('source.uri should not be an empty string');
|
|
197
|
+
if (defaultSource != null && loadingIndicatorSource != null) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
'The <Image> component cannot have defaultSource and loadingIndicatorSource at the same time. Please use either defaultSource or loadingIndicatorSource.',
|
|
200
|
+
);
|
|
169
201
|
}
|
|
170
|
-
const width = source.width ?? props.width;
|
|
171
|
-
const height = source.height ?? props.height;
|
|
172
|
-
style = [{width, height}, styles.base, props.style];
|
|
173
|
-
sources = [source];
|
|
174
|
-
}
|
|
175
202
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
203
|
+
let style_: ImageStyleProp;
|
|
204
|
+
let sources_;
|
|
205
|
+
let headers_: ?ImageSourceHeaders;
|
|
206
|
+
if (Array.isArray(source_)) {
|
|
207
|
+
style_ = [styles.base, style];
|
|
208
|
+
sources_ = source_;
|
|
209
|
+
headers_ = sources_[0].headers;
|
|
210
|
+
} else {
|
|
211
|
+
const {uri} = source_;
|
|
212
|
+
if (uri === '') {
|
|
213
|
+
console.warn('source.uri should not be an empty string');
|
|
214
|
+
}
|
|
215
|
+
const width_ = source_.width ?? width;
|
|
216
|
+
const height_ = source_.height ?? height;
|
|
217
|
+
style_ = [{width: width_, height: height_}, styles.base, style];
|
|
218
|
+
sources_ = [source_];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const nativeProps = restProps as {
|
|
222
|
+
...React.PropsOf<ImageViewNativeComponent>,
|
|
223
|
+
};
|
|
224
|
+
|
|
181
225
|
// Both iOS and C++ sides expect to have "source" prop, whereas on Android it's "src"
|
|
182
226
|
// (for historical reasons). So in the latter case we populate both "src" and "source",
|
|
183
227
|
// in order to have a better alignment between platforms in the future.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
228
|
+
// TODO: `src` should be eventually removed from the API on Android.
|
|
229
|
+
nativeProps.src = sources_;
|
|
230
|
+
nativeProps.source = sources_;
|
|
231
|
+
|
|
232
|
+
nativeProps.style = style_;
|
|
233
|
+
|
|
234
|
+
if (headers_ != null) {
|
|
235
|
+
nativeProps.headers = headers_;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (onLoadStart != null) {
|
|
239
|
+
nativeProps.shouldNotifyLoadEvents = true;
|
|
240
|
+
nativeProps.onLoadStart = onLoadStart;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (onLoad != null) {
|
|
244
|
+
nativeProps.shouldNotifyLoadEvents = true;
|
|
245
|
+
nativeProps.onLoad = onLoad;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (onLoadEnd != null) {
|
|
249
|
+
nativeProps.shouldNotifyLoadEvents = true;
|
|
250
|
+
nativeProps.onLoadEnd = onLoadEnd;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (onError != null) {
|
|
254
|
+
nativeProps.shouldNotifyLoadEvents = true;
|
|
255
|
+
nativeProps.onError = onError;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (defaultSource_ != null && defaultSource_.uri != null) {
|
|
259
|
+
nativeProps.defaultSource = defaultSource_.uri;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (
|
|
263
|
+
loadingIndicatorSource_ != null &&
|
|
264
|
+
loadingIndicatorSource_.uri != null
|
|
265
|
+
) {
|
|
266
|
+
nativeProps.loadingIndicatorSrc = loadingIndicatorSource_.uri;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (ariaLabel != null) {
|
|
270
|
+
nativeProps.accessibilityLabel = ariaLabel;
|
|
271
|
+
} else if (accessibilityLabel != null) {
|
|
272
|
+
nativeProps.accessibilityLabel = accessibilityLabel;
|
|
273
|
+
} else if (alt != null) {
|
|
274
|
+
nativeProps.accessibilityLabel = alt;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (ariaLabelledBy != null) {
|
|
278
|
+
nativeProps.accessibilityLabelledBy = ariaLabelledBy;
|
|
279
|
+
} else if (accessibilityLabelledBy != null) {
|
|
280
|
+
nativeProps.accessibilityLabelledBy = accessibilityLabelledBy;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (alt != null) {
|
|
284
|
+
nativeProps.accessible = true;
|
|
285
|
+
} else if (accessible != null) {
|
|
286
|
+
nativeProps.accessible = accessible;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (
|
|
290
|
+
accessibilityState != null ||
|
|
291
|
+
ariaBusy != null ||
|
|
292
|
+
ariaChecked != null ||
|
|
293
|
+
ariaDisabled != null ||
|
|
294
|
+
ariaExpanded != null ||
|
|
295
|
+
ariaSelected != null
|
|
296
|
+
) {
|
|
297
|
+
nativeProps.accessibilityState = {
|
|
298
|
+
busy: ariaBusy ?? accessibilityState?.busy,
|
|
299
|
+
checked: ariaChecked ?? accessibilityState?.checked,
|
|
300
|
+
disabled: ariaDisabled ?? accessibilityState?.disabled,
|
|
301
|
+
expanded: ariaExpanded ?? accessibilityState?.expanded,
|
|
302
|
+
selected: ariaSelected ?? accessibilityState?.selected,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (ariaHidden === true) {
|
|
307
|
+
nativeProps.importantForAccessibility = 'no-hide-descendants';
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const flattenedStyle_ = flattenStyle<ImageStyleProp>(style);
|
|
311
|
+
const objectFit_ = convertObjectFitToResizeMode(flattenedStyle_?.objectFit);
|
|
312
|
+
const resizeMode_ =
|
|
313
|
+
objectFit_ || resizeMode || flattenedStyle_?.resizeMode || 'cover';
|
|
314
|
+
nativeProps.resizeMode = resizeMode_;
|
|
315
|
+
|
|
316
|
+
const actualRef = useWrapRefWithImageAttachedCallbacks(forwardedRef);
|
|
317
|
+
|
|
318
|
+
const hasTextAncestor = use(TextAncestorContext);
|
|
319
|
+
const analyticTag = use(ImageAnalyticsTagContext);
|
|
320
|
+
if (analyticTag !== null) {
|
|
321
|
+
nativeProps.internal_analyticTag = analyticTag;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return hasTextAncestor ? (
|
|
325
|
+
<TextInlineImageNativeComponent
|
|
326
|
+
// $FlowFixMe[incompatible-type]
|
|
327
|
+
style={style_}
|
|
328
|
+
resizeMode={resizeMode_}
|
|
329
|
+
headers={headers_}
|
|
330
|
+
src={sources_}
|
|
331
|
+
ref={actualRef}
|
|
332
|
+
/>
|
|
333
|
+
) : (
|
|
334
|
+
<ImageViewNativeComponent {...nativeProps} ref={actualRef} />
|
|
335
|
+
);
|
|
205
336
|
};
|
|
206
337
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
338
|
+
_BaseImage = BaseImage;
|
|
339
|
+
} else {
|
|
340
|
+
let BaseImage: AbstractImageAndroid = ({
|
|
341
|
+
ref: forwardedRef,
|
|
342
|
+
...props
|
|
343
|
+
}: {
|
|
344
|
+
ref?: React.RefSetter<HostInstance>,
|
|
345
|
+
...ImageProps,
|
|
346
|
+
}) => {
|
|
347
|
+
let source = getImageSourcesFromImageProps(props) || {
|
|
348
|
+
uri: undefined,
|
|
349
|
+
width: undefined,
|
|
350
|
+
height: undefined,
|
|
351
|
+
};
|
|
352
|
+
const defaultSource = resolveAssetSource(props.defaultSource);
|
|
353
|
+
const loadingIndicatorSource = resolveAssetSource(
|
|
354
|
+
props.loadingIndicatorSource,
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
if (props.children != null) {
|
|
358
|
+
throw new Error(
|
|
359
|
+
'The <Image> component cannot contain children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.',
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (props.defaultSource != null && props.loadingIndicatorSource != null) {
|
|
364
|
+
throw new Error(
|
|
365
|
+
'The <Image> component cannot have defaultSource and loadingIndicatorSource at the same time. Please use either defaultSource or loadingIndicatorSource.',
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
let style: ImageStyleProp;
|
|
370
|
+
let sources;
|
|
371
|
+
if (Array.isArray(source)) {
|
|
372
|
+
style = [styles.base, props.style];
|
|
373
|
+
sources = source;
|
|
374
|
+
} else {
|
|
375
|
+
const {uri} = source;
|
|
376
|
+
if (uri === '') {
|
|
377
|
+
console.warn('source.uri should not be an empty string');
|
|
378
|
+
}
|
|
379
|
+
const width = source.width ?? props.width;
|
|
380
|
+
const height = source.height ?? props.height;
|
|
381
|
+
style = [{width, height}, styles.base, props.style];
|
|
382
|
+
sources = [source];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const {onLoadStart, onLoad, onLoadEnd, onError} = props;
|
|
386
|
+
const nativeProps = {
|
|
387
|
+
...props,
|
|
388
|
+
style,
|
|
389
|
+
shouldNotifyLoadEvents: !!(onLoadStart || onLoad || onLoadEnd || onError),
|
|
390
|
+
// Both iOS and C++ sides expect to have "source" prop, whereas on Android it's "src"
|
|
391
|
+
// (for historical reasons). So in the latter case we populate both "src" and "source",
|
|
392
|
+
// in order to have a better alignment between platforms in the future.
|
|
393
|
+
src: sources,
|
|
394
|
+
source: sources,
|
|
395
|
+
/* $FlowFixMe[prop-missing](>=0.78.0 site=react_native_android_fb) This issue was found
|
|
396
|
+
* when making Flow check .android.js files. */
|
|
397
|
+
headers: (source?.[0]?.headers || source?.headers: ?{[string]: string}),
|
|
398
|
+
defaultSource: defaultSource ? defaultSource.uri : null,
|
|
399
|
+
loadingIndicatorSrc: loadingIndicatorSource
|
|
400
|
+
? loadingIndicatorSource.uri
|
|
401
|
+
: null,
|
|
402
|
+
accessibilityLabel:
|
|
403
|
+
props['aria-label'] ?? props.accessibilityLabel ?? props.alt,
|
|
404
|
+
accessibilityLabelledBy:
|
|
405
|
+
props?.['aria-labelledby'] ?? props?.accessibilityLabelledBy,
|
|
406
|
+
accessible: props.alt !== undefined ? true : props.accessible,
|
|
407
|
+
accessibilityState: {
|
|
408
|
+
busy: props['aria-busy'] ?? props.accessibilityState?.busy,
|
|
409
|
+
checked: props['aria-checked'] ?? props.accessibilityState?.checked,
|
|
410
|
+
disabled: props['aria-disabled'] ?? props.accessibilityState?.disabled,
|
|
411
|
+
expanded: props['aria-expanded'] ?? props.accessibilityState?.expanded,
|
|
412
|
+
selected: props['aria-selected'] ?? props.accessibilityState?.selected,
|
|
413
|
+
},
|
|
414
|
+
importantForAccessibility:
|
|
415
|
+
props['aria-hidden'] === true
|
|
416
|
+
? ('no-hide-descendants' as const)
|
|
417
|
+
: props.importantForAccessibility,
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
const flattenedStyle = flattenStyle<ImageStyleProp>(style);
|
|
421
|
+
const objectFit = convertObjectFitToResizeMode(flattenedStyle?.objectFit);
|
|
422
|
+
const resizeMode =
|
|
423
|
+
objectFit || props.resizeMode || flattenedStyle?.resizeMode || 'cover';
|
|
424
|
+
|
|
425
|
+
const actualRef = useWrapRefWithImageAttachedCallbacks(forwardedRef);
|
|
426
|
+
|
|
427
|
+
return (
|
|
428
|
+
<ImageAnalyticsTagContext.Consumer>
|
|
429
|
+
{analyticTag => {
|
|
430
|
+
const nativePropsWithAnalytics =
|
|
431
|
+
analyticTag !== null
|
|
432
|
+
? {
|
|
433
|
+
...nativeProps,
|
|
434
|
+
internal_analyticTag: analyticTag,
|
|
435
|
+
}
|
|
436
|
+
: nativeProps;
|
|
437
|
+
return (
|
|
438
|
+
<TextAncestorContext.Consumer>
|
|
439
|
+
{hasTextAncestor => {
|
|
440
|
+
if (hasTextAncestor) {
|
|
441
|
+
return (
|
|
442
|
+
<TextInlineImageNativeComponent
|
|
443
|
+
// $FlowFixMe[incompatible-type]
|
|
444
|
+
style={style}
|
|
445
|
+
resizeMode={resizeMode}
|
|
446
|
+
headers={nativeProps.headers}
|
|
447
|
+
src={sources}
|
|
448
|
+
ref={actualRef}
|
|
449
|
+
/>
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
228
453
|
return (
|
|
229
|
-
<
|
|
230
|
-
|
|
231
|
-
style={style}
|
|
454
|
+
<ImageViewNativeComponent
|
|
455
|
+
{...nativePropsWithAnalytics}
|
|
232
456
|
resizeMode={resizeMode}
|
|
233
|
-
headers={nativeProps.headers}
|
|
234
|
-
src={sources}
|
|
235
457
|
ref={actualRef}
|
|
236
458
|
/>
|
|
237
459
|
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
</TextAncestorContext.Consumer>
|
|
249
|
-
);
|
|
250
|
-
}}
|
|
251
|
-
</ImageAnalyticsTagContext.Consumer>
|
|
252
|
-
);
|
|
253
|
-
};
|
|
460
|
+
}}
|
|
461
|
+
</TextAncestorContext.Consumer>
|
|
462
|
+
);
|
|
463
|
+
}}
|
|
464
|
+
</ImageAnalyticsTagContext.Consumer>
|
|
465
|
+
);
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
_BaseImage = BaseImage;
|
|
469
|
+
}
|
|
254
470
|
|
|
255
471
|
const imageComponentDecorator = unstable_getImageComponentDecorator();
|
|
256
472
|
if (imageComponentDecorator != null) {
|
|
257
|
-
|
|
473
|
+
_BaseImage = imageComponentDecorator(_BaseImage);
|
|
258
474
|
}
|
|
259
475
|
|
|
260
476
|
// $FlowExpectedError[incompatible-type] Eventually we need to move these functions from statics of the component to exports in the module.
|
|
261
|
-
const Image: ImageAndroid =
|
|
477
|
+
const Image: ImageAndroid = _BaseImage;
|
|
262
478
|
|
|
263
479
|
Image.displayName = 'Image';
|
|
264
480
|
|
|
@@ -153,6 +153,7 @@ let BaseImage: AbstractImageIOS = ({
|
|
|
153
153
|
'aria-disabled': ariaDisabled,
|
|
154
154
|
'aria-expanded': ariaExpanded,
|
|
155
155
|
'aria-selected': ariaSelected,
|
|
156
|
+
'aria-hidden': ariaHidden,
|
|
156
157
|
src,
|
|
157
158
|
...restProps
|
|
158
159
|
} = props;
|
|
@@ -164,6 +165,10 @@ let BaseImage: AbstractImageIOS = ({
|
|
|
164
165
|
expanded: ariaExpanded ?? props.accessibilityState?.expanded,
|
|
165
166
|
selected: ariaSelected ?? props.accessibilityState?.selected,
|
|
166
167
|
};
|
|
168
|
+
|
|
169
|
+
// In order for `aria-hidden` to work on iOS we must set `accessible` to false (`accessibilityElementsHidden` is not enough).
|
|
170
|
+
const accessible =
|
|
171
|
+
ariaHidden !== true && (props.alt !== undefined ? true : props.accessible);
|
|
167
172
|
const accessibilityLabel = props['aria-label'] ?? props.accessibilityLabel;
|
|
168
173
|
|
|
169
174
|
const actualRef = useWrapRefWithImageAttachedCallbacks(forwardedRef);
|
|
@@ -175,7 +180,7 @@ let BaseImage: AbstractImageIOS = ({
|
|
|
175
180
|
<ImageViewNativeComponent
|
|
176
181
|
accessibilityState={_accessibilityState}
|
|
177
182
|
{...restProps}
|
|
178
|
-
accessible={
|
|
183
|
+
accessible={accessible}
|
|
179
184
|
accessibilityLabel={accessibilityLabel ?? props.alt}
|
|
180
185
|
ref={actualRef}
|
|
181
186
|
style={style}
|
|
@@ -172,6 +172,7 @@ let BaseImage: AbstractImageIOS = ({
|
|
|
172
172
|
'aria-multiselectable': ariaMultiselectable, // Win32
|
|
173
173
|
'aria-required': ariaRequired, // Win32
|
|
174
174
|
'aria-selected': ariaSelected,
|
|
175
|
+
'aria-hidden': ariaHidden,
|
|
175
176
|
src,
|
|
176
177
|
...restProps
|
|
177
178
|
} = props;
|
|
@@ -186,6 +187,10 @@ let BaseImage: AbstractImageIOS = ({
|
|
|
186
187
|
required: ariaRequired ?? props.accessibilityState?.required, // Win32
|
|
187
188
|
selected: ariaSelected ?? props.accessibilityState?.selected,
|
|
188
189
|
};
|
|
190
|
+
|
|
191
|
+
// In order for `aria-hidden` to work on iOS we must set `accessible` to false (`accessibilityElementsHidden` is not enough).
|
|
192
|
+
const accessible =
|
|
193
|
+
ariaHidden !== true && (props.alt !== undefined ? true : props.accessible);
|
|
189
194
|
const accessibilityLabel = props['aria-label'] ?? props.accessibilityLabel;
|
|
190
195
|
|
|
191
196
|
const actualRef = useWrapRefWithImageAttachedCallbacks(forwardedRef);
|
|
@@ -207,7 +212,7 @@ let BaseImage: AbstractImageIOS = ({
|
|
|
207
212
|
<ImageViewNativeComponent
|
|
208
213
|
accessibilityState={_accessibilityState}
|
|
209
214
|
{...restProps}
|
|
210
|
-
accessible={
|
|
215
|
+
accessible={accessible}
|
|
211
216
|
accessibilityLabel={accessibilityLabel ?? props.alt}
|
|
212
217
|
ref={actualRef}
|
|
213
218
|
style={style}
|
|
@@ -15,20 +15,26 @@ import type {ImageProps} from './ImageProps';
|
|
|
15
15
|
|
|
16
16
|
import resolveAssetSource from './resolveAssetSource';
|
|
17
17
|
|
|
18
|
+
export type ImageSourceHeaders = {
|
|
19
|
+
[string]: string,
|
|
20
|
+
};
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
23
|
* A function which returns the appropriate value for image source
|
|
20
24
|
* by resolving the `source`, `src` and `srcSet` props.
|
|
21
25
|
*/
|
|
22
26
|
export function getImageSourcesFromImageProps(
|
|
23
27
|
imageProps: ImageProps,
|
|
24
|
-
):
|
|
28
|
+
):
|
|
29
|
+
| ?ResolvedAssetSource
|
|
30
|
+
| $ReadOnlyArray<{uri: string, headers: ImageSourceHeaders, ...}> {
|
|
25
31
|
let source = resolveAssetSource(imageProps.source);
|
|
26
32
|
|
|
27
33
|
let sources;
|
|
28
34
|
|
|
29
35
|
const {crossOrigin, referrerPolicy, src, srcSet, width, height} = imageProps;
|
|
30
36
|
|
|
31
|
-
const headers:
|
|
37
|
+
const headers: ImageSourceHeaders = {};
|
|
32
38
|
if (crossOrigin === 'use-credentials') {
|
|
33
39
|
headers['Access-Control-Allow-Credentials'] = 'true';
|
|
34
40
|
}
|
|
@@ -111,7 +111,7 @@ function addCustomSourceTransformer(
|
|
|
111
111
|
function resolveAssetSource(source: ?ImageSource): ?ResolvedAssetSource {
|
|
112
112
|
if (source == null || typeof source === 'object') {
|
|
113
113
|
// $FlowFixMe[incompatible-exact] `source` doesn't exactly match `ResolvedAssetSource`
|
|
114
|
-
// $FlowFixMe[incompatible-
|
|
114
|
+
// $FlowFixMe[incompatible-type] `source` doesn't exactly match `ResolvedAssetSource`
|
|
115
115
|
return source;
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const resolveAssetSource = require('./resolveAssetSource.js'); // Get base impl
|
|
12
|
+
const Platform = require('../Utilities/Platform').default;
|
|
13
|
+
const ensureShortPath = require('./assetPaths.js');
|
|
14
14
|
|
|
15
15
|
type IPackagerAsset = {
|
|
16
16
|
__packager_asset: boolean,
|
|
@@ -123,10 +123,9 @@ class AssetResolverLateScaleResolution {
|
|
|
123
123
|
|
|
124
124
|
// We should leave the resource scale out of the URI, and do that lookup on the native side.
|
|
125
125
|
// That way we can handle dynamic dpi changes and multimon scenarios better
|
|
126
|
-
|
|
126
|
+
resolveAssetSource.setCustomSourceTransformer(resolver => {
|
|
127
127
|
const lsrResolver = new AssetResolverLateScaleResolution(resolver);
|
|
128
128
|
return lsrResolver.defaultAsset();
|
|
129
|
-
}
|
|
129
|
+
});
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
export default resolveAssetSource;
|
|
131
|
+
module.exports = resolveAssetSource;
|