@office-iss/react-native-win32 0.0.0-canary.292 → 0.0.0-canary.294
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 +8 -1
- package/CHANGELOG.json +58 -1
- package/CHANGELOG.md +22 -4
- package/IntegrationTests/ImageCachePolicyTest.js +1 -1
- package/IntegrationTests/LayoutEventsTest.js +1 -4
- package/Libraries/Animated/AnimatedExports.js.flow +126 -0
- package/Libraries/Animated/AnimatedImplementation.js +0 -121
- package/Libraries/Animated/animations/Animation.js +8 -4
- package/Libraries/Animated/nodes/AnimatedNode.js +2 -2
- package/Libraries/Animated/nodes/AnimatedValue.js +8 -4
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/BlobManager.js +1 -0
- package/Libraries/Blob/URL.js +13 -1
- package/Libraries/Components/Pressable/Pressable.js +4 -1
- package/Libraries/Components/Pressable/Pressable.win32.js +4 -1
- package/Libraries/Components/ScrollView/ScrollView.d.ts +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +1 -0
- package/Libraries/Components/Switch/Switch.js +7 -3
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +1 -0
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.flow.js +25 -0
- package/Libraries/Components/TextInput/TextInput.flow.win32.js +25 -1
- package/Libraries/Components/TextInput/TextInput.js +3 -0
- package/Libraries/Components/TextInput/TextInput.win32.js +2 -0
- package/Libraries/Components/View/View.js +18 -21
- package/Libraries/Components/View/View.win32.js +21 -24
- package/Libraries/Components/View/ViewAccessibility.js +16 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/setUpReactDevTools.js +5 -5
- package/Libraries/Image/ImageProps.js +2 -3
- package/Libraries/Image/ImageSource.js +3 -1
- package/Libraries/Image/ImageSourceUtils.js +4 -2
- package/Libraries/Lists/FlatList.d.ts +2 -2
- package/Libraries/Lists/SectionListModern.js +1 -2
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +1 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +1 -0
- package/Libraries/NativeModules/specs/NativeDevMenu.js +2 -2
- package/Libraries/ReactNative/AppContainer-dev.js +3 -2
- package/Libraries/ReactNative/FabricUIManager.js +10 -0
- package/Libraries/ReactNative/RendererImplementation.js +6 -5
- package/Libraries/ReactNative/getNativeComponentAttributes.js +1 -0
- package/Libraries/ReactNative/renderApplication.js +9 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow +51 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +4840 -4748
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +4947 -4829
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3998 -3888
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5005 -4948
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +2744 -2652
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5020 -4933
- package/Libraries/Settings/Settings.ios.js +1 -0
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +47 -3
- package/Libraries/StyleSheet/processBackgroundImage.js +670 -214
- package/Libraries/Text/TextNativeComponent.js +0 -4
- package/Libraries/Text/TextNativeComponent.win32.js +0 -4
- package/index.js +1 -288
- package/index.win32.js +3 -292
- package/overrides.json +14 -14
- package/package.json +20 -20
- package/src/private/{devmenu → devsupport/devmenu}/DevMenu.js +1 -1
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/BorderBox.js +2 -2
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/BoxInspector.js +5 -4
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementBox.js +7 -5
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementProperties.js +10 -9
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/Inspector.js +13 -11
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorOverlay.js +4 -3
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorPanel.js +8 -7
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/NetworkOverlay.js +9 -8
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ReactDevToolsOverlay.js +7 -7
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/StyleInspector.js +6 -5
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/XHRInterceptor.js +2 -2
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/getInspectorDataForViewAtPoint.js +2 -2
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/resolveBoxStyle.js +1 -1
- package/src/private/{inspector → devsupport/devmenu/perfmonitor}/PerformanceOverlay.js +5 -4
- package/src/private/{specs_DEPRECATED/modules → devsupport/devmenu/specs}/NativeDevMenu.js +2 -2
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.android.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.ios.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.win32.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/setUpFuseboxReactDevToolsDispatcher.js +1 -1
- package/src/private/{fusebox → devsupport/rndevtools}/specs/NativeReactDevToolsRuntimeSettingsModule.js +2 -2
- package/src/private/{specs_DEPRECATED/modules → devsupport/rndevtools/specs}/NativeReactDevToolsSettingsManager.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +48 -18
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +11 -5
- package/src/private/renderer/errorhandling/ErrorHandlers.js +2 -2
- package/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js +3 -0
- package/src/private/types/HostInstance.js +2 -2
- package/src/private/webapis/performance/PerformanceEntry.js +6 -1
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -0
- package/src/private/webapis/performance/specs/NativePerformance.js +10 -1
- package/types/index.d.ts +1 -2
- package/types/public/ReactNativeTypes.d.ts +2 -2
- package/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js +0 -38
- package/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js +0 -22
- package/Libraries/Blob/__mocks__/BlobModule.js +0 -16
- package/Libraries/Blob/__mocks__/FileReaderModule.js +0 -20
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +0 -32
- package/Libraries/Core/__mocks__/ErrorUtils.js +0 -33
- package/Libraries/Core/__mocks__/NativeExceptionsManager.js +0 -19
- package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +0 -49
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +0 -118
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +0 -134
- package/Libraries/NewAppScreen/components/Colors.js +0 -19
- package/Libraries/NewAppScreen/components/DebugInstructions.js +0 -39
- package/Libraries/NewAppScreen/components/Header.js +0 -75
- package/Libraries/NewAppScreen/components/HermesBadge.js +0 -51
- package/Libraries/NewAppScreen/components/LearnMoreLinks.js +0 -146
- package/Libraries/NewAppScreen/components/ReloadInstructions.js +0 -37
- package/Libraries/NewAppScreen/components/logo.png +0 -0
- package/Libraries/NewAppScreen/index.js +0 -25
- package/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +0 -58
- package/Libraries/Utilities/__mocks__/BackHandler.js +0 -45
- package/Libraries/Utilities/__mocks__/GlobalPerformanceLogger.js +0 -16
- package/Libraries/Utilities/__mocks__/PixelRatio.js +0 -25
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +0 -30
- package/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js +0 -81
- package/jest/__tests__/setup-test.js +0 -18
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +0 -267
- package/types/modules/LaunchScreen.d.ts +0 -26
- /package/src/private/{devmenu → devsupport/devmenu}/DevMenu.d.ts +0 -0
- /package/src/private/{debugging → devsupport/rndevtools}/FuseboxSessionObserver.js +0 -0
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
import type {ImageStyleProp, TextStyleProp} from '../StyleSheet';
|
|
14
|
-
|
|
15
|
-
const StyleSheet = require('../StyleSheet').default;
|
|
16
|
-
const imageStyle = {tintColor: 'rgb(0, 0, 0)'};
|
|
17
|
-
const textStyle = {color: 'rgb(0, 0, 0)'};
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
testGoodCompose() {
|
|
21
|
-
(StyleSheet.compose(imageStyle, imageStyle): ImageStyleProp);
|
|
22
|
-
|
|
23
|
-
(StyleSheet.compose(textStyle, textStyle): TextStyleProp);
|
|
24
|
-
|
|
25
|
-
(StyleSheet.compose(null, null): TextStyleProp);
|
|
26
|
-
|
|
27
|
-
(StyleSheet.compose(textStyle, null): TextStyleProp);
|
|
28
|
-
|
|
29
|
-
(StyleSheet.compose(
|
|
30
|
-
textStyle,
|
|
31
|
-
Math.random() < 0.5 ? textStyle : null,
|
|
32
|
-
): TextStyleProp);
|
|
33
|
-
|
|
34
|
-
(StyleSheet.compose([textStyle], null): TextStyleProp);
|
|
35
|
-
|
|
36
|
-
(StyleSheet.compose([textStyle], null): TextStyleProp);
|
|
37
|
-
|
|
38
|
-
(StyleSheet.compose([textStyle], [textStyle]): TextStyleProp);
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
testBadCompose() {
|
|
42
|
-
// $FlowExpectedError - Incompatible type.
|
|
43
|
-
(StyleSheet.compose(textStyle, textStyle): ImageStyleProp);
|
|
44
|
-
|
|
45
|
-
// $FlowExpectedError - Incompatible type.
|
|
46
|
-
(StyleSheet.compose(
|
|
47
|
-
// $FlowExpectedError - Incompatible type.
|
|
48
|
-
[textStyle],
|
|
49
|
-
null,
|
|
50
|
-
): ImageStyleProp);
|
|
51
|
-
|
|
52
|
-
// $FlowExpectedError - Incompatible type.
|
|
53
|
-
(StyleSheet.compose(
|
|
54
|
-
Math.random() < 0.5 ? textStyle : null,
|
|
55
|
-
null,
|
|
56
|
-
): ImageStyleProp);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
@@ -1,45 +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
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
const _backPressSubscriptions = new Set();
|
|
13
|
-
|
|
14
|
-
const BackHandler = {
|
|
15
|
-
exitApp: jest.fn(),
|
|
16
|
-
|
|
17
|
-
addEventListener: function (
|
|
18
|
-
eventName: BackPressEventName,
|
|
19
|
-
handler: () => ?boolean,
|
|
20
|
-
): {remove: () => void} {
|
|
21
|
-
_backPressSubscriptions.add(handler);
|
|
22
|
-
return {
|
|
23
|
-
remove: () => {
|
|
24
|
-
_backPressSubscriptions.delete(handler);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
mockPressBack: function () {
|
|
30
|
-
let invokeDefault = true;
|
|
31
|
-
const subscriptions = [..._backPressSubscriptions].reverse();
|
|
32
|
-
for (let i = 0; i < subscriptions.length; ++i) {
|
|
33
|
-
if (subscriptions[i]()) {
|
|
34
|
-
invokeDefault = false;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (invokeDefault) {
|
|
40
|
-
BackHandler.exitApp();
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
module.exports = BackHandler;
|
|
@@ -1,16 +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
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
const GlobalPerformanceLogger = jest
|
|
13
|
-
.unmock('../createPerformanceLogger')
|
|
14
|
-
.genMockFromModule('../GlobalPerformanceLogger').default;
|
|
15
|
-
|
|
16
|
-
export default GlobalPerformanceLogger;
|
|
@@ -1,25 +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
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
const PixelRatio = {
|
|
13
|
-
get: jest.fn().mockReturnValue(2),
|
|
14
|
-
getFontScale: jest.fn(() => PixelRatio.get()),
|
|
15
|
-
getPixelSizeForLayoutSize: jest.fn(layoutSize =>
|
|
16
|
-
Math.round(layoutSize * PixelRatio.get()),
|
|
17
|
-
),
|
|
18
|
-
roundToNearestPixel: jest.fn(layoutSize => {
|
|
19
|
-
const ratio = PixelRatio.get();
|
|
20
|
-
return Math.round(layoutSize * ratio) / ratio;
|
|
21
|
-
}),
|
|
22
|
-
startDetecting: jest.fn(),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default PixelRatio;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {HostComponent} from '../../src/private/types/HostComponent';
|
|
12
|
-
import type {HostInstance} from '../../src/private/types/HostInstance';
|
|
13
|
-
|
|
14
|
-
import * as React from 'react';
|
|
15
|
-
|
|
16
|
-
function takesHostComponentInstance(instance: HostInstance | null): void {}
|
|
17
|
-
|
|
18
|
-
const MyHostComponent = (('Host': any): HostComponent<{...}>);
|
|
19
|
-
|
|
20
|
-
<MyHostComponent
|
|
21
|
-
ref={hostComponentRef => {
|
|
22
|
-
takesHostComponentInstance(hostComponentRef);
|
|
23
|
-
|
|
24
|
-
if (hostComponentRef == null) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
hostComponentRef.measureLayout(hostComponentRef, () => {});
|
|
29
|
-
}}
|
|
30
|
-
/>;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import EventEmitter from '../EventEmitter';
|
|
12
|
-
|
|
13
|
-
const emitter = new EventEmitter<{
|
|
14
|
-
void: [],
|
|
15
|
-
string: [string],
|
|
16
|
-
strings: [string, string],
|
|
17
|
-
error: [Error],
|
|
18
|
-
}>();
|
|
19
|
-
|
|
20
|
-
const subscription = emitter.addListener('void', unknown => {
|
|
21
|
-
(unknown: void);
|
|
22
|
-
});
|
|
23
|
-
subscription.remove();
|
|
24
|
-
|
|
25
|
-
emitter.addListener('string', foo => {
|
|
26
|
-
(foo: string);
|
|
27
|
-
});
|
|
28
|
-
emitter.addListener('strings', (foo, bar) => {
|
|
29
|
-
(foo: string);
|
|
30
|
-
(bar: string);
|
|
31
|
-
});
|
|
32
|
-
emitter.addListener('error', error => {
|
|
33
|
-
(error: Error);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
emitter.emit('void');
|
|
37
|
-
emitter.emit('string', 'foo');
|
|
38
|
-
emitter.emit('strings', 'foo', 'bar');
|
|
39
|
-
emitter.emit('error', new Error());
|
|
40
|
-
|
|
41
|
-
emitter.removeAllListeners('void');
|
|
42
|
-
emitter.removeAllListeners('string');
|
|
43
|
-
emitter.removeAllListeners('strings');
|
|
44
|
-
emitter.removeAllListeners('error');
|
|
45
|
-
emitter.removeAllListeners();
|
|
46
|
-
|
|
47
|
-
emitter.listenerCount('void');
|
|
48
|
-
emitter.listenerCount('string');
|
|
49
|
-
emitter.listenerCount('strings');
|
|
50
|
-
emitter.listenerCount('error');
|
|
51
|
-
|
|
52
|
-
// $FlowExpectedError[prop-missing]
|
|
53
|
-
emitter.addListener('does-not-exist', () => {
|
|
54
|
-
// ...
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// $FlowExpectedError[prop-missing]
|
|
58
|
-
subscription.context;
|
|
59
|
-
// $FlowExpectedError[prop-missing]
|
|
60
|
-
subscription.listener;
|
|
61
|
-
// $FlowExpectedError[prop-missing]
|
|
62
|
-
subscription.once;
|
|
63
|
-
|
|
64
|
-
// $FlowExpectedError[invalid-tuple-arity]
|
|
65
|
-
emitter.emit('void', undefined);
|
|
66
|
-
// $FlowExpectedError[incompatible-call]
|
|
67
|
-
emitter.emit('string', 123);
|
|
68
|
-
// $FlowExpectedError[invalid-tuple-arity]
|
|
69
|
-
emitter.emit('strings', 'foo');
|
|
70
|
-
// $FlowExpectedError[invalid-tuple-arity]
|
|
71
|
-
emitter.emit('strings', 'foo', 'bar', 'baz');
|
|
72
|
-
// $FlowExpectedError[invalid-tuple-arity]
|
|
73
|
-
emitter.emit('error');
|
|
74
|
-
// $FlowExpectedError[prop-missing]
|
|
75
|
-
emitter.emit('does-not-exist');
|
|
76
|
-
|
|
77
|
-
// $FlowExpectedError[prop-missing]
|
|
78
|
-
emitter.removeAllListeners('does-not-exist');
|
|
79
|
-
|
|
80
|
-
// $FlowExpectedError[prop-missing]
|
|
81
|
-
emitter.listenerCount('does-not-exist');
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import NativeExceptionsManager from '../../Libraries/Core/NativeExceptionsManager';
|
|
13
|
-
|
|
14
|
-
test('NativeExceptionsManager is a mock', () => {
|
|
15
|
-
expect(jest.isMockFunction(NativeExceptionsManager.reportException)).toBe(
|
|
16
|
-
true,
|
|
17
|
-
);
|
|
18
|
-
});
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
NativeBatchedObserverCallback,
|
|
13
|
-
NativeMemoryInfo,
|
|
14
|
-
NativePerformanceMarkResult,
|
|
15
|
-
NativePerformanceMeasureResult,
|
|
16
|
-
OpaqueNativeObserverHandle,
|
|
17
|
-
PerformanceObserverInit,
|
|
18
|
-
RawPerformanceEntry,
|
|
19
|
-
RawPerformanceEntryType,
|
|
20
|
-
ReactNativeStartupTiming,
|
|
21
|
-
} from '../NativePerformance';
|
|
22
|
-
import typeof NativePerformance from '../NativePerformance';
|
|
23
|
-
|
|
24
|
-
import {RawPerformanceEntryTypeValues} from '../../internals/RawPerformanceEntry';
|
|
25
|
-
|
|
26
|
-
type MockObserver = {
|
|
27
|
-
handleEntry: (entry: RawPerformanceEntry) => void,
|
|
28
|
-
callback: NativeBatchedObserverCallback,
|
|
29
|
-
didScheduleFlushBuffer: boolean,
|
|
30
|
-
entries: Array<RawPerformanceEntry>,
|
|
31
|
-
options: PerformanceObserverInit,
|
|
32
|
-
droppedEntriesCount: number,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const eventCounts: Map<string, number> = new Map();
|
|
36
|
-
const observers: Set<MockObserver> = new Set();
|
|
37
|
-
const marks: Map<string, number> = new Map();
|
|
38
|
-
let entries: Array<RawPerformanceEntry> = [];
|
|
39
|
-
|
|
40
|
-
function getMockObserver(
|
|
41
|
-
opaqueNativeObserverHandle: OpaqueNativeObserverHandle,
|
|
42
|
-
): MockObserver {
|
|
43
|
-
return opaqueNativeObserverHandle as $FlowFixMe as MockObserver;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function createMockObserver(callback: NativeBatchedObserverCallback) {
|
|
47
|
-
const observer: MockObserver = {
|
|
48
|
-
callback,
|
|
49
|
-
didScheduleFlushBuffer: false,
|
|
50
|
-
entries: [],
|
|
51
|
-
options: {},
|
|
52
|
-
droppedEntriesCount: 0,
|
|
53
|
-
handleEntry: (entry: RawPerformanceEntry) => {
|
|
54
|
-
if (
|
|
55
|
-
observer.options.type !== entry.entryType &&
|
|
56
|
-
!observer.options.entryTypes?.includes(entry.entryType)
|
|
57
|
-
) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
entry.entryType === RawPerformanceEntryTypeValues.EVENT &&
|
|
63
|
-
entry.duration < (observer.options?.durationThreshold ?? 0)
|
|
64
|
-
) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
observer.entries.push(entry);
|
|
69
|
-
|
|
70
|
-
if (!observer.didScheduleFlushBuffer) {
|
|
71
|
-
observer.didScheduleFlushBuffer = true;
|
|
72
|
-
// $FlowFixMe[incompatible-call]
|
|
73
|
-
global.queueMicrotask(() => {
|
|
74
|
-
observer.didScheduleFlushBuffer = false;
|
|
75
|
-
// We want to emulate the way it's done in native (i.e. async/batched)
|
|
76
|
-
observer.callback();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
return observer;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function reportEntry(entry: RawPerformanceEntry) {
|
|
86
|
-
entries.push(entry);
|
|
87
|
-
|
|
88
|
-
switch (entry.entryType) {
|
|
89
|
-
case RawPerformanceEntryTypeValues.MARK:
|
|
90
|
-
marks.set(entry.name, entry.startTime);
|
|
91
|
-
break;
|
|
92
|
-
case RawPerformanceEntryTypeValues.MEASURE:
|
|
93
|
-
break;
|
|
94
|
-
case RawPerformanceEntryTypeValues.EVENT:
|
|
95
|
-
eventCounts.set(entry.name, (eventCounts.get(entry.name) ?? 0) + 1);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
for (const observer of observers) {
|
|
100
|
-
observer.handleEntry(entry);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let currentTime: number = 12;
|
|
105
|
-
|
|
106
|
-
const NativePerformanceMock = {
|
|
107
|
-
setCurrentTime: (time: number): void => {
|
|
108
|
-
currentTime = time;
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
now: (): number => currentTime,
|
|
112
|
-
|
|
113
|
-
markWithResult: (
|
|
114
|
-
name: string,
|
|
115
|
-
startTime?: number,
|
|
116
|
-
): NativePerformanceMarkResult => {
|
|
117
|
-
const computedStartTime = startTime ?? performance.now();
|
|
118
|
-
|
|
119
|
-
marks.set(name, computedStartTime);
|
|
120
|
-
reportEntry({
|
|
121
|
-
entryType: RawPerformanceEntryTypeValues.MARK,
|
|
122
|
-
name,
|
|
123
|
-
startTime: computedStartTime,
|
|
124
|
-
duration: 0,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
return computedStartTime;
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
measureWithResult: (
|
|
131
|
-
name: string,
|
|
132
|
-
startTime: number,
|
|
133
|
-
endTime: number,
|
|
134
|
-
duration?: number,
|
|
135
|
-
startMark?: string,
|
|
136
|
-
endMark?: string,
|
|
137
|
-
): NativePerformanceMeasureResult => {
|
|
138
|
-
const start = startMark != null ? marks.get(startMark) : startTime;
|
|
139
|
-
const end = endMark != null ? marks.get(endMark) : endTime;
|
|
140
|
-
|
|
141
|
-
if (start === undefined) {
|
|
142
|
-
throw new Error('startMark does not exist');
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (end === undefined) {
|
|
146
|
-
throw new Error('endMark does not exist');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const computedDuration = duration ?? end - start;
|
|
150
|
-
reportEntry({
|
|
151
|
-
entryType: RawPerformanceEntryTypeValues.MEASURE,
|
|
152
|
-
name,
|
|
153
|
-
startTime: start,
|
|
154
|
-
duration: computedDuration,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
return [start, computedDuration];
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
getSimpleMemoryInfo: (): NativeMemoryInfo => {
|
|
161
|
-
return {};
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
getReactNativeStartupTiming: (): ReactNativeStartupTiming => {
|
|
165
|
-
return {
|
|
166
|
-
startTime: 0,
|
|
167
|
-
endTime: 0,
|
|
168
|
-
executeJavaScriptBundleEntryPointStart: 0,
|
|
169
|
-
executeJavaScriptBundleEntryPointEnd: 0,
|
|
170
|
-
initializeRuntimeStart: 0,
|
|
171
|
-
initializeRuntimeEnd: 0,
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
getEventCounts: (): $ReadOnlyArray<[string, number]> => {
|
|
176
|
-
return Array.from(eventCounts.entries());
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
createObserver: (
|
|
180
|
-
callback: NativeBatchedObserverCallback,
|
|
181
|
-
): OpaqueNativeObserverHandle => {
|
|
182
|
-
return createMockObserver(callback);
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
getDroppedEntriesCount: (observer: OpaqueNativeObserverHandle): number => {
|
|
186
|
-
return getMockObserver(observer).droppedEntriesCount;
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
observe: (
|
|
190
|
-
observer: OpaqueNativeObserverHandle,
|
|
191
|
-
options: PerformanceObserverInit,
|
|
192
|
-
): void => {
|
|
193
|
-
const mockObserver = getMockObserver(observer);
|
|
194
|
-
mockObserver.options = options;
|
|
195
|
-
observers.add(mockObserver);
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
disconnect: (observer: OpaqueNativeObserverHandle): void => {
|
|
199
|
-
const mockObserver = getMockObserver(observer);
|
|
200
|
-
observers.delete(mockObserver);
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
takeRecords: (
|
|
204
|
-
observer: OpaqueNativeObserverHandle,
|
|
205
|
-
): $ReadOnlyArray<RawPerformanceEntry> => {
|
|
206
|
-
const mockObserver = getMockObserver(observer);
|
|
207
|
-
const observerEntries = mockObserver.entries;
|
|
208
|
-
mockObserver.entries = [];
|
|
209
|
-
return observerEntries.sort((a, b) => a.startTime - b.startTime);
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
clearMarks: (entryName?: string) => {
|
|
213
|
-
if (entryName != null) {
|
|
214
|
-
marks.delete(entryName);
|
|
215
|
-
} else {
|
|
216
|
-
marks.clear();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
entries = entries.filter(
|
|
220
|
-
entry =>
|
|
221
|
-
entry.entryType !== RawPerformanceEntryTypeValues.MARK ||
|
|
222
|
-
(entryName != null && entry.name !== entryName),
|
|
223
|
-
);
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
clearMeasures: (entryName?: string) => {
|
|
227
|
-
entries = entries.filter(
|
|
228
|
-
entry =>
|
|
229
|
-
entry.entryType !== RawPerformanceEntryTypeValues.MEASURE ||
|
|
230
|
-
(entryName != null && entry.name !== entryName),
|
|
231
|
-
);
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
getEntries: (): $ReadOnlyArray<RawPerformanceEntry> => {
|
|
235
|
-
return [...entries].sort((a, b) => a.startTime - b.startTime);
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
getEntriesByName: (
|
|
239
|
-
entryName: string,
|
|
240
|
-
entryType?: ?RawPerformanceEntryType,
|
|
241
|
-
): $ReadOnlyArray<RawPerformanceEntry> => {
|
|
242
|
-
return NativePerformanceMock.getEntries().filter(
|
|
243
|
-
entry =>
|
|
244
|
-
(entryType == null || entry.entryType === entryType) &&
|
|
245
|
-
entry.name === entryName,
|
|
246
|
-
);
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
getEntriesByType: (
|
|
250
|
-
entryType: RawPerformanceEntryType,
|
|
251
|
-
): $ReadOnlyArray<RawPerformanceEntry> => {
|
|
252
|
-
return entries.filter(entry => entry.entryType === entryType);
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
getSupportedPerformanceEntryTypes:
|
|
256
|
-
(): $ReadOnlyArray<RawPerformanceEntryType> => {
|
|
257
|
-
return [
|
|
258
|
-
RawPerformanceEntryTypeValues.MARK,
|
|
259
|
-
RawPerformanceEntryTypeValues.MEASURE,
|
|
260
|
-
RawPerformanceEntryTypeValues.EVENT,
|
|
261
|
-
];
|
|
262
|
-
},
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
(NativePerformanceMock: NativePerformance);
|
|
266
|
-
|
|
267
|
-
export default NativePerformanceMock;
|
|
@@ -1,26 +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
|
-
*/
|
|
9
|
-
|
|
10
|
-
// Adds the JSX elements used in the launch screen.
|
|
11
|
-
|
|
12
|
-
declare module 'react-native/Libraries/NewAppScreen' {
|
|
13
|
-
export const Header: any;
|
|
14
|
-
export const LearnMoreLinks: any;
|
|
15
|
-
export const Colors: {
|
|
16
|
-
primary: string;
|
|
17
|
-
white: string;
|
|
18
|
-
lighter: string;
|
|
19
|
-
light: string;
|
|
20
|
-
dark: string;
|
|
21
|
-
darker: string;
|
|
22
|
-
black: string;
|
|
23
|
-
};
|
|
24
|
-
export const DebugInstructions: any;
|
|
25
|
-
export const ReloadInstructions: any;
|
|
26
|
-
}
|
|
File without changes
|
|
File without changes
|