mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
20 lines
695 B
TypeScript
20 lines
695 B
TypeScript
import { type CurrentLocation } from './location-types'
|
|
export { type CurrentLocation } from './location-types'
|
|
declare const FaceclawLocationUpdates: any
|
|
|
|
/** Main-thread one-shot lookup, independent of navigation and compass managers. */
|
|
export function getCurrentLocation(): Promise<CurrentLocation> {
|
|
return new Promise((resolve, reject) => {
|
|
const provider = FaceclawLocationUpdates.new()
|
|
provider.eventHandler = (json: string) => {
|
|
try {
|
|
const event = JSON.parse(json)
|
|
if (event.error) reject(new Error(event.error))
|
|
else resolve(event)
|
|
} catch (error) { reject(error) }
|
|
finally { provider.stop() }
|
|
}
|
|
provider.startOnce()
|
|
})
|
|
}
|