/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format */ 'use strict'; const NOT_A_NATIVE_COMPONENT = ` const requireNativeComponent = require('requireNativeComponent').default; export default 'Not a view config' `; const FULL_NATIVE_COMPONENT = ` // @flow const codegenNativeCommands = require('codegenNativeCommands'); const codegenNativeComponent = require('codegenNativeComponent'); import type { Int32, BubblingEventHandler, DirectEventHandler, WithDefault, } from 'CodegenFlowtypes'; import type {NativeComponentType} from 'codegenNativeComponent'; import type {ViewProps} from 'ViewPropTypes'; type ModuleProps = $ReadOnly<{| ...ViewProps, // Props boolean_default_true_optional_both?: WithDefault, // Events onDirectEventDefinedInlineNull: DirectEventHandler, onBubblingEventDefinedInlineNull: BubblingEventHandler, |}>; type NativeType = NativeComponentType; interface NativeCommands { +hotspotUpdate: (viewRef: React.ElementRef, x: Int32, y: Int32) => void; +scrollTo: (viewRef: React.ElementRef, y: Int32, animated: boolean) => void; } export const Commands = codegenNativeCommands({ supportedCommands: ['hotspotUpdate', 'scrollTo'], }); export default codegenNativeComponent('Module', { interfaceOnly: true, paperComponentName: 'RCTModule', }); `; const FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT = ` // @flow const codegenNativeCommands = require('codegenNativeCommands'); const codegenNativeComponent = require('codegenNativeComponent'); import type {NativeComponentType} from 'codegenNativeComponent'; import type { Int32, BubblingEventHandler, DirectEventHandler, WithDefault, } from 'CodegenFlowtypes'; import type {ViewProps} from 'ViewPropTypes'; type ModuleProps = $ReadOnly<{| ...ViewProps, // Props boolean_default_true_optional_both?: WithDefault, // Events onDirectEventDefinedInlineNull: DirectEventHandler, onBubblingEventDefinedInlineNull: BubblingEventHandler, |}>; type NativeType = NativeComponentType; interface NativeCommands { +hotspotUpdate: (viewRef: React.ElementRef, x: Int32, y: Int32) => void; +scrollTo: (viewRef: React.ElementRef, y: Int32, animated: boolean) => void; } export const Commands = codegenNativeCommands({ supportedCommands: ['hotspotUpdate', 'scrollTo'], }); export default (codegenNativeComponent('Module', { interfaceOnly: true, paperComponentName: 'RCTModule', }): NativeType); `; module.exports = { 'NotANativeComponent.js': NOT_A_NATIVE_COMPONENT, 'FullNativeComponent.js': FULL_NATIVE_COMPONENT, 'FullTypedNativeComponent.js': FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT, };