import { useDevice, useRuntimeConfig } from '#imports' /** * Composable to determine if the game is being played within a webview. * It checks the user agent stored in local storage against a predefined webview user agent. * * @returns {Object} An object containing the `isPlayingInWebview` function. */ export function usePlayGameInWebview() { const { isMobile } = useDevice() const { WEBVIEW_USER_AGENT } = useRuntimeConfig().public /** * Checks if the current environment is a webview. * This is determined by comparing the user agent stored in local storage with a predefined webview user agent. * * @returns {boolean} True if the game is being played in a webview, false otherwise. */ const isPlayingInWebview = (): boolean => { if (!isMobile) { return false } try { const ua = localStorage?.getItem('ua') return Boolean(ua && ua === WEBVIEW_USER_AGENT) } catch (error) { console.error('Error checking if playing in webview:', error) return false } } return { isPlayingInWebview, } }