1313 * instances and get some data from them (like their instance handle / fiber).
1414 */
1515
16- import type ReactNativeDocumentT from '../../../src/private/webapis/dom/nodes/ReactNativeDocument' ;
17- import typeof * as ReactNativeDocumentModuleT from '../../../src/private/webapis/dom/nodes/ReactNativeDocument' ;
18- import type ReactNativeElementT from '../../../src/private/webapis/dom/nodes/ReactNativeElement' ;
19- import type ReadOnlyTextT from '../../../src/private/webapis/dom/nodes/ReadOnlyText' ;
20- import typeof * as RendererProxyT from '../../ReactNative/RendererProxy' ;
2116import type {
2217 InternalInstanceHandle ,
2318 Node ,
2419 ViewConfig ,
2520} from '../../Renderer/shims/ReactNativeTypes' ;
2621import type { RootTag } from '../RootTag' ;
2722
28- export opaque type PublicRootInstance = mixed ;
29-
30- // Lazy loaded to avoid evaluating the module when using the legacy renderer.
31- let ReactNativeDocumentModuleObject : ?ReactNativeDocumentModuleT ;
32- let ReactNativeElementClass : Class < ReactNativeElementT > ;
33- let ReadOnlyTextClass : Class < ReadOnlyTextT > ;
34- let RendererProxy : RendererProxyT ;
35-
36- function getReactNativeDocumentModule ( ) : ReactNativeDocumentModuleT {
37- if ( ReactNativeDocumentModuleObject == null ) {
38- // We initialize this lazily to avoid a require cycle.
39- ReactNativeDocumentModuleObject = require ( '../../../src/private/webapis/dom/nodes/ReactNativeDocument' ) ;
40- }
41-
42- return ReactNativeDocumentModuleObject ;
43- }
44-
45- function getReactNativeElementClass ( ) : Class < ReactNativeElementT > {
46- if ( ReactNativeElementClass == null ) {
47- ReactNativeElementClass =
48- require ( '../../../src/private/webapis/dom/nodes/ReactNativeElement' ) . default ;
49- }
50- return ReactNativeElementClass ;
51- }
23+ import ReactNativeDocument , {
24+ createReactNativeDocument ,
25+ } from '../../../src/private/webapis/dom/nodes/ReactNativeDocument' ;
26+ import ReactNativeElement from '../../../src/private/webapis/dom/nodes/ReactNativeElement' ;
27+ import ReadOnlyText from '../../../src/private/webapis/dom/nodes/ReadOnlyText' ;
28+ import * as RendererProxy from '../../ReactNative/RendererProxy' ;
5229
53- function getReadOnlyTextClass ( ) : Class < ReadOnlyTextT > {
54- if ( ReadOnlyTextClass == null ) {
55- ReadOnlyTextClass =
56- require ( '../../../src/private/webapis/dom/nodes/ReadOnlyText' ) . default ;
57- }
58- return ReadOnlyTextClass ;
59- }
30+ export opaque type PublicRootInstance = mixed ;
6031
6132export function createPublicRootInstance ( rootTag : RootTag ) : PublicRootInstance {
62- const ReactNativeDocumentModule = getReactNativeDocumentModule ( ) ;
63-
6433 // $FlowExpectedError[incompatible-return]
65- return ReactNativeDocumentModule . createReactNativeDocument ( rootTag ) ;
34+ return createReactNativeDocument ( rootTag ) ;
6635}
6736
6837export function createPublicInstance (
6938 tag : number ,
7039 viewConfig : ViewConfig ,
7140 internalInstanceHandle : InternalInstanceHandle ,
72- ownerDocument : ReactNativeDocumentT ,
73- ) : ReactNativeElementT {
74- const ReactNativeElement = getReactNativeElementClass ( ) ;
41+ ownerDocument : ReactNativeDocument ,
42+ ) : ReactNativeElement {
7543 return new ReactNativeElement (
7644 tag ,
7745 viewConfig ,
@@ -82,37 +50,33 @@ export function createPublicInstance(
8250
8351export function createPublicTextInstance (
8452 internalInstanceHandle : InternalInstanceHandle ,
85- ownerDocument : ReactNativeDocumentT ,
86- ) : ReadOnlyTextT {
87- const ReadOnlyText = getReadOnlyTextClass ( ) ;
53+ ownerDocument : ReactNativeDocument ,
54+ ) : ReadOnlyText {
8855 return new ReadOnlyText ( internalInstanceHandle , ownerDocument ) ;
8956}
9057
9158export function getNativeTagFromPublicInstance (
92- publicInstance : ReactNativeElementT ,
59+ publicInstance : ReactNativeElement ,
9360) : number {
9461 return publicInstance . __nativeTag ;
9562}
9663
9764export function getNodeFromPublicInstance (
98- publicInstance : ReactNativeElementT ,
65+ publicInstance : ReactNativeElement ,
9966) : ?Node {
10067 // Avoid loading ReactFabric if using an instance from the legacy renderer.
10168 if ( publicInstance . __internalInstanceHandle == null ) {
10269 return null ;
10370 }
10471
105- if ( RendererProxy == null ) {
106- RendererProxy = require ( '../../ReactNative/RendererProxy' ) ;
107- }
10872 return RendererProxy . getNodeFromInternalInstanceHandle (
10973 // $FlowExpectedError[incompatible-type] __internalInstanceHandle is always an InternalInstanceHandle from React when we get here.
11074 publicInstance . __internalInstanceHandle ,
11175 ) ;
11276}
11377
11478export function getInternalInstanceHandleFromPublicInstance (
115- publicInstance : ReactNativeElementT ,
79+ publicInstance : ReactNativeElement ,
11680) : InternalInstanceHandle {
11781 // TODO(T174762768): Remove this once OSS versions of renderers will be synced.
11882 // $FlowExpectedError[prop-missing] Keeping this for backwards-compatibility with the renderers versions in open source.
0 commit comments