import { Platform } from 'react-native'; import { Uniwind } from 'uniwind'; import { DEFAULT_PRESET, applyThemeOverrideWithRuntime, type ApplyThemeOverrideOptions, type ApplyThemeOverrideResult, type UpdateCssVariables, } from './applyThemeOverrideRuntime'; import type { Platform as ForgePlatform } from './types'; export { DEFAULT_PRESET }; export type { ApplyThemeOverrideOptions, ApplyThemeOverrideResult, UpdateCssVariables, } from './applyThemeOverrideRuntime'; const updateCssVariables: UpdateCssVariables = (mode, variables) => { Uniwind.updateCSSVariables(mode, { ...variables }); }; function detectNativePlatform(): ForgePlatform { return Platform.OS === 'ios' || Platform.OS === 'android' ? Platform.OS : 'web'; } export function applyThemeOverride( override: unknown, options: ApplyThemeOverrideOptions = {}, ): ApplyThemeOverrideResult { return applyThemeOverrideWithRuntime(override, { runtimeMap: options.runtimeMap, runtimePlatform: options.runtimePlatform ?? detectNativePlatform(), getUpdateCSSVariables: () => options.updateCSSVariables ?? updateCssVariables, }); }