File size: 8,491 Bytes
b450976 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | import {NativeModule, requireNativeModule} from "expo"
import {AppPermissionReceipt, AppPermissionSnapshot, CrustModuleEvents, InstalledApp} from "./Crust.types"
declare class CrustModule extends NativeModule<CrustModuleEvents> {
/** True for the native iOS app running on an Apple Silicon Mac. */
readonly isIOSAppOnMac?: boolean
/** iOS: passive actual-app authorization status; never requests consent. */
getPermissionStatus(requestId: null): Promise<AppPermissionSnapshot>
/** iOS: a nonce publishes fresh status at the fixed managed-cache path. */
getPermissionStatus(requestId: string): Promise<AppPermissionReceipt>
PI: number
hello(): string
/**
* The canonical path of an existing file or directory: absolute, with `.`,
* `..` and every symlink resolved. Null when nothing is there. The engine
* checks that a path a miniapp names stays inside the directory it may use.
*/
canonicalFilePath(path: string): string | null
setValueAsync(value: string): Promise<void>
/** Android: copy the displayed view's window pixels to a temporary JPEG URI. */
captureMiniappPreview(viewTag: number): Promise<string>
nativeHttpRequest(
requestId: string,
method: string,
url: string,
headers: Record<string, string>,
body?: string | null,
): Promise<{status: number; statusText: string; headers: Record<string, string>; body: string}>
cancelNativeHttpRequest(requestId: string): Promise<void>
showAVRoutePicker(tintColor?: string | null): void
/**
* iOS: configure `preferredScreenEdgesDeferringSystemGestures`. When an
* edge is deferred, the first swipe across that edge is consumed by the
* app and the system gesture (Control Center, Notification Center, Home
* indicator) only fires on a second swipe — i.e. a two-swipe-to-exit UX.
*
* Pass `[]` to restore default behavior. Android: no-op (Android has no
* per-app equivalent; system gestures are configured at the OS level).
*/
setDeferredSystemGestures(edges: Array<"top" | "bottom" | "left" | "right" | "all">): Promise<void>
// MentraOS Notification Commands
setNotificationConfig(listenerEnabled: boolean, blocklist: string[]): Promise<void>
getInstalledApps(): Promise<InstalledApp[]>
getInstalledAppsForNotifications(): Promise<InstalledApp[]>
hasNotificationListenerPermission(): Promise<boolean>
refreshNotificationListener(): Promise<boolean>
openNotificationListenerSettings(): Promise<boolean>
isBetaBuild(): Promise<boolean>
// location services commands
showLocationServicesDialog(): Promise<boolean>
isLocationServicesEnabled(): Promise<boolean>
openLocationSettings(): Promise<boolean>
openAppSettings(): Promise<boolean>
openBluetoothSettings(): Promise<boolean>
// Image Processing Commands
processGalleryImage(
inputPath: string,
outputPath: string,
options: {
lensCorrection?: boolean
colorCorrection?: boolean
},
): Promise<{
success: boolean
outputPath?: string
processingTimeMs?: number
error?: string
}>
mergeHdrBrackets(
underPath: string,
normalPath: string,
overPath: string,
outputPath: string,
): Promise<{
success: boolean
outputPath?: string
processingTimeMs?: number
error?: string
}>
stabilizeVideo(
inputPath: string,
imuPath: string,
outputPath: string,
): Promise<{
success: boolean
outputPath?: string
processingTimeMs?: number
error?: string
}>
// Media Library Commands
saveToGalleryWithDate(
filePath: string,
captureTimeMillis?: number,
displayName?: string,
): Promise<{
success: boolean
uri?: string
identifier?: string
existing?: boolean
error?: string
}>
// Navigation (Android only — iOS stubs return error)
startNavigation(
lat: number,
lng: number,
options?: {
simulate?: boolean
speedMultiplier?: number
/** Optional multi-stop list. When present takes precedence over lat/lng. Last entry is the final destination. */
stops?: Array<{lat: number; lng: number}>
/** "walking" | "driving" | "cycling" | "two_wheeler". Defaults driving. */
mode?: string
avoid?: {highways?: boolean; tolls?: boolean; ferries?: boolean}
/** Force a reroute when the user is more than N meters past a pivot they didn't take. */
missedTurnRerouteMeters?: number
},
): Promise<{ok: boolean; error?: string}>
stopNavigation(): Promise<{ok: boolean; error?: string}>
/**
* Show the Google Nav SDK Terms & Conditions dialog if not already
* accepted. Idempotent — resolves immediately with `{accepted: true}`
* when the user has already accepted (cached in-process / on-disk /
* inside the SDK).
*/
requestNavigationPermission(): Promise<{ok: boolean; accepted: boolean; error?: string}>
/**
* Dev-only: clear cached T&C acceptance (SDK flag + on-disk pref +
* in-process flag) so the next requestNavigationPermission() re-shows
* the dialog. Android only; iOS returns {ok: false, error: "not
* supported on iOS"}.
*/
resetNavigationPermission(): Promise<{ok: boolean; error?: string}>
/**
* Dev-only: nudge the simulated user position ~offsetMeters perpendicular
* to the route so the Nav SDK reroutes. Default 20m. Android only.
*/
simulateDeviation(offsetMeters?: number): Promise<{ok: boolean; error?: string}>
/**
* Dev toggle. When enabled, the native NavigationManager shifts every
* reported location ~8m perpendicular to the route bearing, simulating
* a pedestrian walking on the wrong sidewalk. Only meaningful in
* simulate mode; lets us verify the SDK's along-path pivot trigger
* fires even when the user never crosses the 7m pivot point radius.
* Android-only today; iOS is a no-op stub.
*/
setWrongSidewalkOffset(enabled: boolean): Promise<{ok: boolean; error?: string}>
/**
* Dev toggle. When enabled, the native NavigationManager takes over
* from the Google simulator and walks the user along a modified
* polyline that omits crossing micro-steps — reproducing the
* wrong-sidewalk-then-missed-the-turn scenario. Android-only today;
* iOS is a no-op stub.
*/
setSkipCrossings(enabled: boolean): Promise<{ok: boolean; error?: string}>
// Heading / compass (Android only)
startHeading(): Promise<{ok: boolean; error?: string}>
stopHeading(): Promise<{ok: boolean; error?: string}>
// MentraJS Runtime — per-miniapp JSContext lifecycle.
/**
* Spawn a per-miniapp JS context. Re-spawn is allowed: a live context
* with the same packageName is killed first. Returns true if the
* polyfill bundle + miniapp source evaluated without throwing.
*
* The polyfill bundle is `mobile/modules/mentrajs-runtime/dist/startup.js`
* (shipped inside the host binary). It installs window-style globals
* (console, timers, fetch, localStorage, crypto) atop the JSC runtime.
*/
mentraJsSpawn(packageName: string, polyfillBundle: string, miniappJs: string): Promise<boolean>
mentraJsEvaluate(packageName: string, source: string): Promise<unknown>
mentraJsKill(packageName: string): Promise<void>
/**
* Push a `{kind: "event"|"response", …}` envelope into the named
* context's globalThis.__deliver. Returns when the underlying
* evaluateScript completes (the JS handler runs synchronously on the
* context's queue).
*/
mentraJsDispatchToJs(packageName: string, envelope: Record<string, unknown>): Promise<void>
mentraJsSetManifest(packageName: string, permissions: string[]): Promise<void>
/** Diagnostic — returns the packageNames of every live JSContext. */
mentraJsAlivePackages(): string[]
/** Diagnostic — force a GC cycle on the named context. */
mentraJsDebugForceGC(packageName: string): Promise<boolean>
/**
* Read the bundled MentraJS polyfill (startup.js) shipped inside the
* host binary. Synchronous — host RN code calls this once on app boot
* and caches the string, then passes it to every mentraJsSpawn so
* every JSContext starts with the same polyfill ABI.
*/
mentraJsLoadPolyfillBundle(): string
}
// This call loads the native module object from the JSI.
export default requireNativeModule<CrustModule>("Crust")
|