let deferredPrompt = null export function rememberInstallPrompt(event) { event.preventDefault() deferredPrompt = event } export function isIosDevice(agent = typeof navigator === 'undefined' ? '' : navigator.userAgent) { return /iPhone|iPad|iPod/.test(agent) } export function isAndroidDevice(agent = typeof navigator === 'undefined' ? '' : navigator.userAgent) { return /Android/.test(agent) } export function installHelp({ secure = window.isSecureContext, agent = navigator.userAgent } = {}) { if (!secure) return 'Bookmark this local address for hotspot or Wi-Fi access without Internet. To install Galaxy as a web app (PWA), open your device-specific https://galaxy.firestar.link link from Galaxy Access & Install; this remote link needs Internet.' if (/iPhone|iPad|iPod/.test(agent)) return 'Open Galaxy in Safari, tap Share, then Add to Home Screen. Turn on Open as Web App if shown.' return 'This browser cannot install Galaxy automatically. Open the browser menu and choose Install app or Add to Home Screen. On a Mac in Safari, choose File → Add to Dock.' } export const ANDROID_BETA_URL = 'https://groups.google.com/g/galaxy-starpilot-android-beta' export const InstallApp = { name: 'InstallApp', props: { url: { type: String, default: '' }, updateAvailable: { type: Boolean, default: false } }, data: () => ({ prompt: null, installed: false, message: '', betaUrl: ANDROID_BETA_URL, android: isAndroidDevice(), ios: isIosDevice() }), computed: { playDistribution() { return window.StarPilotApp?.distribution?.() === 'play' }, onPublicGalaxy() { return window.location?.hostname === 'galaxy.firestar.link' } }, mounted() { this.prompt = deferredPrompt this.displayMode = window.matchMedia('(display-mode: standalone)') this.updateInstalled = () => { this.installed = !!window.StarPilotApp || this.displayMode.matches || navigator.standalone === true } this.onPrompt = (event) => { event.preventDefault(); deferredPrompt = event; this.prompt = event } this.onInstalled = () => { this.installed = true; this.prompt = deferredPrompt = null } this.updateInstalled() window.addEventListener('beforeinstallprompt', this.onPrompt) window.addEventListener('appinstalled', this.onInstalled) this.displayMode.addEventListener('change', this.updateInstalled) }, beforeUnmount() { window.removeEventListener('beforeinstallprompt', this.onPrompt) window.removeEventListener('appinstalled', this.onInstalled) this.displayMode?.removeEventListener('change', this.updateInstalled) this.prompt = null }, methods: { installHelp, async installWeb() { if (!this.prompt) return const prompt = this.prompt this.prompt = deferredPrompt = null try { await prompt.prompt() await prompt.userChoice } catch { this.message = installHelp() } }, installAndroid() { if (this.updateAvailable && typeof window.StarPilotApp?.installUpdate === 'function') { window.StarPilotApp.installUpdate() return } location.assign(ANDROID_BETA_URL) }, }, template: `
Galaxy is installed.
{{ installHelp() }}
{{ message }}
Install web appPair in step 1 to get your install link.
Download StarPilot BT on the App Store Join the Android betaUpdates come from Google Play.