2017-05-26 20:51:06 +03:00
|
|
|
/**
|
2018-09-11 00:42:08 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-05-26 20:51:06 +03:00
|
|
|
*
|
2017-10-04 20:06:57 +03:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-05-26 20:51:06 +03:00
|
|
|
*
|
2018-05-13 10:48:49 +03:00
|
|
|
* @format
|
2017-05-26 20:51:06 +03:00
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
|
2020-02-14 06:43:09 +03:00
|
|
|
import type {ElementRef, AbstractComponent} from 'react';
|
2018-05-13 10:48:49 +03:00
|
|
|
|
2017-05-26 20:51:06 +03:00
|
|
|
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;
|
|
|
|
|
2020-11-19 08:16:22 +03:00
|
|
|
type AttributeType<T> =
|
2018-08-22 22:49:15 +03:00
|
|
|
| true
|
|
|
|
| $ReadOnly<{|
|
2020-11-19 08:16:22 +03:00
|
|
|
diff?: (arg1: T, arg2: T) => boolean,
|
2018-09-28 10:48:09 +03:00
|
|
|
process?: (arg1: any) => any,
|
2018-08-22 22:49:15 +03:00
|
|
|
|}>;
|
|
|
|
|
2018-09-11 00:42:08 +03:00
|
|
|
export type AttributeConfiguration<
|
|
|
|
TProps = string,
|
|
|
|
TStyleProps = string,
|
|
|
|
> = $ReadOnly<{
|
2020-11-19 08:16:22 +03:00
|
|
|
[propName: TProps]: AttributeType<any>,
|
|
|
|
style: $ReadOnly<{[propName: TStyleProps]: AttributeType<any>, ...}>,
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2018-09-11 00:42:08 +03:00
|
|
|
}>;
|
|
|
|
|
2020-11-19 08:16:22 +03:00
|
|
|
export type ViewConfig = $ReadOnly<{
|
|
|
|
Commands?: $ReadOnly<{[commandName: string]: number, ...}>,
|
2020-11-19 08:16:22 +03:00
|
|
|
Constants?: $ReadOnly<{[name: string]: mixed, ...}>,
|
|
|
|
Manager?: string,
|
2020-11-19 08:16:22 +03:00
|
|
|
NativeProps?: $ReadOnly<{[propName: string]: string, ...}>,
|
2020-11-19 08:16:22 +03:00
|
|
|
baseModuleName?: ?string,
|
2018-08-22 22:49:15 +03:00
|
|
|
bubblingEventTypes?: $ReadOnly<{
|
2020-11-19 08:16:22 +03:00
|
|
|
[eventName: string]: $ReadOnly<{
|
|
|
|
phasedRegistrationNames: $ReadOnly<{
|
2018-08-22 22:49:15 +03:00
|
|
|
captured: string,
|
|
|
|
bubbled: string,
|
2020-11-19 08:16:22 +03:00
|
|
|
}>,
|
|
|
|
}>,
|
2019-11-21 20:38:13 +03:00
|
|
|
...,
|
2018-08-22 22:49:15 +03:00
|
|
|
}>,
|
|
|
|
directEventTypes?: $ReadOnly<{
|
2020-11-19 08:16:22 +03:00
|
|
|
[eventName: string]: $ReadOnly<{
|
2018-08-22 22:49:15 +03:00
|
|
|
registrationName: string,
|
2020-11-19 08:16:22 +03:00
|
|
|
}>,
|
2019-11-21 20:38:13 +03:00
|
|
|
...,
|
2018-08-22 22:49:15 +03:00
|
|
|
}>,
|
2017-09-15 04:01:25 +03:00
|
|
|
uiViewClassName: string,
|
2020-11-19 08:16:22 +03:00
|
|
|
validAttributes: AttributeConfiguration<string, string>,
|
|
|
|
}>;
|
2017-09-15 04:01:25 +03:00
|
|
|
|
2020-11-19 08:16:22 +03:00
|
|
|
export type PartialViewConfig = $ReadOnly<{
|
|
|
|
bubblingEventTypes?: $PropertyType<ViewConfig, 'bubblingEventTypes'>,
|
|
|
|
directEventTypes?: $PropertyType<ViewConfig, 'directEventTypes'>,
|
|
|
|
uiViewClassName: string,
|
|
|
|
validAttributes?: $ReadOnly<{[propName: string]: AttributeType<any>}>,
|
|
|
|
}>;
|
2017-09-15 04:01:25 +03:00
|
|
|
|
2019-09-26 18:12:53 +03:00
|
|
|
export type NativeMethods = {
|
2017-05-26 20:51:06 +03:00
|
|
|
blur(): void,
|
|
|
|
focus(): void,
|
|
|
|
measure(callback: MeasureOnSuccessCallback): void,
|
|
|
|
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void,
|
|
|
|
measureLayout(
|
2019-09-26 18:12:53 +03:00
|
|
|
relativeToNativeNode: number | ElementRef<HostComponent<mixed>>,
|
2017-05-26 20:51:06 +03:00
|
|
|
onSuccess: MeasureLayoutOnSuccessCallback,
|
2019-09-26 18:12:53 +03:00
|
|
|
onFail?: () => void,
|
2017-05-26 20:51:06 +03:00
|
|
|
): void,
|
|
|
|
setNativeProps(nativeProps: Object): void,
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2019-09-26 18:12:53 +03:00
|
|
|
};
|
2017-05-26 20:51:06 +03:00
|
|
|
|
2019-11-16 00:58:48 +03:00
|
|
|
export type HostComponent<T> = AbstractComponent<T, $ReadOnly<NativeMethods>>;
|
2019-09-25 20:10:48 +03:00
|
|
|
|
2017-05-26 20:51:06 +03:00
|
|
|
type SecretInternalsType = {
|
2018-04-18 03:17:12 +03:00
|
|
|
computeComponentStackForErrorReporting(tag: number): string,
|
2017-05-26 20:51:06 +03:00
|
|
|
// TODO (bvaughn) Decide which additional types to expose here?
|
|
|
|
// And how much information to fill in for the above types.
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2017-05-26 20:51:06 +03:00
|
|
|
};
|
|
|
|
|
2020-03-31 00:02:41 +03:00
|
|
|
type InspectorDataProps = $ReadOnly<{
|
|
|
|
[propName: string]: string,
|
|
|
|
...,
|
|
|
|
}>;
|
|
|
|
|
|
|
|
type InspectorDataSource = $ReadOnly<{|
|
|
|
|
fileName?: string,
|
|
|
|
lineNumber?: number,
|
|
|
|
|}>;
|
|
|
|
|
|
|
|
type InspectorDataGetter = (
|
|
|
|
(componentOrHandle: any) => ?number,
|
|
|
|
) => $ReadOnly<{|
|
|
|
|
measure: Function,
|
|
|
|
props: InspectorDataProps,
|
|
|
|
source: InspectorDataSource,
|
|
|
|
|}>;
|
|
|
|
|
|
|
|
export type InspectorData = $ReadOnly<{|
|
|
|
|
hierarchy: Array<{|
|
|
|
|
name: ?string,
|
|
|
|
getInspectorData: InspectorDataGetter,
|
|
|
|
|}>,
|
|
|
|
selectedIndex: ?number,
|
|
|
|
props: InspectorDataProps,
|
|
|
|
source: ?InspectorDataSource,
|
|
|
|
|}>;
|
|
|
|
|
|
|
|
export type TouchedViewDataAtPoint = $ReadOnly<{|
|
|
|
|
pointerY: number,
|
|
|
|
touchedViewTag?: number,
|
|
|
|
frame: $ReadOnly<{|
|
|
|
|
top: number,
|
|
|
|
left: number,
|
|
|
|
width: number,
|
|
|
|
height: number,
|
|
|
|
|}>,
|
|
|
|
...InspectorData,
|
|
|
|
|}>;
|
|
|
|
|
2017-05-26 20:51:06 +03:00
|
|
|
/**
|
2017-06-09 05:01:23 +03:00
|
|
|
* Flat ReactNative renderer bundles are too big for Flow to parse efficiently.
|
|
|
|
* Provide minimal Flow typing for the high-level RN API and call it a day.
|
|
|
|
*/
|
2017-05-26 20:51:06 +03:00
|
|
|
export type ReactNativeType = {
|
2019-11-04 23:20:24 +03:00
|
|
|
findHostInstance_DEPRECATED(
|
|
|
|
componentOrHandle: any,
|
|
|
|
): ?ElementRef<HostComponent<mixed>>,
|
2017-05-26 20:51:06 +03:00
|
|
|
findNodeHandle(componentOrHandle: any): ?number,
|
2019-07-30 23:15:54 +03:00
|
|
|
dispatchCommand(handle: any, command: string, args: Array<any>): void,
|
2017-05-26 20:51:06 +03:00
|
|
|
render(
|
2017-09-15 04:01:25 +03:00
|
|
|
element: React$Element<any>,
|
2017-05-26 20:51:06 +03:00
|
|
|
containerTag: any,
|
|
|
|
callback: ?Function,
|
|
|
|
): any,
|
|
|
|
unmountComponentAtNode(containerTag: number): any,
|
|
|
|
unmountComponentAtNodeAndRemoveContainer(containerTag: number): any,
|
2019-11-21 20:38:13 +03:00
|
|
|
// TODO (bvaughn) Add types
|
|
|
|
unstable_batchedUpdates: any,
|
2017-05-26 20:51:06 +03:00
|
|
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: SecretInternalsType,
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2017-05-26 20:51:06 +03:00
|
|
|
};
|
2018-04-11 01:19:57 +03:00
|
|
|
|
|
|
|
export type ReactFabricType = {
|
2020-03-16 23:02:43 +03:00
|
|
|
findHostInstance_DEPRECATED(
|
|
|
|
componentOrHandle: any,
|
|
|
|
): ?ElementRef<HostComponent<mixed>>,
|
2018-04-11 01:19:57 +03:00
|
|
|
findNodeHandle(componentOrHandle: any): ?number,
|
2019-07-30 23:15:54 +03:00
|
|
|
dispatchCommand(handle: any, command: string, args: Array<any>): void,
|
2018-04-11 01:19:57 +03:00
|
|
|
render(
|
|
|
|
element: React$Element<any>,
|
|
|
|
containerTag: any,
|
|
|
|
callback: ?Function,
|
|
|
|
): any,
|
|
|
|
unmountComponentAtNode(containerTag: number): any,
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2018-04-11 01:19:57 +03:00
|
|
|
};
|
2019-07-30 23:15:54 +03:00
|
|
|
|
|
|
|
export type ReactNativeEventTarget = {
|
|
|
|
node: Object,
|
|
|
|
canonical: {
|
|
|
|
_nativeTag: number,
|
2020-11-19 08:16:22 +03:00
|
|
|
viewConfig: ViewConfig,
|
2019-07-30 23:15:54 +03:00
|
|
|
currentProps: Object,
|
|
|
|
_internalInstanceHandle: Object,
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2019-07-30 23:15:54 +03:00
|
|
|
},
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2019-07-30 23:15:54 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export type ReactFaricEventTouch = {
|
|
|
|
identifier: number,
|
|
|
|
locationX: number,
|
|
|
|
locationY: number,
|
|
|
|
pageX: number,
|
|
|
|
pageY: number,
|
|
|
|
screenX: number,
|
|
|
|
screenY: number,
|
|
|
|
target: number,
|
|
|
|
timestamp: number,
|
|
|
|
force: number,
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2019-07-30 23:15:54 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export type ReactFaricEvent = {
|
|
|
|
touches: Array<ReactFaricEventTouch>,
|
|
|
|
changedTouches: Array<ReactFaricEventTouch>,
|
|
|
|
targetTouches: Array<ReactFaricEventTouch>,
|
|
|
|
target: number,
|
2019-11-21 20:38:13 +03:00
|
|
|
...
|
2019-07-30 23:15:54 +03:00
|
|
|
};
|
2020-05-05 07:25:56 +03:00
|
|
|
|
|
|
|
// Imperative LayoutAnimation API types
|
|
|
|
//
|
|
|
|
export type LayoutAnimationType =
|
|
|
|
| 'spring'
|
|
|
|
| 'linear'
|
|
|
|
| 'easeInEaseOut'
|
|
|
|
| 'easeIn'
|
|
|
|
| 'easeOut'
|
|
|
|
| 'keyboard';
|
|
|
|
|
|
|
|
export type LayoutAnimationProperty =
|
|
|
|
| 'opacity'
|
|
|
|
| 'scaleX'
|
|
|
|
| 'scaleY'
|
|
|
|
| 'scaleXY';
|
|
|
|
|
|
|
|
export type LayoutAnimationAnimationConfig = $ReadOnly<{|
|
|
|
|
duration?: number,
|
|
|
|
delay?: number,
|
|
|
|
springDamping?: number,
|
|
|
|
initialVelocity?: number,
|
|
|
|
type?: LayoutAnimationType,
|
|
|
|
property?: LayoutAnimationProperty,
|
|
|
|
|}>;
|
|
|
|
|
|
|
|
export type LayoutAnimationConfig = $ReadOnly<{|
|
|
|
|
duration: number,
|
|
|
|
create?: LayoutAnimationAnimationConfig,
|
|
|
|
update?: LayoutAnimationAnimationConfig,
|
|
|
|
delete?: LayoutAnimationAnimationConfig,
|
|
|
|
|}>;
|