@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.
Files changed (209) hide show
  1. package/.flowconfig +3 -11
  2. package/CHANGELOG.json +118 -43
  3. package/CHANGELOG.md +45 -27
  4. package/IntegrationTests/IntegrationTestsApp.js +2 -2
  5. package/IntegrationTests/LayoutEventsTest.js +3 -3
  6. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -3
  7. package/Libraries/Alert/RCTAlertManager.android.js +4 -2
  8. package/Libraries/Animated/Animated.d.ts +2 -0
  9. package/Libraries/Animated/AnimatedEvent.js +1 -1
  10. package/Libraries/Animated/AnimatedExports.js.flow +1 -0
  11. package/Libraries/Animated/AnimatedImplementation.js +4 -2
  12. package/Libraries/Animated/AnimatedMock.js +1 -1
  13. package/Libraries/Animated/Easing.js +2 -0
  14. package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
  15. package/Libraries/Animated/animations/Animation.js +19 -20
  16. package/Libraries/Animated/animations/TimingAnimation.js +2 -0
  17. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  18. package/Libraries/Animated/components/AnimatedSectionList.js +1 -1
  19. package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
  20. package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
  21. package/Libraries/Animated/nodes/AnimatedNode.js +14 -7
  22. package/Libraries/Animated/nodes/AnimatedObject.js +7 -7
  23. package/Libraries/Animated/nodes/AnimatedProps.js +32 -32
  24. package/Libraries/Animated/nodes/AnimatedStyle.js +23 -21
  25. package/Libraries/Animated/nodes/AnimatedTransform.js +6 -6
  26. package/Libraries/Animated/nodes/AnimatedValue.js +18 -26
  27. package/Libraries/AppState/AppState.js +8 -4
  28. package/Libraries/BatchedBridge/BatchedBridge.js +1 -0
  29. package/Libraries/BatchedBridge/MessageQueue.js +5 -0
  30. package/Libraries/BatchedBridge/NativeModules.js +1 -1
  31. package/Libraries/Blob/BlobManager.js +1 -1
  32. package/Libraries/Blob/URLSearchParams.js +2 -0
  33. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -2
  34. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -2
  35. package/Libraries/Components/Button.js +1 -1
  36. package/Libraries/Components/Button.win32.js +1 -1
  37. package/Libraries/Components/Pressable/Pressable.js +10 -1
  38. package/Libraries/Components/Pressable/Pressable.win32.js +9 -0
  39. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  40. package/Libraries/Components/ScrollView/ScrollView.js +13 -4
  41. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  42. package/Libraries/Components/StatusBar/StatusBar.js +2 -2
  43. package/Libraries/Components/Switch/Switch.js +1 -1
  44. package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
  45. package/Libraries/Components/TextInput/TextInput.flow.win32.js +12 -5
  46. package/Libraries/Components/TextInput/TextInput.js +14 -5
  47. package/Libraries/Components/TextInput/TextInput.win32.js +15 -7
  48. package/Libraries/Components/TextInput/TextInputState.js +1 -1
  49. package/Libraries/Components/TextInput/TextInputState.win32.js +1 -1
  50. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +2 -3
  51. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  52. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  53. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  54. package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
  55. package/Libraries/Components/Touchable/TouchableWin32.js +1 -1
  56. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  57. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +3 -3
  58. package/Libraries/Components/View/View.js +81 -167
  59. package/Libraries/Components/View/View.win32.js +3 -1
  60. package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
  61. package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +1 -1
  62. package/Libraries/Core/ExceptionsManager.js +4 -2
  63. package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
  64. package/Libraries/Core/ReactNativeVersion.js +37 -10
  65. package/Libraries/Core/Timers/JSTimers.js +4 -1
  66. package/Libraries/Core/Timers/NativeTiming.js +1 -0
  67. package/Libraries/Core/Timers/immediateShim.js +2 -1
  68. package/Libraries/Core/Timers/queueMicrotask.js +1 -0
  69. package/Libraries/Core/setUpPerformance.js +3 -4
  70. package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
  71. package/Libraries/Image/Image.android.js +327 -111
  72. package/Libraries/Image/Image.ios.js +6 -1
  73. package/Libraries/Image/Image.win32.js +6 -1
  74. package/Libraries/Image/ImageSourceUtils.js +8 -2
  75. package/Libraries/Image/assetPaths.js +1 -1
  76. package/Libraries/Image/resolveAssetSource.js +1 -1
  77. package/Libraries/Image/resolveAssetSource.win32.js +6 -7
  78. package/Libraries/Interaction/InteractionManager.js +118 -167
  79. package/Libraries/Interaction/PanResponder.js +7 -52
  80. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -0
  81. package/Libraries/Lists/FlatList.js +5 -6
  82. package/Libraries/LogBox/Data/LogBoxData.js +5 -2
  83. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  84. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +2 -2
  85. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
  86. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +1 -1
  87. package/Libraries/Modal/Modal.js +3 -3
  88. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  89. package/Libraries/NativeComponent/ViewConfig.js +2 -2
  90. package/Libraries/Network/RCTNetworking.android.js +1 -1
  91. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  92. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  93. package/Libraries/Network/XMLHttpRequest.js +20 -5
  94. package/Libraries/Network/convertRequestBody.js +1 -1
  95. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
  96. package/Libraries/Pressability/HoverState.js +2 -0
  97. package/Libraries/Pressability/HoverState.win32.js +2 -0
  98. package/Libraries/Pressability/Pressability.js +1 -1
  99. package/Libraries/Pressability/Pressability.win32.js +1 -1
  100. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
  101. package/Libraries/ReactNative/AppRegistryImpl.js +4 -2
  102. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
  103. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
  104. package/Libraries/ReactNative/RendererImplementation.js +116 -116
  105. package/Libraries/ReactNative/UIManager.js +3 -3
  106. package/Libraries/ReactNative/renderApplication.js +1 -0
  107. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
  108. package/Libraries/Renderer/implementations/ReactFabric-dev.js +38 -35
  109. package/Libraries/Renderer/implementations/ReactFabric-prod.js +51 -22
  110. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +54 -24
  111. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +36 -33
  112. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5 -5
  113. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5 -5
  114. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
  115. package/Libraries/Share/Share.js +4 -0
  116. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
  117. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
  118. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +4 -0
  119. package/Libraries/StyleSheet/StyleSheet.d.ts +7 -22
  120. package/Libraries/StyleSheet/StyleSheetExports.js +2 -8
  121. package/Libraries/StyleSheet/StyleSheetExports.js.flow +11 -18
  122. package/Libraries/StyleSheet/flattenStyle.js +2 -2
  123. package/Libraries/StyleSheet/processAspectRatio.js +2 -0
  124. package/Libraries/StyleSheet/processFilter.js +5 -5
  125. package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
  126. package/Libraries/Text/Text.js +534 -234
  127. package/Libraries/Text/Text.win32.js +647 -274
  128. package/Libraries/Text/TextNativeComponent.js +2 -2
  129. package/Libraries/Text/TextNativeComponent.win32.js +2 -2
  130. package/Libraries/Utilities/Appearance.d.ts +3 -5
  131. package/Libraries/Utilities/Appearance.js +5 -17
  132. package/Libraries/Utilities/HMRClient.js +2 -1
  133. package/Libraries/Utilities/Platform.android.js +3 -3
  134. package/Libraries/Utilities/Platform.d.ts +1 -0
  135. package/Libraries/Utilities/Platform.ios.js +1 -1
  136. package/Libraries/Utilities/Platform.win32.js +3 -3
  137. package/Libraries/Utilities/PlatformTypes.js +1 -1
  138. package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
  139. package/Libraries/Utilities/SceneTracker.js +1 -1
  140. package/Libraries/Utilities/codegenNativeCommands.js +1 -1
  141. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  142. package/Libraries/Utilities/createPerformanceLogger.js +32 -0
  143. package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
  144. package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
  145. package/Libraries/Utilities/useMergeRefs.js +1 -1
  146. package/Libraries/WebSocket/WebSocketInterceptor.js +2 -0
  147. package/Libraries/promiseRejectionTrackingOptions.js +17 -31
  148. package/Libraries/vendor/emitter/EventEmitter.js +1 -1
  149. package/flow/bom.js.flow +223 -1
  150. package/flow/prettier.js.flow +14 -0
  151. package/index.js +14 -2
  152. package/index.win32.js +16 -2
  153. package/jest/local-setup.js +2 -2
  154. package/jest/mock.js +1 -1
  155. package/jest/mockComponent.js +9 -9
  156. package/jest/mockNativeComponent.js +3 -2
  157. package/jest/mocks/Modal.js +1 -1
  158. package/jest/mocks/ScrollView.js +1 -1
  159. package/jest/mocks/ViewNativeComponent.js +1 -1
  160. package/jest/setup.js +23 -12
  161. package/overrides.json +23 -23
  162. package/package.json +28 -27
  163. package/saveAssetPlugin.js +2 -2
  164. package/src/private/animated/NativeAnimatedHelper.js +16 -5
  165. package/src/private/animated/NativeAnimatedHelper.win32.js +16 -5
  166. package/src/private/animated/createAnimatedPropsHook.js +11 -60
  167. package/src/private/animated/createAnimatedPropsMemoHook.js +8 -54
  168. package/src/private/components/virtualview/VirtualView.js +43 -12
  169. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +93 -0
  170. package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
  171. package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
  172. package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -2
  173. package/src/private/featureflags/ReactNativeFeatureFlags.js +85 -52
  174. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
  175. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +15 -6
  176. package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
  177. package/src/private/setup/{setUpPerformanceObserver.js → setUpPerformanceModern.js} +43 -18
  178. package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -0
  179. package/src/private/types/HostInstance.js +4 -1
  180. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
  181. package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
  182. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
  183. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
  184. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
  185. package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
  186. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
  187. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +15 -12
  188. package/src/private/webapis/dom/oldstylecollections/NodeList.js +14 -11
  189. package/src/private/webapis/geometry/DOMRectList.js +2 -2
  190. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +19 -74
  191. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +0 -4
  192. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
  193. package/src/private/webapis/performance/EventTiming.js +40 -25
  194. package/src/private/webapis/performance/LongTasks.js +35 -2
  195. package/src/private/webapis/performance/Performance.js +347 -166
  196. package/src/private/webapis/performance/PerformanceEntry.js +40 -23
  197. package/src/private/webapis/performance/PerformanceObserver.js +37 -29
  198. package/src/private/webapis/performance/ReactNativeStartupTiming.js +3 -24
  199. package/src/private/webapis/performance/ResourceTiming.js +29 -18
  200. package/src/private/webapis/performance/UserTiming.js +92 -34
  201. package/src/private/webapis/performance/UserTimingExtensibility.js.flow +38 -0
  202. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -4
  203. package/src/private/webapis/performance/internals/Utilities.js +9 -0
  204. package/src/private/webapis/performance/specs/NativePerformance.js +23 -23
  205. package/src/private/webapis/structuredClone/structuredClone.js +10 -10
  206. package/src-win/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  207. package/Libraries/Interaction/InteractionManagerStub.js +0 -184
  208. package/Libraries/Interaction/TaskQueue.js +0 -183
  209. 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 BaseImage: AbstractImageAndroid = ({
132
- ref: forwardedRef,
133
- ...props
134
- }: {
135
- ref?: React.RefSetter<HostInstance>,
136
- ...ImageProps,
137
- }) => {
138
- let source = getImageSourcesFromImageProps(props) || {
139
- uri: undefined,
140
- width: undefined,
141
- height: undefined,
142
- };
143
- const defaultSource = resolveAssetSource(props.defaultSource);
144
- const loadingIndicatorSource = resolveAssetSource(
145
- props.loadingIndicatorSource,
146
- );
147
-
148
- if (props.children != null) {
149
- throw new Error(
150
- '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.',
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
- if (props.defaultSource != null && props.loadingIndicatorSource != null) {
155
- throw new Error(
156
- 'The <Image> component cannot have defaultSource and loadingIndicatorSource at the same time. Please use either defaultSource or loadingIndicatorSource.',
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
- let style: ImageStyleProp;
161
- let sources;
162
- if (Array.isArray(source)) {
163
- style = [styles.base, props.style];
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
- const {onLoadStart, onLoad, onLoadEnd, onError} = props;
177
- const nativeProps = {
178
- ...props,
179
- style,
180
- shouldNotifyLoadEvents: !!(onLoadStart || onLoad || onLoadEnd || onError),
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
- src: sources,
185
- source: sources,
186
- /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
187
- * when making Flow check .android.js files. */
188
- headers: (source?.[0]?.headers || source?.headers: ?{[string]: string}),
189
- defaultSource: defaultSource ? defaultSource.uri : null,
190
- loadingIndicatorSrc: loadingIndicatorSource
191
- ? loadingIndicatorSource.uri
192
- : null,
193
- accessibilityLabel:
194
- props['aria-label'] ?? props.accessibilityLabel ?? props.alt,
195
- accessibilityLabelledBy:
196
- props?.['aria-labelledby'] ?? props?.accessibilityLabelledBy,
197
- accessible: props.alt !== undefined ? true : props.accessible,
198
- accessibilityState: {
199
- busy: props['aria-busy'] ?? props.accessibilityState?.busy,
200
- checked: props['aria-checked'] ?? props.accessibilityState?.checked,
201
- disabled: props['aria-disabled'] ?? props.accessibilityState?.disabled,
202
- expanded: props['aria-expanded'] ?? props.accessibilityState?.expanded,
203
- selected: props['aria-selected'] ?? props.accessibilityState?.selected,
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
- const flattenedStyle = flattenStyle<ImageStyleProp>(style);
208
- const objectFit = convertObjectFitToResizeMode(flattenedStyle?.objectFit);
209
- const resizeMode =
210
- objectFit || props.resizeMode || flattenedStyle?.resizeMode || 'cover';
211
-
212
- const actualRef = useWrapRefWithImageAttachedCallbacks(forwardedRef);
213
-
214
- return (
215
- <ImageAnalyticsTagContext.Consumer>
216
- {analyticTag => {
217
- const nativePropsWithAnalytics =
218
- analyticTag !== null
219
- ? {
220
- ...nativeProps,
221
- internal_analyticTag: analyticTag,
222
- }
223
- : nativeProps;
224
- return (
225
- <TextAncestorContext.Consumer>
226
- {hasTextAncestor => {
227
- if (hasTextAncestor) {
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
- <TextInlineImageNativeComponent
230
- // $FlowFixMe[incompatible-type]
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
- return (
241
- <ImageViewNativeComponent
242
- {...nativePropsWithAnalytics}
243
- resizeMode={resizeMode}
244
- ref={actualRef}
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
- BaseImage = imageComponentDecorator(BaseImage);
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 = BaseImage;
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={props.alt !== undefined ? true : props.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={props.alt !== undefined ? true : props.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
- ): ?ResolvedAssetSource | $ReadOnlyArray<{uri: string, ...}> {
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: {[string]: string} = {};
37
+ const headers: ImageSourceHeaders = {};
32
38
  if (crossOrigin === 'use-credentials') {
33
39
  headers['Access-Control-Allow-Credentials'] = 'true';
34
40
  }
@@ -33,4 +33,4 @@ function ensureShortPath(str) {
33
33
  return assetsPrefix + hash.toString();
34
34
  }
35
35
 
36
- export default ensureShortPath;
36
+ module.exports = ensureShortPath;
@@ -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-return] `source` doesn't exactly match `ResolvedAssetSource`
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
- import resolveAssetSource from './resolveAssetSource.js'; // Get base impl
12
- import Platform from '../Utilities/Platform';
13
- import ensureShortPath from './assetPaths';
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
- function setCustomSourceTransformer(resolver) {
126
+ resolveAssetSource.setCustomSourceTransformer(resolver => {
127
127
  const lsrResolver = new AssetResolverLateScaleResolution(resolver);
128
128
  return lsrResolver.defaultAsset();
129
- }
129
+ });
130
130
 
131
- resolveAssetSource.setCustomSourceTransformer = setCustomSourceTransformer;
132
- export default resolveAssetSource;
131
+ module.exports = resolveAssetSource;