@office-iss/react-native-win32 0.72.6 → 0.73.0-preview.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.
Files changed (272) hide show
  1. package/.flowconfig +15 -4
  2. package/CHANGELOG.json +531 -87
  3. package/CHANGELOG.md +213 -48
  4. package/IntegrationTests/PromiseTest.js +1 -0
  5. package/IntegrationTests/websocket_integration_test_server.js +1 -1
  6. package/Libraries/Animated/Animated.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +1 -1
  8. package/Libraries/Animated/NativeAnimatedHelper.js +14 -10
  9. package/Libraries/Animated/NativeAnimatedHelper.win32.js +16 -12
  10. package/Libraries/Animated/NativeAnimatedModule.js +6 -2
  11. package/Libraries/Animated/NativeAnimatedTurboModule.js +7 -4
  12. package/Libraries/Animated/animations/Animation.js +57 -3
  13. package/Libraries/Animated/animations/DecayAnimation.js +9 -0
  14. package/Libraries/Animated/animations/SpringAnimation.js +8 -0
  15. package/Libraries/Animated/animations/TimingAnimation.js +8 -0
  16. package/Libraries/Animated/components/AnimatedFlatList.js +2 -1
  17. package/Libraries/Animated/components/AnimatedScrollView.js +2 -0
  18. package/Libraries/Animated/components/AnimatedSectionList.js +2 -1
  19. package/Libraries/Animated/createAnimatedComponent.js +1 -0
  20. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  21. package/Libraries/Animated/nodes/AnimatedObject.js +146 -0
  22. package/Libraries/Animated/nodes/AnimatedProps.js +19 -7
  23. package/Libraries/Animated/nodes/AnimatedStyle.js +29 -55
  24. package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -17
  25. package/Libraries/Animated/shouldUseTurboAnimatedModule.js +17 -0
  26. package/Libraries/Animated/useAnimatedProps.js +9 -10
  27. package/Libraries/AppState/AppState.d.ts +1 -1
  28. package/Libraries/AppState/NativeAppState.js +8 -4
  29. package/Libraries/BatchedBridge/MessageQueue.js +45 -36
  30. package/Libraries/Blob/Blob.js +6 -2
  31. package/Libraries/Blob/BlobManager.js +9 -10
  32. package/Libraries/Blob/BlobRegistry.js +14 -9
  33. package/Libraries/Blob/File.js +1 -1
  34. package/Libraries/Blob/FileReader.js +1 -2
  35. package/Libraries/Components/Button/ButtonWin32.Props.d.ts +1 -1
  36. package/Libraries/Components/Button/ButtonWin32.Props.js.map +1 -1
  37. package/Libraries/Components/Button/ButtonWin32.d.ts +1 -1
  38. package/Libraries/Components/Button/ButtonWin32.js +1 -4
  39. package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
  40. package/Libraries/Components/Clipboard/Clipboard.d.ts +4 -4
  41. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +3 -1
  42. package/Libraries/Components/EnterString.win32.d.ts +1 -1
  43. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +26 -6
  44. package/Libraries/Components/Pressable/Pressable.js +3 -2
  45. package/Libraries/Components/Pressable/Pressable.win32.js +4 -3
  46. package/Libraries/Components/Pressable/useAndroidRippleForView.js +1 -1
  47. package/Libraries/Components/SafeAreaView/SafeAreaView.js +7 -7
  48. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +7 -8
  49. package/Libraries/Components/ScrollView/ScrollView.js +3 -1
  50. package/Libraries/Components/ScrollView/ScrollView.win32.js +3 -1
  51. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +39 -46
  52. package/Libraries/Components/Switch/Switch.js +1 -0
  53. package/Libraries/Components/Text/TextWin32.d.ts +1 -1
  54. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  55. package/Libraries/Components/TextInput/TextInput.d.ts +49 -7
  56. package/Libraries/Components/TextInput/TextInput.flow.js +43 -10
  57. package/Libraries/Components/TextInput/TextInput.js +62 -10
  58. package/Libraries/Components/TextInput/TextInput.win32.js +953 -206
  59. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +23 -0
  60. package/Libraries/Components/ToastAndroid/{ToastAndroid.ios.js → ToastAndroid.js} +9 -1
  61. package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +9 -1
  62. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +2 -2
  63. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  64. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  65. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  66. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  67. package/Libraries/Components/Touchable/TouchableOpacity.js +4 -1
  68. package/Libraries/Components/Touchable/TouchableWin32.d.ts +1 -1
  69. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  70. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -0
  71. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +16 -6
  72. package/Libraries/Components/View/ReactNativeStyleAttributes.js +9 -0
  73. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  74. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  75. package/Libraries/Components/View/View.js +46 -32
  76. package/Libraries/Components/View/View.win32.js +37 -6
  77. package/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  78. package/Libraries/Components/View/ViewNativeComponent.js +1 -0
  79. package/Libraries/Components/View/ViewPropTypes.js +18 -3
  80. package/Libraries/Components/View/ViewPropTypes.win32.js +30 -4
  81. package/Libraries/Components/View/ViewWin32.js +3 -2
  82. package/Libraries/Core/Devtools/loadBundleFromServer.js +152 -0
  83. package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -1
  84. package/Libraries/Core/ExceptionsManager.js +16 -7
  85. package/Libraries/Core/ExtendedError.js +12 -0
  86. package/Libraries/Core/ReactNativeVersion.js +3 -3
  87. package/Libraries/Core/ReactNativeVersionCheck.js +0 -2
  88. package/Libraries/Core/ReactNativeVersionCheck.win32.js +0 -2
  89. package/Libraries/Core/__mocks__/NativeExceptionsManager.js +20 -0
  90. package/Libraries/Core/setUpDeveloperTools.js +5 -1
  91. package/Libraries/Core/setUpIntersectionObserver.js +16 -0
  92. package/Libraries/{Components/ProgressBarAndroid/ProgressBarAndroid.ios.js → Core/setUpMutationObserver.js} +6 -2
  93. package/Libraries/Core/setUpPerformance.js +6 -13
  94. package/Libraries/Core/setUpPerformanceObserver.js +16 -0
  95. package/Libraries/Core/setUpRegeneratorRuntime.js +4 -2
  96. package/Libraries/DOM/Nodes/ReactNativeElement.js +135 -18
  97. package/Libraries/DOM/Nodes/ReadOnlyCharacterData.js +72 -0
  98. package/Libraries/DOM/Nodes/ReadOnlyElement.js +209 -21
  99. package/Libraries/DOM/Nodes/ReadOnlyNode.js +206 -17
  100. package/Libraries/DOM/Nodes/ReadOnlyText.js +30 -0
  101. package/Libraries/DOM/Nodes/Utilities/Traversal.js +54 -0
  102. package/Libraries/EventEmitter/NativeEventEmitter.d.ts +0 -6
  103. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +15 -4
  104. package/Libraries/Image/Image.android.js +8 -2
  105. package/Libraries/Image/Image.d.ts +1 -1
  106. package/Libraries/Image/Image.ios.js +4 -1
  107. package/Libraries/Image/Image.win32.js +6 -3
  108. package/Libraries/Image/ImageBackground.js +3 -0
  109. package/Libraries/Image/resolveAssetSource.win32.js +1 -1
  110. package/Libraries/Inspector/DevtoolsOverlay.js +6 -3
  111. package/Libraries/Inspector/NetworkOverlay.js +2 -2
  112. package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -5
  113. package/Libraries/Interaction/PanResponder.js +1 -4
  114. package/Libraries/IntersectionObserver/IntersectionObserver.js +252 -0
  115. package/Libraries/IntersectionObserver/IntersectionObserverEntry.js +140 -0
  116. package/Libraries/IntersectionObserver/IntersectionObserverManager.js +221 -0
  117. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +41 -0
  118. package/Libraries/IntersectionObserver/__mocks__/NativeIntersectionObserver.js +162 -0
  119. package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
  120. package/Libraries/Lists/FlatList.d.ts +2 -1
  121. package/Libraries/Lists/FlatList.js +15 -5
  122. package/Libraries/Lists/SectionList.js +4 -0
  123. package/Libraries/LogBox/Data/LogBoxLog.js +4 -1
  124. package/Libraries/LogBox/Data/LogBoxSymbolication.js +5 -2
  125. package/Libraries/LogBox/Data/parseLogBoxLog.js +57 -20
  126. package/Libraries/LogBox/UI/AnsiHighlight.js +1 -1
  127. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +24 -31
  128. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
  129. package/Libraries/LogBox/UI/LogBoxMessage.js +4 -7
  130. package/Libraries/MutationObserver/MutationObserver.js +184 -0
  131. package/Libraries/MutationObserver/MutationObserverManager.js +218 -0
  132. package/Libraries/MutationObserver/MutationRecord.js +82 -0
  133. package/Libraries/MutationObserver/NativeMutationObserver.js +58 -0
  134. package/Libraries/MutationObserver/__mocks__/NativeMutationObserver.js +327 -0
  135. package/Libraries/NativeComponent/BaseViewConfig.android.js +18 -3
  136. package/Libraries/NativeComponent/BaseViewConfig.ios.js +33 -0
  137. package/Libraries/NativeComponent/BaseViewConfig.win32.js +33 -0
  138. package/Libraries/NativeComponent/NativeComponentRegistry.js +3 -5
  139. package/Libraries/NativeModules/specs/NativeSourceCode.js +6 -6
  140. package/Libraries/Network/RCTNetworking.android.js +2 -1
  141. package/Libraries/Network/XMLHttpRequest.js +1 -1
  142. package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -4
  143. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +9 -2
  144. package/Libraries/Performance/QuickPerformanceLogger.js +1 -1
  145. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
  146. package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +1 -0
  147. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -1
  148. package/Libraries/Pressability/Pressability.js +28 -3
  149. package/Libraries/Pressability/Pressability.win32.js +30 -5
  150. package/Libraries/ReactNative/AppContainer.js +2 -3
  151. package/Libraries/ReactNative/AppRegistry.d.ts +0 -5
  152. package/Libraries/ReactNative/AppRegistry.js +66 -53
  153. package/Libraries/ReactNative/BridgelessUIManager.js +38 -9
  154. package/Libraries/ReactNative/FabricUIManager.js +143 -34
  155. package/Libraries/ReactNative/I18nManager.js +5 -11
  156. package/Libraries/ReactNative/NativeI18nManager.js +7 -5
  157. package/Libraries/ReactNative/PaperUIManager.win32.js +2 -2
  158. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +151 -0
  159. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +81 -0
  160. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +492 -0
  161. package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +32 -0
  162. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +19 -3
  163. package/Libraries/ReactNative/UIManager.js +8 -0
  164. package/Libraries/ReactNative/__mocks__/FabricUIManager.js +648 -0
  165. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +38 -2
  166. package/Libraries/Renderer/implementations/ReactFabric-dev.js +27 -27
  167. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
  168. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
  169. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +27 -27
  170. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -3
  171. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -3
  172. package/Libraries/Renderer/shims/ReactFabric.js +5 -6
  173. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -3
  174. package/Libraries/Renderer/shims/ReactNative.js +2 -3
  175. package/Libraries/Renderer/shims/ReactNativeTypes.js +35 -17
  176. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -3
  177. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -3
  178. package/Libraries/Settings/{Settings.android.js → Settings.js} +4 -4
  179. package/Libraries/Share/Share.d.ts +3 -9
  180. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +9 -4
  181. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +28 -13
  182. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +14 -4
  183. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -1
  184. package/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  185. package/Libraries/StyleSheet/StyleSheet.d.ts +10 -1
  186. package/Libraries/StyleSheet/StyleSheet.js +3 -0
  187. package/Libraries/StyleSheet/StyleSheet.win32.js +3 -0
  188. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +31 -17
  189. package/Libraries/StyleSheet/StyleSheetTypes.js +90 -6
  190. package/Libraries/StyleSheet/flattenStyle.js +4 -0
  191. package/Libraries/StyleSheet/private/_TransformStyle.js +16 -2
  192. package/Libraries/StyleSheet/processColor.js +1 -2
  193. package/Libraries/StyleSheet/processTransformOrigin.js +136 -0
  194. package/Libraries/StyleSheet/splitLayoutProps.js +1 -0
  195. package/Libraries/Text/Text.d.ts +5 -5
  196. package/Libraries/Text/Text.js +17 -10
  197. package/Libraries/Text/Text.win32.js +354 -0
  198. package/Libraries/Text/TextProps.win32.js +281 -0
  199. package/Libraries/TurboModule/TurboModuleRegistry.js +47 -7
  200. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
  201. package/Libraries/Types/CoreEventTypes.d.ts +5 -2
  202. package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -12
  203. package/Libraries/Utilities/NativeDeviceInfo.js +8 -9
  204. package/Libraries/Utilities/NativePlatformConstantsAndroid.js +23 -18
  205. package/Libraries/Utilities/NativePlatformConstantsIOS.js +16 -13
  206. package/Libraries/Utilities/NativePlatformConstantsWin.js +13 -10
  207. package/Libraries/Utilities/PerformanceLoggerContext.js +1 -1
  208. package/Libraries/Utilities/Platform.android.js +12 -8
  209. package/Libraries/Utilities/Platform.d.ts +1 -0
  210. package/Libraries/Utilities/Platform.flow.js +84 -0
  211. package/Libraries/Utilities/Platform.flow.win32.js +111 -0
  212. package/Libraries/Utilities/Platform.ios.js +12 -8
  213. package/Libraries/Utilities/Platform.win32.js +12 -8
  214. package/Libraries/Utilities/PolyfillFunctions.js +1 -1
  215. package/Libraries/Utilities/ReactNativeTestTools.js +1 -2
  216. package/Libraries/Utilities/SceneTracker.js +1 -1
  217. package/Libraries/Utilities/createPerformanceLogger.js +63 -32
  218. package/Libraries/Utilities/useColorScheme.js +7 -8
  219. package/Libraries/WebPerformance/MemoryInfo.js +1 -1
  220. package/Libraries/WebPerformance/NativePerformance.js +3 -8
  221. package/Libraries/WebPerformance/NativePerformanceObserver.js +4 -0
  222. package/Libraries/WebPerformance/Performance.js +42 -15
  223. package/Libraries/WebPerformance/PerformanceEntry.js +14 -6
  224. package/Libraries/WebPerformance/PerformanceEventTiming.js +18 -1
  225. package/Libraries/WebPerformance/ReactNativeStartupTiming.js +40 -14
  226. package/Libraries/WebPerformance/__mocks__/NativePerformance.js +4 -2
  227. package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +21 -3
  228. package/Libraries/promiseRejectionTrackingOptions.js +1 -3
  229. package/Libraries/vendor/emitter/EventEmitter.js +20 -18
  230. package/flow/global.js +1 -3
  231. package/flow/jest.js +5 -1
  232. package/{Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js → jest/ReactNativeInternalFeatureFlagsMock.js} +2 -1
  233. package/jest/__tests__/setup-test.js +18 -0
  234. package/jest/mockModal.js +6 -4
  235. package/jest/setup.js +61 -30
  236. package/jest.config.js +1 -1
  237. package/just-task.js +1 -0
  238. package/overrides.json +51 -46
  239. package/package.json +35 -33
  240. package/src/Libraries/Components/Button/ButtonWin32.Props.ts +1 -1
  241. package/src/Libraries/Components/Button/ButtonWin32.tsx +0 -2
  242. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +2 -2
  243. package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  244. package/src/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  245. package/src/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  246. package/types/experimental.d.ts +44 -0
  247. package/types/index.d.ts +2 -1
  248. package/types/modules/Devtools.d.ts +1 -0
  249. package/types/modules/globals.d.ts +16 -1
  250. package/IntegrationTests/BUCK +0 -32
  251. package/IntegrationTests/PropertiesUpdateTest.js +0 -29
  252. package/IntegrationTests/RCTRootViewIntegrationTestApp.js +0 -86
  253. package/IntegrationTests/ReactContentSizeUpdateTest.js +0 -89
  254. package/IntegrationTests/SizeFlexibilityUpdateTest.js +0 -106
  255. package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +0 -51
  256. package/Libraries/Components/TextInput/TextInput.Types.win32.js +0 -3
  257. package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +0 -1
  258. package/Libraries/Utilities/AcessibilityMapping.js +0 -154
  259. package/Libraries/Utilities/AcessibilityMapping.win32.js +0 -156
  260. package/Libraries/Utilities/NativeDevSplitBundleLoader.js +0 -19
  261. package/Libraries/Utilities/useColorScheme.win32.js +0 -26
  262. package/flow/use-sync-external-store.js +0 -20
  263. package/flow-typed/npm/base64-js_v1.x.x.js +0 -12
  264. package/flow-typed/npm/glob_v7.x.x.js +0 -79
  265. package/flow-typed/npm/pretty-format_v26.x.x.js +0 -49
  266. package/flow-typed/npm/promise_v8.x.x.js +0 -30
  267. package/flow-typed/npm/react-dom_v17.x.x.js +0 -139
  268. package/flow-typed/npm/react-test-renderer_v16.x.x.js +0 -79
  269. package/flow-typed/npm/stacktrace-parser_v0.1.x.js +0 -17
  270. package/flow-typed/npm/yargs_v17.x.x.js +0 -341
  271. package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +0 -68
  272. /package/Libraries/{Renderer/public → ReactNative/ReactFabricPublicInstance}/ReactFabricPublicInstanceUtils.js +0 -0
@@ -73,7 +73,7 @@ export default function Ansi({
73
73
  return content.replace(/\| $/, ' ');
74
74
  } else if (key === 2 && commonWhitespaceLength < Infinity) {
75
75
  // Remove common whitespace at the beginning of the line
76
- return content.substr(commonWhitespaceLength);
76
+ return content.slice(commonWhitespaceLength);
77
77
  } else {
78
78
  return content;
79
79
  }
@@ -10,10 +10,10 @@
10
10
 
11
11
  import type {LogLevel} from '../Data/LogBoxLog';
12
12
 
13
+ import SafeAreaView from '../../Components/SafeAreaView/SafeAreaView';
13
14
  import View from '../../Components/View/View';
14
15
  import StyleSheet from '../../StyleSheet/StyleSheet';
15
16
  import Text from '../../Text/Text';
16
- import DeviceInfo from '../../Utilities/DeviceInfo';
17
17
  import LogBoxButton from './LogBoxButton';
18
18
  import * as LogBoxStyle from './LogBoxStyle';
19
19
  import * as React from 'react';
@@ -52,39 +52,21 @@ type ButtonProps = $ReadOnly<{|
52
52
 
53
53
  function FooterButton(props: ButtonProps): React.Node {
54
54
  return (
55
- <LogBoxButton
56
- backgroundColor={{
57
- default: 'transparent',
58
- pressed: LogBoxStyle.getBackgroundDarkColor(),
59
- }}
60
- onPress={props.onPress}
61
- style={buttonStyles.safeArea}>
62
- <View style={buttonStyles.content}>
63
- <Text style={buttonStyles.label}>{props.text}</Text>
64
- </View>
65
- </LogBoxButton>
55
+ <SafeAreaView style={styles.button}>
56
+ <LogBoxButton
57
+ backgroundColor={{
58
+ default: 'transparent',
59
+ pressed: LogBoxStyle.getBackgroundDarkColor(),
60
+ }}
61
+ onPress={props.onPress}>
62
+ <View style={styles.buttonContent}>
63
+ <Text style={styles.buttonLabel}>{props.text}</Text>
64
+ </View>
65
+ </LogBoxButton>
66
+ </SafeAreaView>
66
67
  );
67
68
  }
68
69
 
69
- const buttonStyles = StyleSheet.create({
70
- safeArea: {
71
- flex: 1,
72
- // $FlowFixMe[sketchy-null-bool]
73
- paddingBottom: DeviceInfo.getConstants().isIPhoneX_deprecated ? 30 : 0,
74
- },
75
- content: {
76
- alignItems: 'center',
77
- height: 48,
78
- justifyContent: 'center',
79
- },
80
- label: {
81
- color: LogBoxStyle.getTextColor(1),
82
- fontSize: 14,
83
- includeFontPadding: false,
84
- lineHeight: 20,
85
- },
86
- });
87
-
88
70
  const styles = StyleSheet.create({
89
71
  root: {
90
72
  backgroundColor: LogBoxStyle.getBackgroundColor(1),
@@ -97,6 +79,17 @@ const styles = StyleSheet.create({
97
79
  button: {
98
80
  flex: 1,
99
81
  },
82
+ buttonContent: {
83
+ alignItems: 'center',
84
+ height: 48,
85
+ justifyContent: 'center',
86
+ },
87
+ buttonLabel: {
88
+ color: LogBoxStyle.getTextColor(1),
89
+ fontSize: 14,
90
+ includeFontPadding: false,
91
+ lineHeight: 20,
92
+ },
100
93
  syntaxErrorText: {
101
94
  textAlign: 'center',
102
95
  width: '100%',
@@ -88,7 +88,7 @@ const backgroundForLevel = (level: LogLevel) =>
88
88
  default: 'transparent',
89
89
  pressed: LogBoxStyle.getFatalDarkColor(),
90
90
  },
91
- }[level]);
91
+ })[level];
92
92
 
93
93
  function LogBoxInspectorHeaderButton(
94
94
  props: $ReadOnly<{|
@@ -138,17 +138,14 @@ function LogBoxMessage(props: Props): React.Node {
138
138
  const key = String(index);
139
139
 
140
140
  if (substitution.offset > prevOffset) {
141
- const prevPart = content.substr(
142
- prevOffset,
143
- substitution.offset - prevOffset,
144
- );
141
+ const prevPart = content.slice(prevOffset, substitution.offset);
145
142
 
146
143
  createUnderLength(key, prevPart);
147
144
  }
148
145
 
149
- const substitutionPart = content.substr(
146
+ const substitutionPart = content.slice(
150
147
  substitution.offset,
151
- substitution.length,
148
+ substitution.offset + substitution.length,
152
149
  );
153
150
 
154
151
  createUnderLength(key + '.5', substitutionPart, substitutionStyle);
@@ -156,7 +153,7 @@ function LogBoxMessage(props: Props): React.Node {
156
153
  }, 0);
157
154
 
158
155
  if (lastOffset < content.length) {
159
- const lastPart = content.substr(lastOffset);
156
+ const lastPart = content.slice(lastOffset);
160
157
  createUnderLength('-1', lastPart);
161
158
  }
162
159
 
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ // flowlint unsafe-getters-setters:off
12
+
13
+ import type {MutationObserverId} from './MutationObserverManager';
14
+ import type MutationRecord from './MutationRecord';
15
+
16
+ import ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
17
+ import * as MutationObserverManager from './MutationObserverManager';
18
+
19
+ export type MutationObserverCallback = (
20
+ mutationRecords: $ReadOnlyArray<MutationRecord>,
21
+ observer: MutationObserver,
22
+ ) => mixed;
23
+
24
+ type MutationObserverInit = $ReadOnly<{
25
+ subtree?: boolean,
26
+ // This is the only supported option so it's required to be `true`.
27
+ childList: true,
28
+
29
+ // Unsupported:
30
+ attributes?: boolean,
31
+ attributeFilter?: $ReadOnlyArray<string>,
32
+ attributeOldValue?: boolean,
33
+ characterData?: boolean,
34
+ characterDataOldValue?: boolean,
35
+ }>;
36
+
37
+ /**
38
+ * This is a React Native implementation for the `MutationObserver` API
39
+ * (https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver).
40
+ *
41
+ * It only supports the `subtree` and `childList` options at the moment.
42
+ */
43
+ export default class MutationObserver {
44
+ _callback: MutationObserverCallback;
45
+ _observationTargets: Set<ReactNativeElement> = new Set();
46
+ _mutationObserverId: ?MutationObserverId;
47
+
48
+ constructor(callback: MutationObserverCallback): void {
49
+ if (callback == null) {
50
+ throw new TypeError(
51
+ "Failed to construct 'MutationObserver': 1 argument required, but only 0 present.",
52
+ );
53
+ }
54
+
55
+ if (typeof callback !== 'function') {
56
+ throw new TypeError(
57
+ "Failed to construct 'MutationObserver': parameter 1 is not of type 'Function'.",
58
+ );
59
+ }
60
+
61
+ this._callback = callback;
62
+ }
63
+
64
+ /**
65
+ * Configures the `MutationObserver` callback to begin receiving notifications
66
+ * of changes to the UI tree that match the given options.
67
+ * Depending on the configuration, the observer may watch a single node in the
68
+ * UI tree, or that node and some or all of its descendant nodes.
69
+ * To stop the `MutationObserver` (so that none of its callbacks will be
70
+ * triggered any longer), call `MutationObserver.disconnect()`.
71
+ */
72
+ observe(target: ReactNativeElement, options?: MutationObserverInit): void {
73
+ if (!(target instanceof ReactNativeElement)) {
74
+ throw new TypeError(
75
+ "Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'ReactNativeElement'.",
76
+ );
77
+ }
78
+
79
+ // Browsers force a cast of this value to boolean
80
+ if (Boolean(options?.childList) !== true) {
81
+ throw new TypeError(
82
+ "Failed to execute 'observe' on 'MutationObserver': The options object must set 'childList' to true.",
83
+ );
84
+ }
85
+
86
+ if (options?.attributes != null) {
87
+ throw new Error(
88
+ "Failed to execute 'observe' on 'MutationObserver': attributes is not supported",
89
+ );
90
+ }
91
+
92
+ if (options?.attributeFilter != null) {
93
+ throw new Error(
94
+ "Failed to execute 'observe' on 'MutationObserver': attributeFilter is not supported",
95
+ );
96
+ }
97
+
98
+ if (options?.attributeOldValue != null) {
99
+ throw new Error(
100
+ "Failed to execute 'observe' on 'MutationObserver': attributeOldValue is not supported",
101
+ );
102
+ }
103
+
104
+ if (options?.characterData != null) {
105
+ throw new Error(
106
+ "Failed to execute 'observe' on 'MutationObserver': characterData is not supported",
107
+ );
108
+ }
109
+
110
+ if (options?.characterDataOldValue != null) {
111
+ throw new Error(
112
+ "Failed to execute 'observe' on 'MutationObserver': characterDataOldValue is not supported",
113
+ );
114
+ }
115
+
116
+ const mutationObserverId = this._getOrCreateMutationObserverId();
117
+
118
+ // As per the spec, if the target is already being observed, we "reset"
119
+ // the observation and only use the last options used.
120
+ if (this._observationTargets.has(target)) {
121
+ MutationObserverManager.unobserve(mutationObserverId, target);
122
+ }
123
+
124
+ MutationObserverManager.observe({
125
+ mutationObserverId,
126
+ target,
127
+ subtree: Boolean(options?.subtree),
128
+ });
129
+
130
+ this._observationTargets.add(target);
131
+ }
132
+
133
+ _unobserve(target: ReactNativeElement): void {
134
+ if (!(target instanceof ReactNativeElement)) {
135
+ throw new TypeError(
136
+ "Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'ReactNativeElement'.",
137
+ );
138
+ }
139
+
140
+ if (!this._observationTargets.has(target)) {
141
+ return;
142
+ }
143
+
144
+ const mutationObserverId = this._mutationObserverId;
145
+ if (mutationObserverId == null) {
146
+ return;
147
+ }
148
+
149
+ MutationObserverManager.unobserve(mutationObserverId, target);
150
+ this._observationTargets.delete(target);
151
+
152
+ if (this._observationTargets.size === 0) {
153
+ MutationObserverManager.unregisterObserver(mutationObserverId);
154
+ this._mutationObserverId = null;
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Tells the observer to stop watching for mutations.
160
+ * The observer can be reused by calling its `observe()` method again.
161
+ */
162
+ disconnect(): void {
163
+ for (const target of this._observationTargets.keys()) {
164
+ this._unobserve(target);
165
+ }
166
+ }
167
+
168
+ _getOrCreateMutationObserverId(): MutationObserverId {
169
+ let mutationObserverId = this._mutationObserverId;
170
+ if (mutationObserverId == null) {
171
+ mutationObserverId = MutationObserverManager.registerObserver(
172
+ this,
173
+ this._callback,
174
+ );
175
+ this._mutationObserverId = mutationObserverId;
176
+ }
177
+ return mutationObserverId;
178
+ }
179
+
180
+ // Only for tests
181
+ __getObserverID(): ?MutationObserverId {
182
+ return this._mutationObserverId;
183
+ }
184
+ }
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ /**
12
+ * This module handles the communication between the React Native renderer
13
+ * and all the mutation observers that are currently observing any targets.
14
+ *
15
+ * In order to reduce the communication between native and JavaScript,
16
+ * we register a single notication callback in native, and then we handle how
17
+ * to notify each entry to the right mutation observer when we receive all
18
+ * the notifications together.
19
+ */
20
+
21
+ import type ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
22
+ import type MutationObserver, {
23
+ MutationObserverCallback,
24
+ } from './MutationObserver';
25
+ import type MutationRecord from './MutationRecord';
26
+
27
+ import {
28
+ getPublicInstanceFromInternalInstanceHandle,
29
+ getShadowNode,
30
+ } from '../DOM/Nodes/ReadOnlyNode';
31
+ import * as Systrace from '../Performance/Systrace';
32
+ import warnOnce from '../Utilities/warnOnce';
33
+ import {createMutationRecord} from './MutationRecord';
34
+ import NativeMutationObserver from './NativeMutationObserver';
35
+
36
+ export type MutationObserverId = number;
37
+
38
+ let nextMutationObserverId: MutationObserverId = 1;
39
+ let isConnected: boolean = false;
40
+
41
+ const registeredMutationObservers: Map<
42
+ MutationObserverId,
43
+ $ReadOnly<{observer: MutationObserver, callback: MutationObserverCallback}>,
44
+ > = new Map();
45
+
46
+ /**
47
+ * Registers the given mutation observer and returns a unique ID for it,
48
+ * which is required to start observing targets.
49
+ */
50
+ export function registerObserver(
51
+ observer: MutationObserver,
52
+ callback: MutationObserverCallback,
53
+ ): MutationObserverId {
54
+ const mutationObserverId = nextMutationObserverId;
55
+ nextMutationObserverId++;
56
+ registeredMutationObservers.set(mutationObserverId, {
57
+ observer,
58
+ callback,
59
+ });
60
+ return mutationObserverId;
61
+ }
62
+
63
+ /**
64
+ * Unregisters the given mutation observer.
65
+ * This should only be called when an observer is no longer observing any
66
+ * targets.
67
+ */
68
+ export function unregisterObserver(
69
+ mutationObserverId: MutationObserverId,
70
+ ): void {
71
+ const deleted = registeredMutationObservers.delete(mutationObserverId);
72
+ if (deleted && registeredMutationObservers.size === 0) {
73
+ // When there are no observers left, we can disconnect the native module
74
+ // so we don't need to check commits for mutations.
75
+ NativeMutationObserver?.disconnect();
76
+ isConnected = false;
77
+ }
78
+ }
79
+
80
+ export function observe({
81
+ mutationObserverId,
82
+ target,
83
+ subtree,
84
+ }: {
85
+ mutationObserverId: MutationObserverId,
86
+ target: ReactNativeElement,
87
+ subtree: boolean,
88
+ }): void {
89
+ if (NativeMutationObserver == null) {
90
+ warnNoNativeMutationObserver();
91
+ return;
92
+ }
93
+
94
+ const registeredObserver =
95
+ registeredMutationObservers.get(mutationObserverId);
96
+ if (registeredObserver == null) {
97
+ console.error(
98
+ `MutationObserverManager: could not start observing target because MutationObserver with ID ${mutationObserverId} was not registered.`,
99
+ );
100
+ return;
101
+ }
102
+
103
+ const targetShadowNode = getShadowNode(target);
104
+ if (targetShadowNode == null) {
105
+ console.error(
106
+ 'MutationObserverManager: could not find reference to host node from target',
107
+ );
108
+ return;
109
+ }
110
+
111
+ if (!isConnected) {
112
+ NativeMutationObserver.connect(
113
+ notifyMutationObservers,
114
+ // We need to do this operation from native to make sure we're retaining
115
+ // the public instance immediately when mutations occur. Otherwise React
116
+ // could dereference it in the instance handle and we wouldn't be able to
117
+ // access it.
118
+ // $FlowExpectedError[incompatible-call] This is typed as (mixed) => mixed in the native module because the codegen doesn't support the actual types.
119
+ getPublicInstanceFromInternalInstanceHandle,
120
+ );
121
+ isConnected = true;
122
+ }
123
+
124
+ return NativeMutationObserver.observe({
125
+ mutationObserverId,
126
+ targetShadowNode,
127
+ subtree,
128
+ });
129
+ }
130
+
131
+ export function unobserve(
132
+ mutationObserverId: number,
133
+ target: ReactNativeElement,
134
+ ): void {
135
+ if (NativeMutationObserver == null) {
136
+ warnNoNativeMutationObserver();
137
+ return;
138
+ }
139
+
140
+ const registeredObserver =
141
+ registeredMutationObservers.get(mutationObserverId);
142
+ if (registeredObserver == null) {
143
+ console.error(
144
+ `MutationObserverManager: could not stop observing target because MutationObserver with ID ${mutationObserverId} was not registered.`,
145
+ );
146
+ return;
147
+ }
148
+
149
+ const targetShadowNode = getShadowNode(target);
150
+ if (targetShadowNode == null) {
151
+ console.error(
152
+ 'MutationObserverManager: could not find reference to host node from target',
153
+ );
154
+ return;
155
+ }
156
+
157
+ NativeMutationObserver.unobserve(mutationObserverId, targetShadowNode);
158
+ }
159
+
160
+ /**
161
+ * This function is called from native when there are `MutationObserver`
162
+ * entries to dispatch.
163
+ */
164
+ function notifyMutationObservers(): void {
165
+ Systrace.beginEvent('MutationObserverManager.notifyMutationObservers');
166
+ try {
167
+ doNotifyMutationObservers();
168
+ } finally {
169
+ Systrace.endEvent();
170
+ }
171
+ }
172
+
173
+ function doNotifyMutationObservers(): void {
174
+ if (NativeMutationObserver == null) {
175
+ warnNoNativeMutationObserver();
176
+ return;
177
+ }
178
+
179
+ const nativeRecords = NativeMutationObserver.takeRecords();
180
+
181
+ const entriesByObserver: Map<
182
+ MutationObserverId,
183
+ Array<MutationRecord>,
184
+ > = new Map();
185
+
186
+ for (const nativeRecord of nativeRecords) {
187
+ let list = entriesByObserver.get(nativeRecord.mutationObserverId);
188
+ if (list == null) {
189
+ list = [];
190
+ entriesByObserver.set(nativeRecord.mutationObserverId, list);
191
+ }
192
+ list.push(createMutationRecord(nativeRecord));
193
+ }
194
+
195
+ for (const [mutationObserverId, entriesForObserver] of entriesByObserver) {
196
+ const registeredObserver =
197
+ registeredMutationObservers.get(mutationObserverId);
198
+ if (!registeredObserver) {
199
+ // This could happen if the observer is disconnected between commit
200
+ // and mount. In this case, we can just ignore the entries.
201
+ return;
202
+ }
203
+
204
+ const {observer, callback} = registeredObserver;
205
+ try {
206
+ callback.call(observer, entriesForObserver, observer);
207
+ } catch (error) {
208
+ console.error(error);
209
+ }
210
+ }
211
+ }
212
+
213
+ function warnNoNativeMutationObserver() {
214
+ warnOnce(
215
+ 'missing-native-mutation-observer',
216
+ 'Missing native implementation of MutationObserver',
217
+ );
218
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ // flowlint unsafe-getters-setters:off
12
+
13
+ import type ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
14
+ import type ReadOnlyNode from '../DOM/Nodes/ReadOnlyNode';
15
+ import type {NativeMutationRecord} from './NativeMutationObserver';
16
+
17
+ import NodeList, {createNodeList} from '../DOM/OldStyleCollections/NodeList';
18
+
19
+ export type MutationType = 'attributes' | 'characterData' | 'childList';
20
+
21
+ /**
22
+ * The `MutationRecord` is a read-only interface that represents an individual
23
+ * DOM mutation observed by a `MutationObserver`.
24
+ *
25
+ * It is the object inside the array passed to the callback of a `MutationObserver`.
26
+ */
27
+ export default class MutationRecord {
28
+ _target: ReactNativeElement;
29
+ _addedNodes: NodeList<ReadOnlyNode>;
30
+ _removedNodes: NodeList<ReadOnlyNode>;
31
+
32
+ constructor(nativeRecord: NativeMutationRecord) {
33
+ // $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type.
34
+ const target = (nativeRecord.target: ReactNativeElement);
35
+ this._target = target;
36
+ // $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type.
37
+ const addedNodes = (nativeRecord.addedNodes: $ReadOnlyArray<ReadOnlyNode>);
38
+ this._addedNodes = createNodeList(addedNodes);
39
+ const removedNodes =
40
+ // $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type.
41
+ (nativeRecord.removedNodes: $ReadOnlyArray<ReadOnlyNode>);
42
+ this._removedNodes = createNodeList(removedNodes);
43
+ }
44
+
45
+ get addedNodes(): NodeList<ReadOnlyNode> {
46
+ return this._addedNodes;
47
+ }
48
+
49
+ get attributeName(): string | null {
50
+ return null;
51
+ }
52
+
53
+ get nextSibling(): ReadOnlyNode | null {
54
+ return null;
55
+ }
56
+
57
+ get oldValue(): mixed | null {
58
+ return null;
59
+ }
60
+
61
+ get previousSibling(): ReadOnlyNode | null {
62
+ return null;
63
+ }
64
+
65
+ get removedNodes(): NodeList<ReadOnlyNode> {
66
+ return this._removedNodes;
67
+ }
68
+
69
+ get target(): ReactNativeElement {
70
+ return this._target;
71
+ }
72
+
73
+ get type(): MutationType {
74
+ return 'childList';
75
+ }
76
+ }
77
+
78
+ export function createMutationRecord(
79
+ entry: NativeMutationRecord,
80
+ ): MutationRecord {
81
+ return new MutationRecord(entry);
82
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import type {TurboModule} from '../TurboModule/RCTExport';
12
+
13
+ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
14
+
15
+ export type MutationObserverId = number;
16
+
17
+ // These types are not supported by the codegen.
18
+ type ShadowNode = mixed;
19
+ type InstanceHandle = mixed;
20
+ type ReactNativeElement = mixed;
21
+ type ReadOnlyNode = mixed;
22
+
23
+ export type NativeMutationRecord = {
24
+ mutationObserverId: MutationObserverId,
25
+ target: ReactNativeElement,
26
+ addedNodes: $ReadOnlyArray<ReadOnlyNode>,
27
+ removedNodes: $ReadOnlyArray<ReadOnlyNode>,
28
+ ...
29
+ };
30
+
31
+ export type NativeMutationObserverObserveOptions = {
32
+ mutationObserverId: number,
33
+ targetShadowNode: ShadowNode,
34
+ subtree: boolean,
35
+ };
36
+
37
+ export interface Spec extends TurboModule {
38
+ +observe: (options: NativeMutationObserverObserveOptions) => void;
39
+ +unobserve: (
40
+ mutationObserverId: number,
41
+ targetShadowNode: ShadowNode,
42
+ ) => void;
43
+ +connect: (
44
+ notifyMutationObservers: () => void,
45
+ // We need this to retain the public instance before React removes the
46
+ // reference to it (which happen in mutations that remove nodes, or when
47
+ // nodes are removed between the change and the callback is executed in JS).
48
+ getPublicInstanceFromInstanceHandle: (
49
+ instanceHandle: InstanceHandle,
50
+ ) => ReadOnlyNode,
51
+ ) => void;
52
+ +disconnect: () => void;
53
+ +takeRecords: () => $ReadOnlyArray<NativeMutationRecord>;
54
+ }
55
+
56
+ export default (TurboModuleRegistry.get<Spec>(
57
+ 'NativeMutationObserverCxx',
58
+ ): ?Spec);