From c5e40d669577fd509603904328288dae0f91fc7d Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 17 Oct 2024 19:43:49 +0300 Subject: new platform util (#5791) --- src/alf/util/platform.ts | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/alf/util/platform.ts b/src/alf/util/platform.ts index 294e08a8b..947f2bd16 100644 --- a/src/alf/util/platform.ts +++ b/src/alf/util/platform.ts @@ -1,25 +1,62 @@ -import {isAndroid, isIOS, isNative, isWeb} from 'platform/detection' +import {Platform} from 'react-native' +import {isAndroid, isIOS, isNative, isWeb} from '#/platform/detection' + +/** + * Identity function on web. Returns nothing on other platforms. + * + * Note: Platform splitting does not tree-shake away the other platforms, + * so don't do stuff like e.g. rely on platform-specific imports. Use + * platform-split files instead. + */ export function web(value: any) { if (isWeb) { return value } } +/** + * Identity function on iOS. Returns nothing on other platforms. + * + * Note: Platform splitting does not tree-shake away the other platforms, + * so don't do stuff like e.g. rely on platform-specific imports. Use + * platform-split files instead. + */ export function ios(value: any) { if (isIOS) { return value } } +/** + * Identity function on Android. Returns nothing on other platforms.. + * + * Note: Platform splitting does not tree-shake away the other platforms, + * so don't do stuff like e.g. rely on platform-specific imports. Use + * platform-split files instead. + */ export function android(value: any) { if (isAndroid) { return value } } +/** + * Identity function on iOS and Android. Returns nothing on web. + * + * Note: Platform splitting does not tree-shake away the other platforms, + * so don't do stuff like e.g. rely on platform-specific imports. Use + * platform-split files instead. + */ export function native(value: any) { if (isNative) { return value } } + +/** + * Note: Platform splitting does not tree-shake away the other platforms, + * so don't do stuff like e.g. rely on platform-specific imports. Use + * platform-split files instead. + */ +export const platform = Platform.select -- cgit 1.4.1