1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @format
8 */
9
10/**
11 * @see https://reactnative.dev/docs/platform-specific-code#content
12 */
13export type PlatformOSType =
14  | 'ios'
15  | 'android'
16  | 'macos'
17  | 'windows'
18  | 'web'
19  | 'native';
20type PlatformConstants = {
21  isTesting: boolean;
22  reactNativeVersion: {
23    major: number;
24    minor: number;
25    patch: number;
26    prerelease?: number | null | undefined;
27  };
28};
29interface PlatformStatic {
30  isTV: boolean;
31  isTesting: boolean;
32  Version: number | string;
33  constants: PlatformConstants;
34
35  /**
36   * @see https://reactnative.dev/docs/platform-specific-code#content
37   */
38  select<T>(
39    specifics:
40      | ({[platform in PlatformOSType]?: T} & {default: T})
41      | {[platform in PlatformOSType]: T},
42  ): T;
43  select<T>(specifics: {[platform in PlatformOSType]?: T}): T | undefined;
44}
45
46interface PlatformIOSStatic extends PlatformStatic {
47  constants: PlatformConstants & {
48    forceTouchAvailable: boolean;
49    interfaceIdiom: string;
50    osVersion: string;
51    systemName: string;
52  };
53  OS: 'ios';
54  isPad: boolean;
55  isTV: boolean;
56  Version: string;
57}
58
59interface PlatformAndroidStatic extends PlatformStatic {
60  constants: PlatformConstants & {
61    Version: number;
62    Release: string;
63    Serial: string;
64    Fingerprint: string;
65    Model: string;
66    Brand: string;
67    Manufacturer: string;
68    ServerHost?: string | undefined;
69    uiMode: 'car' | 'desk' | 'normal' | 'tv' | 'watch' | 'unknown';
70  };
71  OS: 'android';
72  Version: number;
73}
74
75interface PlatformMacOSStatic extends PlatformStatic {
76  OS: 'macos';
77  Version: string;
78  constants: PlatformConstants & {
79    osVersion: string;
80  };
81}
82
83interface PlatformWindowsOSStatic extends PlatformStatic {
84  OS: 'windows';
85  Version: number;
86  constants: PlatformConstants & {
87    osVersion: number;
88  };
89}
90
91interface PlatformWebStatic extends PlatformStatic {
92  OS: 'web';
93}
94
95export type Platform =
96  | PlatformIOSStatic
97  | PlatformAndroidStatic
98  | PlatformWindowsOSStatic
99  | PlatformMacOSStatic
100  | PlatformWebStatic;
101
102export const Platform: Platform;
103