react-native-windows 0.83.0-preview.2 → 0.84.0-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +2 -2
- package/Folly/Folly.vcxproj +2 -0
- package/Libraries/Animated/AnimatedEvent.js +2 -2
- package/Libraries/Animated/animations/Animation.js +1 -3
- package/Libraries/Animated/createAnimatedComponent.js +8 -5
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +40 -4
- package/Libraries/Animated/nodes/AnimatedNode.js +3 -3
- package/Libraries/Animated/nodes/AnimatedObject.js +16 -11
- package/Libraries/Animated/nodes/AnimatedProps.js +43 -12
- package/Libraries/Animated/nodes/AnimatedStyle.js +12 -12
- package/Libraries/Animated/nodes/AnimatedValue.js +6 -3
- package/Libraries/Animated/nodes/AnimatedValueXY.js +1 -1
- package/Libraries/BatchedBridge/MessageQueue.js +24 -22
- package/Libraries/Blob/URL.js +34 -3
- package/Libraries/Blob/URLSearchParams.js +1 -0
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +9 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +6 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +6 -1
- package/Libraries/Components/Button.js +2 -5
- package/Libraries/Components/Button.windows.js +2 -5
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +4 -4
- package/Libraries/Components/Keyboard/Keyboard.js +2 -2
- package/Libraries/Components/Pressable/Pressable.js +8 -8
- package/Libraries/Components/Pressable/Pressable.windows.js +14 -13
- package/Libraries/Components/TextInput/TextInput.flow.js +13 -13
- package/Libraries/Components/TextInput/TextInput.flow.windows.js +19 -18
- package/Libraries/Components/TextInput/TextInput.js +33 -34
- package/Libraries/Components/TextInput/TextInput.windows.js +40 -39
- package/Libraries/Components/Touchable/PooledClass.js +2 -2
- package/Libraries/Components/Touchable/TouchableBounce.js +3 -3
- package/Libraries/Components/Touchable/TouchableBounce.windows.js +3 -3
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +9 -9
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +9 -9
- package/Libraries/Components/View/ViewPropTypes.js +16 -6
- package/Libraries/Components/View/ViewPropTypes.windows.js +21 -11
- package/Libraries/Core/Devtools/loadBundleFromServer.js +6 -3
- package/Libraries/Core/Devtools/loadBundleFromServer.windows.js +6 -3
- package/Libraries/Core/Devtools/symbolicateStackTrace.js +1 -1
- package/Libraries/Core/ExceptionsManager.js +3 -3
- package/Libraries/Core/RawEventEmitter.js +1 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +1 -1
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/setUpDeveloperTools.js +1 -1
- package/Libraries/Core/setUpErrorHandling.js +1 -1
- package/Libraries/EventEmitter/NativeEventEmitter.js +2 -2
- package/Libraries/Image/Image.android.js +2 -2
- package/Libraries/Image/Image.ios.js +2 -2
- package/Libraries/Image/Image.windows.js +2 -2
- package/Libraries/Image/ImageProps.js +1 -1
- package/Libraries/Image/ImageTypes.flow.js +2 -2
- package/Libraries/Interaction/InteractionManager.js +3 -3
- package/Libraries/Interaction/PanResponder.js +1 -1
- package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
- package/Libraries/Linking/Linking.js +1 -1
- package/Libraries/Lists/FlatList.js +2 -2
- package/Libraries/LogBox/Data/LogBoxData.js +31 -4
- package/Libraries/LogBox/Data/LogBoxLog.js +2 -2
- package/Libraries/LogBox/Data/LogBoxSymbolication.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +5 -5
- package/Libraries/LogBox/LogBox.js +7 -7
- package/Libraries/NativeComponent/BaseViewConfig.android.js +12 -0
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +4 -4
- package/Libraries/NativeComponent/ViewConfigIgnore.js +1 -1
- package/Libraries/NativeComponent/ViewConfigIgnore.windows.js +1 -1
- package/Libraries/Network/RCTNetworking.android.js +3 -3
- package/Libraries/Network/RCTNetworking.ios.js +2 -2
- package/Libraries/Network/RCTNetworking.js.flow +2 -2
- package/Libraries/Network/RCTNetworking.windows.js +2 -2
- package/Libraries/Pressability/Pressability.js +9 -9
- package/Libraries/Pressability/Pressability.windows.js +17 -16
- package/Libraries/ReactNative/AppRegistry.flow.js +1 -1
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -1
- package/Libraries/ReactNative/FabricUIManager.js +1 -1
- package/Libraries/ReactNative/PaperUIManager.js +1 -1
- package/Libraries/ReactNative/PaperUIManager.windows.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils.js +2 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +1 -1
- package/Libraries/ReactNative/RendererImplementation.js +1 -1
- package/Libraries/ReactNative/getNativeComponentAttributes.js +1 -1
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -2
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +3 -3
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +11 -4
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +11 -4
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +11 -4
- package/Libraries/Renderer/shims/ReactFabric.js +3 -1
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +3 -1
- package/Libraries/Renderer/shims/ReactNative.js +2 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -1
- package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +3 -1
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +3 -1
- package/Libraries/Settings/Settings.ios.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +4 -2
- package/Libraries/StyleSheet/StyleSheetExports.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +99 -4
- package/Libraries/StyleSheet/StyleSheetTypes.js +6 -8
- package/Libraries/StyleSheet/processFilter.js +1 -1
- package/Libraries/Text/Text.js +46 -6
- package/Libraries/Text/Text.windows.js +46 -6
- package/Libraries/Text/TextNativeComponent.js +1 -1
- package/Libraries/Text/TextProps.js +7 -7
- package/Libraries/Text/TextProps.windows.js +7 -7
- package/Libraries/Types/CodegenTypes.js +1 -1
- package/Libraries/Types/CoreEventTypes.js +31 -0
- package/Libraries/Types/CoreEventTypes.windows.js +31 -13
- package/Libraries/Types/ReactDevToolsTypes.js +2 -2
- package/Libraries/Utilities/Appearance.js +2 -2
- package/Libraries/Utilities/DevLoadingView.js +8 -1
- package/Libraries/Utilities/DevSettings.js +3 -3
- package/Libraries/Utilities/HMRClient.js +4 -3
- package/Libraries/Utilities/RCTLog.js +3 -3
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/SceneTracker.js +1 -1
- package/Libraries/Utilities/codegenNativeCommands.js +1 -1
- package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +3 -3
- package/Libraries/Utilities/logError.js +1 -1
- package/Libraries/Utilities/stringifySafe.js +7 -7
- package/Libraries/Utilities/useRefEffect.js +1 -1
- package/Libraries/WebSocket/WebSocketInterceptor.js +3 -3
- package/Libraries/promiseRejectionTrackingOptions.js +8 -8
- package/Libraries/vendor/core/ErrorUtils.js +10 -10
- package/Libraries/vendor/emitter/EventEmitter.js +6 -6
- package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +5 -0
- package/Microsoft.ReactNative/Fabric/AbiViewProps.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +25 -5
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +2 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +9 -3
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +2 -3
- package/Microsoft.ReactNative/Fabric/ReactTaggedView.h +2 -2
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +2 -0
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +6 -0
- package/Microsoft.ReactNative/ViewProps.idl +9 -0
- package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +12 -2
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/ReactCommon/ReactCommon.vcxproj +7 -1
- package/ReactCommon/ReactCommon.vcxproj.filters +0 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +5 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +0 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +2 -43
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +12 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/attributedstring/TextAttributes.cpp +291 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +0 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +1 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/propsConversions.h +199 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +6 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +17 -10
- package/Scripts/creaternwapp.cmd +8 -1
- package/Scripts/creaternwlib.cmd +21 -2
- package/Shared/DevSettings.h +0 -3
- package/Shared/Modules/WebSocketModule.cpp +0 -1
- package/Shared/Modules/WebSocketModule.h +62 -3
- package/Shared/OInstance.cpp +5 -0
- package/Shared/Shared.vcxitems +4 -6
- package/Shared/Shared.vcxitems.filters +218 -709
- package/codegen/NativeAccessibilityManagerSpec.g.h +2 -0
- package/codegen/NativeAnimatedModuleSpec.g.h +21 -15
- package/codegen/NativeDevLoadingViewSpec.g.h +3 -3
- package/codegen/NativeIntentAndroidSpec.g.h +16 -3
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +209 -191
- package/codegen/react/components/rnwcore/EventEmitters.h +1 -0
- package/codegen/react/components/rnwcore/Props.h +14 -0
- package/codegen/rnwcoreJSI.h +246 -211
- package/index.js +3 -0
- package/index.windows.js +3 -0
- package/jest/mock.js +2 -2
- package/jest/mockComponent.js +1 -1
- package/jest/setup.js +1 -1
- package/package.json +22 -21
- package/src/private/animated/NativeAnimatedHelper.js +130 -125
- package/src/private/animated/NativeAnimatedValidation.js +7 -4
- package/src/private/animated/createAnimatedPropsHook.js +13 -5
- package/src/private/animated/createAnimatedPropsMemoHook.js +10 -10
- package/src/private/components/virtualview/VirtualView.js +16 -9
- package/src/private/components/virtualview/logger/VirtualViewLogger.js +21 -0
- package/src/private/components/virtualview/logger/VirtualViewLoggerTypes.js +24 -0
- package/src/private/devsupport/devmenu/elementinspector/ElementProperties.js +1 -1
- package/src/private/devsupport/devmenu/elementinspector/Inspector.js +6 -25
- package/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js +1 -27
- package/src/private/devsupport/devmenu/elementinspector/XHRInterceptor.js +3 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +63 -42
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +3 -3
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +12 -9
- package/src/private/renderer/errorhandling/ErrorHandlers.js +7 -4
- package/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js +4 -0
- package/src/private/specs_DEPRECATED/modules/NativeDevLoadingView.js +1 -0
- package/src/private/webapis/dom/events/CustomEvent.js +3 -3
- package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentElementInstanceHandle.js +1 -1
- package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +29 -29
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +1 -1
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +2 -2
- package/src/private/webapis/geometry/DOMRectReadOnly.js +1 -1
- package/src/private/webapis/html/events/MessageEvent.js +3 -3
- package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +3 -3
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +53 -5
- package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +2 -2
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +4 -4
- package/src/private/webapis/microtasks/specs/NativeMicrotasks.js +1 -1
- package/src/private/webapis/mutationobserver/MutationObserver.js +1 -1
- package/src/private/webapis/mutationobserver/MutationRecord.js +1 -1
- package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +4 -4
- package/src/private/webapis/performance/Performance.js +1 -1
- package/src/private/webapis/performance/UserTiming.js +1 -1
- package/src/private/webapis/performance/specs/NativePerformance.js +3 -3
- package/src/private/webapis/structuredClone/structuredClone.js +3 -3
- package/src/types/globals.d.ts +30 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +0 -178
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +0 -183
- package/Shared/Modules/WebSocketTurboModule.h +0 -71
- package/src/private/devsupport/devmenu/elementinspector/NetworkOverlay.js +0 -628
- 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;
|