@mentra/engine 0.1.0-beta.0 → 0.1.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/README.md +42 -1
  2. package/build/engine.d.ts +11 -3
  3. package/build/engine.d.ts.map +1 -1
  4. package/build/engine.js +7 -2
  5. package/build/engine.js.map +1 -1
  6. package/build/facades/dev.d.ts.map +1 -1
  7. package/build/facades/dev.js +9 -5
  8. package/build/facades/dev.js.map +1 -1
  9. package/build/facades/gallery.js +1 -1
  10. package/build/facades/gallery.js.map +1 -1
  11. package/build/facades/glasses.d.ts +1 -0
  12. package/build/facades/glasses.d.ts.map +1 -1
  13. package/build/facades/glasses.js +19 -4
  14. package/build/facades/glasses.js.map +1 -1
  15. package/build/facades/glassesSettings.d.ts.map +1 -1
  16. package/build/facades/glassesSettings.js +1 -0
  17. package/build/facades/glassesSettings.js.map +1 -1
  18. package/build/facades/miniapps.d.ts +4 -0
  19. package/build/facades/miniapps.d.ts.map +1 -1
  20. package/build/facades/miniapps.js +5 -0
  21. package/build/facades/miniapps.js.map +1 -1
  22. package/build/facades/ota.d.ts +11 -2
  23. package/build/facades/ota.d.ts.map +1 -1
  24. package/build/facades/ota.js +19 -4
  25. package/build/facades/ota.js.map +1 -1
  26. package/build/facades/pairing.d.ts +4 -0
  27. package/build/facades/pairing.d.ts.map +1 -1
  28. package/build/facades/pairing.js +10 -8
  29. package/build/facades/pairing.js.map +1 -1
  30. package/build/facades/phoneNotifications.d.ts +0 -4
  31. package/build/facades/phoneNotifications.d.ts.map +1 -1
  32. package/build/facades/phoneNotifications.js +4 -14
  33. package/build/facades/phoneNotifications.js.map +1 -1
  34. package/build/index.d.ts +6 -3
  35. package/build/index.d.ts.map +1 -1
  36. package/build/index.js +4 -2
  37. package/build/index.js.map +1 -1
  38. package/build/internal.d.ts +2 -2
  39. package/build/internal.d.ts.map +1 -1
  40. package/build/internal.js +1 -1
  41. package/build/internal.js.map +1 -1
  42. package/build/react/MentraLiveOtaFlow.d.ts +38 -0
  43. package/build/react/MentraLiveOtaFlow.d.ts.map +1 -0
  44. package/build/react/MentraLiveOtaFlow.js +528 -0
  45. package/build/react/MentraLiveOtaFlow.js.map +1 -0
  46. package/build/react/index.d.ts +2 -0
  47. package/build/react/index.d.ts.map +1 -0
  48. package/build/react/index.js +2 -0
  49. package/build/react/index.js.map +1 -0
  50. package/build/react/useEngineSnapshot.d.ts +2 -0
  51. package/build/react/useEngineSnapshot.d.ts.map +1 -0
  52. package/build/react/useEngineSnapshot.js +14 -0
  53. package/build/react/useEngineSnapshot.js.map +1 -0
  54. package/build/runtime/bootstrap.d.ts +24 -1
  55. package/build/runtime/bootstrap.d.ts.map +1 -1
  56. package/build/runtime/bootstrap.js +17 -0
  57. package/build/runtime/bootstrap.js.map +1 -1
  58. package/build/runtime/scanQrSeam.d.ts +7 -0
  59. package/build/runtime/scanQrSeam.d.ts.map +1 -0
  60. package/build/runtime/scanQrSeam.js +16 -0
  61. package/build/runtime/scanQrSeam.js.map +1 -0
  62. package/build/services/AppRegistry.d.ts +18 -8
  63. package/build/services/AppRegistry.d.ts.map +1 -1
  64. package/build/services/AppRegistry.js +44 -45
  65. package/build/services/AppRegistry.js.map +1 -1
  66. package/build/services/AudioCloudUplink.d.ts +9 -3
  67. package/build/services/AudioCloudUplink.d.ts.map +1 -1
  68. package/build/services/AudioCloudUplink.js +9 -3
  69. package/build/services/AudioCloudUplink.js.map +1 -1
  70. package/build/services/AudioPlaybackService.d.ts +9 -1
  71. package/build/services/AudioPlaybackService.d.ts.map +1 -1
  72. package/build/services/AudioPlaybackService.js +77 -32
  73. package/build/services/AudioPlaybackService.js.map +1 -1
  74. package/build/services/BlobStore.d.ts +2 -1
  75. package/build/services/BlobStore.d.ts.map +1 -1
  76. package/build/services/BlobStore.js +17 -9
  77. package/build/services/BlobStore.js.map +1 -1
  78. package/build/services/CloudAudioSubscriptionSync.d.ts.map +1 -1
  79. package/build/services/CloudAudioSubscriptionSync.js +13 -1
  80. package/build/services/CloudAudioSubscriptionSync.js.map +1 -1
  81. package/build/services/CloudClientService.d.ts +15 -0
  82. package/build/services/CloudClientService.d.ts.map +1 -1
  83. package/build/services/CloudClientService.js +75 -0
  84. package/build/services/CloudClientService.js.map +1 -1
  85. package/build/services/ForegroundLocationPermission.d.ts +13 -0
  86. package/build/services/ForegroundLocationPermission.d.ts.map +1 -0
  87. package/build/services/ForegroundLocationPermission.js +12 -0
  88. package/build/services/ForegroundLocationPermission.js.map +1 -0
  89. package/build/services/GlassesSettingsSync.d.ts.map +1 -1
  90. package/build/services/GlassesSettingsSync.js +9 -3
  91. package/build/services/GlassesSettingsSync.js.map +1 -1
  92. package/build/services/GlassesStatusProjection.d.ts +2 -1
  93. package/build/services/GlassesStatusProjection.d.ts.map +1 -1
  94. package/build/services/GlassesStatusProjection.js +15 -8
  95. package/build/services/GlassesStatusProjection.js.map +1 -1
  96. package/build/services/HotspotOtaTransport.d.ts +29 -0
  97. package/build/services/HotspotOtaTransport.d.ts.map +1 -0
  98. package/build/services/HotspotOtaTransport.js +146 -0
  99. package/build/services/HotspotOtaTransport.js.map +1 -0
  100. package/build/services/HotspotShutdown.d.ts +17 -0
  101. package/build/services/HotspotShutdown.d.ts.map +1 -0
  102. package/build/services/HotspotShutdown.js +29 -0
  103. package/build/services/HotspotShutdown.js.map +1 -0
  104. package/build/services/LocalDisplayManager.d.ts +15 -0
  105. package/build/services/LocalDisplayManager.d.ts.map +1 -1
  106. package/build/services/LocalDisplayManager.js +106 -20
  107. package/build/services/LocalDisplayManager.js.map +1 -1
  108. package/build/services/LocalMiniappRuntime.d.ts +67 -1
  109. package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
  110. package/build/services/LocalMiniappRuntime.js +486 -126
  111. package/build/services/LocalMiniappRuntime.js.map +1 -1
  112. package/build/services/LocalMiniappStorage.d.ts +32 -0
  113. package/build/services/LocalMiniappStorage.d.ts.map +1 -0
  114. package/build/services/LocalMiniappStorage.js +66 -0
  115. package/build/services/LocalMiniappStorage.js.map +1 -0
  116. package/build/services/LocalMiniappUserIdentity.d.ts +20 -0
  117. package/build/services/LocalMiniappUserIdentity.d.ts.map +1 -0
  118. package/build/services/LocalMiniappUserIdentity.js +43 -0
  119. package/build/services/LocalMiniappUserIdentity.js.map +1 -0
  120. package/build/services/MicStateCoordinator.d.ts +42 -1
  121. package/build/services/MicStateCoordinator.d.ts.map +1 -1
  122. package/build/services/MicStateCoordinator.js +141 -3
  123. package/build/services/MicStateCoordinator.js.map +1 -1
  124. package/build/services/MiniappLauncher.d.ts.map +1 -1
  125. package/build/services/MiniappLauncher.js +23 -3
  126. package/build/services/MiniappLauncher.js.map +1 -1
  127. package/build/services/MiniappLiveness.d.ts +12 -0
  128. package/build/services/MiniappLiveness.d.ts.map +1 -0
  129. package/build/services/MiniappLiveness.js +16 -0
  130. package/build/services/MiniappLiveness.js.map +1 -0
  131. package/build/services/OtaArtifactDownloader.d.ts +65 -0
  132. package/build/services/OtaArtifactDownloader.d.ts.map +1 -0
  133. package/build/services/OtaArtifactDownloader.js +226 -0
  134. package/build/services/OtaArtifactDownloader.js.map +1 -0
  135. package/build/services/OtaAutoChain.d.ts +34 -0
  136. package/build/services/OtaAutoChain.d.ts.map +1 -0
  137. package/build/services/OtaAutoChain.js +83 -0
  138. package/build/services/OtaAutoChain.js.map +1 -0
  139. package/build/services/OtaErrorMapping.d.ts +18 -0
  140. package/build/services/OtaErrorMapping.d.ts.map +1 -0
  141. package/build/services/OtaErrorMapping.js +63 -0
  142. package/build/services/OtaErrorMapping.js.map +1 -0
  143. package/build/services/OtaInstallCoordinator.d.ts +94 -14
  144. package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
  145. package/build/services/OtaInstallCoordinator.js +574 -130
  146. package/build/services/OtaInstallCoordinator.js.map +1 -1
  147. package/build/services/OtaService.d.ts.map +1 -1
  148. package/build/services/OtaService.js +8 -1
  149. package/build/services/OtaService.js.map +1 -1
  150. package/build/services/OtaUpdateCheckService.d.ts +38 -3
  151. package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
  152. package/build/services/OtaUpdateCheckService.js +142 -22
  153. package/build/services/OtaUpdateCheckService.js.map +1 -1
  154. package/build/services/PhoneCalendarService.d.ts.map +1 -1
  155. package/build/services/PhoneCalendarService.js +22 -1
  156. package/build/services/PhoneCalendarService.js.map +1 -1
  157. package/build/services/PhoneCameraFovCoordinator.d.ts +2 -0
  158. package/build/services/PhoneCameraFovCoordinator.d.ts.map +1 -1
  159. package/build/services/PhoneCameraFovCoordinator.js +14 -0
  160. package/build/services/PhoneCameraFovCoordinator.js.map +1 -1
  161. package/build/services/PhoneNotificationsSync.d.ts.map +1 -1
  162. package/build/services/PhoneNotificationsSync.js +12 -10
  163. package/build/services/PhoneNotificationsSync.js.map +1 -1
  164. package/build/services/PhonePhotoCoordinator.d.ts +10 -3
  165. package/build/services/PhonePhotoCoordinator.d.ts.map +1 -1
  166. package/build/services/PhonePhotoCoordinator.js +21 -3
  167. package/build/services/PhonePhotoCoordinator.js.map +1 -1
  168. package/build/services/PhoneStreamCoordinator.d.ts +8 -1
  169. package/build/services/PhoneStreamCoordinator.d.ts.map +1 -1
  170. package/build/services/PhoneStreamCoordinator.js +125 -13
  171. package/build/services/PhoneStreamCoordinator.js.map +1 -1
  172. package/build/services/PhoneVideoCoordinator.d.ts +2 -0
  173. package/build/services/PhoneVideoCoordinator.d.ts.map +1 -1
  174. package/build/services/PhoneVideoCoordinator.js +10 -0
  175. package/build/services/PhoneVideoCoordinator.js.map +1 -1
  176. package/build/services/SceneRenderer.d.ts.map +1 -1
  177. package/build/services/SceneRenderer.js +15 -0
  178. package/build/services/SceneRenderer.js.map +1 -1
  179. package/build/services/SupportProfileSync.d.ts +22 -0
  180. package/build/services/SupportProfileSync.d.ts.map +1 -0
  181. package/build/services/SupportProfileSync.js +213 -0
  182. package/build/services/SupportProfileSync.js.map +1 -0
  183. package/build/services/TtsTextSanitizer.d.ts +5 -0
  184. package/build/services/TtsTextSanitizer.d.ts.map +1 -0
  185. package/build/services/TtsTextSanitizer.js +61 -0
  186. package/build/services/TtsTextSanitizer.js.map +1 -0
  187. package/build/services/WifiAdbRequest.d.ts +17 -0
  188. package/build/services/WifiAdbRequest.d.ts.map +1 -0
  189. package/build/services/WifiAdbRequest.js +35 -0
  190. package/build/services/WifiAdbRequest.js.map +1 -0
  191. package/build/services/asg/asgCameraApi.d.ts +3 -0
  192. package/build/services/asg/asgCameraApi.d.ts.map +1 -1
  193. package/build/services/asg/asgCameraApi.js +72 -2
  194. package/build/services/asg/asgCameraApi.js.map +1 -1
  195. package/build/services/asg/gallerySyncService.d.ts.map +1 -1
  196. package/build/services/asg/gallerySyncService.js +26 -14
  197. package/build/services/asg/gallerySyncService.js.map +1 -1
  198. package/build/services/asg/localNetworkTransport.d.ts +2 -2
  199. package/build/services/asg/localNetworkTransport.d.ts.map +1 -1
  200. package/build/services/asg/localNetworkTransport.js +6 -6
  201. package/build/services/asg/localNetworkTransport.js.map +1 -1
  202. package/build/services/audioPlaybackAssets.d.ts +8 -0
  203. package/build/services/audioPlaybackAssets.d.ts.map +1 -0
  204. package/build/services/audioPlaybackAssets.js +7 -0
  205. package/build/services/audioPlaybackAssets.js.map +1 -0
  206. package/build/services/glassesClockSync.js +2 -2
  207. package/build/services/glassesClockSync.js.map +1 -1
  208. package/build/services/manifestActions.d.ts +7 -0
  209. package/build/services/manifestActions.d.ts.map +1 -0
  210. package/build/services/manifestActions.js +25 -0
  211. package/build/services/manifestActions.js.map +1 -0
  212. package/build/services/otaDisplayState.d.ts +22 -11
  213. package/build/services/otaDisplayState.d.ts.map +1 -1
  214. package/build/services/otaDisplayState.js +36 -14
  215. package/build/services/otaDisplayState.js.map +1 -1
  216. package/build/services/otaInstallPolicy.d.ts +15 -3
  217. package/build/services/otaInstallPolicy.d.ts.map +1 -1
  218. package/build/services/otaInstallPolicy.js +24 -3
  219. package/build/services/otaInstallPolicy.js.map +1 -1
  220. package/build/services/otaManifestUrl.d.ts +2 -0
  221. package/build/services/otaManifestUrl.d.ts.map +1 -0
  222. package/build/services/{asgOtaVersionUrl.js → otaManifestUrl.js} +15 -5
  223. package/build/services/otaManifestUrl.js.map +1 -0
  224. package/build/services/slimStreamStatus.d.ts +11 -0
  225. package/build/services/slimStreamStatus.d.ts.map +1 -1
  226. package/build/services/slimStreamStatus.js +14 -4
  227. package/build/services/slimStreamStatus.js.map +1 -1
  228. package/build/stores/apps.d.ts.map +1 -1
  229. package/build/stores/apps.js +11 -0
  230. package/build/stores/apps.js.map +1 -1
  231. package/build/stores/bluetoothSettingKeys.d.ts.map +1 -1
  232. package/build/stores/bluetoothSettingKeys.js +2 -0
  233. package/build/stores/bluetoothSettingKeys.js.map +1 -1
  234. package/build/stores/gallerySync.d.ts +2 -0
  235. package/build/stores/gallerySync.d.ts.map +1 -1
  236. package/build/stores/gallerySync.js +2 -0
  237. package/build/stores/gallerySync.js.map +1 -1
  238. package/build/stores/glasses.d.ts.map +1 -1
  239. package/build/stores/glasses.js +3 -0
  240. package/build/stores/glasses.js.map +1 -1
  241. package/build/stores/settings.d.ts +17 -0
  242. package/build/stores/settings.d.ts.map +1 -1
  243. package/build/stores/settings.js +152 -19
  244. package/build/stores/settings.js.map +1 -1
  245. package/build/types/applet.d.ts +2 -0
  246. package/build/types/applet.d.ts.map +1 -1
  247. package/build/types/applet.js.map +1 -1
  248. package/build/types/enums.d.ts +1 -0
  249. package/build/types/enums.d.ts.map +1 -1
  250. package/build/types/enums.js +1 -0
  251. package/build/types/enums.js.map +1 -1
  252. package/build/types/hardware.d.ts +1 -0
  253. package/build/types/hardware.d.ts.map +1 -1
  254. package/build/types/hardware.js +14 -0
  255. package/build/types/hardware.js.map +1 -1
  256. package/build/utils/configuredDevHost.d.ts +6 -0
  257. package/build/utils/configuredDevHost.d.ts.map +1 -0
  258. package/build/utils/configuredDevHost.js +19 -0
  259. package/build/utils/configuredDevHost.js.map +1 -0
  260. package/build/utils/devMiniappLaunch.d.ts +19 -8
  261. package/build/utils/devMiniappLaunch.d.ts.map +1 -1
  262. package/build/utils/devMiniappLaunch.js +144 -21
  263. package/build/utils/devMiniappLaunch.js.map +1 -1
  264. package/build/utils/diagnosticContext.d.ts.map +1 -1
  265. package/build/utils/diagnosticContext.js +15 -17
  266. package/build/utils/diagnosticContext.js.map +1 -1
  267. package/build/utils/hardware/hardware.d.ts.map +1 -1
  268. package/build/utils/hardware/hardware.js +7 -3
  269. package/build/utils/hardware/hardware.js.map +1 -1
  270. package/build/utils/miniappDiagnostics.d.ts +64 -0
  271. package/build/utils/miniappDiagnostics.d.ts.map +1 -0
  272. package/build/utils/miniappDiagnostics.js +173 -0
  273. package/build/utils/miniappDiagnostics.js.map +1 -0
  274. package/build/utils/timers/timers.d.ts.map +1 -1
  275. package/build/utils/timers/timers.js +55 -18
  276. package/build/utils/timers/timers.js.map +1 -1
  277. package/package.json +27 -18
  278. package/src/assets/silence.wav +0 -0
  279. package/src/engine.ts +7 -2
  280. package/src/facades/dev.ts +9 -5
  281. package/src/facades/gallery.ts +1 -1
  282. package/src/facades/glasses.ts +17 -4
  283. package/src/facades/glassesSettings.ts +5 -0
  284. package/src/facades/miniapps.ts +7 -0
  285. package/src/facades/ota.ts +19 -4
  286. package/src/facades/pairing.ts +11 -7
  287. package/src/facades/phoneNotifications.ts +4 -13
  288. package/src/index.ts +26 -2
  289. package/src/internal.ts +2 -1
  290. package/src/react/MentraLiveOtaFlow.tsx +856 -0
  291. package/src/react/index.ts +7 -0
  292. package/src/react/useEngineSnapshot.ts +16 -0
  293. package/src/runtime/bootstrap.ts +33 -1
  294. package/src/runtime/scanQrSeam.ts +20 -0
  295. package/src/services/AppRegistry.ts +72 -48
  296. package/src/services/AudioCloudUplink.ts +9 -3
  297. package/src/services/AudioPlaybackService.ts +94 -34
  298. package/src/services/BlobStore.ts +22 -9
  299. package/src/services/CloudAudioSubscriptionSync.ts +13 -1
  300. package/src/services/CloudClientService.ts +74 -0
  301. package/src/services/ForegroundLocationPermission.ts +24 -0
  302. package/src/services/GlassesSettingsSync.ts +9 -3
  303. package/src/services/GlassesStatusProjection.ts +16 -8
  304. package/src/services/HotspotOtaTransport.ts +184 -0
  305. package/src/services/HotspotShutdown.ts +41 -0
  306. package/src/services/LocalDisplayManager.ts +112 -21
  307. package/src/services/LocalMiniappRuntime.ts +576 -130
  308. package/src/services/LocalMiniappStorage.ts +82 -0
  309. package/src/services/LocalMiniappUserIdentity.ts +46 -0
  310. package/src/services/MicStateCoordinator.ts +169 -4
  311. package/src/services/MiniappLauncher.ts +30 -3
  312. package/src/services/MiniappLiveness.ts +24 -0
  313. package/src/services/OtaArtifactDownloader.ts +312 -0
  314. package/src/services/OtaAutoChain.ts +106 -0
  315. package/src/services/OtaErrorMapping.ts +80 -0
  316. package/src/services/OtaInstallCoordinator.ts +645 -143
  317. package/src/services/OtaService.ts +11 -5
  318. package/src/services/OtaUpdateCheckService.ts +180 -20
  319. package/src/services/PhoneCalendarService.ts +27 -4
  320. package/src/services/PhoneCameraFovCoordinator.ts +15 -0
  321. package/src/services/PhoneNotificationsSync.ts +12 -10
  322. package/src/services/PhonePhotoCoordinator.ts +33 -7
  323. package/src/services/PhoneStreamCoordinator.ts +139 -25
  324. package/src/services/PhoneVideoCoordinator.ts +11 -0
  325. package/src/services/SceneRenderer.ts +16 -0
  326. package/src/services/SupportProfileSync.ts +218 -0
  327. package/src/services/TtsTextSanitizer.ts +66 -0
  328. package/src/services/WifiAdbRequest.ts +53 -0
  329. package/src/services/asg/asgCameraApi.ts +99 -8
  330. package/src/services/asg/gallerySyncService.ts +28 -19
  331. package/src/services/asg/localNetworkTransport.ts +7 -11
  332. package/src/services/audioPlaybackAssets.ts +8 -0
  333. package/src/services/glassesClockSync.ts +2 -2
  334. package/src/services/manifestActions.ts +30 -0
  335. package/src/services/otaDisplayState.ts +57 -16
  336. package/src/services/otaInstallPolicy.ts +29 -3
  337. package/src/services/{asgOtaVersionUrl.ts → otaManifestUrl.ts} +16 -4
  338. package/src/services/slimStreamStatus.ts +16 -5
  339. package/src/stores/apps.ts +12 -0
  340. package/src/stores/bluetoothSettingKeys.ts +2 -0
  341. package/src/stores/gallerySync.ts +4 -0
  342. package/src/stores/glasses.ts +3 -0
  343. package/src/stores/settings.ts +174 -21
  344. package/src/types/applet.ts +2 -0
  345. package/src/types/enums.ts +2 -1
  346. package/src/types/hardware.ts +17 -0
  347. package/src/utils/configuredDevHost.ts +17 -0
  348. package/src/utils/devMiniappLaunch.ts +151 -23
  349. package/src/utils/diagnosticContext.ts +17 -17
  350. package/src/utils/hardware/hardware.ts +7 -9
  351. package/src/utils/miniappDiagnostics.ts +226 -0
  352. package/src/utils/timers/timers.ts +57 -21
  353. package/build/services/asgOtaVersionUrl.d.ts +0 -2
  354. package/build/services/asgOtaVersionUrl.d.ts.map +0 -1
  355. package/build/services/asgOtaVersionUrl.js.map +0 -1
@@ -59,6 +59,7 @@ const initialState = {
59
59
  androidVersion: "",
60
60
  firmwareVersion: "",
61
61
  bluetoothMacAddress: "",
62
+ wifiMacAddress: "",
62
63
  leftMacAddress: "",
63
64
  rightMacAddress: "",
64
65
  buildNumber: "",
@@ -71,6 +72,7 @@ const initialState = {
71
72
  color: "",
72
73
  mtkFirmwareVersion: "",
73
74
  besFirmwareVersion: "",
75
+ hotspotOtaVersion: 0,
74
76
  // wifi info
75
77
  wifi: { state: "disconnected" },
76
78
  wifiStatusKnown: false,
@@ -116,6 +118,7 @@ export const useGlassesStore = create()(subscribeWithSelector((set) => ({
116
118
  };
117
119
  if (!isGlassesConnected(next.connection)) {
118
120
  next.wifiStatusKnown = false;
121
+ next.hotspotOtaVersion = 0;
119
122
  }
120
123
  return next;
121
124
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"glasses.js","sourceRoot":"","sources":["../../src/stores/glasses.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,EAAC,MAAM,8BAA8B,CAAA;AACvG,OAAO,EAAC,MAAM,E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A","sourcesContent":["import type {\n GlassesConnectionStatus,\n GlassesStatus,\n HotspotStatus,\n OtaProgress,\n OtaStatus,\n OtaUpdateInfo,\n WifiStatus,\n} from \"@mentra/bluetooth-sdk/internal\"\nimport {isGlassesConnected, isGlassesLinkLayerBusy, isGlassesReady} from \"../services/GlassesReadiness\"\nimport {create} from \"zustand\"\nimport {subscribeWithSelector} from \"zustand/middleware\"\n\n// Re-export the connection predicates (single source of truth lives in\n// GlassesReadiness) so importers of this store keep getting them.\nexport {isGlassesConnected, isGlassesLinkLayerBusy, isGlassesReady}\n\nexport const selectGlassesConnected = (state: {connection: GlassesConnectionStatus}) =>\n isGlassesConnected(state.connection)\n\nexport const selectGlassesReady = (state: {connection: GlassesConnectionStatus}) => isGlassesReady(state.connection)\n\nexport interface GlassesState extends GlassesStatus {\n systemTimeMs: number\n wifiStatusKnown: boolean\n setGlassesInfo: (info: GlassesInfoUpdate) => void\n setBatteryInfo: (batteryLevel: number, charging: boolean, caseBatteryLevel: number, caseCharging: boolean) => void\n setWifiInfo: (connected: boolean, ssid: string) => void\n setHotspotInfo: (enabled: boolean, ssid: string, password: string, ip: string) => void\n // OTA methods\n otaStatus: OtaStatus | null\n setOtaStatus: (status: OtaStatus | null) => void\n setOtaUpdateAvailable: (info: OtaUpdateInfo | null) => void\n setOtaProgress: (progress: OtaProgress | null) => void\n setOtaInProgress: (inProgress: boolean) => void\n setMtkUpdatedThisSession: (updated: boolean) => void\n clearOtaState: () => void\n reset: () => void\n mtkUpdatedThisSession: boolean\n}\n\ntype LegacyWifiFields = {\n wifiConnected?: boolean\n wifiSsid?: string\n wifiLocalIp?: string\n}\n\ntype LegacyHotspotFields = {\n hotspotEnabled?: boolean\n hotspotSsid?: string\n hotspotPassword?: string\n hotspotGatewayIp?: string\n hotspotLocalIp?: string\n}\n\ntype GlassesInfoUpdate = Partial<GlassesStatus> & LegacyWifiFields & LegacyHotspotFields\n\nfunction wifiFromLegacyFields(info: LegacyWifiFields): WifiStatus | null {\n if (info.wifiConnected === true) {\n const ssid = info.wifiSsid?.trim()\n const localIp = info.wifiLocalIp?.trim()\n return ssid ? {state: \"connected\", ssid, ...(localIp ? {localIp} : {})} : null\n }\n if (info.wifiConnected === false) {\n return {state: \"disconnected\"}\n }\n return null\n}\n\nfunction hotspotFromLegacyFields(info: LegacyHotspotFields): HotspotStatus | null {\n if (info.hotspotEnabled === true) {\n const ssid = info.hotspotSsid?.trim()\n const password = info.hotspotPassword?.trim()\n const localIp = (info.hotspotGatewayIp ?? info.hotspotLocalIp)?.trim()\n return ssid && password && localIp ? {state: \"enabled\", ssid, password, localIp} : null\n }\n if (info.hotspotEnabled === false) {\n return {state: \"disabled\"}\n }\n return null\n}\n\nexport const getGlasesInfoPartial = (state: GlassesStatus) => {\n const wifi = state.wifi\n const connected = isGlassesConnected(state.connection)\n return {\n batteryLevel: state.batteryLevel,\n charging: state.charging,\n caseBatteryLevel: state.caseBatteryLevel,\n caseCharging: state.caseCharging,\n connected,\n wifiConnected: wifi.state === \"connected\",\n wifiSsid: wifi.state === \"connected\" ? wifi.ssid : \"\",\n deviceModel: state.deviceModel,\n // Cloud GlassesInfo uses modelName, map from deviceModel so the cloud\n // knows which device is connected when it receives connection state updates\n modelName: state.deviceModel || null,\n }\n}\n\ninterface GlassesStore extends GlassesStatus {\n systemTimeMs: number\n mtkUpdatedThisSession: boolean\n wifiStatusKnown: boolean\n otaStatus: OtaStatus | null\n}\n\nconst initialState: GlassesStore = {\n // state:\n connection: {state: \"disconnected\"},\n micEnabled: false,\n bluetoothClassicConnected: false,\n signalStrength: -1,\n signalStrengthUpdatedAt: 0,\n voiceActivityDetectionEnabled: true,\n // device info\n deviceModel: \"\",\n androidVersion: \"\",\n firmwareVersion: \"\",\n bluetoothMacAddress: \"\",\n leftMacAddress: \"\",\n rightMacAddress: \"\",\n buildNumber: \"\",\n systemTimeMs: 0,\n otaVersionUrl: \"\",\n appVersion: \"\",\n bluetoothName: \"\",\n serialNumber: \"\",\n style: \"\",\n color: \"\",\n mtkFirmwareVersion: \"\",\n besFirmwareVersion: \"\",\n // wifi info\n wifi: {state: \"disconnected\"},\n wifiStatusKnown: false,\n // battery info\n batteryLevel: -1,\n charging: false,\n caseBatteryLevel: -1,\n caseCharging: false,\n caseOpen: false,\n caseRemoved: true,\n // hotspot info\n hotspot: {state: \"disabled\"},\n // OTA update info\n otaStatus: null,\n otaUpdateAvailable: null,\n otaProgress: null,\n otaInProgress: false,\n mtkUpdatedThisSession: false,\n // ring:\n controllerConnected: false,\n controllerFullyBooted: false,\n controllerMacAddress: \"\",\n controllerBatteryLevel: -1,\n controllerSignalStrength: -1,\n}\n\nexport const useGlassesStore = create<GlassesState>()(\n subscribeWithSelector((set) => ({\n ...initialState,\n\n setGlassesInfo: (info) =>\n set((state) => {\n const {\n wifiConnected,\n wifiSsid,\n wifiLocalIp,\n hotspotEnabled,\n hotspotSsid,\n hotspotPassword,\n hotspotGatewayIp,\n hotspotLocalIp,\n wifi,\n hotspot,\n ...sdkInfo\n } = info\n const wifiUpdate = wifi ?? wifiFromLegacyFields({wifiConnected, wifiSsid, wifiLocalIp})\n const hotspotUpdate =\n hotspot ??\n hotspotFromLegacyFields({hotspotEnabled, hotspotSsid, hotspotPassword, hotspotGatewayIp, hotspotLocalIp})\n const hasWifiInfoUpdate =\n Object.prototype.hasOwnProperty.call(info, \"wifi\") ||\n Object.prototype.hasOwnProperty.call(info, \"wifiConnected\") ||\n Object.prototype.hasOwnProperty.call(info, \"wifiSsid\") ||\n Object.prototype.hasOwnProperty.call(info, \"wifiLocalIp\")\n const next = {\n ...state,\n ...sdkInfo,\n ...(wifiUpdate ? {wifi: wifiUpdate} : {}),\n ...(hotspotUpdate ? {hotspot: hotspotUpdate} : {}),\n ...(hasWifiInfoUpdate ? {wifiStatusKnown: true} : {}),\n }\n if (!isGlassesConnected(next.connection)) {\n next.wifiStatusKnown = false\n }\n return next\n }),\n\n setBatteryInfo: (batteryLevel, charging, caseBatteryLevel, caseCharging) =>\n set({\n batteryLevel,\n charging,\n caseBatteryLevel,\n caseCharging,\n }),\n\n setWifiInfo: (connected, ssid) =>\n set(() => {\n const trimmedSsid = ssid.trim()\n if (connected && !trimmedSsid) {\n return {}\n }\n const wifi: WifiStatus = connected ? {state: \"connected\", ssid: trimmedSsid} : {state: \"disconnected\"}\n return {\n wifi,\n wifiStatusKnown: true,\n }\n }),\n\n setHotspotInfo: (enabled: boolean, ssid: string, password: string, ip: string) =>\n set(() => {\n const hotspot = hotspotFromLegacyFields({\n hotspotEnabled: enabled,\n hotspotSsid: ssid,\n hotspotPassword: password,\n hotspotGatewayIp: ip,\n })\n return hotspot ? {hotspot} : {}\n }),\n\n // OTA methods\n setOtaStatus: (status: OtaStatus | null) => set({otaStatus: status}),\n\n setOtaUpdateAvailable: (info: OtaUpdateInfo | null) => set({otaUpdateAvailable: info}),\n\n setOtaProgress: (progress: OtaProgress | null) =>\n set((state) => {\n const otaInProgress = progress !== null && progress.status !== \"FINISHED\" && progress.status !== \"FAILED\"\n console.log(\"🔍 GLASSES STORE: setOtaProgress called with:\", JSON.stringify(progress))\n console.log(\"🔍 GLASSES STORE: otaInProgress =\", otaInProgress)\n\n // Never allow progress to regress within the same stage+currentUpdate — except a new\n // work wave (STARTED) or the step after FINISHED (multi-hop APK: 27→31→36 re-downloads from 0).\n const prev = state.otaProgress\n const sameWave =\n progress &&\n prev &&\n progress.stage === prev.stage &&\n progress.currentUpdate === prev.currentUpdate &&\n progress.progress < prev.progress\n if (sameWave) {\n const nextIsNewWave = progress.status === \"STARTED\" || prev.status === \"FINISHED\"\n if (!nextIsNewWave) {\n return {otaProgress: {...progress, progress: prev.progress}, otaInProgress}\n }\n }\n\n return {otaProgress: progress, otaInProgress}\n }),\n\n setOtaInProgress: (inProgress: boolean) => set({otaInProgress: inProgress}),\n\n setMtkUpdatedThisSession: (updated: boolean) => set({mtkUpdatedThisSession: updated}),\n\n clearOtaState: () =>\n set({\n otaUpdateAvailable: null,\n otaProgress: null,\n otaInProgress: false,\n // Note: mtkUpdatedThisSession is NOT cleared here - it stays true until glasses disconnect/reboot\n }),\n\n reset: () => set(initialState),\n })),\n)\n\nexport function getGlassesSystemTimeMs(): number {\n return useGlassesStore.getState().systemTimeMs ?? 0\n}\n\nexport const waitForGlassesState = <K extends keyof GlassesState>(\n key: K,\n predicate: (value: GlassesState[K]) => boolean,\n timeoutMs = 1000,\n): Promise<boolean> => {\n return new Promise((resolve) => {\n const state = useGlassesStore.getState()\n if (predicate(state[key])) {\n resolve(true)\n return\n }\n\n const unsubscribe = useGlassesStore.subscribe(\n (s) => s[key],\n (value) => {\n if (predicate(value)) {\n unsubscribe()\n resolve(true)\n }\n },\n )\n\n setTimeout(() => {\n unsubscribe()\n resolve(predicate(useGlassesStore.getState()[key]))\n }, timeoutMs)\n })\n}\n"]}
1
+ {"version":3,"file":"glasses.js","sourceRoot":"","sources":["../../src/stores/glasses.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,EAAC,MAAM,8BAA8B,CAAA;AACvG,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAA;AAExD,uEAAuE;AACvE,kEAAkE;AAClE,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,EAAC,CAAA;AAEnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAA4C,EAAE,EAAE,CACrF,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AAEtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAA4C,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AAqCpH,SAAS,oBAAoB,CAAC,IAAsB;IAClD,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAA;QA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,SAA8C,EAC9C,SAAS,GAAG,IAAI,EACE,EAAE;IACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;QACxC,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAA;YACb,OAAM;QACR,CAAC;QAED,MAAM,WAAW,GAAG,eAAe,CAAC,SAAS,CAC3C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EACb,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrB,WAAW,EAAE,CAAA;gBACb,OAAO,CAAC,IAAI,CAAC,CAAA;YACf,CAAC;QACH,CAAC,CACF,CAAA;QAED,UAAU,CAAC,GAAG,EAAE;YACd,WAAW,EAAE,CAAA;YACb,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACrD,CAAC,EAAE,SAAS,CAAC,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import type {\n GlassesConnectionStatus,\n GlassesStatus,\n HotspotStatus,\n OtaProgress,\n OtaStatus,\n OtaUpdateInfo,\n WifiStatus,\n} from \"@mentra/bluetooth-sdk/internal\"\nimport {isGlassesConnected, isGlassesLinkLayerBusy, isGlassesReady} from \"../services/GlassesReadiness\"\nimport {create} from \"zustand\"\nimport {subscribeWithSelector} from \"zustand/middleware\"\n\n// Re-export the connection predicates (single source of truth lives in\n// GlassesReadiness) so importers of this store keep getting them.\nexport {isGlassesConnected, isGlassesLinkLayerBusy, isGlassesReady}\n\nexport const selectGlassesConnected = (state: {connection: GlassesConnectionStatus}) =>\n isGlassesConnected(state.connection)\n\nexport const selectGlassesReady = (state: {connection: GlassesConnectionStatus}) => isGlassesReady(state.connection)\n\nexport interface GlassesState extends GlassesStatus {\n systemTimeMs: number\n wifiStatusKnown: boolean\n setGlassesInfo: (info: GlassesInfoUpdate) => void\n setBatteryInfo: (batteryLevel: number, charging: boolean, caseBatteryLevel: number, caseCharging: boolean) => void\n setWifiInfo: (connected: boolean, ssid: string) => void\n setHotspotInfo: (enabled: boolean, ssid: string, password: string, ip: string) => void\n // OTA methods\n otaStatus: OtaStatus | null\n setOtaStatus: (status: OtaStatus | null) => void\n setOtaUpdateAvailable: (info: OtaUpdateInfo | null) => void\n setOtaProgress: (progress: OtaProgress | null) => void\n setOtaInProgress: (inProgress: boolean) => void\n setMtkUpdatedThisSession: (updated: boolean) => void\n clearOtaState: () => void\n reset: () => void\n mtkUpdatedThisSession: boolean\n}\n\ntype LegacyWifiFields = {\n wifiConnected?: boolean\n wifiSsid?: string\n wifiLocalIp?: string\n}\n\ntype LegacyHotspotFields = {\n hotspotEnabled?: boolean\n hotspotSsid?: string\n hotspotPassword?: string\n hotspotGatewayIp?: string\n hotspotLocalIp?: string\n}\n\ntype GlassesInfoUpdate = Partial<GlassesStatus> & LegacyWifiFields & LegacyHotspotFields\n\nfunction wifiFromLegacyFields(info: LegacyWifiFields): WifiStatus | null {\n if (info.wifiConnected === true) {\n const ssid = info.wifiSsid?.trim()\n const localIp = info.wifiLocalIp?.trim()\n return ssid ? {state: \"connected\", ssid, ...(localIp ? {localIp} : {})} : null\n }\n if (info.wifiConnected === false) {\n return {state: \"disconnected\"}\n }\n return null\n}\n\nfunction hotspotFromLegacyFields(info: LegacyHotspotFields): HotspotStatus | null {\n if (info.hotspotEnabled === true) {\n const ssid = info.hotspotSsid?.trim()\n const password = info.hotspotPassword?.trim()\n const localIp = (info.hotspotGatewayIp ?? info.hotspotLocalIp)?.trim()\n return ssid && password && localIp ? {state: \"enabled\", ssid, password, localIp} : null\n }\n if (info.hotspotEnabled === false) {\n return {state: \"disabled\"}\n }\n return null\n}\n\nexport const getGlasesInfoPartial = (state: GlassesStatus) => {\n const wifi = state.wifi\n const connected = isGlassesConnected(state.connection)\n return {\n batteryLevel: state.batteryLevel,\n charging: state.charging,\n caseBatteryLevel: state.caseBatteryLevel,\n caseCharging: state.caseCharging,\n connected,\n wifiConnected: wifi.state === \"connected\",\n wifiSsid: wifi.state === \"connected\" ? wifi.ssid : \"\",\n deviceModel: state.deviceModel,\n // Cloud GlassesInfo uses modelName, map from deviceModel so the cloud\n // knows which device is connected when it receives connection state updates\n modelName: state.deviceModel || null,\n }\n}\n\ninterface GlassesStore extends GlassesStatus {\n systemTimeMs: number\n mtkUpdatedThisSession: boolean\n wifiStatusKnown: boolean\n otaStatus: OtaStatus | null\n}\n\nconst initialState: GlassesStore = {\n // state:\n connection: {state: \"disconnected\"},\n micEnabled: false,\n bluetoothClassicConnected: false,\n signalStrength: -1,\n signalStrengthUpdatedAt: 0,\n voiceActivityDetectionEnabled: true,\n // device info\n deviceModel: \"\",\n androidVersion: \"\",\n firmwareVersion: \"\",\n bluetoothMacAddress: \"\",\n wifiMacAddress: \"\",\n leftMacAddress: \"\",\n rightMacAddress: \"\",\n buildNumber: \"\",\n systemTimeMs: 0,\n otaVersionUrl: \"\",\n appVersion: \"\",\n bluetoothName: \"\",\n serialNumber: \"\",\n style: \"\",\n color: \"\",\n mtkFirmwareVersion: \"\",\n besFirmwareVersion: \"\",\n hotspotOtaVersion: 0,\n // wifi info\n wifi: {state: \"disconnected\"},\n wifiStatusKnown: false,\n // battery info\n batteryLevel: -1,\n charging: false,\n caseBatteryLevel: -1,\n caseCharging: false,\n caseOpen: false,\n caseRemoved: true,\n // hotspot info\n hotspot: {state: \"disabled\"},\n // OTA update info\n otaStatus: null,\n otaUpdateAvailable: null,\n otaProgress: null,\n otaInProgress: false,\n mtkUpdatedThisSession: false,\n // ring:\n controllerConnected: false,\n controllerFullyBooted: false,\n controllerMacAddress: \"\",\n controllerBatteryLevel: -1,\n controllerSignalStrength: -1,\n}\n\nexport const useGlassesStore = create<GlassesState>()(\n subscribeWithSelector((set) => ({\n ...initialState,\n\n setGlassesInfo: (info) =>\n set((state) => {\n const {\n wifiConnected,\n wifiSsid,\n wifiLocalIp,\n hotspotEnabled,\n hotspotSsid,\n hotspotPassword,\n hotspotGatewayIp,\n hotspotLocalIp,\n wifi,\n hotspot,\n ...sdkInfo\n } = info\n const wifiUpdate = wifi ?? wifiFromLegacyFields({wifiConnected, wifiSsid, wifiLocalIp})\n const hotspotUpdate =\n hotspot ??\n hotspotFromLegacyFields({hotspotEnabled, hotspotSsid, hotspotPassword, hotspotGatewayIp, hotspotLocalIp})\n const hasWifiInfoUpdate =\n Object.prototype.hasOwnProperty.call(info, \"wifi\") ||\n Object.prototype.hasOwnProperty.call(info, \"wifiConnected\") ||\n Object.prototype.hasOwnProperty.call(info, \"wifiSsid\") ||\n Object.prototype.hasOwnProperty.call(info, \"wifiLocalIp\")\n const next = {\n ...state,\n ...sdkInfo,\n ...(wifiUpdate ? {wifi: wifiUpdate} : {}),\n ...(hotspotUpdate ? {hotspot: hotspotUpdate} : {}),\n ...(hasWifiInfoUpdate ? {wifiStatusKnown: true} : {}),\n }\n if (!isGlassesConnected(next.connection)) {\n next.wifiStatusKnown = false\n next.hotspotOtaVersion = 0\n }\n return next\n }),\n\n setBatteryInfo: (batteryLevel, charging, caseBatteryLevel, caseCharging) =>\n set({\n batteryLevel,\n charging,\n caseBatteryLevel,\n caseCharging,\n }),\n\n setWifiInfo: (connected, ssid) =>\n set(() => {\n const trimmedSsid = ssid.trim()\n if (connected && !trimmedSsid) {\n return {}\n }\n const wifi: WifiStatus = connected ? {state: \"connected\", ssid: trimmedSsid} : {state: \"disconnected\"}\n return {\n wifi,\n wifiStatusKnown: true,\n }\n }),\n\n setHotspotInfo: (enabled: boolean, ssid: string, password: string, ip: string) =>\n set(() => {\n const hotspot = hotspotFromLegacyFields({\n hotspotEnabled: enabled,\n hotspotSsid: ssid,\n hotspotPassword: password,\n hotspotGatewayIp: ip,\n })\n return hotspot ? {hotspot} : {}\n }),\n\n // OTA methods\n setOtaStatus: (status: OtaStatus | null) => set({otaStatus: status}),\n\n setOtaUpdateAvailable: (info: OtaUpdateInfo | null) => set({otaUpdateAvailable: info}),\n\n setOtaProgress: (progress: OtaProgress | null) =>\n set((state) => {\n const otaInProgress = progress !== null && progress.status !== \"FINISHED\" && progress.status !== \"FAILED\"\n console.log(\"🔍 GLASSES STORE: setOtaProgress called with:\", JSON.stringify(progress))\n console.log(\"🔍 GLASSES STORE: otaInProgress =\", otaInProgress)\n\n // Never allow progress to regress within the same stage+currentUpdate — except a new\n // work wave (STARTED) or the step after FINISHED (multi-hop APK: 27→31→36 re-downloads from 0).\n const prev = state.otaProgress\n const sameWave =\n progress &&\n prev &&\n progress.stage === prev.stage &&\n progress.currentUpdate === prev.currentUpdate &&\n progress.progress < prev.progress\n if (sameWave) {\n const nextIsNewWave = progress.status === \"STARTED\" || prev.status === \"FINISHED\"\n if (!nextIsNewWave) {\n return {otaProgress: {...progress, progress: prev.progress}, otaInProgress}\n }\n }\n\n return {otaProgress: progress, otaInProgress}\n }),\n\n setOtaInProgress: (inProgress: boolean) => set({otaInProgress: inProgress}),\n\n setMtkUpdatedThisSession: (updated: boolean) => set({mtkUpdatedThisSession: updated}),\n\n clearOtaState: () =>\n set({\n otaUpdateAvailable: null,\n otaProgress: null,\n otaInProgress: false,\n // Note: mtkUpdatedThisSession is NOT cleared here - it stays true until glasses disconnect/reboot\n }),\n\n reset: () => set(initialState),\n })),\n)\n\nexport function getGlassesSystemTimeMs(): number {\n return useGlassesStore.getState().systemTimeMs ?? 0\n}\n\nexport const waitForGlassesState = <K extends keyof GlassesState>(\n key: K,\n predicate: (value: GlassesState[K]) => boolean,\n timeoutMs = 1000,\n): Promise<boolean> => {\n return new Promise((resolve) => {\n const state = useGlassesStore.getState()\n if (predicate(state[key])) {\n resolve(true)\n return\n }\n\n const unsubscribe = useGlassesStore.subscribe(\n (s) => s[key],\n (value) => {\n if (predicate(value)) {\n unsubscribe()\n resolve(true)\n }\n },\n )\n\n setTimeout(() => {\n unsubscribe()\n resolve(predicate(useGlassesStore.getState()[key]))\n }, timeoutMs)\n })\n}\n"]}
@@ -9,6 +9,23 @@ export interface Setting {
9
9
  override?: () => any;
10
10
  persist: boolean;
11
11
  nativeAuthoritative?: true;
12
+ /**
13
+ * Clear this setting when the build's environment changes.
14
+ *
15
+ * A persisted override normally outranks both the build's env and the
16
+ * compiled default, which is right within one environment: a developer's
17
+ * METRO_AUTO pin should survive a rebuild. It is wrong across environments,
18
+ * where an override pinned under a dev build would silently follow the
19
+ * install onto a store build pointed at production.
20
+ *
21
+ * Note this keys off the build's environment label, so it does NOT fire on a
22
+ * TestFlight to App Store promotion: that ships the same binary with the same
23
+ * label. Promotion is safe because the publishing lane bakes prod URLs, not
24
+ * because this reset runs. See the resolution block in loadSettings.
25
+ *
26
+ * Absent means the value is never invalidated automatically.
27
+ */
28
+ resetOnBuildEnvChange?: true;
12
29
  }
13
30
  export declare const SETTINGS: Record<string, Setting>;
14
31
  export declare const OFFLINE_APPLETS: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/stores/settings.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAwB,MAAM,aAAa,CAAA;AAQ9D,OAAO,EAAC,wBAAwB,EAAE,gCAAgC,EAAC,MAAM,wBAAwB,CAAA;AAEjG,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,GAAG,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,EAAE,OAAO,CAAA;IAGrB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAEjC,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAA;IAEpB,OAAO,EAAE,OAAO,CAAA;IAQhB,mBAAmB,CAAC,EAAE,IAAI,CAAA;CAC3B;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,CAA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AAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAqBD,eAAO,MAAM,gBAAgB;;;;;;;;EA+U5B,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,CAAC,GAAG,GAAG,EAAE,KAAK,MAAM,KAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAI3F,CAAA"}
@@ -10,6 +10,15 @@ export const SETTINGS = {
10
10
  // feature flags / mantle settings:
11
11
  dev_mode: { key: "dev_mode", defaultValue: () => __DEV__, writable: true, saveOnServer: true, persist: true }, // deprecated
12
12
  debug_mode: { key: "debug_mode", defaultValue: () => __DEV__, writable: true, saveOnServer: true, persist: true },
13
+ android_notification_listener_enabled: {
14
+ key: "android_notification_listener_enabled",
15
+ // Operational kill switch. The listener now runs in a guarded lightweight
16
+ // process, so normal installs can safely capture notifications by default.
17
+ defaultValue: () => true,
18
+ writable: true,
19
+ saveOnServer: true,
20
+ persist: true,
21
+ },
13
22
  super_mode: { key: "super_mode", defaultValue: () => false, writable: true, saveOnServer: true, persist: true },
14
23
  appearance_menu_enabled: {
15
24
  key: "appearance_menu_enabled",
@@ -134,6 +143,7 @@ export const SETTINGS = {
134
143
  writable: true,
135
144
  saveOnServer: false,
136
145
  persist: true,
146
+ resetOnBuildEnvChange: true,
137
147
  },
138
148
  cloud_runtime_url: {
139
149
  key: "cloud_runtime_url",
@@ -141,6 +151,7 @@ export const SETTINGS = {
141
151
  writable: true,
142
152
  saveOnServer: false,
143
153
  persist: true,
154
+ resetOnBuildEnvChange: true,
144
155
  },
145
156
  // Bookmarked Cloud V2 endpoint pairs. Each entry is {label, coreUrl,
146
157
  // runtimeUrl} — core + runtime are saved together because they are always
@@ -154,7 +165,7 @@ export const SETTINGS = {
154
165
  },
155
166
  // Developer override for the ASG OTA manifest URL. null/empty = no override;
156
167
  // the normal selection applies (legacy-glasses gate, EXPO_PUBLIC_ASG_OTA_VERSION_URL,
157
- // glasses-reported URL, then production). See getAsgOtaVersionUrl.
168
+ // glasses-reported URL, then production). See resolveOtaManifestUrl.
158
169
  ota_version_url: {
159
170
  key: "ota_version_url",
160
171
  defaultValue: () => null,
@@ -225,6 +236,14 @@ export const SETTINGS = {
225
236
  persist: true,
226
237
  nativeAuthoritative: true,
227
238
  },
239
+ project_name: {
240
+ key: "project_name",
241
+ defaultValue: () => "",
242
+ writable: true,
243
+ saveOnServer: false,
244
+ persist: true,
245
+ nativeAuthoritative: true,
246
+ },
228
247
  default_controller: {
229
248
  key: "default_controller",
230
249
  defaultValue: () => "",
@@ -338,12 +357,23 @@ export const SETTINGS = {
338
357
  saveOnServer: true,
339
358
  persist: true,
340
359
  },
360
+ // The Mentra App intentionally preserves Mentra Live's historical VAD-on
361
+ // product default. Standalone public Bluetooth SDK hosts default VAD off so
362
+ // their microphone audio remains continuous.
341
363
  voice_activity_detection_enabled: {
342
364
  key: "voice_activity_detection_enabled",
343
365
  defaultValue: () => true,
344
366
  writable: true,
345
- saveOnServer: false,
346
- persist: false,
367
+ saveOnServer: true,
368
+ persist: true,
369
+ },
370
+ // Mentra Live center-mic loudness / "Barrier" gate (cs_swit type 10). Default on.
371
+ loudness_gate_enabled: {
372
+ key: "loudness_gate_enabled",
373
+ defaultValue: () => true,
374
+ writable: true,
375
+ saveOnServer: true,
376
+ persist: true,
347
377
  },
348
378
  always_on_status_bar: {
349
379
  key: "always_on_status_bar",
@@ -496,7 +526,7 @@ export const SETTINGS = {
496
526
  },
497
527
  camera_fov: {
498
528
  key: "camera_fov",
499
- defaultValue: () => ({ fov: 102, roi_position: 0 }),
529
+ defaultValue: () => ({ fov: 118, roi_position: 0 }),
500
530
  writable: true,
501
531
  saveOnServer: true,
502
532
  persist: true,
@@ -533,7 +563,7 @@ export const SETTINGS = {
533
563
  // offline applets
534
564
  offline_mode: { key: "offline_mode", defaultValue: () => false, writable: true, saveOnServer: true, persist: true },
535
565
  // Runtime flag: coordinator flips this on when cloud STT has failed and fallback is active.
536
- // Native GlassesStore watches it to gate PCM Sherpa feeding. Not user-facing.
566
+ // Native GlassesStore watches it to gate PCM 鈫?Sherpa feeding. Not user-facing.
537
567
  local_stt_fallback_active: {
538
568
  key: "local_stt_fallback_active",
539
569
  defaultValue: () => false,
@@ -594,13 +624,6 @@ export const SETTINGS = {
594
624
  persist: true,
595
625
  },
596
626
  // notifications
597
- notifications_enabled: {
598
- key: "notifications_enabled",
599
- defaultValue: () => true,
600
- writable: true,
601
- saveOnServer: true,
602
- persist: true,
603
- },
604
627
  notifications_blocklist: {
605
628
  key: "notifications_blocklist",
606
629
  defaultValue: () => [],
@@ -641,6 +664,7 @@ export const BLUETOOTH_SETTING_KEYS = [
641
664
  SETTINGS.sensing_enabled.key,
642
665
  SETTINGS.power_saving_mode.key,
643
666
  SETTINGS.voice_activity_detection_enabled.key,
667
+ SETTINGS.loudness_gate_enabled.key,
644
668
  SETTINGS.lc3_frame_size.key,
645
669
  SETTINGS.preferred_mic.key,
646
670
  SETTINGS.screen_disabled.key,
@@ -669,6 +693,7 @@ export const BLUETOOTH_SETTING_KEYS = [
669
693
  SETTINGS.default_wearable.key,
670
694
  SETTINGS.device_name.key,
671
695
  SETTINGS.device_address.key,
696
+ SETTINGS.project_name.key,
672
697
  SETTINGS.default_controller.key,
673
698
  SETTINGS.pending_controller.key,
674
699
  SETTINGS.controller_device_name.key,
@@ -676,7 +701,7 @@ export const BLUETOOTH_SETTING_KEYS = [
676
701
  // offline applets:
677
702
  SETTINGS.offline_mode.key,
678
703
  // Runtime flag flipped by LocalSttFallbackCoordinator. Native reads it from
679
- // GlassesStore to gate PCM Sherpa feeding in handlePcm and to keep the
704
+ // GlassesStore to gate PCM 鈫?Sherpa feeding in handlePcm and to keep the
680
705
  // mic on while local STT is the active engine.
681
706
  SETTINGS.local_stt_fallback_active.key,
682
707
  SETTINGS.gallery_mode.key,
@@ -686,12 +711,12 @@ export const BLUETOOTH_SETTING_KEYS = [
686
711
  ];
687
712
  // Pairing identity is NATIVE-authoritative: the native layer writes it on
688
713
  // pairing success (handleDeviceReady) / forget and echoes it down via
689
- // save_setting; JS persists those echoes. JS→native, identity travels ONLY in
714
+ // save_setting; JS persists those echoes. JS鈫抧ative, identity travels ONLY in
690
715
  // the explicit full seeds (device-store hydration, pre-connect push,
691
716
  // post-demotion re-push) — never in the change-push subscription. Relaying an
692
717
  // echoed identity change back up would make the sync bidirectional with loop
693
718
  // gain 1: two identity values in flight (e.g. a boot demotion crossing a
694
- // native promotion) then chase each other through push→apply→echo→push
719
+ // native promotion) then chase each other through push鈫抋pply鈫抏cho鈫抪ush
695
720
  // forever, flapping the UI.
696
721
  //
697
722
  // Derived from the `nativeAuthoritative` descriptor flag (not maintained as a
@@ -709,6 +734,9 @@ const getDefaultSettings = () => Object.keys(SETTINGS).reduce((acc, key) => {
709
734
  // second caller runs a duplicate full disk load while the first is still in
710
735
  // flight. Cleared on failure so a later call can retry.
711
736
  let loadAllSettingsInFlight = null;
737
+ function printableSettingValue(key, value) {
738
+ return key.includes("token") || key.includes("email") ? "<redacted>" : JSON.stringify(value);
739
+ }
712
740
  export const useSettingsStore = create()(subscribeWithSelector((set, get) => ({
713
741
  settings: getDefaultSettings(),
714
742
  isInitialized: false,
@@ -727,7 +755,7 @@ export const useSettingsStore = create()(subscribeWithSelector((set, get) => ({
727
755
  throw new Error(`SETTINGS: ${originalKey} is not writable!`);
728
756
  }
729
757
  // Update store immediately for optimistic UI
730
- console.log(`SETTINGS: SET: ${key} = ${value}`);
758
+ console.log(`SETTINGS: SET: ${key} = ${printableSettingValue(key, value)}`);
731
759
  set((state) => ({
732
760
  settings: { ...state.settings, [key]: value },
733
761
  }));
@@ -838,8 +866,7 @@ export const useSettingsStore = create()(subscribeWithSelector((set, get) => ({
838
866
  // logs are uploaded in bug-report artifacts (same keys
839
867
  // diagnosticContext's SENSITIVE_SETTINGS_KEYS strips, minus an
840
868
  // import that would cycle stores <-> utils).
841
- const printable = setting.key.includes("token") || setting.key.includes("email") ? "<redacted>" : JSON.stringify(value);
842
- console.log(`SETTINGS: LOAD: ${setting.key} = ${printable}`);
869
+ console.log(`SETTINGS: LOAD: ${setting.key} = ${printableSettingValue(setting.key, value)}`);
843
870
  loadedSettings[setting.key] = value;
844
871
  }
845
872
  // console.log("##############################################")
@@ -849,6 +876,91 @@ export const useSettingsStore = create()(subscribeWithSelector((set, get) => ({
849
876
  isInitialized: true,
850
877
  settings: { ...state.settings, ...loadedSettings },
851
878
  }));
879
+ // This hidden debug switch originally shipped default-off while the
880
+ // notification-listener cold-start ANR was being investigated. Now
881
+ // that the listener runs in its own guarded process, migrate existing
882
+ // installs to the new default once; later explicit debug changes still
883
+ // persist normally.
884
+ // Reset the cloud backend override when the build's environment changes.
885
+ //
886
+ // cloud_core_url / cloud_runtime_url are persist:true and outrank both
887
+ // the build's env and the compiled default (see resolveUrl in
888
+ // cloudClient.ts). That is what we want inside one environment: a
889
+ // developer's METRO_AUTO pin should survive a rebuild. It is wrong
890
+ // across environments.
891
+ //
892
+ // The concrete case is an install that moves BETWEEN environments: an
893
+ // internal tester running a dev build with a pinned override who then
894
+ // installs the store build. The override outranks that build's prod
895
+ // URLs, so without this they keep talking to dev with nothing
896
+ // surfacing it.
897
+ //
898
+ // Note what this deliberately does NOT do, because the distinction is
899
+ // easy to get backwards. TestFlight and the App Store receive the SAME
900
+ // binary, so promotion does not change EXPO_PUBLIC_BUILD_ENV and this
901
+ // reset never fires on it. Promotion is safe for a different reason:
902
+ // the publishing lane bakes prod URLs (staging-builds.yml defaults
903
+ // cloud_env to prod), so a promoted build was pointed at production the
904
+ // whole time. The same holds for Android internal-track to production.
905
+ //
906
+ // The residual gap is therefore an override pinned while already on a
907
+ // prod-labelled build, which no label comparison can see. That is a
908
+ // deliberate limit: reaching it means typing a URL into a dev-only
909
+ // screen, VersionInfo renders the current value, and the same screen
910
+ // clears it.
911
+ //
912
+ // Comparing the baked EXPO_PUBLIC_BUILD_ENV against the last one seen
913
+ // on this device covers those environment switches and fresh installs
914
+ // without touching the setting write path. A reinstall needs no
915
+ // handling: it drops the marker and the override together
916
+ // (android:allowBackup="false", and iOS deletes the container).
917
+ const BUILD_ENV_KEY = "settings.lastBuildEnv";
918
+ const buildEnv = (process.env.EXPO_PUBLIC_BUILD_ENV ?? "dev").trim() || "dev";
919
+ const lastBuildEnv = storage.load(BUILD_ENV_KEY);
920
+ const previousBuildEnv = lastBuildEnv.is_error() ? undefined : lastBuildEnv.value;
921
+ if (previousBuildEnv !== buildEnv) {
922
+ // Clear when there is no marker yet, not just on a recorded change.
923
+ // The first build carrying this code meets every existing install
924
+ // with previousBuildEnv === undefined, and those are exactly the
925
+ // installs that may hold an override set before the pin existed --
926
+ // the population this is here to repair. Treating "no marker" as a
927
+ // fresh install would record the marker and never look again. A
928
+ // genuinely fresh install has nothing persisted, so the clear below
929
+ // writes each default over itself and costs nothing.
930
+ //
931
+ // Driven by the descriptors rather than a hardcoded key list, so a
932
+ // setting that needs this behaviour declares it in one place and
933
+ // cannot be missed here.
934
+ const scoped = Object.values(SETTINGS).filter((setting) => setting.resetOnBuildEnvChange);
935
+ console.log(`SETTINGS: build env ${previousBuildEnv ?? "(none recorded)"} -> ${buildEnv}, ` +
936
+ `clearing ${scoped.length} build-scoped setting(s)`);
937
+ let allCleared = true;
938
+ for (const setting of scoped) {
939
+ const cleared = await get().setSetting(setting.key, setting.defaultValue(), false);
940
+ if (cleared.is_error()) {
941
+ allCleared = false;
942
+ console.log(`SETTINGS: could not clear ${setting.key}:`, cleared.error);
943
+ }
944
+ }
945
+ // Advance the marker only once the reset actually landed. Recording
946
+ // it after a failed write would retire the retry and leave the stale
947
+ // override for the life of the install; leaving it unset costs one
948
+ // repeated attempt per launch until a write succeeds.
949
+ if (allCleared) {
950
+ storage.save(BUILD_ENV_KEY, buildEnv);
951
+ }
952
+ }
953
+ const NOTIFICATION_LISTENER_MIGRATION_KEY = "migration:android_notification_listener_default_on_v1";
954
+ const notificationListenerMigrationDone = storage.load(NOTIFICATION_LISTENER_MIGRATION_KEY);
955
+ if (notificationListenerMigrationDone.is_error() || !notificationListenerMigrationDone.value) {
956
+ const result = await get().setSetting(SETTINGS.android_notification_listener_enabled.key, true, false);
957
+ if (result.is_error()) {
958
+ console.log("SETTINGS: notification listener migration failed:", result.error);
959
+ }
960
+ else {
961
+ storage.save(NOTIFICATION_LISTENER_MIGRATION_KEY, true);
962
+ }
963
+ }
852
964
  // One-time migration: force android_blur=false for existing users.
853
965
  // The setting's default is already false; this migration covers users
854
966
  // who explicitly opted into Android blur effects before we discovered
@@ -856,7 +968,7 @@ export const useSettingsStore = create()(subscribeWithSelector((set, get) => ({
856
968
  // The dimezisBlurViewSdk31Plus blur each costs ~5-10ms/frame; with
857
969
  // multiple blurs on home (top fade + AppSwitcherButton x2) a low-end
858
970
  // device misses the 16ms budget consistently. Users can turn it back
859
- // on under Settings Appearance once we've optimized further.
971
+ // on under Settings 鈫?Appearance once we've optimized further.
860
972
  //
861
973
  // The setSetting call also pushes to the server (saveOnServer: true)
862
974
  // so the server-stored value flips too — otherwise the next sync
@@ -882,6 +994,27 @@ export const useSettingsStore = create()(subscribeWithSelector((set, get) => ({
882
994
  // already correct.
883
995
  storage.save(MIGRATION_KEY, true);
884
996
  }
997
+ // The old camera default cropped the sensor to 102掳. Move existing
998
+ // default-shaped values to the full 118掳 sensor once; named miniapp
999
+ // requests for the 102掳 "standard" preset remain available.
1000
+ const CAMERA_FOV_MIGRATION_KEY = "migration:camera_fov_full_sensor_v1";
1001
+ const cameraFovMigrationDone = storage.load(CAMERA_FOV_MIGRATION_KEY);
1002
+ if (cameraFovMigrationDone.is_error() || !cameraFovMigrationDone.value) {
1003
+ const current = get().getSetting(SETTINGS.camera_fov.key);
1004
+ let migrationSucceeded = true;
1005
+ if (current?.fov === 102 && (current.roi_position ?? 0) === 0) {
1006
+ const result = await get().setSetting(SETTINGS.camera_fov.key, { fov: 118, roi_position: 0 }, true);
1007
+ if (result.is_error()) {
1008
+ console.log("SETTINGS: camera FOV migration failed:", result.error);
1009
+ migrationSucceeded = false;
1010
+ }
1011
+ }
1012
+ // Unlike the blur migration above, a failed camera set may leave the
1013
+ // local value unchanged. Only mark this migration complete once the
1014
+ // desired value was applied so a transient failure retries on boot.
1015
+ if (migrationSucceeded)
1016
+ storage.save(CAMERA_FOV_MIGRATION_KEY, true);
1017
+ }
885
1018
  });
886
1019
  loadAllSettingsInFlight = inFlight;
887
1020
  void Promise.resolve(inFlight).then((result) => {