()
| 14 | export const PlatformContext = createContext<PlatformContextProps | undefined>(undefined); |
| 15 | |
| 16 | function getOS(): Platform { |
| 17 | const platform = window.navigator.platform; |
| 18 | const macosPlatforms = ["Macintosh", "MacIntel", "MacPPC", "Mac68K"]; |
| 19 | const windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"]; |
| 20 | const iosPlatforms = ["iPhone", "iPad", "iPod"]; |
| 21 | |
| 22 | if (macosPlatforms.includes(platform) || iosPlatforms.includes(platform)) { |
| 23 | return "mac"; |
| 24 | } else if (windowsPlatforms.includes(platform)) { |
| 25 | return "windows"; |
| 26 | } else { |
| 27 | return "linux"; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | const PlatformProviderInternal = ({ children }: { children: ReactNode }) => { |
| 32 | const [platform, setPlatform] = useState<Platform>(getOS()); |
no outgoing calls
no test coverage detected