diff --git a/packages/react-native/Libraries/Alert/RCTAlertManager.js b/packages/react-native/Libraries/Alert/RCTAlertManager.js new file mode 100644 index 00000000000..f40c4b62938 --- /dev/null +++ b/packages/react-native/Libraries/Alert/RCTAlertManager.js @@ -0,0 +1,17 @@ +/** + * 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-local + * @format + */ + +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". + +import RCTAlertManager from './RCTAlertManager'; + +export default RCTAlertManager; diff --git a/packages/react-native/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js b/packages/react-native/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js new file mode 100644 index 00000000000..ed4a92e8e92 --- /dev/null +++ b/packages/react-native/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js @@ -0,0 +1,17 @@ +/** + * 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-local + * @format + */ + +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". + +import legacySendAccessibilityEvent from './legacySendAccessibilityEvent'; + +export default legacySendAccessibilityEvent; diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index 44beee38714..753983a3657 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -13,8 +13,6 @@ import type { MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, } from '../../../src/private/types/HostInstance'; -import type {AccessibilityRole} from '../../Components/View/ViewAccessibility'; -import typeof DrawerLayoutAndroidCommon from './DrawerLayoutAndroid.js'; import type { DrawerLayoutAndroidMethods, DrawerLayoutAndroidProps, @@ -305,4 +303,4 @@ const styles = StyleSheet.create({ }, }); -export default DrawerLayoutAndroid as $FlowFixMe as DrawerLayoutAndroidCommon; +export default DrawerLayoutAndroid as $FlowFixMe; diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js new file mode 100644 index 00000000000..a1768576e87 --- /dev/null +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js @@ -0,0 +1,15 @@ +/** + * 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-local + */ + +'use strict'; + +import DrawerLayoutAndroidFallback from './DrawerLayoutAndroidFallback'; + +export default DrawerLayoutAndroidFallback; diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js index 246ea5a624f..64693f6c144 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js @@ -5,73 +5,13 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow strict-local + * @flow */ -'use strict'; +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". -// import typeof DrawerLayoutAndroid from './DrawerLayoutAndroid.android'; -import type { - MeasureInWindowOnSuccessCallback, - MeasureLayoutOnSuccessCallback, - MeasureOnSuccessCallback, -} from '../../../src/private/types/HostInstance'; -import type { - DrawerLayoutAndroidMethods, - DrawerLayoutAndroidProps, - DrawerLayoutAndroidState, -} from './DrawerLayoutAndroidTypes'; +import DrawerLayoutAndroid from './DrawerLayoutAndroid'; -import UnimplementedView from '../UnimplementedViews/UnimplementedView'; -import * as React from 'react'; - -export type { - DrawerLayoutAndroidProps, - DrawerSlideEvent, -} from './DrawerLayoutAndroidTypes'; - -export default class DrawerLayoutAndroid - extends React.Component - implements DrawerLayoutAndroidMethods -{ - render(): React.Node { - return ; - } - - openDrawer(): void { - throw new Error('DrawerLayoutAndroid is only available on Android'); - } - - closeDrawer(): void { - throw new Error('DrawerLayoutAndroid is only available on Android'); - } - - blur(): void { - throw new Error('DrawerLayoutAndroid is only available on Android'); - } - - focus(): void { - throw new Error('DrawerLayoutAndroid is only available on Android'); - } - - measure(callback: MeasureOnSuccessCallback): void { - throw new Error('DrawerLayoutAndroid is only available on Android'); - } - - measureInWindow(callback: MeasureInWindowOnSuccessCallback): void { - throw new Error('DrawerLayoutAndroid is only available on Android'); - } - - measureLayout( - relativeToNativeNode: number, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail?: () => void, - ): void { - throw new Error('DrawerLayoutAndroid is only available on Android'); - } - - // $FlowFixMe[unclear-type] - setNativeProps(nativeProps: Object): void { - throw new Error('DrawerLayoutAndroid is only available on Android'); - } -} +export default DrawerLayoutAndroid; diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js.flow b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js.flow new file mode 100644 index 00000000000..52d7d1c4f3f --- /dev/null +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js.flow @@ -0,0 +1,18 @@ +/** + * 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-local + */ + +import DrawerLayoutAndroid from './DrawerLayoutAndroidFallback'; + +export type { + DrawerLayoutAndroidProps, + DrawerSlideEvent, +} from './DrawerLayoutAndroidTypes'; + +export default DrawerLayoutAndroid; diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidFallback.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidFallback.js new file mode 100644 index 00000000000..57cf6451261 --- /dev/null +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidFallback.js @@ -0,0 +1,71 @@ +/** + * 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-local + */ + +'use strict'; + +import type { + MeasureInWindowOnSuccessCallback, + MeasureLayoutOnSuccessCallback, + MeasureOnSuccessCallback, +} from '../../../src/private/types/HostInstance'; +import type { + DrawerLayoutAndroidMethods, + DrawerLayoutAndroidProps, + DrawerLayoutAndroidState, +} from './DrawerLayoutAndroidTypes'; + +import UnimplementedView from '../UnimplementedViews/UnimplementedView'; +import * as React from 'react'; + +export default class DrawerLayoutAndroid + extends React.Component + implements DrawerLayoutAndroidMethods +{ + render(): React.Node { + return ; + } + + openDrawer(): void { + throw new Error('DrawerLayoutAndroid is only available on Android'); + } + + closeDrawer(): void { + throw new Error('DrawerLayoutAndroid is only available on Android'); + } + + blur(): void { + throw new Error('DrawerLayoutAndroid is only available on Android'); + } + + focus(): void { + throw new Error('DrawerLayoutAndroid is only available on Android'); + } + + measure(callback: MeasureOnSuccessCallback): void { + throw new Error('DrawerLayoutAndroid is only available on Android'); + } + + measureInWindow(callback: MeasureInWindowOnSuccessCallback): void { + throw new Error('DrawerLayoutAndroid is only available on Android'); + } + + measureLayout( + relativeToNativeNode: number, + onSuccess: MeasureLayoutOnSuccessCallback, + onFail?: () => void, + ): void { + throw new Error('DrawerLayoutAndroid is only available on Android'); + } + + // $FlowFixMe[unclear-type] + setNativeProps(nativeProps: Object): void { + throw new Error('DrawerLayoutAndroid is only available on Android'); + } +} diff --git a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js index 78442582f74..d26d1976c81 100644 --- a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +++ b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js @@ -13,12 +13,22 @@ import typeof ProgressBarAndroidNativeComponentType from './ProgressBarAndroidNativeComponent'; import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes'; +import Platform from '../../Utilities/Platform'; + export type {ProgressBarAndroidProps}; -export default require('../UnimplementedViews/UnimplementedView') - .default as $FlowFixMe as component( +let ProgressBarAndroid: component( ref?: React.RefSetter< React.ElementRef, >, ...props: ProgressBarAndroidProps ); + +if (Platform.OS === 'android') { + ProgressBarAndroid = require('./ProgressBarAndroid').default; +} else { + ProgressBarAndroid = require('../UnimplementedViews/UnimplementedView') + .default as $FlowFixMe; +} + +export default ProgressBarAndroid; diff --git a/packages/react-native/Libraries/Image/Image.js b/packages/react-native/Libraries/Image/Image.js new file mode 100644 index 00000000000..71a280b4b5c --- /dev/null +++ b/packages/react-native/Libraries/Image/Image.js @@ -0,0 +1,17 @@ +/** + * 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-local + * @format + */ + +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". + +import Image from './Image'; + +export default Image; diff --git a/packages/react-native/Libraries/NativeComponent/BaseViewConfig.js b/packages/react-native/Libraries/NativeComponent/BaseViewConfig.js new file mode 100644 index 00000000000..e602620e76c --- /dev/null +++ b/packages/react-native/Libraries/NativeComponent/BaseViewConfig.js @@ -0,0 +1,17 @@ +/** + * 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-local + * @format + */ + +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". + +import BaseViewConfig from './BaseViewConfig'; + +export default BaseViewConfig; diff --git a/packages/react-native/Libraries/Network/RCTNetworking.js b/packages/react-native/Libraries/Network/RCTNetworking.js new file mode 100644 index 00000000000..fe7e75bad53 --- /dev/null +++ b/packages/react-native/Libraries/Network/RCTNetworking.js @@ -0,0 +1,17 @@ +/** + * 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-local + * @format + */ + +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". + +import RCTNetworking from './RCTNetworking'; + +export default RCTNetworking; diff --git a/packages/react-native/Libraries/Settings/Settings.js b/packages/react-native/Libraries/Settings/Settings.js index 1e607faac2d..7adf8ad18c7 100644 --- a/packages/react-native/Libraries/Settings/Settings.js +++ b/packages/react-native/Libraries/Settings/Settings.js @@ -8,26 +8,20 @@ * @flow */ -'use strict'; +import Platform from '../Utilities/Platform'; -const Settings = { - get(key: string): any { - console.warn('Settings is not yet supported on this platform.'); - return null; - }, - - set(settings: Object) { - console.warn('Settings is not yet supported on this platform.'); - }, - - watchKeys(keys: string | Array, callback: () => void): number { - console.warn('Settings is not yet supported on this platform.'); - return -1; - }, - - clearWatch(watchId: number) { - console.warn('Settings is not yet supported on this platform.'); - }, +let Settings: { + get(key: string): any, + set(settings: Object): void, + watchKeys(keys: string | Array, callback: () => void): number, + clearWatch(watchId: number): void, + ... }; +if (Platform.OS === 'ios') { + Settings = require('./Settings').default; +} else { + Settings = require('./SettingsFallback').default; +} + export default Settings; diff --git a/packages/react-native/Libraries/Settings/SettingsFallback.js b/packages/react-native/Libraries/Settings/SettingsFallback.js new file mode 100644 index 00000000000..1e607faac2d --- /dev/null +++ b/packages/react-native/Libraries/Settings/SettingsFallback.js @@ -0,0 +1,33 @@ +/** + * 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 + */ + +'use strict'; + +const Settings = { + get(key: string): any { + console.warn('Settings is not yet supported on this platform.'); + return null; + }, + + set(settings: Object) { + console.warn('Settings is not yet supported on this platform.'); + }, + + watchKeys(keys: string | Array, callback: () => void): number { + console.warn('Settings is not yet supported on this platform.'); + return -1; + }, + + clearWatch(watchId: number) { + console.warn('Settings is not yet supported on this platform.'); + }, +}; + +export default Settings; diff --git a/packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.js b/packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.js new file mode 100644 index 00000000000..3cb166c0fb2 --- /dev/null +++ b/packages/react-native/Libraries/StyleSheet/PlatformColorValueTypes.js @@ -0,0 +1,15 @@ +/** + * 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-local + * @format + */ + +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". + +export * from './PlatformColorValueTypes'; diff --git a/packages/react-native/Libraries/Utilities/BackHandler.js b/packages/react-native/Libraries/Utilities/BackHandler.js new file mode 100644 index 00000000000..e3634bd9d29 --- /dev/null +++ b/packages/react-native/Libraries/Utilities/BackHandler.js @@ -0,0 +1,17 @@ +/** + * 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-local + * @format + */ + +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". + +import BackHandler from './BackHandler'; + +export default BackHandler; diff --git a/packages/react-native/Libraries/Utilities/Platform.js b/packages/react-native/Libraries/Utilities/Platform.js new file mode 100644 index 00000000000..7cae7a4bf8e --- /dev/null +++ b/packages/react-native/Libraries/Utilities/Platform.js @@ -0,0 +1,17 @@ +/** + * 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 + */ + +// NOTE: This file supports backwards compatibility of subpath (deep) imports +// from 'react-native' with platform-specific extensions. It can be deleted +// once we remove the "./*" mapping from package.json "exports". + +import Platform from './Platform'; + +export default Platform; 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 a13201e2539..90660616198 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 @@ -101,6 +101,11 @@ declare export default typeof NativeAlertManager; " `; +exports[`public API should not change unintentionally Libraries/Alert/RCTAlertManager.js 1`] = ` +"declare export default typeof RCTAlertManager; +" +`; + exports[`public API should not change unintentionally Libraries/Alert/RCTAlertManager.js.flow 1`] = ` "declare export default { alertWithArgs( @@ -1476,6 +1481,11 @@ declare export default typeof NativeAccessibilityManager; " `; +exports[`public API should not change unintentionally Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js 1`] = ` +"declare export default typeof legacySendAccessibilityEvent; +" +`; + exports[`public API should not change unintentionally Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js.flow 1`] = ` "declare function legacySendAccessibilityEvent( reactTag: number, @@ -1573,11 +1583,21 @@ declare export default typeof AndroidDrawerLayoutNativeComponent; `; exports[`public API should not change unintentionally Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js 1`] = ` +"declare export default typeof DrawerLayoutAndroid; +" +`; + +exports[`public API should not change unintentionally Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js.flow 1`] = ` "export type { DrawerLayoutAndroidProps, DrawerSlideEvent, } from \\"./DrawerLayoutAndroidTypes\\"; -declare export default class DrawerLayoutAndroid +declare export default typeof DrawerLayoutAndroid; +" +`; + +exports[`public API should not change unintentionally Libraries/Components/DrawerAndroid/DrawerLayoutAndroidFallback.js 1`] = ` +"declare export default class DrawerLayoutAndroid extends React.Component implements DrawerLayoutAndroidMethods { @@ -1820,12 +1840,13 @@ declare export default function useAndroidRippleForView( exports[`public API should not change unintentionally Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js 1`] = ` "export type { ProgressBarAndroidProps }; -declare export default component( +declare let ProgressBarAndroid: component( ref?: React.RefSetter< React.ElementRef, >, ...props: ProgressBarAndroidProps ); +declare export default typeof ProgressBarAndroid; " `; @@ -4304,6 +4325,11 @@ declare export function getUrlCacheBreaker(): string; " `; +exports[`public API should not change unintentionally Libraries/Image/Image.js 1`] = ` +"declare export default typeof Image; +" +`; + exports[`public API should not change unintentionally Libraries/Image/Image.js.flow 1`] = ` "export type { ImageProgressEventIOS, @@ -5749,6 +5775,11 @@ declare export default typeof RCTModalHostViewNativeComponent; " `; +exports[`public API should not change unintentionally Libraries/NativeComponent/BaseViewConfig.js 1`] = ` +"declare export default typeof BaseViewConfig; +" +`; + exports[`public API should not change unintentionally Libraries/NativeComponent/BaseViewConfig.js.flow 1`] = ` "declare const PlatformBaseViewConfig: PartialViewConfigWithoutName; declare export default typeof PlatformBaseViewConfig; @@ -5923,6 +5954,11 @@ declare export default typeof NativeNetworkingIOS; " `; +exports[`public API should not change unintentionally Libraries/Network/RCTNetworking.js 1`] = ` +"declare export default typeof RCTNetworking; +" +`; + exports[`public API should not change unintentionally Libraries/Network/RCTNetworking.js.flow 1`] = ` "declare const RCTNetworking: interface { addListener>( @@ -6997,6 +7033,18 @@ declare export default typeof NativeSettingsManager; `; exports[`public API should not change unintentionally Libraries/Settings/Settings.js 1`] = ` +"declare let Settings: { + get(key: string): any, + set(settings: Object): void, + watchKeys(keys: string | Array, callback: () => void): number, + clearWatch(watchId: number): void, + ... +}; +declare export default typeof Settings; +" +`; + +exports[`public API should not change unintentionally Libraries/Settings/SettingsFallback.js 1`] = ` "declare const Settings: { get(key: string): any, set(settings: Object): void, @@ -7054,6 +7102,11 @@ export type EdgeInsetsOrSizeProp = RectOrSize; " `; +exports[`public API should not change unintentionally Libraries/StyleSheet/PlatformColorValueTypes.js 1`] = ` +"export * from \\"./PlatformColorValueTypes\\"; +" +`; + exports[`public API should not change unintentionally Libraries/StyleSheet/PlatformColorValueTypes.js.flow 1`] = ` "declare export function PlatformColor(...names: Array): ColorValue; declare export function normalizeColorObject( @@ -8227,6 +8280,11 @@ declare export function addChangeListener( " `; +exports[`public API should not change unintentionally Libraries/Utilities/BackHandler.js 1`] = ` +"declare export default typeof BackHandler; +" +`; + exports[`public API should not change unintentionally Libraries/Utilities/BackHandler.js.flow 1`] = ` "export type BackPressEventName = \\"backPress\\" | \\"hardwareBackPress\\"; type TBackHandler = { @@ -8416,6 +8474,11 @@ declare export default typeof PixelRatio; " `; +exports[`public API should not change unintentionally Libraries/Utilities/Platform.js 1`] = ` +"declare export default typeof Platform; +" +`; + exports[`public API should not change unintentionally Libraries/Utilities/Platform.js.flow 1`] = ` "declare export default Platform; "