import {registerWebModule, NativeModule} from "expo" import {CrustModuleEvents} from "./Crust.types" class CrustModule extends NativeModule { PI = Math.PI private readonly httpRequests = new Map() async setValueAsync(value: string): Promise { this.emit("onChange", {value}) } async nativeHttpRequest(requestId: string, method: string, url: string, headers: Record, body?: string | null) { const controller = new AbortController() this.httpRequests.set(requestId, controller) try { const response = await fetch(url, {method, headers, body, signal: controller.signal}) return { status: response.status, statusText: response.statusText, headers: Object.fromEntries(response.headers.entries()), body: await response.text(), } } finally { this.httpRequests.delete(requestId) } } async cancelNativeHttpRequest(requestId: string): Promise { this.httpRequests.get(requestId)?.abort() this.httpRequests.delete(requestId) } /** The web has no local files to resolve. */ canonicalFilePath(_path: string): string | null { return null } hello() { return "Hello world! 👋" } showAVRoutePicker(_tintColor?: string | null) {} async setDeferredSystemGestures(_edges: string[]): Promise {} async setNotificationConfig(_listenerEnabled: boolean, _blocklist: string[]): Promise {} async getInstalledApps() { return [] } async getInstalledAppsForNotifications() { return [] } async hasNotificationListenerPermission() { return false } async refreshNotificationListener() { return false } async openNotificationListenerSettings() { return false } async isBetaBuild() { return false } async mentraJsSpawn(_pkg: string, _polyfill: string, _miniappJs: string) { return false } async mentraJsEvaluate(_pkg: string, _src: string) { return null } async mentraJsKill(_pkg: string) { return } async mentraJsDispatchToJs(_pkg: string, _env: Record) { return } async mentraJsSetManifest(_pkg: string, _perms: string[]) { return } mentraJsAlivePackages() { return [] } async mentraJsDebugForceGC(_pkg: string) { return false } mentraJsLoadPolyfillBundle() { return "" } } export default registerWebModule(CrustModule, "CrustModule")