2017-05-26 20:51:06 +03:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
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
|
|
|
|
*/
|
|
|
|
|
2018-05-15 23:08:47 +03:00
|
|
|
import React 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;
|
|
|
|
|
2017-09-15 04:01:27 +03:00
|
|
|
type BubblingEventType = {
|
|
|
|
phasedRegistrationNames: {
|
|
|
|
captured: string,
|
|
|
|
bubbled: string,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
type DirectEventType = {
|
|
|
|
registrationName: string,
|
|
|
|
};
|
|
|
|
|
2017-09-15 04:01:25 +03:00
|
|
|
export type ReactNativeBaseComponentViewConfig = {
|
|
|
|
validAttributes: Object,
|
|
|
|
uiViewClassName: string,
|
2017-09-15 04:01:27 +03:00
|
|
|
bubblingEventTypes?: {[topLevelType: string]: BubblingEventType},
|
|
|
|
directEventTypes?: {[topLevelType: string]: DirectEventType},
|
2017-09-15 04:01:25 +03:00
|
|
|
propTypes?: Object,
|
|
|
|
};
|
|
|
|
|
|
|
|
export type ViewConfigGetter = () => ReactNativeBaseComponentViewConfig;
|
|
|
|
|
2018-05-13 10:48:49 +03:00
|
|
|
/**
|
|
|
|
* Class only exists for its Flow type.
|
|
|
|
*/
|
|
|
|
class ReactNativeComponent<Props> extends React.Component<Props> {
|
|
|
|
blur(): void {}
|
|
|
|
focus(): void {}
|
|
|
|
measure(callback: MeasureOnSuccessCallback): void {}
|
|
|
|
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {}
|
|
|
|
measureLayout(
|
|
|
|
relativeToNativeNode: number,
|
|
|
|
onSuccess: MeasureLayoutOnSuccessCallback,
|
|
|
|
onFail?: () => void,
|
|
|
|
): void {}
|
|
|
|
setNativeProps(nativeProps: Object): void {}
|
|
|
|
}
|
|
|
|
|
2017-05-26 20:51:06 +03:00
|
|
|
/**
|
|
|
|
* This type keeps ReactNativeFiberHostComponent and NativeMethodsMixin in sync.
|
|
|
|
* It can also provide types for ReactNative applications that use NMM or refs.
|
|
|
|
*/
|
|
|
|
export type NativeMethodsMixinType = {
|
|
|
|
blur(): void,
|
|
|
|
focus(): void,
|
|
|
|
measure(callback: MeasureOnSuccessCallback): void,
|
|
|
|
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void,
|
|
|
|
measureLayout(
|
|
|
|
relativeToNativeNode: number,
|
|
|
|
onSuccess: MeasureLayoutOnSuccessCallback,
|
|
|
|
onFail: () => void,
|
|
|
|
): void,
|
|
|
|
setNativeProps(nativeProps: Object): void,
|
|
|
|
};
|
|
|
|
|
|
|
|
type SecretInternalsType = {
|
|
|
|
NativeMethodsMixin: NativeMethodsMixinType,
|
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.
|
|
|
|
};
|
|
|
|
|
2018-04-19 00:59:57 +03:00
|
|
|
type SecretInternalsFabricType = {
|
|
|
|
NativeMethodsMixin: NativeMethodsMixinType,
|
|
|
|
};
|
|
|
|
|
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 = {
|
2018-05-13 10:48:49 +03:00
|
|
|
NativeComponent: typeof ReactNativeComponent,
|
2017-05-26 20:51:06 +03:00
|
|
|
findNodeHandle(componentOrHandle: any): ?number,
|
|
|
|
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,
|
|
|
|
unstable_batchedUpdates: any, // TODO (bvaughn) Add types
|
|
|
|
|
|
|
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: SecretInternalsType,
|
|
|
|
};
|
2018-04-11 01:19:57 +03:00
|
|
|
|
|
|
|
export type ReactFabricType = {
|
2018-05-13 10:48:49 +03:00
|
|
|
NativeComponent: typeof ReactNativeComponent,
|
2018-04-11 01:19:57 +03:00
|
|
|
findNodeHandle(componentOrHandle: any): ?number,
|
|
|
|
render(
|
|
|
|
element: React$Element<any>,
|
|
|
|
containerTag: any,
|
|
|
|
callback: ?Function,
|
|
|
|
): any,
|
|
|
|
unmountComponentAtNode(containerTag: number): any,
|
|
|
|
|
2018-04-19 00:59:57 +03:00
|
|
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: SecretInternalsFabricType,
|
2018-04-11 01:19:57 +03:00
|
|
|
};
|