// public types import type { EventSubscription } from 'react-native'; import { Platform } from 'react-native'; import type { TBLRNTLogLevel } from './NativeTBLRNTTurboModule'; import { PLATFORMS, isSupportedPlatform } from './consts/platforms'; // Unified log level enum for JavaScript layer export enum TBLLogLevel { VERBOSE = 'VERBOSE', DEBUG = 'DEBUG', INFO = 'INFO', WARNING = 'WARNING', ERROR = 'ERROR', } // Platform-specific mappings const TBLLogLevelMapping = { [PLATFORMS.IOS]: { [TBLLogLevel.VERBOSE]: 0, [TBLLogLevel.DEBUG]: 1, [TBLLogLevel.INFO]: 2, [TBLLogLevel.WARNING]: 3, [TBLLogLevel.ERROR]: 4, }, [PLATFORMS.ANDROID]: { [TBLLogLevel.VERBOSE]: 2, [TBLLogLevel.DEBUG]: 3, [TBLLogLevel.INFO]: 4, [TBLLogLevel.WARNING]: 5, [TBLLogLevel.ERROR]: 6, }, } as const; // Helper function with better type safety and fallback export const convertToPlatformLogLevel = ( level: TBLLogLevel ): TBLRNTLogLevel => { if (!isSupportedPlatform(Platform.OS)) { console.warn( `[TBLLogLevel] Unsupported platform '${Platform.OS}', falling back to iOS mapping` ); return TBLLogLevelMapping[PLATFORMS.IOS][level] as TBLRNTLogLevel; } return TBLLogLevelMapping[Platform.OS][level] as TBLRNTLogLevel; }; export enum TBLFetchingPolicy { PARALLEL, SERIAL, } export enum TBLPlacementType { PAGE_MIDDLE, PAGE_BOTTOM, FEED, } export interface TBLExtraProperties { [key: string]: string; } export type OnResizeArgs = { height: number; placement: string }; export type RNNativeTBLEvents = { onResize: EventSubscription; onItemClick: EventSubscription; onTaboolaWidgetOnTop: EventSubscription; onAdReceiveSuccess: EventSubscription; onAdReceiveFail: EventSubscription; onUpdateContentCompleted: EventSubscription; onEvent: EventSubscription; }; export type ResizeCallback = (event: OnResizeArgs) => void;