@office-iss/react-native-win32 0.75.1 → 0.76.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/.eslintrc.js +11 -0
- package/.flowconfig +5 -4
- package/CHANGELOG.json +172 -40
- package/CHANGELOG.md +57 -24
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +7 -7
- package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
- package/Libraries/Animated/animations/Animation.js +11 -1
- package/Libraries/Animated/animations/DecayAnimation.js +1 -1
- package/Libraries/Animated/animations/SpringAnimation.js +1 -1
- package/Libraries/Animated/animations/TimingAnimation.js +2 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +10 -9
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
- package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
- package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
- package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
- package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
- package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
- package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
- package/Libraries/Animated/useAnimatedProps.js +142 -7
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/FileReader.js +1 -1
- package/Libraries/Blob/URL.js +2 -62
- package/Libraries/Blob/URLSearchParams.js +71 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +131 -169
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
- package/Libraries/Components/TextInput/TextInput.js +230 -94
- package/Libraries/Components/TextInput/TextInput.win32.js +230 -100
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +2 -0
- package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/Libraries/Components/View/ViewNativeComponent.js +0 -1
- package/Libraries/Components/View/ViewPropTypes.js +14 -0
- package/Libraries/Components/View/ViewPropTypes.win32.js +14 -0
- package/Libraries/Core/ExceptionsManager.js +2 -0
- package/Libraries/Core/InitializeCore.js +3 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
- package/Libraries/Core/ReactNativeVersion.js +4 -4
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
- package/Libraries/Core/setUpErrorHandling.js +7 -1
- package/Libraries/Core/setUpGlobals.js +1 -0
- package/Libraries/Core/setUpReactRefresh.js +0 -4
- package/Libraries/Image/AssetSourceResolver.js +28 -1
- package/Libraries/Image/Image.android.js +9 -14
- package/Libraries/Image/Image.ios.js +11 -22
- package/Libraries/Image/Image.win32.js +11 -24
- package/Libraries/Image/ImageBackground.js +1 -8
- package/Libraries/Image/ImageUtils.js +9 -9
- package/Libraries/Image/ImageViewNativeComponent.js +1 -0
- package/Libraries/Inspector/Inspector.js +3 -2
- package/Libraries/Inspector/Inspector.win32.js +3 -2
- package/Libraries/Inspector/InspectorPanel.js +16 -10
- package/Libraries/Inspector/NetworkOverlay.js +1 -1
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/Lists/FlatList.js +1 -1
- package/Libraries/Lists/SectionList.js +2 -2
- package/Libraries/Lists/SectionListModern.js +3 -3
- package/Libraries/LogBox/Data/LogBoxData.js +24 -3
- package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +9 -29
- package/Libraries/Modal/Modal.js +0 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +7 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
- package/Libraries/Network/XMLHttpRequest.js +4 -2
- package/Libraries/ReactNative/AppContainer-dev.js +1 -5
- package/Libraries/ReactNative/AppContainer-prod.js +1 -5
- package/Libraries/ReactNative/AppContainer.js +0 -1
- package/Libraries/ReactNative/AppRegistry.js +0 -6
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
- package/Libraries/ReactNative/RendererImplementation.js +26 -4
- package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
- package/Libraries/ReactNative/renderApplication.js +0 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +74 -15
- package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
- package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
- package/Libraries/StyleSheet/processBoxShadow.js +211 -0
- package/Libraries/StyleSheet/processFilter.js +231 -42
- package/Libraries/Text/Text.js +394 -196
- package/Libraries/Text/Text.win32.js +442 -229
- package/Libraries/Text/TextNativeComponent.js +2 -1
- package/Libraries/Text/TextNativeComponent.win32.js +1 -1
- package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
- package/Libraries/Types/CodegenTypes.js +3 -1
- package/Libraries/Utilities/Appearance.js +108 -84
- package/Libraries/Utilities/DevLoadingView.js +2 -4
- package/Libraries/Utilities/HMRClient.js +2 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +0 -9
- package/Libraries/Utilities/stringifyViewConfig.js +22 -0
- package/Libraries/Utilities/useColorScheme.js +3 -3
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/promiseRejectionTrackingOptions.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +6 -5
- package/flow/jest.js +2 -2
- package/index.js +3 -1
- package/index.win32.js +3 -1
- package/jest/mockComponent.js +4 -1
- package/jest/mockModal.js +1 -3
- package/jest/mockScrollView.js +1 -1
- package/jest/renderer.js +2 -2
- package/jest/setup.js +16 -13
- package/jest.config.js +1 -2
- package/overrides.json +22 -22
- package/package.json +27 -26
- package/src/private/animated/NativeAnimatedHelper.js +438 -0
- package/src/private/animated/NativeAnimatedHelper.win32.js +440 -0
- package/src/private/animated/NativeAnimatedValidation.js +64 -0
- package/src/private/components/HScrollViewNativeComponents.js +56 -0
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
- package/src/private/components/VScrollViewNativeComponents.js +48 -0
- package/src/private/components/useSyncOnScroll.js +48 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
- package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
- package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
- package/src/private/setup/setUpDOM.js +28 -0
- package/src/private/setup/setUpIntersectionObserver.js +27 -0
- package/src/private/setup/setUpMutationObserver.js +26 -0
- package/src/private/setup/setUpPerformanceObserver.js +64 -0
- package/src/private/specs/modules/NativeAppearance.js +3 -3
- package/src/private/specs/modules/NativeLinkingManager.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsWin.js +7 -0
- package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
- package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
- package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
- package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
- package/src/private/webapis/performance/LongTasks.js +39 -0
- package/src/private/webapis/performance/Performance.js +22 -9
- package/src/private/webapis/performance/PerformanceEntry.js +36 -18
- package/src/private/webapis/performance/PerformanceObserver.js +29 -43
- package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
- package/src/private/webapis/performance/UserTiming.js +17 -12
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
- package/src-win/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/types/experimental.d.ts +20 -1
- package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
- package/Libraries/Animated/NativeAnimatedHelper.win32.js +0 -617
- package/Libraries/Core/setUpIntersectionObserver.js +0 -16
- package/Libraries/Core/setUpMutationObserver.js +0 -16
- package/Libraries/Core/setUpPerformanceObserver.js +0 -18
- package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
- package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
- package/src/private/core/setUpDOM.js +0 -18
- package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
- /package/src/private/{core → styles}/composeStyles.js +0 -0
|
@@ -16,8 +16,9 @@ import type {TextProps} from './TextProps';
|
|
|
16
16
|
import {createViewConfig} from '../NativeComponent/ViewConfig';
|
|
17
17
|
import UIManager from '../ReactNative/UIManager';
|
|
18
18
|
import createReactNativeComponentClass from '../Renderer/shims/createReactNativeComponentClass';
|
|
19
|
+
import Platform from '../Utilities/Platform';
|
|
19
20
|
|
|
20
|
-
type NativeTextProps = $ReadOnly<{
|
|
21
|
+
export type NativeTextProps = $ReadOnly<{
|
|
21
22
|
...TextProps,
|
|
22
23
|
isHighlighted?: ?boolean,
|
|
23
24
|
selectionColor?: ?ProcessedColorValue,
|
|
@@ -17,7 +17,7 @@ import {createViewConfig} from '../NativeComponent/ViewConfig';
|
|
|
17
17
|
import UIManager from '../ReactNative/UIManager';
|
|
18
18
|
import createReactNativeComponentClass from '../Renderer/shims/createReactNativeComponentClass';
|
|
19
19
|
|
|
20
|
-
type NativeTextProps = $ReadOnly<{
|
|
20
|
+
export type NativeTextProps = $ReadOnly<{
|
|
21
21
|
...TextProps,
|
|
22
22
|
isHighlighted?: ?boolean,
|
|
23
23
|
selectionColor?: ?ProcessedColorValue,
|
|
@@ -16,52 +16,25 @@ const NativeModules = require('../BatchedBridge/NativeModules');
|
|
|
16
16
|
|
|
17
17
|
const turboModuleProxy = global.__turboModuleProxy;
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
TurboModules: ([]: Array<string>),
|
|
22
|
-
NotFound: ([]: Array<string>),
|
|
23
|
-
};
|
|
19
|
+
const useLegacyNativeModuleInterop =
|
|
20
|
+
global.RN$Bridgeless !== true || global.RN$TurboInterop === true;
|
|
24
21
|
|
|
25
|
-
function isBridgeless() {
|
|
26
|
-
return global.RN$Bridgeless === true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function isTurboModuleInteropEnabled() {
|
|
30
|
-
return global.RN$TurboInterop === true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// TODO(154308585): Remove "module not found" debug info logging
|
|
34
|
-
function shouldReportDebugInfo() {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// TODO(148943970): Consider reversing the lookup here:
|
|
39
|
-
// Lookup on __turboModuleProxy, then lookup on nativeModuleProxy
|
|
40
22
|
function requireModule<T: TurboModule>(name: string): ?T {
|
|
41
|
-
if (!isBridgeless() || isTurboModuleInteropEnabled()) {
|
|
42
|
-
// Backward compatibility layer during migration.
|
|
43
|
-
const legacyModule = NativeModules[name];
|
|
44
|
-
if (legacyModule != null) {
|
|
45
|
-
if (shouldReportDebugInfo()) {
|
|
46
|
-
moduleLoadHistory.NativeModules.push(name);
|
|
47
|
-
}
|
|
48
|
-
return ((legacyModule: $FlowFixMe): T);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
23
|
if (turboModuleProxy != null) {
|
|
53
24
|
const module: ?T = turboModuleProxy(name);
|
|
54
25
|
if (module != null) {
|
|
55
|
-
if (shouldReportDebugInfo()) {
|
|
56
|
-
moduleLoadHistory.TurboModules.push(name);
|
|
57
|
-
}
|
|
58
26
|
return module;
|
|
59
27
|
}
|
|
60
28
|
}
|
|
61
29
|
|
|
62
|
-
if (
|
|
63
|
-
|
|
30
|
+
if (useLegacyNativeModuleInterop) {
|
|
31
|
+
// Backward compatibility layer during migration.
|
|
32
|
+
const legacyModule: ?T = NativeModules[name];
|
|
33
|
+
if (legacyModule != null) {
|
|
34
|
+
return legacyModule;
|
|
35
|
+
}
|
|
64
36
|
}
|
|
37
|
+
|
|
65
38
|
return null;
|
|
66
39
|
}
|
|
67
40
|
|
|
@@ -71,20 +44,10 @@ export function get<T: TurboModule>(name: string): ?T {
|
|
|
71
44
|
|
|
72
45
|
export function getEnforcing<T: TurboModule>(name: string): T {
|
|
73
46
|
const module = requireModule<T>(name);
|
|
74
|
-
|
|
47
|
+
invariant(
|
|
48
|
+
module != null,
|
|
75
49
|
`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found. ` +
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (shouldReportDebugInfo()) {
|
|
79
|
-
message +=
|
|
80
|
-
' Bridgeless mode: ' + (isBridgeless() ? 'true' : 'false') + '. ';
|
|
81
|
-
message +=
|
|
82
|
-
'TurboModule interop: ' +
|
|
83
|
-
(isTurboModuleInteropEnabled() ? 'true' : 'false') +
|
|
84
|
-
'. ';
|
|
85
|
-
message += 'Modules loaded: ' + JSON.stringify(moduleLoadHistory);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
invariant(module != null, message);
|
|
50
|
+
'Verify that a module by this name is registered in the native binary.',
|
|
51
|
+
);
|
|
89
52
|
return module;
|
|
90
53
|
}
|
|
@@ -42,4 +42,6 @@ type DefaultTypes = number | boolean | string | $ReadOnlyArray<string>;
|
|
|
42
42
|
// eslint-disable-next-line no-unused-vars
|
|
43
43
|
export type WithDefault<Type: DefaultTypes, Value: ?Type | string> = ?Type;
|
|
44
44
|
|
|
45
|
-
export type EventEmitter<T> = (
|
|
45
|
+
export type EventEmitter<T> = (
|
|
46
|
+
handler: (T) => void | Promise<void>,
|
|
47
|
+
) => EventSubscription;
|
|
@@ -8,100 +8,124 @@
|
|
|
8
8
|
* @flow strict-local
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import type {EventSubscription} from '../vendor/emitter/EventEmitter';
|
|
12
|
+
import type {AppearancePreferences, ColorSchemeName} from './NativeAppearance';
|
|
13
|
+
import typeof INativeAppearance from './NativeAppearance';
|
|
14
|
+
|
|
11
15
|
import NativeEventEmitter from '../EventEmitter/NativeEventEmitter';
|
|
12
|
-
import
|
|
13
|
-
import EventEmitter, {
|
|
14
|
-
type EventSubscription,
|
|
15
|
-
} from '../vendor/emitter/EventEmitter';
|
|
16
|
+
import EventEmitter from '../vendor/emitter/EventEmitter';
|
|
16
17
|
import {isAsyncDebugging} from './DebugEnvironment';
|
|
17
|
-
import NativeAppearance, {
|
|
18
|
-
type AppearancePreferences,
|
|
19
|
-
type ColorSchemeName,
|
|
20
|
-
} from './NativeAppearance';
|
|
21
18
|
import invariant from 'invariant';
|
|
22
19
|
|
|
23
|
-
type
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}>();
|
|
20
|
+
type Appearance = {
|
|
21
|
+
colorScheme: ?ColorSchemeName,
|
|
22
|
+
};
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
let lazyState: ?{
|
|
25
|
+
+NativeAppearance: INativeAppearance,
|
|
26
|
+
// Cache the color scheme to reduce the cost of reading it between changes.
|
|
27
|
+
// NOTE: If `NativeAppearance` is null, this will always be null.
|
|
28
|
+
appearance: ?Appearance,
|
|
29
|
+
// NOTE: This is non-nullable to make it easier for `onChangedListener` to
|
|
30
|
+
// return a non-nullable `EventSubscription` value. This is not the common
|
|
31
|
+
// path, so we do not have to over-optimize it.
|
|
32
|
+
+eventEmitter: EventEmitter<{change: [Appearance]}>,
|
|
30
33
|
};
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Ensures that all state and listeners are lazily initialized correctly.
|
|
37
|
+
*/
|
|
38
|
+
function getState(): $NonMaybeType<typeof lazyState> {
|
|
39
|
+
if (lazyState != null) {
|
|
40
|
+
return lazyState;
|
|
41
|
+
}
|
|
42
|
+
const eventEmitter = new EventEmitter<{change: [Appearance]}>();
|
|
43
|
+
// NOTE: Avoid initializing `NativeAppearance` until it is actually used.
|
|
44
|
+
const NativeAppearance = require('./NativeAppearance').default;
|
|
45
|
+
if (NativeAppearance == null) {
|
|
46
|
+
// Assign `null` to avoid re-initializing on subsequent invocations.
|
|
47
|
+
lazyState = {
|
|
48
|
+
NativeAppearance: null,
|
|
49
|
+
appearance: null,
|
|
50
|
+
eventEmitter,
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
const state: $NonMaybeType<typeof lazyState> = {
|
|
54
|
+
NativeAppearance,
|
|
55
|
+
appearance: null,
|
|
56
|
+
eventEmitter,
|
|
57
|
+
};
|
|
58
|
+
new NativeEventEmitter<{
|
|
59
|
+
appearanceChanged: [AppearancePreferences],
|
|
60
|
+
}>(NativeAppearance).addListener('appearanceChanged', newAppearance => {
|
|
61
|
+
state.appearance = {
|
|
62
|
+
colorScheme: toColorScheme(newAppearance.colorScheme),
|
|
63
|
+
};
|
|
64
|
+
eventEmitter.emit('change', state.appearance);
|
|
65
|
+
});
|
|
66
|
+
lazyState = state;
|
|
67
|
+
}
|
|
68
|
+
return lazyState;
|
|
52
69
|
}
|
|
53
70
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
getColorScheme(): ?ColorSchemeName {
|
|
66
|
-
if (__DEV__) {
|
|
67
|
-
if (isAsyncDebugging) {
|
|
68
|
-
// Hard code light theme when using the async debugger as
|
|
69
|
-
// sync calls aren't supported
|
|
70
|
-
return 'light';
|
|
71
|
-
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the current color scheme preference. This value may change, so the
|
|
73
|
+
* value should not be cached without either listening to changes or using
|
|
74
|
+
* the `useColorScheme` hook.
|
|
75
|
+
*/
|
|
76
|
+
export function getColorScheme(): ?ColorSchemeName {
|
|
77
|
+
if (__DEV__) {
|
|
78
|
+
if (isAsyncDebugging) {
|
|
79
|
+
// Hard code light theme when using the async debugger as
|
|
80
|
+
// sync calls aren't supported
|
|
81
|
+
return 'light';
|
|
72
82
|
}
|
|
83
|
+
}
|
|
84
|
+
let colorScheme = null;
|
|
85
|
+
const state = getState();
|
|
86
|
+
const {NativeAppearance} = state;
|
|
87
|
+
if (NativeAppearance != null) {
|
|
88
|
+
if (state.appearance == null) {
|
|
89
|
+
// Lazily initialize `state.appearance`. This should only
|
|
90
|
+
// happen once because we never reassign a null value to it.
|
|
91
|
+
state.appearance = {
|
|
92
|
+
colorScheme: toColorScheme(NativeAppearance.getColorScheme()),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
colorScheme = state.appearance.colorScheme;
|
|
96
|
+
}
|
|
97
|
+
return colorScheme;
|
|
98
|
+
}
|
|
73
99
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return nativeColorScheme;
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
setColorScheme(colorScheme: ?ColorSchemeName): void {
|
|
89
|
-
const nativeColorScheme = colorScheme == null ? 'unspecified' : colorScheme;
|
|
90
|
-
|
|
91
|
-
invariant(
|
|
92
|
-
colorScheme === 'dark' || colorScheme === 'light' || colorScheme == null,
|
|
93
|
-
"Unrecognized color scheme. Did you mean 'dark', 'light' or null?",
|
|
94
|
-
);
|
|
100
|
+
/**
|
|
101
|
+
* Updates the current color scheme to the supplied value.
|
|
102
|
+
*/
|
|
103
|
+
export function setColorScheme(colorScheme: ?ColorSchemeName): void {
|
|
104
|
+
const state = getState();
|
|
105
|
+
const {NativeAppearance} = state;
|
|
106
|
+
if (NativeAppearance != null) {
|
|
107
|
+
NativeAppearance.setColorScheme(colorScheme ?? 'unspecified');
|
|
108
|
+
state.appearance = {colorScheme};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
95
111
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Add an event handler that is fired when appearance preferences change.
|
|
114
|
+
*/
|
|
115
|
+
export function addChangeListener(
|
|
116
|
+
listener: ({colorScheme: ?ColorSchemeName}) => void,
|
|
117
|
+
): EventSubscription {
|
|
118
|
+
const {eventEmitter} = getState();
|
|
119
|
+
return eventEmitter.addListener('change', listener);
|
|
120
|
+
}
|
|
100
121
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
/**
|
|
123
|
+
* TODO: (hramos) T52919652 Use ?ColorSchemeName once codegen supports union
|
|
124
|
+
*/
|
|
125
|
+
function toColorScheme(colorScheme: ?string): ?ColorSchemeName {
|
|
126
|
+
invariant(
|
|
127
|
+
colorScheme === 'dark' || colorScheme === 'light' || colorScheme == null,
|
|
128
|
+
"Unrecognized color scheme. Did you mean 'dark', 'light' or null?",
|
|
129
|
+
);
|
|
130
|
+
return colorScheme;
|
|
131
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import processColor from '../StyleSheet/processColor';
|
|
12
|
-
import
|
|
12
|
+
import {getColorScheme} from './Appearance';
|
|
13
13
|
import NativeDevLoadingView from './NativeDevLoadingView';
|
|
14
14
|
|
|
15
15
|
const COLOR_SCHEME = {
|
|
@@ -39,9 +39,7 @@ module.exports = {
|
|
|
39
39
|
showMessage(message: string, type: 'load' | 'refresh') {
|
|
40
40
|
if (NativeDevLoadingView) {
|
|
41
41
|
const colorScheme =
|
|
42
|
-
|
|
43
|
-
? COLOR_SCHEME.dark
|
|
44
|
-
: COLOR_SCHEME.default;
|
|
42
|
+
getColorScheme() === 'dark' ? COLOR_SCHEME.dark : COLOR_SCHEME.default;
|
|
45
43
|
|
|
46
44
|
const colorSet = colorScheme[type];
|
|
47
45
|
|
|
@@ -126,7 +126,7 @@ const HMRClient: HMRClientNativeInterface = {
|
|
|
126
126
|
data: data.map(item =>
|
|
127
127
|
typeof item === 'string'
|
|
128
128
|
? item
|
|
129
|
-
: prettyFormat(item, {
|
|
129
|
+
: prettyFormat.format(item, {
|
|
130
130
|
escapeString: true,
|
|
131
131
|
highlight: true,
|
|
132
132
|
maxDepth: 3,
|
|
@@ -379,6 +379,7 @@ function showCompileError() {
|
|
|
379
379
|
|
|
380
380
|
/* $FlowFixMe[class-object-subtyping] added when improving typing for this
|
|
381
381
|
* parameters */
|
|
382
|
+
// $FlowFixMe[incompatible-type]
|
|
382
383
|
const error: ExtendedError = new Error(message);
|
|
383
384
|
// Symbolicating compile errors is wasted effort
|
|
384
385
|
// because the stack trace is meaningless:
|
|
@@ -115,7 +115,7 @@ function expectNoConsoleError() {
|
|
|
115
115
|
|
|
116
116
|
async function expectRendersMatchingSnapshot(
|
|
117
117
|
name: string,
|
|
118
|
-
ComponentProvider: () => React.
|
|
118
|
+
ComponentProvider: () => React.MixedElement,
|
|
119
119
|
unmockComponent: () => mixed,
|
|
120
120
|
) {
|
|
121
121
|
let instance;
|
|
@@ -15,11 +15,8 @@ import type {
|
|
|
15
15
|
Timespan,
|
|
16
16
|
} from './IPerformanceLogger';
|
|
17
17
|
|
|
18
|
-
import * as Systrace from '../Performance/Systrace';
|
|
19
18
|
import infoLog from './infoLog';
|
|
20
19
|
|
|
21
|
-
const _cookies: {[key: string]: number, ...} = {};
|
|
22
|
-
|
|
23
20
|
const PRINT_TO_CONSOLE: false = false; // Type as false to prevent accidentally committing `true`;
|
|
24
21
|
|
|
25
22
|
export const getCurrentTimestamp: () => number =
|
|
@@ -233,7 +230,6 @@ class PerformanceLogger implements IPerformanceLogger {
|
|
|
233
230
|
startTime: timestamp,
|
|
234
231
|
startExtras: extras,
|
|
235
232
|
};
|
|
236
|
-
_cookies[key] = Systrace.beginAsyncEvent(key);
|
|
237
233
|
if (PRINT_TO_CONSOLE) {
|
|
238
234
|
infoLog('PerformanceLogger.js', 'start: ' + key);
|
|
239
235
|
}
|
|
@@ -277,11 +273,6 @@ class PerformanceLogger implements IPerformanceLogger {
|
|
|
277
273
|
if (PRINT_TO_CONSOLE) {
|
|
278
274
|
infoLog('PerformanceLogger.js', 'end: ' + key);
|
|
279
275
|
}
|
|
280
|
-
|
|
281
|
-
if (_cookies[key] != null) {
|
|
282
|
-
Systrace.endAsyncEvent(key, _cookies[key]);
|
|
283
|
-
delete _cookies[key];
|
|
284
|
-
}
|
|
285
276
|
}
|
|
286
277
|
}
|
|
287
278
|
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
* @flow
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export default function stringifyViewConfig(viewConfig: any): string {
|
|
12
|
+
return JSON.stringify(
|
|
13
|
+
viewConfig,
|
|
14
|
+
(key, val) => {
|
|
15
|
+
if (typeof val === 'function') {
|
|
16
|
+
return `ƒ ${val.name}`;
|
|
17
|
+
}
|
|
18
|
+
return val;
|
|
19
|
+
},
|
|
20
|
+
2,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
import type {ColorSchemeName} from './NativeAppearance';
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import {addChangeListener, getColorScheme} from './Appearance';
|
|
16
16
|
import {useSyncExternalStore} from 'react';
|
|
17
17
|
|
|
18
18
|
const subscribe = (onStoreChange: () => void) => {
|
|
19
|
-
const appearanceSubscription =
|
|
19
|
+
const appearanceSubscription = addChangeListener(onStoreChange);
|
|
20
20
|
return () => appearanceSubscription.remove();
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export default function useColorScheme(): ?ColorSchemeName {
|
|
24
|
-
return useSyncExternalStore(subscribe,
|
|
24
|
+
return useSyncExternalStore(subscribe, getColorScheme);
|
|
25
25
|
}
|
|
@@ -68,7 +68,7 @@ type WebSocketEventDefinitions = {
|
|
|
68
68
|
* See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
|
|
69
69
|
* See https://github.com/websockets/ws
|
|
70
70
|
*/
|
|
71
|
-
class WebSocket extends (EventTarget(...WEBSOCKET_EVENTS):
|
|
71
|
+
class WebSocket extends (EventTarget(...WEBSOCKET_EVENTS): typeof EventTarget) {
|
|
72
72
|
static CONNECTING: number = CONNECTING;
|
|
73
73
|
static OPEN: number = OPEN;
|
|
74
74
|
static CLOSING: number = CLOSING;
|
|
@@ -27,7 +27,7 @@ let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = {
|
|
|
27
27
|
stack = error.stack;
|
|
28
28
|
} else {
|
|
29
29
|
try {
|
|
30
|
-
message = require('pretty-format')(rejection);
|
|
30
|
+
message = require('pretty-format').format(rejection);
|
|
31
31
|
} catch {
|
|
32
32
|
message =
|
|
33
33
|
typeof rejection === 'string'
|
|
@@ -35,11 +35,9 @@ interface Registration<TArgs> {
|
|
|
35
35
|
+remove: () => void;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<TArgs>(TArgs) => Set<Registration<TArgs>>,
|
|
42
|
-
>;
|
|
38
|
+
type Registry<TEventToArgsMap: {...}> = {
|
|
39
|
+
[K in keyof TEventToArgsMap]: Set<Registration<TEventToArgsMap[K]>>,
|
|
40
|
+
};
|
|
43
41
|
|
|
44
42
|
/**
|
|
45
43
|
* EventEmitter manages listeners and publishes events to them.
|
|
@@ -64,6 +62,7 @@ type Registry<TEventToArgsMap: {...}> = $ObjMap<
|
|
|
64
62
|
export default class EventEmitter<TEventToArgsMap: {...}>
|
|
65
63
|
implements IEventEmitter<TEventToArgsMap>
|
|
66
64
|
{
|
|
65
|
+
// $FlowFixMe[incompatible-type]
|
|
67
66
|
#registry: Registry<TEventToArgsMap> = {};
|
|
68
67
|
|
|
69
68
|
/**
|
|
@@ -113,6 +112,7 @@ export default class EventEmitter<TEventToArgsMap: {...}>
|
|
|
113
112
|
// Copy `registrations` to take a snapshot when we invoke `emit`, in case
|
|
114
113
|
// registrations are added or removed when listeners are invoked.
|
|
115
114
|
for (const registration of Array.from(registrations)) {
|
|
115
|
+
// $FlowFixMe[incompatible-call]
|
|
116
116
|
registration.listener.apply(registration.context, args);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -125,6 +125,7 @@ export default class EventEmitter<TEventToArgsMap: {...}>
|
|
|
125
125
|
eventType?: ?TEvent,
|
|
126
126
|
): void {
|
|
127
127
|
if (eventType == null) {
|
|
128
|
+
// $FlowFixMe[incompatible-type]
|
|
128
129
|
this.#registry = {};
|
|
129
130
|
} else {
|
|
130
131
|
delete this.#registry[eventType];
|
package/flow/jest.js
CHANGED
|
@@ -251,7 +251,7 @@ type EnzymeMatchersType = {
|
|
|
251
251
|
toContainMatchingElement(selector: string): void,
|
|
252
252
|
toContainMatchingElements(n: number, selector: string): void,
|
|
253
253
|
toContainExactlyOneMatchingElement(selector: string): void,
|
|
254
|
-
toContainReact(element: React
|
|
254
|
+
toContainReact(element: React.MixedElement): void,
|
|
255
255
|
toExist(): void,
|
|
256
256
|
toHaveClassName(className: string): void,
|
|
257
257
|
toHaveHTML(html: string): void,
|
|
@@ -267,7 +267,7 @@ type EnzymeMatchersType = {
|
|
|
267
267
|
toHaveValue(value: any): void,
|
|
268
268
|
toIncludeText(text: string): void,
|
|
269
269
|
toMatchElement(
|
|
270
|
-
element: React
|
|
270
|
+
element: React.MixedElement,
|
|
271
271
|
options?: {|ignoreProps?: boolean, verbose?: boolean|},
|
|
272
272
|
): void,
|
|
273
273
|
toMatchSelector(selector: string): void,
|
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
|
+
'use client';
|
|
12
13
|
|
|
13
14
|
// APIs
|
|
14
15
|
import typeof ActionSheetIOS from './Libraries/ActionSheetIOS/ActionSheetIOS';
|
|
@@ -59,6 +60,7 @@ import typeof VirtualizedList from './Libraries/Lists/VirtualizedList';
|
|
|
59
60
|
import typeof VirtualizedSectionList from './Libraries/Lists/VirtualizedSectionList';
|
|
60
61
|
import typeof LogBox from './Libraries/LogBox/LogBox';
|
|
61
62
|
import typeof Modal from './Libraries/Modal/Modal';
|
|
63
|
+
// $FlowFixMe[invalid-exported-annotation]
|
|
62
64
|
import typeof NativeDialogManagerAndroid from './Libraries/NativeModules/specs/NativeDialogManagerAndroid';
|
|
63
65
|
import typeof Networking from './Libraries/Network/RCTNetworking';
|
|
64
66
|
import typeof * as Systrace from './Libraries/Performance/Systrace';
|
|
@@ -80,7 +82,7 @@ import typeof StyleSheet from './Libraries/StyleSheet/StyleSheet';
|
|
|
80
82
|
import typeof Text from './Libraries/Text/Text';
|
|
81
83
|
import typeof * as TurboModuleRegistry from './Libraries/TurboModule/TurboModuleRegistry';
|
|
82
84
|
import typeof UTFSequence from './Libraries/UTFSequence';
|
|
83
|
-
import typeof Appearance from './Libraries/Utilities/Appearance';
|
|
85
|
+
import typeof * as Appearance from './Libraries/Utilities/Appearance';
|
|
84
86
|
import typeof BackHandler from './Libraries/Utilities/BackHandler';
|
|
85
87
|
import typeof DeviceInfo from './Libraries/Utilities/DeviceInfo';
|
|
86
88
|
import typeof DevSettings from './Libraries/Utilities/DevSettings';
|
package/index.win32.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
|
+
'use client';
|
|
12
13
|
|
|
13
14
|
// APIs
|
|
14
15
|
import typeof ActionSheetIOS from './Libraries/ActionSheetIOS/ActionSheetIOS';
|
|
@@ -59,6 +60,7 @@ import typeof VirtualizedList from './Libraries/Lists/VirtualizedList';
|
|
|
59
60
|
import typeof VirtualizedSectionList from './Libraries/Lists/VirtualizedSectionList';
|
|
60
61
|
import typeof LogBox from './Libraries/LogBox/LogBox';
|
|
61
62
|
import typeof Modal from './Libraries/Modal/Modal';
|
|
63
|
+
// $FlowFixMe[invalid-exported-annotation]
|
|
62
64
|
import typeof NativeDialogManagerAndroid from './Libraries/NativeModules/specs/NativeDialogManagerAndroid';
|
|
63
65
|
import typeof Networking from './Libraries/Network/RCTNetworking';
|
|
64
66
|
import typeof * as Systrace from './Libraries/Performance/Systrace';
|
|
@@ -80,7 +82,7 @@ import typeof StyleSheet from './Libraries/StyleSheet/StyleSheet';
|
|
|
80
82
|
import typeof Text from './Libraries/Text/Text';
|
|
81
83
|
import typeof * as TurboModuleRegistry from './Libraries/TurboModule/TurboModuleRegistry';
|
|
82
84
|
import typeof UTFSequence from './Libraries/UTFSequence';
|
|
83
|
-
import typeof Appearance from './Libraries/Utilities/Appearance';
|
|
85
|
+
import typeof * as Appearance from './Libraries/Utilities/Appearance';
|
|
84
86
|
import typeof BackHandler from './Libraries/Utilities/BackHandler';
|
|
85
87
|
import typeof DeviceInfo from './Libraries/Utilities/DeviceInfo';
|
|
86
88
|
import typeof DevSettings from './Libraries/Utilities/DevSettings';
|
package/jest/mockComponent.js
CHANGED
|
@@ -16,7 +16,10 @@ module.exports = (moduleName, instanceMethods, isESModule) => {
|
|
|
16
16
|
const React = require('react');
|
|
17
17
|
|
|
18
18
|
const SuperClass =
|
|
19
|
-
typeof RealComponent === 'function'
|
|
19
|
+
typeof RealComponent === 'function' &&
|
|
20
|
+
RealComponent.prototype.constructor instanceof React.Component
|
|
21
|
+
? RealComponent
|
|
22
|
+
: React.Component;
|
|
20
23
|
|
|
21
24
|
const name =
|
|
22
25
|
RealComponent.displayName ||
|
package/jest/mockModal.js
CHANGED
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
import typeof Modal from '../Libraries/Modal/Modal';
|
|
16
|
-
|
|
17
15
|
const React = require('react');
|
|
18
16
|
|
|
19
17
|
function mockModal(BaseComponent: $FlowFixMe) {
|
|
20
18
|
class ModalMock extends BaseComponent {
|
|
21
|
-
render(): React.
|
|
19
|
+
render(): React.MixedElement | null {
|
|
22
20
|
if (this.props.visible === false) {
|
|
23
21
|
return null;
|
|
24
22
|
}
|
package/jest/mockScrollView.js
CHANGED
|
@@ -20,7 +20,7 @@ const RCTScrollView: $FlowFixMe = requireNativeComponent('RCTScrollView');
|
|
|
20
20
|
|
|
21
21
|
function mockScrollView(BaseComponent: $FlowFixMe) {
|
|
22
22
|
class ScrollViewMock extends BaseComponent {
|
|
23
|
-
render(): React.
|
|
23
|
+
render(): React.MixedElement {
|
|
24
24
|
return (
|
|
25
25
|
<RCTScrollView {...this.props}>
|
|
26
26
|
{this.props.refreshControl}
|
package/jest/renderer.js
CHANGED
|
@@ -16,7 +16,7 @@ import * as React from 'react';
|
|
|
16
16
|
import TestRenderer from 'react-test-renderer';
|
|
17
17
|
|
|
18
18
|
export async function create(
|
|
19
|
-
Component: React.
|
|
19
|
+
Component: React.MixedElement,
|
|
20
20
|
): Promise<ReactTestRenderer> {
|
|
21
21
|
let component;
|
|
22
22
|
await TestRenderer.act(async () => {
|
|
@@ -33,7 +33,7 @@ export async function unmount(testRenderer: ReactTestRenderer) {
|
|
|
33
33
|
|
|
34
34
|
export async function update(
|
|
35
35
|
testRenderer: ReactTestRenderer,
|
|
36
|
-
element: React.
|
|
36
|
+
element: React.MixedElement,
|
|
37
37
|
) {
|
|
38
38
|
await TestRenderer.act(async () => {
|
|
39
39
|
testRenderer.update(element);
|