@mentra/engine 0.1.0-beta.0
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.
- package/README.md +79 -0
- package/build/devtools.d.ts +11 -0
- package/build/devtools.d.ts.map +1 -0
- package/build/devtools.js +13 -0
- package/build/devtools.js.map +1 -0
- package/build/engine.d.ts +261 -0
- package/build/engine.d.ts.map +1 -0
- package/build/engine.js +170 -0
- package/build/engine.js.map +1 -0
- package/build/facades/dev.d.ts +58 -0
- package/build/facades/dev.d.ts.map +1 -0
- package/build/facades/dev.js +189 -0
- package/build/facades/dev.js.map +1 -0
- package/build/facades/display.d.ts +21 -0
- package/build/facades/display.d.ts.map +1 -0
- package/build/facades/display.js +17 -0
- package/build/facades/display.js.map +1 -0
- package/build/facades/displayMirror.d.ts +15 -0
- package/build/facades/displayMirror.d.ts.map +1 -0
- package/build/facades/displayMirror.js +29 -0
- package/build/facades/displayMirror.js.map +1 -0
- package/build/facades/gallery.d.ts +62 -0
- package/build/facades/gallery.d.ts.map +1 -0
- package/build/facades/gallery.js +61 -0
- package/build/facades/gallery.js.map +1 -0
- package/build/facades/glasses.d.ts +141 -0
- package/build/facades/glasses.d.ts.map +1 -0
- package/build/facades/glasses.js +199 -0
- package/build/facades/glasses.js.map +1 -0
- package/build/facades/glassesSettings.d.ts +13 -0
- package/build/facades/glassesSettings.d.ts.map +1 -0
- package/build/facades/glassesSettings.js +54 -0
- package/build/facades/glassesSettings.js.map +1 -0
- package/build/facades/glassesWifi.d.ts +25 -0
- package/build/facades/glassesWifi.d.ts.map +1 -0
- package/build/facades/glassesWifi.js +57 -0
- package/build/facades/glassesWifi.js.map +1 -0
- package/build/facades/miniapps.d.ts +43 -0
- package/build/facades/miniapps.d.ts.map +1 -0
- package/build/facades/miniapps.js +49 -0
- package/build/facades/miniapps.js.map +1 -0
- package/build/facades/notifications.d.ts +13 -0
- package/build/facades/notifications.d.ts.map +1 -0
- package/build/facades/notifications.js +12 -0
- package/build/facades/notifications.js.map +1 -0
- package/build/facades/ota.d.ts +103 -0
- package/build/facades/ota.d.ts.map +1 -0
- package/build/facades/ota.js +156 -0
- package/build/facades/ota.js.map +1 -0
- package/build/facades/pairing.d.ts +114 -0
- package/build/facades/pairing.d.ts.map +1 -0
- package/build/facades/pairing.js +275 -0
- package/build/facades/pairing.js.map +1 -0
- package/build/facades/permissions.d.ts +33 -0
- package/build/facades/permissions.d.ts.map +1 -0
- package/build/facades/permissions.js +155 -0
- package/build/facades/permissions.js.map +1 -0
- package/build/facades/phoneNotifications.d.ts +21 -0
- package/build/facades/phoneNotifications.d.ts.map +1 -0
- package/build/facades/phoneNotifications.js +51 -0
- package/build/facades/phoneNotifications.js.map +1 -0
- package/build/facades/reports.d.ts +36 -0
- package/build/facades/reports.d.ts.map +1 -0
- package/build/facades/reports.js +134 -0
- package/build/facades/reports.js.map +1 -0
- package/build/facades/session.d.ts +21 -0
- package/build/facades/session.d.ts.map +1 -0
- package/build/facades/session.js +52 -0
- package/build/facades/session.js.map +1 -0
- package/build/facades/settings.d.ts +37 -0
- package/build/facades/settings.d.ts.map +1 -0
- package/build/facades/settings.js +55 -0
- package/build/facades/settings.js.map +1 -0
- package/build/facades/speech.d.ts +30 -0
- package/build/facades/speech.d.ts.map +1 -0
- package/build/facades/speech.js +37 -0
- package/build/facades/speech.js.map +1 -0
- package/build/index.d.ts +43 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +45 -0
- package/build/index.js.map +1 -0
- package/build/internal.d.ts +67 -0
- package/build/internal.d.ts.map +1 -0
- package/build/internal.js +90 -0
- package/build/internal.js.map +1 -0
- package/build/runtime/bootstrap.d.ts +83 -0
- package/build/runtime/bootstrap.d.ts.map +1 -0
- package/build/runtime/bootstrap.js +56 -0
- package/build/runtime/bootstrap.js.map +1 -0
- package/build/runtime/config.d.ts +146 -0
- package/build/runtime/config.d.ts.map +1 -0
- package/build/runtime/config.js +18 -0
- package/build/runtime/config.js.map +1 -0
- package/build/runtime/streamConfig.d.ts +4 -0
- package/build/runtime/streamConfig.d.ts.map +1 -0
- package/build/runtime/streamConfig.js +38 -0
- package/build/runtime/streamConfig.js.map +1 -0
- package/build/services/AppRegistry.d.ts +269 -0
- package/build/services/AppRegistry.d.ts.map +1 -0
- package/build/services/AppRegistry.js +1079 -0
- package/build/services/AppRegistry.js.map +1 -0
- package/build/services/AudioCloudUplink.d.ts +9 -0
- package/build/services/AudioCloudUplink.d.ts.map +1 -0
- package/build/services/AudioCloudUplink.js +48 -0
- package/build/services/AudioCloudUplink.js.map +1 -0
- package/build/services/AudioPlaybackService.d.ts +175 -0
- package/build/services/AudioPlaybackService.d.ts.map +1 -0
- package/build/services/AudioPlaybackService.js +705 -0
- package/build/services/AudioPlaybackService.js.map +1 -0
- package/build/services/AutomaticReportResult.d.ts +20 -0
- package/build/services/AutomaticReportResult.d.ts.map +1 -0
- package/build/services/AutomaticReportResult.js +29 -0
- package/build/services/AutomaticReportResult.js.map +1 -0
- package/build/services/BlobStore.d.ts +91 -0
- package/build/services/BlobStore.d.ts.map +1 -0
- package/build/services/BlobStore.js +668 -0
- package/build/services/BlobStore.js.map +1 -0
- package/build/services/CaptionsTesterReportService.d.ts +4 -0
- package/build/services/CaptionsTesterReportService.d.ts.map +1 -0
- package/build/services/CaptionsTesterReportService.js +80 -0
- package/build/services/CaptionsTesterReportService.js.map +1 -0
- package/build/services/CloudAudioSubscriptionSync.d.ts +24 -0
- package/build/services/CloudAudioSubscriptionSync.d.ts.map +1 -0
- package/build/services/CloudAudioSubscriptionSync.js +39 -0
- package/build/services/CloudAudioSubscriptionSync.js.map +1 -0
- package/build/services/CloudClientService.d.ts +143 -0
- package/build/services/CloudClientService.d.ts.map +1 -0
- package/build/services/CloudClientService.js +644 -0
- package/build/services/CloudClientService.js.map +1 -0
- package/build/services/CloudTranscriptE2EMetrics.d.ts +4 -0
- package/build/services/CloudTranscriptE2EMetrics.d.ts.map +1 -0
- package/build/services/CloudTranscriptE2EMetrics.js +24 -0
- package/build/services/CloudTranscriptE2EMetrics.js.map +1 -0
- package/build/services/ConnectionCoordinator.d.ts +51 -0
- package/build/services/ConnectionCoordinator.d.ts.map +1 -0
- package/build/services/ConnectionCoordinator.js +34 -0
- package/build/services/ConnectionCoordinator.js.map +1 -0
- package/build/services/DevServerBridge.d.ts +63 -0
- package/build/services/DevServerBridge.d.ts.map +1 -0
- package/build/services/DevServerBridge.js +294 -0
- package/build/services/DevServerBridge.js.map +1 -0
- package/build/services/DeviceEventRouter.d.ts +3 -0
- package/build/services/DeviceEventRouter.d.ts.map +1 -0
- package/build/services/DeviceEventRouter.js +190 -0
- package/build/services/DeviceEventRouter.js.map +1 -0
- package/build/services/DeviceStoreHydration.d.ts +38 -0
- package/build/services/DeviceStoreHydration.d.ts.map +1 -0
- package/build/services/DeviceStoreHydration.js +124 -0
- package/build/services/DeviceStoreHydration.js.map +1 -0
- package/build/services/DisplayProcessor.d.ts +223 -0
- package/build/services/DisplayProcessor.d.ts.map +1 -0
- package/build/services/DisplayProcessor.js +552 -0
- package/build/services/DisplayProcessor.js.map +1 -0
- package/build/services/GlassesReadiness.d.ts +41 -0
- package/build/services/GlassesReadiness.d.ts.map +1 -0
- package/build/services/GlassesReadiness.js +82 -0
- package/build/services/GlassesReadiness.js.map +1 -0
- package/build/services/GlassesSettingsSync.d.ts +33 -0
- package/build/services/GlassesSettingsSync.d.ts.map +1 -0
- package/build/services/GlassesSettingsSync.js +121 -0
- package/build/services/GlassesSettingsSync.js.map +1 -0
- package/build/services/GlassesStatusProjection.d.ts +3 -0
- package/build/services/GlassesStatusProjection.d.ts.map +1 -0
- package/build/services/GlassesStatusProjection.js +65 -0
- package/build/services/GlassesStatusProjection.js.map +1 -0
- package/build/services/HeadingService.d.ts +27 -0
- package/build/services/HeadingService.d.ts.map +1 -0
- package/build/services/HeadingService.js +96 -0
- package/build/services/HeadingService.js.map +1 -0
- package/build/services/LocalDisplayManager.d.ts +139 -0
- package/build/services/LocalDisplayManager.d.ts.map +1 -0
- package/build/services/LocalDisplayManager.js +579 -0
- package/build/services/LocalDisplayManager.js.map +1 -0
- package/build/services/LocalMiniappRuntime.d.ts +439 -0
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -0
- package/build/services/LocalMiniappRuntime.js +3695 -0
- package/build/services/LocalMiniappRuntime.js.map +1 -0
- package/build/services/LocalSttFallbackCoordinator.d.ts +57 -0
- package/build/services/LocalSttFallbackCoordinator.d.ts.map +1 -0
- package/build/services/LocalSttFallbackCoordinator.js +137 -0
- package/build/services/LocalSttFallbackCoordinator.js.map +1 -0
- package/build/services/MentraJSCrashController.d.ts +97 -0
- package/build/services/MentraJSCrashController.d.ts.map +1 -0
- package/build/services/MentraJSCrashController.js +138 -0
- package/build/services/MentraJSCrashController.js.map +1 -0
- package/build/services/MentraJSCrashloopReportService.d.ts +9 -0
- package/build/services/MentraJSCrashloopReportService.d.ts.map +1 -0
- package/build/services/MentraJSCrashloopReportService.js +54 -0
- package/build/services/MentraJSCrashloopReportService.js.map +1 -0
- package/build/services/MentraJSLogPipeline.d.ts +87 -0
- package/build/services/MentraJSLogPipeline.d.ts.map +1 -0
- package/build/services/MentraJSLogPipeline.js +137 -0
- package/build/services/MentraJSLogPipeline.js.map +1 -0
- package/build/services/MentraJSRouter.d.ts +203 -0
- package/build/services/MentraJSRouter.d.ts.map +1 -0
- package/build/services/MentraJSRouter.js +480 -0
- package/build/services/MentraJSRouter.js.map +1 -0
- package/build/services/MentraUIRouter.d.ts +137 -0
- package/build/services/MentraUIRouter.d.ts.map +1 -0
- package/build/services/MentraUIRouter.js +210 -0
- package/build/services/MentraUIRouter.js.map +1 -0
- package/build/services/MicStateCoordinator.d.ts +37 -0
- package/build/services/MicStateCoordinator.d.ts.map +1 -0
- package/build/services/MicStateCoordinator.js +81 -0
- package/build/services/MicStateCoordinator.js.map +1 -0
- package/build/services/MiniappEngine.d.ts +31 -0
- package/build/services/MiniappEngine.d.ts.map +1 -0
- package/build/services/MiniappEngine.js +119 -0
- package/build/services/MiniappEngine.js.map +1 -0
- package/build/services/MiniappLauncher.d.ts +129 -0
- package/build/services/MiniappLauncher.d.ts.map +1 -0
- package/build/services/MiniappLauncher.js +291 -0
- package/build/services/MiniappLauncher.js.map +1 -0
- package/build/services/MiniappRunningRegistry.d.ts +24 -0
- package/build/services/MiniappRunningRegistry.d.ts.map +1 -0
- package/build/services/MiniappRunningRegistry.js +52 -0
- package/build/services/MiniappRunningRegistry.js.map +1 -0
- package/build/services/NativeHttpResponse.d.ts +3 -0
- package/build/services/NativeHttpResponse.d.ts.map +1 -0
- package/build/services/NativeHttpResponse.js +6 -0
- package/build/services/NativeHttpResponse.js.map +1 -0
- package/build/services/NavigationHandlers.d.ts +90 -0
- package/build/services/NavigationHandlers.d.ts.map +1 -0
- package/build/services/NavigationHandlers.js +379 -0
- package/build/services/NavigationHandlers.js.map +1 -0
- package/build/services/NavigationService.d.ts +254 -0
- package/build/services/NavigationService.d.ts.map +1 -0
- package/build/services/NavigationService.js +553 -0
- package/build/services/NavigationService.js.map +1 -0
- package/build/services/NotificationsEmitter.d.ts +28 -0
- package/build/services/NotificationsEmitter.d.ts.map +1 -0
- package/build/services/NotificationsEmitter.js +22 -0
- package/build/services/NotificationsEmitter.js.map +1 -0
- package/build/services/OfflineSpeechModelService.d.ts +33 -0
- package/build/services/OfflineSpeechModelService.d.ts.map +1 -0
- package/build/services/OfflineSpeechModelService.js +136 -0
- package/build/services/OfflineSpeechModelService.js.map +1 -0
- package/build/services/OtaInstallCoordinator.d.ts +195 -0
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -0
- package/build/services/OtaInstallCoordinator.js +1047 -0
- package/build/services/OtaInstallCoordinator.js.map +1 -0
- package/build/services/OtaService.d.ts +3 -0
- package/build/services/OtaService.d.ts.map +1 -0
- package/build/services/OtaService.js +65 -0
- package/build/services/OtaService.js.map +1 -0
- package/build/services/OtaUpdateCheckService.d.ts +65 -0
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -0
- package/build/services/OtaUpdateCheckService.js +260 -0
- package/build/services/OtaUpdateCheckService.js.map +1 -0
- package/build/services/PairingIdentity.d.ts +80 -0
- package/build/services/PairingIdentity.d.ts.map +1 -0
- package/build/services/PairingIdentity.js +145 -0
- package/build/services/PairingIdentity.js.map +1 -0
- package/build/services/PhoneCalendarHelpers.d.ts +32 -0
- package/build/services/PhoneCalendarHelpers.d.ts.map +1 -0
- package/build/services/PhoneCalendarHelpers.js +157 -0
- package/build/services/PhoneCalendarHelpers.js.map +1 -0
- package/build/services/PhoneCalendarService.d.ts +5 -0
- package/build/services/PhoneCalendarService.d.ts.map +1 -0
- package/build/services/PhoneCalendarService.js +24 -0
- package/build/services/PhoneCalendarService.js.map +1 -0
- package/build/services/PhoneCameraFovCoordinator.d.ts +28 -0
- package/build/services/PhoneCameraFovCoordinator.d.ts.map +1 -0
- package/build/services/PhoneCameraFovCoordinator.js +180 -0
- package/build/services/PhoneCameraFovCoordinator.js.map +1 -0
- package/build/services/PhoneLocationService.d.ts +36 -0
- package/build/services/PhoneLocationService.d.ts.map +1 -0
- package/build/services/PhoneLocationService.js +115 -0
- package/build/services/PhoneLocationService.js.map +1 -0
- package/build/services/PhoneNotificationsSync.d.ts +3 -0
- package/build/services/PhoneNotificationsSync.d.ts.map +1 -0
- package/build/services/PhoneNotificationsSync.js +35 -0
- package/build/services/PhoneNotificationsSync.js.map +1 -0
- package/build/services/PhonePhotoCoordinator.d.ts +103 -0
- package/build/services/PhonePhotoCoordinator.d.ts.map +1 -0
- package/build/services/PhonePhotoCoordinator.js +326 -0
- package/build/services/PhonePhotoCoordinator.js.map +1 -0
- package/build/services/PhoneStreamCoordinator.d.ts +168 -0
- package/build/services/PhoneStreamCoordinator.d.ts.map +1 -0
- package/build/services/PhoneStreamCoordinator.js +632 -0
- package/build/services/PhoneStreamCoordinator.js.map +1 -0
- package/build/services/PhoneVideoCoordinator.d.ts +50 -0
- package/build/services/PhoneVideoCoordinator.d.ts.map +1 -0
- package/build/services/PhoneVideoCoordinator.js +147 -0
- package/build/services/PhoneVideoCoordinator.js.map +1 -0
- package/build/services/STTModelManager.d.ts +65 -0
- package/build/services/STTModelManager.d.ts.map +1 -0
- package/build/services/STTModelManager.js +292 -0
- package/build/services/STTModelManager.js.map +1 -0
- package/build/services/SceneRenderer.d.ts +90 -0
- package/build/services/SceneRenderer.d.ts.map +1 -0
- package/build/services/SceneRenderer.js +248 -0
- package/build/services/SceneRenderer.js.map +1 -0
- package/build/services/SentenceTtsPipeline.d.ts +31 -0
- package/build/services/SentenceTtsPipeline.d.ts.map +1 -0
- package/build/services/SentenceTtsPipeline.js +67 -0
- package/build/services/SentenceTtsPipeline.js.map +1 -0
- package/build/services/StreamLifecycleController.d.ts +67 -0
- package/build/services/StreamLifecycleController.d.ts.map +1 -0
- package/build/services/StreamLifecycleController.js +152 -0
- package/build/services/StreamLifecycleController.js.map +1 -0
- package/build/services/TTSModelManager.d.ts +90 -0
- package/build/services/TTSModelManager.d.ts.map +1 -0
- package/build/services/TTSModelManager.js +366 -0
- package/build/services/TTSModelManager.js.map +1 -0
- package/build/services/TranscriptionRouting.d.ts +12 -0
- package/build/services/TranscriptionRouting.d.ts.map +1 -0
- package/build/services/TranscriptionRouting.js +24 -0
- package/build/services/TranscriptionRouting.js.map +1 -0
- package/build/services/WebviewBridge.d.ts +22 -0
- package/build/services/WebviewBridge.d.ts.map +1 -0
- package/build/services/WebviewBridge.js +47 -0
- package/build/services/WebviewBridge.js.map +1 -0
- package/build/services/asg/GalleryMediaIntegrityReportService.d.ts +17 -0
- package/build/services/asg/GalleryMediaIntegrityReportService.d.ts.map +1 -0
- package/build/services/asg/GalleryMediaIntegrityReportService.js +43 -0
- package/build/services/asg/GalleryMediaIntegrityReportService.js.map +1 -0
- package/build/services/asg/asgCameraApi.d.ts +205 -0
- package/build/services/asg/asgCameraApi.d.ts.map +1 -0
- package/build/services/asg/asgCameraApi.js +1410 -0
- package/build/services/asg/asgCameraApi.js.map +1 -0
- package/build/services/asg/cameraRollExportCoordinator.d.ts +60 -0
- package/build/services/asg/cameraRollExportCoordinator.d.ts.map +1 -0
- package/build/services/asg/cameraRollExportCoordinator.js +618 -0
- package/build/services/asg/cameraRollExportCoordinator.js.map +1 -0
- package/build/services/asg/cameraRollExportLedger.d.ts +44 -0
- package/build/services/asg/cameraRollExportLedger.d.ts.map +1 -0
- package/build/services/asg/cameraRollExportLedger.js +78 -0
- package/build/services/asg/cameraRollExportLedger.js.map +1 -0
- package/build/services/asg/galleryMediaValidation.d.ts +29 -0
- package/build/services/asg/galleryMediaValidation.d.ts.map +1 -0
- package/build/services/asg/galleryMediaValidation.js +149 -0
- package/build/services/asg/galleryMediaValidation.js.map +1 -0
- package/build/services/asg/galleryNotices.d.ts +33 -0
- package/build/services/asg/galleryNotices.d.ts.map +1 -0
- package/build/services/asg/galleryNotices.js +29 -0
- package/build/services/asg/galleryNotices.js.map +1 -0
- package/build/services/asg/galleryPathMigration.d.ts +3 -0
- package/build/services/asg/galleryPathMigration.d.ts.map +1 -0
- package/build/services/asg/galleryPathMigration.js +26 -0
- package/build/services/asg/galleryPathMigration.js.map +1 -0
- package/build/services/asg/gallerySettingsService.d.ts +20 -0
- package/build/services/asg/gallerySettingsService.d.ts.map +1 -0
- package/build/services/asg/gallerySettingsService.js +53 -0
- package/build/services/asg/gallerySettingsService.js.map +1 -0
- package/build/services/asg/gallerySyncNotifications.d.ts +56 -0
- package/build/services/asg/gallerySyncNotifications.d.ts.map +1 -0
- package/build/services/asg/gallerySyncNotifications.js +198 -0
- package/build/services/asg/gallerySyncNotifications.js.map +1 -0
- package/build/services/asg/gallerySyncService.d.ts +137 -0
- package/build/services/asg/gallerySyncService.d.ts.map +1 -0
- package/build/services/asg/gallerySyncService.js +1933 -0
- package/build/services/asg/gallerySyncService.js.map +1 -0
- package/build/services/asg/galleryTransferLedger.d.ts +58 -0
- package/build/services/asg/galleryTransferLedger.d.ts.map +1 -0
- package/build/services/asg/galleryTransferLedger.js +225 -0
- package/build/services/asg/galleryTransferLedger.js.map +1 -0
- package/build/services/asg/localNetworkTransport.d.ts +15 -0
- package/build/services/asg/localNetworkTransport.d.ts.map +1 -0
- package/build/services/asg/localNetworkTransport.js +144 -0
- package/build/services/asg/localNetworkTransport.js.map +1 -0
- package/build/services/asg/localStorageService.d.ts +146 -0
- package/build/services/asg/localStorageService.d.ts.map +1 -0
- package/build/services/asg/localStorageService.js +572 -0
- package/build/services/asg/localStorageService.js.map +1 -0
- package/build/services/asg/mediaProcessingQueue.d.ts +70 -0
- package/build/services/asg/mediaProcessingQueue.d.ts.map +1 -0
- package/build/services/asg/mediaProcessingQueue.js +451 -0
- package/build/services/asg/mediaProcessingQueue.js.map +1 -0
- package/build/services/asgOtaVersionUrl.d.ts +2 -0
- package/build/services/asgOtaVersionUrl.d.ts.map +1 -0
- package/build/services/asgOtaVersionUrl.js +36 -0
- package/build/services/asgOtaVersionUrl.js.map +1 -0
- package/build/services/blobPaths.d.ts +31 -0
- package/build/services/blobPaths.d.ts.map +1 -0
- package/build/services/blobPaths.js +86 -0
- package/build/services/blobPaths.js.map +1 -0
- package/build/services/cloudStreamApi.d.ts +59 -0
- package/build/services/cloudStreamApi.d.ts.map +1 -0
- package/build/services/cloudStreamApi.js +81 -0
- package/build/services/cloudStreamApi.js.map +1 -0
- package/build/services/gallerySyncClock.d.ts +17 -0
- package/build/services/gallerySyncClock.d.ts.map +1 -0
- package/build/services/gallerySyncClock.js +21 -0
- package/build/services/gallerySyncClock.js.map +1 -0
- package/build/services/glassesClockSync.d.ts +20 -0
- package/build/services/glassesClockSync.d.ts.map +1 -0
- package/build/services/glassesClockSync.js +97 -0
- package/build/services/glassesClockSync.js.map +1 -0
- package/build/services/manifestVersionGate.d.ts +28 -0
- package/build/services/manifestVersionGate.d.ts.map +1 -0
- package/build/services/manifestVersionGate.js +41 -0
- package/build/services/manifestVersionGate.js.map +1 -0
- package/build/services/mentraUiShim.d.ts +38 -0
- package/build/services/mentraUiShim.d.ts.map +1 -0
- package/build/services/mentraUiShim.js +360 -0
- package/build/services/mentraUiShim.js.map +1 -0
- package/build/services/navigation/roadNameResolver.d.ts +67 -0
- package/build/services/navigation/roadNameResolver.d.ts.map +1 -0
- package/build/services/navigation/roadNameResolver.js +96 -0
- package/build/services/navigation/roadNameResolver.js.map +1 -0
- package/build/services/navigation/routesApiCodec.d.ts +38 -0
- package/build/services/navigation/routesApiCodec.d.ts.map +1 -0
- package/build/services/navigation/routesApiCodec.js +68 -0
- package/build/services/navigation/routesApiCodec.js.map +1 -0
- package/build/services/otaDisplayState.d.ts +42 -0
- package/build/services/otaDisplayState.d.ts.map +1 -0
- package/build/services/otaDisplayState.js +92 -0
- package/build/services/otaDisplayState.js.map +1 -0
- package/build/services/otaInstallPolicy.d.ts +81 -0
- package/build/services/otaInstallPolicy.d.ts.map +1 -0
- package/build/services/otaInstallPolicy.js +96 -0
- package/build/services/otaInstallPolicy.js.map +1 -0
- package/build/services/otaLegacyMapping.d.ts +22 -0
- package/build/services/otaLegacyMapping.d.ts.map +1 -0
- package/build/services/otaLegacyMapping.js +56 -0
- package/build/services/otaLegacyMapping.js.map +1 -0
- package/build/services/slimStreamStatus.d.ts +7 -0
- package/build/services/slimStreamStatus.d.ts.map +1 -0
- package/build/services/slimStreamStatus.js +26 -0
- package/build/services/slimStreamStatus.js.map +1 -0
- package/build/stores/apps.d.ts +104 -0
- package/build/stores/apps.d.ts.map +1 -0
- package/build/stores/apps.js +492 -0
- package/build/stores/apps.js.map +1 -0
- package/build/stores/bluetoothSettingKeys.d.ts +4 -0
- package/build/stores/bluetoothSettingKeys.d.ts.map +1 -0
- package/build/stores/bluetoothSettingKeys.js +31 -0
- package/build/stores/bluetoothSettingKeys.js.map +1 -0
- package/build/stores/cloudClientStatus.d.ts +9 -0
- package/build/stores/cloudClientStatus.d.ts.map +1 -0
- package/build/stores/cloudClientStatus.js +24 -0
- package/build/stores/cloudClientStatus.js.map +1 -0
- package/build/stores/connection.d.ts +22 -0
- package/build/stores/connection.d.ts.map +1 -0
- package/build/stores/connection.js +43 -0
- package/build/stores/connection.js.map +1 -0
- package/build/stores/core.d.ts +15 -0
- package/build/stores/core.d.ts.map +1 -0
- package/build/stores/core.js +21 -0
- package/build/stores/core.js.map +1 -0
- package/build/stores/display.d.ts +24 -0
- package/build/stores/display.d.ts.map +1 -0
- package/build/stores/display.js +96 -0
- package/build/stores/display.js.map +1 -0
- package/build/stores/gallerySync.d.ts +101 -0
- package/build/stores/gallerySync.d.ts.map +1 -0
- package/build/stores/gallerySync.js +217 -0
- package/build/stores/gallerySync.js.map +1 -0
- package/build/stores/glasses.d.ts +62 -0
- package/build/stores/glasses.d.ts.map +1 -0
- package/build/stores/glasses.js +203 -0
- package/build/stores/glasses.js.map +1 -0
- package/build/stores/settings.d.ts +37 -0
- package/build/stores/settings.d.ts.map +1 -0
- package/build/stores/settings.js +922 -0
- package/build/stores/settings.js.map +1 -0
- package/build/types/applet.d.ts +96 -0
- package/build/types/applet.d.ts.map +1 -0
- package/build/types/applet.js +5 -0
- package/build/types/applet.js.map +1 -0
- package/build/types/asg.d.ts +53 -0
- package/build/types/asg.d.ts.map +1 -0
- package/build/types/asg.js +2 -0
- package/build/types/asg.js.map +1 -0
- package/build/types/capabilities/even-realities-g1.d.ts +12 -0
- package/build/types/capabilities/even-realities-g1.d.ts.map +1 -0
- package/build/types/capabilities/even-realities-g1.js +55 -0
- package/build/types/capabilities/even-realities-g1.js.map +1 -0
- package/build/types/capabilities/even-realities-g2.d.ts +12 -0
- package/build/types/capabilities/even-realities-g2.d.ts.map +1 -0
- package/build/types/capabilities/even-realities-g2.js +75 -0
- package/build/types/capabilities/even-realities-g2.js.map +1 -0
- package/build/types/capabilities/mentra-display.d.ts +12 -0
- package/build/types/capabilities/mentra-display.d.ts.map +1 -0
- package/build/types/capabilities/mentra-display.js +63 -0
- package/build/types/capabilities/mentra-display.js.map +1 -0
- package/build/types/capabilities/mentra-live.d.ts +12 -0
- package/build/types/capabilities/mentra-live.d.ts.map +1 -0
- package/build/types/capabilities/mentra-live.js +92 -0
- package/build/types/capabilities/mentra-live.js.map +1 -0
- package/build/types/capabilities/none.d.ts +13 -0
- package/build/types/capabilities/none.d.ts.map +1 -0
- package/build/types/capabilities/none.js +65 -0
- package/build/types/capabilities/none.js.map +1 -0
- package/build/types/capabilities/simulated-glasses.d.ts +13 -0
- package/build/types/capabilities/simulated-glasses.d.ts.map +1 -0
- package/build/types/capabilities/simulated-glasses.js +65 -0
- package/build/types/capabilities/simulated-glasses.js.map +1 -0
- package/build/types/capabilities/vuzix-z100.d.ts +12 -0
- package/build/types/capabilities/vuzix-z100.d.ts.map +1 -0
- package/build/types/capabilities/vuzix-z100.js +52 -0
- package/build/types/capabilities/vuzix-z100.js.map +1 -0
- package/build/types/enums.d.ts +40 -0
- package/build/types/enums.d.ts.map +1 -0
- package/build/types/enums.js +44 -0
- package/build/types/enums.js.map +1 -0
- package/build/types/hardware.d.ts +160 -0
- package/build/types/hardware.d.ts.map +1 -0
- package/build/types/hardware.js +36 -0
- package/build/types/hardware.js.map +1 -0
- package/build/types/index.d.ts +11 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +10 -0
- package/build/types/index.js.map +1 -0
- package/build/utils/GlobalEventEmitter.d.ts +10 -0
- package/build/utils/GlobalEventEmitter.d.ts.map +1 -0
- package/build/utils/GlobalEventEmitter.js +13 -0
- package/build/utils/GlobalEventEmitter.js.map +1 -0
- package/build/utils/cloudClient/RnUdpAdapter.d.ts +3 -0
- package/build/utils/cloudClient/RnUdpAdapter.d.ts.map +1 -0
- package/build/utils/cloudClient/RnUdpAdapter.js +41 -0
- package/build/utils/cloudClient/RnUdpAdapter.js.map +1 -0
- package/build/utils/cloudClient/cloudSecureStore.d.ts +3 -0
- package/build/utils/cloudClient/cloudSecureStore.d.ts.map +1 -0
- package/build/utils/cloudClient/cloudSecureStore.js +26 -0
- package/build/utils/cloudClient/cloudSecureStore.js.map +1 -0
- package/build/utils/debouncedPatch.d.ts +6 -0
- package/build/utils/debouncedPatch.d.ts.map +1 -0
- package/build/utils/debouncedPatch.js +25 -0
- package/build/utils/debouncedPatch.js.map +1 -0
- package/build/utils/devLogging.d.ts +26 -0
- package/build/utils/devLogging.d.ts.map +1 -0
- package/build/utils/devLogging.js +116 -0
- package/build/utils/devLogging.js.map +1 -0
- package/build/utils/devMiniappLaunch.d.ts +44 -0
- package/build/utils/devMiniappLaunch.d.ts.map +1 -0
- package/build/utils/devMiniappLaunch.js +52 -0
- package/build/utils/devMiniappLaunch.js.map +1 -0
- package/build/utils/diagnosticContext.d.ts +3 -0
- package/build/utils/diagnosticContext.d.ts.map +1 -0
- package/build/utils/diagnosticContext.js +119 -0
- package/build/utils/diagnosticContext.js.map +1 -0
- package/build/utils/display/composer/ColumnComposer.d.ts +131 -0
- package/build/utils/display/composer/ColumnComposer.d.ts.map +1 -0
- package/build/utils/display/composer/ColumnComposer.js +204 -0
- package/build/utils/display/composer/ColumnComposer.js.map +1 -0
- package/build/utils/display/composer/index.d.ts +9 -0
- package/build/utils/display/composer/index.d.ts.map +1 -0
- package/build/utils/display/composer/index.js +9 -0
- package/build/utils/display/composer/index.js.map +1 -0
- package/build/utils/display/helpers/DisplayHelpers.d.ts +165 -0
- package/build/utils/display/helpers/DisplayHelpers.d.ts.map +1 -0
- package/build/utils/display/helpers/DisplayHelpers.js +312 -0
- package/build/utils/display/helpers/DisplayHelpers.js.map +1 -0
- package/build/utils/display/helpers/ScrollView.d.ts +183 -0
- package/build/utils/display/helpers/ScrollView.d.ts.map +1 -0
- package/build/utils/display/helpers/ScrollView.js +257 -0
- package/build/utils/display/helpers/ScrollView.js.map +1 -0
- package/build/utils/display/helpers/index.d.ts +11 -0
- package/build/utils/display/helpers/index.d.ts.map +1 -0
- package/build/utils/display/helpers/index.js +10 -0
- package/build/utils/display/helpers/index.js.map +1 -0
- package/build/utils/display/index.d.ts +174 -0
- package/build/utils/display/index.d.ts.map +1 -0
- package/build/utils/display/index.js +185 -0
- package/build/utils/display/index.js.map +1 -0
- package/build/utils/display/measurer/TextMeasurer.d.ts +160 -0
- package/build/utils/display/measurer/TextMeasurer.d.ts.map +1 -0
- package/build/utils/display/measurer/TextMeasurer.js +273 -0
- package/build/utils/display/measurer/TextMeasurer.js.map +1 -0
- package/build/utils/display/measurer/index.d.ts +10 -0
- package/build/utils/display/measurer/index.d.ts.map +1 -0
- package/build/utils/display/measurer/index.js +11 -0
- package/build/utils/display/measurer/index.js.map +1 -0
- package/build/utils/display/measurer/script-detection.d.ts +53 -0
- package/build/utils/display/measurer/script-detection.d.ts.map +1 -0
- package/build/utils/display/measurer/script-detection.js +184 -0
- package/build/utils/display/measurer/script-detection.js.map +1 -0
- package/build/utils/display/profiles/g1.d.ts +33 -0
- package/build/utils/display/profiles/g1.d.ts.map +1 -0
- package/build/utils/display/profiles/g1.js +213 -0
- package/build/utils/display/profiles/g1.js.map +1 -0
- package/build/utils/display/profiles/g2.d.ts +13 -0
- package/build/utils/display/profiles/g2.d.ts.map +1 -0
- package/build/utils/display/profiles/g2.js +34 -0
- package/build/utils/display/profiles/g2.js.map +1 -0
- package/build/utils/display/profiles/index.d.ts +12 -0
- package/build/utils/display/profiles/index.d.ts.map +1 -0
- package/build/utils/display/profiles/index.js +15 -0
- package/build/utils/display/profiles/index.js.map +1 -0
- package/build/utils/display/profiles/nex.d.ts +10 -0
- package/build/utils/display/profiles/nex.d.ts.map +1 -0
- package/build/utils/display/profiles/nex.js +150 -0
- package/build/utils/display/profiles/nex.js.map +1 -0
- package/build/utils/display/profiles/types.d.ts +103 -0
- package/build/utils/display/profiles/types.d.ts.map +1 -0
- package/build/utils/display/profiles/types.js +2 -0
- package/build/utils/display/profiles/types.js.map +1 -0
- package/build/utils/display/profiles/z100.d.ts +33 -0
- package/build/utils/display/profiles/z100.d.ts.map +1 -0
- package/build/utils/display/profiles/z100.js +182 -0
- package/build/utils/display/profiles/z100.js.map +1 -0
- package/build/utils/display/scene/degrade.d.ts +25 -0
- package/build/utils/display/scene/degrade.d.ts.map +1 -0
- package/build/utils/display/scene/degrade.js +64 -0
- package/build/utils/display/scene/degrade.js.map +1 -0
- package/build/utils/display/scene/differ.d.ts +38 -0
- package/build/utils/display/scene/differ.d.ts.map +1 -0
- package/build/utils/display/scene/differ.js +107 -0
- package/build/utils/display/scene/differ.js.map +1 -0
- package/build/utils/display/scene/index.d.ts +10 -0
- package/build/utils/display/scene/index.d.ts.map +1 -0
- package/build/utils/display/scene/index.js +6 -0
- package/build/utils/display/scene/index.js.map +1 -0
- package/build/utils/display/scene/process.d.ts +35 -0
- package/build/utils/display/scene/process.d.ts.map +1 -0
- package/build/utils/display/scene/process.js +187 -0
- package/build/utils/display/scene/process.js.map +1 -0
- package/build/utils/display/scene/store.d.ts +48 -0
- package/build/utils/display/scene/store.d.ts.map +1 -0
- package/build/utils/display/scene/store.js +0 -0
- package/build/utils/display/scene/store.js.map +1 -0
- package/build/utils/display/scene/types.d.ts +120 -0
- package/build/utils/display/scene/types.d.ts.map +1 -0
- package/build/utils/display/scene/types.js +0 -0
- package/build/utils/display/scene/types.js.map +1 -0
- package/build/utils/display/wrapper/TextWrapper.d.ts +102 -0
- package/build/utils/display/wrapper/TextWrapper.d.ts.map +1 -0
- package/build/utils/display/wrapper/TextWrapper.js +471 -0
- package/build/utils/display/wrapper/TextWrapper.js.map +1 -0
- package/build/utils/display/wrapper/index.d.ts +12 -0
- package/build/utils/display/wrapper/index.d.ts.map +1 -0
- package/build/utils/display/wrapper/index.js +12 -0
- package/build/utils/display/wrapper/index.js.map +1 -0
- package/build/utils/display/wrapper/types.d.ts +75 -0
- package/build/utils/display/wrapper/types.d.ts.map +1 -0
- package/build/utils/display/wrapper/types.js +11 -0
- package/build/utils/display/wrapper/types.js.map +1 -0
- package/build/utils/e2eMetrics.d.ts +6 -0
- package/build/utils/e2eMetrics.d.ts.map +1 -0
- package/build/utils/e2eMetrics.js +27 -0
- package/build/utils/e2eMetrics.js.map +1 -0
- package/build/utils/hardware/hardware.d.ts +42 -0
- package/build/utils/hardware/hardware.d.ts.map +1 -0
- package/build/utils/hardware/hardware.js +127 -0
- package/build/utils/hardware/hardware.js.map +1 -0
- package/build/utils/hardware/index.d.ts +2 -0
- package/build/utils/hardware/index.d.ts.map +1 -0
- package/build/utils/hardware/index.js +2 -0
- package/build/utils/hardware/index.js.map +1 -0
- package/build/utils/miniappGlobals.d.ts +60 -0
- package/build/utils/miniappGlobals.d.ts.map +1 -0
- package/build/utils/miniappGlobals.js +224 -0
- package/build/utils/miniappGlobals.js.map +1 -0
- package/build/utils/permissions/MediaLibraryPermissions.d.ts +45 -0
- package/build/utils/permissions/MediaLibraryPermissions.d.ts.map +1 -0
- package/build/utils/permissions/MediaLibraryPermissions.js +145 -0
- package/build/utils/permissions/MediaLibraryPermissions.js.map +1 -0
- package/build/utils/permissions/galleryDisplayName.d.ts +8 -0
- package/build/utils/permissions/galleryDisplayName.d.ts.map +1 -0
- package/build/utils/permissions/galleryDisplayName.js +25 -0
- package/build/utils/permissions/galleryDisplayName.js.map +1 -0
- package/build/utils/storage/index.d.ts +3 -0
- package/build/utils/storage/index.d.ts.map +1 -0
- package/build/utils/storage/index.js +3 -0
- package/build/utils/storage/index.js.map +1 -0
- package/build/utils/storage/storage.d.ts +24 -0
- package/build/utils/storage/storage.d.ts.map +1 -0
- package/build/utils/storage/storage.js +85 -0
- package/build/utils/storage/storage.js.map +1 -0
- package/build/utils/storage/zip.d.ts +3 -0
- package/build/utils/storage/zip.d.ts.map +1 -0
- package/build/utils/storage/zip.js +14 -0
- package/build/utils/storage/zip.js.map +1 -0
- package/build/utils/timers/index.d.ts +3 -0
- package/build/utils/timers/index.d.ts.map +1 -0
- package/build/utils/timers/index.js +3 -0
- package/build/utils/timers/index.js.map +1 -0
- package/build/utils/timers/timers.d.ts +9 -0
- package/build/utils/timers/timers.d.ts.map +1 -0
- package/build/utils/timers/timers.js +105 -0
- package/build/utils/timers/timers.js.map +1 -0
- package/package.json +120 -0
- package/src/devtools.ts +13 -0
- package/src/engine.ts +173 -0
- package/src/facades/dev.ts +198 -0
- package/src/facades/display.ts +17 -0
- package/src/facades/displayMirror.ts +33 -0
- package/src/facades/gallery.ts +69 -0
- package/src/facades/glasses.ts +206 -0
- package/src/facades/glassesSettings.ts +56 -0
- package/src/facades/glassesWifi.ts +68 -0
- package/src/facades/miniapps.ts +55 -0
- package/src/facades/notifications.ts +15 -0
- package/src/facades/ota.ts +174 -0
- package/src/facades/pairing.ts +329 -0
- package/src/facades/permissions.ts +165 -0
- package/src/facades/phoneNotifications.ts +50 -0
- package/src/facades/reports.ts +185 -0
- package/src/facades/session.ts +55 -0
- package/src/facades/settings.ts +57 -0
- package/src/facades/speech.ts +38 -0
- package/src/index.ts +191 -0
- package/src/internal.ts +159 -0
- package/src/runtime/bootstrap.ts +118 -0
- package/src/runtime/config.ts +147 -0
- package/src/runtime/streamConfig.ts +34 -0
- package/src/services/AppRegistry.ts +1190 -0
- package/src/services/AudioCloudUplink.ts +50 -0
- package/src/services/AudioPlaybackService.ts +813 -0
- package/src/services/AutomaticReportResult.ts +48 -0
- package/src/services/BlobStore.ts +746 -0
- package/src/services/CaptionsTesterReportService.ts +107 -0
- package/src/services/CloudAudioSubscriptionSync.ts +41 -0
- package/src/services/CloudClientService.ts +689 -0
- package/src/services/CloudTranscriptE2EMetrics.ts +27 -0
- package/src/services/ConnectionCoordinator.ts +65 -0
- package/src/services/DevServerBridge.ts +332 -0
- package/src/services/DeviceEventRouter.ts +238 -0
- package/src/services/DeviceStoreHydration.ts +130 -0
- package/src/services/DisplayProcessor.ts +775 -0
- package/src/services/GlassesReadiness.ts +103 -0
- package/src/services/GlassesSettingsSync.ts +134 -0
- package/src/services/GlassesStatusProjection.ts +73 -0
- package/src/services/HeadingService.ts +98 -0
- package/src/services/LocalDisplayManager.ts +703 -0
- package/src/services/LocalMiniappRuntime.ts +4213 -0
- package/src/services/LocalSttFallbackCoordinator.ts +147 -0
- package/src/services/MentraJSCrashController.ts +189 -0
- package/src/services/MentraJSCrashloopReportService.ts +66 -0
- package/src/services/MentraJSLogPipeline.ts +166 -0
- package/src/services/MentraJSRouter.ts +557 -0
- package/src/services/MentraUIRouter.ts +244 -0
- package/src/services/MicStateCoordinator.ts +94 -0
- package/src/services/MiniappEngine.ts +143 -0
- package/src/services/MiniappLauncher.ts +340 -0
- package/src/services/MiniappRunningRegistry.ts +57 -0
- package/src/services/NativeHttpResponse.ts +6 -0
- package/src/services/NavigationHandlers.ts +423 -0
- package/src/services/NavigationService.ts +731 -0
- package/src/services/NotificationsEmitter.ts +48 -0
- package/src/services/OfflineSpeechModelService.ts +168 -0
- package/src/services/OtaInstallCoordinator.ts +1205 -0
- package/src/services/OtaService.ts +83 -0
- package/src/services/OtaUpdateCheckService.ts +386 -0
- package/src/services/PairingIdentity.ts +154 -0
- package/src/services/PhoneCalendarHelpers.ts +212 -0
- package/src/services/PhoneCalendarService.ts +42 -0
- package/src/services/PhoneCameraFovCoordinator.ts +195 -0
- package/src/services/PhoneLocationService.ts +122 -0
- package/src/services/PhoneNotificationsSync.ts +44 -0
- package/src/services/PhonePhotoCoordinator.ts +409 -0
- package/src/services/PhoneStreamCoordinator.ts +777 -0
- package/src/services/PhoneVideoCoordinator.ts +189 -0
- package/src/services/STTModelManager.ts +360 -0
- package/src/services/SceneRenderer.ts +292 -0
- package/src/services/SentenceTtsPipeline.ts +106 -0
- package/src/services/StreamLifecycleController.ts +213 -0
- package/src/services/TTSModelManager.ts +466 -0
- package/src/services/TranscriptionRouting.ts +37 -0
- package/src/services/WebviewBridge.ts +50 -0
- package/src/services/asg/GalleryMediaIntegrityReportService.ts +70 -0
- package/src/services/asg/asgCameraApi.ts +1695 -0
- package/src/services/asg/cameraRollExportCoordinator.ts +627 -0
- package/src/services/asg/cameraRollExportLedger.ts +122 -0
- package/src/services/asg/galleryMediaValidation.ts +183 -0
- package/src/services/asg/galleryNotices.ts +61 -0
- package/src/services/asg/galleryPathMigration.ts +22 -0
- package/src/services/asg/gallerySettingsService.ts +68 -0
- package/src/services/asg/gallerySyncNotifications.ts +236 -0
- package/src/services/asg/gallerySyncService.ts +2269 -0
- package/src/services/asg/galleryTransferLedger.ts +312 -0
- package/src/services/asg/localNetworkTransport.ts +173 -0
- package/src/services/asg/localStorageService.ts +652 -0
- package/src/services/asg/mediaProcessingQueue.ts +518 -0
- package/src/services/asgOtaVersionUrl.ts +41 -0
- package/src/services/blobPaths.ts +86 -0
- package/src/services/cloudStreamApi.ts +154 -0
- package/src/services/gallerySyncClock.ts +39 -0
- package/src/services/glassesClockSync.ts +115 -0
- package/src/services/manifestVersionGate.ts +43 -0
- package/src/services/mentraUiShim.ts +366 -0
- package/src/services/navigation/roadNameResolver.ts +112 -0
- package/src/services/navigation/routesApiCodec.ts +69 -0
- package/src/services/otaDisplayState.ts +115 -0
- package/src/services/otaInstallPolicy.ts +106 -0
- package/src/services/otaLegacyMapping.ts +71 -0
- package/src/services/slimStreamStatus.ts +28 -0
- package/src/stores/apps.ts +614 -0
- package/src/stores/bluetoothSettingKeys.ts +36 -0
- package/src/stores/cloudClientStatus.ts +37 -0
- package/src/stores/connection.ts +69 -0
- package/src/stores/core.ts +32 -0
- package/src/stores/display.ts +121 -0
- package/src/stores/gallerySync.ts +380 -0
- package/src/stores/glasses.ts +309 -0
- package/src/stores/settings.ts +1001 -0
- package/src/types/applet.ts +112 -0
- package/src/types/asg.ts +58 -0
- package/src/types/capabilities/even-realities-g1.ts +67 -0
- package/src/types/capabilities/even-realities-g2.ts +88 -0
- package/src/types/capabilities/mentra-display.ts +75 -0
- package/src/types/capabilities/mentra-live.ts +103 -0
- package/src/types/capabilities/none.ts +76 -0
- package/src/types/capabilities/simulated-glasses.ts +76 -0
- package/src/types/capabilities/vuzix-z100.ts +64 -0
- package/src/types/enums.ts +43 -0
- package/src/types/hardware.ts +203 -0
- package/src/types/index.ts +37 -0
- package/src/utils/GlobalEventEmitter.ts +14 -0
- package/src/utils/cloudClient/RnUdpAdapter.ts +47 -0
- package/src/utils/cloudClient/cloudSecureStore.ts +28 -0
- package/src/utils/debouncedPatch.ts +28 -0
- package/src/utils/devLogging.ts +140 -0
- package/src/utils/devMiniappLaunch.ts +68 -0
- package/src/utils/diagnosticContext.ts +155 -0
- package/src/utils/display/composer/ColumnComposer.ts +285 -0
- package/src/utils/display/composer/index.ts +15 -0
- package/src/utils/display/helpers/DisplayHelpers.ts +413 -0
- package/src/utils/display/helpers/ScrollView.ts +337 -0
- package/src/utils/display/helpers/index.ts +14 -0
- package/src/utils/display/index.ts +273 -0
- package/src/utils/display/measurer/TextMeasurer.ts +346 -0
- package/src/utils/display/measurer/index.ts +21 -0
- package/src/utils/display/measurer/script-detection.ts +218 -0
- package/src/utils/display/profiles/g1.ts +236 -0
- package/src/utils/display/profiles/g2.ts +39 -0
- package/src/utils/display/profiles/index.ts +28 -0
- package/src/utils/display/profiles/nex.ts +166 -0
- package/src/utils/display/profiles/types.ts +132 -0
- package/src/utils/display/profiles/z100.ts +198 -0
- package/src/utils/display/scene/degrade.ts +80 -0
- package/src/utils/display/scene/differ.ts +128 -0
- package/src/utils/display/scene/index.ts +21 -0
- package/src/utils/display/scene/process.ts +214 -0
- package/src/utils/display/scene/store.ts +0 -0
- package/src/utils/display/scene/types.ts +0 -0
- package/src/utils/display/wrapper/TextWrapper.ts +546 -0
- package/src/utils/display/wrapper/index.ts +15 -0
- package/src/utils/display/wrapper/types.ts +102 -0
- package/src/utils/e2eMetrics.ts +30 -0
- package/src/utils/hardware/hardware.ts +166 -0
- package/src/utils/hardware/index.ts +1 -0
- package/src/utils/miniappGlobals.ts +260 -0
- package/src/utils/permissions/MediaLibraryPermissions.ts +161 -0
- package/src/utils/permissions/galleryDisplayName.ts +28 -0
- package/src/utils/storage/index.ts +2 -0
- package/src/utils/storage/storage.ts +101 -0
- package/src/utils/storage/zip.ts +13 -0
- package/src/utils/timers/index.ts +2 -0
- package/src/utils/timers/timers.ts +139 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevServerBridge.js","sourceRoot":"","sources":["../../src/services/D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iBACnB,CAAC,CACH,CAAA;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,iCAAiC;gBACjC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;gBAC7B,KAAK,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,CAAA;gBAC3B,OAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,KAAkB;QACtC,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YACzB,YAAY,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;YAClC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAA;QAC7B,CAAC;QACD,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;YAClB,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;YACD,KAAK,CAAC,EAAE,GAAG,IAAI,CAAA;QACjB,CAAC;IACH,CAAC;CACF;AAED,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;AAC7C,eAAe,eAAe,CAAA","sourcesContent":["/**\n * DevServerBridge — phone-side WebSocket connection to a `mentra-miniapp dev`\n * sidecar running on a developer's laptop.\n *\n * Multiplexed over a single WebSocket per dev miniapp:\n * laptop → phone : {type: \"reload\"} → trigger WebView.reload()\n * phone → laptop: {type: \"log\", level, args, ...} → forwarded console calls\n *\n * Lifecycle: `connect(packageName, devUrl, devPort)` is called from\n * MiniappHost.mountDev once the dev applet is mounted. `disconnect(packageName)`\n * is called from MiniappHost.unmount. Reconnect with exponential backoff on\n * unexpected close — the dev server is the developer's laptop and may bounce.\n *\n * Outgoing logs are buffered in a small ring while disconnected; flushed on\n * reconnect. This catches early-startup logs the developer would otherwise\n * miss when re-launching the dev server.\n */\n\nconst LOG_TAG = \"DEV_SERVER_BRIDGE\"\nconst PROTOCOL_VERSION = \"mentra-dev/1\"\nconst HELLO_TIMEOUT_MS = 1_000\nconst BACKOFF_MIN_MS = 1_000\nconst BACKOFF_MAX_MS = 30_000\nconst RING_BUFFER_MAX_ENTRIES = 100\nconst RING_BUFFER_MAX_BYTES = 32 * 1024\n\ntype State = \"idle\" | \"connecting\" | \"connected\" | \"disconnected\" | \"closed\"\n\ninterface BufferedLog {\n packageName: string\n level: string\n args: unknown[]\n timestamp: number\n /** \"ui\" = WebView, \"background\" = JSContext. Stamped at capture time. */\n source: \"ui\" | \"background\"\n size: number\n}\n\ninterface BridgeEntry {\n state: State\n ws: WebSocket | null\n url: string\n attempts: number\n ringBuffer: BufferedLog[]\n ringBytes: number\n reloadHandler: ((packageName: string) => void) | null\n reconnectTimer: ReturnType<typeof setTimeout> | null\n}\n\nclass DevServerBridge {\n private entries = new Map<string, BridgeEntry>()\n private globalReloadHandler: ((packageName: string) => void) | null = null\n private globalRespawnBackgroundHandler: ((packageName: string) => void) | null = null\n\n /**\n * Register a global reload handler. MiniappHost calls this once at boot. The\n * bridge invokes the handler with the offending packageName whenever a\n * reload signal is received.\n */\n public onReload(handler: (packageName: string) => void): void {\n this.globalReloadHandler = handler\n }\n\n /**\n * Register a global background-respawn handler. Fires when the dev\n * server sends `{type: \"respawn-bg\"}` — emitted on filesystem changes\n * under `src/background/`. The host (MentraJSRouter via the\n * bootstrap) should kill + respawn the JSContext to pick up the\n * change. WebView reload is separate (see `onReload`).\n */\n public onRespawnBackground(handler: ((packageName: string) => void) | null): void {\n this.globalRespawnBackgroundHandler = handler\n }\n\n /** Clear the background-respawn handler when the miniapp engine is stopped. */\n public clearRespawnBackgroundHandler(): void {\n this.globalRespawnBackgroundHandler = null\n }\n\n /** Open (or re-open) a bridge to the given dev server. */\n public connect(packageName: string, devHostUrl: string, devPort: number): void {\n const url = this.buildWsUrl(devHostUrl, devPort)\n let entry = this.entries.get(packageName)\n if (entry) {\n // Already have an entry; if the URL changed (e.g. LAN IP shifted), close\n // and rebuild.\n if (entry.url === url && (entry.state === \"connecting\" || entry.state === \"connected\")) return\n this.teardownEntry(entry)\n }\n entry = {\n state: \"idle\",\n ws: null,\n url,\n attempts: 0,\n ringBuffer: [],\n ringBytes: 0,\n reloadHandler: null,\n reconnectTimer: null,\n }\n this.entries.set(packageName, entry)\n this.openSocket(packageName, entry)\n }\n\n /** Close a bridge for good. Called from MiniappHost.unmount. */\n public disconnect(packageName: string): void {\n const entry = this.entries.get(packageName)\n if (!entry) return\n entry.state = \"closed\"\n this.teardownEntry(entry)\n this.entries.delete(packageName)\n }\n\n /**\n * Forward a `log` envelope to the connected dev sidecar. Called from\n * the JSContext side (`MentraJSRouter.__log` handler) AND the WebView\n * side (`MentraUIRouter.routeFromWebView` for `type:\"log\"` frames).\n *\n * `source` distinguishes the two halves so the CLI can prefix lines\n * `[UI]` vs `[MentraJS]`. Logs are silently dropped when no bridge\n * exists for the package (no `mentra-miniapp dev` running) and\n * buffered in the per-bridge ring while disconnected.\n */\n public forwardLog(\n packageName: string,\n level: string,\n args: unknown[],\n timestamp: number,\n source: \"ui\" | \"background\",\n ): void {\n const entry = this.entries.get(packageName)\n if (!entry) return\n const message = JSON.stringify({type: \"log\", level, args, packageName, timestamp, source})\n if (entry.state === \"connected\" && entry.ws) {\n try {\n entry.ws.send(message)\n return\n } catch {\n // Fall through to buffer.\n }\n }\n this.bufferLog(entry, {packageName, level, args, timestamp, source, size: message.length})\n }\n\n // -----------------------------------------------------------------------\n\n private buildWsUrl(devHostUrl: string, devPort: number): string {\n let host: string\n try {\n const parsed = new URL(devHostUrl)\n host = parsed.hostname\n } catch {\n // devHostUrl might already be just an IP; best-effort.\n host = devHostUrl.replace(/^https?:\\/\\//, \"\").split(\":\")[0].split(\"/\")[0]\n }\n return `ws://${host}:${devPort}/__mentra_dev`\n }\n\n private openSocket(packageName: string, entry: BridgeEntry): void {\n if (entry.state === \"closed\") return\n entry.state = \"connecting\"\n const ws = new WebSocket(entry.url)\n entry.ws = ws\n\n let helloTimer: ReturnType<typeof setTimeout> | null = null\n let helloAcked = false\n\n const teardown = (reason: string): void => {\n if (helloTimer) {\n clearTimeout(helloTimer)\n helloTimer = null\n }\n try {\n ws.close()\n } catch {\n /* ignore */\n }\n if (entry.state === \"closed\") return\n entry.state = \"disconnected\"\n entry.ws = null\n entry.attempts++\n console.log(`${LOG_TAG}: ${packageName} disconnected (${reason}); reconnect in ${this.backoffMs(entry.attempts)}ms`)\n this.scheduleReconnect(packageName, entry)\n }\n\n ws.onopen = () => {\n // Send hello; wait for hello-ack to confirm we hit the right server.\n try {\n ws.send(JSON.stringify({type: \"hello\", protocol: PROTOCOL_VERSION}))\n } catch {\n teardown(\"hello send failed\")\n return\n }\n helloTimer = setTimeout(() => {\n if (!helloAcked) {\n teardown(\"hello-ack timeout\")\n }\n }, HELLO_TIMEOUT_MS)\n }\n\n ws.onmessage = (ev) => {\n const data = typeof ev.data === \"string\" ? ev.data : null\n if (!data) return\n let parsed: {type?: string; protocol?: string} | null = null\n try {\n parsed = JSON.parse(data)\n } catch {\n return\n }\n if (!parsed) return\n\n if (parsed.type === \"hello-ack\") {\n if (parsed.protocol !== PROTOCOL_VERSION) {\n teardown(`protocol mismatch: server sent ${parsed.protocol}, expected ${PROTOCOL_VERSION}`)\n return\n }\n helloAcked = true\n if (helloTimer) {\n clearTimeout(helloTimer)\n helloTimer = null\n }\n entry.state = \"connected\"\n entry.attempts = 0\n console.log(`${LOG_TAG}: ${packageName} connected to ${entry.url}`)\n this.flushRingBuffer(packageName, entry)\n return\n }\n\n if (parsed.type === \"reload\") {\n console.log(`${LOG_TAG}: ${packageName} received reload signal`)\n this.globalReloadHandler?.(packageName)\n return\n }\n\n // Two-layer dev signal: filesystem changes under src/background/\n // trigger a full JSContext kill + respawn (not just a WebView\n // reload). The host's MentraJSRouter listens here.\n if (parsed.type === \"respawn-bg\") {\n console.log(`${LOG_TAG}: ${packageName} received respawn-bg signal`)\n this.globalRespawnBackgroundHandler?.(packageName)\n return\n }\n }\n\n ws.onerror = () => {\n // onclose follows; defer all teardown to that path so we don't double-fire.\n }\n\n ws.onclose = () => {\n teardown(helloAcked ? \"ws closed\" : \"ws closed before hello-ack\")\n }\n }\n\n private scheduleReconnect(packageName: string, entry: BridgeEntry): void {\n if (entry.state === \"closed\") return\n if (entry.reconnectTimer) clearTimeout(entry.reconnectTimer)\n const delay = this.backoffMs(entry.attempts)\n entry.reconnectTimer = setTimeout(() => {\n entry.reconnectTimer = null\n // Verify still alive and still in the bridge map.\n const current = this.entries.get(packageName)\n if (!current || current !== entry || entry.state === \"closed\") return\n this.openSocket(packageName, entry)\n }, delay)\n }\n\n private backoffMs(attempts: number): number {\n const exp = Math.min(BACKOFF_MAX_MS, BACKOFF_MIN_MS * Math.pow(2, Math.max(0, attempts - 1)))\n const jitter = exp * (0.8 + Math.random() * 0.4)\n return Math.round(jitter)\n }\n\n private bufferLog(entry: BridgeEntry, log: BufferedLog): void {\n entry.ringBuffer.push(log)\n entry.ringBytes += log.size\n while (\n entry.ringBuffer.length > RING_BUFFER_MAX_ENTRIES ||\n entry.ringBytes > RING_BUFFER_MAX_BYTES\n ) {\n const dropped = entry.ringBuffer.shift()\n if (dropped) entry.ringBytes -= dropped.size\n if (entry.ringBuffer.length === 0) {\n entry.ringBytes = 0\n break\n }\n }\n }\n\n private flushRingBuffer(packageName: string, entry: BridgeEntry): void {\n if (entry.ringBuffer.length === 0) return\n const buffered = entry.ringBuffer\n entry.ringBuffer = []\n entry.ringBytes = 0\n if (!entry.ws) return\n for (const log of buffered) {\n try {\n entry.ws.send(\n JSON.stringify({\n type: \"log\",\n level: log.level,\n args: log.args,\n packageName: log.packageName,\n timestamp: log.timestamp,\n source: log.source,\n }),\n )\n } catch {\n // Re-buffer on failure and bail.\n entry.ringBuffer.unshift(log)\n entry.ringBytes += log.size\n return\n }\n }\n }\n\n private teardownEntry(entry: BridgeEntry): void {\n if (entry.reconnectTimer) {\n clearTimeout(entry.reconnectTimer)\n entry.reconnectTimer = null\n }\n if (entry.ws) {\n try {\n entry.ws.close()\n } catch {\n /* ignore */\n }\n entry.ws = null\n }\n }\n}\n\nconst devServerBridge = new DevServerBridge()\nexport default devServerBridge\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceEventRouter.d.ts","sourceRoot":"","sources":["../../src/services/DeviceEventRouter.ts"],"names":[],"mappings":"AAmCA,wBAAgB,sBAAsB,IAAI,IAAI,CAqM7C;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device-event router — engine-owned. Subscribes to the inbound native BLE/device
|
|
3
|
+
* events and routes them into the engine runtime: device stores, the process event
|
|
4
|
+
* bus, the photo/stream coordinators, and local miniapps (via forwardEvent).
|
|
5
|
+
*
|
|
6
|
+
* Why this exists: engine owns the stores, coordinators, miniapp runtime, and facades,
|
|
7
|
+
* but it never *subscribed to the device* for most events — the host MantleManager was
|
|
8
|
+
* still the event router the whole runtime secretly depended on. So a bare OEM that
|
|
9
|
+
* imported engine + called engine.start() got a connected runtime with almost no device
|
|
10
|
+
* data flowing in (no miniapp input, dead gallery sync, starved coordinators). This
|
|
11
|
+
* service moves those inbound bridges into engine so ANY host gets them.
|
|
12
|
+
*
|
|
13
|
+
* Scope: the engine legs only. The Cloud V1 relays that used to live beside them in
|
|
14
|
+
* MantleManager (touch→cloud, the cloud-SDK stream/photo legs, etc.) were deleted with
|
|
15
|
+
* Cloud V1 app end-of-life.
|
|
16
|
+
*
|
|
17
|
+
* Started by `engine.start()`. Idempotent.
|
|
18
|
+
*/
|
|
19
|
+
import BluetoothSdk from "@mentra/bluetooth-sdk/internal";
|
|
20
|
+
import { shallow } from "zustand/shallow";
|
|
21
|
+
import localMiniappRuntime from "./LocalMiniappRuntime";
|
|
22
|
+
import localSttFallbackCoordinator from "./LocalSttFallbackCoordinator";
|
|
23
|
+
import { phonePhotoCoordinator } from "./PhonePhotoCoordinator";
|
|
24
|
+
import { phoneStreamCoordinator } from "./PhoneStreamCoordinator";
|
|
25
|
+
import { isGlassesConnected } from "./GlassesReadiness";
|
|
26
|
+
import { useGlassesStore } from "../stores/glasses";
|
|
27
|
+
import { useSettingsStore } from "../stores/settings";
|
|
28
|
+
import { useAppStatusStore } from "../stores/apps";
|
|
29
|
+
import { retirePendingSelectionOnPromotion } from "./PairingIdentity";
|
|
30
|
+
import GlobalEventEmitter from "../utils/GlobalEventEmitter";
|
|
31
|
+
import { asgCameraApi } from "./asg/asgCameraApi";
|
|
32
|
+
let subs = [];
|
|
33
|
+
export function startDeviceEventRouter() {
|
|
34
|
+
if (subs.length)
|
|
35
|
+
return;
|
|
36
|
+
// --- device state → engine stores ---
|
|
37
|
+
// Standalone WiFi status → glasses store.
|
|
38
|
+
subs.push(BluetoothSdk.addListener("wifi_status_change", (event) => {
|
|
39
|
+
const { type: _type, ...wifi } = event;
|
|
40
|
+
useGlassesStore.getState().setGlassesInfo({ wifi });
|
|
41
|
+
}));
|
|
42
|
+
// Forward glasses Wi-Fi to miniapps (session.glasses.onWifi) from the STORE — the
|
|
43
|
+
// single source of truth — so every path converges here: wifi_status_change,
|
|
44
|
+
// onGlassesStatus, and BLE disconnect. Effective connectivity requires the glasses
|
|
45
|
+
// to be connected AND on Wi-Fi, so a disconnect correctly flips `connected` false.
|
|
46
|
+
subs.push({
|
|
47
|
+
remove: useGlassesStore.subscribe((s) => {
|
|
48
|
+
const connected = isGlassesConnected(s.connection) && s.wifi.state === "connected";
|
|
49
|
+
return {
|
|
50
|
+
connected,
|
|
51
|
+
ssid: s.wifi.state === "connected" ? s.wifi.ssid : undefined,
|
|
52
|
+
localIp: s.wifi.state === "connected" ? s.wifi.localIp : undefined,
|
|
53
|
+
};
|
|
54
|
+
}, (wifi) => localMiniappRuntime.forwardEvent("glasses_wifi", wifi), { equalityFn: shallow }),
|
|
55
|
+
});
|
|
56
|
+
// Incremental battery status → glasses store + local miniapps.
|
|
57
|
+
subs.push(BluetoothSdk.addListener("battery_status", (event) => {
|
|
58
|
+
const state = useGlassesStore.getState();
|
|
59
|
+
state.setBatteryInfo(event.level, event.charging, state.caseBatteryLevel, state.caseCharging);
|
|
60
|
+
localMiniappRuntime.forwardEvent("glasses_battery_update", {
|
|
61
|
+
type: "glasses_battery_update",
|
|
62
|
+
level: event.level,
|
|
63
|
+
charging: event.charging,
|
|
64
|
+
timestamp: event.timestamp ?? Date.now(),
|
|
65
|
+
});
|
|
66
|
+
}));
|
|
67
|
+
// Hotspot status → glasses store + event bus. engine's own gallerySyncService listens
|
|
68
|
+
// on the bus for these, so without this bridge engine's gallery sync is dead.
|
|
69
|
+
subs.push(BluetoothSdk.addListener("hotspot_status_change", (event) => {
|
|
70
|
+
const enabled = event.state === "enabled";
|
|
71
|
+
const ssid = enabled ? event.ssid : "";
|
|
72
|
+
const password = enabled ? event.password : "";
|
|
73
|
+
const localIp = enabled ? event.localIp : "";
|
|
74
|
+
useGlassesStore.getState().setHotspotInfo(enabled, ssid, password, localIp);
|
|
75
|
+
// Always retarget the ASG camera client: on disable (or an event with no
|
|
76
|
+
// IP) fall back to the localhost default so later calls fail fast instead
|
|
77
|
+
// of hitting the previous network's stale glasses IP.
|
|
78
|
+
asgCameraApi.setServer(localIp || "localhost", 8089);
|
|
79
|
+
GlobalEventEmitter.emit("hotspot_status_change", { enabled, ssid, password, local_ip: localIp });
|
|
80
|
+
}));
|
|
81
|
+
subs.push(BluetoothSdk.addListener("hotspot_error", (event) => {
|
|
82
|
+
GlobalEventEmitter.emit("hotspot_error", { error_message: event.errorMessage, timestamp: event.timestamp });
|
|
83
|
+
}));
|
|
84
|
+
// Glasses gallery content counts → event bus (consumed by gallerySyncService).
|
|
85
|
+
subs.push(BluetoothSdk.addListener("gallery_status", (event) => {
|
|
86
|
+
GlobalEventEmitter.emit("gallery_status", {
|
|
87
|
+
photos: event.photos,
|
|
88
|
+
videos: event.videos,
|
|
89
|
+
total: event.total,
|
|
90
|
+
has_content: event.hasContent,
|
|
91
|
+
camera_busy: event.cameraBusy,
|
|
92
|
+
});
|
|
93
|
+
}));
|
|
94
|
+
// Hardware-originated setting changes (user changes a setting ON the glasses) → store.
|
|
95
|
+
// The inbound complement to GlassesSettingsSync (which only pushes store→device).
|
|
96
|
+
subs.push(BluetoothSdk.addListener("save_setting", async (event) => {
|
|
97
|
+
const settings = useSettingsStore.getState();
|
|
98
|
+
// Damp the relay: native re-echoes some settings unconditionally (e.g.
|
|
99
|
+
// the identity block at every handleDeviceReady) — a same-value echo
|
|
100
|
+
// must not become a store write (persistence churn + change-push noise).
|
|
101
|
+
if (settings.getSetting(event.key) !== event.value) {
|
|
102
|
+
await settings.setSetting(event.key, event.value);
|
|
103
|
+
}
|
|
104
|
+
// Two-phase identity: a promoted default retires the pending selection
|
|
105
|
+
// marker. The rule lives with PairingIdentity (a no-op for other keys).
|
|
106
|
+
await retirePendingSelectionOnPromotion(event.key, event.value);
|
|
107
|
+
}));
|
|
108
|
+
// --- coordinators (owns()-gated) ---
|
|
109
|
+
// Phone-owned photo errors settle the in-flight long-poll fast (vs. timeout).
|
|
110
|
+
// Non-owned photo responses used to forward to the Cloud V1 photo pipeline via
|
|
111
|
+
// restComms; that relay was removed with Cloud V1 app end-of-life, so they drop.
|
|
112
|
+
// Wire v2 sends a short 4-hex BLE requestId; the coordinator maps it back to
|
|
113
|
+
// the cloud requestId (resolveCloudRequestId) before ownership checks.
|
|
114
|
+
subs.push(BluetoothSdk.addListener("photo_response", (event) => {
|
|
115
|
+
const cloudRequestId = event.requestId ? phonePhotoCoordinator.resolveCloudRequestId(event.requestId) : "";
|
|
116
|
+
if (cloudRequestId && phonePhotoCoordinator.owns(cloudRequestId)) {
|
|
117
|
+
if (event.state === "error") {
|
|
118
|
+
phonePhotoCoordinator.handlePhotoError(event.requestId ?? cloudRequestId, event.errorCode ?? "GLASSES_ERROR", event.errorMessage ?? "Glasses reported an error");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
// Phone-owned stream status / keep-alive → the stream coordinator. The Cloud V1 relay
|
|
123
|
+
// for non-owned streams was removed with Cloud V1 app end-of-life.
|
|
124
|
+
subs.push(BluetoothSdk.addListener("stream_status", (event) => {
|
|
125
|
+
if (event.streamId && phoneStreamCoordinator.owns(event.streamId)) {
|
|
126
|
+
phoneStreamCoordinator.handleGlassesStatus(event);
|
|
127
|
+
}
|
|
128
|
+
}));
|
|
129
|
+
subs.push(BluetoothSdk.addListener("keep_alive_ack", (event) => {
|
|
130
|
+
if (event.streamId && phoneStreamCoordinator.owns(event.streamId)) {
|
|
131
|
+
phoneStreamCoordinator.handleKeepAliveAck(event);
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
// --- device input → local miniapps (forwardEvent is subscriber-gated; a no-op when
|
|
135
|
+
// no miniapp listens). The v1 SocketComms cloud legs for these were removed with
|
|
136
|
+
// the Cloud V1 ripout. ---
|
|
137
|
+
subs.push(BluetoothSdk.addListener("button_press", (event) => {
|
|
138
|
+
localMiniappRuntime.forwardEvent("button_press", event);
|
|
139
|
+
}));
|
|
140
|
+
subs.push(BluetoothSdk.addListener("touch_event", (event) => {
|
|
141
|
+
localMiniappRuntime.forwardEvent("touch_event", event);
|
|
142
|
+
}));
|
|
143
|
+
// G2 IMU accelerometer — payload already matches the miniapp AccelData shape.
|
|
144
|
+
subs.push(BluetoothSdk.addListener("accel_event", (event) => {
|
|
145
|
+
localMiniappRuntime.forwardEvent("accel_event", {
|
|
146
|
+
x: event.x,
|
|
147
|
+
y: event.y,
|
|
148
|
+
z: event.z,
|
|
149
|
+
timestamp: typeof event.timestamp === "number" ? event.timestamp : Date.now(),
|
|
150
|
+
});
|
|
151
|
+
}));
|
|
152
|
+
// Head position — translate native {up:boolean} → SDK {position:"up"|"down"}.
|
|
153
|
+
subs.push(BluetoothSdk.addListener("head_up", (event) => {
|
|
154
|
+
localMiniappRuntime.forwardEvent("head_up", { position: event.up ? "up" : "down", timestamp: Date.now() });
|
|
155
|
+
}));
|
|
156
|
+
// On-device STT transcripts → local miniapps only while the local engine is
|
|
157
|
+
// active (cloud fallback or an explicit forceLocal subscription). The runtime
|
|
158
|
+
// filters mixed local/cloud delivery per miniapp to avoid double-delivery.
|
|
159
|
+
// forwardEvent is subscriber-gated — a no-op when no miniapp listens.
|
|
160
|
+
// (Was MantleManager.handle_local_transcription; its offline-captions display branch
|
|
161
|
+
// went away with the pseudo captions renderer.)
|
|
162
|
+
subs.push(BluetoothSdk.addListener("local_transcription", (event) => {
|
|
163
|
+
if (!localSttFallbackCoordinator.isActive())
|
|
164
|
+
return;
|
|
165
|
+
const lang = event.transcribeLanguage ?? localSttFallbackCoordinator.getActiveLanguage() ?? "en-US";
|
|
166
|
+
localMiniappRuntime.forwardEvent(`transcription:${lang}`, event, "local");
|
|
167
|
+
}));
|
|
168
|
+
// --- glasses swipe-menu app launcher (G2) ---
|
|
169
|
+
subs.push(BluetoothSdk.addListener("miniapp_selected", (event) => {
|
|
170
|
+
const packageName = event.packageName;
|
|
171
|
+
if (!packageName)
|
|
172
|
+
return;
|
|
173
|
+
const app = useAppStatusStore.getState().apps.find((a) => a.packageName === packageName);
|
|
174
|
+
if (!app)
|
|
175
|
+
return;
|
|
176
|
+
// Toggle: stop if running, else start.
|
|
177
|
+
if (app.running) {
|
|
178
|
+
useAppStatusStore.getState().stop(packageName);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
useAppStatusStore.getState().start(app, { skipNavigation: true });
|
|
182
|
+
}
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
export function stopDeviceEventRouter() {
|
|
186
|
+
for (const sub of subs)
|
|
187
|
+
sub.remove();
|
|
188
|
+
subs = [];
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=DeviceEventRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceEventRouter.js","sourceRoot":"","sources":["../../src/services/DeviceEventRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,YAAY,MAAM,gC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CAAA;QAC/C,IAAI,CAAC,WAAW;YAAE,OAAM;QACxB,MAAM,GAAG,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,WAAW,CAAC,CAAA;QACxF,IAAI,CAAC,GAAG;YAAE,OAAM;QAChB,uCAAuC;QACvC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAChD,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAA;QACjE,CAAC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,GAAG,CAAC,MAAM,EAAE,CAAA;IACpC,IAAI,GAAG,EAAE,CAAA;AACX,CAAC","sourcesContent":["/**\n * Device-event router — engine-owned. Subscribes to the inbound native BLE/device\n * events and routes them into the engine runtime: device stores, the process event\n * bus, the photo/stream coordinators, and local miniapps (via forwardEvent).\n *\n * Why this exists: engine owns the stores, coordinators, miniapp runtime, and facades,\n * but it never *subscribed to the device* for most events — the host MantleManager was\n * still the event router the whole runtime secretly depended on. So a bare OEM that\n * imported engine + called engine.start() got a connected runtime with almost no device\n * data flowing in (no miniapp input, dead gallery sync, starved coordinators). This\n * service moves those inbound bridges into engine so ANY host gets them.\n *\n * Scope: the engine legs only. The Cloud V1 relays that used to live beside them in\n * MantleManager (touch→cloud, the cloud-SDK stream/photo legs, etc.) were deleted with\n * Cloud V1 app end-of-life.\n *\n * Started by `engine.start()`. Idempotent.\n */\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport {shallow} from \"zustand/shallow\"\n\nimport localMiniappRuntime from \"./LocalMiniappRuntime\"\nimport localSttFallbackCoordinator from \"./LocalSttFallbackCoordinator\"\nimport {phonePhotoCoordinator} from \"./PhonePhotoCoordinator\"\nimport {phoneStreamCoordinator} from \"./PhoneStreamCoordinator\"\nimport {isGlassesConnected} from \"./GlassesReadiness\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {useSettingsStore} from \"../stores/settings\"\nimport {useAppStatusStore} from \"../stores/apps\"\nimport {retirePendingSelectionOnPromotion} from \"./PairingIdentity\"\nimport GlobalEventEmitter from \"../utils/GlobalEventEmitter\"\nimport {asgCameraApi} from \"./asg/asgCameraApi\"\n\nlet subs: Array<{remove: () => void}> = []\n\nexport function startDeviceEventRouter(): void {\n if (subs.length) return\n\n // --- device state → engine stores ---\n\n // Standalone WiFi status → glasses store.\n subs.push(\n BluetoothSdk.addListener(\"wifi_status_change\", (event) => {\n const {type: _type, ...wifi} = event\n useGlassesStore.getState().setGlassesInfo({wifi})\n }),\n )\n\n // Forward glasses Wi-Fi to miniapps (session.glasses.onWifi) from the STORE — the\n // single source of truth — so every path converges here: wifi_status_change,\n // onGlassesStatus, and BLE disconnect. Effective connectivity requires the glasses\n // to be connected AND on Wi-Fi, so a disconnect correctly flips `connected` false.\n subs.push({\n remove: useGlassesStore.subscribe(\n (s) => {\n const connected = isGlassesConnected(s.connection) && s.wifi.state === \"connected\"\n return {\n connected,\n ssid: s.wifi.state === \"connected\" ? s.wifi.ssid : undefined,\n localIp: s.wifi.state === \"connected\" ? s.wifi.localIp : undefined,\n }\n },\n (wifi) => localMiniappRuntime.forwardEvent(\"glasses_wifi\", wifi),\n {equalityFn: shallow},\n ),\n })\n\n // Incremental battery status → glasses store + local miniapps.\n subs.push(\n BluetoothSdk.addListener(\"battery_status\", (event) => {\n const state = useGlassesStore.getState()\n state.setBatteryInfo(event.level, event.charging, state.caseBatteryLevel, state.caseCharging)\n localMiniappRuntime.forwardEvent(\"glasses_battery_update\", {\n type: \"glasses_battery_update\",\n level: event.level,\n charging: event.charging,\n timestamp: event.timestamp ?? Date.now(),\n })\n }),\n )\n\n // Hotspot status → glasses store + event bus. engine's own gallerySyncService listens\n // on the bus for these, so without this bridge engine's gallery sync is dead.\n subs.push(\n BluetoothSdk.addListener(\"hotspot_status_change\", (event) => {\n const enabled = event.state === \"enabled\"\n const ssid = enabled ? event.ssid : \"\"\n const password = enabled ? event.password : \"\"\n const localIp = enabled ? event.localIp : \"\"\n useGlassesStore.getState().setHotspotInfo(enabled, ssid, password, localIp)\n // Always retarget the ASG camera client: on disable (or an event with no\n // IP) fall back to the localhost default so later calls fail fast instead\n // of hitting the previous network's stale glasses IP.\n asgCameraApi.setServer(localIp || \"localhost\", 8089)\n GlobalEventEmitter.emit(\"hotspot_status_change\", {enabled, ssid, password, local_ip: localIp})\n }),\n )\n subs.push(\n BluetoothSdk.addListener(\"hotspot_error\", (event) => {\n GlobalEventEmitter.emit(\"hotspot_error\", {error_message: event.errorMessage, timestamp: event.timestamp})\n }),\n )\n\n // Glasses gallery content counts → event bus (consumed by gallerySyncService).\n subs.push(\n BluetoothSdk.addListener(\"gallery_status\", (event) => {\n GlobalEventEmitter.emit(\"gallery_status\", {\n photos: event.photos,\n videos: event.videos,\n total: event.total,\n has_content: event.hasContent,\n camera_busy: event.cameraBusy,\n })\n }),\n )\n\n // Hardware-originated setting changes (user changes a setting ON the glasses) → store.\n // The inbound complement to GlassesSettingsSync (which only pushes store→device).\n subs.push(\n BluetoothSdk.addListener(\"save_setting\", async (event) => {\n const settings = useSettingsStore.getState()\n // Damp the relay: native re-echoes some settings unconditionally (e.g.\n // the identity block at every handleDeviceReady) — a same-value echo\n // must not become a store write (persistence churn + change-push noise).\n if (settings.getSetting(event.key) !== event.value) {\n await settings.setSetting(event.key, event.value)\n }\n // Two-phase identity: a promoted default retires the pending selection\n // marker. The rule lives with PairingIdentity (a no-op for other keys).\n await retirePendingSelectionOnPromotion(event.key, event.value)\n }),\n )\n\n // --- coordinators (owns()-gated) ---\n\n // Phone-owned photo errors settle the in-flight long-poll fast (vs. timeout).\n // Non-owned photo responses used to forward to the Cloud V1 photo pipeline via\n // restComms; that relay was removed with Cloud V1 app end-of-life, so they drop.\n // Wire v2 sends a short 4-hex BLE requestId; the coordinator maps it back to\n // the cloud requestId (resolveCloudRequestId) before ownership checks.\n subs.push(\n BluetoothSdk.addListener(\"photo_response\", (event) => {\n const cloudRequestId = event.requestId ? phonePhotoCoordinator.resolveCloudRequestId(event.requestId) : \"\"\n if (cloudRequestId && phonePhotoCoordinator.owns(cloudRequestId)) {\n if (event.state === \"error\") {\n phonePhotoCoordinator.handlePhotoError(\n event.requestId ?? cloudRequestId,\n event.errorCode ?? \"GLASSES_ERROR\",\n event.errorMessage ?? \"Glasses reported an error\",\n )\n }\n }\n }),\n )\n\n // Phone-owned stream status / keep-alive → the stream coordinator. The Cloud V1 relay\n // for non-owned streams was removed with Cloud V1 app end-of-life.\n subs.push(\n BluetoothSdk.addListener(\"stream_status\", (event) => {\n if (event.streamId && phoneStreamCoordinator.owns(event.streamId)) {\n phoneStreamCoordinator.handleGlassesStatus(event)\n }\n }),\n )\n subs.push(\n BluetoothSdk.addListener(\"keep_alive_ack\", (event) => {\n if (event.streamId && phoneStreamCoordinator.owns(event.streamId)) {\n phoneStreamCoordinator.handleKeepAliveAck(event)\n }\n }),\n )\n\n // --- device input → local miniapps (forwardEvent is subscriber-gated; a no-op when\n // no miniapp listens). The v1 SocketComms cloud legs for these were removed with\n // the Cloud V1 ripout. ---\n\n subs.push(\n BluetoothSdk.addListener(\"button_press\", (event) => {\n localMiniappRuntime.forwardEvent(\"button_press\", event)\n }),\n )\n subs.push(\n BluetoothSdk.addListener(\"touch_event\", (event) => {\n localMiniappRuntime.forwardEvent(\"touch_event\", event)\n }),\n )\n // G2 IMU accelerometer — payload already matches the miniapp AccelData shape.\n subs.push(\n BluetoothSdk.addListener(\"accel_event\", (event) => {\n localMiniappRuntime.forwardEvent(\"accel_event\", {\n x: event.x,\n y: event.y,\n z: event.z,\n timestamp: typeof event.timestamp === \"number\" ? event.timestamp : Date.now(),\n })\n }),\n )\n // Head position — translate native {up:boolean} → SDK {position:\"up\"|\"down\"}.\n subs.push(\n BluetoothSdk.addListener(\"head_up\", (event) => {\n localMiniappRuntime.forwardEvent(\"head_up\", {position: event.up ? \"up\" : \"down\", timestamp: Date.now()})\n }),\n )\n // On-device STT transcripts → local miniapps only while the local engine is\n // active (cloud fallback or an explicit forceLocal subscription). The runtime\n // filters mixed local/cloud delivery per miniapp to avoid double-delivery.\n // forwardEvent is subscriber-gated — a no-op when no miniapp listens.\n // (Was MantleManager.handle_local_transcription; its offline-captions display branch\n // went away with the pseudo captions renderer.)\n subs.push(\n BluetoothSdk.addListener(\"local_transcription\", (event) => {\n if (!localSttFallbackCoordinator.isActive()) return\n const lang = event.transcribeLanguage ?? localSttFallbackCoordinator.getActiveLanguage() ?? \"en-US\"\n localMiniappRuntime.forwardEvent(`transcription:${lang}`, event, \"local\")\n }),\n )\n\n // --- glasses swipe-menu app launcher (G2) ---\n subs.push(\n BluetoothSdk.addListener(\"miniapp_selected\", (event) => {\n const packageName = event.packageName as string\n if (!packageName) return\n const app = useAppStatusStore.getState().apps.find((a) => a.packageName === packageName)\n if (!app) return\n // Toggle: stop if running, else start.\n if (app.running) {\n useAppStatusStore.getState().stop(packageName)\n } else {\n useAppStatusStore.getState().start(app, {skipNavigation: true})\n }\n }),\n )\n}\n\nexport function stopDeviceEventRouter(): void {\n for (const sub of subs) sub.remove()\n subs = []\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seed the native DeviceStore from the persisted settings. Single-flight: the
|
|
3
|
+
* first caller runs it, everyone else awaits the same promise. On failure the
|
|
4
|
+
* current awaiters see the rejection (and fail open — the pre-guard behavior,
|
|
5
|
+
* where the connect calls' own error handling was the last line of defense),
|
|
6
|
+
* and the memo clears so a LATER read can retry and heal.
|
|
7
|
+
*/
|
|
8
|
+
export declare function hydrateDeviceStore(): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Test-only: clear the hydration memo so each test starts from an unhydrated
|
|
11
|
+
* store instead of inheriting whichever hydration a previous test ran.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resetDeviceStoreHydrationForTests(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the SDK holds an actual default DEVICE to reconnect to — the
|
|
16
|
+
* hydration-aware two-state read. Distinct from the `default_wearable`
|
|
17
|
+
* setting (a model string that pending/orphaned states can hold without any
|
|
18
|
+
* paired device): `connectDefault()` throws without a device.
|
|
19
|
+
* Rejects if hydration failed; callers fail open.
|
|
20
|
+
*/
|
|
21
|
+
export declare function hasDefaultDevice(): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Boot repair for the orphaned-identity population: a persisted
|
|
24
|
+
* `default_wearable` whose native default device does not exist after a
|
|
25
|
+
* completed hydration. Two-phase writes stop NEW orphans from forming
|
|
26
|
+
* (identity is only promoted at pairing success); this demotes the ones
|
|
27
|
+
* already in the field — selection-time writes abandoned before pairing
|
|
28
|
+
* succeeded, and identity resurrected from the server before it stopped
|
|
29
|
+
* syncing — down to `pending_wearable`, which the host renders as a
|
|
30
|
+
* finish-pairing card instead of a connect button that would throw
|
|
31
|
+
* "Set a default glasses device before calling connectDefault".
|
|
32
|
+
*
|
|
33
|
+
* Runs after hydration on every start; converges because a demoted default
|
|
34
|
+
* can't re-trip the condition. Skips while the link layer is busy or
|
|
35
|
+
* connected (an in-flight pairing owns the identity right now).
|
|
36
|
+
*/
|
|
37
|
+
export declare function demoteOrphanedDefaultWearable(): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=DeviceStoreHydration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceStoreHydration.d.ts","sourceRoot":"","sources":["../../src/services/DeviceStoreHydration.ts"],"names":[],"mappings":"AAgCA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAwBlD;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,IAAI,IAAI,CAExD;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAGzD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC,CA6BnE"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeviceStoreHydration — the cold-start contract for the native DeviceStore.
|
|
3
|
+
*
|
|
4
|
+
* The Bluetooth SDK's DeviceStore is in-memory on BOTH platforms: every key
|
|
5
|
+
* (including the pairing identity `default_wearable` / `device_name` /
|
|
6
|
+
* `device_address`) initializes to "" at process start and only becomes real
|
|
7
|
+
* once JS pushes the persisted settings over `updateBluetoothSettings`. Until
|
|
8
|
+
* that seed lands, `BluetoothSdk.getDefaultDevice()` returns null for
|
|
9
|
+
* genuinely-paired users — the false "absent" that made the first
|
|
10
|
+
* hasDefaultDevice guard misfire at cold start (see the revert of the
|
|
11
|
+
* hasDefaultDevice pairing-route guards).
|
|
12
|
+
*
|
|
13
|
+
* This service makes that seed an explicit, awaited initialization step:
|
|
14
|
+
* 1. load the persisted settings store (idempotent),
|
|
15
|
+
* 2. push the full Bluetooth settings set (identity included) to native.
|
|
16
|
+
* `engine.start()` awaits it, so every post-start `getDefaultDevice()` read is
|
|
17
|
+
* a trustworthy two-state answer. `hasDefaultDevice()` also awaits it
|
|
18
|
+
* internally (belt-and-suspenders for reads that race start()).
|
|
19
|
+
*
|
|
20
|
+
* Failure surfaces as a REJECTION — never a false "absent". Callers guarding
|
|
21
|
+
* destructive or routing decisions must fail open (treat as "has a device"),
|
|
22
|
+
* matching the foreground-reconnect pattern.
|
|
23
|
+
*/
|
|
24
|
+
import BluetoothSdk from "@mentra/bluetooth-sdk/internal";
|
|
25
|
+
import { useSettingsStore, SETTINGS } from "../stores/settings";
|
|
26
|
+
import { useGlassesStore } from "../stores/glasses";
|
|
27
|
+
import { pushAllBluetoothSettings } from "./GlassesSettingsSync";
|
|
28
|
+
import { demoteDefaultToPending } from "./PairingIdentity";
|
|
29
|
+
import { DeviceTypes } from "../types";
|
|
30
|
+
let hydrationPromise = null;
|
|
31
|
+
/**
|
|
32
|
+
* Seed the native DeviceStore from the persisted settings. Single-flight: the
|
|
33
|
+
* first caller runs it, everyone else awaits the same promise. On failure the
|
|
34
|
+
* current awaiters see the rejection (and fail open — the pre-guard behavior,
|
|
35
|
+
* where the connect calls' own error handling was the last line of defense),
|
|
36
|
+
* and the memo clears so a LATER read can retry and heal.
|
|
37
|
+
*/
|
|
38
|
+
export function hydrateDeviceStore() {
|
|
39
|
+
if (!hydrationPromise) {
|
|
40
|
+
const startedAt = Date.now();
|
|
41
|
+
hydrationPromise = (async () => {
|
|
42
|
+
const loadResult = await useSettingsStore.getState().loadAllSettings();
|
|
43
|
+
if (loadResult.is_error()) {
|
|
44
|
+
throw new Error(`DeviceStoreHydration: settings load failed: ${loadResult.error}`);
|
|
45
|
+
}
|
|
46
|
+
await pushAllBluetoothSettings();
|
|
47
|
+
const settings = useSettingsStore.getState();
|
|
48
|
+
const model = settings.getSetting(SETTINGS.default_wearable.key);
|
|
49
|
+
const hasName = !!settings.getSetting(SETTINGS.device_name.key);
|
|
50
|
+
// Cold-start timing evidence: this line must appear BEFORE any
|
|
51
|
+
// RECONNECT/guard log for the hydration contract to hold on device.
|
|
52
|
+
console.log(`DeviceStoreHydration: native seed complete in ${Date.now() - startedAt}ms ` +
|
|
53
|
+
`(default_wearable=${model || "<none>"}, device_name present=${hasName})`);
|
|
54
|
+
})().catch((error) => {
|
|
55
|
+
hydrationPromise = null;
|
|
56
|
+
throw error;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return hydrationPromise;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Test-only: clear the hydration memo so each test starts from an unhydrated
|
|
63
|
+
* store instead of inheriting whichever hydration a previous test ran.
|
|
64
|
+
*/
|
|
65
|
+
export function resetDeviceStoreHydrationForTests() {
|
|
66
|
+
hydrationPromise = null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Whether the SDK holds an actual default DEVICE to reconnect to — the
|
|
70
|
+
* hydration-aware two-state read. Distinct from the `default_wearable`
|
|
71
|
+
* setting (a model string that pending/orphaned states can hold without any
|
|
72
|
+
* paired device): `connectDefault()` throws without a device.
|
|
73
|
+
* Rejects if hydration failed; callers fail open.
|
|
74
|
+
*/
|
|
75
|
+
export async function hasDefaultDevice() {
|
|
76
|
+
await hydrateDeviceStore();
|
|
77
|
+
return !!(await BluetoothSdk.getDefaultDevice());
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Boot repair for the orphaned-identity population: a persisted
|
|
81
|
+
* `default_wearable` whose native default device does not exist after a
|
|
82
|
+
* completed hydration. Two-phase writes stop NEW orphans from forming
|
|
83
|
+
* (identity is only promoted at pairing success); this demotes the ones
|
|
84
|
+
* already in the field — selection-time writes abandoned before pairing
|
|
85
|
+
* succeeded, and identity resurrected from the server before it stopped
|
|
86
|
+
* syncing — down to `pending_wearable`, which the host renders as a
|
|
87
|
+
* finish-pairing card instead of a connect button that would throw
|
|
88
|
+
* "Set a default glasses device before calling connectDefault".
|
|
89
|
+
*
|
|
90
|
+
* Runs after hydration on every start; converges because a demoted default
|
|
91
|
+
* can't re-trip the condition. Skips while the link layer is busy or
|
|
92
|
+
* connected (an in-flight pairing owns the identity right now).
|
|
93
|
+
*/
|
|
94
|
+
export async function demoteOrphanedDefaultWearable() {
|
|
95
|
+
// Never judge "native default absent" against an unseeded store: a valid
|
|
96
|
+
// pairing identity would read as an orphan and be demoted. Awaiting the
|
|
97
|
+
// (memoized) hydration makes the check safe regardless of call ordering;
|
|
98
|
+
// a failed hydration rejects here instead of demoting blind.
|
|
99
|
+
await hydrateDeviceStore();
|
|
100
|
+
const settings = useSettingsStore.getState();
|
|
101
|
+
const model = settings.getSetting(SETTINGS.default_wearable.key);
|
|
102
|
+
if (!model)
|
|
103
|
+
return;
|
|
104
|
+
// The simulated device is its own identity (name mirrors the model); it
|
|
105
|
+
// reconstructs a native default from settings alone and never orphans.
|
|
106
|
+
if (model.includes(DeviceTypes.SIMULATED))
|
|
107
|
+
return;
|
|
108
|
+
// "disconnected" is the only idle state — anything else (scanning /
|
|
109
|
+
// connecting / bonding / connected) means a pairing or link owns the
|
|
110
|
+
// identity right now.
|
|
111
|
+
if (useGlassesStore.getState().connection.state !== "disconnected")
|
|
112
|
+
return;
|
|
113
|
+
if (await BluetoothSdk.getDefaultDevice())
|
|
114
|
+
return;
|
|
115
|
+
console.log(`DeviceStoreHydration: demoting orphaned default_wearable "${model}" to pending_wearable`);
|
|
116
|
+
// The identity write set (latest-selection-wins backfill + identity-triplet
|
|
117
|
+
// clear) lives with PairingIdentity, the single writer of the JS-side
|
|
118
|
+
// identity keys; this boot repair owns only the guards above.
|
|
119
|
+
await demoteDefaultToPending(model);
|
|
120
|
+
// The hydration seed already landed the pre-demotion values in the native
|
|
121
|
+
// store; re-push so native mirrors the demoted identity too.
|
|
122
|
+
await pushAllBluetoothSettings();
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=DeviceStoreHydration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceStoreHydration.js","sourceRoot":"","sources":["../../src/services/DeviceStoreHydration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,YAAY,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,wBAAwB,EAAC,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAA;AAE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AAU,gBAAgB;IACpC,MAAM,kBAAkB,EAAE,CAAA;IAC1B,OAAO,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,gBAAgB,EAAE,CAAC,CAAA;AAClD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B;IACjD,yEAAyE;IACzE,wEAAwE;IACxE,yEAAyE;IACzE,6DAA6D;IAC7D,MAAM,kBAAkB,EAAE,CAAA;IAE1B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAA;IAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAuB,CAAA;IACtF,IAAI,CAAC,KAAK;QAAE,OAAM;IAClB,wEAAwE;IACxE,uEAAuE;IACvE,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC;QAAE,OAAM;IAEjD,oEAAoE;IACpE,qEAAqE;IACrE,sBAAsB;IACtB,IAAI,eAAe,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,KAAK,KAAK,cAAc;QAAE,OAAM;IAE1E,IAAI,MAAM,YAAY,CAAC,gBAAgB,EAAE;QAAE,OAAM;IAEjD,OAAO,CAAC,GAAG,CAAC,6DAA6D,KAAK,uBAAuB,CAAC,CAAA;IACtG,4EAA4E;IAC5E,sEAAsE;IACtE,8DAA8D;IAC9D,MAAM,sBAAsB,CAAC,KAAK,CAAC,CAAA;IACnC,0EAA0E;IAC1E,6DAA6D;IAC7D,MAAM,wBAAwB,EAAE,CAAA;AAClC,CAAC","sourcesContent":["/**\n * DeviceStoreHydration — the cold-start contract for the native DeviceStore.\n *\n * The Bluetooth SDK's DeviceStore is in-memory on BOTH platforms: every key\n * (including the pairing identity `default_wearable` / `device_name` /\n * `device_address`) initializes to \"\" at process start and only becomes real\n * once JS pushes the persisted settings over `updateBluetoothSettings`. Until\n * that seed lands, `BluetoothSdk.getDefaultDevice()` returns null for\n * genuinely-paired users — the false \"absent\" that made the first\n * hasDefaultDevice guard misfire at cold start (see the revert of the\n * hasDefaultDevice pairing-route guards).\n *\n * This service makes that seed an explicit, awaited initialization step:\n * 1. load the persisted settings store (idempotent),\n * 2. push the full Bluetooth settings set (identity included) to native.\n * `engine.start()` awaits it, so every post-start `getDefaultDevice()` read is\n * a trustworthy two-state answer. `hasDefaultDevice()` also awaits it\n * internally (belt-and-suspenders for reads that race start()).\n *\n * Failure surfaces as a REJECTION — never a false \"absent\". Callers guarding\n * destructive or routing decisions must fail open (treat as \"has a device\"),\n * matching the foreground-reconnect pattern.\n */\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {pushAllBluetoothSettings} from \"./GlassesSettingsSync\"\nimport {demoteDefaultToPending} from \"./PairingIdentity\"\nimport {DeviceTypes} from \"../types\"\n\nlet hydrationPromise: Promise<void> | null = null\n\n/**\n * Seed the native DeviceStore from the persisted settings. Single-flight: the\n * first caller runs it, everyone else awaits the same promise. On failure the\n * current awaiters see the rejection (and fail open — the pre-guard behavior,\n * where the connect calls' own error handling was the last line of defense),\n * and the memo clears so a LATER read can retry and heal.\n */\nexport function hydrateDeviceStore(): Promise<void> {\n if (!hydrationPromise) {\n const startedAt = Date.now()\n hydrationPromise = (async () => {\n const loadResult = await useSettingsStore.getState().loadAllSettings()\n if (loadResult.is_error()) {\n throw new Error(`DeviceStoreHydration: settings load failed: ${loadResult.error}`)\n }\n await pushAllBluetoothSettings()\n const settings = useSettingsStore.getState()\n const model = settings.getSetting(SETTINGS.default_wearable.key)\n const hasName = !!settings.getSetting(SETTINGS.device_name.key)\n // Cold-start timing evidence: this line must appear BEFORE any\n // RECONNECT/guard log for the hydration contract to hold on device.\n console.log(\n `DeviceStoreHydration: native seed complete in ${Date.now() - startedAt}ms ` +\n `(default_wearable=${model || \"<none>\"}, device_name present=${hasName})`,\n )\n })().catch((error) => {\n hydrationPromise = null\n throw error\n })\n }\n return hydrationPromise\n}\n\n/**\n * Test-only: clear the hydration memo so each test starts from an unhydrated\n * store instead of inheriting whichever hydration a previous test ran.\n */\nexport function resetDeviceStoreHydrationForTests(): void {\n hydrationPromise = null\n}\n\n/**\n * Whether the SDK holds an actual default DEVICE to reconnect to — the\n * hydration-aware two-state read. Distinct from the `default_wearable`\n * setting (a model string that pending/orphaned states can hold without any\n * paired device): `connectDefault()` throws without a device.\n * Rejects if hydration failed; callers fail open.\n */\nexport async function hasDefaultDevice(): Promise<boolean> {\n await hydrateDeviceStore()\n return !!(await BluetoothSdk.getDefaultDevice())\n}\n\n/**\n * Boot repair for the orphaned-identity population: a persisted\n * `default_wearable` whose native default device does not exist after a\n * completed hydration. Two-phase writes stop NEW orphans from forming\n * (identity is only promoted at pairing success); this demotes the ones\n * already in the field — selection-time writes abandoned before pairing\n * succeeded, and identity resurrected from the server before it stopped\n * syncing — down to `pending_wearable`, which the host renders as a\n * finish-pairing card instead of a connect button that would throw\n * \"Set a default glasses device before calling connectDefault\".\n *\n * Runs after hydration on every start; converges because a demoted default\n * can't re-trip the condition. Skips while the link layer is busy or\n * connected (an in-flight pairing owns the identity right now).\n */\nexport async function demoteOrphanedDefaultWearable(): Promise<void> {\n // Never judge \"native default absent\" against an unseeded store: a valid\n // pairing identity would read as an orphan and be demoted. Awaiting the\n // (memoized) hydration makes the check safe regardless of call ordering;\n // a failed hydration rejects here instead of demoting blind.\n await hydrateDeviceStore()\n\n const settings = useSettingsStore.getState()\n const model = settings.getSetting(SETTINGS.default_wearable.key) as string | undefined\n if (!model) return\n // The simulated device is its own identity (name mirrors the model); it\n // reconstructs a native default from settings alone and never orphans.\n if (model.includes(DeviceTypes.SIMULATED)) return\n\n // \"disconnected\" is the only idle state — anything else (scanning /\n // connecting / bonding / connected) means a pairing or link owns the\n // identity right now.\n if (useGlassesStore.getState().connection.state !== \"disconnected\") return\n\n if (await BluetoothSdk.getDefaultDevice()) return\n\n console.log(`DeviceStoreHydration: demoting orphaned default_wearable \"${model}\" to pending_wearable`)\n // The identity write set (latest-selection-wins backfill + identity-triplet\n // clear) lives with PairingIdentity, the single writer of the JS-side\n // identity keys; this boot repair owns only the guards above.\n await demoteDefaultToPending(model)\n // The hydration seed already landed the pre-demotion values in the native\n // store; re-push so native mirrors the demoted identity too.\n await pushAllBluetoothSettings()\n}\n"]}
|