@office-iss/react-native-win32 0.83.0-preview.1 → 0.84.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 (193) hide show
  1. package/.flowconfig +2 -2
  2. package/CHANGELOG.json +42 -6
  3. package/CHANGELOG.md +22 -5
  4. package/IntegrationTests/AccessibilityManagerTest.js +10 -7
  5. package/IntegrationTests/ImageCachePolicyTest.js +8 -8
  6. package/IntegrationTests/IntegrationTestsApp.js +3 -3
  7. package/IntegrationTests/LayoutEventsTest.js +1 -1
  8. package/IntegrationTests/TimersTest.js +1 -1
  9. package/IntegrationTests/WebSocketTest.js +1 -1
  10. package/Libraries/Animated/AnimatedEvent.js +2 -2
  11. package/Libraries/Animated/animations/Animation.js +1 -3
  12. package/Libraries/Animated/createAnimatedComponent.js +8 -5
  13. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  14. package/Libraries/Animated/nodes/AnimatedInterpolation.js +40 -4
  15. package/Libraries/Animated/nodes/AnimatedNode.js +3 -3
  16. package/Libraries/Animated/nodes/AnimatedObject.js +16 -11
  17. package/Libraries/Animated/nodes/AnimatedProps.js +43 -12
  18. package/Libraries/Animated/nodes/AnimatedStyle.js +12 -12
  19. package/Libraries/Animated/nodes/AnimatedValue.js +6 -3
  20. package/Libraries/Animated/nodes/AnimatedValueXY.js +1 -1
  21. package/Libraries/BatchedBridge/MessageQueue.js +24 -22
  22. package/Libraries/Blob/URL.js +34 -3
  23. package/Libraries/Blob/URLSearchParams.js +1 -0
  24. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +6 -0
  25. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +6 -1
  26. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +8 -1
  27. package/Libraries/Components/Button.js +2 -5
  28. package/Libraries/Components/Button.win32.js +2 -5
  29. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
  30. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +4 -4
  31. package/Libraries/Components/Keyboard/Keyboard.js +2 -2
  32. package/Libraries/Components/Pressable/Pressable.js +8 -8
  33. package/Libraries/Components/Pressable/Pressable.win32.js +14 -13
  34. package/Libraries/Components/TextInput/TextInput.flow.js +13 -13
  35. package/Libraries/Components/TextInput/TextInput.flow.win32.js +13 -13
  36. package/Libraries/Components/TextInput/TextInput.js +33 -34
  37. package/Libraries/Components/TextInput/TextInput.win32.js +39 -39
  38. package/Libraries/Components/Touchable/PooledClass.js +2 -2
  39. package/Libraries/Components/Touchable/TouchableBounce.js +3 -3
  40. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  41. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +1 -1
  42. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +9 -9
  43. package/Libraries/Components/View/View.win32.js +5 -5
  44. package/Libraries/Components/View/ViewPropTypes.js +16 -6
  45. package/Libraries/Components/View/ViewPropTypes.win32.js +20 -10
  46. package/Libraries/Core/Devtools/loadBundleFromServer.js +6 -3
  47. package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +6 -3
  48. package/Libraries/Core/Devtools/symbolicateStackTrace.js +1 -1
  49. package/Libraries/Core/ExceptionsManager.js +3 -3
  50. package/Libraries/Core/RawEventEmitter.js +1 -1
  51. package/Libraries/Core/ReactFiberErrorDialog.js +1 -1
  52. package/Libraries/Core/ReactNativeVersion.js +1 -1
  53. package/Libraries/Core/setUpDeveloperTools.js +1 -1
  54. package/Libraries/Core/setUpErrorHandling.js +1 -1
  55. package/Libraries/EventEmitter/NativeEventEmitter.js +2 -2
  56. package/Libraries/Image/Image.android.js +2 -2
  57. package/Libraries/Image/Image.ios.js +2 -2
  58. package/Libraries/Image/Image.win32.js +1 -1
  59. package/Libraries/Image/ImageProps.js +1 -1
  60. package/Libraries/Image/ImageTypes.flow.js +2 -2
  61. package/Libraries/Interaction/InteractionManager.js +3 -3
  62. package/Libraries/Interaction/PanResponder.js +1 -1
  63. package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
  64. package/Libraries/Linking/Linking.js +1 -1
  65. package/Libraries/Lists/FlatList.js +2 -2
  66. package/Libraries/LogBox/Data/LogBoxData.js +31 -4
  67. package/Libraries/LogBox/Data/LogBoxLog.js +2 -2
  68. package/Libraries/LogBox/Data/LogBoxSymbolication.js +1 -1
  69. package/Libraries/LogBox/Data/parseLogBoxLog.js +5 -5
  70. package/Libraries/LogBox/LogBox.js +7 -7
  71. package/Libraries/NativeComponent/BaseViewConfig.android.js +12 -0
  72. package/Libraries/NativeComponent/StaticViewConfigValidator.js +4 -4
  73. package/Libraries/NativeComponent/ViewConfigIgnore.js +1 -1
  74. package/Libraries/Network/RCTNetworking.android.js +3 -3
  75. package/Libraries/Network/RCTNetworking.ios.js +2 -2
  76. package/Libraries/Network/RCTNetworking.js.flow +2 -2
  77. package/Libraries/Network/RCTNetworking.win32.js +2 -2
  78. package/Libraries/Pressability/Pressability.js +9 -9
  79. package/Libraries/Pressability/Pressability.win32.js +17 -16
  80. package/Libraries/ReactNative/AppRegistry.flow.js +1 -1
  81. package/Libraries/ReactNative/BridgelessUIManager.js +1 -1
  82. package/Libraries/ReactNative/FabricUIManager.js +1 -1
  83. package/Libraries/ReactNative/PaperUIManager.js +1 -1
  84. package/Libraries/ReactNative/PaperUIManager.win32.js +1 -1
  85. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -1
  86. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils.js +2 -2
  87. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +1 -1
  88. package/Libraries/ReactNative/RendererImplementation.js +1 -1
  89. package/Libraries/ReactNative/getNativeComponentAttributes.js +1 -1
  90. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -2
  91. package/Libraries/Renderer/implementations/ReactFabric-dev.js +3 -3
  92. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
  93. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
  94. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +11 -4
  95. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +11 -4
  96. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +11 -4
  97. package/Libraries/Renderer/shims/ReactFabric.js +3 -1
  98. package/Libraries/Renderer/shims/ReactFeatureFlags.js +3 -1
  99. package/Libraries/Renderer/shims/ReactNative.js +2 -2
  100. package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -1
  101. package/Libraries/Renderer/shims/ReactNativeTypes.win32.js +3 -1
  102. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
  103. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +3 -1
  104. package/Libraries/Settings/Settings.ios.js +1 -1
  105. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
  106. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
  107. package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +4 -2
  108. package/Libraries/StyleSheet/StyleSheetExports.js +1 -1
  109. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +99 -4
  110. package/Libraries/StyleSheet/StyleSheetTypes.js +6 -8
  111. package/Libraries/StyleSheet/processFilter.js +1 -1
  112. package/Libraries/Text/Text.js +46 -6
  113. package/Libraries/Text/Text.win32.js +46 -6
  114. package/Libraries/Text/TextNativeComponent.js +1 -1
  115. package/Libraries/Text/TextNativeComponent.win32.js +1 -1
  116. package/Libraries/Text/TextProps.js +7 -7
  117. package/Libraries/Text/TextProps.win32.js +7 -7
  118. package/Libraries/Types/CodegenTypes.js +1 -1
  119. package/Libraries/Types/CoreEventTypes.js +31 -0
  120. package/Libraries/Types/CoreEventTypes.win32.js +30 -13
  121. package/Libraries/Types/ReactDevToolsTypes.js +2 -2
  122. package/Libraries/Utilities/Appearance.js +2 -2
  123. package/Libraries/Utilities/DevLoadingView.js +8 -1
  124. package/Libraries/Utilities/DevSettings.js +3 -3
  125. package/Libraries/Utilities/HMRClient.js +4 -3
  126. package/Libraries/Utilities/RCTLog.js +3 -3
  127. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  128. package/Libraries/Utilities/SceneTracker.js +1 -1
  129. package/Libraries/Utilities/codegenNativeCommands.js +1 -1
  130. package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +3 -3
  131. package/Libraries/Utilities/logError.js +1 -1
  132. package/Libraries/Utilities/stringifySafe.js +7 -7
  133. package/Libraries/Utilities/useRefEffect.js +1 -1
  134. package/Libraries/WebSocket/WebSocketInterceptor.js +3 -3
  135. package/Libraries/promiseRejectionTrackingOptions.js +8 -8
  136. package/Libraries/vendor/core/ErrorUtils.js +10 -10
  137. package/Libraries/vendor/emitter/EventEmitter.js +6 -6
  138. package/flow/HermesInternalType.js +6 -6
  139. package/flow/bom.js.flow +35 -28
  140. package/flow/cssom.js.flow +3 -3
  141. package/flow/dom.js.flow +34 -33
  142. package/index.js +3 -0
  143. package/index.win32.js +3 -0
  144. package/index.win32.js.flow +8 -0
  145. package/jest/mock.js +2 -2
  146. package/jest/mockComponent.js +1 -1
  147. package/jest/setup.js +1 -1
  148. package/overrides.json +23 -23
  149. package/package.json +19 -18
  150. package/src/private/animated/NativeAnimatedHelper.js +130 -125
  151. package/src/private/animated/NativeAnimatedHelper.win32.js +130 -125
  152. package/src/private/animated/NativeAnimatedValidation.js +7 -4
  153. package/src/private/animated/createAnimatedPropsHook.js +13 -5
  154. package/src/private/animated/createAnimatedPropsMemoHook.js +10 -10
  155. package/src/private/components/virtualview/VirtualView.js +16 -9
  156. package/src/private/components/virtualview/logger/VirtualViewLogger.js +21 -0
  157. package/src/private/components/virtualview/logger/VirtualViewLoggerTypes.js +24 -0
  158. package/src/private/devsupport/devmenu/elementinspector/ElementProperties.js +1 -1
  159. package/src/private/devsupport/devmenu/elementinspector/Inspector.js +6 -25
  160. package/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js +1 -27
  161. package/src/private/devsupport/devmenu/elementinspector/XHRInterceptor.js +3 -2
  162. package/src/private/featureflags/ReactNativeFeatureFlags.js +63 -42
  163. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +3 -3
  164. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +12 -9
  165. package/src/private/renderer/errorhandling/ErrorHandlers.js +7 -4
  166. package/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js +1 -1
  167. package/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js +4 -0
  168. package/src/private/specs_DEPRECATED/modules/NativeDevLoadingView.js +1 -0
  169. package/src/private/webapis/dom/events/CustomEvent.js +3 -3
  170. package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentElementInstanceHandle.js +1 -1
  171. package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
  172. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +29 -29
  173. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +1 -1
  174. package/src/private/webapis/dom/oldstylecollections/NodeList.js +2 -2
  175. package/src/private/webapis/geometry/DOMRectReadOnly.js +1 -1
  176. package/src/private/webapis/html/events/MessageEvent.js +3 -3
  177. package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +3 -3
  178. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +53 -5
  179. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +2 -2
  180. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +4 -4
  181. package/src/private/webapis/microtasks/specs/NativeMicrotasks.js +1 -1
  182. package/src/private/webapis/mutationobserver/MutationObserver.js +1 -1
  183. package/src/private/webapis/mutationobserver/MutationRecord.js +1 -1
  184. package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +4 -4
  185. package/src/private/webapis/performance/Performance.js +1 -1
  186. package/src/private/webapis/performance/UserTiming.js +1 -1
  187. package/src/private/webapis/performance/specs/NativePerformance.js +3 -3
  188. package/src/private/webapis/structuredClone/structuredClone.js +3 -3
  189. package/src/types/globals.d.ts +30 -1
  190. package/src-win/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +6 -0
  191. package/src-win/index.win32.js.flow +8 -0
  192. package/src/private/devsupport/devmenu/elementinspector/NetworkOverlay.js +0 -628
  193. package/src/private/devsupport/devmenu/perfmonitor/PerformanceOverlay.js +0 -66
@@ -1,628 +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
- import type XMLHttpRequest from '../../../../../Libraries/Network/XMLHttpRequest';
14
- import type {ListRenderItemInfo} from '@react-native/virtualized-lists';
15
-
16
- import ScrollView from '../../../../../Libraries/Components/ScrollView/ScrollView';
17
- import * as React from 'react';
18
-
19
- const TouchableHighlight =
20
- require('../../../../../Libraries/Components/Touchable/TouchableHighlight').default;
21
- const View = require('../../../../../Libraries/Components/View/View').default;
22
- const FlatList = require('../../../../../Libraries/Lists/FlatList').default;
23
- const StyleSheet =
24
- require('../../../../../Libraries/StyleSheet/StyleSheet').default;
25
- const Text = require('../../../../../Libraries/Text/Text').default;
26
- const WebSocketInterceptor =
27
- require('../../../../../Libraries/WebSocket/WebSocketInterceptor').default;
28
- const XHRInterceptor = require('./XHRInterceptor').default;
29
-
30
- const LISTVIEW_CELL_HEIGHT = 15;
31
-
32
- // Global id for the intercepted XMLHttpRequest objects.
33
- let nextXHRId = 0;
34
-
35
- type NetworkRequestInfo = {
36
- id: number,
37
- type?: string,
38
- url?: string,
39
- method?: string,
40
- status?: number,
41
- dataSent?: any,
42
- responseContentType?: string,
43
- responseSize?: number,
44
- requestHeaders?: Object,
45
- responseHeaders?: string,
46
- response?: Object | string,
47
- responseURL?: string,
48
- responseType?: string,
49
- timeout?: number,
50
- closeReason?: string,
51
- messages?: string,
52
- serverClose?: Object,
53
- serverError?: Object,
54
- ...
55
- };
56
-
57
- type Props = $ReadOnly<{}>;
58
- type State = {
59
- detailRowId: ?number,
60
- requests: Array<NetworkRequestInfo>,
61
- };
62
-
63
- function getStringByValue(value: any): string {
64
- if (value === undefined) {
65
- return 'undefined';
66
- }
67
- if (typeof value === 'object') {
68
- return JSON.stringify(value);
69
- }
70
- if (typeof value === 'string' && value.length > 500) {
71
- return String(value)
72
- .slice(0, 500)
73
- .concat('\n***TRUNCATED TO 500 CHARACTERS***');
74
- }
75
- return value;
76
- }
77
-
78
- function getTypeShortName(type: any): string {
79
- if (type === 'XMLHttpRequest') {
80
- return 'XHR';
81
- } else if (type === 'WebSocket') {
82
- return 'WS';
83
- }
84
-
85
- return '';
86
- }
87
-
88
- function keyExtractor(request: NetworkRequestInfo): string {
89
- return String(request.id);
90
- }
91
-
92
- const XHR_ID_KEY = Symbol('XHR_ID');
93
-
94
- function getXHRId(xhr: XMLHttpRequest): number {
95
- // $FlowExpectedError[prop-missing]
96
- return xhr[XHR_ID_KEY];
97
- }
98
-
99
- function setXHRId(xhr: XMLHttpRequest, id: number) {
100
- // $FlowExpectedError[prop-missing]
101
- xhr[XHR_ID_KEY] = id;
102
- }
103
-
104
- /**
105
- * Show all the intercepted network requests over the InspectorPanel.
106
- */
107
- class NetworkOverlay extends React.Component<Props, State> {
108
- _requestsListView: ?React.ElementRef<Class<FlatList<NetworkRequestInfo>>>;
109
- _detailScrollView: ?React.ElementRef<typeof ScrollView>;
110
-
111
- // Metrics are used to decide when if the request list should be sticky, and
112
- // scroll to the bottom as new network requests come in, or if the user has
113
- // intentionally scrolled away from the bottom - to instead flash the scroll bar
114
- // and keep the current position
115
- _requestsListViewScrollMetrics: {
116
- contentLength: number,
117
- offset: number,
118
- visibleLength: number,
119
- } = {
120
- offset: 0,
121
- visibleLength: 0,
122
- contentLength: 0,
123
- };
124
-
125
- // Map of `socketId` -> `index in `this.state.requests`.
126
- _socketIdMap: {[number]: number} = {};
127
- // Map of `xhr[XHR_ID_KEY]` -> `index in `this.state.requests`.
128
- _xhrIdMap: {[key: number]: number, ...} = {};
129
-
130
- state: State = {
131
- detailRowId: null,
132
- requests: [],
133
- };
134
-
135
- _enableXHRInterception(): void {
136
- if (XHRInterceptor.isInterceptorEnabled()) {
137
- return;
138
- }
139
- // Show the XHR request item in listView as soon as it was opened.
140
- XHRInterceptor.setOpenCallback((method, url, xhr) => {
141
- // Generate a global id for each intercepted xhr object, add this id
142
- // to the xhr object as a private `_index` property to identify it,
143
- // so that we can distinguish different xhr objects in callbacks.
144
- setXHRId(xhr, nextXHRId++);
145
- const xhrIndex = this.state.requests.length;
146
- this._xhrIdMap[getXHRId(xhr)] = xhrIndex;
147
-
148
- const _xhr: NetworkRequestInfo = {
149
- id: xhrIndex,
150
- type: 'XMLHttpRequest',
151
- method: method,
152
- url: url,
153
- };
154
- this.setState(
155
- {
156
- requests: this.state.requests.concat(_xhr),
157
- },
158
- this._indicateAdditionalRequests,
159
- );
160
- });
161
-
162
- XHRInterceptor.setRequestHeaderCallback((header, value, xhr) => {
163
- // $FlowFixMe[prop-missing]
164
- const xhrIndex = this._getRequestIndexByXHRID(getXHRId(xhr));
165
- if (xhrIndex === -1) {
166
- return;
167
- }
168
-
169
- this.setState(({requests}) => {
170
- const networkRequestInfo = requests[xhrIndex];
171
- if (!networkRequestInfo.requestHeaders) {
172
- networkRequestInfo.requestHeaders = ({}: {[any]: any});
173
- }
174
- networkRequestInfo.requestHeaders[header] = value;
175
- return {requests};
176
- });
177
- });
178
-
179
- XHRInterceptor.setSendCallback((data, xhr) => {
180
- // $FlowFixMe[prop-missing]
181
- const xhrIndex = this._getRequestIndexByXHRID(getXHRId(xhr));
182
- if (xhrIndex === -1) {
183
- return;
184
- }
185
-
186
- this.setState(({requests}) => {
187
- const networkRequestInfo = requests[xhrIndex];
188
- networkRequestInfo.dataSent = data;
189
- return {requests};
190
- });
191
- });
192
-
193
- XHRInterceptor.setHeaderReceivedCallback(
194
- (type, size, responseHeaders, xhr) => {
195
- // $FlowFixMe[prop-missing]
196
- const xhrIndex = this._getRequestIndexByXHRID(getXHRId(xhr));
197
- if (xhrIndex === -1) {
198
- return;
199
- }
200
-
201
- this.setState(({requests}) => {
202
- const networkRequestInfo = requests[xhrIndex];
203
- networkRequestInfo.responseContentType = type;
204
- networkRequestInfo.responseSize = size;
205
- networkRequestInfo.responseHeaders = responseHeaders;
206
- return {requests};
207
- });
208
- },
209
- );
210
-
211
- XHRInterceptor.setResponseCallback(
212
- (status, timeout, response, responseURL, responseType, xhr) => {
213
- // $FlowFixMe[prop-missing]
214
- const xhrIndex = this._getRequestIndexByXHRID(getXHRId(xhr));
215
- if (xhrIndex === -1) {
216
- return;
217
- }
218
-
219
- this.setState(({requests}) => {
220
- const networkRequestInfo = requests[xhrIndex];
221
- networkRequestInfo.status = status;
222
- networkRequestInfo.timeout = timeout;
223
- networkRequestInfo.response = response;
224
- networkRequestInfo.responseURL = responseURL;
225
- networkRequestInfo.responseType = responseType;
226
-
227
- return {requests};
228
- });
229
- },
230
- );
231
-
232
- // Fire above callbacks.
233
- XHRInterceptor.enableInterception();
234
- }
235
-
236
- _enableWebSocketInterception(): void {
237
- if (WebSocketInterceptor.isInterceptorEnabled()) {
238
- return;
239
- }
240
- // Show the WebSocket request item in listView when 'connect' is called.
241
- WebSocketInterceptor.setConnectCallback(
242
- (url, protocols, options, socketId) => {
243
- const socketIndex = this.state.requests.length;
244
- this._socketIdMap[socketId] = socketIndex;
245
- const _webSocket: NetworkRequestInfo = {
246
- id: socketIndex,
247
- type: 'WebSocket',
248
- url: url,
249
- protocols: protocols,
250
- };
251
- this.setState(
252
- {
253
- requests: this.state.requests.concat(_webSocket),
254
- },
255
- this._indicateAdditionalRequests,
256
- );
257
- },
258
- );
259
-
260
- WebSocketInterceptor.setCloseCallback(
261
- (statusCode, closeReason, socketId) => {
262
- const socketIndex = this._socketIdMap[socketId];
263
- if (socketIndex === undefined) {
264
- return;
265
- }
266
- if (statusCode !== null && closeReason !== null) {
267
- this.setState(({requests}) => {
268
- const networkRequestInfo = requests[socketIndex];
269
- networkRequestInfo.status = statusCode;
270
- networkRequestInfo.closeReason = closeReason;
271
- return {requests};
272
- });
273
- }
274
- },
275
- );
276
-
277
- WebSocketInterceptor.setSendCallback((data, socketId) => {
278
- const socketIndex = this._socketIdMap[socketId];
279
- if (socketIndex === undefined) {
280
- return;
281
- }
282
-
283
- this.setState(({requests}) => {
284
- const networkRequestInfo = requests[socketIndex];
285
-
286
- if (!networkRequestInfo.messages) {
287
- networkRequestInfo.messages = '';
288
- }
289
- networkRequestInfo.messages += 'Sent: ' + JSON.stringify(data) + '\n';
290
-
291
- return {requests};
292
- });
293
- });
294
-
295
- WebSocketInterceptor.setOnMessageCallback((message, socketId) => {
296
- const socketIndex = this._socketIdMap[socketId];
297
- if (socketIndex === undefined) {
298
- return;
299
- }
300
-
301
- this.setState(({requests}) => {
302
- const networkRequestInfo = requests[socketIndex];
303
-
304
- if (!networkRequestInfo.messages) {
305
- networkRequestInfo.messages = '';
306
- }
307
- networkRequestInfo.messages +=
308
- 'Received: ' + JSON.stringify(message) + '\n';
309
-
310
- return {requests};
311
- });
312
- });
313
-
314
- WebSocketInterceptor.setOnCloseCallback((message, socketId) => {
315
- const socketIndex = this._socketIdMap[socketId];
316
- if (socketIndex === undefined) {
317
- return;
318
- }
319
-
320
- this.setState(({requests}) => {
321
- const networkRequestInfo = requests[socketIndex];
322
- networkRequestInfo.serverClose = message;
323
-
324
- return {requests};
325
- });
326
- });
327
-
328
- WebSocketInterceptor.setOnErrorCallback((message, socketId) => {
329
- const socketIndex = this._socketIdMap[socketId];
330
- if (socketIndex === undefined) {
331
- return;
332
- }
333
-
334
- this.setState(({requests}) => {
335
- const networkRequestInfo = requests[socketIndex];
336
- networkRequestInfo.serverError = message;
337
-
338
- return {requests};
339
- });
340
- });
341
-
342
- // Fire above callbacks.
343
- WebSocketInterceptor.enableInterception();
344
- }
345
-
346
- componentDidMount() {
347
- this._enableXHRInterception();
348
- this._enableWebSocketInterception();
349
- }
350
-
351
- componentWillUnmount() {
352
- XHRInterceptor.disableInterception();
353
- WebSocketInterceptor.disableInterception();
354
- }
355
-
356
- _renderItem = ({
357
- item,
358
- index,
359
- }: ListRenderItemInfo<NetworkRequestInfo>): React.MixedElement => {
360
- const tableRowViewStyle = [
361
- styles.tableRow,
362
- index % 2 === 1 ? styles.tableRowOdd : styles.tableRowEven,
363
- index === this.state.detailRowId && styles.tableRowPressed,
364
- ];
365
- const urlCellViewStyle = styles.urlCellView;
366
- const methodCellViewStyle = styles.methodCellView;
367
-
368
- return (
369
- <TouchableHighlight
370
- onPress={() => {
371
- this._pressRow(index);
372
- }}>
373
- <View>
374
- <View style={tableRowViewStyle}>
375
- <View style={urlCellViewStyle}>
376
- <Text style={styles.cellText} numberOfLines={1}>
377
- {item.url}
378
- </Text>
379
- </View>
380
- <View style={methodCellViewStyle}>
381
- <Text style={styles.cellText} numberOfLines={1}>
382
- {getTypeShortName(item.type)}
383
- </Text>
384
- </View>
385
- </View>
386
- </View>
387
- </TouchableHighlight>
388
- );
389
- };
390
-
391
- _renderItemDetail(id: number): React.Node {
392
- const requestItem = this.state.requests[id];
393
- const details = Object.keys(requestItem).map(key => {
394
- if (key === 'id') {
395
- return;
396
- }
397
- return (
398
- <View style={styles.detailViewRow} key={key}>
399
- <Text style={[styles.detailViewText, styles.detailKeyCellView]}>
400
- {key}
401
- </Text>
402
- <Text style={[styles.detailViewText, styles.detailValueCellView]}>
403
- {getStringByValue(requestItem[key])}
404
- </Text>
405
- </View>
406
- );
407
- });
408
-
409
- return (
410
- <View>
411
- <TouchableHighlight
412
- style={styles.closeButton}
413
- onPress={this._closeButtonClicked}>
414
- <View>
415
- <Text style={styles.closeButtonText}>v</Text>
416
- </View>
417
- </TouchableHighlight>
418
- <ScrollView
419
- style={styles.detailScrollView}
420
- ref={scrollRef => (this._detailScrollView = scrollRef)}>
421
- {details}
422
- </ScrollView>
423
- </View>
424
- );
425
- }
426
-
427
- _indicateAdditionalRequests = (): void => {
428
- if (this._requestsListView) {
429
- const distanceFromEndThreshold = LISTVIEW_CELL_HEIGHT * 2;
430
- const {offset, visibleLength, contentLength} =
431
- this._requestsListViewScrollMetrics;
432
- const distanceFromEnd = contentLength - visibleLength - offset;
433
- const isCloseToEnd = distanceFromEnd <= distanceFromEndThreshold;
434
- if (isCloseToEnd) {
435
- this._requestsListView.scrollToEnd();
436
- } else {
437
- this._requestsListView.flashScrollIndicators();
438
- }
439
- }
440
- };
441
-
442
- _captureRequestsListView = (listRef: ?FlatList<NetworkRequestInfo>): void => {
443
- this._requestsListView = listRef;
444
- };
445
-
446
- _requestsListViewOnScroll = (e: Object): void => {
447
- this._requestsListViewScrollMetrics.offset = e.nativeEvent.contentOffset.y;
448
- this._requestsListViewScrollMetrics.visibleLength =
449
- e.nativeEvent.layoutMeasurement.height;
450
- this._requestsListViewScrollMetrics.contentLength =
451
- e.nativeEvent.contentSize.height;
452
- };
453
-
454
- /**
455
- * Popup a scrollView to dynamically show detailed information of
456
- * the request, when pressing a row in the network flow listView.
457
- */
458
- _pressRow(rowId: number): void {
459
- this.setState({detailRowId: rowId}, this._scrollDetailToTop);
460
- }
461
-
462
- _scrollDetailToTop = (): void => {
463
- if (this._detailScrollView) {
464
- this._detailScrollView.scrollTo({
465
- y: 0,
466
- animated: false,
467
- });
468
- }
469
- };
470
-
471
- _closeButtonClicked = () => {
472
- this.setState({detailRowId: null});
473
- };
474
-
475
- _getRequestIndexByXHRID(index: number): number {
476
- if (index === undefined) {
477
- return -1;
478
- }
479
- const xhrIndex = this._xhrIdMap[index];
480
- if (xhrIndex === undefined) {
481
- return -1;
482
- } else {
483
- return xhrIndex;
484
- }
485
- }
486
-
487
- render(): React.Node {
488
- const {requests, detailRowId} = this.state;
489
-
490
- return (
491
- <View style={styles.container}>
492
- {detailRowId != null && this._renderItemDetail(detailRowId)}
493
- <View style={styles.listViewTitle}>
494
- {requests.length > 0 && (
495
- <View style={styles.tableRow}>
496
- <View style={styles.urlTitleCellView}>
497
- <Text style={styles.cellText} numberOfLines={1}>
498
- URL
499
- </Text>
500
- </View>
501
- <View style={styles.methodTitleCellView}>
502
- <Text style={styles.cellText} numberOfLines={1}>
503
- Type
504
- </Text>
505
- </View>
506
- </View>
507
- )}
508
- </View>
509
-
510
- <FlatList
511
- ref={this._captureRequestsListView}
512
- onScroll={this._requestsListViewOnScroll}
513
- style={styles.listView}
514
- data={requests}
515
- renderItem={this._renderItem}
516
- keyExtractor={keyExtractor}
517
- extraData={this.state}
518
- />
519
- </View>
520
- );
521
- }
522
- }
523
-
524
- const styles = StyleSheet.create({
525
- container: {
526
- paddingTop: 10,
527
- paddingBottom: 10,
528
- paddingLeft: 5,
529
- paddingRight: 5,
530
- },
531
- listViewTitle: {
532
- height: 20,
533
- },
534
- listView: {
535
- flex: 1,
536
- height: 60,
537
- },
538
- tableRow: {
539
- flexDirection: 'row',
540
- flex: 1,
541
- height: LISTVIEW_CELL_HEIGHT,
542
- },
543
- tableRowEven: {
544
- backgroundColor: '#555',
545
- },
546
- tableRowOdd: {
547
- backgroundColor: '#000',
548
- },
549
- tableRowPressed: {
550
- backgroundColor: '#3B5998',
551
- },
552
- cellText: {
553
- color: 'white',
554
- fontSize: 12,
555
- },
556
- methodTitleCellView: {
557
- height: 18,
558
- borderColor: '#DCD7CD',
559
- borderTopWidth: 1,
560
- borderBottomWidth: 1,
561
- borderRightWidth: 1,
562
- alignItems: 'center',
563
- justifyContent: 'center',
564
- backgroundColor: '#444',
565
- flex: 1,
566
- },
567
- urlTitleCellView: {
568
- height: 18,
569
- borderColor: '#DCD7CD',
570
- borderTopWidth: 1,
571
- borderBottomWidth: 1,
572
- borderLeftWidth: 1,
573
- borderRightWidth: 1,
574
- justifyContent: 'center',
575
- backgroundColor: '#444',
576
- flex: 5,
577
- paddingLeft: 3,
578
- },
579
- methodCellView: {
580
- height: 15,
581
- borderColor: '#DCD7CD',
582
- borderRightWidth: 1,
583
- alignItems: 'center',
584
- justifyContent: 'center',
585
- flex: 1,
586
- },
587
- urlCellView: {
588
- height: 15,
589
- borderColor: '#DCD7CD',
590
- borderLeftWidth: 1,
591
- borderRightWidth: 1,
592
- justifyContent: 'center',
593
- flex: 5,
594
- paddingLeft: 3,
595
- },
596
- detailScrollView: {
597
- flex: 1,
598
- height: 180,
599
- marginTop: 5,
600
- marginBottom: 5,
601
- },
602
- detailKeyCellView: {
603
- flex: 1.3,
604
- },
605
- detailValueCellView: {
606
- flex: 2,
607
- },
608
- detailViewRow: {
609
- flexDirection: 'row',
610
- paddingHorizontal: 3,
611
- },
612
- detailViewText: {
613
- color: 'white',
614
- fontSize: 11,
615
- },
616
- closeButtonText: {
617
- color: 'white',
618
- fontSize: 10,
619
- },
620
- closeButton: {
621
- marginTop: 5,
622
- backgroundColor: '#888',
623
- justifyContent: 'center',
624
- alignItems: 'center',
625
- },
626
- });
627
-
628
- export default NetworkOverlay;
@@ -1,66 +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
- import * as React from 'react';
14
-
15
- const View = require('../../../../../Libraries/Components/View/View').default;
16
- const StyleSheet =
17
- require('../../../../../Libraries/StyleSheet/StyleSheet').default;
18
- const Text = require('../../../../../Libraries/Text/Text').default;
19
- const PerformanceLogger =
20
- require('../../../../../Libraries/Utilities/GlobalPerformanceLogger').default;
21
-
22
- class PerformanceOverlay extends React.Component<{...}> {
23
- render(): React.Node {
24
- const perfLogs = PerformanceLogger.getTimespans();
25
- const items = [];
26
-
27
- for (const key in perfLogs) {
28
- if (perfLogs[key]?.totalTime) {
29
- const unit = key === 'BundleSize' ? 'b' : 'ms';
30
- items.push(
31
- <View style={styles.row} key={key}>
32
- <Text style={[styles.text, styles.label]}>{key}</Text>
33
- <Text style={[styles.text, styles.totalTime]}>
34
- {perfLogs[key].totalTime + unit}
35
- </Text>
36
- </View>,
37
- );
38
- }
39
- }
40
-
41
- return <View style={styles.container}>{items}</View>;
42
- }
43
- }
44
-
45
- const styles = StyleSheet.create({
46
- container: {
47
- height: 100,
48
- paddingTop: 10,
49
- },
50
- label: {
51
- flex: 1,
52
- },
53
- row: {
54
- flexDirection: 'row',
55
- paddingHorizontal: 10,
56
- },
57
- text: {
58
- color: 'white',
59
- fontSize: 12,
60
- },
61
- totalTime: {
62
- paddingRight: 100,
63
- },
64
- });
65
-
66
- export default PerformanceOverlay;