diff options
-rw-r--r-- | src/alf/util/platform.ts | 39 |
1 files changed, 38 insertions, 1 deletions
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 |