-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { requireNativeModule } from 'expo-modules-core'; | ||
|
||
type ExpoGoModule = { | ||
expoVersion: string; | ||
projectConfig: ExpoGoProjectConfig; | ||
}; | ||
|
||
type ExpoGoProjectConfig = { | ||
mainModuleName?: string; | ||
debuggerHost?: string; | ||
logUrl?: string; | ||
developer?: { | ||
tool?: string; | ||
[key: string]: any; | ||
}; | ||
packagerOpts?: ExpoGoPackagerOpts; | ||
}; | ||
|
||
type ExpoGoPackagerOpts = { | ||
hostType?: string; | ||
dev?: boolean; | ||
strict?: boolean; | ||
minify?: boolean; | ||
urlType?: string; | ||
urlRandomness?: string; | ||
lanType?: string; | ||
[key: string]: any; | ||
}; | ||
|
||
// ExpoGo module is available only when the app is run in Expo Go, | ||
// otherwise we use `null` instead of throwing an error. | ||
const NativeExpoGoModule = ((): ExpoGoModule | null => { | ||
try { | ||
return requireNativeModule('ExpoGo'); | ||
} catch { | ||
return null; | ||
} | ||
})(); | ||
|
||
/** | ||
* Returns a boolean value whether the app is running in Expo Go. | ||
*/ | ||
export function isRunningInExpoGo(): boolean { | ||
return NativeExpoGoModule != null; | ||
} | ||
|
||
/** | ||
* Returns an Expo Go project config from the manifest or `null` if the app is not running in Expo Go. | ||
*/ | ||
export function getExpoGoProjectConfig(): ExpoGoProjectConfig | null { | ||
return NativeExpoGoModule?.projectConfig ?? null; | ||
} |