@office-iss/react-native-win32 0.0.0-canary.298 → 0.0.0-canary.299

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 (220) hide show
  1. package/.flowconfig +5 -3
  2. package/CHANGELOG.json +28 -1
  3. package/CHANGELOG.md +16 -6
  4. package/IntegrationTests/IntegrationTestsApp.js +1 -0
  5. package/IntegrationTests/LoggingTestModule.js +16 -20
  6. package/IntegrationTests/TimersTest.js +1 -0
  7. package/IntegrationTests/WebSocketTest.js +1 -0
  8. package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
  9. package/Libraries/Alert/Alert.js +2 -2
  10. package/Libraries/Alert/NativeAlertManager.js +1 -0
  11. package/Libraries/Alert/RCTAlertManager.android.js +19 -13
  12. package/Libraries/Alert/RCTAlertManager.ios.js +9 -11
  13. package/Libraries/Alert/RCTAlertManager.js +1 -3
  14. package/Libraries/Alert/RCTAlertManager.js.flow +4 -6
  15. package/Libraries/Animated/AnimatedEvent.js +4 -3
  16. package/Libraries/Animated/AnimatedExports.js.flow +5 -0
  17. package/Libraries/Animated/AnimatedImplementation.js +44 -44
  18. package/Libraries/Animated/AnimatedMock.js +2 -2
  19. package/Libraries/Animated/NativeAnimatedModule.js +1 -0
  20. package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
  21. package/Libraries/Animated/animations/Animation.js +6 -1
  22. package/Libraries/Animated/components/AnimatedScrollView.js +6 -5
  23. package/Libraries/Animated/components/AnimatedText.js +2 -5
  24. package/Libraries/Animated/components/AnimatedView.js +2 -1
  25. package/Libraries/Animated/createAnimatedComponent.js +2 -4
  26. package/Libraries/Animated/nodes/AnimatedProps.js +2 -7
  27. package/Libraries/AppState/NativeAppState.js +1 -0
  28. package/Libraries/Blob/NativeBlobModule.js +1 -0
  29. package/Libraries/Blob/NativeFileReaderModule.js +1 -0
  30. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js +1 -2
  31. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfoWin32.js +1 -2
  32. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js +1 -2
  33. package/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +1 -2
  34. package/Libraries/Components/Button.js +7 -4
  35. package/Libraries/Components/Button.win32.js +7 -4
  36. package/Libraries/Components/Clipboard/NativeClipboard.js +1 -2
  37. package/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +1 -2
  38. package/Libraries/Components/Keyboard/NativeKeyboardObserver.js +1 -2
  39. package/Libraries/Components/Pressable/Pressable.js +8 -2
  40. package/Libraries/Components/Pressable/Pressable.win32.js +8 -8
  41. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +1 -2
  42. package/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +1 -2
  43. package/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +1 -0
  44. package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +1 -2
  45. package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +9 -0
  46. package/Libraries/Components/SafeAreaView/SafeAreaView.js +3 -2
  47. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +3 -2
  48. package/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +1 -2
  49. package/Libraries/Components/ScrollView/ScrollView.d.ts +10 -1
  50. package/Libraries/Components/ScrollView/ScrollView.js +3 -1
  51. package/Libraries/Components/Sound/NativeSoundManager.js +1 -2
  52. package/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +1 -2
  53. package/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +1 -2
  54. package/Libraries/Components/StatusBar/StatusBar.d.ts +4 -0
  55. package/Libraries/Components/StatusBar/StatusBar.js +5 -0
  56. package/Libraries/Components/Switch/AndroidSwitchNativeComponent.js +1 -2
  57. package/Libraries/Components/Switch/Switch.js +2 -1
  58. package/Libraries/Components/Switch/SwitchNativeComponent.js +1 -2
  59. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +8 -7
  60. package/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js +1 -2
  61. package/Libraries/Components/TextInput/TextInput.flow.js +1 -1
  62. package/Libraries/Components/TextInput/TextInput.js +2 -4
  63. package/Libraries/Components/TextInput/TextInput.win32.js +28 -3
  64. package/Libraries/Components/ToastAndroid/NativeToastAndroid.js +1 -2
  65. package/Libraries/Components/Touchable/Touchable.js +7 -3
  66. package/Libraries/Components/Touchable/Touchable.win32.js +7 -3
  67. package/Libraries/Components/Touchable/TouchableHighlight.js +5 -1
  68. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +3 -2
  69. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +3 -2
  70. package/Libraries/Components/Touchable/TouchableOpacity.d.ts +1 -0
  71. package/Libraries/Components/Touchable/TouchableOpacity.js +3 -2
  72. package/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +1 -2
  73. package/Libraries/Components/View/ReactNativeStyleAttributes.js +6 -15
  74. package/Libraries/Components/View/View.js +17 -18
  75. package/Libraries/Components/View/View.win32.js +16 -2
  76. package/Libraries/Components/View/ViewAccessibility.js +0 -7
  77. package/Libraries/Components/View/ViewAccessibility.win32.js +0 -7
  78. package/Libraries/Components/View/ViewPropTypes.d.ts +4 -0
  79. package/Libraries/Components/View/ViewPropTypes.js +8 -0
  80. package/Libraries/Components/View/ViewPropTypes.win32.js +8 -0
  81. package/Libraries/Core/ExceptionsManager.js +28 -15
  82. package/Libraries/Core/NativeExceptionsManager.js +1 -0
  83. package/Libraries/Core/ReactNativeVersion.js +1 -1
  84. package/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js +1 -0
  85. package/Libraries/Core/Timers/NativeTiming.js +1 -0
  86. package/Libraries/Core/checkNativeVersion.js +1 -0
  87. package/Libraries/Core/setUpReactDevTools.js +21 -4
  88. package/Libraries/Debugging/DebuggingOverlayNativeComponent.js +1 -0
  89. package/Libraries/EventEmitter/NativeEventEmitter.js +3 -3
  90. package/Libraries/Image/Image.android.js +3 -3
  91. package/Libraries/Image/ImageSource.d.ts +5 -0
  92. package/Libraries/Image/ImageViewNativeComponent.js +3 -3
  93. package/Libraries/Image/NativeImageEditor.js +1 -0
  94. package/Libraries/Image/NativeImageLoaderAndroid.js +1 -0
  95. package/Libraries/Image/NativeImageLoaderIOS.js +1 -0
  96. package/Libraries/Image/NativeImageLoaderWin32.js +1 -0
  97. package/Libraries/Image/NativeImageStoreAndroid.js +1 -0
  98. package/Libraries/Image/NativeImageStoreIOS.js +1 -0
  99. package/Libraries/Image/RelativeImageStub.js +1 -1
  100. package/Libraries/Image/TextInlineImageNativeComponent.js +3 -3
  101. package/Libraries/Interaction/InteractionManager.js +6 -1
  102. package/Libraries/Interaction/NativeFrameRateLogger.js +1 -0
  103. package/Libraries/Interaction/TaskQueue.js +14 -0
  104. package/Libraries/LayoutAnimation/LayoutAnimation.js +12 -8
  105. package/Libraries/Linking/NativeIntentAndroid.js +1 -0
  106. package/Libraries/Linking/NativeLinkingManager.js +1 -0
  107. package/Libraries/Lists/FlatList.js +5 -6
  108. package/Libraries/Lists/SectionList.js +4 -4
  109. package/Libraries/Lists/VirtualizedList.js +3 -2
  110. package/Libraries/LogBox/Data/LogBoxData.js +7 -4
  111. package/Libraries/LogBox/LogBox.js +72 -101
  112. package/Libraries/Modal/Modal.d.ts +8 -2
  113. package/Libraries/Modal/Modal.js +19 -2
  114. package/Libraries/Modal/NativeModalManager.js +1 -0
  115. package/Libraries/Modal/RCTModalHostViewNativeComponent.js +1 -0
  116. package/Libraries/NativeComponent/BaseViewConfig.android.js +6 -15
  117. package/Libraries/NativeComponent/BaseViewConfig.ios.js +6 -15
  118. package/Libraries/NativeComponent/BaseViewConfig.win32.js +6 -15
  119. package/Libraries/NativeModules/specs/NativeDevMenu.js +1 -0
  120. package/Libraries/NativeModules/specs/NativeDevSettings.js +1 -0
  121. package/Libraries/NativeModules/specs/NativeDeviceEventManager.js +1 -0
  122. package/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js +1 -0
  123. package/Libraries/NativeModules/specs/NativeLogBox.js +1 -0
  124. package/Libraries/NativeModules/specs/NativeRedBox.js +1 -0
  125. package/Libraries/NativeModules/specs/NativeSourceCode.js +1 -0
  126. package/Libraries/Network/NativeNetworkingAndroid.js +1 -0
  127. package/Libraries/Network/NativeNetworkingIOS.js +1 -0
  128. package/Libraries/Network/XMLHttpRequest.js +2 -0
  129. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
  130. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -2
  131. package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
  132. package/Libraries/ReactNative/AppRegistry.flow.js +2 -2
  133. package/Libraries/ReactNative/AppRegistryImpl.js +0 -10
  134. package/Libraries/ReactNative/BridgelessUIManager.js +1 -1
  135. package/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js +1 -0
  136. package/Libraries/ReactNative/NativeI18nManager.js +1 -0
  137. package/Libraries/ReactNative/NativeUIManager.js +1 -0
  138. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +80 -61
  139. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
  140. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow +2 -2
  141. package/Libraries/Renderer/implementations/ReactFabric-dev.js +3 -1
  142. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -1
  143. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -1
  144. package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -12
  145. package/Libraries/Renderer/shims/ReactNativeTypes.win32.js +3 -12
  146. package/Libraries/Settings/NativeSettingsManager.js +1 -0
  147. package/Libraries/Share/NativeShareModule.js +1 -0
  148. package/Libraries/StyleSheet/StyleSheet.js +1 -0
  149. package/Libraries/StyleSheet/processAspectRatio.js +2 -0
  150. package/Libraries/Text/Text.js +4 -6
  151. package/Libraries/Text/TextAncestor.js +3 -10
  152. package/Libraries/Text/TextAncestorContext.js +23 -0
  153. package/Libraries/Text/TextProps.js +2 -2
  154. package/Libraries/Text/TextProps.win32.js +2 -2
  155. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +1 -0
  156. package/Libraries/Types/CodegenTypesNamespace.js +1 -0
  157. package/Libraries/Utilities/HMRClient.js +12 -2
  158. package/Libraries/Utilities/NativeAppearance.js +1 -0
  159. package/Libraries/Utilities/NativeDevLoadingView.js +1 -0
  160. package/Libraries/Utilities/NativeDeviceInfo.js +1 -2
  161. package/Libraries/Utilities/NativePlatformConstantsAndroid.js +1 -0
  162. package/Libraries/Utilities/NativePlatformConstantsIOS.js +1 -0
  163. package/Libraries/Utilities/NativePlatformConstantsWin.js +1 -0
  164. package/Libraries/Utilities/Platform.android.js +1 -4
  165. package/Libraries/Utilities/Platform.ios.js +1 -4
  166. package/Libraries/Utilities/Platform.js.flow +2 -2
  167. package/Libraries/Utilities/Platform.win32.js +1 -4
  168. package/Libraries/Utilities/PlatformTypes.js +1 -1
  169. package/Libraries/Utilities/codegenNativeCommands.js +4 -2
  170. package/Libraries/Utilities/codegenNativeComponent.js +3 -3
  171. package/Libraries/Utilities/createPerformanceLogger.js +32 -0
  172. package/Libraries/Vibration/NativeVibration.js +1 -0
  173. package/Libraries/WebSocket/NativeWebSocketModule.js +1 -0
  174. package/Libraries/vendor/emitter/EventEmitter.js +6 -6
  175. package/index.js +21 -0
  176. package/index.win32.js +12 -1
  177. package/jest/setup.js +1 -0
  178. package/overrides.json +25 -25
  179. package/package.json +11 -11
  180. package/src/private/animated/createAnimatedPropsHook.js +4 -1
  181. package/src/private/animated/createAnimatedPropsMemoHook.js +2 -2
  182. package/src/private/components/virtualview/VirtualView.js +145 -0
  183. package/src/private/components/virtualview/VirtualViewNativeComponent.js +90 -0
  184. package/src/private/featureflags/ReactNativeFeatureFlags.js +43 -23
  185. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +9 -5
  186. package/src/private/setup/setUpPerformanceObserver.js +7 -0
  187. package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +7 -4
  188. package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +3 -3
  189. package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +3 -3
  190. package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +3 -3
  191. package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +10 -7
  192. package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +5 -4
  193. package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +7 -4
  194. package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +9 -6
  195. package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +9 -6
  196. package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +14 -5
  197. package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +8 -5
  198. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +5 -5
  199. package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +3 -3
  200. package/src/private/specs_DEPRECATED/modules/NativeDeviceInfo.js +1 -0
  201. package/src/private/specs_DEPRECATED/modules/NativeUIManager.js +9 -6
  202. package/src/private/styles/composeStyles.js +5 -12
  203. package/src/private/webapis/errors/DOMException.js +1 -1
  204. package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +4 -2
  205. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +12 -7
  206. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +13 -0
  207. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +2 -1
  208. package/src/private/webapis/performance/Performance.js +164 -61
  209. package/src/private/webapis/performance/PerformanceEntry.js +20 -16
  210. package/src/private/webapis/performance/PerformanceObserver.js +31 -27
  211. package/src/private/webapis/performance/ResourceTiming.js +108 -0
  212. package/src/private/webapis/performance/UserTiming.js +60 -8
  213. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +47 -32
  214. package/src/private/webapis/performance/specs/NativePerformance.js +13 -1
  215. package/src-win/Libraries/Components/View/ViewPropTypes.d.ts +4 -0
  216. package/Libraries/BugReporting/BugReporting.js +0 -140
  217. package/Libraries/BugReporting/NativeBugReporting.js +0 -13
  218. package/Libraries/BugReporting/dumpReactTree.js +0 -151
  219. package/Libraries/BugReporting/getReactData.js +0 -187
  220. package/src/private/specs_DEPRECATED/modules/NativeBugReporting.js +0 -20
@@ -17,6 +17,7 @@ import type {
17
17
  import {PerformanceEventTiming} from '../EventTiming';
18
18
  import {PerformanceLongTaskTiming} from '../LongTasks';
19
19
  import {PerformanceEntry} from '../PerformanceEntry';
20
+ import {PerformanceResourceTiming} from '../ResourceTiming';
20
21
  import {PerformanceMark, PerformanceMeasure} from '../UserTiming';
21
22
 
22
23
  export const RawPerformanceEntryTypeValues = {
@@ -30,38 +31,52 @@ export const RawPerformanceEntryTypeValues = {
30
31
  export function rawToPerformanceEntry(
31
32
  entry: RawPerformanceEntry,
32
33
  ): PerformanceEntry {
33
- if (entry.entryType === RawPerformanceEntryTypeValues.EVENT) {
34
- return new PerformanceEventTiming({
35
- name: entry.name,
36
- startTime: entry.startTime,
37
- duration: entry.duration,
38
- processingStart: entry.processingStart,
39
- processingEnd: entry.processingEnd,
40
- interactionId: entry.interactionId,
41
- });
42
- } else if (entry.entryType === RawPerformanceEntryTypeValues.LONGTASK) {
43
- return new PerformanceLongTaskTiming({
44
- name: entry.name,
45
- entryType: rawToPerformanceEntryType(entry.entryType),
46
- startTime: entry.startTime,
47
- duration: entry.duration,
48
- });
49
- } else if (entry.entryType === RawPerformanceEntryTypeValues.MARK) {
50
- return new PerformanceMark(entry.name, {
51
- startTime: entry.startTime,
52
- });
53
- } else if (entry.entryType === RawPerformanceEntryTypeValues.MEASURE) {
54
- return new PerformanceMeasure(entry.name, {
55
- startTime: entry.startTime,
56
- duration: entry.duration,
57
- });
58
- } else {
59
- return new PerformanceEntry({
60
- name: entry.name,
61
- entryType: rawToPerformanceEntryType(entry.entryType),
62
- startTime: entry.startTime,
63
- duration: entry.duration,
64
- });
34
+ switch (entry.entryType) {
35
+ case RawPerformanceEntryTypeValues.EVENT:
36
+ return new PerformanceEventTiming({
37
+ name: entry.name,
38
+ startTime: entry.startTime,
39
+ duration: entry.duration,
40
+ processingStart: entry.processingStart,
41
+ processingEnd: entry.processingEnd,
42
+ interactionId: entry.interactionId,
43
+ });
44
+ case RawPerformanceEntryTypeValues.LONGTASK:
45
+ return new PerformanceLongTaskTiming({
46
+ name: entry.name,
47
+ entryType: rawToPerformanceEntryType(entry.entryType),
48
+ startTime: entry.startTime,
49
+ duration: entry.duration,
50
+ });
51
+ case RawPerformanceEntryTypeValues.MARK:
52
+ return new PerformanceMark(entry.name, {
53
+ startTime: entry.startTime,
54
+ });
55
+ case RawPerformanceEntryTypeValues.MEASURE:
56
+ return new PerformanceMeasure(entry.name, {
57
+ startTime: entry.startTime,
58
+ duration: entry.duration,
59
+ });
60
+ case RawPerformanceEntryTypeValues.RESOURCE:
61
+ return new PerformanceResourceTiming({
62
+ name: entry.name,
63
+ startTime: entry.startTime,
64
+ duration: entry.duration,
65
+ fetchStart: entry.fetchStart ?? 0,
66
+ requestStart: entry.requestStart ?? 0,
67
+ connectStart: entry.connectStart ?? 0,
68
+ connectEnd: entry.connectEnd ?? 0,
69
+ responseStart: entry.responseStart ?? 0,
70
+ responseEnd: entry.responseEnd ?? 0,
71
+ responseStatus: entry.responseStatus,
72
+ });
73
+ default:
74
+ return new PerformanceEntry({
75
+ name: entry.name,
76
+ entryType: rawToPerformanceEntryType(entry.entryType),
77
+ startTime: entry.startTime,
78
+ duration: entry.duration,
79
+ });
65
80
  }
66
81
  }
67
82
 
@@ -39,7 +39,7 @@ export type RawPerformanceEntry = {
39
39
  responseStatus?: number,
40
40
  };
41
41
 
42
- export type OpaqueNativeObserverHandle = mixed;
42
+ export opaque type OpaqueNativeObserverHandle = mixed;
43
43
 
44
44
  export type NativeBatchedObserverCallback = () => void;
45
45
  export type NativePerformanceMarkResult = number;
@@ -58,6 +58,15 @@ export interface Spec extends TurboModule {
58
58
  name: string,
59
59
  startTime?: number,
60
60
  ) => NativePerformanceMarkResult;
61
+ +measure?: (
62
+ name: string,
63
+ startTime?: number,
64
+ endTime?: number,
65
+ duration?: number,
66
+ startMark?: string,
67
+ endMark?: string,
68
+ ) => NativePerformanceMeasureResult;
69
+ // DEPRECATED: Use measure instead.
61
70
  +measureWithResult?: (
62
71
  name: string,
63
72
  startTime: number,
@@ -96,6 +105,9 @@ export interface Spec extends TurboModule {
96
105
  ) => $ReadOnlyArray<RawPerformanceEntry>;
97
106
 
98
107
  +getSupportedPerformanceEntryTypes?: () => $ReadOnlyArray<RawPerformanceEntryType>;
108
+
109
+ +setCurrentTimeStampForTesting?: (timeStamp: number) => void;
110
+ +clearEventCountsForTesting?: () => void;
99
111
  }
100
112
 
101
113
  export default (TurboModuleRegistry.get<Spec>('NativePerformanceCxx'): ?Spec);
@@ -23,6 +23,9 @@ import {
23
23
  import {Touchable} from 'react-native/Libraries/Components/Touchable/Touchable';
24
24
  import {AccessibilityProps} from './ViewAccessibility';
25
25
 
26
+ /**
27
+ * @deprecated These properties are not implemented natively.
28
+ */
26
29
  export interface TVViewPropsIOS {
27
30
  /**
28
31
  * *(Apple TV only)* When set to true, this view will be focusable
@@ -36,6 +39,7 @@ export interface TVViewPropsIOS {
36
39
  * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view.
37
40
  *
38
41
  * @platform ios
42
+ * @deprecated Use `focusable` instead
39
43
  */
40
44
  hasTVPreferredFocus?: boolean | undefined;
41
45
 
@@ -1,140 +0,0 @@
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 RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
12
- import NativeRedBox from '../NativeModules/specs/NativeRedBox';
13
- import {type EventSubscription} from '../vendor/emitter/EventEmitter';
14
- import NativeBugReporting from './NativeBugReporting';
15
-
16
- type ExtraData = {[key: string]: string, ...};
17
- type SourceCallback = () => string;
18
- type DebugData = {
19
- extras: ExtraData,
20
- files: ExtraData,
21
- ...
22
- };
23
-
24
- function defaultExtras() {
25
- BugReporting.addFileSource('react_hierarchy.txt', () =>
26
- require('./dumpReactTree').default(),
27
- );
28
- }
29
-
30
- /**
31
- * A simple class for collecting bug report data. Components can add sources that will be queried when a bug report
32
- * is created via `collectExtraData`. For example, a list component might add a source that provides the list of rows
33
- * that are currently visible on screen. Components should also remember to call `remove()` on the object that is
34
- * returned by `addSource` when they are unmounted.
35
- */
36
- class BugReporting {
37
- static _extraSources: Map<string, SourceCallback> = new Map();
38
- static _fileSources: Map<string, SourceCallback> = new Map();
39
- static _subscription: ?EventSubscription = null;
40
- static _redboxSubscription: ?EventSubscription = null;
41
-
42
- static _maybeInit() {
43
- if (!BugReporting._subscription) {
44
- BugReporting._subscription = RCTDeviceEventEmitter.addListener(
45
- 'collectBugExtraData',
46
- // $FlowFixMe[method-unbinding]
47
- BugReporting.collectExtraData,
48
- null,
49
- );
50
- defaultExtras();
51
- }
52
-
53
- if (!BugReporting._redboxSubscription) {
54
- BugReporting._redboxSubscription = RCTDeviceEventEmitter.addListener(
55
- 'collectRedBoxExtraData',
56
- // $FlowFixMe[method-unbinding]
57
- BugReporting.collectExtraData,
58
- null,
59
- );
60
- }
61
- }
62
-
63
- /**
64
- * Maps a string key to a simple callback that should return a string payload to be attached
65
- * to a bug report. Source callbacks are called when `collectExtraData` is called.
66
- *
67
- * Returns an object to remove the source when the component unmounts.
68
- *
69
- * Conflicts trample with a warning.
70
- */
71
- static addSource(
72
- key: string,
73
- callback: SourceCallback,
74
- ): {remove: () => void, ...} {
75
- return this._addSource(key, callback, BugReporting._extraSources);
76
- }
77
-
78
- /**
79
- * Maps a string key to a simple callback that should return a string payload to be attached
80
- * to a bug report. Source callbacks are called when `collectExtraData` is called.
81
- *
82
- * Returns an object to remove the source when the component unmounts.
83
- *
84
- * Conflicts trample with a warning.
85
- */
86
- static addFileSource(
87
- key: string,
88
- callback: SourceCallback,
89
- ): {remove: () => void, ...} {
90
- return this._addSource(key, callback, BugReporting._fileSources);
91
- }
92
-
93
- static _addSource(
94
- key: string,
95
- callback: SourceCallback,
96
- source: Map<string, SourceCallback>,
97
- ): {remove: () => void, ...} {
98
- BugReporting._maybeInit();
99
- if (source.has(key)) {
100
- console.warn(
101
- `BugReporting.add* called multiple times for same key '${key}'`,
102
- );
103
- }
104
- source.set(key, callback);
105
- return {
106
- remove: () => {
107
- source.delete(key);
108
- },
109
- };
110
- }
111
-
112
- /**
113
- * This can be called from a native bug reporting flow, or from JS code.
114
- *
115
- * If available, this will call `NativeModules.BugReporting.setExtraData(extraData)`
116
- * after collecting `extraData`.
117
- */
118
- static collectExtraData(): DebugData {
119
- const extraData: ExtraData = {};
120
- for (const [key, callback] of BugReporting._extraSources) {
121
- extraData[key] = callback();
122
- }
123
- const fileData: ExtraData = {};
124
- for (const [key, callback] of BugReporting._fileSources) {
125
- fileData[key] = callback();
126
- }
127
-
128
- if (NativeBugReporting != null && NativeBugReporting.setExtraData != null) {
129
- NativeBugReporting.setExtraData(extraData, fileData);
130
- }
131
-
132
- if (NativeRedBox != null && NativeRedBox.setExtraData != null) {
133
- NativeRedBox.setExtraData(extraData, 'From BugReporting.js');
134
- }
135
-
136
- return {extras: extraData, files: fileData};
137
- }
138
- }
139
-
140
- export default BugReporting;
@@ -1,13 +0,0 @@
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
- export * from '../../src/private/specs_DEPRECATED/modules/NativeBugReporting';
12
- import NativeBugReporting from '../../src/private/specs_DEPRECATED/modules/NativeBugReporting';
13
- export default NativeBugReporting;
@@ -1,151 +0,0 @@
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
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- /*
14
- const getReactData = require('getReactData').default;
15
-
16
- const INDENTATION_SIZE = 2;
17
- const MAX_DEPTH = 2;
18
- const MAX_STRING_LENGTH = 50;
19
- */
20
-
21
- /**
22
- * Dump all React Native root views and their content. This function tries
23
- * it best to get the content but ultimately relies on implementation details
24
- * of React and will fail in future versions.
25
- */
26
- function dumpReactTree(): string {
27
- try {
28
- return getReactTree();
29
- } catch (e) {
30
- return 'Failed to dump react tree: ' + e;
31
- }
32
- }
33
-
34
- function getReactTree() {
35
- // TODO(sema): Reenable tree dumps using the Fiber tree structure. #15945684
36
- return (
37
- 'React tree dumps have been temporarily disabled while React is ' +
38
- 'upgraded to Fiber.'
39
- );
40
- /*
41
- let output = '';
42
- const rootIds = Object.getOwnPropertyNames(ReactNativeMount._instancesByContainerID);
43
- for (const rootId of rootIds) {
44
- const instance = ReactNativeMount._instancesByContainerID[rootId];
45
- output += `============ Root ID: ${rootId} ============\n`;
46
- output += dumpNode(instance, 0);
47
- output += `============ End root ID: ${rootId} ============\n`;
48
- }
49
- return output;
50
- */
51
- }
52
-
53
- /*
54
- function dumpNode(node: Object, indentation: number) {
55
- const data = getReactData(node);
56
- if (data.nodeType === 'Text') {
57
- return indent(indentation) + data.text + '\n';
58
- } else if (data.nodeType === 'Empty') {
59
- return '';
60
- }
61
- let output = indent(indentation) + `<${data.name}`;
62
- if (data.nodeType === 'Composite') {
63
- for (const propName of Object.getOwnPropertyNames(data.props || {})) {
64
- if (isNormalProp(propName)) {
65
- try {
66
- const value = convertValue(data.props[propName]);
67
- if (value) {
68
- output += ` ${propName}=${value}`;
69
- }
70
- } catch (e) {
71
- const message = `[Failed to get property: ${e}]`;
72
- output += ` ${propName}=${message}`;
73
- }
74
- }
75
- }
76
- }
77
- let childOutput = '';
78
- for (const child of data.children || []) {
79
- childOutput += dumpNode(child, indentation + 1);
80
- }
81
-
82
- if (childOutput) {
83
- output += '>\n' + childOutput + indent(indentation) + `</${data.name}>\n`;
84
- } else {
85
- output += ' />\n';
86
- }
87
-
88
- return output;
89
- }
90
-
91
- function isNormalProp(name: string): boolean {
92
- switch (name) {
93
- case 'children':
94
- case 'key':
95
- case 'ref':
96
- return false;
97
- default:
98
- return true;
99
- }
100
- }
101
-
102
- function convertObject(object: Object, depth: number) {
103
- if (depth >= MAX_DEPTH) {
104
- return '[...omitted]';
105
- }
106
- let output = '{';
107
- let first = true;
108
- for (const key of Object.getOwnPropertyNames(object)) {
109
- if (!first) {
110
- output += ', ';
111
- }
112
- output += `${key}: ${convertValue(object[key], depth + 1)}`;
113
- first = false;
114
- }
115
- return output + '}';
116
- }
117
-
118
- function convertValue(value, depth = 0): ?string {
119
- if (!value) {
120
- return null;
121
- }
122
-
123
- switch (typeof value) {
124
- case 'string':
125
- return JSON.stringify(possiblyEllipsis(value).replace('\n', '\\n'));
126
- case 'boolean':
127
- case 'number':
128
- return JSON.stringify(value);
129
- case 'function':
130
- return '[function]';
131
- case 'object':
132
- return convertObject(value, depth);
133
- default:
134
- return null;
135
- }
136
- }
137
-
138
- function possiblyEllipsis(value: string) {
139
- if (value.length > MAX_STRING_LENGTH) {
140
- return value.slice(0, MAX_STRING_LENGTH) + '...';
141
- } else {
142
- return value;
143
- }
144
- }
145
-
146
- function indent(size: number) {
147
- return ' '.repeat(size * INDENTATION_SIZE);
148
- }
149
- */
150
-
151
- export default dumpReactTree;
@@ -1,187 +0,0 @@
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
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- /**
14
- * Convert a react internal instance to a sanitized data object.
15
- *
16
- * This is shamelessly stolen from react-devtools:
17
- * https://github.com/facebook/react-devtools/blob/HEAD/backend/getData.js
18
- */
19
- function getData(element: Object): Object {
20
- let children = null;
21
- let props = null;
22
- let state = null;
23
- let context = null;
24
- let updater = null;
25
- let name = null;
26
- let type = null;
27
- let text = null;
28
- let publicInstance = null;
29
- let nodeType = 'Native';
30
- // If the parent is a native node without rendered children, but with
31
- // multiple string children, then the `element` that gets passed in here is
32
- // a plain value -- a string or number.
33
- if (typeof element !== 'object') {
34
- nodeType = 'Text';
35
- text = element + '';
36
- } else if (
37
- element._currentElement === null ||
38
- element._currentElement === false
39
- ) {
40
- nodeType = 'Empty';
41
- } else if (element._renderedComponent) {
42
- nodeType = 'NativeWrapper';
43
- children = [element._renderedComponent];
44
- props = element._instance.props;
45
- state = element._instance.state;
46
- context = element._instance.context;
47
- if (context && Object.keys(context).length === 0) {
48
- context = null;
49
- }
50
- } else if (element._renderedChildren) {
51
- children = childrenList(element._renderedChildren);
52
- } else if (element._currentElement && element._currentElement.props) {
53
- // This is a native node without rendered children -- meaning the children
54
- // prop is just a string or (in the case of the <option>) a list of
55
- // strings & numbers.
56
- children = element._currentElement.props.children;
57
- }
58
-
59
- if (!props && element._currentElement && element._currentElement.props) {
60
- props = element._currentElement.props;
61
- }
62
-
63
- // != used deliberately here to catch undefined and null
64
- if (element._currentElement != null) {
65
- type = element._currentElement.type;
66
- if (typeof type === 'string') {
67
- name = type;
68
- } else if (element.getName) {
69
- nodeType = 'Composite';
70
- name = element.getName();
71
- // 0.14 top-level wrapper
72
- // TODO(jared): The backend should just act as if these don't exist.
73
- if (
74
- element._renderedComponent &&
75
- element._currentElement.props ===
76
- element._renderedComponent._currentElement
77
- ) {
78
- nodeType = 'Wrapper';
79
- }
80
- if (name === null) {
81
- name = 'No display name';
82
- }
83
- } else if (element._stringText) {
84
- nodeType = 'Text';
85
- text = element._stringText;
86
- } else {
87
- name = type.displayName || type.name || 'Unknown';
88
- }
89
- }
90
-
91
- if (element._instance) {
92
- const inst = element._instance;
93
- updater = {
94
- setState: inst.setState && inst.setState.bind(inst),
95
- forceUpdate: inst.forceUpdate && inst.forceUpdate.bind(inst),
96
- setInProps: inst.forceUpdate && setInProps.bind(null, element),
97
- setInState: inst.forceUpdate && setInState.bind(null, inst),
98
- setInContext: inst.forceUpdate && setInContext.bind(null, inst),
99
- };
100
- publicInstance = inst;
101
-
102
- // TODO: React ART currently falls in this bucket, but this doesn't
103
- // actually make sense and we should clean this up after stabilizing our
104
- // API for backends
105
- if (inst._renderedChildren) {
106
- children = childrenList(inst._renderedChildren);
107
- }
108
- }
109
-
110
- return {
111
- nodeType,
112
- type,
113
- name,
114
- props,
115
- state,
116
- context,
117
- children,
118
- text,
119
- updater,
120
- publicInstance,
121
- };
122
- }
123
-
124
- function setInProps(
125
- internalInst: any,
126
- path: Array<string | number>,
127
- value: any,
128
- ) {
129
- const element = internalInst._currentElement;
130
- internalInst._currentElement = {
131
- ...element,
132
- props: copyWithSet(element.props, path, value),
133
- };
134
- internalInst._instance.forceUpdate();
135
- }
136
-
137
- function setInState(inst: any, path: Array<string | number>, value: any) {
138
- setIn(inst.state, path, value);
139
- inst.forceUpdate();
140
- }
141
-
142
- function setInContext(inst: any, path: Array<string | number>, value: any) {
143
- setIn(inst.context, path, value);
144
- inst.forceUpdate();
145
- }
146
-
147
- function setIn(obj: Object, path: Array<string | number>, value: any) {
148
- const last = path.pop();
149
- const parent = path.reduce((obj_, attr) => (obj_ ? obj_[attr] : null), obj);
150
- if (parent) {
151
- parent[last] = value;
152
- }
153
- }
154
-
155
- function childrenList(children: any) {
156
- const res = [];
157
- for (const name in children) {
158
- res.push(children[name]);
159
- }
160
- return res;
161
- }
162
-
163
- function copyWithSetImpl(
164
- obj: any | Array<any>,
165
- path: Array<string | number>,
166
- idx: number,
167
- value: any,
168
- ): any {
169
- if (idx >= path.length) {
170
- return value;
171
- }
172
- const key = path[idx];
173
- const updated = Array.isArray(obj) ? obj.slice() : {...obj};
174
- // $FlowFixMe[incompatible-use] number or string is fine here
175
- updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
176
- return updated;
177
- }
178
-
179
- function copyWithSet(
180
- obj: Object | Array<any>,
181
- path: Array<string | number>,
182
- value: any,
183
- ): Object | Array<any> {
184
- return copyWithSetImpl(obj, path, 0, value);
185
- }
186
-
187
- export default getData;
@@ -1,20 +0,0 @@
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
8
- * @format
9
- */
10
-
11
- import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
12
-
13
- import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry';
14
-
15
- export interface Spec extends TurboModule {
16
- +startReportAProblemFlow: () => void;
17
- +setExtraData: (extraData: Object, extraFiles: Object) => void;
18
- }
19
-
20
- export default (TurboModuleRegistry.get<Spec>('BugReporting'): ?Spec);