@office-iss/react-native-win32 0.76.2 → 0.77.0-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -1
- package/.flowconfig +5 -1
- package/CHANGELOG.json +179 -53
- package/CHANGELOG.md +82 -28
- package/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts +1 -0
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +13 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +2 -2
- package/Libraries/Animated/NativeAnimatedAllowlist.js +20 -9
- package/Libraries/Animated/animations/Animation.js +60 -25
- package/Libraries/Animated/animations/DecayAnimation.js +26 -38
- package/Libraries/Animated/animations/SpringAnimation.js +33 -39
- package/Libraries/Animated/animations/TimingAnimation.js +34 -42
- package/Libraries/Animated/components/AnimatedFlatList.js +1 -1
- package/Libraries/Animated/components/AnimatedSectionList.js +3 -1
- package/Libraries/Animated/createAnimatedComponent.js +60 -33
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +1 -1
- package/Libraries/Animated/nodes/AnimatedNode.js +39 -45
- package/Libraries/Animated/nodes/AnimatedObject.js +13 -3
- package/Libraries/Animated/nodes/AnimatedProps.js +104 -46
- package/Libraries/Animated/nodes/AnimatedStyle.js +116 -39
- package/Libraries/Animated/nodes/AnimatedTransform.js +56 -23
- package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -3
- package/Libraries/Animated/useAnimatedProps.js +41 -35
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +77 -5
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +82 -5
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +4 -4
- package/Libraries/Components/Button.js +9 -4
- package/Libraries/Components/Button.win32.js +12 -4
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +3 -1
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +7 -0
- package/Libraries/Components/Pressable/Pressable.js +4 -4
- package/Libraries/Components/Pressable/Pressable.win32.js +4 -4
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +13 -7
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +3 -2
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +4 -4
- package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +4 -4
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +0 -1
- package/Libraries/Components/ScrollView/ScrollView.js +49 -88
- package/Libraries/Components/ScrollView/ScrollViewCommands.js +1 -1
- package/Libraries/Components/ScrollView/ScrollViewContext.js +2 -0
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +0 -2
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +8 -9
- package/Libraries/Components/Switch/Switch.js +8 -6
- package/Libraries/Components/TextInput/InputAccessoryView.js +1 -1
- package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +4 -4
- package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +6 -4
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +2 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +27 -4
- package/Libraries/Components/TextInput/TextInput.flow.js +36 -19
- package/Libraries/Components/TextInput/TextInput.js +37 -13
- package/Libraries/Components/TextInput/TextInput.win32.js +40 -15
- package/Libraries/Components/TextInput/TextInputState.js +11 -13
- package/Libraries/Components/TextInput/TextInputState.win32.js +13 -16
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +3 -0
- package/Libraries/Components/Touchable/BoundingDimensions.js +11 -3
- package/Libraries/Components/Touchable/Position.js +7 -2
- package/Libraries/Components/Touchable/Touchable.js +4 -0
- package/Libraries/Components/Touchable/Touchable.win32.js +4 -0
- package/Libraries/Components/Touchable/TouchableBounce.js +6 -2
- package/Libraries/Components/Touchable/TouchableHighlight.js +5 -5
- package/Libraries/Components/Touchable/TouchableOpacity.js +6 -5
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -2
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +6 -1
- package/Libraries/Components/View/View.js +4 -4
- package/Libraries/Components/View/View.win32.js +4 -4
- package/Libraries/Components/View/ViewNativeComponent.js +6 -98
- package/Libraries/Components/View/ViewPropTypes.d.ts +7 -0
- package/Libraries/Components/View/ViewPropTypes.js +0 -3
- package/Libraries/Components/View/ViewPropTypes.win32.js +0 -3
- package/Libraries/Components/View/ViewWin32.js +1 -0
- package/Libraries/Core/ExceptionsManager.js +50 -29
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/__mocks__/NativeExceptionsManager.js +0 -1
- package/Libraries/Core/setUpBatchedBridge.js +1 -10
- package/Libraries/Core/setUpDeveloperTools.js +1 -5
- package/Libraries/Core/setUpErrorHandling.js +20 -18
- package/Libraries/Core/setUpReactDevTools.js +107 -8
- package/Libraries/Core/setUpSegmentFetcher.js +1 -0
- package/Libraries/Core/setUpTimers.js +21 -18
- package/Libraries/Debugging/DebuggingOverlay.js +4 -5
- package/Libraries/Image/AssetSourceResolver.js +12 -1
- package/Libraries/Image/Image.android.js +1 -5
- package/Libraries/Image/Image.d.ts +20 -29
- package/Libraries/Image/Image.ios.js +0 -2
- package/Libraries/Image/Image.win32.js +0 -2
- package/Libraries/Image/ImageBackground.js +2 -5
- package/Libraries/Image/ImageProps.js +7 -6
- package/Libraries/Image/ImageResizeMode.d.ts +8 -1
- package/Libraries/Image/ImageResizeMode.js +4 -1
- package/Libraries/Image/ImageSource.d.ts +0 -2
- package/Libraries/Image/ImageSource.js +0 -2
- package/Libraries/Image/ImageTypes.flow.js +11 -9
- package/Libraries/Image/ImageUtils.js +6 -3
- package/Libraries/Image/ImageViewNativeComponent.js +5 -3
- package/Libraries/Inspector/Inspector.js +1 -0
- package/Libraries/Inspector/Inspector.win32.js +2 -1
- package/Libraries/Inspector/NetworkOverlay.js +4 -0
- package/Libraries/Inspector/ReactDevToolsOverlay.js +8 -14
- package/Libraries/Inspector/getInspectorDataForViewAtPoint.js +3 -5
- package/Libraries/Interaction/InteractionManager.js +6 -1
- package/Libraries/Interaction/InteractionManagerStub.js +176 -0
- package/Libraries/Interaction/TouchHistoryMath.js +22 -19
- package/Libraries/JSInspector/NetworkAgent.js +1 -1
- package/Libraries/Lists/FlatList.d.ts +1 -2
- package/Libraries/Lists/FlatList.js +2 -2
- package/Libraries/Lists/SectionListModern.js +7 -7
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +2 -2
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +3 -3
- package/Libraries/LogBox/LogBox.js +18 -5
- package/Libraries/LogBox/LogBoxInspectorContainer.js +1 -1
- package/Libraries/LogBox/LogBoxNotificationContainer.js +2 -2
- package/Libraries/LogBox/UI/AnsiHighlight.js +26 -17
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +6 -1
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +6 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +1 -1
- package/Libraries/LogBox/UI/LogBoxMessage.js +2 -2
- package/Libraries/Modal/Modal.d.ts +12 -0
- package/Libraries/Modal/Modal.js +31 -4
- package/Libraries/NativeComponent/BaseViewConfig.android.js +72 -1
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +2 -1
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +3 -11
- package/Libraries/NativeComponent/NativeComponentRegistry.js +3 -3
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -1
- package/Libraries/Network/FormData.js +11 -3
- package/Libraries/Network/XHRInterceptor.js +63 -14
- package/Libraries/Network/XMLHttpRequest.js +26 -1
- package/Libraries/NewAppScreen/components/HermesBadge.js +1 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +49 -2
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +4 -4
- package/Libraries/Pressability/HoverState.js +2 -0
- package/Libraries/Pressability/HoverState.win32.js +2 -0
- package/Libraries/Pressability/Pressability.js +2 -3
- package/Libraries/Pressability/Pressability.win32.js +2 -3
- package/Libraries/Pressability/usePressability.js +4 -1
- package/Libraries/ReactNative/AppContainer.js +1 -1
- package/Libraries/ReactNative/AppRegistry.js +1 -11
- package/Libraries/ReactNative/DisplayMode.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -3
- package/Libraries/ReactNative/RendererImplementation.js +18 -17
- package/Libraries/ReactNative/getCachedComponentWithDebugName.js +1 -3
- package/Libraries/ReactNative/renderApplication.js +9 -8
- package/Libraries/ReactNative/requireNativeComponent.js +5 -2
- package/Libraries/Renderer/shims/ReactFabric.js +3 -3
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
- package/Libraries/Renderer/shims/ReactNative.js +3 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.js +22 -35
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +5 -6
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
- package/Libraries/StyleSheet/StyleSheet.js +7 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +7 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +13 -2
- package/Libraries/StyleSheet/StyleSheetTypes.js +24 -6
- package/Libraries/StyleSheet/processBackgroundImage.js +87 -110
- package/Libraries/StyleSheet/processTransform.js +3 -34
- package/Libraries/Text/Text.js +248 -249
- package/Libraries/Text/Text.win32.js +282 -295
- package/Libraries/Text/TextNativeComponent.js +0 -1
- package/Libraries/TurboModule/TurboModuleRegistry.js +5 -5
- package/Libraries/Types/CoreEventTypes.d.ts +3 -10
- package/Libraries/Types/CoreEventTypes.js +4 -6
- package/Libraries/Types/CoreEventTypes.win32.js +4 -6
- package/Libraries/Utilities/Appearance.js +3 -1
- package/Libraries/Utilities/BackHandler.android.js +6 -18
- package/Libraries/Utilities/BackHandler.d.ts +0 -4
- package/Libraries/Utilities/BackHandler.ios.js +0 -7
- package/Libraries/Utilities/BackHandler.win32.js +6 -18
- package/Libraries/Utilities/FocusManager.win32.js +1 -1
- package/Libraries/Utilities/HMRClient.js +3 -4
- package/Libraries/Utilities/Platform.flow.js +2 -2
- package/Libraries/Utilities/Platform.flow.win32.js +3 -2
- package/Libraries/Utilities/__mocks__/BackHandler.js +3 -8
- package/Libraries/Utilities/codegenNativeComponent.js +1 -1
- package/Libraries/Utilities/useMergeRefs.js +26 -7
- package/Libraries/WebSocket/WebSocketEvent.js +4 -1
- package/Libraries/WebSocket/WebSocketInterceptor.js +31 -13
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +6 -5
- package/Libraries/promiseRejectionTrackingOptions.js +1 -1
- package/index.js +10 -3
- package/index.win32.js +10 -3
- package/jest/setup.js +36 -1
- package/overrides.json +37 -37
- package/package.json +20 -20
- package/src/private/animated/NativeAnimatedHelper.js +18 -16
- package/src/private/animated/NativeAnimatedHelper.win32.js +18 -15
- package/src/private/animated/useAnimatedPropsMemo.js +356 -0
- package/src/private/components/HScrollViewNativeComponents.js +1 -27
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +11 -8
- package/src/private/components/VScrollViewNativeComponents.js +2 -25
- package/src/private/debugging/ReactDevToolsSettingsManager.android.js +20 -0
- package/src/private/debugging/ReactDevToolsSettingsManager.ios.js +30 -0
- package/src/private/debugging/ReactDevToolsSettingsManager.win32.js +20 -0
- package/src/private/{fusebox → debugging}/setUpFuseboxReactDevToolsDispatcher.js +6 -0
- package/src/private/devmenu/DevMenu.d.ts +20 -0
- package/src/private/devmenu/DevMenu.js +31 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +95 -86
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +8 -2
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +17 -19
- package/src/private/fusebox/specs/NativeReactDevToolsRuntimeSettingsModule.js +34 -0
- package/src/private/setup/setUpDOM.js +14 -6
- package/src/private/setup/setUpMutationObserver.js +5 -0
- package/src/private/specs/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -0
- package/src/private/specs/components/RCTModalHostViewNativeComponent.js +8 -0
- package/src/private/specs/modules/NativeAccessibilityInfo.js +9 -0
- package/src/private/specs/modules/NativeAccessibilityInfoWin32.js +9 -0
- package/src/private/specs/modules/NativeAccessibilityManager.js +4 -0
- package/src/private/specs/modules/NativeActionSheetManager.js +2 -0
- package/src/private/specs/modules/NativeAppearance.js +4 -10
- package/src/private/specs/modules/NativeExceptionsManager.js +0 -12
- package/src/private/specs/modules/{NativeDevToolsSettingsManager.js → NativeReactDevToolsSettingsManager.js} +3 -5
- package/src/private/webapis/dom/geometry/DOMRect.js +2 -2
- package/src/private/webapis/dom/geometry/DOMRectReadOnly.js +2 -2
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +2 -3
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +102 -11
- package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +26 -0
- package/src/private/webapis/intersectionobserver/IntersectionObserverManager.js +1 -0
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
- package/src/private/webapis/intersectionobserver/specs/__mocks__/NativeIntersectionObserver.js +9 -0
- package/src/private/webapis/performance/EventTiming.js +13 -8
- package/src/private/webapis/performance/Performance.js +66 -73
- package/src/private/webapis/performance/PerformanceEntry.js +2 -5
- package/src/private/webapis/performance/PerformanceObserver.js +65 -164
- package/src/private/webapis/performance/RawPerformanceEntry.js +1 -1
- package/src/private/webapis/performance/UserTiming.js +11 -7
- package/src/private/webapis/performance/Utilities.js +18 -0
- package/src/private/webapis/performance/specs/NativePerformance.js +71 -2
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +267 -0
- package/src-win/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
- package/src-win/Libraries/Components/View/ViewPropTypes.d.ts +7 -0
- package/types/index.d.ts +1 -1
- package/types/public/ReactNativeTypes.d.ts +4 -8
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.android.js +0 -35
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.d.ts +0 -20
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.ios.js +0 -49
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.win32.js +0 -35
- package/Libraries/DevToolsSettings/NativeDevToolsSettingsManager.js +0 -13
- package/Libraries/ReactNative/ReactFabricInternals.js +0 -17
- package/src/private/components/useSyncOnScroll.js +0 -48
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +0 -61
- package/src/private/webapis/performance/specs/__mocks__/NativePerformance.js +0 -67
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceObserver.js +0 -127
- package/types/experimental.d.ts +0 -59
- /package/src/private/{fusebox → debugging}/FuseboxSessionObserver.js +0 -0
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {EventSubscription} from '../../../Libraries/vendor/emitter/EventEmitter';
|
|
12
11
|
import type {EventConfig} from '../../../Libraries/Animated/AnimatedEvent';
|
|
13
12
|
import type {
|
|
14
13
|
AnimationConfig,
|
|
@@ -18,13 +17,14 @@ import type {
|
|
|
18
17
|
AnimatedNodeConfig,
|
|
19
18
|
EventMapping,
|
|
20
19
|
} from '../../../Libraries/Animated/NativeAnimatedModule';
|
|
20
|
+
import type {EventSubscription} from '../../../Libraries/vendor/emitter/EventEmitter';
|
|
21
21
|
|
|
22
|
-
import
|
|
22
|
+
import NativeAnimatedNonTurboModule from '../../../Libraries/Animated/NativeAnimatedModule';
|
|
23
|
+
import NativeAnimatedTurboModule from '../../../Libraries/Animated/NativeAnimatedTurboModule';
|
|
23
24
|
import NativeEventEmitter from '../../../Libraries/EventEmitter/NativeEventEmitter';
|
|
24
25
|
import RCTDeviceEventEmitter from '../../../Libraries/EventEmitter/RCTDeviceEventEmitter';
|
|
25
26
|
import Platform from '../../../Libraries/Utilities/Platform';
|
|
26
|
-
import
|
|
27
|
-
import NativeAnimatedTurboModule from '../../../Libraries/Animated/NativeAnimatedTurboModule';
|
|
27
|
+
import * as ReactNativeFeatureFlags from '../featureflags/ReactNativeFeatureFlags';
|
|
28
28
|
import invariant from 'invariant';
|
|
29
29
|
import nullthrows from 'nullthrows';
|
|
30
30
|
|
|
@@ -46,7 +46,7 @@ const isSingleOpBatching =
|
|
|
46
46
|
Platform.OS === 'android' &&
|
|
47
47
|
NativeAnimatedModule?.queueAndExecuteBatchedOperations != null &&
|
|
48
48
|
ReactNativeFeatureFlags.animatedShouldUseSingleOp();
|
|
49
|
-
let
|
|
49
|
+
let flushQueueImmediate = null;
|
|
50
50
|
|
|
51
51
|
const eventListenerGetValueCallbacks: {
|
|
52
52
|
[number]: (value: number) => void,
|
|
@@ -142,9 +142,13 @@ const API = {
|
|
|
142
142
|
queueOperations = true;
|
|
143
143
|
if (
|
|
144
144
|
ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush() &&
|
|
145
|
-
|
|
145
|
+
flushQueueImmediate
|
|
146
146
|
) {
|
|
147
|
-
|
|
147
|
+
if (ReactNativeFeatureFlags.enableAnimatedClearImmediateFix()) {
|
|
148
|
+
clearImmediate(flushQueueImmediate);
|
|
149
|
+
} else {
|
|
150
|
+
clearTimeout(flushQueueImmediate);
|
|
151
|
+
}
|
|
148
152
|
}
|
|
149
153
|
},
|
|
150
154
|
|
|
@@ -161,9 +165,9 @@ const API = {
|
|
|
161
165
|
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
|
162
166
|
|
|
163
167
|
if (ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush()) {
|
|
164
|
-
const
|
|
165
|
-
clearImmediate(
|
|
166
|
-
|
|
168
|
+
const prevImmediate = flushQueueImmediate;
|
|
169
|
+
clearImmediate(prevImmediate);
|
|
170
|
+
flushQueueImmediate = setImmediate(API.flushQueue);
|
|
167
171
|
} else {
|
|
168
172
|
API.flushQueue();
|
|
169
173
|
}
|
|
@@ -174,11 +178,11 @@ const API = {
|
|
|
174
178
|
/* [Windows #11041
|
|
175
179
|
// TODO: (T136971132)
|
|
176
180
|
invariant(
|
|
177
|
-
NativeAnimatedModule
|
|
181
|
+
NativeAnimatedModule,
|
|
178
182
|
'Native animated module is not available',
|
|
179
183
|
);
|
|
180
184
|
Windows] */
|
|
181
|
-
|
|
185
|
+
flushQueueImmediate = null;
|
|
182
186
|
|
|
183
187
|
if (singleOpQueue.length === 0) {
|
|
184
188
|
return;
|
|
@@ -195,12 +199,11 @@ const API = {
|
|
|
195
199
|
singleOpQueue.length = 0;
|
|
196
200
|
}
|
|
197
201
|
: (): void => {
|
|
198
|
-
// TODO: (T136971132)
|
|
199
202
|
invariant(
|
|
200
|
-
NativeAnimatedModule
|
|
203
|
+
NativeAnimatedModule,
|
|
201
204
|
'Native animated module is not available',
|
|
202
205
|
);
|
|
203
|
-
|
|
206
|
+
flushQueueImmediate = null;
|
|
204
207
|
|
|
205
208
|
if (queue.length === 0) {
|
|
206
209
|
return;
|
|
@@ -0,0 +1,356 @@
|
|
|
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
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type AnimatedProps from '../../../Libraries/Animated/nodes/AnimatedProps';
|
|
13
|
+
import type {AnimatedPropsAllowlist} from '../../../Libraries/Animated/nodes/AnimatedProps';
|
|
14
|
+
import type {AnimatedStyleAllowlist} from '../../../Libraries/Animated/nodes/AnimatedStyle';
|
|
15
|
+
|
|
16
|
+
import {AnimatedEvent} from '../../../Libraries/Animated/AnimatedEvent';
|
|
17
|
+
import AnimatedNode from '../../../Libraries/Animated/nodes/AnimatedNode';
|
|
18
|
+
import {isPlainObject} from '../../../Libraries/Animated/nodes/AnimatedObject';
|
|
19
|
+
import flattenStyle from '../../../Libraries/StyleSheet/flattenStyle';
|
|
20
|
+
import nullthrows from 'nullthrows';
|
|
21
|
+
import {useMemo, useState} from 'react';
|
|
22
|
+
|
|
23
|
+
type CompositeKey = {
|
|
24
|
+
style?: {[string]: CompositeKeyComponent},
|
|
25
|
+
[string]:
|
|
26
|
+
| CompositeKeyComponent
|
|
27
|
+
| AnimatedEvent
|
|
28
|
+
| $ReadOnlyArray<mixed>
|
|
29
|
+
| $ReadOnly<{[string]: mixed}>,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type CompositeKeyComponent =
|
|
33
|
+
| AnimatedNode
|
|
34
|
+
| Array<CompositeKeyComponent | null>
|
|
35
|
+
| {[string]: CompositeKeyComponent};
|
|
36
|
+
|
|
37
|
+
type $ReadOnlyCompositeKey = $ReadOnly<{
|
|
38
|
+
style?: $ReadOnly<{[string]: CompositeKeyComponent}>,
|
|
39
|
+
[string]:
|
|
40
|
+
| $ReadOnlyCompositeKeyComponent
|
|
41
|
+
| AnimatedEvent
|
|
42
|
+
| $ReadOnlyArray<mixed>
|
|
43
|
+
| $ReadOnly<{[string]: mixed}>,
|
|
44
|
+
}>;
|
|
45
|
+
|
|
46
|
+
type $ReadOnlyCompositeKeyComponent =
|
|
47
|
+
| AnimatedNode
|
|
48
|
+
| $ReadOnlyArray<$ReadOnlyCompositeKeyComponent | null>
|
|
49
|
+
| $ReadOnly<{[string]: $ReadOnlyCompositeKeyComponent}>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A hook that returns an `AnimatedProps` object that is memoized based on the
|
|
53
|
+
* subset of `props` that are instances of `AnimatedNode` or `AnimatedEvent`.
|
|
54
|
+
*/
|
|
55
|
+
export function useAnimatedPropsMemo(
|
|
56
|
+
create: () => AnimatedProps,
|
|
57
|
+
// TODO: Make this two separate arguments after the experiment is over. This
|
|
58
|
+
// is only an array-like structure to make it easier to experiment with this
|
|
59
|
+
// and `useMemo`.
|
|
60
|
+
[allowlist, props]: [?AnimatedPropsAllowlist, {[string]: mixed}],
|
|
61
|
+
): AnimatedProps {
|
|
62
|
+
const compositeKey = useMemo(
|
|
63
|
+
() => createCompositeKeyForProps(props, allowlist),
|
|
64
|
+
[allowlist, props],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const [state, setState] = useState<{
|
|
68
|
+
allowlist: ?AnimatedPropsAllowlist,
|
|
69
|
+
compositeKey: $ReadOnlyCompositeKey | null,
|
|
70
|
+
value: AnimatedProps,
|
|
71
|
+
}>(() => ({
|
|
72
|
+
allowlist,
|
|
73
|
+
compositeKey,
|
|
74
|
+
value: create(),
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
if (
|
|
78
|
+
state.allowlist !== allowlist ||
|
|
79
|
+
!areCompositeKeysEqual(state.compositeKey, compositeKey)
|
|
80
|
+
) {
|
|
81
|
+
setState({
|
|
82
|
+
allowlist,
|
|
83
|
+
compositeKey,
|
|
84
|
+
value: create(),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return state.value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new composite key for a `props` object that can be used to detect
|
|
92
|
+
* whether a new `AnimatedProps` instance must be created.
|
|
93
|
+
*
|
|
94
|
+
* - With an allowlist, those props are searched for `AnimatedNode` instances.
|
|
95
|
+
* - Without an allowlist, `style` is searched for `AnimatedNode` instances,
|
|
96
|
+
* but all other objects and arrays are included (not searched). We do not
|
|
97
|
+
* search objects and arrays without an allowlist in case they are very large
|
|
98
|
+
* data structures. We safely traverse `style` becuase it is bounded.
|
|
99
|
+
*
|
|
100
|
+
* Any `AnimatedEvent` instances at the first depth are always included.
|
|
101
|
+
*
|
|
102
|
+
* If `props` contains no `AnimatedNode` or `AnimatedEvent` instances, this
|
|
103
|
+
* returns null.
|
|
104
|
+
*/
|
|
105
|
+
export function createCompositeKeyForProps(
|
|
106
|
+
props: $ReadOnly<{[string]: mixed}>,
|
|
107
|
+
allowlist: ?AnimatedPropsAllowlist,
|
|
108
|
+
): $ReadOnlyCompositeKey | null {
|
|
109
|
+
let compositeKey: CompositeKey | null = null;
|
|
110
|
+
|
|
111
|
+
const keys = Object.keys(props);
|
|
112
|
+
for (let ii = 0, length = keys.length; ii < length; ii++) {
|
|
113
|
+
const key = keys[ii];
|
|
114
|
+
const value = props[key];
|
|
115
|
+
|
|
116
|
+
if (allowlist == null || hasOwn(allowlist, key)) {
|
|
117
|
+
let compositeKeyComponent;
|
|
118
|
+
if (key === 'style') {
|
|
119
|
+
// $FlowFixMe[incompatible-call] - `style` is a valid argument.
|
|
120
|
+
// $FlowFixMe[incompatible-type] - `flattenStyle` returns an object.
|
|
121
|
+
const flatStyle: ?{[string]: mixed} = flattenStyle(value);
|
|
122
|
+
if (flatStyle != null) {
|
|
123
|
+
compositeKeyComponent = createCompositeKeyForObject(
|
|
124
|
+
flatStyle,
|
|
125
|
+
allowlist?.style,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
} else if (
|
|
129
|
+
value instanceof AnimatedNode ||
|
|
130
|
+
value instanceof AnimatedEvent
|
|
131
|
+
) {
|
|
132
|
+
compositeKeyComponent = value;
|
|
133
|
+
} else if (Array.isArray(value)) {
|
|
134
|
+
compositeKeyComponent =
|
|
135
|
+
allowlist == null ? value : createCompositeKeyForArray(value);
|
|
136
|
+
} else if (isPlainObject(value)) {
|
|
137
|
+
compositeKeyComponent =
|
|
138
|
+
allowlist == null ? value : createCompositeKeyForObject(value);
|
|
139
|
+
}
|
|
140
|
+
if (compositeKeyComponent != null) {
|
|
141
|
+
if (compositeKey == null) {
|
|
142
|
+
compositeKey = {} as CompositeKey;
|
|
143
|
+
}
|
|
144
|
+
compositeKey[key] = compositeKeyComponent;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return compositeKey;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Creates a new composite key for an array that retains all values that are or
|
|
154
|
+
* contain `AnimatedNode` instances, and `null` for the rest.
|
|
155
|
+
*
|
|
156
|
+
* If `array` contains no `AnimatedNode` instances, this returns null.
|
|
157
|
+
*/
|
|
158
|
+
function createCompositeKeyForArray(
|
|
159
|
+
array: $ReadOnlyArray<mixed>,
|
|
160
|
+
): $ReadOnlyArray<$ReadOnlyCompositeKeyComponent | null> | null {
|
|
161
|
+
let compositeKey: Array<$ReadOnlyCompositeKeyComponent | null> | null = null;
|
|
162
|
+
|
|
163
|
+
for (let ii = 0, length = array.length; ii < length; ii++) {
|
|
164
|
+
const value = array[ii];
|
|
165
|
+
|
|
166
|
+
let compositeKeyComponent;
|
|
167
|
+
if (value instanceof AnimatedNode) {
|
|
168
|
+
compositeKeyComponent = value;
|
|
169
|
+
} else if (Array.isArray(value)) {
|
|
170
|
+
compositeKeyComponent = createCompositeKeyForArray(value);
|
|
171
|
+
} else if (isPlainObject(value)) {
|
|
172
|
+
compositeKeyComponent = createCompositeKeyForObject(value);
|
|
173
|
+
}
|
|
174
|
+
if (compositeKeyComponent != null) {
|
|
175
|
+
if (compositeKey == null) {
|
|
176
|
+
compositeKey = new Array<$ReadOnlyCompositeKeyComponent | null>(
|
|
177
|
+
array.length,
|
|
178
|
+
).fill(null);
|
|
179
|
+
}
|
|
180
|
+
compositeKey[ii] = compositeKeyComponent;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return compositeKey;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Creates a new composite key for an object that retains only properties that
|
|
189
|
+
* are or contain `AnimatedNode` instances.
|
|
190
|
+
*
|
|
191
|
+
* When used to create composite keys for `style` props:
|
|
192
|
+
*
|
|
193
|
+
* - With an allowlist, those properties are searched.
|
|
194
|
+
* - Without an allowlist, every property is searched.
|
|
195
|
+
*
|
|
196
|
+
* If `object` contains no `AnimatedNode` instances, this returns null.
|
|
197
|
+
*/
|
|
198
|
+
function createCompositeKeyForObject(
|
|
199
|
+
object: $ReadOnly<{[string]: mixed}>,
|
|
200
|
+
allowlist?: ?AnimatedStyleAllowlist,
|
|
201
|
+
): $ReadOnly<{[string]: $ReadOnlyCompositeKeyComponent}> | null {
|
|
202
|
+
let compositeKey: {[string]: $ReadOnlyCompositeKeyComponent} | null = null;
|
|
203
|
+
|
|
204
|
+
const keys = Object.keys(object);
|
|
205
|
+
for (let ii = 0, length = keys.length; ii < length; ii++) {
|
|
206
|
+
const key = keys[ii];
|
|
207
|
+
|
|
208
|
+
if (allowlist == null || hasOwn(allowlist, key)) {
|
|
209
|
+
const value = object[key];
|
|
210
|
+
|
|
211
|
+
let compositeKeyComponent;
|
|
212
|
+
if (value instanceof AnimatedNode) {
|
|
213
|
+
compositeKeyComponent = value;
|
|
214
|
+
} else if (Array.isArray(value)) {
|
|
215
|
+
compositeKeyComponent = createCompositeKeyForArray(value);
|
|
216
|
+
} else if (isPlainObject(value)) {
|
|
217
|
+
compositeKeyComponent = createCompositeKeyForObject(value);
|
|
218
|
+
}
|
|
219
|
+
if (compositeKeyComponent != null) {
|
|
220
|
+
if (compositeKey == null) {
|
|
221
|
+
compositeKey = {} as {[string]: $ReadOnlyCompositeKeyComponent};
|
|
222
|
+
}
|
|
223
|
+
compositeKey[key] = compositeKeyComponent;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return compositeKey;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function areCompositeKeysEqual(
|
|
232
|
+
maybePrev: $ReadOnlyCompositeKey | null,
|
|
233
|
+
maybeNext: $ReadOnlyCompositeKey | null,
|
|
234
|
+
allowlist: ?AnimatedPropsAllowlist,
|
|
235
|
+
): boolean {
|
|
236
|
+
if (maybePrev === maybeNext) {
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
if (maybePrev === null || maybeNext === null) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
// Help Flow retain the type refinements of these.
|
|
243
|
+
const prev = maybePrev;
|
|
244
|
+
const next = maybeNext;
|
|
245
|
+
|
|
246
|
+
const keys = Object.keys(prev);
|
|
247
|
+
const length = keys.length;
|
|
248
|
+
if (length !== Object.keys(next).length) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
for (let ii = 0; ii < length; ii++) {
|
|
252
|
+
const key = keys[ii];
|
|
253
|
+
if (!hasOwn(next, key)) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
const prevComponent = prev[key];
|
|
257
|
+
const nextComponent = next[key];
|
|
258
|
+
|
|
259
|
+
if (key === 'style') {
|
|
260
|
+
// We know style components are objects with non-mixed values.
|
|
261
|
+
if (
|
|
262
|
+
!areCompositeKeyComponentsEqual(
|
|
263
|
+
// $FlowIgnore[incompatible-cast]
|
|
264
|
+
prevComponent as $ReadOnlyCompositeKeyComponent,
|
|
265
|
+
// $FlowIgnore[incompatible-cast]
|
|
266
|
+
nextComponent as $ReadOnlyCompositeKeyComponent,
|
|
267
|
+
)
|
|
268
|
+
) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
} else if (
|
|
272
|
+
prevComponent instanceof AnimatedNode ||
|
|
273
|
+
prevComponent instanceof AnimatedEvent
|
|
274
|
+
) {
|
|
275
|
+
if (prevComponent !== nextComponent) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
// When `allowlist` is null, the components must be the same. Otherwise,
|
|
280
|
+
// we created the components using deep traversal, so deep compare them.
|
|
281
|
+
if (allowlist == null) {
|
|
282
|
+
if (prevComponent !== nextComponent) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
if (
|
|
287
|
+
!areCompositeKeyComponentsEqual(
|
|
288
|
+
// $FlowIgnore[incompatible-cast]
|
|
289
|
+
prevComponent as $ReadOnlyCompositeKeyComponent,
|
|
290
|
+
// $FlowIgnore[incompatible-cast]
|
|
291
|
+
nextComponent as $ReadOnlyCompositeKeyComponent,
|
|
292
|
+
)
|
|
293
|
+
) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function areCompositeKeyComponentsEqual(
|
|
303
|
+
prev: $ReadOnlyCompositeKeyComponent | null,
|
|
304
|
+
next: $ReadOnlyCompositeKeyComponent | null,
|
|
305
|
+
): boolean {
|
|
306
|
+
if (prev === next) {
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
if (prev instanceof AnimatedNode) {
|
|
310
|
+
return prev === next;
|
|
311
|
+
}
|
|
312
|
+
if (Array.isArray(prev)) {
|
|
313
|
+
if (!Array.isArray(next)) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
const length = prev.length;
|
|
317
|
+
if (length !== next.length) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
for (let ii = 0; ii < length; ii++) {
|
|
321
|
+
if (!areCompositeKeyComponentsEqual(prev[ii], next[ii])) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
if (isPlainObject(prev)) {
|
|
328
|
+
if (!isPlainObject(next)) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
const keys = Object.keys(prev);
|
|
332
|
+
const length = keys.length;
|
|
333
|
+
if (length !== Object.keys(next).length) {
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
for (let ii = 0; ii < length; ii++) {
|
|
337
|
+
const key = keys[ii];
|
|
338
|
+
if (
|
|
339
|
+
!hasOwn(nullthrows(next), key) ||
|
|
340
|
+
!areCompositeKeyComponentsEqual(prev[key], next[key])
|
|
341
|
+
) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Supported versions of JSC do not implement the newer Object.hasOwn. Remove
|
|
351
|
+
// this shim when they do.
|
|
352
|
+
// $FlowIgnore[method-unbinding]
|
|
353
|
+
const _hasOwnProp = Object.prototype.hasOwnProperty;
|
|
354
|
+
const hasOwn: (obj: $ReadOnly<{...}>, prop: string) => boolean =
|
|
355
|
+
// $FlowIgnore[method-unbinding]
|
|
356
|
+
Object.hasOwn ?? ((obj, prop) => _hasOwnProp.call(obj, prop));
|
|
@@ -12,44 +12,18 @@
|
|
|
12
12
|
import type {ScrollViewNativeProps} from '../../../Libraries/Components/ScrollView/ScrollViewNativeComponentType';
|
|
13
13
|
import type {ViewProps} from '../../../Libraries/Components/View/ViewPropTypes';
|
|
14
14
|
import type {HostComponent} from '../../../Libraries/Renderer/shims/ReactNativeTypes';
|
|
15
|
-
import type {TScrollViewNativeImperativeHandle} from './useSyncOnScroll';
|
|
16
15
|
|
|
17
16
|
import AndroidHorizontalScrollViewNativeComponent from '../../../Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent';
|
|
18
17
|
import ScrollContentViewNativeComponent from '../../../Libraries/Components/ScrollView/ScrollContentViewNativeComponent';
|
|
19
18
|
import ScrollViewNativeComponent from '../../../Libraries/Components/ScrollView/ScrollViewNativeComponent';
|
|
20
19
|
import Platform from '../../../Libraries/Utilities/Platform';
|
|
21
20
|
import AndroidHorizontalScrollContentViewNativeComponent from '../specs/components/AndroidHorizontalScrollContentViewNativeComponent';
|
|
22
|
-
import useSyncOnScroll from './useSyncOnScroll';
|
|
23
|
-
import * as React from 'react';
|
|
24
|
-
import {forwardRef} from 'react';
|
|
25
21
|
|
|
26
|
-
const
|
|
22
|
+
export const HScrollViewNativeComponent: HostComponent<ScrollViewNativeProps> =
|
|
27
23
|
Platform.OS === 'android'
|
|
28
24
|
? AndroidHorizontalScrollViewNativeComponent
|
|
29
25
|
: ScrollViewNativeComponent;
|
|
30
26
|
|
|
31
|
-
// TODO: After upgrading to React 19, remove `forwardRef` from this component.
|
|
32
|
-
export const HScrollViewNativeComponent: React.AbstractComponent<
|
|
33
|
-
ScrollViewNativeProps,
|
|
34
|
-
TScrollViewNativeImperativeHandle,
|
|
35
|
-
// $FlowExpectedError[incompatible-type] - Flow cannot model imperative handles, yet.
|
|
36
|
-
> = forwardRef(function HScrollViewNativeComponent(
|
|
37
|
-
props: ScrollViewNativeProps,
|
|
38
|
-
ref: ?React.RefSetter<TScrollViewNativeImperativeHandle | null>,
|
|
39
|
-
): React.Node {
|
|
40
|
-
const [componentRef, enableSyncOnScroll] = useSyncOnScroll(ref);
|
|
41
|
-
// NOTE: When `useSyncOnScroll` triggers an update, `props` will not have
|
|
42
|
-
// changed. Notably, `props.children` will be the same, allowing React to
|
|
43
|
-
// bail out during reconciliation.
|
|
44
|
-
return (
|
|
45
|
-
<HScrollViewNativeComponentForPlatform
|
|
46
|
-
{...props}
|
|
47
|
-
ref={componentRef}
|
|
48
|
-
enableSyncOnScroll={enableSyncOnScroll}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
27
|
export const HScrollContentViewNativeComponent: HostComponent<ViewProps> =
|
|
54
28
|
Platform.OS === 'android'
|
|
55
29
|
? AndroidHorizontalScrollContentViewNativeComponent
|
|
@@ -10,19 +10,22 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type {ViewProps} from '../../../Libraries/Components/View/ViewPropTypes';
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
import View from '../../../Libraries/Components/View/View';
|
|
15
|
+
import UIManager from '../../../Libraries/ReactNative/UIManager';
|
|
16
|
+
import Platform from '../../../Libraries/Utilities/Platform';
|
|
15
17
|
import * as React from 'react';
|
|
16
18
|
|
|
17
|
-
const exported:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const exported: component(
|
|
20
|
+
ref?: React.RefSetter<React.ElementRef<typeof View>>,
|
|
21
|
+
...ViewProps
|
|
22
|
+
) = Platform.select({
|
|
21
23
|
ios: require('../../../src/private/specs/components/RCTSafeAreaViewNativeComponent')
|
|
22
24
|
.default,
|
|
23
|
-
android:
|
|
24
|
-
require('../../../src/private/specs/components/RCTSafeAreaViewNativeComponent')
|
|
25
|
-
|
|
25
|
+
android: UIManager.hasViewManagerConfig('RCTSafeAreaView')
|
|
26
|
+
? require('../../../src/private/specs/components/RCTSafeAreaViewNativeComponent')
|
|
27
|
+
.default
|
|
28
|
+
: View,
|
|
26
29
|
default: View,
|
|
27
30
|
});
|
|
28
31
|
|
|
@@ -12,37 +12,14 @@
|
|
|
12
12
|
import type {ScrollViewNativeProps} from '../../../Libraries/Components/ScrollView/ScrollViewNativeComponentType';
|
|
13
13
|
import type {ViewProps} from '../../../Libraries/Components/View/ViewPropTypes';
|
|
14
14
|
import type {HostComponent} from '../../../Libraries/Renderer/shims/ReactNativeTypes';
|
|
15
|
-
import type {TScrollViewNativeImperativeHandle} from './useSyncOnScroll';
|
|
16
15
|
|
|
17
16
|
import ScrollContentViewNativeComponent from '../../../Libraries/Components/ScrollView/ScrollContentViewNativeComponent';
|
|
18
17
|
import ScrollViewNativeComponent from '../../../Libraries/Components/ScrollView/ScrollViewNativeComponent';
|
|
19
18
|
import View from '../../../Libraries/Components/View/View';
|
|
20
19
|
import Platform from '../../../Libraries/Utilities/Platform';
|
|
21
|
-
import useSyncOnScroll from './useSyncOnScroll';
|
|
22
|
-
import * as React from 'react';
|
|
23
|
-
import {forwardRef} from 'react';
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
ScrollViewNativeProps,
|
|
28
|
-
TScrollViewNativeImperativeHandle,
|
|
29
|
-
// $FlowExpectedError[incompatible-type] - Flow cannot model imperative handles, yet.
|
|
30
|
-
> = forwardRef(function VScrollViewNativeComponent(
|
|
31
|
-
props: ScrollViewNativeProps,
|
|
32
|
-
ref: ?React.RefSetter<TScrollViewNativeImperativeHandle | null>,
|
|
33
|
-
): React.Node {
|
|
34
|
-
const [componentRef, enableSyncOnScroll] = useSyncOnScroll(ref);
|
|
35
|
-
// NOTE: When `useSyncOnScroll` triggers an update, `props` will not have
|
|
36
|
-
// changed. Notably, `props.children` will be the same, allowing React to
|
|
37
|
-
// bail out during reconciliation.
|
|
38
|
-
return (
|
|
39
|
-
<ScrollViewNativeComponent
|
|
40
|
-
{...props}
|
|
41
|
-
ref={componentRef}
|
|
42
|
-
enableSyncOnScroll={enableSyncOnScroll}
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
});
|
|
21
|
+
export const VScrollViewNativeComponent: HostComponent<ScrollViewNativeProps> =
|
|
22
|
+
ScrollViewNativeComponent;
|
|
46
23
|
|
|
47
24
|
export const VScrollContentViewNativeComponent: HostComponent<ViewProps> =
|
|
48
25
|
Platform.OS === 'android' ? View : ScrollContentViewNativeComponent;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import NativeReactDevToolsSettingsManager from '../specs/modules/NativeReactDevToolsSettingsManager';
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
setGlobalHookSettings(settings: string) {
|
|
15
|
+
NativeReactDevToolsSettingsManager?.setGlobalHookSettings(settings);
|
|
16
|
+
},
|
|
17
|
+
getGlobalHookSettings(): ?string {
|
|
18
|
+
return NativeReactDevToolsSettingsManager?.getGlobalHookSettings();
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
import Settings from '../../../Libraries/Settings/Settings';
|
|
12
|
+
|
|
13
|
+
const GLOBAL_HOOK_SETTINGS = 'ReactDevTools::HookSettings';
|
|
14
|
+
|
|
15
|
+
const ReactDevToolsSettingsManager = {
|
|
16
|
+
setGlobalHookSettings(settings: string): void {
|
|
17
|
+
Settings.set({
|
|
18
|
+
[GLOBAL_HOOK_SETTINGS]: settings,
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
getGlobalHookSettings(): ?string {
|
|
22
|
+
const value = Settings.get(GLOBAL_HOOK_SETTINGS);
|
|
23
|
+
if (typeof value === 'string') {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports = ReactDevToolsSettingsManager;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import NativeReactDevToolsSettingsManager from '../specs/modules/NativeReactDevToolsSettingsManager';
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
setGlobalHookSettings(settings: string) {
|
|
15
|
+
NativeReactDevToolsSettingsManager?.setGlobalHookSettings(settings);
|
|
16
|
+
},
|
|
17
|
+
getGlobalHookSettings(): ?string {
|
|
18
|
+
return NativeReactDevToolsSettingsManager?.getGlobalHookSettings();
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -62,6 +62,12 @@ export class Domain {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Globally bound object providing a hook for React DevTools runtime API calls
|
|
67
|
+
* over CDP.
|
|
68
|
+
*
|
|
69
|
+
* @see {@link ./__docs__/FuseboxReactDevToolsDispatcher.excalidraw-embedded.png}
|
|
70
|
+
*/
|
|
65
71
|
class FuseboxReactDevToolsDispatcher {
|
|
66
72
|
static #domainNameToDomainMap: Map<DomainName, Domain> = new Map();
|
|
67
73
|
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* The DevMenu module exposes methods for interacting with the Dev Menu in development.
|
|
12
|
+
*/
|
|
13
|
+
export interface DevMenuStatic {
|
|
14
|
+
/**
|
|
15
|
+
* Show the Dev Menu.
|
|
16
|
+
*/
|
|
17
|
+
show(): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const DevMenu: DevMenuStatic;
|