@mentra/engine 0.1.0-dev.0 → 3.1.0-dev.4
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 +55 -18
- package/build/bluetooth-sdk/debug.d.ts +2 -0
- package/build/bluetooth-sdk/debug.d.ts.map +1 -0
- package/build/bluetooth-sdk/debug.js +2 -0
- package/build/bluetooth-sdk/debug.js.map +1 -0
- package/build/bluetooth-sdk/index.d.ts +3 -0
- package/build/bluetooth-sdk/index.d.ts.map +1 -0
- package/build/bluetooth-sdk/index.js +3 -0
- package/build/bluetooth-sdk/index.js.map +1 -0
- package/build/bluetooth-sdk/photo-receiver.d.ts +3 -0
- package/build/bluetooth-sdk/photo-receiver.d.ts.map +1 -0
- package/build/bluetooth-sdk/photo-receiver.js +3 -0
- package/build/bluetooth-sdk/photo-receiver.js.map +1 -0
- package/build/bluetooth-sdk/react.d.ts +2 -0
- package/build/bluetooth-sdk/react.d.ts.map +1 -0
- package/build/bluetooth-sdk/react.js +2 -0
- package/build/bluetooth-sdk/react.js.map +1 -0
- package/build/bluetooth-sdk/types.d.ts +2 -0
- package/build/bluetooth-sdk/types.d.ts.map +1 -0
- package/build/bluetooth-sdk/types.js +2 -0
- package/build/bluetooth-sdk/types.js.map +1 -0
- package/build/engine.d.ts +24 -16
- package/build/engine.d.ts.map +1 -1
- package/build/engine.js +9 -4
- package/build/engine.js.map +1 -1
- package/build/facades/dev.d.ts +3 -2
- package/build/facades/dev.d.ts.map +1 -1
- package/build/facades/dev.js +18 -12
- package/build/facades/dev.js.map +1 -1
- package/build/facades/display.d.ts +1 -1
- package/build/facades/display.d.ts.map +1 -1
- package/build/facades/display.js +1 -1
- package/build/facades/display.js.map +1 -1
- package/build/facades/gallery.js +1 -1
- package/build/facades/gallery.js.map +1 -1
- package/build/facades/glasses.d.ts +4 -13
- package/build/facades/glasses.d.ts.map +1 -1
- package/build/facades/glasses.js +21 -6
- package/build/facades/glasses.js.map +1 -1
- package/build/facades/glassesSettings.d.ts.map +1 -1
- package/build/facades/glassesSettings.js +1 -0
- package/build/facades/glassesSettings.js.map +1 -1
- package/build/facades/miniapps.d.ts +4 -0
- package/build/facades/miniapps.d.ts.map +1 -1
- package/build/facades/miniapps.js +5 -0
- package/build/facades/miniapps.js.map +1 -1
- package/build/facades/ota.d.ts +14 -16
- package/build/facades/ota.d.ts.map +1 -1
- package/build/facades/ota.js +22 -7
- package/build/facades/ota.js.map +1 -1
- package/build/facades/pairing.d.ts +8 -5
- package/build/facades/pairing.d.ts.map +1 -1
- package/build/facades/pairing.js +12 -10
- package/build/facades/pairing.js.map +1 -1
- package/build/facades/permissions.d.ts +10 -0
- package/build/facades/permissions.d.ts.map +1 -1
- package/build/facades/permissions.js +10 -0
- package/build/facades/permissions.js.map +1 -1
- package/build/facades/phoneNotifications.d.ts +0 -4
- package/build/facades/phoneNotifications.d.ts.map +1 -1
- package/build/facades/phoneNotifications.js +4 -14
- package/build/facades/phoneNotifications.js.map +1 -1
- package/build/facades/speech.d.ts +7 -6
- package/build/facades/speech.d.ts.map +1 -1
- package/build/facades/speech.js +1 -1
- package/build/facades/speech.js.map +1 -1
- package/build/generated/releaseMetadata.d.ts +12 -0
- package/build/generated/releaseMetadata.d.ts.map +1 -0
- package/build/generated/releaseMetadata.js +10 -0
- package/build/generated/releaseMetadata.js.map +1 -0
- package/build/index.d.ts +10 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -5
- package/build/index.js.map +1 -1
- package/build/react/MentraLiveOtaFlow.d.ts +38 -0
- package/build/react/MentraLiveOtaFlow.d.ts.map +1 -0
- package/build/react/MentraLiveOtaFlow.js +528 -0
- package/build/react/MentraLiveOtaFlow.js.map +1 -0
- package/build/react/index.d.ts +2 -0
- package/build/react/index.d.ts.map +1 -0
- package/build/react/index.js +2 -0
- package/build/react/index.js.map +1 -0
- package/build/react/useEngineSnapshot.d.ts +2 -0
- package/build/react/useEngineSnapshot.d.ts.map +1 -0
- package/build/react/useEngineSnapshot.js +14 -0
- package/build/react/useEngineSnapshot.js.map +1 -0
- package/build/runtime/bootstrap.d.ts +24 -1
- package/build/runtime/bootstrap.d.ts.map +1 -1
- package/build/runtime/bootstrap.js +17 -0
- package/build/runtime/bootstrap.js.map +1 -1
- package/build/runtime/scanQrSeam.d.ts +7 -0
- package/build/runtime/scanQrSeam.d.ts.map +1 -0
- package/build/runtime/scanQrSeam.js +16 -0
- package/build/runtime/scanQrSeam.js.map +1 -0
- package/build/services/AppRegistry.d.ts +41 -57
- package/build/services/AppRegistry.d.ts.map +1 -1
- package/build/services/AppRegistry.js +208 -144
- package/build/services/AppRegistry.js.map +1 -1
- package/build/services/AudioCloudUplink.d.ts +12 -0
- package/build/services/AudioCloudUplink.d.ts.map +1 -1
- package/build/services/AudioCloudUplink.js +22 -1
- package/build/services/AudioCloudUplink.js.map +1 -1
- package/build/services/AudioPlaybackService.d.ts +41 -2
- package/build/services/AudioPlaybackService.d.ts.map +1 -1
- package/build/services/AudioPlaybackService.js +250 -33
- package/build/services/AudioPlaybackService.js.map +1 -1
- package/build/services/BlobStore.d.ts +2 -1
- package/build/services/BlobStore.d.ts.map +1 -1
- package/build/services/BlobStore.js +17 -9
- package/build/services/BlobStore.js.map +1 -1
- package/build/services/CloudAudioSubscriptionSync.d.ts.map +1 -1
- package/build/services/CloudAudioSubscriptionSync.js +13 -1
- package/build/services/CloudAudioSubscriptionSync.js.map +1 -1
- package/build/services/CloudClientService.d.ts +15 -0
- package/build/services/CloudClientService.d.ts.map +1 -1
- package/build/services/CloudClientService.js +93 -1
- package/build/services/CloudClientService.js.map +1 -1
- package/build/services/DeviceEventRouter.js +5 -5
- package/build/services/DeviceEventRouter.js.map +1 -1
- package/build/services/ForegroundLocationPermission.d.ts +13 -0
- package/build/services/ForegroundLocationPermission.d.ts.map +1 -0
- package/build/services/ForegroundLocationPermission.js +12 -0
- package/build/services/ForegroundLocationPermission.js.map +1 -0
- package/build/services/GlassesSettingsSync.d.ts.map +1 -1
- package/build/services/GlassesSettingsSync.js +9 -3
- package/build/services/GlassesSettingsSync.js.map +1 -1
- package/build/services/GlassesStatusProjection.d.ts +2 -1
- package/build/services/GlassesStatusProjection.d.ts.map +1 -1
- package/build/services/GlassesStatusProjection.js +15 -8
- package/build/services/GlassesStatusProjection.js.map +1 -1
- package/build/services/HotspotOtaTransport.d.ts +29 -0
- package/build/services/HotspotOtaTransport.d.ts.map +1 -0
- package/build/services/HotspotOtaTransport.js +146 -0
- package/build/services/HotspotOtaTransport.js.map +1 -0
- package/build/services/HotspotShutdown.d.ts +17 -0
- package/build/services/HotspotShutdown.d.ts.map +1 -0
- package/build/services/HotspotShutdown.js +29 -0
- package/build/services/HotspotShutdown.js.map +1 -0
- package/build/services/LocalDisplayManager.d.ts +15 -0
- package/build/services/LocalDisplayManager.d.ts.map +1 -1
- package/build/services/LocalDisplayManager.js +106 -20
- package/build/services/LocalDisplayManager.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts +74 -2
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +785 -291
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/LocalMiniappStorage.d.ts +32 -0
- package/build/services/LocalMiniappStorage.d.ts.map +1 -0
- package/build/services/LocalMiniappStorage.js +66 -0
- package/build/services/LocalMiniappStorage.js.map +1 -0
- package/build/services/LocalMiniappUserIdentity.d.ts +20 -0
- package/build/services/LocalMiniappUserIdentity.d.ts.map +1 -0
- package/build/services/LocalMiniappUserIdentity.js +43 -0
- package/build/services/LocalMiniappUserIdentity.js.map +1 -0
- package/build/services/LocalSttFallbackCoordinator.d.ts +9 -6
- package/build/services/LocalSttFallbackCoordinator.d.ts.map +1 -1
- package/build/services/LocalSttFallbackCoordinator.js +18 -12
- package/build/services/LocalSttFallbackCoordinator.js.map +1 -1
- package/build/services/MicStateCoordinator.d.ts +42 -1
- package/build/services/MicStateCoordinator.d.ts.map +1 -1
- package/build/services/MicStateCoordinator.js +141 -3
- package/build/services/MicStateCoordinator.js.map +1 -1
- package/build/services/MiniappLauncher.d.ts.map +1 -1
- package/build/services/MiniappLauncher.js +23 -3
- package/build/services/MiniappLauncher.js.map +1 -1
- package/build/services/MiniappLiveness.d.ts +12 -0
- package/build/services/MiniappLiveness.d.ts.map +1 -0
- package/build/services/MiniappLiveness.js +16 -0
- package/build/services/MiniappLiveness.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/OtaArtifactDownloader.d.ts +65 -0
- package/build/services/OtaArtifactDownloader.d.ts.map +1 -0
- package/build/services/OtaArtifactDownloader.js +226 -0
- package/build/services/OtaArtifactDownloader.js.map +1 -0
- package/build/services/OtaAutoChain.d.ts +34 -0
- package/build/services/OtaAutoChain.d.ts.map +1 -0
- package/build/services/OtaAutoChain.js +83 -0
- package/build/services/OtaAutoChain.js.map +1 -0
- package/build/services/OtaErrorMapping.d.ts +18 -0
- package/build/services/OtaErrorMapping.d.ts.map +1 -0
- package/build/services/OtaErrorMapping.js +63 -0
- package/build/services/OtaErrorMapping.js.map +1 -0
- package/build/services/OtaInstallCoordinator.d.ts +95 -15
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
- package/build/services/OtaInstallCoordinator.js +577 -130
- package/build/services/OtaInstallCoordinator.js.map +1 -1
- package/build/services/OtaService.d.ts.map +1 -1
- package/build/services/OtaService.js +8 -1
- package/build/services/OtaService.js.map +1 -1
- package/build/services/OtaUpdateCheckService.d.ts +39 -4
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
- package/build/services/OtaUpdateCheckService.js +138 -22
- package/build/services/OtaUpdateCheckService.js.map +1 -1
- 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 +45 -0
- package/build/services/PhoneCalendarService.js.map +1 -0
- package/build/services/PhoneCameraFovCoordinator.d.ts +30 -0
- package/build/services/PhoneCameraFovCoordinator.d.ts.map +1 -0
- package/build/services/PhoneCameraFovCoordinator.js +194 -0
- package/build/services/PhoneCameraFovCoordinator.js.map +1 -0
- package/build/services/PhoneNotificationsSync.d.ts.map +1 -1
- package/build/services/PhoneNotificationsSync.js +12 -10
- package/build/services/PhoneNotificationsSync.js.map +1 -1
- package/build/services/PhonePhotoCoordinator.d.ts +26 -2
- package/build/services/PhonePhotoCoordinator.d.ts.map +1 -1
- package/build/services/PhonePhotoCoordinator.js +79 -9
- package/build/services/PhonePhotoCoordinator.js.map +1 -1
- package/build/services/PhoneStreamCoordinator.d.ts +8 -1
- package/build/services/PhoneStreamCoordinator.d.ts.map +1 -1
- package/build/services/PhoneStreamCoordinator.js +125 -13
- package/build/services/PhoneStreamCoordinator.js.map +1 -1
- package/build/services/PhoneVideoCoordinator.d.ts +2 -0
- package/build/services/PhoneVideoCoordinator.d.ts.map +1 -1
- package/build/services/PhoneVideoCoordinator.js +10 -0
- package/build/services/PhoneVideoCoordinator.js.map +1 -1
- package/build/services/SceneRenderer.d.ts.map +1 -1
- package/build/services/SceneRenderer.js +15 -0
- package/build/services/SceneRenderer.js.map +1 -1
- 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/SupportProfileSync.d.ts +22 -0
- package/build/services/SupportProfileSync.d.ts.map +1 -0
- package/build/services/SupportProfileSync.js +213 -0
- package/build/services/SupportProfileSync.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/TtsTextSanitizer.d.ts +5 -0
- package/build/services/TtsTextSanitizer.d.ts.map +1 -0
- package/build/services/TtsTextSanitizer.js +61 -0
- package/build/services/TtsTextSanitizer.js.map +1 -0
- package/build/services/WifiAdbRequest.d.ts +17 -0
- package/build/services/WifiAdbRequest.d.ts.map +1 -0
- package/build/services/WifiAdbRequest.js +35 -0
- package/build/services/WifiAdbRequest.js.map +1 -0
- package/build/services/asg/asgCameraApi.d.ts +43 -0
- package/build/services/asg/asgCameraApi.d.ts.map +1 -1
- package/build/services/asg/asgCameraApi.js +509 -26
- package/build/services/asg/asgCameraApi.js.map +1 -1
- 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/galleryNotices.d.ts +1 -1
- package/build/services/asg/galleryNotices.d.ts.map +1 -1
- package/build/services/asg/galleryNotices.js.map +1 -1
- 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 +1 -0
- package/build/services/asg/gallerySettingsService.d.ts.map +1 -1
- package/build/services/asg/gallerySettingsService.js +2 -0
- package/build/services/asg/gallerySettingsService.js.map +1 -1
- package/build/services/asg/gallerySyncService.d.ts.map +1 -1
- package/build/services/asg/gallerySyncService.js +162 -56
- package/build/services/asg/gallerySyncService.js.map +1 -1
- 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 +18 -0
- package/build/services/asg/localStorageService.d.ts.map +1 -1
- package/build/services/asg/localStorageService.js +168 -19
- package/build/services/asg/localStorageService.js.map +1 -1
- package/build/services/asg/mediaProcessingQueue.d.ts +10 -0
- package/build/services/asg/mediaProcessingQueue.d.ts.map +1 -1
- package/build/services/asg/mediaProcessingQueue.js +193 -62
- package/build/services/asg/mediaProcessingQueue.js.map +1 -1
- package/build/services/audioPlaybackAssets.d.ts +8 -0
- package/build/services/audioPlaybackAssets.d.ts.map +1 -0
- package/build/services/audioPlaybackAssets.js +7 -0
- package/build/services/audioPlaybackAssets.js.map +1 -0
- package/build/services/gallerySyncClock.js +1 -1
- package/build/services/gallerySyncClock.js.map +1 -1
- package/build/services/glassesClockSync.d.ts.map +1 -1
- package/build/services/glassesClockSync.js +6 -2
- package/build/services/glassesClockSync.js.map +1 -1
- package/build/services/manifestActions.d.ts +7 -0
- package/build/services/manifestActions.d.ts.map +1 -0
- package/build/services/manifestActions.js +25 -0
- package/build/services/manifestActions.js.map +1 -0
- package/build/services/otaDisplayState.d.ts +23 -12
- package/build/services/otaDisplayState.d.ts.map +1 -1
- package/build/services/otaDisplayState.js +36 -14
- package/build/services/otaDisplayState.js.map +1 -1
- package/build/services/otaInstallPolicy.d.ts +16 -4
- package/build/services/otaInstallPolicy.d.ts.map +1 -1
- package/build/services/otaInstallPolicy.js +24 -3
- package/build/services/otaInstallPolicy.js.map +1 -1
- package/build/services/otaLegacyMapping.d.ts +1 -1
- package/build/services/otaLegacyMapping.d.ts.map +1 -1
- package/build/services/otaLegacyMapping.js.map +1 -1
- package/build/services/otaManifestPolicy.d.ts +14 -0
- package/build/services/otaManifestPolicy.d.ts.map +1 -0
- package/build/services/otaManifestPolicy.js +19 -0
- package/build/services/otaManifestPolicy.js.map +1 -0
- package/build/services/otaManifestUrl.d.ts +3 -0
- package/build/services/otaManifestUrl.d.ts.map +1 -0
- package/build/services/otaManifestUrl.js +38 -0
- package/build/services/otaManifestUrl.js.map +1 -0
- package/build/services/slimStreamStatus.d.ts +11 -0
- package/build/services/slimStreamStatus.d.ts.map +1 -1
- package/build/services/slimStreamStatus.js +14 -4
- package/build/services/slimStreamStatus.js.map +1 -1
- package/build/stores/apps.d.ts.map +1 -1
- package/build/stores/apps.js +11 -0
- package/build/stores/apps.js.map +1 -1
- package/build/stores/bluetoothSettingKeys.d.ts.map +1 -1
- package/build/stores/bluetoothSettingKeys.js +2 -0
- package/build/stores/bluetoothSettingKeys.js.map +1 -1
- package/build/stores/gallerySync.d.ts +2 -0
- package/build/stores/gallerySync.d.ts.map +1 -1
- package/build/stores/gallerySync.js +2 -0
- package/build/stores/gallerySync.js.map +1 -1
- package/build/stores/glasses.d.ts.map +1 -1
- package/build/stores/glasses.js +3 -0
- package/build/stores/glasses.js.map +1 -1
- package/build/stores/settings.d.ts +17 -0
- package/build/stores/settings.d.ts.map +1 -1
- package/build/stores/settings.js +157 -17
- package/build/stores/settings.js.map +1 -1
- package/build/types/applet.d.ts +2 -0
- package/build/types/applet.d.ts.map +1 -1
- package/build/types/applet.js.map +1 -1
- package/build/types/asg.d.ts +7 -0
- package/build/types/asg.d.ts.map +1 -1
- package/build/types/asg.js.map +1 -1
- package/build/types/enums.d.ts +2 -25
- package/build/types/enums.d.ts.map +1 -1
- package/build/types/enums.js +2 -27
- package/build/types/enums.js.map +1 -1
- package/build/types/hardware.d.ts +4 -13
- package/build/types/hardware.d.ts.map +1 -1
- package/build/types/hardware.js +15 -3
- package/build/types/hardware.js.map +1 -1
- package/build/types/index.d.ts +2 -6
- package/build/types/index.d.ts.map +1 -1
- package/build/types/index.js +2 -6
- package/build/types/index.js.map +1 -1
- package/build/utils/configuredDevHost.d.ts +6 -0
- package/build/utils/configuredDevHost.d.ts.map +1 -0
- package/build/utils/configuredDevHost.js +19 -0
- package/build/utils/configuredDevHost.js.map +1 -0
- package/build/utils/devMiniappLaunch.d.ts +19 -8
- package/build/utils/devMiniappLaunch.d.ts.map +1 -1
- package/build/utils/devMiniappLaunch.js +144 -21
- package/build/utils/devMiniappLaunch.js.map +1 -1
- package/build/utils/diagnosticContext.d.ts.map +1 -1
- package/build/utils/diagnosticContext.js +15 -17
- package/build/utils/diagnosticContext.js.map +1 -1
- package/build/utils/hardware/hardware.d.ts.map +1 -1
- package/build/utils/hardware/hardware.js +7 -3
- package/build/utils/hardware/hardware.js.map +1 -1
- package/build/utils/miniappDiagnostics.d.ts +64 -0
- package/build/utils/miniappDiagnostics.d.ts.map +1 -0
- package/build/utils/miniappDiagnostics.js +173 -0
- package/build/utils/miniappDiagnostics.js.map +1 -0
- package/build/utils/permissions/MediaLibraryPermissions.d.ts +11 -0
- package/build/utils/permissions/MediaLibraryPermissions.d.ts.map +1 -1
- package/build/utils/permissions/MediaLibraryPermissions.js +27 -4
- package/build/utils/permissions/MediaLibraryPermissions.js.map +1 -1
- package/build/utils/timers/timers.d.ts.map +1 -1
- package/build/utils/timers/timers.js +55 -18
- package/build/utils/timers/timers.js.map +1 -1
- package/package.json +59 -31
- package/src/assets/silence.wav +0 -0
- package/src/bluetooth-sdk/debug.ts +1 -0
- package/src/bluetooth-sdk/index.ts +2 -0
- package/src/bluetooth-sdk/photo-receiver.ts +2 -0
- package/src/bluetooth-sdk/react.ts +1 -0
- package/src/bluetooth-sdk/types.ts +1 -0
- package/src/engine.ts +9 -4
- package/src/facades/dev.ts +17 -12
- package/src/facades/display.ts +1 -1
- package/src/facades/gallery.ts +1 -1
- package/src/facades/glasses.ts +20 -7
- package/src/facades/glassesSettings.ts +5 -0
- package/src/facades/miniapps.ts +7 -0
- package/src/facades/ota.ts +23 -8
- package/src/facades/pairing.ts +15 -11
- package/src/facades/permissions.ts +14 -0
- package/src/facades/phoneNotifications.ts +4 -13
- package/src/facades/speech.ts +21 -7
- package/src/generated/releaseMetadata.ts +20 -0
- package/src/index.ts +39 -13
- package/src/react/MentraLiveOtaFlow.tsx +856 -0
- package/src/react/index.ts +7 -0
- package/src/react/useEngineSnapshot.ts +16 -0
- package/src/runtime/bootstrap.ts +33 -1
- package/src/runtime/scanQrSeam.ts +20 -0
- package/src/services/AppRegistry.ts +240 -149
- package/src/services/AudioCloudUplink.ts +23 -1
- package/src/services/AudioPlaybackService.ts +287 -38
- package/src/services/BlobStore.ts +22 -9
- package/src/services/CloudAudioSubscriptionSync.ts +13 -1
- package/src/services/CloudClientService.ts +96 -1
- package/src/services/DeviceEventRouter.ts +5 -5
- package/src/services/ForegroundLocationPermission.ts +24 -0
- package/src/services/GlassesSettingsSync.ts +9 -3
- package/src/services/GlassesStatusProjection.ts +16 -8
- package/src/services/HotspotOtaTransport.ts +184 -0
- package/src/services/HotspotShutdown.ts +41 -0
- package/src/services/LocalDisplayManager.ts +112 -21
- package/src/services/LocalMiniappRuntime.ts +967 -346
- package/src/services/LocalMiniappStorage.ts +82 -0
- package/src/services/LocalMiniappUserIdentity.ts +46 -0
- package/src/services/LocalSttFallbackCoordinator.ts +19 -12
- package/src/services/MicStateCoordinator.ts +169 -4
- package/src/services/MiniappLauncher.ts +30 -3
- package/src/services/MiniappLiveness.ts +24 -0
- package/src/services/NativeHttpResponse.ts +6 -0
- package/src/services/OtaArtifactDownloader.ts +312 -0
- package/src/services/OtaAutoChain.ts +106 -0
- package/src/services/OtaErrorMapping.ts +80 -0
- package/src/services/OtaInstallCoordinator.ts +649 -144
- package/src/services/OtaService.ts +11 -5
- package/src/services/OtaUpdateCheckService.ts +181 -21
- package/src/services/PhoneCalendarHelpers.ts +212 -0
- package/src/services/PhoneCalendarService.ts +65 -0
- package/src/services/PhoneCameraFovCoordinator.ts +210 -0
- package/src/services/PhoneNotificationsSync.ts +12 -10
- package/src/services/PhonePhotoCoordinator.ts +116 -18
- package/src/services/PhoneStreamCoordinator.ts +139 -25
- package/src/services/PhoneVideoCoordinator.ts +11 -0
- package/src/services/SceneRenderer.ts +16 -0
- package/src/services/SentenceTtsPipeline.ts +106 -0
- package/src/services/SupportProfileSync.ts +218 -0
- package/src/services/TranscriptionRouting.ts +37 -0
- package/src/services/TtsTextSanitizer.ts +66 -0
- package/src/services/WifiAdbRequest.ts +53 -0
- package/src/services/asg/asgCameraApi.ts +615 -33
- package/src/services/asg/cameraRollExportCoordinator.ts +627 -0
- package/src/services/asg/cameraRollExportLedger.ts +122 -0
- package/src/services/asg/galleryNotices.ts +1 -0
- package/src/services/asg/galleryPathMigration.ts +22 -0
- package/src/services/asg/gallerySettingsService.ts +3 -0
- package/src/services/asg/gallerySyncService.ts +184 -73
- package/src/services/asg/galleryTransferLedger.ts +312 -0
- package/src/services/asg/localNetworkTransport.ts +169 -0
- package/src/services/asg/localStorageService.ts +179 -24
- package/src/services/asg/mediaProcessingQueue.ts +209 -62
- package/src/services/audioPlaybackAssets.ts +8 -0
- package/src/services/gallerySyncClock.ts +1 -1
- package/src/services/glassesClockSync.ts +6 -2
- package/src/services/manifestActions.ts +30 -0
- package/src/services/otaDisplayState.ts +58 -17
- package/src/services/otaInstallPolicy.ts +30 -4
- package/src/services/otaLegacyMapping.ts +1 -1
- package/src/services/otaManifestPolicy.ts +42 -0
- package/src/services/otaManifestUrl.ts +44 -0
- package/src/services/slimStreamStatus.ts +16 -5
- package/src/stores/apps.ts +12 -0
- package/src/stores/bluetoothSettingKeys.ts +2 -0
- package/src/stores/gallerySync.ts +4 -0
- package/src/stores/glasses.ts +3 -0
- package/src/stores/settings.ts +179 -18
- package/src/types/applet.ts +2 -0
- package/src/types/asg.ts +7 -0
- package/src/types/enums.ts +3 -28
- package/src/types/hardware.ts +20 -13
- package/src/types/index.ts +2 -6
- package/src/utils/configuredDevHost.ts +17 -0
- package/src/utils/devMiniappLaunch.ts +151 -23
- package/src/utils/diagnosticContext.ts +17 -17
- package/src/utils/hardware/hardware.ts +7 -9
- package/src/utils/miniappDiagnostics.ts +226 -0
- package/src/utils/permissions/MediaLibraryPermissions.ts +35 -4
- package/src/utils/timers/timers.ts +57 -21
- package/build/devtools.d.ts +0 -11
- package/build/devtools.d.ts.map +0 -1
- package/build/devtools.js +0 -13
- package/build/devtools.js.map +0 -1
- package/build/internal.d.ts +0 -66
- package/build/internal.d.ts.map +0 -1
- package/build/internal.js +0 -89
- package/build/internal.js.map +0 -1
- package/build/services/asgOtaVersionUrl.d.ts +0 -2
- package/build/services/asgOtaVersionUrl.d.ts.map +0 -1
- package/build/services/asgOtaVersionUrl.js +0 -36
- package/build/services/asgOtaVersionUrl.js.map +0 -1
- package/src/devtools.ts +0 -13
- package/src/internal.ts +0 -158
- package/src/services/asgOtaVersionUrl.ts +0 -41
|
@@ -18,7 +18,19 @@ export class CloudAudioSubscriptionSync {
|
|
|
18
18
|
lastAppliedKey = "";
|
|
19
19
|
pendingKey = "";
|
|
20
20
|
begin(nextKey) {
|
|
21
|
-
|
|
21
|
+
// Exact duplicate of the write already in flight — nothing to do.
|
|
22
|
+
if (nextKey === this.pendingKey) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
// Matches the last successfully applied set, but ONLY skip when nothing
|
|
26
|
+
// else is in flight. If a different write is pending (e.g. desired went
|
|
27
|
+
// fr-FR -> [] -> fr-FR while the [] write is still on the wire),
|
|
28
|
+
// lastAppliedKey is stale: it names what was applied BEFORE the in-flight
|
|
29
|
+
// write lands. Skipping here would drop the re-subscribe and strand the
|
|
30
|
+
// cloud on the intermediate (empty) set — captions silently die on any
|
|
31
|
+
// rapid A -> B -> A subscription churn. The cloud's own version counter
|
|
32
|
+
// resolves ordering between the concurrent writes, so sending both is safe.
|
|
33
|
+
if (nextKey === this.lastAppliedKey && this.pendingKey === "") {
|
|
22
34
|
return false;
|
|
23
35
|
}
|
|
24
36
|
this.pendingKey = nextKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudAudioSubscriptionSync.js","sourceRoot":"","sources":["../../src/services/CloudAudioSubscriptionSync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,0BAA0B;IAC7B,cAAc,GAAG,EAAE,CAAA;IACnB,UAAU,GAAG,EAAE,CAAA;IAEhB,KAAK,CAAC,OAAe;QAC1B,IAAI,OAAO,KAAK,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"CloudAudioSubscriptionSync.js","sourceRoot":"","sources":["../../src/services/CloudAudioSubscriptionSync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,0BAA0B;IAC7B,cAAc,GAAG,EAAE,CAAA;IACnB,UAAU,GAAG,EAAE,CAAA;IAEhB,KAAK,CAAC,OAAe;QAC1B,kEAAkE;QAClE,IAAI,OAAO,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;YAChC,OAAO,KAAK,CAAA;QACd,CAAC;QACD,wEAAwE;QACxE,wEAAwE;QACxE,iEAAiE;QACjE,0EAA0E;QAC1E,wEAAwE;QACxE,uEAAuE;QACvE,wEAAwE;QACxE,4EAA4E;QAC5E,IAAI,OAAO,KAAK,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,KAAK,EAAE,EAAE,CAAC;YAC9D,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,SAAS,CAAC,GAAW;QAC1B,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QACtB,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,GAAG,CAAA;IAC3B,CAAC;IAEM,MAAM,CAAC,GAAW;QACvB,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * Tracks cloud-audio subscription writes so LocalMiniappRuntime can dedupe\n * successful writes without losing retryability after transient Core/network\n * failures.\n *\n * Failure mode this protects:\n * 1. Local captions subscribes to transcription.\n * 2. The first Cloud V2 `PUT /api/audio/subscriptions` throws while the socket\n * is reconnecting or Core is briefly unreachable.\n * 3. A reconnect/resync recomputes the same desired subscription set.\n *\n * If we mark the set as \"last applied\" before the PUT succeeds, step 3 is\n * incorrectly deduped and captions can wait forever even though Cloud V2 later\n * reconnects. So `begin()` only blocks exact duplicates while a write is in\n * flight; only `succeeded()` promotes that key to the applied state.\n */\nexport class CloudAudioSubscriptionSync {\n private lastAppliedKey = \"\"\n private pendingKey = \"\"\n\n public begin(nextKey: string): boolean {\n // Exact duplicate of the write already in flight — nothing to do.\n if (nextKey === this.pendingKey) {\n return false\n }\n // Matches the last successfully applied set, but ONLY skip when nothing\n // else is in flight. If a different write is pending (e.g. desired went\n // fr-FR -> [] -> fr-FR while the [] write is still on the wire),\n // lastAppliedKey is stale: it names what was applied BEFORE the in-flight\n // write lands. Skipping here would drop the re-subscribe and strand the\n // cloud on the intermediate (empty) set — captions silently die on any\n // rapid A -> B -> A subscription churn. The cloud's own version counter\n // resolves ordering between the concurrent writes, so sending both is safe.\n if (nextKey === this.lastAppliedKey && this.pendingKey === \"\") {\n return false\n }\n this.pendingKey = nextKey\n return true\n }\n\n public succeeded(key: string): void {\n if (this.pendingKey === key) {\n this.pendingKey = \"\"\n }\n this.lastAppliedKey = key\n }\n\n public failed(key: string): void {\n if (this.pendingKey === key) {\n this.pendingKey = \"\"\n }\n }\n}\n"]}
|
|
@@ -39,6 +39,18 @@ export declare const cloudClientService: {
|
|
|
39
39
|
runtime: string;
|
|
40
40
|
} | null): void;
|
|
41
41
|
getPreinstalledMiniappRegistry(): Promise<PreinstalledMiniappRegistry>;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the stable Core-owned Mentra user id.
|
|
44
|
+
*
|
|
45
|
+
* Storage must use this identity rather than the short-lived Core access
|
|
46
|
+
* token. A previously verified id is restored from MMKV so local miniapps
|
|
47
|
+
* remain available after an offline process restart. On first sign-in,
|
|
48
|
+
* callers join the auth module's single-flight exchange/refresh instead of
|
|
49
|
+
* falling back to an anonymous namespace.
|
|
50
|
+
*/
|
|
51
|
+
resolveMentraUserId(): Promise<string>;
|
|
52
|
+
/** Read the stable Mentra user id after async identity resolution. */
|
|
53
|
+
getMentraUserId(): string;
|
|
42
54
|
getMiniappAuthToken(packageName: string, opts?: {
|
|
43
55
|
minTtlMs?: number;
|
|
44
56
|
devAttestation?: string;
|
|
@@ -136,6 +148,9 @@ export declare const cloudClientService: {
|
|
|
136
148
|
status: import("@mentra/cloud-client").ReportStatus;
|
|
137
149
|
}>;
|
|
138
150
|
};
|
|
151
|
+
supportProfile: {
|
|
152
|
+
update(input: import("@mentra/cloud-client").SupportStateInput): Promise<import("@mentra/cloud-client").SupportProfileUpdateResult>;
|
|
153
|
+
};
|
|
139
154
|
};
|
|
140
155
|
hasAudioSubscriptions(): boolean;
|
|
141
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudClientService.d.ts","sourceRoot":"","sources":["../../src/services/CloudClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"CloudClientService.d.ts","sourceRoot":"","sources":["../../src/services/CloudClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAC,WAAW,EAAgD,MAAM,mCAAmC,CAAA;AAC5G,OAAO,KAAK,EAAC,2BAA2B,EAAkB,MAAM,mCAAmC,CAAA;AAGnG,OAAO,KAAK,EAAC,iBAAiB,EA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,CAAC;wBAIvB,CAAC,QAAQ,EAAE,yBAAyB,KAAK,IAAI,GAAG,MAAM,IAAI;;oBAQhE,MAAM,YAAY,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;;;wBAOnE,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;8BAIrD,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;;;;+BAI9D,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;0BAIvE,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;6BA4BxD,OAAO;CAGjC,CAAA"}
|
|
@@ -13,22 +13,28 @@
|
|
|
13
13
|
* The local-miniapp path drives the cloud's transcription/translation through
|
|
14
14
|
* this service.
|
|
15
15
|
*/
|
|
16
|
-
import { CloudClient, setNativeUdp, setSecureStorage } from "@mentra/cloud-client/react-native";
|
|
16
|
+
import { CloudClient, setNativeHttp, setNativeUdp, setSecureStorage } from "@mentra/cloud-client/react-native";
|
|
17
|
+
import { Platform } from "react-native";
|
|
17
18
|
import BluetoothSdk from "@mentra/bluetooth-sdk/internal";
|
|
19
|
+
import CrustModule from "@mentra/crust";
|
|
18
20
|
import { getAuth, getConfigValues } from "../runtime/bootstrap";
|
|
19
21
|
import { useSettingsStore, SETTINGS } from "../stores/settings";
|
|
20
22
|
import { createCloudUdpSocket } from "../utils/cloudClient/RnUdpAdapter";
|
|
21
23
|
import { cloudSecureStore } from "../utils/cloudClient/cloudSecureStore";
|
|
24
|
+
import { storage as mmkvStorage } from "../utils/storage";
|
|
22
25
|
import { useCloudClientStatusStore } from "../stores/cloudClientStatus";
|
|
23
26
|
import { islandNotifications } from "./NotificationsEmitter";
|
|
24
27
|
import { BgTimer } from "../utils/timers";
|
|
25
28
|
import { logCloudV2TranscriptMetric } from "./CloudTranscriptE2EMetrics";
|
|
29
|
+
import { LocalMiniappUserIdentity } from "./LocalMiniappUserIdentity";
|
|
30
|
+
import { nativeHttpResponseBody } from "./NativeHttpResponse";
|
|
26
31
|
const LOG_TAG = "cloudClient";
|
|
27
32
|
// Persistent cloud-disconnect detector: the cloud-client reconnect loop is infinite
|
|
28
33
|
// and never surfaces a "giving up" signal, so "persistent failure" = the session has
|
|
29
34
|
// been continuously NOT connected for this long. A quick reconnect cancels it; brief
|
|
30
35
|
// flaps that recover don't fire. Raised as engine.notifications(connection_failed_persistent).
|
|
31
36
|
const CLOUD_PERSISTENT_FAILURE_MS = 60_000;
|
|
37
|
+
const LOCAL_MINIAPP_USER_ID_KEY = "mentra.localMiniapp.userId";
|
|
32
38
|
/** Cancel the pending persistent-failure alarm + re-arm for the next outage. */
|
|
33
39
|
function clearPersistentFailureAlarm() {
|
|
34
40
|
if (persistentFailureTimer) {
|
|
@@ -58,6 +64,22 @@ let authStateUnsubscribe = null;
|
|
|
58
64
|
let localDevRuntimeToken = null;
|
|
59
65
|
let lc3FrameSizeUnsubscribe = null;
|
|
60
66
|
let coreTokenSyncPromise = null;
|
|
67
|
+
const localMiniappUserIdentity = new LocalMiniappUserIdentity({
|
|
68
|
+
get() {
|
|
69
|
+
const result = mmkvStorage.load(LOCAL_MINIAPP_USER_ID_KEY);
|
|
70
|
+
return result.is_ok() ? result.value : null;
|
|
71
|
+
},
|
|
72
|
+
set(userId) {
|
|
73
|
+
const result = mmkvStorage.save(LOCAL_MINIAPP_USER_ID_KEY, userId);
|
|
74
|
+
if (result.is_error())
|
|
75
|
+
throw result.error;
|
|
76
|
+
},
|
|
77
|
+
remove() {
|
|
78
|
+
const result = mmkvStorage.remove(LOCAL_MINIAPP_USER_ID_KEY);
|
|
79
|
+
if (result.is_error())
|
|
80
|
+
throw result.error;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
61
83
|
const transcriptListeners = new Set();
|
|
62
84
|
const translationListeners = new Set();
|
|
63
85
|
const statusListeners = new Set();
|
|
@@ -97,6 +119,7 @@ async function syncCoreAccessTokenToBluetoothInternal() {
|
|
|
97
119
|
if (c !== client) {
|
|
98
120
|
throw new Error("cloud client changed while syncing core token");
|
|
99
121
|
}
|
|
122
|
+
localMiniappUserIdentity.remember(c.auth.identity.mentraUserId);
|
|
100
123
|
const result = await useSettingsStore.getState().setSetting(SETTINGS.core_token.key, token, false);
|
|
101
124
|
if (result.is_error()) {
|
|
102
125
|
throw result.error;
|
|
@@ -235,6 +258,14 @@ function ensureAuthWatch() {
|
|
|
235
258
|
let reconnectPending = false;
|
|
236
259
|
try {
|
|
237
260
|
const sub = auth.onStateChange((event, session) => {
|
|
261
|
+
if (event === "SIGNED_OUT") {
|
|
262
|
+
localMiniappUserIdentity.forget();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
// A new sign-in may belong to a different account. Force the next
|
|
266
|
+
// storage request to resolve and persist that account's Core identity.
|
|
267
|
+
if (event === "SIGNED_IN")
|
|
268
|
+
localMiniappUserIdentity.forget();
|
|
238
269
|
if (!session?.token)
|
|
239
270
|
return;
|
|
240
271
|
if (connected || reconnectPending)
|
|
@@ -298,6 +329,20 @@ function ensureTransports() {
|
|
|
298
329
|
transportsReady = true;
|
|
299
330
|
setNativeUdp(() => createCloudUdpSocket());
|
|
300
331
|
setSecureStorage(cloudSecureStore);
|
|
332
|
+
if (Platform.OS !== "android")
|
|
333
|
+
return;
|
|
334
|
+
setNativeHttp(async (input, init) => {
|
|
335
|
+
if (typeof input !== "string" || (init?.body != null && typeof init.body !== "string")) {
|
|
336
|
+
return globalThis.fetch(input, init);
|
|
337
|
+
}
|
|
338
|
+
const headers = Object.fromEntries(new Headers(init?.headers).entries());
|
|
339
|
+
const result = await CrustModule.nativeHttpRequest(init?.method ?? "GET", input, headers, init?.body ?? null);
|
|
340
|
+
return new Response(nativeHttpResponseBody(result.status, result.body), {
|
|
341
|
+
status: result.status,
|
|
342
|
+
statusText: result.statusText,
|
|
343
|
+
headers: result.headers,
|
|
344
|
+
});
|
|
345
|
+
});
|
|
301
346
|
}
|
|
302
347
|
function clearRuntimeEventSubscriptions() {
|
|
303
348
|
runtimeStatusUnsubscribe?.();
|
|
@@ -343,6 +388,12 @@ function construct() {
|
|
|
343
388
|
// LC3 at 16 kHz with the frame size the encoder emits.
|
|
344
389
|
audio: { codec: "lc3", sampleRate: 16000, frameSizeBytes: frameSizeBytes() },
|
|
345
390
|
auth,
|
|
391
|
+
timers: {
|
|
392
|
+
setTimeout: (callback, delayMs) => BgTimer.setTimeout(callback, delayMs),
|
|
393
|
+
clearTimeout: (handle) => BgTimer.clearTimeout(handle),
|
|
394
|
+
setInterval: (callback, intervalMs) => BgTimer.setInterval(callback, intervalMs),
|
|
395
|
+
clearInterval: (handle) => BgTimer.clearInterval(handle),
|
|
396
|
+
},
|
|
346
397
|
logger: cloudLogger,
|
|
347
398
|
});
|
|
348
399
|
const c = client;
|
|
@@ -369,6 +420,7 @@ function construct() {
|
|
|
369
420
|
return;
|
|
370
421
|
connected = true;
|
|
371
422
|
console.log(`${LOG_TAG}: runtime connected`);
|
|
423
|
+
console.log(`${LOG_TAG}: debug: ws-session-debug connected`);
|
|
372
424
|
// Cloud is up — cancel any pending persistent-failure alarm and re-arm for the
|
|
373
425
|
// next outage.
|
|
374
426
|
clearPersistentFailureAlarm();
|
|
@@ -384,6 +436,7 @@ function construct() {
|
|
|
384
436
|
return;
|
|
385
437
|
connected = false;
|
|
386
438
|
console.log(`${LOG_TAG}: runtime disconnected (${info.reason})`);
|
|
439
|
+
console.log(`${LOG_TAG}: debug: ws-session-debug disconnected reason=${info.reason} willStayDown=${/superseded by newer session/i.test(info.reason)}`);
|
|
387
440
|
// Arm the persistent-failure alarm once; if we're still down when it fires, raise
|
|
388
441
|
// the notification. A reconnect within the window cancels it (onConnected above).
|
|
389
442
|
if (!persistentFailureTimer && !persistentFailureNotified) {
|
|
@@ -462,6 +515,35 @@ export const cloudClientService = {
|
|
|
462
515
|
throw new Error("cloud client core is unavailable");
|
|
463
516
|
return c.core.miniapps.getRegistry();
|
|
464
517
|
},
|
|
518
|
+
/**
|
|
519
|
+
* Resolve the stable Core-owned Mentra user id.
|
|
520
|
+
*
|
|
521
|
+
* Storage must use this identity rather than the short-lived Core access
|
|
522
|
+
* token. A previously verified id is restored from MMKV so local miniapps
|
|
523
|
+
* remain available after an offline process restart. On first sign-in,
|
|
524
|
+
* callers join the auth module's single-flight exchange/refresh instead of
|
|
525
|
+
* falling back to an anonymous namespace.
|
|
526
|
+
*/
|
|
527
|
+
async resolveMentraUserId() {
|
|
528
|
+
return localMiniappUserIdentity.resolve(async () => {
|
|
529
|
+
if (!client)
|
|
530
|
+
this.init();
|
|
531
|
+
const c = client;
|
|
532
|
+
if (!c)
|
|
533
|
+
throw new Error("cloud client not initialized");
|
|
534
|
+
await c.auth.getCoreToken();
|
|
535
|
+
if (c !== client)
|
|
536
|
+
throw new Error("cloud client changed while resolving user identity");
|
|
537
|
+
return c.auth.identity.mentraUserId;
|
|
538
|
+
});
|
|
539
|
+
},
|
|
540
|
+
/** Read the stable Mentra user id after async identity resolution. */
|
|
541
|
+
getMentraUserId() {
|
|
542
|
+
const userId = localMiniappUserIdentity.get();
|
|
543
|
+
if (!userId)
|
|
544
|
+
throw new Error("Mentra user identity is unavailable");
|
|
545
|
+
return userId;
|
|
546
|
+
},
|
|
465
547
|
async getMiniappAuthToken(packageName, opts) {
|
|
466
548
|
if (!client)
|
|
467
549
|
this.init();
|
|
@@ -491,6 +573,11 @@ export const cloudClientService = {
|
|
|
491
573
|
clearPersistentFailureAlarm();
|
|
492
574
|
const wasConnected = connected;
|
|
493
575
|
client = null;
|
|
576
|
+
// stop() is part of the logout lifecycle and runs before the host emits
|
|
577
|
+
// SIGNED_OUT. Remove the persisted namespace owner here so a later account
|
|
578
|
+
// can never inherit it. A force-stop/process kill does not call stop(), so
|
|
579
|
+
// the cached id still survives the offline cold-start case.
|
|
580
|
+
localMiniappUserIdentity.forget();
|
|
494
581
|
localDevRuntimeToken = null;
|
|
495
582
|
connected = false;
|
|
496
583
|
resetRuntimeStatus();
|
|
@@ -619,6 +706,11 @@ export const cloudClientService = {
|
|
|
619
706
|
return getCoreClient().reports.complete(...args);
|
|
620
707
|
},
|
|
621
708
|
},
|
|
709
|
+
supportProfile: {
|
|
710
|
+
update(...args) {
|
|
711
|
+
return getCoreClient().supportProfile.update(...args);
|
|
712
|
+
},
|
|
713
|
+
},
|
|
622
714
|
},
|
|
623
715
|
hasAudioSubscriptions() {
|
|
624
716
|
return audioSubscriptions.length > 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudClientService.js","sourceRoot":"","sources":["../../src/services/CloudClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAC,MAAM,mCAAmC,CAAA;AAK7F,OAAO,YAAY,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAC,OAAO,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAE7D,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAC,gBAAgB,EAAC,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,0BA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AM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;YAC1D,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;QAClD,CAAC;QACD,iBAAiB,CAAC,GAAuE;YACvF,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;YAC1D,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;QACnD,CAAC;QACD,YAAY,CAAC,GAAkE;YAC7E,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;YAC1D,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;QAC9C,CAAC;KACF;IAED,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,MAAM,CAAC,GAAG,IAAgD;gBACxD,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;YAChD,CAAC;YACD,OAAO,CAAC,GAAG,IAAiD;gBAC1D,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;YACjD,CAAC;YACD,cAAc,CAAC,GAAG,IAAwD;gBACxE,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAA;YACxD,CAAC;YACD,QAAQ,CAAC,GAAG,IAAkD;gBAC5D,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAA;YAClD,CAAC;SACF;KACF;IAED,qBAAqB;QACnB,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAA;IACtC,CAAC;CACF,CAAA","sourcesContent":["/**\n * Owns the singleton `@mentra/cloud-client` (CloudClient) for the engine runtime\n * — the keystone move that pulls backend comms INTO engine.\n *\n * engine constructs the client from engine-owned pieces (the native UDP socket,\n * the MMKV secure store, the cloud-status store) plus the two things the host\n * provides through the engine front door: `auth.getSubjectToken` (the one\n * permanent seam — the OEM owns login) and the resolved cloud endpoints\n * (`config.coreUrl/runtimeUrl`, computed host-side from dev/settings). On init it\n * exposes cloud runtime methods directly from this service, so the host no longer\n * injects a cloud adapter — engine owns construction and wiring.\n *\n * The local-miniapp path drives the cloud's transcription/translation through\n * this service.\n */\nimport {CloudClient, setNativeUdp, setSecureStorage} from \"@mentra/cloud-client/react-native\"\nimport type {PreinstalledMiniappRegistry, RuntimeSnapshot} from \"@mentra/cloud-client/react-native\"\nimport type {SubjectTokenType} from \"@mentra/cloud-client\"\nimport type {AudioSubscription, TranscriptionData, TranslationData} from \"@mentra/cloud-protocol\"\n\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport {getAuth, getConfigValues} from \"../runtime/bootstrap\"\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\nimport {type CloudClientStatusSnapshot, type MiniappAuthToken} from \"../runtime/config\"\nimport {createCloudUdpSocket} from \"../utils/cloudClient/RnUdpAdapter\"\nimport {cloudSecureStore} from \"../utils/cloudClient/cloudSecureStore\"\nimport {useCloudClientStatusStore} from \"../stores/cloudClientStatus\"\nimport {islandNotifications} from \"./NotificationsEmitter\"\nimport {BgTimer} from \"../utils/timers\"\nimport {logCloudV2TranscriptMetric} from \"./CloudTranscriptE2EMetrics\"\n\nconst LOG_TAG = \"cloudClient\"\ntype CloudCore = NonNullable<CloudClient[\"core\"]>\n\n// Persistent cloud-disconnect detector: the cloud-client reconnect loop is infinite\n// and never surfaces a \"giving up\" signal, so \"persistent failure\" = the session has\n// been continuously NOT connected for this long. A quick reconnect cancels it; brief\n// flaps that recover don't fire. Raised as engine.notifications(connection_failed_persistent).\nconst CLOUD_PERSISTENT_FAILURE_MS = 60_000\n\n/** Cancel the pending persistent-failure alarm + re-arm for the next outage. */\nfunction clearPersistentFailureAlarm(): void {\n if (persistentFailureTimer) {\n BgTimer.clearTimeout(persistentFailureTimer)\n persistentFailureTimer = null\n }\n persistentFailureNotified = false\n}\n\ntype Lc3FrameSizeBytes = 20 | 40 | 60\n\n// Neutral last-ditch fallbacks (reachable under `adb reverse`) for when the host\n// passes no endpoints. The host normally resolves the real URLs (dev override /\n// Metro host / env) and hands them in via `engine.configure({config})`.\nconst FALLBACK_CORE_URL = \"http://localhost:3000\"\nconst FALLBACK_RUNTIME_URL = \"http://localhost:3001\"\nconst LOCAL_AUTH_PORT = 3002\n\nlet client: CloudClient | null = null\nlet connected = false\nlet persistentFailureTimer: ReturnType<typeof BgTimer.setTimeout> | null = null\nlet persistentFailureNotified = false\nlet audioSubscriptions: AudioSubscription[] = []\nlet transportsReady = false\n/** Endpoints to build with — seeded from config, overridable via reconnect(). */\nlet endpointsOverride: {core: string; runtime: string} | null = null\nlet runtimeStatusUnsubscribe: (() => void) | null = null\nlet transcriptUnsubscribe: (() => void) | null = null\nlet translationUnsubscribe: (() => void) | null = null\nlet authStateUnsubscribe: (() => void) | null = null\nlet localDevRuntimeToken: {runtimeUrl: string; token: string; expiresAtMs: number} | null = null\nlet lc3FrameSizeUnsubscribe: (() => void) | null = null\nlet coreTokenSyncPromise: Promise<string> | null = null\n\nconst transcriptListeners = new Set<(d: TranscriptionData) => void>()\nconst translationListeners = new Set<(d: TranslationData) => void>()\nconst statusListeners = new Set<(snapshot: CloudClientStatusSnapshot) => void>()\nconst connectionListeners = new Set<(connected: boolean) => void>()\n\nfunction resolveEndpoints(): {core: string; runtime: string} {\n if (endpointsOverride) return endpointsOverride\n const cfg = getConfigValues()\n return {\n core: cfg.coreUrl?.trim() || FALLBACK_CORE_URL,\n runtime: cfg.runtimeUrl?.trim() || FALLBACK_RUNTIME_URL,\n }\n}\n\nfunction getCoreClient(): CloudCore {\n if (!client) construct()\n const core = client?.core\n if (!core) throw new Error(\"cloud client core not configured\")\n return core\n}\n\nfunction syncCoreAccessTokenToBluetooth(): Promise<string> {\n if (coreTokenSyncPromise) return coreTokenSyncPromise\n\n coreTokenSyncPromise = syncCoreAccessTokenToBluetoothInternal().finally(() => {\n coreTokenSyncPromise = null\n })\n return coreTokenSyncPromise\n}\n\nasync function syncCoreAccessTokenToBluetoothInternal(): Promise<string> {\n if (!client) construct()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n const token = await c.auth.getCoreToken()\n if (c !== client) {\n throw new Error(\"cloud client changed while syncing core token\")\n }\n const result = await useSettingsStore.getState().setSetting(SETTINGS.core_token.key, token, false)\n if (result.is_error()) {\n throw result.error\n }\n\n try {\n await BluetoothSdk.updateBluetoothSettings({[SETTINGS.core_token.key]: token})\n } catch (err) {\n console.warn(`${LOG_TAG}: direct Bluetooth core_token sync failed: ${(err as Error)?.message ?? err}`)\n }\n\n return token\n}\n\nfunction frameSizeBytes(): Lc3FrameSizeBytes {\n // Read LIVE from the engine settings store (the source of truth) so a\n // reconnect after a glasses swap (G1=20 ↔ G2=40) picks up the new frame size,\n // not the one-time engine.configure({config}) snapshot. Falls back to the\n // config value (set at boot) then 20 when the setting is unset.\n const fromSettings = useSettingsStore.getState().getSetting(SETTINGS.lc3_frame_size.key)\n const size = fromSettings ?? getConfigValues().audioFrameSizeBytes\n return size === 20 || size === 40 || size === 60 ? size : 20\n}\n\nasync function getSubjectToken(): Promise<{token: string; type: SubjectTokenType}> {\n const a = getAuth()\n if (!a) throw new Error(\"cloudClient: engine.configure({auth}) not called\")\n const r = await a.getSubjectToken()\n // IslandAuth's SubjectTokenType is intentionally open (`string & {}`) so OEMs\n // can use other token kinds; cloud-client's is a closed union. The host's\n // actual value (\"supabase\") is valid — narrow at this boundary.\n return {token: r.token, type: r.type as SubjectTokenType}\n}\n\nfunction normalizeExpiresAt(expiresAt: number): number {\n return expiresAt < 10_000_000_000 ? expiresAt * 1000 : expiresAt\n}\n\nfunction shouldUseLocalDevRuntimeToken(endpoints: {runtime: string}): boolean {\n if (!__DEV__) return false\n try {\n const host = new URL(endpoints.runtime).hostname\n return host === \"localhost\" || host === \"127.0.0.1\" || host === \"10.0.2.2\"\n } catch {\n return false\n }\n}\n\nasync function getLocalDevRuntimeToken(runtimeEndpoint: string, opts?: {forceRefresh?: boolean}): Promise<string> {\n const now = Date.now()\n if (\n !opts?.forceRefresh &&\n localDevRuntimeToken?.runtimeUrl === runtimeEndpoint &&\n localDevRuntimeToken.expiresAtMs - now > 60_000\n ) {\n return localDevRuntimeToken.token\n }\n\n const base = new URL(runtimeEndpoint)\n base.port = String(LOCAL_AUTH_PORT)\n base.pathname = \"/api/dev/runtime-token\"\n base.search = new URLSearchParams({userId: \"local-phone-user\", tenantId: \"mentra\"}).toString()\n\n const res = await fetch(base.toString())\n if (!res.ok) {\n throw new Error(`cloudClient: local dev runtime token failed (${res.status})`)\n }\n const body = (await res.json()) as {access_token?: string; expires_in?: number}\n if (!body.access_token) {\n throw new Error(\"cloudClient: local dev runtime token response missing access_token\")\n }\n localDevRuntimeToken = {\n runtimeUrl: runtimeEndpoint,\n token: body.access_token,\n expiresAtMs: now + (body.expires_in ?? 300) * 1000,\n }\n return body.access_token\n}\n\nfunction toCloudClientStatusSnapshot(snapshot: RuntimeSnapshot): CloudClientStatusSnapshot {\n return {status: snapshot.status, audioTransport: snapshot.audioTransport}\n}\n\nfunction currentRuntimeStatus(): CloudClientStatusSnapshot {\n const state = useCloudClientStatusStore.getState()\n return {status: state.status, audioTransport: state.audioTransport}\n}\n\nfunction setRuntimeStatus(snapshot: RuntimeSnapshot): void {\n useCloudClientStatusStore.getState().setSnapshot(snapshot)\n emitStatus(toCloudClientStatusSnapshot(snapshot))\n}\n\nfunction resetRuntimeStatus(): void {\n useCloudClientStatusStore.getState().reset()\n emitStatus(currentRuntimeStatus())\n}\n\nfunction stringifyMeta(meta: unknown): string {\n if (!meta || typeof meta !== \"object\") return \"\"\n try {\n return ` ${JSON.stringify(meta)}`\n } catch {\n return \"\"\n }\n}\n\nconst cloudLogger = {\n debug: (msg: string, meta?: unknown) => console.log(`${LOG_TAG}: debug: ${msg}${stringifyMeta(meta)}`),\n info: (msg: string, meta?: unknown) => console.log(`${LOG_TAG}: info: ${msg}${stringifyMeta(meta)}`),\n warn: (msg: string, meta?: unknown) => console.warn(`${LOG_TAG}: warn: ${msg}${stringifyMeta(meta)}`),\n error: (msg: string, meta?: unknown) => console.warn(`${LOG_TAG}: error: ${msg}${stringifyMeta(meta)}`),\n}\n\nfunction notifyConnectionListeners(next: boolean): void {\n for (const l of connectionListeners) {\n try {\n l(next)\n } catch (err) {\n console.warn(`${LOG_TAG}: connection listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction extractUnsubscribe(sub: unknown): (() => void) | null {\n const candidates: unknown[] = []\n const s = sub as Record<string, unknown> | null | undefined\n if (s && typeof s === \"object\") {\n candidates.push(s)\n candidates.push((s.value as Record<string, unknown>)?.subscription)\n candidates.push((s.data as Record<string, unknown>)?.subscription)\n candidates.push(s.subscription)\n }\n for (const c of candidates) {\n const unsub = (c as {unsubscribe?: unknown})?.unsubscribe\n if (typeof unsub === \"function\") return unsub as () => void\n }\n return null\n}\n\nfunction ensureAuthWatch(): void {\n if (authStateUnsubscribe) return\n authStateUnsubscribe = () => {}\n\n const auth = getAuth()\n if (!auth?.onStateChange) return\n\n let reconnectPending = false\n try {\n const sub = auth.onStateChange((event, session) => {\n if (!session?.token) return\n if (connected || reconnectPending) return\n\n reconnectPending = true\n console.log(`${LOG_TAG}: auth session available (${event}) while disconnected — reconnecting`)\n try {\n cloudClientService.reconnect()\n } finally {\n setTimeout(() => {\n reconnectPending = false\n }, 0)\n }\n })\n\n const unsub = extractUnsubscribe(sub)\n if (unsub) authStateUnsubscribe = unsub\n } catch (err) {\n console.warn(`${LOG_TAG}: auth watch subscribe failed: ${(err as Error)?.message ?? err}`)\n }\n}\n\nfunction stopAuthWatch(): void {\n authStateUnsubscribe?.()\n authStateUnsubscribe = null\n}\n\nfunction emitTranscript(data: TranscriptionData): void {\n for (const l of transcriptListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: transcript listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitTranslation(data: TranslationData): void {\n for (const l of translationListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: translation listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitStatus(snapshot: CloudClientStatusSnapshot): void {\n for (const l of statusListeners) {\n try {\n l(snapshot)\n } catch (err) {\n console.warn(`${LOG_TAG}: status listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction ensureTransports(): void {\n if (transportsReady) return\n transportsReady = true\n setNativeUdp(() => createCloudUdpSocket())\n setSecureStorage(cloudSecureStore)\n}\n\nfunction clearRuntimeEventSubscriptions(): void {\n runtimeStatusUnsubscribe?.()\n runtimeStatusUnsubscribe = null\n transcriptUnsubscribe?.()\n transcriptUnsubscribe = null\n translationUnsubscribe?.()\n translationUnsubscribe = null\n}\n\nfunction startLc3FrameSizeWatcher(): void {\n if (lc3FrameSizeUnsubscribe) return\n\n let last = frameSizeBytes()\n lc3FrameSizeUnsubscribe = useSettingsStore.subscribe(\n (state) => state.getSetting(SETTINGS.lc3_frame_size.key),\n () => {\n const next = frameSizeBytes()\n if (next === last) return\n last = next\n if (!client) return\n console.log(`${LOG_TAG}: LC3 frame size changed to ${next}; reconnecting runtime`)\n cloudClientService.reconnect()\n },\n )\n}\n\nfunction stopLc3FrameSizeWatcher(): void {\n lc3FrameSizeUnsubscribe?.()\n lc3FrameSizeUnsubscribe = null\n}\n\nfunction construct(): void {\n ensureTransports()\n\n const endpoints = resolveEndpoints()\n console.log(`${LOG_TAG}: endpoints ${JSON.stringify(endpoints)}`)\n\n const coreAuth = {getSubjectToken}\n const auth = shouldUseLocalDevRuntimeToken(endpoints)\n ? {\n core: coreAuth,\n runtime: {getToken: (opts?: {forceRefresh?: boolean}) => getLocalDevRuntimeToken(endpoints.runtime, opts)},\n }\n : {core: coreAuth, runtime: {source: \"core\" as const}}\n\n client = new CloudClient({\n endpoints,\n // The phone LC3-encodes mic audio (even in phone/simulated mode); announce\n // LC3 at 16 kHz with the frame size the encoder emits.\n audio: {codec: \"lc3\", sampleRate: 16000, frameSizeBytes: frameSizeBytes()},\n auth,\n logger: cloudLogger,\n })\n\n const c = client\n clearRuntimeEventSubscriptions()\n runtimeStatusUnsubscribe = c.runtime.onStatusChanged((status) => {\n if (c !== client) return\n setRuntimeStatus(status)\n })\n transcriptUnsubscribe = c.runtime.onTranscript((data) => {\n if (c !== client) return\n logCloudV2TranscriptMetric(data)\n emitTranscript(data)\n })\n translationUnsubscribe = c.runtime.onTranslation((data) => {\n if (c !== client) return\n emitTranslation(data)\n })\n setRuntimeStatus(c.runtime.getStatus())\n\n c.runtime.onConnected(() => {\n if (c !== client) return\n connected = true\n console.log(`${LOG_TAG}: runtime connected`)\n // Cloud is up — cancel any pending persistent-failure alarm and re-arm for the\n // next outage.\n clearPersistentFailureAlarm()\n // Re-apply the authoritative subscription set, including the empty set, so\n // a fresh phone launch clears any stale server-side audio subscriptions.\n c.runtime\n .setSubscriptions(audioSubscriptions)\n .catch((err) =>\n console.warn(`${LOG_TAG}: re-applying queued subscriptions failed: ${(err as Error)?.message ?? err}`),\n )\n notifyConnectionListeners(true)\n })\n c.runtime.onDisconnected((info) => {\n if (c !== client) return\n connected = false\n console.log(`${LOG_TAG}: runtime disconnected (${info.reason})`)\n // Arm the persistent-failure alarm once; if we're still down when it fires, raise\n // the notification. A reconnect within the window cancels it (onConnected above).\n if (!persistentFailureTimer && !persistentFailureNotified) {\n persistentFailureTimer = BgTimer.setTimeout(() => {\n persistentFailureTimer = null\n if (connected) return\n persistentFailureNotified = true\n islandNotifications.emit({\n kind: \"connection_failed_persistent\",\n reason: `Cloud session has been disconnected for over ${Math.round(CLOUD_PERSISTENT_FAILURE_MS / 1000)}s`,\n metadata: {downForMs: CLOUD_PERSISTENT_FAILURE_MS, lastReason: info.reason},\n timestamp: Date.now(),\n })\n }, CLOUD_PERSISTENT_FAILURE_MS)\n }\n notifyConnectionListeners(false)\n })\n c.runtime.onError((err) => {\n console.warn(`${LOG_TAG}: runtime error: ${err.code}`)\n })\n\n // Best-effort connect. Do not crash the app if the dev cloud is unreachable.\n c.runtime\n .connect()\n .then(() => console.log(`${LOG_TAG}: connect() resolved`))\n .catch((err) => console.warn(`${LOG_TAG}: connect() failed: ${err?.message ?? err}`))\n\n syncCoreAccessTokenToBluetooth().catch((err) =>\n console.warn(`${LOG_TAG}: initial Bluetooth core_token sync failed: ${(err as Error)?.message ?? err}`),\n )\n\n startLc3FrameSizeWatcher()\n}\n\n/**\n * engine's cloud client. Owns the singleton CloudClient, its connection state,\n * and the runtime-hook wiring.\n */\nexport const cloudClientService = {\n /**\n * Construct (once) + connect the client. Idempotent. Best-effort connect — a\n * failure is logged and the app keeps running. Requires\n * `engine.configure({auth, config})` first.\n */\n init(): void {\n if (client) return\n ensureAuthWatch()\n construct()\n },\n\n /**\n * Tear down + rebuild. Pass new endpoints to switch URLs; pass `null` to CLEAR\n * a prior override and fall back to the boot config (so cleared/default cloud\n * URLs don't keep reconnecting to a stale override); omit to keep the current.\n */\n reconnect(endpoints?: {core: string; runtime: string} | null): void {\n if (endpoints !== undefined) endpointsOverride = endpoints\n try {\n client?.runtime.close()\n } catch (err) {\n console.warn(`${LOG_TAG}: reconnect close() failed: ${(err as Error)?.message ?? err}`)\n }\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n\n const wasConnected = connected\n client = null\n localDevRuntimeToken = null\n connected = false\n resetRuntimeStatus()\n if (wasConnected) notifyConnectionListeners(false)\n\n construct()\n },\n\n async getPreinstalledMiniappRegistry(): Promise<PreinstalledMiniappRegistry> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.miniapps.getRegistry()\n },\n\n async getMiniappAuthToken(\n packageName: string,\n opts?: {minTtlMs?: number; devAttestation?: string},\n ): Promise<MiniappAuthToken> {\n if (!client) this.init()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n const {token, expiresAt} = await c.auth.getMiniappToken(packageName, opts)\n const identity = c.auth.identity\n return {\n mentraUserId: identity.mentraUserId,\n tenantId: identity.tenantId,\n token,\n expiresAt: normalizeExpiresAt(expiresAt),\n }\n },\n\n /** Tear down the client + connection (the engine.stop() lifecycle). */\n stop(): void {\n try {\n client?.runtime.close()\n } catch (err) {\n console.warn(`${LOG_TAG}: stop close() failed: ${(err as Error)?.message ?? err}`)\n }\n stopLc3FrameSizeWatcher()\n stopAuthWatch()\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n const wasConnected = connected\n client = null\n localDevRuntimeToken = null\n connected = false\n resetRuntimeStatus()\n if (wasConnected) notifyConnectionListeners(false)\n },\n\n /** Device-side managed photo (cloud-v2): presign now, deliver bytes, await ready. */\n startManagedPhoto(opts: Record<string, unknown> = {}) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.startManagedPhoto(opts)\n },\n awaitManagedPhotoReady(requestId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.awaitManagedPhotoReady(requestId)\n },\n\n /** Managed stream (cloud-v2): provision ingest+playback on the runtime. */\n startManagedStream(opts: Record<string, unknown> = {}) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.startManagedStream(opts)\n },\n getManagedStreamStatus(streamId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.getManagedStreamStatus(streamId)\n },\n stopManagedStream(streamId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.stopManagedStream(streamId)\n },\n\n /** Current live-session connection state (handshake completed). */\n isConnected(): boolean {\n return connected\n },\n\n /** Subscribe to connection-state transitions. Returns an unsubscribe fn. */\n onConnectionChange(listener: (connected: boolean) => void): () => void {\n connectionListeners.add(listener)\n return () => {\n connectionListeners.delete(listener)\n }\n },\n\n /** Replace the v2 cloud's audio subscription set for the live session. */\n async setSubscriptions(subs: AudioSubscription[]): Promise<void> {\n // Cache unconditionally so the desired set survives a not-yet-connected\n // session and reconnects; the onConnected handler re-applies the cached set.\n audioSubscriptions = subs\n const c = client\n if (connected && c) {\n await c.runtime.setSubscriptions(subs)\n }\n },\n\n sendAudioFrame(frame: Uint8Array): void {\n client?.runtime.sendAudioFrame(frame)\n },\n\n onTranscript(cb: (d: TranscriptionData) => void): () => void {\n transcriptListeners.add(cb)\n return () => {\n transcriptListeners.delete(cb)\n }\n },\n\n onTranslation(cb: (d: TranslationData) => void): () => void {\n translationListeners.add(cb)\n return () => {\n translationListeners.delete(cb)\n }\n },\n\n getStatus(): CloudClientStatusSnapshot {\n return currentRuntimeStatus()\n },\n\n getCoreUrl(): string {\n return resolveEndpoints().core\n },\n\n syncCoreTokenToBluetooth(): Promise<string> {\n return syncCoreAccessTokenToBluetooth()\n },\n\n onStatusChanged(cb: (snapshot: CloudClientStatusSnapshot) => void): () => void {\n statusListeners.add(cb)\n return () => {\n statusListeners.delete(cb)\n }\n },\n\n tts: {\n speak(text: string, options?: Parameters<CloudClient[\"runtime\"][\"tts\"][\"speak\"]>[1]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.tts.speak(text, options)\n },\n },\n\n maps: {\n directions(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"directions\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.directions(req)\n },\n reverseGeocode(coord: Parameters<CloudClient[\"runtime\"][\"maps\"][\"reverseGeocode\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.reverseGeocode(coord)\n },\n placeAutocomplete(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"placeAutocomplete\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.placeAutocomplete(req)\n },\n placeDetails(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"placeDetails\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.placeDetails(req)\n },\n },\n\n core: {\n reports: {\n submit(...args: Parameters<CloudCore[\"reports\"][\"submit\"]>) {\n return getCoreClient().reports.submit(...args)\n },\n addLogs(...args: Parameters<CloudCore[\"reports\"][\"addLogs\"]>) {\n return getCoreClient().reports.addLogs(...args)\n },\n addScreenshots(...args: Parameters<CloudCore[\"reports\"][\"addScreenshots\"]>) {\n return getCoreClient().reports.addScreenshots(...args)\n },\n complete(...args: Parameters<CloudCore[\"reports\"][\"complete\"]>) {\n return getCoreClient().reports.complete(...args)\n },\n },\n },\n\n hasAudioSubscriptions(): boolean {\n return audioSubscriptions.length > 0\n },\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CloudClientService.js","sourceRoot":"","sources":["../../src/services/CloudClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAC,MAAM,mCAAmC,CAAA;AAG5G,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AAGrC,OAAO,YAAY,MAAM,gCAAgC,CAAA;AACzD,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,EAAC,OAAO,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAE7D,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAC,gBAAgB,EAAC,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,0BAA0B,EA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C7E,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;YAC1D,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;QAC9C,CAAC;KACF;IAED,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,MAAM,CAAC,GAAG,IAAgD;gBACxD,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;YAChD,CAAC;YACD,OAAO,CAAC,GAAG,IAAiD;gBAC1D,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;YACjD,CAAC;YACD,cAAc,CAAC,GAAG,IAAwD;gBACxE,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAA;YACxD,CAAC;YACD,QAAQ,CAAC,GAAG,IAAkD;gBAC5D,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAA;YAClD,CAAC;SACF;QACD,cAAc,EAAE;YACd,MAAM,CAAC,GAAG,IAAuD;gBAC/D,OAAO,aAAa,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;YACvD,CAAC;SACF;KACF;IAED,qBAAqB;QACnB,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAA;IACtC,CAAC;CACF,CAAA","sourcesContent":["/**\n * Owns the singleton `@mentra/cloud-client` (CloudClient) for the engine runtime\n * — the keystone move that pulls backend comms INTO engine.\n *\n * engine constructs the client from engine-owned pieces (the native UDP socket,\n * the MMKV secure store, the cloud-status store) plus the two things the host\n * provides through the engine front door: `auth.getSubjectToken` (the one\n * permanent seam — the OEM owns login) and the resolved cloud endpoints\n * (`config.coreUrl/runtimeUrl`, computed host-side from dev/settings). On init it\n * exposes cloud runtime methods directly from this service, so the host no longer\n * injects a cloud adapter — engine owns construction and wiring.\n *\n * The local-miniapp path drives the cloud's transcription/translation through\n * this service.\n */\nimport {CloudClient, setNativeHttp, setNativeUdp, setSecureStorage} from \"@mentra/cloud-client/react-native\"\nimport type {PreinstalledMiniappRegistry, RuntimeSnapshot} from \"@mentra/cloud-client/react-native\"\nimport type {SubjectTokenType} from \"@mentra/cloud-client\"\nimport {Platform} from \"react-native\"\nimport type {AudioSubscription, TranscriptionData, TranslationData} from \"@mentra/cloud-protocol\"\n\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport CrustModule from \"@mentra/crust\"\nimport {getAuth, getConfigValues} from \"../runtime/bootstrap\"\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\nimport {type CloudClientStatusSnapshot, type MiniappAuthToken} from \"../runtime/config\"\nimport {createCloudUdpSocket} from \"../utils/cloudClient/RnUdpAdapter\"\nimport {cloudSecureStore} from \"../utils/cloudClient/cloudSecureStore\"\nimport {storage as mmkvStorage} from \"../utils/storage\"\nimport {useCloudClientStatusStore} from \"../stores/cloudClientStatus\"\nimport {islandNotifications} from \"./NotificationsEmitter\"\nimport {BgTimer} from \"../utils/timers\"\nimport {logCloudV2TranscriptMetric} from \"./CloudTranscriptE2EMetrics\"\nimport {LocalMiniappUserIdentity} from \"./LocalMiniappUserIdentity\"\nimport {nativeHttpResponseBody} from \"./NativeHttpResponse\"\n\nconst LOG_TAG = \"cloudClient\"\ntype CloudCore = NonNullable<CloudClient[\"core\"]>\n\n// Persistent cloud-disconnect detector: the cloud-client reconnect loop is infinite\n// and never surfaces a \"giving up\" signal, so \"persistent failure\" = the session has\n// been continuously NOT connected for this long. A quick reconnect cancels it; brief\n// flaps that recover don't fire. Raised as engine.notifications(connection_failed_persistent).\nconst CLOUD_PERSISTENT_FAILURE_MS = 60_000\nconst LOCAL_MINIAPP_USER_ID_KEY = \"mentra.localMiniapp.userId\"\n\n/** Cancel the pending persistent-failure alarm + re-arm for the next outage. */\nfunction clearPersistentFailureAlarm(): void {\n if (persistentFailureTimer) {\n BgTimer.clearTimeout(persistentFailureTimer)\n persistentFailureTimer = null\n }\n persistentFailureNotified = false\n}\n\ntype Lc3FrameSizeBytes = 20 | 40 | 60\n\n// Neutral last-ditch fallbacks (reachable under `adb reverse`) for when the host\n// passes no endpoints. The host normally resolves the real URLs (dev override /\n// Metro host / env) and hands them in via `engine.configure({config})`.\nconst FALLBACK_CORE_URL = \"http://localhost:3000\"\nconst FALLBACK_RUNTIME_URL = \"http://localhost:3001\"\nconst LOCAL_AUTH_PORT = 3002\n\nlet client: CloudClient | null = null\nlet connected = false\nlet persistentFailureTimer: ReturnType<typeof BgTimer.setTimeout> | null = null\nlet persistentFailureNotified = false\nlet audioSubscriptions: AudioSubscription[] = []\nlet transportsReady = false\n/** Endpoints to build with — seeded from config, overridable via reconnect(). */\nlet endpointsOverride: {core: string; runtime: string} | null = null\nlet runtimeStatusUnsubscribe: (() => void) | null = null\nlet transcriptUnsubscribe: (() => void) | null = null\nlet translationUnsubscribe: (() => void) | null = null\nlet authStateUnsubscribe: (() => void) | null = null\nlet localDevRuntimeToken: {runtimeUrl: string; token: string; expiresAtMs: number} | null = null\nlet lc3FrameSizeUnsubscribe: (() => void) | null = null\nlet coreTokenSyncPromise: Promise<string> | null = null\n\nconst localMiniappUserIdentity = new LocalMiniappUserIdentity({\n get(): string | null {\n const result = mmkvStorage.load<string>(LOCAL_MINIAPP_USER_ID_KEY)\n return result.is_ok() ? result.value : null\n },\n set(userId: string): void {\n const result = mmkvStorage.save(LOCAL_MINIAPP_USER_ID_KEY, userId)\n if (result.is_error()) throw result.error\n },\n remove(): void {\n const result = mmkvStorage.remove(LOCAL_MINIAPP_USER_ID_KEY)\n if (result.is_error()) throw result.error\n },\n})\n\nconst transcriptListeners = new Set<(d: TranscriptionData) => void>()\nconst translationListeners = new Set<(d: TranslationData) => void>()\nconst statusListeners = new Set<(snapshot: CloudClientStatusSnapshot) => void>()\nconst connectionListeners = new Set<(connected: boolean) => void>()\n\nfunction resolveEndpoints(): {core: string; runtime: string} {\n if (endpointsOverride) return endpointsOverride\n const cfg = getConfigValues()\n return {\n core: cfg.coreUrl?.trim() || FALLBACK_CORE_URL,\n runtime: cfg.runtimeUrl?.trim() || FALLBACK_RUNTIME_URL,\n }\n}\n\nfunction getCoreClient(): CloudCore {\n if (!client) construct()\n const core = client?.core\n if (!core) throw new Error(\"cloud client core not configured\")\n return core\n}\n\nfunction syncCoreAccessTokenToBluetooth(): Promise<string> {\n if (coreTokenSyncPromise) return coreTokenSyncPromise\n\n coreTokenSyncPromise = syncCoreAccessTokenToBluetoothInternal().finally(() => {\n coreTokenSyncPromise = null\n })\n return coreTokenSyncPromise\n}\n\nasync function syncCoreAccessTokenToBluetoothInternal(): Promise<string> {\n if (!client) construct()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n const token = await c.auth.getCoreToken()\n if (c !== client) {\n throw new Error(\"cloud client changed while syncing core token\")\n }\n localMiniappUserIdentity.remember(c.auth.identity.mentraUserId)\n const result = await useSettingsStore.getState().setSetting(SETTINGS.core_token.key, token, false)\n if (result.is_error()) {\n throw result.error\n }\n\n try {\n await BluetoothSdk.updateBluetoothSettings({[SETTINGS.core_token.key]: token})\n } catch (err) {\n console.warn(`${LOG_TAG}: direct Bluetooth core_token sync failed: ${(err as Error)?.message ?? err}`)\n }\n\n return token\n}\n\nfunction frameSizeBytes(): Lc3FrameSizeBytes {\n // Read LIVE from the engine settings store (the source of truth) so a\n // reconnect after a glasses swap (G1=20 ↔ G2=40) picks up the new frame size,\n // not the one-time engine.configure({config}) snapshot. Falls back to the\n // config value (set at boot) then 20 when the setting is unset.\n const fromSettings = useSettingsStore.getState().getSetting(SETTINGS.lc3_frame_size.key)\n const size = fromSettings ?? getConfigValues().audioFrameSizeBytes\n return size === 20 || size === 40 || size === 60 ? size : 20\n}\n\nasync function getSubjectToken(): Promise<{token: string; type: SubjectTokenType}> {\n const a = getAuth()\n if (!a) throw new Error(\"cloudClient: engine.configure({auth}) not called\")\n const r = await a.getSubjectToken()\n // IslandAuth's SubjectTokenType is intentionally open (`string & {}`) so OEMs\n // can use other token kinds; cloud-client's is a closed union. The host's\n // actual value (\"supabase\") is valid — narrow at this boundary.\n return {token: r.token, type: r.type as SubjectTokenType}\n}\n\nfunction normalizeExpiresAt(expiresAt: number): number {\n return expiresAt < 10_000_000_000 ? expiresAt * 1000 : expiresAt\n}\n\nfunction shouldUseLocalDevRuntimeToken(endpoints: {runtime: string}): boolean {\n if (!__DEV__) return false\n try {\n const host = new URL(endpoints.runtime).hostname\n return host === \"localhost\" || host === \"127.0.0.1\" || host === \"10.0.2.2\"\n } catch {\n return false\n }\n}\n\nasync function getLocalDevRuntimeToken(runtimeEndpoint: string, opts?: {forceRefresh?: boolean}): Promise<string> {\n const now = Date.now()\n if (\n !opts?.forceRefresh &&\n localDevRuntimeToken?.runtimeUrl === runtimeEndpoint &&\n localDevRuntimeToken.expiresAtMs - now > 60_000\n ) {\n return localDevRuntimeToken.token\n }\n\n const base = new URL(runtimeEndpoint)\n base.port = String(LOCAL_AUTH_PORT)\n base.pathname = \"/api/dev/runtime-token\"\n base.search = new URLSearchParams({userId: \"local-phone-user\", tenantId: \"mentra\"}).toString()\n\n const res = await fetch(base.toString())\n if (!res.ok) {\n throw new Error(`cloudClient: local dev runtime token failed (${res.status})`)\n }\n const body = (await res.json()) as {access_token?: string; expires_in?: number}\n if (!body.access_token) {\n throw new Error(\"cloudClient: local dev runtime token response missing access_token\")\n }\n localDevRuntimeToken = {\n runtimeUrl: runtimeEndpoint,\n token: body.access_token,\n expiresAtMs: now + (body.expires_in ?? 300) * 1000,\n }\n return body.access_token\n}\n\nfunction toCloudClientStatusSnapshot(snapshot: RuntimeSnapshot): CloudClientStatusSnapshot {\n return {status: snapshot.status, audioTransport: snapshot.audioTransport}\n}\n\nfunction currentRuntimeStatus(): CloudClientStatusSnapshot {\n const state = useCloudClientStatusStore.getState()\n return {status: state.status, audioTransport: state.audioTransport}\n}\n\nfunction setRuntimeStatus(snapshot: RuntimeSnapshot): void {\n useCloudClientStatusStore.getState().setSnapshot(snapshot)\n emitStatus(toCloudClientStatusSnapshot(snapshot))\n}\n\nfunction resetRuntimeStatus(): void {\n useCloudClientStatusStore.getState().reset()\n emitStatus(currentRuntimeStatus())\n}\n\nfunction stringifyMeta(meta: unknown): string {\n if (!meta || typeof meta !== \"object\") return \"\"\n try {\n return ` ${JSON.stringify(meta)}`\n } catch {\n return \"\"\n }\n}\n\nconst cloudLogger = {\n debug: (msg: string, meta?: unknown) => console.log(`${LOG_TAG}: debug: ${msg}${stringifyMeta(meta)}`),\n info: (msg: string, meta?: unknown) => console.log(`${LOG_TAG}: info: ${msg}${stringifyMeta(meta)}`),\n warn: (msg: string, meta?: unknown) => console.warn(`${LOG_TAG}: warn: ${msg}${stringifyMeta(meta)}`),\n error: (msg: string, meta?: unknown) => console.warn(`${LOG_TAG}: error: ${msg}${stringifyMeta(meta)}`),\n}\n\nfunction notifyConnectionListeners(next: boolean): void {\n for (const l of connectionListeners) {\n try {\n l(next)\n } catch (err) {\n console.warn(`${LOG_TAG}: connection listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction extractUnsubscribe(sub: unknown): (() => void) | null {\n const candidates: unknown[] = []\n const s = sub as Record<string, unknown> | null | undefined\n if (s && typeof s === \"object\") {\n candidates.push(s)\n candidates.push((s.value as Record<string, unknown>)?.subscription)\n candidates.push((s.data as Record<string, unknown>)?.subscription)\n candidates.push(s.subscription)\n }\n for (const c of candidates) {\n const unsub = (c as {unsubscribe?: unknown})?.unsubscribe\n if (typeof unsub === \"function\") return unsub as () => void\n }\n return null\n}\n\nfunction ensureAuthWatch(): void {\n if (authStateUnsubscribe) return\n authStateUnsubscribe = () => {}\n\n const auth = getAuth()\n if (!auth?.onStateChange) return\n\n let reconnectPending = false\n try {\n const sub = auth.onStateChange((event, session) => {\n if (event === \"SIGNED_OUT\") {\n localMiniappUserIdentity.forget()\n return\n }\n // A new sign-in may belong to a different account. Force the next\n // storage request to resolve and persist that account's Core identity.\n if (event === \"SIGNED_IN\") localMiniappUserIdentity.forget()\n if (!session?.token) return\n if (connected || reconnectPending) return\n\n reconnectPending = true\n console.log(`${LOG_TAG}: auth session available (${event}) while disconnected — reconnecting`)\n try {\n cloudClientService.reconnect()\n } finally {\n setTimeout(() => {\n reconnectPending = false\n }, 0)\n }\n })\n\n const unsub = extractUnsubscribe(sub)\n if (unsub) authStateUnsubscribe = unsub\n } catch (err) {\n console.warn(`${LOG_TAG}: auth watch subscribe failed: ${(err as Error)?.message ?? err}`)\n }\n}\n\nfunction stopAuthWatch(): void {\n authStateUnsubscribe?.()\n authStateUnsubscribe = null\n}\n\nfunction emitTranscript(data: TranscriptionData): void {\n for (const l of transcriptListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: transcript listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitTranslation(data: TranslationData): void {\n for (const l of translationListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: translation listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitStatus(snapshot: CloudClientStatusSnapshot): void {\n for (const l of statusListeners) {\n try {\n l(snapshot)\n } catch (err) {\n console.warn(`${LOG_TAG}: status listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction ensureTransports(): void {\n if (transportsReady) return\n transportsReady = true\n setNativeUdp(() => createCloudUdpSocket())\n setSecureStorage(cloudSecureStore)\n if (Platform.OS !== \"android\") return\n setNativeHttp(async (input, init) => {\n if (typeof input !== \"string\" || (init?.body != null && typeof init.body !== \"string\")) {\n return globalThis.fetch(input, init)\n }\n const headers = Object.fromEntries(new Headers(init?.headers).entries())\n const result = await CrustModule.nativeHttpRequest(\n init?.method ?? \"GET\",\n input,\n headers,\n (init?.body as string | undefined) ?? null,\n )\n return new Response(nativeHttpResponseBody(result.status, result.body), {\n status: result.status,\n statusText: result.statusText,\n headers: result.headers,\n })\n })\n}\n\nfunction clearRuntimeEventSubscriptions(): void {\n runtimeStatusUnsubscribe?.()\n runtimeStatusUnsubscribe = null\n transcriptUnsubscribe?.()\n transcriptUnsubscribe = null\n translationUnsubscribe?.()\n translationUnsubscribe = null\n}\n\nfunction startLc3FrameSizeWatcher(): void {\n if (lc3FrameSizeUnsubscribe) return\n\n let last = frameSizeBytes()\n lc3FrameSizeUnsubscribe = useSettingsStore.subscribe(\n (state) => state.getSetting(SETTINGS.lc3_frame_size.key),\n () => {\n const next = frameSizeBytes()\n if (next === last) return\n last = next\n if (!client) return\n console.log(`${LOG_TAG}: LC3 frame size changed to ${next}; reconnecting runtime`)\n cloudClientService.reconnect()\n },\n )\n}\n\nfunction stopLc3FrameSizeWatcher(): void {\n lc3FrameSizeUnsubscribe?.()\n lc3FrameSizeUnsubscribe = null\n}\n\nfunction construct(): void {\n ensureTransports()\n\n const endpoints = resolveEndpoints()\n console.log(`${LOG_TAG}: endpoints ${JSON.stringify(endpoints)}`)\n\n const coreAuth = {getSubjectToken}\n const auth = shouldUseLocalDevRuntimeToken(endpoints)\n ? {\n core: coreAuth,\n runtime: {getToken: (opts?: {forceRefresh?: boolean}) => getLocalDevRuntimeToken(endpoints.runtime, opts)},\n }\n : {core: coreAuth, runtime: {source: \"core\" as const}}\n\n client = new CloudClient({\n endpoints,\n // The phone LC3-encodes mic audio (even in phone/simulated mode); announce\n // LC3 at 16 kHz with the frame size the encoder emits.\n audio: {codec: \"lc3\", sampleRate: 16000, frameSizeBytes: frameSizeBytes()},\n auth,\n timers: {\n setTimeout: (callback, delayMs) => BgTimer.setTimeout(callback, delayMs),\n clearTimeout: (handle) => BgTimer.clearTimeout(handle as number),\n setInterval: (callback, intervalMs) => BgTimer.setInterval(callback, intervalMs),\n clearInterval: (handle) => BgTimer.clearInterval(handle as number),\n },\n logger: cloudLogger,\n })\n\n const c = client\n clearRuntimeEventSubscriptions()\n runtimeStatusUnsubscribe = c.runtime.onStatusChanged((status) => {\n if (c !== client) return\n setRuntimeStatus(status)\n })\n transcriptUnsubscribe = c.runtime.onTranscript((data) => {\n if (c !== client) return\n logCloudV2TranscriptMetric(data)\n emitTranscript(data)\n })\n translationUnsubscribe = c.runtime.onTranslation((data) => {\n if (c !== client) return\n emitTranslation(data)\n })\n setRuntimeStatus(c.runtime.getStatus())\n\n c.runtime.onConnected(() => {\n if (c !== client) return\n connected = true\n console.log(`${LOG_TAG}: runtime connected`)\n console.log(`${LOG_TAG}: debug: ws-session-debug connected`)\n // Cloud is up — cancel any pending persistent-failure alarm and re-arm for the\n // next outage.\n clearPersistentFailureAlarm()\n // Re-apply the authoritative subscription set, including the empty set, so\n // a fresh phone launch clears any stale server-side audio subscriptions.\n c.runtime\n .setSubscriptions(audioSubscriptions)\n .catch((err) =>\n console.warn(`${LOG_TAG}: re-applying queued subscriptions failed: ${(err as Error)?.message ?? err}`),\n )\n notifyConnectionListeners(true)\n })\n c.runtime.onDisconnected((info) => {\n if (c !== client) return\n connected = false\n console.log(`${LOG_TAG}: runtime disconnected (${info.reason})`)\n console.log(\n `${LOG_TAG}: debug: ws-session-debug disconnected reason=${info.reason} willStayDown=${/superseded by newer session/i.test(info.reason)}`,\n )\n // Arm the persistent-failure alarm once; if we're still down when it fires, raise\n // the notification. A reconnect within the window cancels it (onConnected above).\n if (!persistentFailureTimer && !persistentFailureNotified) {\n persistentFailureTimer = BgTimer.setTimeout(() => {\n persistentFailureTimer = null\n if (connected) return\n persistentFailureNotified = true\n islandNotifications.emit({\n kind: \"connection_failed_persistent\",\n reason: `Cloud session has been disconnected for over ${Math.round(CLOUD_PERSISTENT_FAILURE_MS / 1000)}s`,\n metadata: {downForMs: CLOUD_PERSISTENT_FAILURE_MS, lastReason: info.reason},\n timestamp: Date.now(),\n })\n }, CLOUD_PERSISTENT_FAILURE_MS)\n }\n notifyConnectionListeners(false)\n })\n c.runtime.onError((err) => {\n console.warn(`${LOG_TAG}: runtime error: ${err.code}`)\n })\n\n // Best-effort connect. Do not crash the app if the dev cloud is unreachable.\n c.runtime\n .connect()\n .then(() => console.log(`${LOG_TAG}: connect() resolved`))\n .catch((err) => console.warn(`${LOG_TAG}: connect() failed: ${err?.message ?? err}`))\n\n syncCoreAccessTokenToBluetooth().catch((err) =>\n console.warn(`${LOG_TAG}: initial Bluetooth core_token sync failed: ${(err as Error)?.message ?? err}`),\n )\n\n startLc3FrameSizeWatcher()\n}\n\n/**\n * engine's cloud client. Owns the singleton CloudClient, its connection state,\n * and the runtime-hook wiring.\n */\nexport const cloudClientService = {\n /**\n * Construct (once) + connect the client. Idempotent. Best-effort connect — a\n * failure is logged and the app keeps running. Requires\n * `engine.configure({auth, config})` first.\n */\n init(): void {\n if (client) return\n ensureAuthWatch()\n construct()\n },\n\n /**\n * Tear down + rebuild. Pass new endpoints to switch URLs; pass `null` to CLEAR\n * a prior override and fall back to the boot config (so cleared/default cloud\n * URLs don't keep reconnecting to a stale override); omit to keep the current.\n */\n reconnect(endpoints?: {core: string; runtime: string} | null): void {\n if (endpoints !== undefined) endpointsOverride = endpoints\n try {\n client?.runtime.close()\n } catch (err) {\n console.warn(`${LOG_TAG}: reconnect close() failed: ${(err as Error)?.message ?? err}`)\n }\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n\n const wasConnected = connected\n client = null\n localDevRuntimeToken = null\n connected = false\n resetRuntimeStatus()\n if (wasConnected) notifyConnectionListeners(false)\n\n construct()\n },\n\n async getPreinstalledMiniappRegistry(): Promise<PreinstalledMiniappRegistry> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.miniapps.getRegistry()\n },\n\n /**\n * Resolve the stable Core-owned Mentra user id.\n *\n * Storage must use this identity rather than the short-lived Core access\n * token. A previously verified id is restored from MMKV so local miniapps\n * remain available after an offline process restart. On first sign-in,\n * callers join the auth module's single-flight exchange/refresh instead of\n * falling back to an anonymous namespace.\n */\n async resolveMentraUserId(): Promise<string> {\n return localMiniappUserIdentity.resolve(async () => {\n if (!client) this.init()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n await c.auth.getCoreToken()\n if (c !== client) throw new Error(\"cloud client changed while resolving user identity\")\n return c.auth.identity.mentraUserId\n })\n },\n\n /** Read the stable Mentra user id after async identity resolution. */\n getMentraUserId(): string {\n const userId = localMiniappUserIdentity.get()\n if (!userId) throw new Error(\"Mentra user identity is unavailable\")\n return userId\n },\n\n async getMiniappAuthToken(\n packageName: string,\n opts?: {minTtlMs?: number; devAttestation?: string},\n ): Promise<MiniappAuthToken> {\n if (!client) this.init()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n const {token, expiresAt} = await c.auth.getMiniappToken(packageName, opts)\n const identity = c.auth.identity\n return {\n mentraUserId: identity.mentraUserId,\n tenantId: identity.tenantId,\n token,\n expiresAt: normalizeExpiresAt(expiresAt),\n }\n },\n\n /** Tear down the client + connection (the engine.stop() lifecycle). */\n stop(): void {\n try {\n client?.runtime.close()\n } catch (err) {\n console.warn(`${LOG_TAG}: stop close() failed: ${(err as Error)?.message ?? err}`)\n }\n stopLc3FrameSizeWatcher()\n stopAuthWatch()\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n const wasConnected = connected\n client = null\n // stop() is part of the logout lifecycle and runs before the host emits\n // SIGNED_OUT. Remove the persisted namespace owner here so a later account\n // can never inherit it. A force-stop/process kill does not call stop(), so\n // the cached id still survives the offline cold-start case.\n localMiniappUserIdentity.forget()\n localDevRuntimeToken = null\n connected = false\n resetRuntimeStatus()\n if (wasConnected) notifyConnectionListeners(false)\n },\n\n /** Device-side managed photo (cloud-v2): presign now, deliver bytes, await ready. */\n startManagedPhoto(opts: Record<string, unknown> = {}) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.startManagedPhoto(opts)\n },\n awaitManagedPhotoReady(requestId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.awaitManagedPhotoReady(requestId)\n },\n\n /** Managed stream (cloud-v2): provision ingest+playback on the runtime. */\n startManagedStream(opts: Record<string, unknown> = {}) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.startManagedStream(opts)\n },\n getManagedStreamStatus(streamId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.getManagedStreamStatus(streamId)\n },\n stopManagedStream(streamId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.stopManagedStream(streamId)\n },\n\n /** Current live-session connection state (handshake completed). */\n isConnected(): boolean {\n return connected\n },\n\n /** Subscribe to connection-state transitions. Returns an unsubscribe fn. */\n onConnectionChange(listener: (connected: boolean) => void): () => void {\n connectionListeners.add(listener)\n return () => {\n connectionListeners.delete(listener)\n }\n },\n\n /** Replace the v2 cloud's audio subscription set for the live session. */\n async setSubscriptions(subs: AudioSubscription[]): Promise<void> {\n // Cache unconditionally so the desired set survives a not-yet-connected\n // session and reconnects; the onConnected handler re-applies the cached set.\n audioSubscriptions = subs\n const c = client\n if (connected && c) {\n await c.runtime.setSubscriptions(subs)\n }\n },\n\n sendAudioFrame(frame: Uint8Array): void {\n client?.runtime.sendAudioFrame(frame)\n },\n\n onTranscript(cb: (d: TranscriptionData) => void): () => void {\n transcriptListeners.add(cb)\n return () => {\n transcriptListeners.delete(cb)\n }\n },\n\n onTranslation(cb: (d: TranslationData) => void): () => void {\n translationListeners.add(cb)\n return () => {\n translationListeners.delete(cb)\n }\n },\n\n getStatus(): CloudClientStatusSnapshot {\n return currentRuntimeStatus()\n },\n\n getCoreUrl(): string {\n return resolveEndpoints().core\n },\n\n syncCoreTokenToBluetooth(): Promise<string> {\n return syncCoreAccessTokenToBluetooth()\n },\n\n onStatusChanged(cb: (snapshot: CloudClientStatusSnapshot) => void): () => void {\n statusListeners.add(cb)\n return () => {\n statusListeners.delete(cb)\n }\n },\n\n tts: {\n speak(text: string, options?: Parameters<CloudClient[\"runtime\"][\"tts\"][\"speak\"]>[1]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.tts.speak(text, options)\n },\n },\n\n maps: {\n directions(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"directions\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.directions(req)\n },\n reverseGeocode(coord: Parameters<CloudClient[\"runtime\"][\"maps\"][\"reverseGeocode\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.reverseGeocode(coord)\n },\n placeAutocomplete(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"placeAutocomplete\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.placeAutocomplete(req)\n },\n placeDetails(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"placeDetails\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.placeDetails(req)\n },\n },\n\n core: {\n reports: {\n submit(...args: Parameters<CloudCore[\"reports\"][\"submit\"]>) {\n return getCoreClient().reports.submit(...args)\n },\n addLogs(...args: Parameters<CloudCore[\"reports\"][\"addLogs\"]>) {\n return getCoreClient().reports.addLogs(...args)\n },\n addScreenshots(...args: Parameters<CloudCore[\"reports\"][\"addScreenshots\"]>) {\n return getCoreClient().reports.addScreenshots(...args)\n },\n complete(...args: Parameters<CloudCore[\"reports\"][\"complete\"]>) {\n return getCoreClient().reports.complete(...args)\n },\n },\n supportProfile: {\n update(...args: Parameters<CloudCore[\"supportProfile\"][\"update\"]>) {\n return getCoreClient().supportProfile.update(...args)\n },\n },\n },\n\n hasAudioSubscriptions(): boolean {\n return audioSubscriptions.length > 0\n },\n}\n"]}
|
|
@@ -153,17 +153,17 @@ export function startDeviceEventRouter() {
|
|
|
153
153
|
subs.push(BluetoothSdk.addListener("head_up", (event) => {
|
|
154
154
|
localMiniappRuntime.forwardEvent("head_up", { position: event.up ? "up" : "down", timestamp: Date.now() });
|
|
155
155
|
}));
|
|
156
|
-
// On-device STT transcripts → local miniapps
|
|
157
|
-
// active
|
|
158
|
-
//
|
|
159
|
-
//
|
|
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
160
|
// (Was MantleManager.handle_local_transcription; its offline-captions display branch
|
|
161
161
|
// went away with the pseudo captions renderer.)
|
|
162
162
|
subs.push(BluetoothSdk.addListener("local_transcription", (event) => {
|
|
163
163
|
if (!localSttFallbackCoordinator.isActive())
|
|
164
164
|
return;
|
|
165
165
|
const lang = event.transcribeLanguage ?? localSttFallbackCoordinator.getActiveLanguage() ?? "en-US";
|
|
166
|
-
localMiniappRuntime.forwardEvent(`transcription:${lang}`, event);
|
|
166
|
+
localMiniappRuntime.forwardEvent(`transcription:${lang}`, event, "local");
|
|
167
167
|
}));
|
|
168
168
|
// --- glasses swipe-menu app launcher (G2) ---
|
|
169
169
|
subs.push(BluetoothSdk.addListener("miniapp_selected", (event) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceEventRouter.js","sourceRoot":"","sources":["../../src/services/DeviceEventRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,YAAY,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AAEvC,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AACvD,OAAO,2BAA2B,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAA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AK,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, but ONLY when local STT fallback is the\n // active engine (cloud STT is down). When the cloud WS is up, cloud transcripts reach\n // miniapps independently via the same forwardEvent, so gating on isActive() avoids\n // double-delivery. 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)\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"]}
|
|
1
|
+
{"version":3,"file":"DeviceEventRouter.js","sourceRoot":"","sources":["../../src/services/DeviceEventRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,YAAY,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AAEvC,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AACvD,OAAO,2BAA2B,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAC,iCAAiC,EAAC,MAAM,mBAAmB,CAAA;AACnE,OAAO,kBAAkB,MAAM,6BAA6B,CAAA;AAC5D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;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,13 @@
|
|
|
1
|
+
export interface ForegroundLocationPermissionResponse {
|
|
2
|
+
status: string;
|
|
3
|
+
}
|
|
4
|
+
export interface ForegroundLocationPermissionClient {
|
|
5
|
+
getForegroundPermissionsAsync(): Promise<ForegroundLocationPermissionResponse>;
|
|
6
|
+
requestForegroundPermissionsAsync(): Promise<ForegroundLocationPermissionResponse>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolve foreground location permission without invoking an Activity-bound
|
|
10
|
+
* Android permission request while the app is backgrounded.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveForegroundLocationPermission(client: ForegroundLocationPermissionClient, getAppState: () => string): Promise<ForegroundLocationPermissionResponse>;
|
|
13
|
+
//# sourceMappingURL=ForegroundLocationPermission.d.ts.map
|