@office-iss/react-native-win32 0.74.3 → 0.75.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.
- package/.flowconfig +9 -4
- package/CHANGELOG.json +563 -45
- package/CHANGELOG.md +169 -26
- package/Libraries/Animated/AnimatedImplementation.js +2 -0
- package/Libraries/Animated/NativeAnimatedHelper.js +4 -0
- package/Libraries/Animated/NativeAnimatedHelper.win32.js +4 -0
- package/Libraries/Animated/createAnimatedComponent.js +10 -4
- package/Libraries/Animated/useAnimatedProps.js +56 -28
- package/Libraries/BatchedBridge/MessageQueue.js +1 -0
- package/Libraries/Components/Button.js +10 -5
- package/Libraries/Components/Button.win32.js +1 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +11 -2
- package/Libraries/Components/Pressable/Pressable.js +13 -6
- package/Libraries/Components/Pressable/Pressable.win32.js +13 -6
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +4 -0
- package/Libraries/Components/ScrollView/ScrollView.js +109 -29
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +6 -0
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +13 -1
- package/Libraries/Components/StatusBar/StatusBar.js +1 -21
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +0 -15
- package/Libraries/Components/TextInput/InputAccessoryView.js +10 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +0 -12
- package/Libraries/Components/TextInput/TextInput.d.ts +0 -19
- package/Libraries/Components/TextInput/TextInput.js +20 -73
- package/Libraries/Components/TextInput/TextInput.win32.js +21 -75
- package/Libraries/Components/Touchable/Touchable.js +2 -2
- package/Libraries/Components/Touchable/TouchableHighlight.d.ts +4 -10
- package/Libraries/Components/Touchable/TouchableHighlight.js +3 -1
- package/Libraries/Components/Touchable/TouchableOpacity.d.ts +4 -32
- package/Libraries/Components/Touchable/TouchableOpacity.js +3 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +8 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +117 -111
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +6 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
- package/Libraries/Components/View/View.js +0 -11
- package/Libraries/Components/View/View.win32.js +0 -11
- package/Libraries/Components/View/ViewAccessibility.js +4 -4
- package/Libraries/Components/View/ViewAccessibility.win32.js +6 -6
- package/Libraries/Components/View/ViewPropTypes.d.ts +7 -49
- package/Libraries/Components/View/ViewPropTypes.js +7 -0
- package/Libraries/Components/View/ViewPropTypes.win32.js +7 -0
- package/Libraries/Core/Devtools/loadBundleFromServer.js +3 -3
- package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +153 -0
- package/Libraries/Core/Devtools/parseErrorStack.js +5 -5
- package/Libraries/Core/Devtools/parseHermesStack.js +22 -16
- package/Libraries/Core/ErrorHandlers.js +116 -0
- package/Libraries/Core/ExceptionsManager.js +2 -2
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/setUpDeveloperTools.js +3 -1
- package/Libraries/Core/setUpPerformance.js +6 -4
- package/Libraries/Core/setUpReactDevTools.js +70 -10
- package/Libraries/Core/setUpTimers.js +50 -31
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +1 -1
- package/Libraries/Image/Image.android.js +23 -13
- package/Libraries/Image/Image.d.ts +14 -15
- package/Libraries/Image/Image.ios.js +21 -11
- package/Libraries/Image/Image.win32.js +5 -3
- package/Libraries/Image/ImageProps.js +16 -5
- package/Libraries/Image/ImageTypes.flow.js +7 -2
- package/Libraries/Image/ImageUtils.js +1 -0
- package/Libraries/Image/ImageViewNativeComponent.js +2 -1
- package/Libraries/Inspector/ElementBox.js +6 -3
- package/Libraries/Inspector/ElementProperties.js +1 -1
- package/Libraries/Interaction/TouchHistoryMath.js +4 -4
- package/Libraries/IntersectionObserver/IntersectionObserverManager.js +6 -26
- package/Libraries/JSInspector/NetworkAgent.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +39 -29
- package/Libraries/LogBox/Data/LogBoxLog.js +114 -2
- package/Libraries/LogBox/Data/parseLogBoxLog.js +168 -53
- package/Libraries/LogBox/LogBox.js +29 -12
- package/Libraries/LogBox/LogBoxNotificationContainer.js +4 -0
- package/Libraries/LogBox/UI/LogBoxInspector.js +8 -70
- package/Libraries/LogBox/UI/LogBoxInspectorBody.js +87 -0
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +6 -42
- package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +58 -0
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +5 -66
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +8 -52
- package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +76 -0
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +8 -5
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +8 -5
- package/Libraries/LogBox/UI/LogBoxNotification.js +13 -152
- package/Libraries/LogBox/UI/LogBoxNotificationCountBadge.js +63 -0
- package/Libraries/LogBox/UI/LogBoxNotificationDismissButton.js +67 -0
- package/Libraries/LogBox/UI/LogBoxNotificationMessage.js +57 -0
- package/Libraries/NativeComponent/BaseViewConfig.android.js +5 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +5 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +5 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +12 -5
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +3 -0
- package/Libraries/Network/XMLHttpRequest.js +5 -1
- package/Libraries/NewAppScreen/components/LearnMoreLinks.js +3 -3
- package/Libraries/Pressability/Pressability.js +3 -51
- package/Libraries/Pressability/Pressability.win32.js +3 -51
- package/Libraries/ReactNative/AppContainer-dev.js +3 -2
- package/Libraries/ReactNative/AppContainer-prod.js +2 -1
- package/Libraries/ReactNative/AppContainer.js +2 -0
- package/Libraries/ReactNative/AppRegistry.d.ts +7 -0
- package/Libraries/ReactNative/AppRegistry.js +10 -4
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -21
- package/Libraries/ReactNative/FabricUIManager.js +0 -51
- package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +1 -0
- package/Libraries/ReactNative/RendererImplementation.js +20 -2
- package/Libraries/ReactNative/UIManager.d.ts +0 -21
- package/Libraries/ReactNative/UIManagerProperties.js +0 -3
- package/Libraries/ReactNative/__mocks__/FabricUIManager.js +5 -341
- package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -8
- package/Libraries/ReactNative/renderApplication.js +3 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +15682 -27088
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +5082 -4381
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3480 -2571
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +15943 -27543
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5303 -4606
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3450 -2572
- package/Libraries/Renderer/shims/ReactFabric.js +2 -2
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
- package/Libraries/Renderer/shims/ReactNative.js +2 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.js +24 -3
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -2
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
- package/Libraries/Share/Share.d.ts +16 -10
- package/Libraries/Share/Share.js +14 -15
- package/Libraries/StyleSheet/StyleSheet.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheet.js +3 -10
- package/Libraries/StyleSheet/StyleSheet.win32.js +3 -10
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +21 -21
- package/Libraries/StyleSheet/StyleSheetTypes.js +24 -18
- package/Libraries/StyleSheet/flattenStyle.js +1 -0
- package/Libraries/StyleSheet/processFilter.js +132 -0
- package/Libraries/StyleSheet/processTransform.js +18 -3
- package/Libraries/Text/Text.js +151 -128
- package/Libraries/Text/Text.win32.js +163 -138
- package/Libraries/Text/TextNativeComponent.js +5 -4
- package/Libraries/Text/TextNativeComponent.win32.js +5 -4
- package/Libraries/Text/TextProps.js +6 -6
- package/Libraries/Text/TextProps.win32.js +6 -6
- package/Libraries/TurboModule/TurboModuleRegistry.js +2 -1
- package/Libraries/Types/CodegenTypes.js +3 -0
- package/Libraries/Utilities/{LoadingView.android.js → DevLoadingView.js} +33 -11
- package/Libraries/Utilities/Dimensions.js +1 -0
- package/Libraries/Utilities/Dimensions.win32.js +1 -0
- package/Libraries/Utilities/HMRClient.js +36 -8
- package/Libraries/Utilities/HMRClientProdShim.js +1 -0
- package/Libraries/Utilities/Platform.android.js +4 -4
- package/Libraries/Utilities/RCTLog.js +1 -0
- package/Libraries/Utilities/ReactNativeTestTools.js +12 -24
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +11 -6
- package/Libraries/__tests__/ButtonWin32-test.js +7 -6
- package/Libraries/promiseRejectionTrackingOptions.js +1 -0
- package/jest/mockComponent.js +7 -0
- package/jest/renderer.js +25 -14
- package/jest/setup.js +19 -13
- package/jest.config.js +2 -1
- package/overrides.json +30 -29
- package/package.json +27 -25
- package/rn-get-polyfills.js +1 -0
- package/src/private/core/composeStyles.js +27 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +93 -33
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +56 -0
- package/src/private/fusebox/setUpFuseboxReactDevToolsDispatcher.js +108 -0
- package/src/private/specs/modules/NativeBlobModule.js +4 -2
- package/src/private/specs/modules/NativeDevSettings.js +1 -0
- package/src/private/specs/modules/NativePushNotificationManagerIOS.js +0 -4
- package/src/private/specs/modules/NativeUIManager.js +0 -7
- package/src/private/webapis/dom/geometry/DOMRectReadOnly.js +24 -24
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +11 -14
- package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +2 -3
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +24 -54
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +5 -13
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +468 -0
- package/src/private/webapis/dom/nodes/specs/__mocks__/NativeDOMMock.js +413 -0
- package/src/private/webapis/dom/oldstylecollections/DOMRectList.js +4 -4
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +4 -4
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +5 -5
- package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +34 -0
- package/src/private/webapis/microtasks/specs/NativeMicrotasks.js +21 -0
- package/src/private/webapis/performance/EventCounts.js +1 -1
- package/src/private/webapis/performance/MemoryInfo.js +9 -9
- package/src/private/webapis/performance/Performance.js +10 -56
- package/src/private/webapis/performance/PerformanceObserver.js +30 -22
- package/src/private/webapis/performance/RawPerformanceEntry.js +2 -7
- package/src/private/webapis/performance/ReactNativeStartupTiming.js +18 -18
- package/src/private/webapis/performance/UserTiming.js +63 -0
- package/src/private/webapis/performance/{NativePerformance.js → specs/NativePerformance.js} +3 -2
- package/src/private/webapis/performance/{NativePerformanceObserver.js → specs/NativePerformanceObserver.js} +2 -2
- package/src/private/webapis/performance/{__mocks__ → specs/__mocks__}/NativePerformance.js +1 -1
- package/src/private/webapis/performance/{__mocks__ → specs/__mocks__}/NativePerformanceObserver.js +3 -4
- package/src-win/Libraries/Components/View/ViewPropTypes.d.ts +7 -49
- package/types/modules/globals.d.ts +4 -0
- package/Libraries/Components/ScrollView/ScrollView.win32.js +0 -1915
- package/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js +0 -13
- package/Libraries/Utilities/LoadingView.ios.js +0 -50
- package/Libraries/Utilities/LoadingView.js +0 -16
- package/jest/ReactNativeInternalFeatureFlagsMock.js +0 -13
- package/src/private/featureflags/NativeReactNativeFeatureFlags.js +0 -44
- package/src/private/featureflags/__tests__/ReactNativeFeatureFlags-test.js +0 -92
- package/src/private/specs/modules/NativeAnimationsDebugModule.js +0 -20
- package/src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js +0 -85
- package/src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js +0 -80
- package/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js +0 -161
- package/src/private/webapis/performance/__tests__/EventCounts-test.js +0 -116
- package/src/private/webapis/performance/__tests__/NativePerformanceMock-test.js +0 -82
- package/src/private/webapis/performance/__tests__/NativePerformanceObserverMock-test.js +0 -108
- package/src/private/webapis/performance/__tests__/Performance-test.js +0 -117
- package/src/private/webapis/performance/__tests__/PerformanceObserver-test.js +0 -208
|
@@ -1,82 +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
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const NativePerformanceMock = require('../__mocks__/NativePerformance').default;
|
|
12
|
-
const PerformanceObserver = require('../PerformanceObserver').default;
|
|
13
|
-
|
|
14
|
-
describe('NativePerformanceMock', () => {
|
|
15
|
-
jest.mock(
|
|
16
|
-
'../NativePerformanceObserver',
|
|
17
|
-
() => require('../__mocks__/NativePerformanceObserver').default,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
it('marks get reported', async () => {
|
|
21
|
-
let entries = [];
|
|
22
|
-
const observer = new PerformanceObserver((list, _observer) => {
|
|
23
|
-
entries = [...entries, ...list.getEntries()];
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
observer.observe({type: 'mark'});
|
|
27
|
-
|
|
28
|
-
NativePerformanceMock.mark('mark1', 0, 10);
|
|
29
|
-
NativePerformanceMock.mark('mark2', 5, 10);
|
|
30
|
-
NativePerformanceMock.mark('mark3', 10, 20);
|
|
31
|
-
|
|
32
|
-
await jest.runAllTicks();
|
|
33
|
-
expect(entries).toHaveLength(3);
|
|
34
|
-
expect(entries.map(e => e.name)).toStrictEqual(['mark1', 'mark2', 'mark3']);
|
|
35
|
-
expect(entries.map(e => e.startTime)).toStrictEqual([0, 5, 10]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('measures get reported', async () => {
|
|
39
|
-
let entries = [];
|
|
40
|
-
const observer = new PerformanceObserver((list, _observer) => {
|
|
41
|
-
entries = [...entries, ...list.getEntries()];
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
observer.observe({entryTypes: ['measure']});
|
|
45
|
-
|
|
46
|
-
NativePerformanceMock.mark('mark0', 0.0, 1.0);
|
|
47
|
-
NativePerformanceMock.mark('mark1', 1.0, 3.0);
|
|
48
|
-
NativePerformanceMock.mark('mark2', 2.0, 4.0);
|
|
49
|
-
|
|
50
|
-
NativePerformanceMock.measure('measure0', 0, 2);
|
|
51
|
-
NativePerformanceMock.measure('measure1', 0, 2, 4);
|
|
52
|
-
NativePerformanceMock.measure(
|
|
53
|
-
'measure2',
|
|
54
|
-
0,
|
|
55
|
-
0,
|
|
56
|
-
undefined,
|
|
57
|
-
'mark1',
|
|
58
|
-
'mark2',
|
|
59
|
-
);
|
|
60
|
-
NativePerformanceMock.measure('measure3', 0, 0, 5, 'mark1');
|
|
61
|
-
NativePerformanceMock.measure(
|
|
62
|
-
'measure4',
|
|
63
|
-
1.5,
|
|
64
|
-
0,
|
|
65
|
-
undefined,
|
|
66
|
-
undefined,
|
|
67
|
-
'mark2',
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
await jest.runAllTicks();
|
|
71
|
-
expect(entries).toHaveLength(5);
|
|
72
|
-
expect(entries.map(e => e.name)).toStrictEqual([
|
|
73
|
-
'measure0',
|
|
74
|
-
'measure1',
|
|
75
|
-
'measure2',
|
|
76
|
-
'measure3',
|
|
77
|
-
'measure4',
|
|
78
|
-
]);
|
|
79
|
-
expect(entries.map(e => e.startTime)).toStrictEqual([0, 0, 1, 1, 1.5]);
|
|
80
|
-
expect(entries.map(e => e.duration)).toStrictEqual([2, 4, 1, 5, 0.5]);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,108 +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
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import NativePerformanceObserverMock from '../__mocks__/NativePerformanceObserver';
|
|
12
|
-
import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
|
|
13
|
-
|
|
14
|
-
describe('NativePerformanceObserver', () => {
|
|
15
|
-
it('correctly starts and stops listening to entries in a nominal scenario', async () => {
|
|
16
|
-
NativePerformanceObserverMock.startReporting(
|
|
17
|
-
RawPerformanceEntryTypeValues.MARK,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
NativePerformanceObserverMock.logRawEntry({
|
|
21
|
-
name: 'mark1',
|
|
22
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
23
|
-
startTime: 0,
|
|
24
|
-
duration: 10,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
NativePerformanceObserverMock.logRawEntry({
|
|
28
|
-
name: 'mark2',
|
|
29
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
30
|
-
startTime: 0,
|
|
31
|
-
duration: 20,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
NativePerformanceObserverMock.logRawEntry({
|
|
35
|
-
name: 'event1',
|
|
36
|
-
entryType: RawPerformanceEntryTypeValues.EVENT,
|
|
37
|
-
startTime: 0,
|
|
38
|
-
duration: 20,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const entriesResult = NativePerformanceObserverMock.popPendingEntries();
|
|
42
|
-
expect(entriesResult).not.toBe(undefined);
|
|
43
|
-
const entries = entriesResult.entries;
|
|
44
|
-
|
|
45
|
-
expect(entries.length).toBe(2);
|
|
46
|
-
expect(entries[0].name).toBe('mark1');
|
|
47
|
-
expect(entries[1].name).toBe('mark2');
|
|
48
|
-
|
|
49
|
-
const entriesResult1 = NativePerformanceObserverMock.popPendingEntries();
|
|
50
|
-
expect(entriesResult1).not.toBe(undefined);
|
|
51
|
-
const entries1 = entriesResult1.entries;
|
|
52
|
-
expect(entries1.length).toBe(0);
|
|
53
|
-
|
|
54
|
-
NativePerformanceObserverMock.stopReporting('mark');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('correctly clears/gets entries', async () => {
|
|
58
|
-
NativePerformanceObserverMock.logRawEntry({
|
|
59
|
-
name: 'mark1',
|
|
60
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
61
|
-
startTime: 0,
|
|
62
|
-
duration: 0,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
NativePerformanceObserverMock.logRawEntry({
|
|
66
|
-
name: 'event1',
|
|
67
|
-
entryType: RawPerformanceEntryTypeValues.EVENT,
|
|
68
|
-
startTime: 0,
|
|
69
|
-
duration: 0,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
NativePerformanceObserverMock.clearEntries(
|
|
73
|
-
RawPerformanceEntryTypeValues.UNDEFINED,
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
expect(NativePerformanceObserverMock.getEntries()).toStrictEqual([]);
|
|
77
|
-
|
|
78
|
-
NativePerformanceObserverMock.logRawEntry({
|
|
79
|
-
name: 'entry1',
|
|
80
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
81
|
-
startTime: 0,
|
|
82
|
-
duration: 0,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
NativePerformanceObserverMock.logRawEntry({
|
|
86
|
-
name: 'entry2',
|
|
87
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
88
|
-
startTime: 0,
|
|
89
|
-
duration: 0,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
NativePerformanceObserverMock.logRawEntry({
|
|
93
|
-
name: 'entry1',
|
|
94
|
-
entryType: RawPerformanceEntryTypeValues.EVENT,
|
|
95
|
-
startTime: 0,
|
|
96
|
-
duration: 0,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
NativePerformanceObserverMock.clearEntries(
|
|
100
|
-
RawPerformanceEntryTypeValues.UNDEFINED,
|
|
101
|
-
'entry1',
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
expect(
|
|
105
|
-
NativePerformanceObserverMock.getEntries().map(e => e.name),
|
|
106
|
-
).toStrictEqual(['entry2']);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,117 +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
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const Performance = require('../Performance').default;
|
|
12
|
-
|
|
13
|
-
jest.mock(
|
|
14
|
-
'../NativePerformance',
|
|
15
|
-
() => require('../__mocks__/NativePerformance').default,
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
jest.mock(
|
|
19
|
-
'../NativePerformanceObserver',
|
|
20
|
-
() => require('../__mocks__/NativePerformanceObserver').default,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
describe('Performance', () => {
|
|
24
|
-
it('clearEntries removes correct entry types', async () => {
|
|
25
|
-
const performance = new Performance();
|
|
26
|
-
performance.mark('entry1', 0, 0);
|
|
27
|
-
performance.mark('mark2', 0, 0);
|
|
28
|
-
|
|
29
|
-
performance.measure('entry1', {start: 0, duration: 0});
|
|
30
|
-
performance.measure('measure2', {start: 0, duration: 0});
|
|
31
|
-
|
|
32
|
-
performance.clearMarks();
|
|
33
|
-
|
|
34
|
-
expect(performance.getEntries().map(e => e.name)).toStrictEqual([
|
|
35
|
-
'entry1',
|
|
36
|
-
'measure2',
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
performance.mark('entry2', 0, 0);
|
|
40
|
-
performance.mark('mark3', 0, 0);
|
|
41
|
-
|
|
42
|
-
performance.clearMeasures();
|
|
43
|
-
|
|
44
|
-
expect(performance.getEntries().map(e => e.name)).toStrictEqual([
|
|
45
|
-
'entry2',
|
|
46
|
-
'mark3',
|
|
47
|
-
]);
|
|
48
|
-
|
|
49
|
-
performance.clearMarks();
|
|
50
|
-
|
|
51
|
-
expect(performance.getEntries().map(e => e.name)).toStrictEqual([]);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('getEntries only works with allowed entry types', async () => {
|
|
55
|
-
const performance = new Performance();
|
|
56
|
-
performance.clearMarks();
|
|
57
|
-
performance.clearMeasures();
|
|
58
|
-
|
|
59
|
-
performance.mark('entry1', 0, 0);
|
|
60
|
-
performance.mark('mark2', 0, 0);
|
|
61
|
-
|
|
62
|
-
jest.spyOn(console, 'warn').mockImplementation();
|
|
63
|
-
|
|
64
|
-
performance.getEntriesByType('mark');
|
|
65
|
-
expect(console.warn).not.toHaveBeenCalled();
|
|
66
|
-
|
|
67
|
-
performance.getEntriesByType('measure');
|
|
68
|
-
expect(console.warn).not.toHaveBeenCalled();
|
|
69
|
-
|
|
70
|
-
performance.getEntriesByName('entry1');
|
|
71
|
-
expect(console.warn).not.toHaveBeenCalled();
|
|
72
|
-
|
|
73
|
-
performance.getEntriesByName('entry1', 'event');
|
|
74
|
-
expect(console.warn).toHaveBeenCalled();
|
|
75
|
-
|
|
76
|
-
performance.getEntriesByName('entry1', 'mark');
|
|
77
|
-
expect(console.warn).toHaveBeenCalled();
|
|
78
|
-
|
|
79
|
-
performance.getEntriesByType('event');
|
|
80
|
-
expect(console.warn).toHaveBeenCalled();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('getEntries works with marks and measures', async () => {
|
|
84
|
-
const performance = new Performance();
|
|
85
|
-
performance.clearMarks();
|
|
86
|
-
performance.clearMeasures();
|
|
87
|
-
|
|
88
|
-
performance.mark('entry1', 0, 0);
|
|
89
|
-
performance.mark('mark2', 0, 0);
|
|
90
|
-
|
|
91
|
-
performance.measure('entry1', {start: 0, duration: 0});
|
|
92
|
-
performance.measure('measure2', {start: 0, duration: 0});
|
|
93
|
-
|
|
94
|
-
expect(performance.getEntries().map(e => e.name)).toStrictEqual([
|
|
95
|
-
'entry1',
|
|
96
|
-
'mark2',
|
|
97
|
-
'entry1',
|
|
98
|
-
'measure2',
|
|
99
|
-
]);
|
|
100
|
-
|
|
101
|
-
expect(performance.getEntriesByType('mark').map(e => e.name)).toStrictEqual(
|
|
102
|
-
['entry1', 'mark2'],
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
expect(
|
|
106
|
-
performance.getEntriesByType('measure').map(e => e.name),
|
|
107
|
-
).toStrictEqual(['entry1', 'measure2']);
|
|
108
|
-
|
|
109
|
-
expect(
|
|
110
|
-
performance.getEntriesByName('entry1').map(e => e.entryType),
|
|
111
|
-
).toStrictEqual(['mark', 'measure']);
|
|
112
|
-
|
|
113
|
-
expect(
|
|
114
|
-
performance.getEntriesByName('entry1', 'measure').map(e => e.entryType),
|
|
115
|
-
).toStrictEqual(['measure']);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
@@ -1,208 +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
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
|
|
12
|
-
|
|
13
|
-
// NOTE: Jest mocks of transitive dependencies don't appear to work with
|
|
14
|
-
// ES6 module imports, therefore forced to use commonjs style imports here.
|
|
15
|
-
const NativePerformanceObserver = require('../NativePerformanceObserver');
|
|
16
|
-
const PerformanceObserver = require('../PerformanceObserver').default;
|
|
17
|
-
|
|
18
|
-
jest.mock(
|
|
19
|
-
'../NativePerformanceObserver',
|
|
20
|
-
() => require('../__mocks__/NativePerformanceObserver').default,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
describe('PerformanceObserver', () => {
|
|
24
|
-
it('can be mocked by a reference NativePerformanceObserver implementation', async () => {
|
|
25
|
-
expect(NativePerformanceObserver).not.toBe(undefined);
|
|
26
|
-
|
|
27
|
-
let totalEntries = 0;
|
|
28
|
-
const observer = new PerformanceObserver((list, _observer) => {
|
|
29
|
-
expect(_observer).toBe(observer);
|
|
30
|
-
const entries = list.getEntries();
|
|
31
|
-
expect(entries).toHaveLength(1);
|
|
32
|
-
const entry = entries[0];
|
|
33
|
-
expect(entry.name).toBe('mark1');
|
|
34
|
-
expect(entry.entryType).toBe('mark');
|
|
35
|
-
totalEntries += entries.length;
|
|
36
|
-
});
|
|
37
|
-
expect(() => observer.observe({entryTypes: ['mark']})).not.toThrow();
|
|
38
|
-
|
|
39
|
-
NativePerformanceObserver.logRawEntry({
|
|
40
|
-
name: 'mark1',
|
|
41
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
42
|
-
startTime: 0,
|
|
43
|
-
duration: 0,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
await jest.runAllTicks();
|
|
47
|
-
expect(totalEntries).toBe(1);
|
|
48
|
-
observer.disconnect();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('prevents durationThreshold to be used together with entryTypes', async () => {
|
|
52
|
-
const observer = new PerformanceObserver((list, _observer) => {});
|
|
53
|
-
|
|
54
|
-
expect(() =>
|
|
55
|
-
observer.observe({entryTypes: ['mark'], durationThreshold: 100}),
|
|
56
|
-
).toThrow();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('handles durationThreshold argument as expected', async () => {
|
|
60
|
-
let entries = [];
|
|
61
|
-
const observer = new PerformanceObserver((list, _observer) => {
|
|
62
|
-
entries = [...entries, ...list.getEntries()];
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
observer.observe({type: 'mark', durationThreshold: 100});
|
|
66
|
-
|
|
67
|
-
NativePerformanceObserver.logRawEntry({
|
|
68
|
-
name: 'mark1',
|
|
69
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
70
|
-
startTime: 0,
|
|
71
|
-
duration: 200,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
NativePerformanceObserver.logRawEntry({
|
|
75
|
-
name: 'mark2',
|
|
76
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
77
|
-
startTime: 0,
|
|
78
|
-
duration: 20,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
NativePerformanceObserver.logRawEntry({
|
|
82
|
-
name: 'mark3',
|
|
83
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
84
|
-
startTime: 0,
|
|
85
|
-
duration: 100,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
NativePerformanceObserver.logRawEntry({
|
|
89
|
-
name: 'mark4',
|
|
90
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
91
|
-
startTime: 0,
|
|
92
|
-
duration: 500,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
await jest.runAllTicks();
|
|
96
|
-
expect(entries).toHaveLength(3);
|
|
97
|
-
expect(entries.map(e => e.name)).toStrictEqual(['mark1', 'mark3', 'mark4']);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('correctly works with multiple PerformanceObservers with durationThreshold', async () => {
|
|
101
|
-
let entries1 = [];
|
|
102
|
-
const observer1 = new PerformanceObserver((list, _observer) => {
|
|
103
|
-
entries1 = [...entries1, ...list.getEntries()];
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
let entries2 = [];
|
|
107
|
-
const observer2 = new PerformanceObserver((list, _observer) => {
|
|
108
|
-
entries2 = [...entries2, ...list.getEntries()];
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
let entries3 = [];
|
|
112
|
-
const observer3 = new PerformanceObserver((list, _observer) => {
|
|
113
|
-
entries3 = [...entries3, ...list.getEntries()];
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
let entries4 = [];
|
|
117
|
-
const observer4 = new PerformanceObserver((list, _observer) => {
|
|
118
|
-
entries4 = [...entries4, ...list.getEntries()];
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
observer2.observe({type: 'mark', durationThreshold: 200});
|
|
122
|
-
observer1.observe({type: 'mark', durationThreshold: 100});
|
|
123
|
-
observer3.observe({type: 'mark', durationThreshold: 300});
|
|
124
|
-
observer3.observe({type: 'measure', durationThreshold: 500});
|
|
125
|
-
observer4.observe({entryTypes: ['mark', 'measure']});
|
|
126
|
-
|
|
127
|
-
NativePerformanceObserver.logRawEntry({
|
|
128
|
-
name: 'mark1',
|
|
129
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
130
|
-
startTime: 0,
|
|
131
|
-
duration: 200,
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
NativePerformanceObserver.logRawEntry({
|
|
135
|
-
name: 'mark2',
|
|
136
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
137
|
-
startTime: 0,
|
|
138
|
-
duration: 20,
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
NativePerformanceObserver.logRawEntry({
|
|
142
|
-
name: 'mark3',
|
|
143
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
144
|
-
startTime: 0,
|
|
145
|
-
duration: 100,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
NativePerformanceObserver.logRawEntry({
|
|
149
|
-
name: 'mark4',
|
|
150
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
151
|
-
startTime: 0,
|
|
152
|
-
duration: 500,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
await jest.runAllTicks();
|
|
156
|
-
observer1.disconnect();
|
|
157
|
-
|
|
158
|
-
NativePerformanceObserver.logRawEntry({
|
|
159
|
-
name: 'mark5',
|
|
160
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
161
|
-
startTime: 0,
|
|
162
|
-
duration: 200,
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
NativePerformanceObserver.logRawEntry({
|
|
166
|
-
name: 'mark6',
|
|
167
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
168
|
-
startTime: 0,
|
|
169
|
-
duration: 300,
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
await jest.runAllTicks();
|
|
173
|
-
observer3.disconnect();
|
|
174
|
-
|
|
175
|
-
NativePerformanceObserver.logRawEntry({
|
|
176
|
-
name: 'mark7',
|
|
177
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
178
|
-
startTime: 0,
|
|
179
|
-
duration: 200,
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
await jest.runAllTicks();
|
|
183
|
-
observer4.disconnect();
|
|
184
|
-
|
|
185
|
-
expect(entries1.map(e => e.name)).toStrictEqual([
|
|
186
|
-
'mark1',
|
|
187
|
-
'mark3',
|
|
188
|
-
'mark4',
|
|
189
|
-
]);
|
|
190
|
-
expect(entries2.map(e => e.name)).toStrictEqual([
|
|
191
|
-
'mark1',
|
|
192
|
-
'mark4',
|
|
193
|
-
'mark5',
|
|
194
|
-
'mark6',
|
|
195
|
-
'mark7',
|
|
196
|
-
]);
|
|
197
|
-
expect(entries3.map(e => e.name)).toStrictEqual(['mark4', 'mark6']);
|
|
198
|
-
expect(entries4.map(e => e.name)).toStrictEqual([
|
|
199
|
-
'mark1',
|
|
200
|
-
'mark2',
|
|
201
|
-
'mark3',
|
|
202
|
-
'mark4',
|
|
203
|
-
'mark5',
|
|
204
|
-
'mark6',
|
|
205
|
-
'mark7',
|
|
206
|
-
]);
|
|
207
|
-
});
|
|
208
|
-
});
|