|
| 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 strict-local |
| 8 | + * @format |
| 9 | + */ |
| 10 | + |
| 11 | +'use strict'; |
| 12 | + |
| 13 | +// ---------------------------------------------------------------------------- |
| 14 | +// react-native/react-private-interface |
| 15 | +// |
| 16 | +// This is a private entry point allowing React to require React Native |
| 17 | +// internals (previously, Libaries/ReactNativePrivateInterface.js). |
| 18 | +// |
| 19 | +// These APIs should ONLY be used by first party React internals and are not |
| 20 | +// part of our public API. |
| 21 | +// |
| 22 | +// IMPORTANT: Keep this file in sync with react-private-interface.js.flow. |
| 23 | +// ---------------------------------------------------------------------------- |
| 24 | + |
| 25 | +import typeof BatchedBridge from '../Libraries/BatchedBridge/BatchedBridge'; |
| 26 | +import typeof legacySendAccessibilityEvent from '../Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent'; |
| 27 | +import typeof TextInputState from '../Libraries/Components/TextInput/TextInputState'; |
| 28 | +import typeof ExceptionsManager from '../Libraries/Core/ExceptionsManager'; |
| 29 | +import typeof RawEventEmitter from '../Libraries/Core/RawEventEmitter'; |
| 30 | +import typeof ReactFiberErrorDialog from '../Libraries/Core/ReactFiberErrorDialog'; |
| 31 | +import typeof RCTEventEmitter from '../Libraries/EventEmitter/RCTEventEmitter'; |
| 32 | +import typeof { |
| 33 | + createPublicInstance, |
| 34 | + createPublicRootInstance, |
| 35 | + createPublicTextInstance, |
| 36 | + getInternalInstanceHandleFromPublicInstance, |
| 37 | + getNativeTagFromPublicInstance, |
| 38 | + getNodeFromPublicInstance, |
| 39 | +} from '../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; |
| 40 | +import typeof { |
| 41 | + create as createAttributePayload, |
| 42 | + diff as diffAttributePayloads, |
| 43 | +} from '../Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload'; |
| 44 | +import typeof UIManager from '../Libraries/ReactNative/UIManager'; |
| 45 | +import typeof * as ReactNativeViewConfigRegistry from '../Libraries/Renderer/shims/ReactNativeViewConfigRegistry'; |
| 46 | +import typeof flattenStyle from '../Libraries/StyleSheet/flattenStyle'; |
| 47 | +import type {DangerouslyImpreciseStyleProp} from '../Libraries/StyleSheet/StyleSheet'; |
| 48 | +import typeof deepFreezeAndThrowOnMutationInDev from '../Libraries/Utilities/deepFreezeAndThrowOnMutationInDev'; |
| 49 | +import typeof deepDiffer from '../Libraries/Utilities/differ/deepDiffer'; |
| 50 | +import typeof Platform from '../Libraries/Utilities/Platform'; |
| 51 | +import typeof dispatchNativeEvent from './private/renderer/events/dispatchNativeEvent'; |
| 52 | +import typeof CustomEvent from './private/webapis/dom/events/CustomEvent'; |
| 53 | + |
| 54 | +export type {PublicRootInstance} from '../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; |
| 55 | +export type PublicTextInstance = ReturnType<createPublicTextInstance>; |
| 56 | + |
| 57 | +// flowlint unsafe-getters-setters:off |
| 58 | +// eslint-disable-next-line @react-native/monorepo/no-commonjs-exports |
| 59 | +module.exports = { |
| 60 | + get BatchedBridge(): BatchedBridge { |
| 61 | + return require('../Libraries/BatchedBridge/BatchedBridge').default; |
| 62 | + }, |
| 63 | + get ExceptionsManager(): ExceptionsManager { |
| 64 | + return require('../Libraries/Core/ExceptionsManager').default; |
| 65 | + }, |
| 66 | + get Platform(): Platform { |
| 67 | + return require('../Libraries/Utilities/Platform').default; |
| 68 | + }, |
| 69 | + get RCTEventEmitter(): RCTEventEmitter { |
| 70 | + return require('../Libraries/EventEmitter/RCTEventEmitter').default; |
| 71 | + }, |
| 72 | + get ReactNativeViewConfigRegistry(): ReactNativeViewConfigRegistry { |
| 73 | + return require('../Libraries/Renderer/shims/ReactNativeViewConfigRegistry'); |
| 74 | + }, |
| 75 | + get TextInputState(): TextInputState { |
| 76 | + return require('../Libraries/Components/TextInput/TextInputState').default; |
| 77 | + }, |
| 78 | + get UIManager(): UIManager { |
| 79 | + return require('../Libraries/ReactNative/UIManager').default; |
| 80 | + }, |
| 81 | + // TODO: Remove when React has migrated to `createAttributePayload` and `diffAttributePayloads` |
| 82 | + get deepDiffer(): deepDiffer { |
| 83 | + return require('../Libraries/Utilities/differ/deepDiffer').default; |
| 84 | + }, |
| 85 | + get deepFreezeAndThrowOnMutationInDev(): deepFreezeAndThrowOnMutationInDev< |
| 86 | + {...} | Array<unknown>, |
| 87 | + > { |
| 88 | + return require('../Libraries/Utilities/deepFreezeAndThrowOnMutationInDev') |
| 89 | + .default; |
| 90 | + }, |
| 91 | + // TODO: Remove when React has migrated to `createAttributePayload` and `diffAttributePayloads` |
| 92 | + get flattenStyle(): flattenStyle<DangerouslyImpreciseStyleProp> { |
| 93 | + // $FlowFixMe[underconstrained-implicit-instantiation] |
| 94 | + // $FlowFixMe[incompatible-type] |
| 95 | + return require('../Libraries/StyleSheet/flattenStyle').default; |
| 96 | + }, |
| 97 | + get ReactFiberErrorDialog(): ReactFiberErrorDialog { |
| 98 | + return require('../Libraries/Core/ReactFiberErrorDialog').default; |
| 99 | + }, |
| 100 | + get legacySendAccessibilityEvent(): legacySendAccessibilityEvent { |
| 101 | + return require('../Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent') |
| 102 | + .default; |
| 103 | + }, |
| 104 | + get RawEventEmitter(): RawEventEmitter { |
| 105 | + return require('../Libraries/Core/RawEventEmitter').default; |
| 106 | + }, |
| 107 | + get CustomEvent(): CustomEvent { |
| 108 | + return require('./private/webapis/dom/events/CustomEvent').default; |
| 109 | + }, |
| 110 | + get createAttributePayload(): createAttributePayload { |
| 111 | + return require('../Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload') |
| 112 | + .create; |
| 113 | + }, |
| 114 | + get diffAttributePayloads(): diffAttributePayloads { |
| 115 | + return require('../Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload') |
| 116 | + .diff; |
| 117 | + }, |
| 118 | + get createPublicRootInstance(): createPublicRootInstance { |
| 119 | + return require('../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance') |
| 120 | + .createPublicRootInstance; |
| 121 | + }, |
| 122 | + get createPublicInstance(): createPublicInstance { |
| 123 | + return require('../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance') |
| 124 | + .createPublicInstance; |
| 125 | + }, |
| 126 | + get createPublicTextInstance(): createPublicTextInstance { |
| 127 | + return require('../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance') |
| 128 | + .createPublicTextInstance; |
| 129 | + }, |
| 130 | + get getNativeTagFromPublicInstance(): getNativeTagFromPublicInstance { |
| 131 | + return require('../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance') |
| 132 | + .getNativeTagFromPublicInstance; |
| 133 | + }, |
| 134 | + get getNodeFromPublicInstance(): getNodeFromPublicInstance { |
| 135 | + return require('../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance') |
| 136 | + .getNodeFromPublicInstance; |
| 137 | + }, |
| 138 | + get getInternalInstanceHandleFromPublicInstance(): getInternalInstanceHandleFromPublicInstance { |
| 139 | + return require('../Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance') |
| 140 | + .getInternalInstanceHandleFromPublicInstance; |
| 141 | + }, |
| 142 | + get dispatchNativeEvent(): dispatchNativeEvent { |
| 143 | + return require('./private/renderer/events/dispatchNativeEvent').default; |
| 144 | + }, |
| 145 | +}; |
0 commit comments