main
js 221 lines 6.87 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 // libdefs cannot actually import. These are supposed to be the types imported
11 // from 'react-native-renderer/src/ReactNativeTypes'
12 type __MeasureOnSuccessCallback = (
13 x: number,
14 y: number,
15 width: number,
16 height: number,
17 pageX: number,
18 pageY: number,
19 ) => void;
20 type __MeasureInWindowOnSuccessCallback = (
21 x: number,
22 y: number,
23 width: number,
24 height: number,
25 ) => void;
26 type __MeasureLayoutOnSuccessCallback = (
27 left: number,
28 top: number,
29 width: number,
30 height: number,
31 ) => void;
32 type __ReactNativeBaseComponentViewConfig = any;
33 type __ViewConfigGetter = any;
34 type __ViewConfig = any;
35 type __AttributeConfiguration = any;
36
37 // libdefs cannot actually import. This is supposed to be the type imported
38 // from 'react-native-renderer/src/legacy-events/TopLevelEventTypes';
39 type __RNTopLevelEventType = any;
40
41 // libdefs cannot actually import. This is supposed to be the type imported
42 // from 'react-reconciler/src/ReactCapturedValue'
43 type __CapturedError = any;
44
45 type RawEventEmitterEvent = $ReadOnly<{
46 eventName: string,
47 // We expect, but do not/cannot require, that nativeEvent is an object
48 // with the properties: key, elementType (string), type (string), tag (numeric),
49 // and a stateNode of the native element/Fiber the event was emitted to.
50 nativeEvent: {[string]: mixed, ...},
51 }>;
52
53 declare opaque type __PublicInstance;
54 declare opaque type __PublicTextInstance;
55 declare opaque type __PublicRootInstance;
56
57 declare module 'react-native/react-private-interface' {
58 declare export function deepFreezeAndThrowOnMutationInDev<T>(obj: T): T;
59 declare export const ReactFiberErrorDialog: {
60 showErrorDialog: (error: __CapturedError) => boolean,
61 ...
62 };
63 declare export const ReactNativeViewConfigRegistry: {
64 customBubblingEventTypes: Object,
65 customDirectEventTypes: Object,
66
67 register: (name: string, callback: __ViewConfigGetter) => string,
68 get: (name: string) => __ReactNativeBaseComponentViewConfig,
69 ...
70 };
71 declare export const RawEventEmitter: {
72 emit: (channel: string, event: RawEventEmitterEvent) => string,
73 ...
74 };
75 declare export type PublicInstance = __PublicInstance;
76 declare export type PublicTextInstance = __PublicTextInstance;
77 declare export type PublicRootInstance = __PublicRootInstance;
78 declare export type MeasureOnSuccessCallback = __MeasureOnSuccessCallback;
79 declare export type MeasureInWindowOnSuccessCallback =
80 __MeasureInWindowOnSuccessCallback;
81 declare export type MeasureLayoutOnSuccessCallback =
82 __MeasureLayoutOnSuccessCallback;
83 declare export function getNodeFromPublicInstance(
84 publicInstance: PublicInstance,
85 ): Object;
86 declare export function getNativeTagFromPublicInstance(
87 publicInstance: PublicInstance,
88 ): number;
89 declare export function createPublicInstance(
90 tag: number,
91 viewConfig: __ViewConfig,
92 internalInstanceHandle: mixed,
93 publicRootInstance: PublicRootInstance | null,
94 ): PublicInstance;
95 declare export function createPublicRootInstance(
96 rootTag: number,
97 ): PublicRootInstance;
98 declare export function createPublicTextInstance(
99 internalInstanceHandle: mixed,
100 ): PublicTextInstance;
101 declare export function getInternalInstanceHandleFromPublicInstance(
102 publicInstance: PublicInstance,
103 ): ?Object;
104 declare export function dispatchNativeEvent(
105 target: EventTarget,
106 type: string,
107 eventData: {[string]: mixed},
108 ): void;
109 declare export function createAttributePayload(
110 props: Object,
111 validAttributes: __AttributeConfiguration,
112 ): null | Object;
113 declare export function diffAttributePayloads(
114 prevProps: Object,
115 nextProps: Object,
116 validAttributes: __AttributeConfiguration,
117 ): null | Object;
118 }
119
120 declare module 'react-native/setup-env' {
121 }
122
123 declare module 'react-native' {
124 declare export type HostInstance = __PublicInstance;
125 declare export type PublicTextInstance = __PublicTextInstance;
126 declare export type PublicRootInstance = __PublicRootInstance;
127 declare export type MeasureOnSuccessCallback = __MeasureOnSuccessCallback;
128 }
129
130 // eslint-disable-next-line no-unused-vars
131 declare const RN$isNativeEventTargetEventDispatchingEnabled:
132 | (() => boolean)
133 | void;
134
135 // This is needed for a short term solution.
136 // See https://github.com/facebook/react/pull/15490 for more info
137 // eslint-disable-next-line no-unused-vars
138 declare const nativeFabricUIManager: {
139 createNode: (
140 reactTag: number,
141 viewName: string,
142 rootTag: number,
143 props: ?Object,
144 eventTarget: Object,
145 ) => Object,
146 cloneNode: (node: Object) => Object,
147 cloneNodeWithNewChildren: (
148 node: Object,
149 children?: $ReadOnlyArray<Object>,
150 ) => Object,
151 cloneNodeWithNewProps: (node: Object, newProps: ?Object) => Object,
152 cloneNodeWithNewChildrenAndProps: (
153 node: Object,
154 newPropsOrChildren: ?Object | $ReadOnlyArray<Object>,
155 newProps?: ?Object,
156 ) => Object,
157 appendChild: (node: Object, childNode: Object) => void,
158
159 createChildSet: () => Object,
160 appendChildToSet: (childSet: Object, childNode: Object) => void,
161 completeRoot: (rootTag: number, childSet: Object) => void,
162 registerEventHandler: (
163 callback: (
164 eventTarget: null | Object,
165 type: __RNTopLevelEventType,
166 payload: Object,
167 ) => void,
168 ) => void,
169 setNativeProps: (node: Object, nativeProps: Object) => Object,
170 dispatchCommand: (node: Object, command: string, args: Array<any>) => void,
171 sendAccessibilityEvent: (node: Object, eventTypeName: string) => void,
172
173 measure: (node: Object, callback: __MeasureOnSuccessCallback) => void,
174 measureInWindow: (
175 node: Object,
176 callback: __MeasureInWindowOnSuccessCallback,
177 ) => void,
178 measureLayout: (
179 node: Object,
180 relativeNode: Object,
181 onFail: () => void,
182 onSuccess: __MeasureLayoutOnSuccessCallback,
183 ) => void,
184 getBoundingClientRect: (
185 node: Object,
186 ) => [
187 /* x:*/ number,
188 /* y:*/ number,
189 /* width:*/ number,
190 /* height:*/ number,
191 ],
192 findNodeAtPoint: (
193 node: Object,
194 locationX: number,
195 locationY: number,
196 callback: (Object) => void,
197 ) => void,
198 setIsJSResponder: (
199 node: Object,
200 isJsResponder: boolean,
201 blockNativeResponder: boolean,
202 ) => void,
203 unstable_DefaultEventPriority: number,
204 unstable_DiscreteEventPriority: number,
205 unstable_ContinuousEventPriority: number,
206 unstable_IdleEventPriority: number,
207 unstable_getCurrentEventPriority: () => number,
208 applyViewTransitionName: (
209 node: Object,
210 name: string,
211 className: ?string,
212 ) => void,
213 createViewTransitionInstance: (name: string, tag: number) => void,
214 startViewTransition: (mutationCallback: () => void) => {
215 finished: Promise<void>,
216 ready: Promise<void>,
217 },
218 startViewTransitionReadyFinished: () => void,
219 suspendOnActiveViewTransition: () => void,
220 ...
221 };