diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js index 5393467cb7e69d..2c6a8c98e9ccd4 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ArrayPropsNativeComponent.js @@ -8,9 +8,9 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; import type {ImageSource} from 'react-native/Libraries/Image/ImageSource'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet'; import type { DimensionValue, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js index 94fe74cddfe4df..b04ff5bb9ef581 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/BooleanPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {WithDefault} from 'react-native/Libraries/Types/CodegenTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js index 8a0a713fc7bc78..f35404e4e15aea 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ColorPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/DimensionPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/DimensionPropNativeComponent.js index 6628556b19bf86..3ce62bf78c5cf9 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/DimensionPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/DimensionPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {DimensionValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EdgeInsetsPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EdgeInsetsPropNativeComponent.js index 821206e7e12453..f8100559d1835f 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EdgeInsetsPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EdgeInsetsPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js index c2146683c52901..0a6abd2eaca615 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EnumPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {WithDefault} from 'react-native/Libraries/Types/CodegenTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js index 4e1f549ec8dc22..3ebaafc43fcc39 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventNestedObjectPropsNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { BubblingEventHandler, Int32, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js index 79779aa6f71fe7..89da4ee874b8fa 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/EventPropsNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { BubblingEventHandler, DirectEventHandler, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js index cceb20370ae198..fbe522dd9847bb 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/FloatPropsNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { Float, WithDefault, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js index 7631051aab4cf8..c4842e015c232b 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ImagePropNativeComponent.js @@ -8,9 +8,9 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; import type {ImageSource} from 'react-native/Libraries/Image/ImageSource'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js index 5c1aeb87183a7c..4f709255122127 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/IntegerPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { Int32, WithDefault, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js index 6433a985a04643..ae2ca719f949f3 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/InterfaceOnlyNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { BubblingEventHandler, WithDefault, diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/MixedPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/MixedPropNativeComponent.js index 240ab41773f1d0..2a70de5afa9ceb 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/MixedPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/MixedPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {UnsafeMixed} from 'react-native/Libraries/Types/CodegenTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js index b0c230c47e687d..a74b7214a47dc1 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/MultiNativePropNativeComponent.js @@ -8,9 +8,9 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; import type {ImageSource} from 'react-native/Libraries/Image/ImageSource'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet'; import type {PointValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js index f1bc3bb102cc42..6c0fad9d9da6e3 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/NoPropsNoEventsNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/ObjectPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/ObjectPropsNativeComponent.js index dceb916b3c4dfa..dc3f8543cace4b 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/ObjectPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/ObjectPropsNativeComponent.js @@ -8,9 +8,9 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; import type {ImageSource} from 'react-native/Libraries/Image/ImageSource'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet'; import type {PointValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; import type { diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js index a9de5a9564ed63..f3b91fff48253b 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/PointPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {PointValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js index 6117f8a9b38c7f..a4775a2fb735d3 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/components/StringPropNativeComponent.js @@ -8,8 +8,8 @@ * @flow strict-local */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {WithDefault} from 'react-native/Libraries/Types/CodegenTypes'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js b/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js index 80945db5671731..2961eb8f361fdf 100644 --- a/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js +++ b/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js @@ -8,8 +8,8 @@ * @format */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { DirectEventHandler, Int32, diff --git a/packages/react-native-test-library/src/SampleNativeComponent.js b/packages/react-native-test-library/src/SampleNativeComponent.js index 05557d73360535..854db39f005afd 100644 --- a/packages/react-native-test-library/src/SampleNativeComponent.js +++ b/packages/react-native-test-library/src/SampleNativeComponent.js @@ -8,8 +8,8 @@ * @format */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { BubblingEventHandler, Double, diff --git a/packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js b/packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js index ccae5960ac2106..c42e4ac4afbf3d 100644 --- a/packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +++ b/packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js @@ -8,7 +8,7 @@ * @format */ -import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {EventSubscription} from '../../vendor/emitter/EventEmitter'; import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter'; diff --git a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js index d251a3634b64f2..140b5457b2785c 100644 --- a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -9,7 +9,7 @@ */ 'use strict'; -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; import type {ViewProps} from '../View/ViewPropTypes'; import StyleSheet, {type ColorValue} from '../../StyleSheet/StyleSheet'; diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index 2b11746b6483f5..a411b9ff9c9419 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -8,12 +8,12 @@ * @format */ -import type {AccessibilityRole} from '../../Components/View/ViewAccessibility'; import type { MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, -} from '../../Renderer/shims/ReactNativeTypes'; +} from '../../../src/private/types/HostInstance'; +import type {AccessibilityRole} from '../../Components/View/ViewAccessibility'; import type {ColorValue, ViewStyleProp} from '../../StyleSheet/StyleSheet'; import type {DirectEventHandler} from '../../Types/CodegenTypes'; diff --git a/packages/react-native/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js b/packages/react-native/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js index 8c1cf66970316b..698bee769952cf 100644 --- a/packages/react-native/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +++ b/packages/react-native/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js @@ -8,7 +8,7 @@ * @format */ -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; import type {ViewProps} from '../View/ViewPropTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; diff --git a/packages/react-native/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js b/packages/react-native/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js index f806848bbc7f7f..c6143672214538 100644 --- a/packages/react-native/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +++ b/packages/react-native/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js @@ -9,7 +9,8 @@ */ 'use strict'; -import type {HostComponent} from '../../../Renderer/shims/ReactNativeTypes'; + +import type {HostComponent} from '../../../../src/private/types/HostComponent'; import requireNativeComponent from '../../../ReactNative/requireNativeComponent'; import * as React from 'react'; diff --git a/packages/react-native/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js b/packages/react-native/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js index c99ea196ae3bfc..7f2179f5fde9b9 100644 --- a/packages/react-native/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +++ b/packages/react-native/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js @@ -8,10 +8,8 @@ * @format */ -import type { - HostComponent, - PartialViewConfig, -} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes'; import type {ScrollViewNativeProps as Props} from './ScrollViewNativeComponentType'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js b/packages/react-native/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js index 6ad8519391e861..d7ba7642f41537 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js @@ -8,10 +8,8 @@ * @flow strict-local */ -import type { - HostComponent, - PartialViewConfig, -} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes'; import type {ViewProps as Props} from '../View/ViewPropTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js index 8883cb47e76446..ed43fb3a815eee 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js @@ -8,14 +8,14 @@ * @flow strict-local */ -import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; import type {PointProp} from '../../StyleSheet/PointPropType'; import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; import type {ColorValue} from '../../StyleSheet/StyleSheet'; import type { - LayoutChangeEvent, GestureResponderEvent, + LayoutChangeEvent, ScrollEvent, } from '../../Types/CoreEventTypes'; import type {EventSubscription} from '../../vendor/emitter/EventEmitter'; diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollViewCommands.js b/packages/react-native/Libraries/Components/ScrollView/ScrollViewCommands.js index 056f3ff85b2957..20d971bd5e14b3 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollViewCommands.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollViewCommands.js @@ -8,7 +8,7 @@ * @flow strict-local */ -import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; import type {Double} from '../../Types/CodegenTypes'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js b/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js index 2709ce0d81559a..82f9c93baf348c 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollViewNativeComponent.js @@ -8,10 +8,8 @@ * @format */ -import type { - HostComponent, - PartialViewConfig, -} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes'; import type {ScrollViewNativeProps as Props} from './ScrollViewNativeComponentType'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; diff --git a/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index d9b847fc88cb22..566ac1576247c5 100644 --- a/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -8,10 +8,8 @@ * @format */ -import type { - HostComponent, - PartialViewConfig, -} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes'; import type { ColorValue, TextStyleProp, diff --git a/packages/react-native/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js b/packages/react-native/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js index 595006b1c40287..8c40af63337d00 100644 --- a/packages/react-native/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +++ b/packages/react-native/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js @@ -8,10 +8,8 @@ * @format */ -import type { - HostComponent, - PartialViewConfig, -} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes'; import type {TextInputNativeCommands} from './TextInputNativeCommands'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; diff --git a/packages/react-native/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js b/packages/react-native/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js index 306b30bde4d3f2..a52be63c5d1a9c 100644 --- a/packages/react-native/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +++ b/packages/react-native/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js @@ -8,10 +8,8 @@ * @format */ -import type { - HostComponent, - PartialViewConfig, -} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes'; import type {TextInputNativeCommands} from './TextInputNativeCommands'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js index 8746ba306f757a..99ee960007e124 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js @@ -8,11 +8,11 @@ * @format */ -import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type { GestureResponderEvent, - ScrollEvent, NativeSyntheticEvent, + ScrollEvent, } from '../../Types/CoreEventTypes'; import type {ViewProps} from '../View/ViewPropTypes'; diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index c8dff5c57298c5..7e82ca041366e1 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -8,12 +8,12 @@ * @format */ -import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {____TextStyle_Internal as TextStyleInternal} from '../../StyleSheet/StyleSheetTypes'; import type { GestureResponderEvent, - ScrollEvent, NativeSyntheticEvent, + ScrollEvent, } from '../../Types/CoreEventTypes'; import type {ViewProps} from '../View/ViewPropTypes'; import type {TextInputType} from './TextInput.flow'; diff --git a/packages/react-native/Libraries/Components/TextInput/TextInputState.js b/packages/react-native/Libraries/Components/TextInput/TextInputState.js index f0894d74c30427..949c7d09c93d3a 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInputState.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInputState.js @@ -12,12 +12,7 @@ // TextInputs. All calls relating to the keyboard should be funneled // through here. -import type { - HostInstance, - MeasureInWindowOnSuccessCallback, - MeasureLayoutOnSuccessCallback, - MeasureOnSuccessCallback, -} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import {Commands as AndroidTextInputCommands} from '../../Components/TextInput/AndroidTextInputNativeComponent'; import {Commands as iOSTextInputCommands} from '../../Components/TextInput/RCTSingelineTextInputNativeComponent'; @@ -26,18 +21,7 @@ const {findNodeHandle} = require('../../ReactNative/RendererProxy'); const Platform = require('../../Utilities/Platform').default; let currentlyFocusedInputRef: ?HostInstance = null; -const inputs = new Set<{ - blur(): void, - focus(): void, - measure(callback: MeasureOnSuccessCallback): void, - measureInWindow(callback: MeasureInWindowOnSuccessCallback): void, - measureLayout( - relativeToNativeNode: number | HostInstance, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail?: () => void, - ): void, - setNativeProps(nativeProps: {...}): void, -}>(); +const inputs = new Set(); function currentlyFocusedInput(): ?HostInstance { return currentlyFocusedInputRef; diff --git a/packages/react-native/Libraries/Components/View/ViewNativeComponent.js b/packages/react-native/Libraries/Components/View/ViewNativeComponent.js index b32b9065db73ec..ac34b460478622 100644 --- a/packages/react-native/Libraries/Components/View/ViewNativeComponent.js +++ b/packages/react-native/Libraries/Components/View/ViewNativeComponent.js @@ -8,10 +8,8 @@ * @format */ -import type { - HostComponent, - HostInstance, -} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; diff --git a/packages/react-native/Libraries/Debugging/DebuggingOverlayRegistry.js b/packages/react-native/Libraries/Debugging/DebuggingOverlayRegistry.js index d0c5ab4261a0f8..88b6512829781a 100644 --- a/packages/react-native/Libraries/Debugging/DebuggingOverlayRegistry.js +++ b/packages/react-native/Libraries/Debugging/DebuggingOverlayRegistry.js @@ -9,13 +9,13 @@ * @oncall react_native */ +import type {HostInstance} from '../../src/private/types/HostInstance'; import type ReactNativeElement from '../../src/private/webapis/dom/nodes/ReactNativeElement'; import type ReadOnlyElement from '../../src/private/webapis/dom/nodes/ReadOnlyElement'; import type { AppContainerRootViewRef, DebuggingOverlayRef, } from '../ReactNative/AppContainer-dev'; -import type {NativeMethods} from '../Renderer/shims/ReactNativeTypes'; import type { InstanceFromReactDevTools, ReactDevToolsAgent, @@ -51,7 +51,7 @@ type ModernNodeUpdate = { type LegacyNodeUpdate = { id: number, - instance: NativeMethods, + instance: HostInstance, color: string, }; @@ -95,7 +95,7 @@ class DebuggingOverlayRegistry { #getPublicInstanceFromInstance = ( instanceHandle: InstanceFromReactDevTools, - ): NativeMethods | null => { + ): HostInstance | null => { // `canonical.publicInstance` => Fabric if (instanceHandle.canonical?.publicInstance != null) { return instanceHandle.canonical?.publicInstance; @@ -134,7 +134,7 @@ class DebuggingOverlayRegistry { } #findLowestParentFromRegistryForInstanceLegacy( - instance: NativeMethods, + instance: HostInstance, ): ?DebuggingOverlayRegistrySubscriberProtocol { const candidates: Array = []; @@ -374,7 +374,7 @@ class DebuggingOverlayRegistry { require('../../src/private/webapis/dom/nodes/ReactNativeElement').default; const reactNativeElements: Array = []; - const legacyPublicInstances: Array = []; + const legacyPublicInstances: Array = []; for (const node of nodes) { const publicInstance = this.#getPublicInstanceFromInstance(node); @@ -442,10 +442,10 @@ class DebuggingOverlayRegistry { } // TODO: remove once DOM Node APIs are opt-in by default and Paper is no longer supported. - #onHighlightElementsLegacy(elements: Array): void { + #onHighlightElementsLegacy(elements: Array): void { const parentToElementsMap = new Map< DebuggingOverlayRegistrySubscriberProtocol, - Array, + Array, >(); for (const element of elements) { diff --git a/packages/react-native/Libraries/Image/ImageBackground.js b/packages/react-native/Libraries/Image/ImageBackground.js index 2eeee82b77311c..166fab9fbe1f4b 100644 --- a/packages/react-native/Libraries/Image/ImageBackground.js +++ b/packages/react-native/Libraries/Image/ImageBackground.js @@ -8,7 +8,7 @@ * @format */ -import type {HostInstance} from '../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../src/private/types/HostInstance'; import type {ImageBackgroundProps} from './ImageProps'; import View from '../Components/View/View'; diff --git a/packages/react-native/Libraries/Image/ImageViewNativeComponent.js b/packages/react-native/Libraries/Image/ImageViewNativeComponent.js index 6772d0a32162af..979e512a653e1e 100644 --- a/packages/react-native/Libraries/Image/ImageViewNativeComponent.js +++ b/packages/react-native/Libraries/Image/ImageViewNativeComponent.js @@ -8,12 +8,10 @@ * @format */ +import type {HostComponent} from '../../src/private/types/HostComponent'; +import type {HostInstance} from '../../src/private/types/HostInstance'; import type {ViewProps} from '../Components/View/ViewPropTypes'; -import type { - HostComponent, - HostInstance, - PartialViewConfig, -} from '../Renderer/shims/ReactNativeTypes'; +import type {PartialViewConfig} from '../Renderer/shims/ReactNativeTypes'; import type { ColorValue, DangerouslyImpreciseStyle, diff --git a/packages/react-native/Libraries/Image/TextInlineImageNativeComponent.js b/packages/react-native/Libraries/Image/TextInlineImageNativeComponent.js index ff0bdb28b9a229..87d344617b2215 100644 --- a/packages/react-native/Libraries/Image/TextInlineImageNativeComponent.js +++ b/packages/react-native/Libraries/Image/TextInlineImageNativeComponent.js @@ -10,11 +10,9 @@ 'use strict'; +import type {HostComponent} from '../../src/private/types/HostComponent'; import type {ViewProps} from '../Components/View/ViewPropTypes'; -import type { - HostComponent, - PartialViewConfig, -} from '../Renderer/shims/ReactNativeTypes'; +import type {PartialViewConfig} from '../Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../StyleSheet/StyleSheet'; import type {ImageResizeMode} from './ImageResizeMode'; diff --git a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js index a8842884bf6807..84f77f5b8e7131 100644 --- a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js +++ b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js @@ -8,8 +8,8 @@ * @format */ +import type {HostComponent} from '../../src/private/types/HostComponent'; import type { - HostComponent, PartialViewConfig, ViewConfig, } from '../Renderer/shims/ReactNativeTypes'; diff --git a/packages/react-native/Libraries/Pressability/Pressability.js b/packages/react-native/Libraries/Pressability/Pressability.js index 35f9e292f5591c..24614858116e00 100644 --- a/packages/react-native/Libraries/Pressability/Pressability.js +++ b/packages/react-native/Libraries/Pressability/Pressability.js @@ -8,12 +8,12 @@ * @format */ -import type {HostInstance} from '../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../src/private/types/HostInstance'; import type { BlurEvent, FocusEvent, - MouseEvent, GestureResponderEvent, + MouseEvent, } from '../Types/CoreEventTypes'; import SoundManager from '../Components/Sound/SoundManager'; diff --git a/packages/react-native/Libraries/ReactNative/FabricUIManager.js b/packages/react-native/Libraries/ReactNative/FabricUIManager.js index 97888852f30524..7766b3ee551b9d 100644 --- a/packages/react-native/Libraries/ReactNative/FabricUIManager.js +++ b/packages/react-native/Libraries/ReactNative/FabricUIManager.js @@ -10,13 +10,15 @@ 'use strict'; -import type {NativeElementReference} from '../../src/private/webapis/dom/nodes/specs/NativeDOM'; import type { - InternalInstanceHandle, - LayoutAnimationConfig, MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, +} from '../../src/private/types/HostInstance'; +import type {NativeElementReference} from '../../src/private/webapis/dom/nodes/specs/NativeDOM'; +import type { + InternalInstanceHandle, + LayoutAnimationConfig, Node, } from '../Renderer/shims/ReactNativeTypes'; import type {RootTag} from '../Types/RootTagTypes'; diff --git a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js index bfa7ae15392a6b..fd33718bb8181c 100644 --- a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +++ b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js @@ -11,10 +11,12 @@ import type { HostInstance, INativeMethods, - InternalInstanceHandle, MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, +} from '../../../src/private/types/HostInstance'; +import type { + InternalInstanceHandle, ViewConfig, } from '../../Renderer/shims/ReactNativeTypes'; diff --git a/packages/react-native/Libraries/ReactNative/RendererImplementation.js b/packages/react-native/Libraries/ReactNative/RendererImplementation.js index 7ff71985c03987..34613c645b6080 100644 --- a/packages/react-native/Libraries/ReactNative/RendererImplementation.js +++ b/packages/react-native/Libraries/ReactNative/RendererImplementation.js @@ -8,13 +8,11 @@ * @flow strict-local */ +import type {HostInstance} from '../../src/private/types/HostInstance'; import type { - HostComponent, - HostInstance, InternalInstanceHandle, Node, } from '../Renderer/shims/ReactNativeTypes'; -import type ReactFabricHostComponent from './ReactFabricPublicInstance/ReactFabricHostComponent'; import type {ElementRef, ElementType} from 'react'; import { @@ -136,8 +134,8 @@ export function isProfilingRenderer(): boolean { } export function isChildPublicInstance( - parentInstance: ReactFabricHostComponent | HostComponent, - childInstance: ReactFabricHostComponent | HostComponent, + parentInstance: HostInstance, + childInstance: HostInstance, ): boolean { return require('../Renderer/shims/ReactNative').default.isChildPublicInstance( parentInstance, diff --git a/packages/react-native/Libraries/ReactNative/requireNativeComponent.js b/packages/react-native/Libraries/ReactNative/requireNativeComponent.js index 44bfa0aa93f3dc..b9c8d575954bde 100644 --- a/packages/react-native/Libraries/ReactNative/requireNativeComponent.js +++ b/packages/react-native/Libraries/ReactNative/requireNativeComponent.js @@ -10,7 +10,7 @@ 'use strict'; -import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../src/private/types/HostComponent'; const createReactNativeComponentClass = require('../Renderer/shims/createReactNativeComponentClass').default; diff --git a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js index 4b78b97deadafb..c05b40e7a259bf 100644 --- a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js +++ b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js @@ -36,7 +36,19 @@ import typeof deepFreezeAndThrowOnMutationInDev from '../Utilities/deepFreezeAnd import typeof deepDiffer from '../Utilities/differ/deepDiffer'; import typeof Platform from '../Utilities/Platform'; +// Expose these types to the React renderer +export type { + HostInstance as PublicInstance, + + // These types are only necessary for Paper + INativeMethods as LegacyPublicInstance, + MeasureOnSuccessCallback, + MeasureInWindowOnSuccessCallback, + MeasureLayoutOnSuccessCallback, +} from '../../src/private/types/HostInstance'; + export type {PublicRootInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; +export type PublicTextInstance = ReturnType; // flowlint unsafe-getters-setters:off module.exports = { diff --git a/packages/react-native/Libraries/Text/TextNativeComponent.js b/packages/react-native/Libraries/Text/TextNativeComponent.js index dd51923357b160..b3402fa925e704 100644 --- a/packages/react-native/Libraries/Text/TextNativeComponent.js +++ b/packages/react-native/Libraries/Text/TextNativeComponent.js @@ -8,7 +8,7 @@ * @format */ -import type {HostComponent} from '../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../src/private/types/HostComponent'; import type {ProcessedColorValue} from '../StyleSheet/processColor'; import type {GestureResponderEvent} from '../Types/CoreEventTypes'; import type {TextProps} from './TextProps'; diff --git a/packages/react-native/Libraries/Types/CoreEventTypes.js b/packages/react-native/Libraries/Types/CoreEventTypes.js index 64df8f4a25151d..003ed7ec73a8ea 100644 --- a/packages/react-native/Libraries/Types/CoreEventTypes.js +++ b/packages/react-native/Libraries/Types/CoreEventTypes.js @@ -8,7 +8,7 @@ * @format */ -import type {HostInstance} from '../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../src/private/types/HostInstance'; export type NativeSyntheticEvent<+T> = $ReadOnly<{ bubbles: ?boolean, diff --git a/packages/react-native/Libraries/Types/ReactDevToolsTypes.js b/packages/react-native/Libraries/Types/ReactDevToolsTypes.js index 9772b01c4bde2b..658f96c33b831b 100644 --- a/packages/react-native/Libraries/Types/ReactDevToolsTypes.js +++ b/packages/react-native/Libraries/Types/ReactDevToolsTypes.js @@ -9,19 +9,15 @@ * @oncall react_native */ -import type {NativeMethods} from '../Renderer/shims/ReactNativeTypes'; - -type PublicInstance = { - ...NativeMethods, -}; +import type {HostInstance} from '../../src/private/types/HostInstance'; export type InstanceFromReactDevTools = - | PublicInstance + | HostInstance | { canonical?: - | PublicInstance // TODO: remove this variant when syncing the new version of the renderer from React to React Native. + | HostInstance | { - publicInstance?: PublicInstance, + publicInstance?: HostInstance, }, }; diff --git a/packages/react-native/Libraries/Utilities/__tests__/useMergeRefs-test.js b/packages/react-native/Libraries/Utilities/__tests__/useMergeRefs-test.js index 2b4684e5305654..93bbd764cb0997 100644 --- a/packages/react-native/Libraries/Utilities/__tests__/useMergeRefs-test.js +++ b/packages/react-native/Libraries/Utilities/__tests__/useMergeRefs-test.js @@ -9,7 +9,7 @@ * @oncall react_native */ -import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ReactTestRenderer} from 'react-test-renderer'; import View from '../../Components/View/View'; diff --git a/packages/react-native/Libraries/Utilities/__tests__/useRefEffect-test.js b/packages/react-native/Libraries/Utilities/__tests__/useRefEffect-test.js index ae6212f8cca1d9..4c0a5a4174706e 100644 --- a/packages/react-native/Libraries/Utilities/__tests__/useRefEffect-test.js +++ b/packages/react-native/Libraries/Utilities/__tests__/useRefEffect-test.js @@ -9,12 +9,7 @@ * @oncall react_native */ -import type { - HostInstance, - MeasureInWindowOnSuccessCallback, - MeasureLayoutOnSuccessCallback, - MeasureOnSuccessCallback, -} from '../../Renderer/shims/ReactNativeTypes.js'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import View from '../../Components/View/View'; import useRefEffect from '../useRefEffect'; @@ -31,18 +26,7 @@ function TestView({ childKey: ?string, effect: () => (() => void) | void, }) { - const ref = useRefEffect<{ - blur(): void, - focus(): void, - measure(callback: MeasureOnSuccessCallback): void, - measureInWindow(callback: MeasureInWindowOnSuccessCallback): void, - measureLayout( - relativeToNativeNode: number | HostInstance, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail?: () => void, - ): void, - setNativeProps(nativeProps: {...}): void, - }>(effect); + const ref = useRefEffect(effect); return ; } diff --git a/packages/react-native/Libraries/Utilities/codegenNativeComponent.js b/packages/react-native/Libraries/Utilities/codegenNativeComponent.js index ccb894b1397524..1a045be7aaae1c 100644 --- a/packages/react-native/Libraries/Utilities/codegenNativeComponent.js +++ b/packages/react-native/Libraries/Utilities/codegenNativeComponent.js @@ -10,7 +10,7 @@ // TODO: move this file to shims/ReactNative (requires React update and sync) -import type {HostComponent} from '../../Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../src/private/types/HostComponent'; import requireNativeComponent from '../../Libraries/ReactNative/requireNativeComponent'; import UIManager from '../ReactNative/UIManager'; diff --git a/packages/react-native/Libraries/__flowtests__/ReactNativeTypes-flowtest.js b/packages/react-native/Libraries/__flowtests__/ReactNativeTypes-flowtest.js index 18b72069229db7..d9340374288e25 100644 --- a/packages/react-native/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +++ b/packages/react-native/Libraries/__flowtests__/ReactNativeTypes-flowtest.js @@ -8,10 +8,8 @@ * @format */ -import type { - HostComponent, - HostInstance, -} from '../Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../src/private/types/HostComponent'; +import type {HostInstance} from '../../src/private/types/HostInstance'; import * as React from 'react'; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 1d84b370ca8f57..16c820902f777d 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -6976,8 +6976,8 @@ declare export function unstable_batchedUpdates( ): void; declare export function isProfilingRenderer(): boolean; declare export function isChildPublicInstance( - parentInstance: ReactFabricHostComponent | HostComponent, - childInstance: ReactFabricHostComponent | HostComponent + parentInstance: HostInstance, + childInstance: HostInstance ): boolean; declare export function getNodeFromInternalInstanceHandle( internalInstanceHandle: InternalInstanceHandle @@ -8100,16 +8100,13 @@ export type MouseEvent = NativeSyntheticEvent< `; exports[`public API should not change unintentionally Libraries/Types/ReactDevToolsTypes.js 1`] = ` -"type PublicInstance = { - ...NativeMethods, -}; -export type InstanceFromReactDevTools = - | PublicInstance +"export type InstanceFromReactDevTools = + | HostInstance | { canonical?: - | PublicInstance + | HostInstance | { - publicInstance?: PublicInstance, + publicInstance?: HostInstance, }, }; export type ReactDevToolsAgentEvents = { @@ -9016,10 +9013,8 @@ declare export default class EventEmitter< `; exports[`public API should not change unintentionally index.js.flow 1`] = ` -"export type { - HostComponent, - HostInstance, -} from \\"./Libraries/Renderer/shims/ReactNativeTypes\\"; +"export type { HostInstance } from \\"./src/private/types/HostInstance\\"; +export type { HostComponent } from \\"./src/private/types/HostComponent\\"; export { default as registerCallableModule } from \\"./Libraries/Core/registerCallableModule\\"; export { default as AccessibilityInfo } from \\"./Libraries/Components/AccessibilityInfo/AccessibilityInfo\\"; export { default as ActivityIndicator } from \\"./Libraries/Components/ActivityIndicator/ActivityIndicator\\"; @@ -9122,6 +9117,63 @@ exports[`public API should not change unintentionally src/private/setup/setUpPer " `; +exports[`public API should not change unintentionally src/private/types/HostComponent.js 1`] = ` +"export type HostComponent = component( + ref: React$RefSetter, + ...Config +); +" +`; + +exports[`public API should not change unintentionally src/private/types/HostInstance.js 1`] = ` +"export type MeasureOnSuccessCallback = ( + x: number, + y: number, + width: number, + height: number, + pageX: number, + pageY: number +) => void; +export type MeasureInWindowOnSuccessCallback = ( + x: number, + y: number, + width: number, + height: number +) => void; +export type MeasureLayoutOnSuccessCallback = ( + left: number, + top: number, + width: number, + height: number +) => void; +export interface INativeMethods { + blur(): void; + focus(): void; + measure(callback: MeasureOnSuccessCallback): void; + measureInWindow(callback: MeasureInWindowOnSuccessCallback): void; + measureLayout( + relativeToNativeNode: number | HostInstance, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail?: () => void + ): void; + setNativeProps(nativeProps: { ... }): void; +} +export type NativeMethods = $ReadOnly<{ + blur(): void, + focus(): void, + measure(callback: MeasureOnSuccessCallback): void, + measureInWindow(callback: MeasureInWindowOnSuccessCallback): void, + measureLayout( + relativeToNativeNode: number | HostInstance, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail?: () => void + ): void, + setNativeProps(nativeProps: { ... }): void, +}>; +export type HostInstance = NativeMethods; +" +`; + exports[`public API should not change unintentionally src/private/webapis/dom/nodes/ReactNativeDocument.js 1`] = ` "declare export default class ReactNativeDocument extends ReadOnlyNode { constructor( diff --git a/packages/react-native/Libraries/__tests__/public-api-test.js b/packages/react-native/Libraries/__tests__/public-api-test.js index dd61b28a29a6be..a8df7b6d723eee 100644 --- a/packages/react-native/Libraries/__tests__/public-api-test.js +++ b/packages/react-native/Libraries/__tests__/public-api-test.js @@ -44,6 +44,7 @@ const JS_LIBRARIES_FILES_IGNORE_PATTERNS = [ const JS_PRIVATE_FILES_INCLUDE_PATTERNS = [ 'setup/**/*.js', 'specs/**/*.js', + 'types/**/*.js', 'webapis/dom/geometry/*.js', 'webapis/dom/nodes/*.js', 'webapis/dom/oldstylecollections/*.js', diff --git a/packages/react-native/index.js.flow b/packages/react-native/index.js.flow index 2f3e99ce97d2f5..573dfa1f328543 100644 --- a/packages/react-native/index.js.flow +++ b/packages/react-native/index.js.flow @@ -17,10 +17,8 @@ // TODO(T215317597): Reconsider the pre-existing grouping of these APIs -export type { - HostComponent, - HostInstance, -} from './Libraries/Renderer/shims/ReactNativeTypes'; +export type {HostInstance} from './src/private/types/HostInstance'; +export type {HostComponent} from './src/private/types/HostComponent'; export {default as registerCallableModule} from './Libraries/Core/registerCallableModule'; // #region Components diff --git a/packages/react-native/src/private/components/HScrollViewNativeComponents.js b/packages/react-native/src/private/components/HScrollViewNativeComponents.js index 66ed7854c2d4fc..eac223ea025908 100644 --- a/packages/react-native/src/private/components/HScrollViewNativeComponents.js +++ b/packages/react-native/src/private/components/HScrollViewNativeComponents.js @@ -11,7 +11,7 @@ import type {ScrollViewNativeProps} from '../../../Libraries/Components/ScrollView/ScrollViewNativeComponentType'; import type {ViewProps} from '../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../types/HostComponent'; import AndroidHorizontalScrollViewNativeComponent from '../../../Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent'; import ScrollContentViewNativeComponent from '../../../Libraries/Components/ScrollView/ScrollContentViewNativeComponent'; diff --git a/packages/react-native/src/private/components/VScrollViewNativeComponents.js b/packages/react-native/src/private/components/VScrollViewNativeComponents.js index e110d875cf1a8a..2732cc16a28688 100644 --- a/packages/react-native/src/private/components/VScrollViewNativeComponents.js +++ b/packages/react-native/src/private/components/VScrollViewNativeComponents.js @@ -11,7 +11,7 @@ import type {ScrollViewNativeProps} from '../../../Libraries/Components/ScrollView/ScrollViewNativeComponentType'; import type {ViewProps} from '../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../types/HostComponent'; import ScrollContentViewNativeComponent from '../../../Libraries/Components/ScrollView/ScrollContentViewNativeComponent'; import ScrollViewNativeComponent from '../../../Libraries/Components/ScrollView/ScrollViewNativeComponent'; diff --git a/packages/react-native/src/private/inspector/getInspectorDataForViewAtPoint.js b/packages/react-native/src/private/inspector/getInspectorDataForViewAtPoint.js index 9d71b3b2b09d28..d3567831dedb21 100644 --- a/packages/react-native/src/private/inspector/getInspectorDataForViewAtPoint.js +++ b/packages/react-native/src/private/inspector/getInspectorDataForViewAtPoint.js @@ -8,10 +8,8 @@ * @flow */ -import type { - HostInstance, - TouchedViewDataAtPoint, -} from '../../../Libraries/Renderer/shims/ReactNativeTypes'; +import type {TouchedViewDataAtPoint} from '../../../Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from '../types/HostInstance'; const invariant = require('invariant'); diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js index d1115820ce8df8..e975dc6370236e 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js @@ -9,9 +9,9 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheet'; import type {WithDefault} from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js index 370368bbe89345..5ce22b3cd7fad7 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js @@ -9,7 +9,6 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheet'; import type { DirectEventHandler, @@ -17,6 +16,7 @@ import type { Int32, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNativeCommands'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js index d6c3fd0af28ffc..7aaaae4a9d74b1 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js @@ -9,7 +9,7 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js index 1b5d27f92614a1..8b1a90fe01e4a4 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js @@ -9,13 +9,13 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheet'; import type { DirectEventHandler, Float, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNativeCommands'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js index a57a61e5b9d15d..61a4fe98bd25a9 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js @@ -9,13 +9,13 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheet'; import type { BubblingEventHandler, Int32, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNativeCommands'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js index eea8fa72b5b810..7e4a11809b369a 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js @@ -9,8 +9,8 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ProcessedColorValue} from '../../../../Libraries/StyleSheet/processColor'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNativeCommands'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js index dede4a63b06d33..5d448b9a8abf5e 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js @@ -9,12 +9,12 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheet'; import type { Double, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js index 8de4e61b088dc4..cac73d80b792fe 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js @@ -9,13 +9,13 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheet'; import type { DirectEventHandler, Float, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNativeCommands'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js index 3f71ae25e20158..0157a3188af149 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js @@ -9,8 +9,8 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheet'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js index 2c7e58f7f557f2..bd79afdfa20aa8 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js @@ -9,12 +9,12 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type { DirectEventHandler, Int32, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js index 5e9aeb530682e4..b8cf23004abc79 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js @@ -9,7 +9,7 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js index f24967511dc8ca..63491492179c22 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js @@ -9,13 +9,13 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {ColorValue} from '../../../../Libraries/StyleSheet/StyleSheet'; import type { BubblingEventHandler, Int32, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNativeCommands'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js index d1ba83747327f0..09ccaf9774f641 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js @@ -9,8 +9,8 @@ */ import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from '../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type {WithDefault} from '../../../../Libraries/Types/CodegenTypes'; +import type {HostComponent} from '../../types/HostComponent'; import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent'; diff --git a/packages/react-native/src/private/types/HostComponent.js b/packages/react-native/src/private/types/HostComponent.js new file mode 100644 index 00000000000000..c84a4f70a3f4af --- /dev/null +++ b/packages/react-native/src/private/types/HostComponent.js @@ -0,0 +1,16 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict + * @format + */ + +import type {HostInstance} from './HostInstance'; + +export type HostComponent = component( + ref: React$RefSetter, + ...Config +); diff --git a/packages/react-native/src/private/types/HostInstance.js b/packages/react-native/src/private/types/HostInstance.js new file mode 100644 index 00000000000000..189e1532b8f413 --- /dev/null +++ b/packages/react-native/src/private/types/HostInstance.js @@ -0,0 +1,67 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow strict + */ + +export type MeasureOnSuccessCallback = ( + x: number, + y: number, + width: number, + height: number, + pageX: number, + pageY: number, +) => void; + +export type MeasureInWindowOnSuccessCallback = ( + x: number, + y: number, + width: number, + height: number, +) => void; + +export type MeasureLayoutOnSuccessCallback = ( + left: number, + top: number, + width: number, + height: number, +) => void; + +/** + * Current usages should migrate to this definition + */ +export interface INativeMethods { + blur(): void; + focus(): void; + measure(callback: MeasureOnSuccessCallback): void; + measureInWindow(callback: MeasureInWindowOnSuccessCallback): void; + measureLayout( + relativeToNativeNode: number | HostInstance, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail?: () => void, + ): void; + setNativeProps(nativeProps: {...}): void; +} + +export type NativeMethods = $ReadOnly<{ + blur(): void, + focus(): void, + measure(callback: MeasureOnSuccessCallback): void, + measureInWindow(callback: MeasureInWindowOnSuccessCallback): void, + measureLayout( + relativeToNativeNode: number | HostInstance, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail?: () => void, + ): void, + setNativeProps(nativeProps: {...}): void, +}>; + +// This validates that INativeMethods and NativeMethods stay in sync using Flow! +declare const ensureNativeMethodsAreSynced: NativeMethods; +(ensureNativeMethodsAreSynced: INativeMethods); + +export type HostInstance = NativeMethods; diff --git a/packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js b/packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js index 0326779a6ea392..afeaa03297aa18 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js +++ b/packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js @@ -10,16 +10,18 @@ // flowlint unsafe-getters-setters:off +import type { + InternalInstanceHandle, + Node as ShadowNode, + ViewConfig, +} from '../../../../../Libraries/Renderer/shims/ReactNativeTypes'; import type { HostInstance, INativeMethods, - InternalInstanceHandle, MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, - Node as ShadowNode, - ViewConfig, -} from '../../../../../Libraries/Renderer/shims/ReactNativeTypes'; +} from '../../../types/HostInstance'; import type {InstanceHandle} from './internals/NodeInternals'; import type ReactNativeDocument from './ReactNativeDocument'; diff --git a/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js b/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js index 8434e5cac65b76..e7a63bf45316b5 100644 --- a/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js +++ b/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js @@ -8,8 +8,8 @@ * @format */ +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { BubblingEventHandler, Double, diff --git a/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js b/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js index 852f8df418ab83..1ecf491b6e9f17 100644 --- a/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js +++ b/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js @@ -10,8 +10,8 @@ 'use strict'; +import type {HostComponent} from 'react-native'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type {NativeSyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes'; const {requireNativeComponent} = require('react-native'); diff --git a/packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js b/packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js index c31765f8c295fa..7bca51309d55d3 100644 --- a/packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js +++ b/packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js @@ -10,7 +10,7 @@ 'use strict'; -import type {NativeMethods} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from 'react-native'; import {RNTesterThemeContext} from '../../components/RNTesterTheme'; @@ -207,7 +207,7 @@ class ActionSheetAnchorExample extends React.Component< clicked: 'none', }; - anchorRef: {current: null | $Exact} = React.createRef(); + anchorRef: {current: null | HostInstance} = React.createRef(); render(): React.Node { return ( @@ -434,7 +434,7 @@ class ShareScreenshotAnchorExample extends React.Component< text: '', }; - anchorRef: {current: null | $Exact} = React.createRef(); + anchorRef: {current: null | HostInstance} = React.createRef(); render(): React.Node { return ( diff --git a/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventAttributesHoverablePointers.js b/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventAttributesHoverablePointers.js index 9db7be46222238..9a1d8d0513ce16 100644 --- a/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventAttributesHoverablePointers.js +++ b/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventAttributesHoverablePointers.js @@ -9,7 +9,7 @@ */ import type {PlatformTestComponentBaseProps} from '../PlatformTest/RNTesterPlatformTestTypes'; -import type {HostInstance} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from 'react-native'; import type { LayoutRectangle, PointerEvent, diff --git a/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventAttributesNoHoverPointers.js b/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventAttributesNoHoverPointers.js index 96bdecd2d75b94..e55a27b84308cc 100644 --- a/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventAttributesNoHoverPointers.js +++ b/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventAttributesNoHoverPointers.js @@ -9,7 +9,7 @@ */ import type {PlatformTestComponentBaseProps} from '../PlatformTest/RNTesterPlatformTestTypes'; -import type {HostInstance} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from 'react-native'; import type { LayoutRectangle, PointerEvent, diff --git a/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventPointerOverOut.js b/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventPointerOverOut.js index 54c2d844f20013..9a77b8fd117eb7 100644 --- a/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventPointerOverOut.js +++ b/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventPointerOverOut.js @@ -9,7 +9,7 @@ */ import type {PlatformTestComponentBaseProps} from '../PlatformTest/RNTesterPlatformTestTypes'; -import type {HostInstance} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; +import type {HostInstance} from 'react-native'; import type {PointerEvent} from 'react-native/Libraries/Types/CoreEventTypes'; import RNTesterPlatformTest from '../PlatformTest/RNTesterPlatformTest';