about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-10-17 19:43:49 +0300
committerGitHub <noreply@github.com>2024-10-17 11:43:49 -0500
commitc5e40d669577fd509603904328288dae0f91fc7d (patch)
treea2f07661bbf85ed9c5ac742848e06a688363ef4c
parentbe725f79ba6a51e8cda42f1ea57a9a943f0aaeaa (diff)
downloadvoidsky-c5e40d669577fd509603904328288dae0f91fc7d.tar.zst
new platform util (#5791)
-rw-r--r--src/alf/util/platform.ts39
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