UNPKG

react-native

Version:

A framework for building native apps using React

73 lines (65 loc) • 2.34 kB
/** * 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 */ import type { RootTag, TurboModule, } from '../../../../Libraries/TurboModule/RCTExport'; import type { EventEmitter, UnsafeObject, } from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export enum EnumInt { A = 23, B = 42, } export type ObjectStruct = { a: number, b: string, c?: ?string, }; export interface Spec extends TurboModule { readonly onPress: EventEmitter<void>; readonly onClick: EventEmitter<string>; readonly onChange: EventEmitter<ObjectStruct>; readonly onSubmit: EventEmitter<ObjectStruct[]>; // Exported methods. readonly getConstants: () => { const1: boolean, const2: number, const3: string, }; readonly voidFunc: () => void; readonly getBool: (arg: boolean) => boolean; readonly getEnum?: (arg: EnumInt) => EnumInt; readonly getNumber: (arg: number) => number; readonly getString: (arg: string) => string; readonly getArray: (arg: Array<unknown>) => Array<unknown>; readonly getObject: (arg: UnsafeObject) => UnsafeObject; readonly getUnsafeObject: (arg: UnsafeObject) => UnsafeObject; readonly getRootTag: (arg: RootTag) => RootTag; readonly getValue: (x: number, y: string, z: UnsafeObject) => UnsafeObject; readonly getArrayBuffer: (buffer: ArrayBuffer) => ArrayBuffer; readonly createNativeBuffer: (size: number) => ArrayBuffer; readonly processAsyncBuffer: (payload: ArrayBuffer) => Promise<number>; readonly getValueWithCallback: (callback: (value: string) => void) => void; readonly getValueWithPromise: (error: boolean) => Promise<string>; readonly voidFuncThrows?: () => void; readonly getObjectThrows?: (arg: UnsafeObject) => UnsafeObject; readonly promiseThrows?: () => Promise<void>; readonly voidFuncAssert?: () => void; readonly getObjectAssert?: (arg: UnsafeObject) => UnsafeObject; readonly promiseAssert?: () => Promise<void>; // Android-only readonly getImageUrl?: () => Promise<string | null>; } export default TurboModuleRegistry.getEnforcing<Spec>( 'SampleTurboModule', ) as Spec;