Rollout support for multiplatform react-native project (#39131)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39131

Docs on the new behavior: https://flow.org/en/docs/react/multiplatform

Changelog: [Internal]

Reviewed By: samwgoldman

Differential Revision: D48085422

fbshipit-source-id: daaa5a7d7d04871ab3da1ad47c6b88ef4226bdfd
This commit is contained in:
Sam Zhou 2023-08-24 09:54:15 -07:00 committed by Facebook GitHub Bot
parent 3c6bf7bf32
commit 4b97484650
16 changed files with 339 additions and 15 deletions

View File

@ -1,7 +1,4 @@
[ignore]
; Ignore other platform suffixes
.*\.android\.js$
; Ignore templates for 'react-native init'
<PROJECT_ROOT>/packages/react-native/template/.*
@ -11,9 +8,6 @@
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Flow doesn't support platforms
.*/packages/react-native/Libraries/Utilities/LoadingView.js
.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$
[untyped]
@ -41,7 +35,10 @@ format.bracket_spacing=false
module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js
experimental.multi_platform=true
experimental.multi_platform.extensions=.ios
experimental.multi_platform.extensions=.android
munge_underscores=true

View File

@ -1,7 +1,4 @@
[ignore]
; Ignore other platform suffixes
.*\.ios\.js$
; Ignore templates for 'react-native init'
<PROJECT_ROOT>/packages/react-native/template/.*
@ -11,9 +8,6 @@
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Flow doesn't support platforms
.*/packages/react-native/Libraries/Utilities/LoadingView.js
.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$
[untyped]
@ -41,7 +35,10 @@ format.bracket_spacing=false
module.file_ext=.js
module.file_ext=.json
module.file_ext=.android.js
experimental.multi_platform=true
experimental.multi_platform.extensions=.ios
experimental.multi_platform.extensions=.android
munge_underscores=true

View File

@ -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 type {Args} from './NativeAlertManager';
declare module.exports: {
alertWithArgs(
args: Args,
callback: (id: number, value: string) => void,
): void,
};

View File

@ -0,0 +1,20 @@
/**
* 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
*/
/**
* This is a function exposed to the React Renderer that can be used by the
* pre-Fabric renderer to emit accessibility events to pre-Fabric nodes.
*/
declare function legacySendAccessibilityEvent(
reactTag: number,
eventType: string,
): void;
module.exports = legacySendAccessibilityEvent;

View File

@ -10,4 +10,11 @@
'use strict';
module.exports = require('../UnimplementedViews/UnimplementedView');
import typeof UnimplementedViewType from '../UnimplementedViews/UnimplementedView';
import typeof ProgressBarAndroidNativeComponentType from './ProgressBarAndroidNativeComponent';
export type {ProgressBarAndroidProps} from './ProgressBarAndroid.android';
module.exports = (require('../UnimplementedViews/UnimplementedView'):
| UnimplementedViewType
| ProgressBarAndroidNativeComponentType);

View File

@ -0,0 +1,19 @@
/**
* 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
*/
declare const DevToolsSettingsManager: {
setConsolePatchSettings(newConsolePatchSettings: string): void,
getConsolePatchSettings(): ?string,
setProfilingSettings(newProfilingSettings: string): void,
getProfilingSettings(): ?string,
reload(): void,
};
module.exports = DevToolsSettingsManager;

View File

@ -0,0 +1,40 @@
/**
* 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
* @format
*/
import type {RootTag} from '../Types/RootTagTypes';
import type {ResolvedAssetSource} from './AssetSourceResolver';
import type {ImageIOS, ImageAndroid} from './Image.flow';
export type ImageComponentStatics = $ReadOnly<{
getSize: (
uri: string,
success: (width: number, height: number) => void,
failure?: (error: any) => void,
) => void,
getSizeWithHeaders: (
uri: string,
headers: {[string]: string},
success: (width: number, height: number) => void,
failure?: (error: any) => void,
) => any,
prefetch: (url: string) => any,
abortPrefetch?: number => void,
prefetchWithMetadata: (
url: string,
queryRootName: string,
rootTag?: ?RootTag,
) => any,
queryCache: (
urls: Array<string>,
) => Promise<{[string]: 'memory' | 'disk' | 'disk/memory'}>,
resolveAssetSource: (source: any) => ?ResolvedAssetSource,
}>;
declare module.exports: ImageIOS | ImageAndroid;

View File

@ -0,0 +1,14 @@
/**
* 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 type {PartialViewConfigWithoutName} from './PlatformBaseViewConfig';
declare const PlatformBaseViewConfig: PartialViewConfigWithoutName;
export default PlatformBaseViewConfig;

View File

@ -0,0 +1,88 @@
/**
* 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
*/
'use strict';
import type {EventSubscription} from '../vendor/emitter/EventEmitter';
import type {RequestBody} from './convertRequestBody';
import type {NativeResponseType} from './XMLHttpRequest';
type RCTNetworkingEventDefinitions = $ReadOnly<{
didSendNetworkData: [
[
number, // requestId
number, // progress
number, // total
],
],
didReceiveNetworkResponse: [
[
number, // requestId
number, // status
?{[string]: string}, // responseHeaders
?string, // responseURL
],
],
didReceiveNetworkData: [
[
number, // requestId
string, // response
],
],
didReceiveNetworkIncrementalData: [
[
number, // requestId
string, // responseText
number, // progress
number, // total
],
],
didReceiveNetworkDataProgress: [
[
number, // requestId
number, // loaded
number, // total
],
],
didCompleteNetworkResponse: [
[
number, // requestId
string, // error
boolean, // timeOutError
],
],
}>;
declare const RCTNetworking: interface {
addListener<K: $Keys<RCTNetworkingEventDefinitions>>(
eventType: K,
listener: (...$ElementType<RCTNetworkingEventDefinitions, K>) => mixed,
context?: mixed,
): EventSubscription,
sendRequest(
method: string,
trackingName: string,
url: string,
headers: {...},
data: RequestBody,
responseType: NativeResponseType,
incrementalUpdates: boolean,
timeout: number,
callback: (requestId: number) => void,
withCredentials: boolean,
): void,
abortRequest(requestId: number): void,
clearCookies(callback: (result: boolean) => void): void,
};
export default RCTNetworking;

View File

@ -0,0 +1,22 @@
/**
* 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 type {ProcessedColorValue} from './processColor';
import type {ColorValue, NativeColorValue} from './StyleSheet';
declare export function PlatformColor(...names: Array<string>): ColorValue;
declare export function normalizeColorObject(
color: NativeColorValue,
): ?ProcessedColorValue;
declare export function processColorObject(
color: NativeColorValue,
): ?NativeColorValue;

View File

@ -0,0 +1,27 @@
/**
* 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';
type BackPressEventName = 'backPress' | 'hardwareBackPress';
type TBackHandler = {|
+exitApp: () => void,
+addEventListener: (
eventName: BackPressEventName,
handler: () => ?boolean,
) => {remove: () => void, ...},
+removeEventListener: (
eventName: BackPressEventName,
handler: () => ?boolean,
) => void,
|};
declare module.exports: TBackHandler;

View File

@ -0,0 +1,13 @@
/**
* 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 {Platform} from './Platform.flow';
declare module.exports: Platform;

View File

@ -0,0 +1,13 @@
/**
* 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
*/
import typeof RNTesterApp from './RNTesterAppShared';
declare module.exports: RNTesterApp;

View File

@ -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
*/
'use strict';
import type {RNTesterModule} from '../../types/RNTesterTypes';
declare module.exports: RNTesterModule;

View File

@ -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
*/
'use strict';
import type {RNTesterModule} from '../../types/RNTesterTypes';
declare module.exports: RNTesterModule;

View File

@ -0,0 +1,19 @@
/**
* 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';
import type {RNTesterModuleInfo} from '../types/RNTesterTypes';
declare const APIs: Array<RNTesterModuleInfo>;
declare const Components: Array<RNTesterModuleInfo>;
declare const Modules: {...};
module.exports = {APIs, Components, Modules};