|
| 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 | + * @format |
| 8 | + */ |
| 9 | + |
| 10 | +import type {HostComponent} from '../../types/public/ReactNativeTypes'; |
| 11 | +import * as React from 'react'; |
| 12 | + |
| 13 | +/** |
| 14 | + * Configures a function that is called to determine whether a given component |
| 15 | + * should be registered using reflection of the native component at runtime. |
| 16 | + * |
| 17 | + * The provider should return null if the native component is unavailable in |
| 18 | + * the current environment. |
| 19 | + */ |
| 20 | +export function setRuntimeConfigProvider( |
| 21 | + runtimeConfigProvider: (name: string) => { |
| 22 | + native: boolean; |
| 23 | + verify: boolean; |
| 24 | + } | null, |
| 25 | +): void; |
| 26 | + |
| 27 | +/** |
| 28 | + * Gets a `NativeComponent` that can be rendered by React Native. |
| 29 | + * |
| 30 | + * The supplied `viewConfigProvider` may or may not be invoked and utilized, |
| 31 | + * depending on how `setRuntimeConfigProvider` is configured. |
| 32 | + */ |
| 33 | +export function get<Config extends object>( |
| 34 | + name: string, |
| 35 | + viewConfigProvider: () => PartialViewConfig, |
| 36 | +): HostComponent<Config>; |
| 37 | + |
| 38 | +/** |
| 39 | + * Same as `NativeComponentRegistry.get(...)`, except this will check either |
| 40 | + * the `setRuntimeConfigProvider` configuration or use native reflection (slow) |
| 41 | + * to determine whether this native component is available. |
| 42 | + * |
| 43 | + * If the native component is not available, a stub component is returned. Note |
| 44 | + * that the return value of this is not `HostComponent` because the returned |
| 45 | + * component instance is not guaranteed to have native methods. |
| 46 | + */ |
| 47 | +export function getWithFallback_DEPRECATED<Config extends object>( |
| 48 | + name: string, |
| 49 | + viewConfigProvider: () => PartialViewConfig, |
| 50 | +): React.ComponentType<Config>; |
| 51 | + |
| 52 | +/** |
| 53 | + * Unstable API. Do not use! |
| 54 | + * |
| 55 | + * This method returns if there is a StaticViewConfig registered for the |
| 56 | + * component name received as a parameter. |
| 57 | + */ |
| 58 | +export function unstable_hasStaticViewConfig(name: string): boolean; |
| 59 | + |
| 60 | +type AttributeType<T, V> = |
| 61 | + | true |
| 62 | + | { |
| 63 | + readonly diff?: ((arg1: T, arg2: T) => boolean) | undefined; |
| 64 | + readonly process?: ((arg1: V) => T) | undefined; |
| 65 | + }; |
| 66 | +type AnyAttributeType = AttributeType<any, any>; |
| 67 | +type AttributeConfiguration = { |
| 68 | + readonly [propName: string]: AnyAttributeType | void; |
| 69 | + readonly style?: |
| 70 | + | { |
| 71 | + readonly [propName: string]: AnyAttributeType; |
| 72 | + } |
| 73 | + | undefined; |
| 74 | +}; |
| 75 | + |
| 76 | +type PartialViewConfig = Readonly<{ |
| 77 | + bubblingEventTypes?: |
| 78 | + | { |
| 79 | + readonly [eventName: string]: { |
| 80 | + readonly phasedRegistrationNames: { |
| 81 | + readonly bubbled: string; |
| 82 | + readonly captured: string; |
| 83 | + readonly skipBubbling?: boolean | undefined; |
| 84 | + }; |
| 85 | + }; |
| 86 | + } |
| 87 | + | undefined; |
| 88 | + directEventTypes?: |
| 89 | + | { |
| 90 | + readonly [eventName: string]: { |
| 91 | + readonly registrationName: string; |
| 92 | + }; |
| 93 | + } |
| 94 | + | undefined; |
| 95 | + supportsRawText?: boolean | undefined; |
| 96 | + uiViewClassName: string; |
| 97 | + validAttributes?: AttributeConfiguration | undefined; |
| 98 | +}>; |
0 commit comments