@mentra/engine 0.1.0-dev.0 → 0.1.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -1
- package/build/engine.d.ts +11 -3
- package/build/engine.d.ts.map +1 -1
- package/build/engine.js +7 -2
- 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/gallery.js +1 -1
- package/build/facades/gallery.js.map +1 -1
- package/build/facades/glasses.d.ts +1 -0
- package/build/facades/glasses.d.ts.map +1 -1
- package/build/facades/glasses.js +19 -4
- 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 +11 -2
- package/build/facades/ota.d.ts.map +1 -1
- package/build/facades/ota.js +19 -4
- package/build/facades/ota.js.map +1 -1
- package/build/facades/pairing.d.ts +4 -0
- package/build/facades/pairing.d.ts.map +1 -1
- package/build/facades/pairing.js +10 -8
- 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/index.d.ts +6 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/internal.d.ts +3 -2
- package/build/internal.d.ts.map +1 -1
- package/build/internal.js +2 -1
- package/build/internal.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 +33 -57
- package/build/services/AppRegistry.d.ts.map +1 -1
- package/build/services/AppRegistry.js +193 -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 +94 -14
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
- package/build/services/OtaInstallCoordinator.js +574 -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 +38 -3
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
- package/build/services/OtaUpdateCheckService.js +142 -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.js +2 -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 +22 -11
- 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 +15 -3
- 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/otaManifestUrl.d.ts +2 -0
- package/build/services/otaManifestUrl.d.ts.map +1 -0
- package/build/services/{asgOtaVersionUrl.js → otaManifestUrl.js} +15 -5
- 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 +1 -0
- package/build/types/enums.d.ts.map +1 -1
- package/build/types/enums.js +1 -0
- package/build/types/enums.js.map +1 -1
- package/build/types/hardware.d.ts +1 -0
- package/build/types/hardware.d.ts.map +1 -1
- package/build/types/hardware.js +14 -0
- package/build/types/hardware.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 +25 -15
- package/src/assets/silence.wav +0 -0
- package/src/engine.ts +7 -2
- package/src/facades/dev.ts +17 -12
- package/src/facades/gallery.ts +1 -1
- package/src/facades/glasses.ts +17 -4
- package/src/facades/glassesSettings.ts +5 -0
- package/src/facades/miniapps.ts +7 -0
- package/src/facades/ota.ts +19 -4
- package/src/facades/pairing.ts +11 -7
- package/src/facades/permissions.ts +14 -0
- package/src/facades/phoneNotifications.ts +4 -13
- package/src/index.ts +26 -2
- package/src/internal.ts +3 -1
- 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 +224 -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 +645 -143
- package/src/services/OtaService.ts +11 -5
- package/src/services/OtaUpdateCheckService.ts +180 -20
- 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 +2 -2
- package/src/services/manifestActions.ts +30 -0
- package/src/services/otaDisplayState.ts +57 -16
- package/src/services/otaInstallPolicy.ts +29 -3
- package/src/services/{asgOtaVersionUrl.ts → otaManifestUrl.ts} +16 -4
- 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 +2 -1
- package/src/types/hardware.ts +17 -0
- 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/services/asgOtaVersionUrl.d.ts +0 -2
- package/build/services/asgOtaVersionUrl.d.ts.map +0 -1
- package/build/services/asgOtaVersionUrl.js.map +0 -1
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import displayProcessor from "./DisplayProcessor";
|
|
14
14
|
import BluetoothSdk from "@mentra/bluetooth-sdk/internal";
|
|
15
|
+
import { useDisplayStore } from "../stores/display";
|
|
15
16
|
import { SETTINGS, useSettingsStore } from "../stores/settings";
|
|
16
17
|
import { useGlassesStore } from "../stores/glasses";
|
|
17
18
|
import { DeviceTypes, getModelCapabilities } from "../types";
|
|
@@ -227,6 +228,20 @@ class SceneRenderer {
|
|
|
227
228
|
void Promise.resolve(BluetoothSdk.displayEvent({ view: frame.view, scene: frame })).catch((err) => {
|
|
228
229
|
console.error(`${LOG_TAG}: native scene send failed:`, err);
|
|
229
230
|
});
|
|
231
|
+
// Keep the phone-side glasses mirror on the same frame as native. Legacy
|
|
232
|
+
// layouts update this store in LocalDisplayManager.sendToNative; scene
|
|
233
|
+
// frames bypass that method, so without an explicit write every
|
|
234
|
+
// positioning device (including G2) leaves the mirror blank/stale.
|
|
235
|
+
const caps = this.currentCapabilities();
|
|
236
|
+
useDisplayStore.getState().setDisplayEvent({
|
|
237
|
+
view: frame.view,
|
|
238
|
+
layout: {
|
|
239
|
+
layoutType: "scene",
|
|
240
|
+
width: caps?.width,
|
|
241
|
+
height: caps?.height,
|
|
242
|
+
elements: frame.elements,
|
|
243
|
+
},
|
|
244
|
+
});
|
|
230
245
|
}
|
|
231
246
|
catch (err) {
|
|
232
247
|
console.error(`${LOG_TAG}: native scene send failed:`, err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneRenderer.js","sourceRoot":"","sources":["../../src/services/SceneRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,YAAY,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAC,QAAQ,E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ager owns WHO may draw (arbitration/boot/expiry); this service\n * owns WHAT gets sent for a scene: capabilities lookup, legacy-layout→scene\n * conversion (sugar and old bundles ride the same pipeline), process → diff →\n * SceneFrame emission, retained-scene replay, and the degrade branch for\n * devices that can't position elements.\n *\n * Everything device-specific here is DATA (capability fields, display profile);\n * the code paths are generic. Spec: notes/miniapp-display-render-implementation-spec.md\n */\n\nimport displayProcessor from \"./DisplayProcessor\"\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {DeviceTypes, getModelCapabilities} from \"../types\"\nimport {\n degradeScene,\n diffScene,\n processScene,\n SceneStore,\n type FrameElement,\n type SceneBreakMode,\n type SceneDisplayCapabilities,\n type SceneElementInput,\n type SceneFrame,\n} from \"../utils/display/scene\"\n\nconst LOG_TAG = \"SCENE_RENDERER\"\n\n/** Legacy layout shape (matches DisplayPayload.layout). */\nexport type LegacyLayout = {layoutType: string; [key: string]: unknown}\n\nexport type SceneEmitResult =\n /** A SceneFrame went to native. */\n | {kind: \"scene\"; degraded: boolean; dropped: string[]}\n /** Degrade path: caller routes this legacy layout through the existing pipeline (null layout ⇒ clear). */\n | {kind: \"legacy\"; layout: LegacyLayout | null; degraded: boolean; dropped: string[]}\n /** No display capabilities on the connected device. */\n | {kind: \"no-display\"}\n\nclass SceneRenderer {\n private static instance: SceneRenderer | null = null\n private store = new SceneStore()\n\n public static getInstance(): SceneRenderer {\n if (!SceneRenderer.instance) {\n SceneRenderer.instance = new SceneRenderer()\n }\n return SceneRenderer.instance\n }\n\n // ===========================================================================\n // Capabilities\n // ===========================================================================\n\n /**\n * Scene capabilities of the currently-selected device, or null when it has no\n * display block. Read on demand — same model source the CONNECT_ACK uses.\n */\n public currentCapabilities(): SceneDisplayCapabilities | null {\n // dev read these via the (since-removed) settings/glassesStatus runtime\n // hooks; engine reads its own stores directly.\n const model =\n (useSettingsStore.getState().getSetting(SETTINGS.default_wearable.key) as string | undefined) ??\n (useGlassesStore.getState().deviceModel as string | undefined)\n const display = getModelCapabilities((model ?? DeviceTypes.NONE) as DeviceTypes)?.display\n if (!display) return null\n return {\n width: display.width ?? display.resolution?.width ?? displayProcessor.getProfile().displayWidthPx,\n height: display.height ?? display.resolution?.height ?? displayProcessor.getProfile().displayHeightPx ?? 288,\n canPosition: display.canPosition === true,\n maxTextElements: display.maxTextElements ?? 6,\n maxImageElements: display.maxImageElements ?? 0,\n maxImagePx: display.maxImagePx,\n shapes: display.shapes ?? [],\n intensityLevels: display.intensityLevels ?? 2,\n partialUpdate: display.partialUpdate ?? false,\n }\n }\n\n // ===========================================================================\n // Legacy layout → scene conversion (sugar + old bundles on the scene path)\n // ===========================================================================\n\n /**\n * Convert a legacy layout into scene elements for a positioning device.\n * Returns null for layouts that must stay on the legacy path (dashboard_card,\n * clear_view, unknown types). Sugar semantics: full-canvas / split boxes.\n */\n public convertLegacyLayout(layout: LegacyLayout, caps: SceneDisplayCapabilities): SceneElementInput[] | null {\n const W = caps.width\n const H = caps.height\n const breakMode = layout.breakMode as SceneBreakMode | undefined\n\n switch (layout.layoutType) {\n case \"text_wall\":\n return [\n {\n type: \"text\",\n id: \"sugar:wall\",\n box: {x: 0, y: 0, w: W, h: H},\n text: String(layout.text ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n case \"double_text_wall\": {\n const half = Math.floor(W / 2)\n return [\n {\n type: \"text\",\n id: \"sugar:left\",\n box: {x: 0, y: 0, w: half, h: H},\n text: String(layout.topText ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n {\n type: \"text\",\n id: \"sugar:right\",\n box: {x: half, y: 0, w: W - half, h: H},\n text: String(layout.bottomText ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n }\n case \"reference_card\": {\n const titleH = Math.max(24, Math.floor(H / 5))\n return [\n {type: \"text\", id: \"sugar:title\", box: {x: 0, y: 0, w: W, h: titleH}, text: String(layout.title ?? \"\")},\n {\n type: \"text\",\n id: \"sugar:body\",\n box: {x: 0, y: titleH, w: W, h: H - titleH},\n text: String(layout.text ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n }\n case \"bitmap_view\": {\n // Dimensionless legacy bitmaps historically landed in the device's\n // default ~200×100 container (G2 seeded 200×100 at 188,44) — NOT the\n // full canvas, which would tile a small image across the whole frame.\n const w = (layout.width as number | undefined) ?? Math.min(200, W)\n const h = (layout.height as number | undefined) ?? Math.min(100, H)\n return [\n {\n type: \"image\",\n id: \"sugar:bmp\",\n box: {\n x: (layout.x as number | undefined) ?? Math.max(0, Math.round((W - w) / 2)),\n y: (layout.y as number | undefined) ?? Math.max(0, Math.round((H - h) / 4)),\n w,\n h,\n },\n data: String(layout.data ?? \"\"),\n },\n ]\n }\n case \"positioned_text\": {\n const border = (layout.borderWidth as number | undefined) ?? 0\n const radius = (layout.borderRadius as number | undefined) ?? 0\n return [\n {\n type: \"text\",\n id: \"sugar:pos\",\n box: {\n x: (layout.x as number | undefined) ?? 0,\n y: (layout.y as number | undefined) ?? 0,\n w: (layout.width as number | undefined) ?? W,\n h: (layout.height as number | undefined) ?? H,\n },\n text: String(layout.text ?? \"\"),\n ...(border || radius ? {style: {border, radius}} : {}),\n },\n ]\n }\n default:\n return null\n }\n }\n\n // ===========================================================================\n // Emit\n // ===========================================================================\n\n /**\n * Process + diff + send a scene for (app, view). On non-positioning devices\n * this returns the degraded legacy layout instead — the caller routes it\n * through the existing DisplayProcessor path (which wraps it, keeping G1/Z100\n * output byte-identical to today).\n */\n public emitScene(appId: string, view: \"main\" | \"dashboard\", elements: SceneElementInput[]): SceneEmitResult {\n const caps = this.currentCapabilities()\n if (!caps) return {kind: \"no-display\"}\n\n if (!caps.canPosition) {\n const {layout, degraded, dropped} = degradeScene(elements)\n return {kind: \"legacy\", layout, degraded, dropped}\n }\n\n const processed = processScene(elements, caps, displayProcessor.getProfile())\n // A stale baseline means the glasses were cleared since the last commit —\n // diff from empty so everything repaints (the retained frame stays valid\n // as the replay source only).\n const prevFrame = this.store.isBaselineStale(appId, view) ? [] : this.store.lastFrame(appId, view)\n const {elements: diffed, removed} = diffScene(\n prevFrame,\n processed.elements,\n this.store.nextSyntheticId(appId, view),\n )\n this.store.commit(appId, view, diffed)\n\n const frame: SceneFrame = {\n appId,\n view,\n sceneEpoch: this.store.currentEpoch(appId, view),\n elements: diffed,\n removed,\n }\n this.sendFrame(frame)\n return {kind: \"scene\", degraded: processed.degraded, dropped: processed.dropped}\n }\n\n /**\n * Re-emit an app's retained scene (reconnect / arbitration restore). Replay\n * is always create-based — the device rebuilds from scratch (spec §4).\n * Returns false when nothing is retained.\n */\n public replayApp(appId: string, view: \"main\" | \"dashboard\"): boolean {\n const frame = this.store.buildReplayFrame(appId, view)\n if (!frame) return false\n this.sendFrame(frame)\n return true\n }\n\n /** Forget an app's retained scenes (app stop). */\n public clearApp(appId: string): void {\n this.store.clear(appId)\n }\n\n /**\n * Reset the diff baseline for (app, view) without touching the device.\n * Used when a legacy layout bypasses the scene path (clear_view /\n * dashboard_card / unknown layoutTypes go to native raw): after that, the\n * retained frame no longer matches the glasses, so the next render() must\n * diff from empty — otherwise \"unchanged\" elements would be skipped and\n * never repainted.\n */\n public resetBaseline(appId: string, view: \"main\" | \"dashboard\"): void {\n this.store.commit(appId, view, [])\n }\n\n /**\n * A system-level clear wiped the view (durationMs expiry, unmount fallback,\n * boot-window expiry): mark every app's baseline for that view stale. Unlike\n * resetBaseline this KEEPS the retained frames — they remain the\n * restore-as-replay source; only incremental diffing restarts from empty.\n */\n public markViewStale(view: \"main\" | \"dashboard\"): void {\n this.store.markViewStale(view)\n }\n\n private sendFrame(frame: SceneFrame): void {\n try {\n // sendDisplayEvent hook -> direct BluetoothSdk.displayEvent (the exact\n // wiring the deleted MantleManager hook provided).\n void Promise.resolve(BluetoothSdk.displayEvent({view: frame.view, scene: frame})).catch((err) => {\n console.error(`${LOG_TAG}: native scene send failed:`, err)\n })\n } catch (err) {\n console.error(`${LOG_TAG}: native scene send failed:`, err)\n }\n }\n\n // ===========================================================================\n // Test hooks\n // ===========================================================================\n\n public _resetForTest(): void {\n this.store.clearAll()\n }\n\n public _lastFrameForTest(appId: string, view: string): FrameElement[] {\n return this.store.lastFrame(appId, view)\n }\n}\n\nconst sceneRenderer = SceneRenderer.getInstance()\nexport default sceneRenderer\nexport {SceneRenderer}\n"]}
|
|
1
|
+
{"version":3,"file":"SceneRenderer.js","sourceRoot":"","sources":["../../src/services/SceneRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,YAAY,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,WAAW,EAAE,oBAAoB,EAAC,MAAM,UAAU,CAAA;AAC1D,OAAO,EACL,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,UAAU,GAMX,MAAM,wBAAwB,CAAA;AAE/B,MAAM,OAAO,GAAG,gBAAgB,CAAA;AAahC,MAAM,aAAa;IACT,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAAA;IAC5C,KAAK,GAAG,IAAI,UAAU,EAAE,CAAA;IAEzB,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC5B,aAAa,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAA;QAC9C,CAAC;QACD,OAAO,aAAa,CAAC,QAAQ,CAAA;IAC/B,CAAC;IAED,8EAA8E;IAC9E,eAAe;IACf,8EAA8E;IAE9E;;;OAGG;IACI,mBAAmB;QACxB,wEAAwE;QACxE,+CAA+C;QAC/C,MAAM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,uEAAuE;YACvE,gEAAgE;YAChE,mEAAmE;YACnE,MAAM,IAAI,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAA;YACvC,eAAe,CAAC,QAAQ,EAAE,CAAC,eAAe,CAAC;gBACzC,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,MAAM,EAAE;oBACN,UAAU,EAAE,OAAO;oBACnB,KAAK,EAAE,IAAI,EAAE,KAAK;oBAClB,MAAM,EAAE,IAAI,EAAE,MAAM;oBACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;iBACzB;aACF,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,6BAA6B,EAAE,GAAG,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;IAED,8EAA8E;IAC9E,aAAa;IACb,8EAA8E;IAEvE,aAAa;QAClB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;IACvB,CAAC;IAEM,iBAAiB,CAAC,KAAa,EAAE,IAAY;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC;;AAGH,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAA;AACjD,eAAe,aAAa,CAAA;AAC5B,OAAO,EAAC,aAAa,EAAC,CAAA","sourcesContent":["/**\n * SceneRenderer — the device-aware boundary of the scene display pipeline.\n *\n * LocalDisplayManager owns WHO may draw (arbitration/boot/expiry); this service\n * owns WHAT gets sent for a scene: capabilities lookup, legacy-layout→scene\n * conversion (sugar and old bundles ride the same pipeline), process → diff →\n * SceneFrame emission, retained-scene replay, and the degrade branch for\n * devices that can't position elements.\n *\n * Everything device-specific here is DATA (capability fields, display profile);\n * the code paths are generic. Spec: notes/miniapp-display-render-implementation-spec.md\n */\n\nimport displayProcessor from \"./DisplayProcessor\"\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport {useDisplayStore} from \"../stores/display\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {DeviceTypes, getModelCapabilities} from \"../types\"\nimport {\n degradeScene,\n diffScene,\n processScene,\n SceneStore,\n type FrameElement,\n type SceneBreakMode,\n type SceneDisplayCapabilities,\n type SceneElementInput,\n type SceneFrame,\n} from \"../utils/display/scene\"\n\nconst LOG_TAG = \"SCENE_RENDERER\"\n\n/** Legacy layout shape (matches DisplayPayload.layout). */\nexport type LegacyLayout = {layoutType: string; [key: string]: unknown}\n\nexport type SceneEmitResult =\n /** A SceneFrame went to native. */\n | {kind: \"scene\"; degraded: boolean; dropped: string[]}\n /** Degrade path: caller routes this legacy layout through the existing pipeline (null layout ⇒ clear). */\n | {kind: \"legacy\"; layout: LegacyLayout | null; degraded: boolean; dropped: string[]}\n /** No display capabilities on the connected device. */\n | {kind: \"no-display\"}\n\nclass SceneRenderer {\n private static instance: SceneRenderer | null = null\n private store = new SceneStore()\n\n public static getInstance(): SceneRenderer {\n if (!SceneRenderer.instance) {\n SceneRenderer.instance = new SceneRenderer()\n }\n return SceneRenderer.instance\n }\n\n // ===========================================================================\n // Capabilities\n // ===========================================================================\n\n /**\n * Scene capabilities of the currently-selected device, or null when it has no\n * display block. Read on demand — same model source the CONNECT_ACK uses.\n */\n public currentCapabilities(): SceneDisplayCapabilities | null {\n // dev read these via the (since-removed) settings/glassesStatus runtime\n // hooks; engine reads its own stores directly.\n const model =\n (useSettingsStore.getState().getSetting(SETTINGS.default_wearable.key) as string | undefined) ??\n (useGlassesStore.getState().deviceModel as string | undefined)\n const display = getModelCapabilities((model ?? DeviceTypes.NONE) as DeviceTypes)?.display\n if (!display) return null\n return {\n width: display.width ?? display.resolution?.width ?? displayProcessor.getProfile().displayWidthPx,\n height: display.height ?? display.resolution?.height ?? displayProcessor.getProfile().displayHeightPx ?? 288,\n canPosition: display.canPosition === true,\n maxTextElements: display.maxTextElements ?? 6,\n maxImageElements: display.maxImageElements ?? 0,\n maxImagePx: display.maxImagePx,\n shapes: display.shapes ?? [],\n intensityLevels: display.intensityLevels ?? 2,\n partialUpdate: display.partialUpdate ?? false,\n }\n }\n\n // ===========================================================================\n // Legacy layout → scene conversion (sugar + old bundles on the scene path)\n // ===========================================================================\n\n /**\n * Convert a legacy layout into scene elements for a positioning device.\n * Returns null for layouts that must stay on the legacy path (dashboard_card,\n * clear_view, unknown types). Sugar semantics: full-canvas / split boxes.\n */\n public convertLegacyLayout(layout: LegacyLayout, caps: SceneDisplayCapabilities): SceneElementInput[] | null {\n const W = caps.width\n const H = caps.height\n const breakMode = layout.breakMode as SceneBreakMode | undefined\n\n switch (layout.layoutType) {\n case \"text_wall\":\n return [\n {\n type: \"text\",\n id: \"sugar:wall\",\n box: {x: 0, y: 0, w: W, h: H},\n text: String(layout.text ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n case \"double_text_wall\": {\n const half = Math.floor(W / 2)\n return [\n {\n type: \"text\",\n id: \"sugar:left\",\n box: {x: 0, y: 0, w: half, h: H},\n text: String(layout.topText ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n {\n type: \"text\",\n id: \"sugar:right\",\n box: {x: half, y: 0, w: W - half, h: H},\n text: String(layout.bottomText ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n }\n case \"reference_card\": {\n const titleH = Math.max(24, Math.floor(H / 5))\n return [\n {type: \"text\", id: \"sugar:title\", box: {x: 0, y: 0, w: W, h: titleH}, text: String(layout.title ?? \"\")},\n {\n type: \"text\",\n id: \"sugar:body\",\n box: {x: 0, y: titleH, w: W, h: H - titleH},\n text: String(layout.text ?? \"\"),\n ...(breakMode ? {style: {breakMode}} : {}),\n },\n ]\n }\n case \"bitmap_view\": {\n // Dimensionless legacy bitmaps historically landed in the device's\n // default ~200×100 container (G2 seeded 200×100 at 188,44) — NOT the\n // full canvas, which would tile a small image across the whole frame.\n const w = (layout.width as number | undefined) ?? Math.min(200, W)\n const h = (layout.height as number | undefined) ?? Math.min(100, H)\n return [\n {\n type: \"image\",\n id: \"sugar:bmp\",\n box: {\n x: (layout.x as number | undefined) ?? Math.max(0, Math.round((W - w) / 2)),\n y: (layout.y as number | undefined) ?? Math.max(0, Math.round((H - h) / 4)),\n w,\n h,\n },\n data: String(layout.data ?? \"\"),\n },\n ]\n }\n case \"positioned_text\": {\n const border = (layout.borderWidth as number | undefined) ?? 0\n const radius = (layout.borderRadius as number | undefined) ?? 0\n return [\n {\n type: \"text\",\n id: \"sugar:pos\",\n box: {\n x: (layout.x as number | undefined) ?? 0,\n y: (layout.y as number | undefined) ?? 0,\n w: (layout.width as number | undefined) ?? W,\n h: (layout.height as number | undefined) ?? H,\n },\n text: String(layout.text ?? \"\"),\n ...(border || radius ? {style: {border, radius}} : {}),\n },\n ]\n }\n default:\n return null\n }\n }\n\n // ===========================================================================\n // Emit\n // ===========================================================================\n\n /**\n * Process + diff + send a scene for (app, view). On non-positioning devices\n * this returns the degraded legacy layout instead — the caller routes it\n * through the existing DisplayProcessor path (which wraps it, keeping G1/Z100\n * output byte-identical to today).\n */\n public emitScene(appId: string, view: \"main\" | \"dashboard\", elements: SceneElementInput[]): SceneEmitResult {\n const caps = this.currentCapabilities()\n if (!caps) return {kind: \"no-display\"}\n\n if (!caps.canPosition) {\n const {layout, degraded, dropped} = degradeScene(elements)\n return {kind: \"legacy\", layout, degraded, dropped}\n }\n\n const processed = processScene(elements, caps, displayProcessor.getProfile())\n // A stale baseline means the glasses were cleared since the last commit —\n // diff from empty so everything repaints (the retained frame stays valid\n // as the replay source only).\n const prevFrame = this.store.isBaselineStale(appId, view) ? [] : this.store.lastFrame(appId, view)\n const {elements: diffed, removed} = diffScene(\n prevFrame,\n processed.elements,\n this.store.nextSyntheticId(appId, view),\n )\n this.store.commit(appId, view, diffed)\n\n const frame: SceneFrame = {\n appId,\n view,\n sceneEpoch: this.store.currentEpoch(appId, view),\n elements: diffed,\n removed,\n }\n this.sendFrame(frame)\n return {kind: \"scene\", degraded: processed.degraded, dropped: processed.dropped}\n }\n\n /**\n * Re-emit an app's retained scene (reconnect / arbitration restore). Replay\n * is always create-based — the device rebuilds from scratch (spec §4).\n * Returns false when nothing is retained.\n */\n public replayApp(appId: string, view: \"main\" | \"dashboard\"): boolean {\n const frame = this.store.buildReplayFrame(appId, view)\n if (!frame) return false\n this.sendFrame(frame)\n return true\n }\n\n /** Forget an app's retained scenes (app stop). */\n public clearApp(appId: string): void {\n this.store.clear(appId)\n }\n\n /**\n * Reset the diff baseline for (app, view) without touching the device.\n * Used when a legacy layout bypasses the scene path (clear_view /\n * dashboard_card / unknown layoutTypes go to native raw): after that, the\n * retained frame no longer matches the glasses, so the next render() must\n * diff from empty — otherwise \"unchanged\" elements would be skipped and\n * never repainted.\n */\n public resetBaseline(appId: string, view: \"main\" | \"dashboard\"): void {\n this.store.commit(appId, view, [])\n }\n\n /**\n * A system-level clear wiped the view (durationMs expiry, unmount fallback,\n * boot-window expiry): mark every app's baseline for that view stale. Unlike\n * resetBaseline this KEEPS the retained frames — they remain the\n * restore-as-replay source; only incremental diffing restarts from empty.\n */\n public markViewStale(view: \"main\" | \"dashboard\"): void {\n this.store.markViewStale(view)\n }\n\n private sendFrame(frame: SceneFrame): void {\n try {\n // sendDisplayEvent hook -> direct BluetoothSdk.displayEvent (the exact\n // wiring the deleted MantleManager hook provided).\n void Promise.resolve(BluetoothSdk.displayEvent({view: frame.view, scene: frame})).catch((err) => {\n console.error(`${LOG_TAG}: native scene send failed:`, err)\n })\n\n // Keep the phone-side glasses mirror on the same frame as native. Legacy\n // layouts update this store in LocalDisplayManager.sendToNative; scene\n // frames bypass that method, so without an explicit write every\n // positioning device (including G2) leaves the mirror blank/stale.\n const caps = this.currentCapabilities()\n useDisplayStore.getState().setDisplayEvent({\n view: frame.view,\n layout: {\n layoutType: \"scene\",\n width: caps?.width,\n height: caps?.height,\n elements: frame.elements,\n },\n })\n } catch (err) {\n console.error(`${LOG_TAG}: native scene send failed:`, err)\n }\n }\n\n // ===========================================================================\n // Test hooks\n // ===========================================================================\n\n public _resetForTest(): void {\n this.store.clearAll()\n }\n\n public _lastFrameForTest(appId: string, view: string): FrameElement[] {\n return this.store.lastFrame(appId, view)\n }\n}\n\nconst sceneRenderer = SceneRenderer.getInstance()\nexport default sceneRenderer\nexport {SceneRenderer}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface SentenceAudio {
|
|
2
|
+
audioUrl: string;
|
|
3
|
+
cleanup?: () => Promise<void> | void;
|
|
4
|
+
}
|
|
5
|
+
export interface SentencePlaybackResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
completed: boolean;
|
|
8
|
+
error: string | null;
|
|
9
|
+
duration: number | null;
|
|
10
|
+
}
|
|
11
|
+
export interface SentencePipelineRun {
|
|
12
|
+
cancelled: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface SentenceTtsPipelineOptions {
|
|
15
|
+
sentences: string[];
|
|
16
|
+
firstAudio: SentenceAudio;
|
|
17
|
+
run: SentencePipelineRun;
|
|
18
|
+
synthesize: (sentence: string) => Promise<SentenceAudio>;
|
|
19
|
+
play: (audio: SentenceAudio, index: number) => Promise<SentencePlaybackResult>;
|
|
20
|
+
onCleanupError?: (error: unknown) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Play pre-segmented TTS with one-sentence lookahead.
|
|
24
|
+
*
|
|
25
|
+
* The next sentence begins synthesis before playback of the current sentence,
|
|
26
|
+
* minimizing the transition delay without requiring incremental waveform
|
|
27
|
+
* support from the TTS model.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runSentenceTtsPipeline({ sentences, firstAudio, run, synthesize, play, onCleanupError, }: SentenceTtsPipelineOptions): Promise<SentencePlaybackResult>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=SentenceTtsPipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SentenceTtsPipeline.d.ts","sourceRoot":"","sources":["../../src/services/SentenceTtsPipeline.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CACrC;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,UAAU,0BAA0B;IAClC,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,UAAU,EAAE,aAAa,CAAA;IACzB,GAAG,EAAE,mBAAmB,CAAA;IACxB,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;IACxD,IAAI,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAC9E,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAC1C;AAUD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,EAC3C,SAAS,EACT,UAAU,EACV,GAAG,EACH,UAAU,EACV,IAAI,EACJ,cAAc,GACf,EAAE,0BAA0B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA0D9D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
async function cleanupAudio(audio, onError) {
|
|
2
|
+
try {
|
|
3
|
+
await Promise.resolve(audio.cleanup?.());
|
|
4
|
+
}
|
|
5
|
+
catch (error) {
|
|
6
|
+
onError?.(error);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Play pre-segmented TTS with one-sentence lookahead.
|
|
11
|
+
*
|
|
12
|
+
* The next sentence begins synthesis before playback of the current sentence,
|
|
13
|
+
* minimizing the transition delay without requiring incremental waveform
|
|
14
|
+
* support from the TTS model.
|
|
15
|
+
*/
|
|
16
|
+
export async function runSentenceTtsPipeline({ sentences, firstAudio, run, synthesize, play, onCleanupError, }) {
|
|
17
|
+
let current = firstAudio;
|
|
18
|
+
let totalDuration = 0;
|
|
19
|
+
for (let index = 0; index < sentences.length; index++) {
|
|
20
|
+
if (run.cancelled) {
|
|
21
|
+
await cleanupAudio(current, onCleanupError);
|
|
22
|
+
return { success: true, completed: false, error: null, duration: totalDuration };
|
|
23
|
+
}
|
|
24
|
+
// Attach both handlers immediately so a fast native rejection cannot
|
|
25
|
+
// become an unhandled promise while the current sentence is playing.
|
|
26
|
+
const nextOutcome = index + 1 < sentences.length
|
|
27
|
+
? synthesize(sentences[index + 1]).then((audio) => ({ audio, error: null }), (error) => ({ audio: null, error }))
|
|
28
|
+
: null;
|
|
29
|
+
const playback = await play(current, index);
|
|
30
|
+
totalDuration += playback.duration ?? 0;
|
|
31
|
+
await cleanupAudio(current, onCleanupError);
|
|
32
|
+
if (run.cancelled) {
|
|
33
|
+
if (nextOutcome) {
|
|
34
|
+
void nextOutcome.then(({ audio }) => {
|
|
35
|
+
if (audio)
|
|
36
|
+
void cleanupAudio(audio, onCleanupError);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return { success: true, completed: false, error: null, duration: totalDuration };
|
|
40
|
+
}
|
|
41
|
+
if (!playback.success || !playback.completed) {
|
|
42
|
+
if (nextOutcome) {
|
|
43
|
+
void nextOutcome.then(({ audio }) => {
|
|
44
|
+
if (audio)
|
|
45
|
+
void cleanupAudio(audio, onCleanupError);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return playback;
|
|
49
|
+
}
|
|
50
|
+
if (!nextOutcome) {
|
|
51
|
+
return { success: true, completed: true, error: null, duration: totalDuration };
|
|
52
|
+
}
|
|
53
|
+
const next = await nextOutcome;
|
|
54
|
+
if (!next.audio) {
|
|
55
|
+
const message = next.error instanceof Error ? next.error.message : String(next.error);
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
completed: false,
|
|
59
|
+
error: `Offline TTS failed for sentence ${index + 2}: ${message}`,
|
|
60
|
+
duration: totalDuration,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
current = next.audio;
|
|
64
|
+
}
|
|
65
|
+
return { success: true, completed: true, error: null, duration: totalDuration };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=SentenceTtsPipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SentenceTtsPipeline.js","sourceRoot":"","sources":["../../src/services/SentenceTtsPipeline.ts"],"names":[],"mappings":"AAyBA,KAAK,UAAU,YAAY,CAAC,KAAoB,EAAE,OAAkC;IAClF,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAC3C,SAAS,EACT,UAAU,EACV,GAAG,EACH,UAAU,EACV,IAAI,EACJ,cAAc,GACa;IAC3B,IAAI,OAAO,GAAG,UAAU,CAAA;IACxB,IAAI,aAAa,GAAG,CAAC,CAAA;IAErB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACtD,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClB,MAAM,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;YAC3C,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EA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EAAE;oBAChC,IAAI,KAAK;wBAAE,KAAK,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,CAAA;gBACrD,CAAC,CAAC,CAAA;YACJ,CAAC;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAC,CAAA;QAC/E,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,WAAW,CAAA;QAC9B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACrF,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,KAAK;gBAChB,KAAK,EAAE,mCAAmC,KAAK,GAAG,CAAC,KAAK,OAAO,EAAE;gBACjE,QAAQ,EAAE,aAAa;aACxB,CAAA;QACH,CAAC;QACD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAA;IACtB,CAAC;IAED,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAC,CAAA;AAC/E,CAAC","sourcesContent":["export interface SentenceAudio {\n audioUrl: string\n cleanup?: () => Promise<void> | void\n}\n\nexport interface SentencePlaybackResult {\n success: boolean\n completed: boolean\n error: string | null\n duration: number | null\n}\n\nexport interface SentencePipelineRun {\n cancelled: boolean\n}\n\ninterface SentenceTtsPipelineOptions {\n sentences: string[]\n firstAudio: SentenceAudio\n run: SentencePipelineRun\n synthesize: (sentence: string) => Promise<SentenceAudio>\n play: (audio: SentenceAudio, index: number) => Promise<SentencePlaybackResult>\n onCleanupError?: (error: unknown) => void\n}\n\nasync function cleanupAudio(audio: SentenceAudio, onError?: (error: unknown) => void): Promise<void> {\n try {\n await Promise.resolve(audio.cleanup?.())\n } catch (error) {\n onError?.(error)\n }\n}\n\n/**\n * Play pre-segmented TTS with one-sentence lookahead.\n *\n * The next sentence begins synthesis before playback of the current sentence,\n * minimizing the transition delay without requiring incremental waveform\n * support from the TTS model.\n */\nexport async function runSentenceTtsPipeline({\n sentences,\n firstAudio,\n run,\n synthesize,\n play,\n onCleanupError,\n}: SentenceTtsPipelineOptions): Promise<SentencePlaybackResult> {\n let current = firstAudio\n let totalDuration = 0\n\n for (let index = 0; index < sentences.length; index++) {\n if (run.cancelled) {\n await cleanupAudio(current, onCleanupError)\n return {success: true, completed: false, error: null, duration: totalDuration}\n }\n\n // Attach both handlers immediately so a fast native rejection cannot\n // become an unhandled promise while the current sentence is playing.\n const nextOutcome =\n index + 1 < sentences.length\n ? synthesize(sentences[index + 1]).then(\n (audio) => ({audio, error: null}),\n (error: unknown) => ({audio: null, error}),\n )\n : null\n\n const playback = await play(current, index)\n totalDuration += playback.duration ?? 0\n await cleanupAudio(current, onCleanupError)\n\n if (run.cancelled) {\n if (nextOutcome) {\n void nextOutcome.then(({audio}) => {\n if (audio) void cleanupAudio(audio, onCleanupError)\n })\n }\n return {success: true, completed: false, error: null, duration: totalDuration}\n }\n if (!playback.success || !playback.completed) {\n if (nextOutcome) {\n void nextOutcome.then(({audio}) => {\n if (audio) void cleanupAudio(audio, onCleanupError)\n })\n }\n return playback\n }\n if (!nextOutcome) {\n return {success: true, completed: true, error: null, duration: totalDuration}\n }\n\n const next = await nextOutcome\n if (!next.audio) {\n const message = next.error instanceof Error ? next.error.message : String(next.error)\n return {\n success: false,\n completed: false,\n error: `Offline TTS failed for sentence ${index + 2}: ${message}`,\n duration: totalDuration,\n }\n }\n current = next.audio\n }\n\n return {success: true, completed: true, error: null, duration: totalDuration}\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SupportStateInput } from "@mentra/cloud-client";
|
|
2
|
+
/**
|
|
3
|
+
* Keep Cloud V2's canonical support snapshot current without creating an event
|
|
4
|
+
* stream from noisy store updates. Only the explicitly selected fields below
|
|
5
|
+
* leave the phone; Wi-Fi, Bluetooth addresses, location and diagnostics do not.
|
|
6
|
+
*/
|
|
7
|
+
export declare function startSupportProfileSync(): void;
|
|
8
|
+
export declare function stopSupportProfileSync(): void;
|
|
9
|
+
export declare function retryDelayForSupportProfileResult(result: {
|
|
10
|
+
status: "accepted" | "deduplicated" | "stale";
|
|
11
|
+
}): number | null;
|
|
12
|
+
/**
|
|
13
|
+
* Support freshness is not worth an aggressive retry loop. A snapshot the
|
|
14
|
+
* server keeps rejecting (skewed clock, deleted account, signed-out host)
|
|
15
|
+
* backs off exponentially until it converges on the heartbeat cadence.
|
|
16
|
+
*/
|
|
17
|
+
export declare function retryDelayForSendFailure(consecutiveFailures: number): number;
|
|
18
|
+
export declare function buildSnapshot(observedAt?: Date): SupportStateInput;
|
|
19
|
+
/** Record only normalized connection failures; arbitrary exception messages never leave the phone. */
|
|
20
|
+
export declare function recordSupportProfileConnectionFailure(error: unknown, stage: string): void;
|
|
21
|
+
export declare function snapshotFingerprint(snapshot: SupportStateInput): string;
|
|
22
|
+
//# sourceMappingURL=SupportProfileSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupportProfileSync.d.ts","sourceRoot":"","sources":["../../src/services/SupportProfileSync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAA;AAwB3D;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAO9C;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAgB7C;AA+ED,wBAAgB,iCAAiC,CAAC,MAAM,EAAE;IACxD,MAAM,EAAE,UAAU,GAAG,cAAc,GAAG,OAAO,CAAA;CAC9C,GAAG,MAAM,GAAG,IAAI,CAGhB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,wBAAgB,aAAa,CAAC,UAAU,OAAa,GAAG,iBAAiB,CAoCxE;AAED,sGAAsG;AACtG,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAiBzF;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAEvE"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import Constants from "expo-constants";
|
|
2
|
+
import * as Device from "expo-device";
|
|
3
|
+
import { Platform } from "react-native";
|
|
4
|
+
import { useGlassesStore } from "../stores/glasses";
|
|
5
|
+
import { BgTimer } from "../utils/timers";
|
|
6
|
+
import { cloudClientService } from "./CloudClientService";
|
|
7
|
+
const ENGINE_VERSION = require("../../package.json").version;
|
|
8
|
+
const BLUETOOTH_SDK_VERSION = require("@mentra/bluetooth-sdk/package.json").version;
|
|
9
|
+
const DEBOUNCE_MS = 2_000;
|
|
10
|
+
const RETRY_MS = 30_000;
|
|
11
|
+
const HEARTBEAT_MS = 6 * 60 * 60_000;
|
|
12
|
+
let unsubscribe = null;
|
|
13
|
+
let debounceTimer = null;
|
|
14
|
+
let retryTimer = null;
|
|
15
|
+
let heartbeatTimer = null;
|
|
16
|
+
let lastSentFingerprint = null;
|
|
17
|
+
let queuedFingerprint = null;
|
|
18
|
+
let sendingGeneration = null;
|
|
19
|
+
let syncGeneration = 0;
|
|
20
|
+
let consecutiveSendFailures = 0;
|
|
21
|
+
let lastFailure = null;
|
|
22
|
+
let lastConnectionState = null;
|
|
23
|
+
/**
|
|
24
|
+
* Keep Cloud V2's canonical support snapshot current without creating an event
|
|
25
|
+
* stream from noisy store updates. Only the explicitly selected fields below
|
|
26
|
+
* leave the phone; Wi-Fi, Bluetooth addresses, location and diagnostics do not.
|
|
27
|
+
*/
|
|
28
|
+
export function startSupportProfileSync() {
|
|
29
|
+
if (unsubscribe)
|
|
30
|
+
return;
|
|
31
|
+
const generation = ++syncGeneration;
|
|
32
|
+
lastConnectionState = useGlassesStore.getState().connection.state;
|
|
33
|
+
unsubscribe = useGlassesStore.subscribe(() => handleGlassesStoreChange(generation));
|
|
34
|
+
heartbeatTimer = BgTimer.setInterval(() => void sendCurrentSnapshot(true, generation), HEARTBEAT_MS);
|
|
35
|
+
void sendCurrentSnapshot(true, generation);
|
|
36
|
+
}
|
|
37
|
+
export function stopSupportProfileSync() {
|
|
38
|
+
syncGeneration += 1;
|
|
39
|
+
unsubscribe?.();
|
|
40
|
+
unsubscribe = null;
|
|
41
|
+
if (debounceTimer !== null)
|
|
42
|
+
BgTimer.clearTimeout(debounceTimer);
|
|
43
|
+
if (retryTimer !== null)
|
|
44
|
+
BgTimer.clearTimeout(retryTimer);
|
|
45
|
+
if (heartbeatTimer !== null)
|
|
46
|
+
BgTimer.clearInterval(heartbeatTimer);
|
|
47
|
+
debounceTimer = null;
|
|
48
|
+
retryTimer = null;
|
|
49
|
+
heartbeatTimer = null;
|
|
50
|
+
lastSentFingerprint = null;
|
|
51
|
+
queuedFingerprint = null;
|
|
52
|
+
sendingGeneration = null;
|
|
53
|
+
consecutiveSendFailures = 0;
|
|
54
|
+
lastFailure = null;
|
|
55
|
+
lastConnectionState = null;
|
|
56
|
+
}
|
|
57
|
+
function handleGlassesStoreChange(generation) {
|
|
58
|
+
if (!unsubscribe || generation !== syncGeneration)
|
|
59
|
+
return;
|
|
60
|
+
const connectionState = useGlassesStore.getState().connection.state;
|
|
61
|
+
if (connectionState === "connected" && lastConnectionState !== "connected")
|
|
62
|
+
lastFailure = null;
|
|
63
|
+
lastConnectionState = connectionState;
|
|
64
|
+
scheduleMeaningfulUpdate(generation);
|
|
65
|
+
}
|
|
66
|
+
function scheduleMeaningfulUpdate(generation = syncGeneration) {
|
|
67
|
+
if (!unsubscribe || generation !== syncGeneration)
|
|
68
|
+
return;
|
|
69
|
+
const fingerprint = snapshotFingerprint(buildSnapshot());
|
|
70
|
+
if (fingerprint === lastSentFingerprint)
|
|
71
|
+
return;
|
|
72
|
+
queuedFingerprint = fingerprint;
|
|
73
|
+
armDebounce(generation);
|
|
74
|
+
}
|
|
75
|
+
function armDebounce(generation) {
|
|
76
|
+
if (debounceTimer !== null)
|
|
77
|
+
BgTimer.clearTimeout(debounceTimer);
|
|
78
|
+
debounceTimer = BgTimer.setTimeout(() => {
|
|
79
|
+
debounceTimer = null;
|
|
80
|
+
void sendCurrentSnapshot(false, generation);
|
|
81
|
+
}, DEBOUNCE_MS);
|
|
82
|
+
}
|
|
83
|
+
async function sendCurrentSnapshot(force, generation = syncGeneration) {
|
|
84
|
+
if (!unsubscribe || generation !== syncGeneration)
|
|
85
|
+
return;
|
|
86
|
+
if (sendingGeneration === generation) {
|
|
87
|
+
const fingerprint = snapshotFingerprint(buildSnapshot());
|
|
88
|
+
if (fingerprint !== lastSentFingerprint)
|
|
89
|
+
queuedFingerprint = fingerprint;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const snapshot = buildSnapshot();
|
|
93
|
+
const fingerprint = snapshotFingerprint(snapshot);
|
|
94
|
+
if (!force && fingerprint === lastSentFingerprint)
|
|
95
|
+
return;
|
|
96
|
+
sendingGeneration = generation;
|
|
97
|
+
let retryDelayMs = null;
|
|
98
|
+
try {
|
|
99
|
+
const result = await cloudClientService.core.supportProfile.update(snapshot);
|
|
100
|
+
if (generation !== syncGeneration || !unsubscribe)
|
|
101
|
+
return;
|
|
102
|
+
consecutiveSendFailures = 0;
|
|
103
|
+
retryDelayMs = retryDelayForSupportProfileResult(result);
|
|
104
|
+
if (retryDelayMs === null) {
|
|
105
|
+
lastSentFingerprint = fingerprint;
|
|
106
|
+
if (queuedFingerprint === fingerprint)
|
|
107
|
+
queuedFingerprint = null;
|
|
108
|
+
if (retryTimer !== null)
|
|
109
|
+
BgTimer.clearTimeout(retryTimer);
|
|
110
|
+
retryTimer = null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (generation !== syncGeneration || !unsubscribe)
|
|
115
|
+
return;
|
|
116
|
+
consecutiveSendFailures += 1;
|
|
117
|
+
retryDelayMs = retryDelayForSendFailure(consecutiveSendFailures);
|
|
118
|
+
console.warn(`supportProfile: Cloud V2 update failed (retry in ${Math.round(retryDelayMs / 1_000)}s):`, error instanceof Error ? error.message : error);
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
const generationIsActive = generation === syncGeneration && sendingGeneration === generation && Boolean(unsubscribe);
|
|
122
|
+
if (generationIsActive) {
|
|
123
|
+
sendingGeneration = null;
|
|
124
|
+
if (retryDelayMs !== null) {
|
|
125
|
+
if (retryTimer !== null)
|
|
126
|
+
BgTimer.clearTimeout(retryTimer);
|
|
127
|
+
retryTimer = BgTimer.setTimeout(() => {
|
|
128
|
+
retryTimer = null;
|
|
129
|
+
void sendCurrentSnapshot(true, generation);
|
|
130
|
+
}, retryDelayMs);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const currentFingerprint = snapshotFingerprint(buildSnapshot());
|
|
134
|
+
if (currentFingerprint !== lastSentFingerprint) {
|
|
135
|
+
queuedFingerprint = currentFingerprint;
|
|
136
|
+
if (retryTimer === null)
|
|
137
|
+
armDebounce(generation);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export function retryDelayForSupportProfileResult(result) {
|
|
144
|
+
if (result.status === "accepted" || result.status === "deduplicated")
|
|
145
|
+
return null;
|
|
146
|
+
return RETRY_MS;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Support freshness is not worth an aggressive retry loop. A snapshot the
|
|
150
|
+
* server keeps rejecting (skewed clock, deleted account, signed-out host)
|
|
151
|
+
* backs off exponentially until it converges on the heartbeat cadence.
|
|
152
|
+
*/
|
|
153
|
+
export function retryDelayForSendFailure(consecutiveFailures) {
|
|
154
|
+
return Math.min(HEARTBEAT_MS, RETRY_MS * 2 ** Math.min(Math.max(consecutiveFailures, 1) - 1, 10));
|
|
155
|
+
}
|
|
156
|
+
export function buildSnapshot(observedAt = new Date()) {
|
|
157
|
+
const glasses = useGlassesStore.getState();
|
|
158
|
+
const device = {
|
|
159
|
+
hardwareId: optional(glasses.serialNumber),
|
|
160
|
+
model: optional(glasses.deviceModel),
|
|
161
|
+
androidVersion: optional(glasses.androidVersion),
|
|
162
|
+
firmwareVersion: optional(glasses.firmwareVersion),
|
|
163
|
+
mtkFirmwareVersion: optional(glasses.mtkFirmwareVersion),
|
|
164
|
+
besFirmwareVersion: optional(glasses.besFirmwareVersion),
|
|
165
|
+
appVersion: optional(glasses.appVersion),
|
|
166
|
+
buildNumber: optional(glasses.buildNumber),
|
|
167
|
+
};
|
|
168
|
+
const hasDevice = Object.values(device).some(Boolean);
|
|
169
|
+
const constants = Constants;
|
|
170
|
+
return {
|
|
171
|
+
observedAt: observedAt.toISOString(),
|
|
172
|
+
host: {
|
|
173
|
+
appVersion: optional(constants.nativeAppVersion ?? Constants.expoConfig?.version),
|
|
174
|
+
appBuild: optional(constants.nativeBuildVersion),
|
|
175
|
+
engineVersion: optional(ENGINE_VERSION),
|
|
176
|
+
bluetoothSdkVersion: optional(BLUETOOTH_SDK_VERSION),
|
|
177
|
+
phonePlatform: Platform.OS === "ios" || Platform.OS === "android" ? Platform.OS : "unknown",
|
|
178
|
+
phoneModel: optional(Device.modelName),
|
|
179
|
+
phoneOsVersion: optional(Platform.OS === "android"
|
|
180
|
+
? String(Platform.constants?.Release ?? Platform.Version)
|
|
181
|
+
: String(Platform.Version)),
|
|
182
|
+
connectionState: glasses.connection.state,
|
|
183
|
+
...(lastFailure ? { failureCode: lastFailure.code, failureStage: lastFailure.stage } : {}),
|
|
184
|
+
},
|
|
185
|
+
...(hasDevice ? { device } : {}),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** Record only normalized connection failures; arbitrary exception messages never leave the phone. */
|
|
189
|
+
export function recordSupportProfileConnectionFailure(error, stage) {
|
|
190
|
+
const rawCode = typeof error === "object" && error && "code" in error ? String(error.code ?? "") : "";
|
|
191
|
+
const message = error instanceof Error ? `${error.name} ${error.message}`.toLowerCase() : "";
|
|
192
|
+
const code = /^[a-zA-Z0-9_.-]{1,64}$/.test(rawCode)
|
|
193
|
+
? rawCode.toLowerCase()
|
|
194
|
+
: message.includes("permission")
|
|
195
|
+
? "permission_denied"
|
|
196
|
+
: message.includes("bluetooth") && (message.includes("off") || message.includes("unavailable"))
|
|
197
|
+
? "bluetooth_unavailable"
|
|
198
|
+
: message.includes("not found") || message.includes("no default")
|
|
199
|
+
? "device_not_found"
|
|
200
|
+
: message.includes("timeout")
|
|
201
|
+
? "connect_timeout"
|
|
202
|
+
: "connect_failed";
|
|
203
|
+
lastFailure = { code, stage: stage.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 64) };
|
|
204
|
+
scheduleMeaningfulUpdate();
|
|
205
|
+
}
|
|
206
|
+
export function snapshotFingerprint(snapshot) {
|
|
207
|
+
return JSON.stringify({ host: snapshot.host, device: snapshot.device });
|
|
208
|
+
}
|
|
209
|
+
function optional(value) {
|
|
210
|
+
const trimmed = value?.trim();
|
|
211
|
+
return trimmed ? trimmed.slice(0, 128) : undefined;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=SupportProfileSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupportProfileSync.js","sourceRoot":"","sources":["../../src/services/SupportProfileSync.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AAGrC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,OAAO,EAAC,MA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AS,CAAC,EAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAC,CAAC,CAAA;AACvE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAgC;IAChD,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;IAC7B,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACpD,CAAC","sourcesContent":["import Constants from \"expo-constants\"\nimport * as Device from \"expo-device\"\nimport {Platform} from \"react-native\"\nimport type {SupportStateInput} from \"@mentra/cloud-client\"\n\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {BgTimer} from \"../utils/timers\"\nimport {cloudClientService} from \"./CloudClientService\"\n\nconst ENGINE_VERSION = (require(\"../../package.json\") as {version?: string}).version\nconst BLUETOOTH_SDK_VERSION = (require(\"@mentra/bluetooth-sdk/package.json\") as {version?: string}).version\nconst DEBOUNCE_MS = 2_000\nconst RETRY_MS = 30_000\nconst HEARTBEAT_MS = 6 * 60 * 60_000\n\nlet unsubscribe: (() => void) | null = null\nlet debounceTimer: number | null = null\nlet retryTimer: number | null = null\nlet heartbeatTimer: number | null = null\nlet lastSentFingerprint: string | null = null\nlet queuedFingerprint: string | null = null\nlet sendingGeneration: number | null = null\nlet syncGeneration = 0\nlet consecutiveSendFailures = 0\nlet lastFailure: {code: string; stage: string} | null = null\nlet lastConnectionState: string | null = null\n\n/**\n * Keep Cloud V2's canonical support snapshot current without creating an event\n * stream from noisy store updates. Only the explicitly selected fields below\n * leave the phone; Wi-Fi, Bluetooth addresses, location and diagnostics do not.\n */\nexport function startSupportProfileSync(): void {\n if (unsubscribe) return\n const generation = ++syncGeneration\n lastConnectionState = useGlassesStore.getState().connection.state\n unsubscribe = useGlassesStore.subscribe(() => handleGlassesStoreChange(generation))\n heartbeatTimer = BgTimer.setInterval(() => void sendCurrentSnapshot(true, generation), HEARTBEAT_MS)\n void sendCurrentSnapshot(true, generation)\n}\n\nexport function stopSupportProfileSync(): void {\n syncGeneration += 1\n unsubscribe?.()\n unsubscribe = null\n if (debounceTimer !== null) BgTimer.clearTimeout(debounceTimer)\n if (retryTimer !== null) BgTimer.clearTimeout(retryTimer)\n if (heartbeatTimer !== null) BgTimer.clearInterval(heartbeatTimer)\n debounceTimer = null\n retryTimer = null\n heartbeatTimer = null\n lastSentFingerprint = null\n queuedFingerprint = null\n sendingGeneration = null\n consecutiveSendFailures = 0\n lastFailure = null\n lastConnectionState = null\n}\n\nfunction handleGlassesStoreChange(generation: number): void {\n if (!unsubscribe || generation !== syncGeneration) return\n const connectionState = useGlassesStore.getState().connection.state\n if (connectionState === \"connected\" && lastConnectionState !== \"connected\") lastFailure = null\n lastConnectionState = connectionState\n scheduleMeaningfulUpdate(generation)\n}\n\nfunction scheduleMeaningfulUpdate(generation = syncGeneration): void {\n if (!unsubscribe || generation !== syncGeneration) return\n const fingerprint = snapshotFingerprint(buildSnapshot())\n if (fingerprint === lastSentFingerprint) return\n queuedFingerprint = fingerprint\n armDebounce(generation)\n}\n\nfunction armDebounce(generation: number): void {\n if (debounceTimer !== null) BgTimer.clearTimeout(debounceTimer)\n debounceTimer = BgTimer.setTimeout(() => {\n debounceTimer = null\n void sendCurrentSnapshot(false, generation)\n }, DEBOUNCE_MS)\n}\n\nasync function sendCurrentSnapshot(force: boolean, generation = syncGeneration): Promise<void> {\n if (!unsubscribe || generation !== syncGeneration) return\n if (sendingGeneration === generation) {\n const fingerprint = snapshotFingerprint(buildSnapshot())\n if (fingerprint !== lastSentFingerprint) queuedFingerprint = fingerprint\n return\n }\n const snapshot = buildSnapshot()\n const fingerprint = snapshotFingerprint(snapshot)\n if (!force && fingerprint === lastSentFingerprint) return\n\n sendingGeneration = generation\n let retryDelayMs: number | null = null\n try {\n const result = await cloudClientService.core.supportProfile.update(snapshot)\n if (generation !== syncGeneration || !unsubscribe) return\n consecutiveSendFailures = 0\n retryDelayMs = retryDelayForSupportProfileResult(result)\n if (retryDelayMs === null) {\n lastSentFingerprint = fingerprint\n if (queuedFingerprint === fingerprint) queuedFingerprint = null\n if (retryTimer !== null) BgTimer.clearTimeout(retryTimer)\n retryTimer = null\n }\n } catch (error) {\n if (generation !== syncGeneration || !unsubscribe) return\n consecutiveSendFailures += 1\n retryDelayMs = retryDelayForSendFailure(consecutiveSendFailures)\n console.warn(\n `supportProfile: Cloud V2 update failed (retry in ${Math.round(retryDelayMs / 1_000)}s):`,\n error instanceof Error ? error.message : error,\n )\n } finally {\n const generationIsActive = generation === syncGeneration && sendingGeneration === generation && Boolean(unsubscribe)\n if (generationIsActive) {\n sendingGeneration = null\n if (retryDelayMs !== null) {\n if (retryTimer !== null) BgTimer.clearTimeout(retryTimer)\n retryTimer = BgTimer.setTimeout(() => {\n retryTimer = null\n void sendCurrentSnapshot(true, generation)\n }, retryDelayMs)\n } else {\n const currentFingerprint = snapshotFingerprint(buildSnapshot())\n if (currentFingerprint !== lastSentFingerprint) {\n queuedFingerprint = currentFingerprint\n if (retryTimer === null) armDebounce(generation)\n }\n }\n }\n }\n}\n\nexport function retryDelayForSupportProfileResult(result: {\n status: \"accepted\" | \"deduplicated\" | \"stale\"\n}): number | null {\n if (result.status === \"accepted\" || result.status === \"deduplicated\") return null\n return RETRY_MS\n}\n\n/**\n * Support freshness is not worth an aggressive retry loop. A snapshot the\n * server keeps rejecting (skewed clock, deleted account, signed-out host)\n * backs off exponentially until it converges on the heartbeat cadence.\n */\nexport function retryDelayForSendFailure(consecutiveFailures: number): number {\n return Math.min(HEARTBEAT_MS, RETRY_MS * 2 ** Math.min(Math.max(consecutiveFailures, 1) - 1, 10))\n}\n\nexport function buildSnapshot(observedAt = new Date()): SupportStateInput {\n const glasses = useGlassesStore.getState()\n const device = {\n hardwareId: optional(glasses.serialNumber),\n model: optional(glasses.deviceModel),\n androidVersion: optional(glasses.androidVersion),\n firmwareVersion: optional(glasses.firmwareVersion),\n mtkFirmwareVersion: optional(glasses.mtkFirmwareVersion),\n besFirmwareVersion: optional(glasses.besFirmwareVersion),\n appVersion: optional(glasses.appVersion),\n buildNumber: optional(glasses.buildNumber),\n }\n const hasDevice = Object.values(device).some(Boolean)\n const constants = Constants as typeof Constants & {\n nativeAppVersion?: string | null\n nativeBuildVersion?: string | null\n }\n return {\n observedAt: observedAt.toISOString(),\n host: {\n appVersion: optional(constants.nativeAppVersion ?? Constants.expoConfig?.version),\n appBuild: optional(constants.nativeBuildVersion),\n engineVersion: optional(ENGINE_VERSION),\n bluetoothSdkVersion: optional(BLUETOOTH_SDK_VERSION),\n phonePlatform: Platform.OS === \"ios\" || Platform.OS === \"android\" ? Platform.OS : \"unknown\",\n phoneModel: optional(Device.modelName),\n phoneOsVersion: optional(\n Platform.OS === \"android\"\n ? String((Platform.constants as {Release?: string} | undefined)?.Release ?? Platform.Version)\n : String(Platform.Version),\n ),\n connectionState: glasses.connection.state,\n ...(lastFailure ? {failureCode: lastFailure.code, failureStage: lastFailure.stage} : {}),\n },\n ...(hasDevice ? {device} : {}),\n }\n}\n\n/** Record only normalized connection failures; arbitrary exception messages never leave the phone. */\nexport function recordSupportProfileConnectionFailure(error: unknown, stage: string): void {\n const rawCode =\n typeof error === \"object\" && error && \"code\" in error ? String((error as {code?: unknown}).code ?? \"\") : \"\"\n const message = error instanceof Error ? `${error.name} ${error.message}`.toLowerCase() : \"\"\n const code = /^[a-zA-Z0-9_.-]{1,64}$/.test(rawCode)\n ? rawCode.toLowerCase()\n : message.includes(\"permission\")\n ? \"permission_denied\"\n : message.includes(\"bluetooth\") && (message.includes(\"off\") || message.includes(\"unavailable\"))\n ? \"bluetooth_unavailable\"\n : message.includes(\"not found\") || message.includes(\"no default\")\n ? \"device_not_found\"\n : message.includes(\"timeout\")\n ? \"connect_timeout\"\n : \"connect_failed\"\n lastFailure = {code, stage: stage.replace(/[^a-zA-Z0-9_.-]/g, \"_\").slice(0, 64)}\n scheduleMeaningfulUpdate()\n}\n\nexport function snapshotFingerprint(snapshot: SupportStateInput): string {\n return JSON.stringify({host: snapshot.host, device: snapshot.device})\n}\n\nfunction optional(value: string | null | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed.slice(0, 128) : undefined\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TranscriptionRouteSummary {
|
|
2
|
+
hasCloudSubscriber: boolean;
|
|
3
|
+
hasForceLocalSubscriber: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface TranscriptionSubscriberRoutes {
|
|
6
|
+
cloud: boolean;
|
|
7
|
+
forceLocal: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type TranscriptionDeliveryRoute = "default" | "forceLocal" | "all";
|
|
10
|
+
export declare function summarizeTranscriptionRoutes<T>(subscribers: Iterable<T>, routesFor: (subscriber: T) => TranscriptionSubscriberRoutes): TranscriptionRouteSummary;
|
|
11
|
+
export declare function transcriptionDeliveryRoute(source: "cloud" | "local", routes: TranscriptionSubscriberRoutes, cloudConnected: boolean): TranscriptionDeliveryRoute | null;
|
|
12
|
+
//# sourceMappingURL=TranscriptionRouting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranscriptionRouting.d.ts","sourceRoot":"","sources":["../../src/services/TranscriptionRouting.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,kBAAkB,EAAE,OAAO,CAAA;IAC3B,uBAAuB,EAAE,OAAO,CAAA;CACjC;AAED,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,OAAO,CAAA;IACd,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,CAAA;AAEzE,wBAAgB,4BAA4B,CAAC,CAAC,EAC5C,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,EACxB,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC,KAAK,6BAA6B,GAC1D,yBAAyB,CAS3B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,OAAO,GAAG,OAAO,EACzB,MAAM,EAAE,6BAA6B,EACrC,cAAc,EAAE,OAAO,GACtB,0BAA0B,GAAG,IAAI,CAMnC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function summarizeTranscriptionRoutes(subscribers, routesFor) {
|
|
2
|
+
let hasCloudSubscriber = false;
|
|
3
|
+
let hasForceLocalSubscriber = false;
|
|
4
|
+
for (const subscriber of subscribers) {
|
|
5
|
+
const routes = routesFor(subscriber);
|
|
6
|
+
if (routes.cloud)
|
|
7
|
+
hasCloudSubscriber = true;
|
|
8
|
+
if (routes.forceLocal)
|
|
9
|
+
hasForceLocalSubscriber = true;
|
|
10
|
+
}
|
|
11
|
+
return { hasCloudSubscriber, hasForceLocalSubscriber };
|
|
12
|
+
}
|
|
13
|
+
export function transcriptionDeliveryRoute(source, routes, cloudConnected) {
|
|
14
|
+
if (source === "cloud")
|
|
15
|
+
return routes.cloud ? "default" : null;
|
|
16
|
+
if (cloudConnected)
|
|
17
|
+
return routes.forceLocal ? "forceLocal" : null;
|
|
18
|
+
if (routes.cloud && routes.forceLocal)
|
|
19
|
+
return "all";
|
|
20
|
+
if (routes.forceLocal)
|
|
21
|
+
return "forceLocal";
|
|
22
|
+
return routes.cloud ? "default" : null;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=TranscriptionRouting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranscriptionRouting.js","sourceRoot":"","sources":["../../src/services/TranscriptionRouting.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,4BAA4B,CAC1C,WAAwB,EACxB,SAA2D;IAE3D,IAAI,kBAAkB,GAAG,KAAK,CAAA;IAC9B,IAAI,uBAAuB,GAAG,KAAK,CAAA;IACnC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAA;QACpC,IAAI,MAAM,CAAC,KAAK;YAAE,kBAAkB,GAAG,IAAI,CAAA;QAC3C,IAAI,MAAM,CAAC,UAAU;YAAE,uBAAuB,GAAG,IAAI,CAAA;IACvD,CAAC;IACD,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAC,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,MAAyB,EACzB,MAAqC,EACrC,cAAuB;IAEvB,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAA;IAC9D,IAAI,cAAc;QAAE,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAA;IAClE,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,UAAU;QAAE,OAAO,KAAK,CAAA;IACnD,IAAI,MAAM,CAAC,UAAU;QAAE,OAAO,YAAY,CAAA;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAA;AACxC,CAAC","sourcesContent":["export interface TranscriptionRouteSummary {\n hasCloudSubscriber: boolean\n hasForceLocalSubscriber: boolean\n}\n\nexport interface TranscriptionSubscriberRoutes {\n cloud: boolean\n forceLocal: boolean\n}\n\nexport type TranscriptionDeliveryRoute = \"default\" | \"forceLocal\" | \"all\"\n\nexport function summarizeTranscriptionRoutes<T>(\n subscribers: Iterable<T>,\n routesFor: (subscriber: T) => TranscriptionSubscriberRoutes,\n): TranscriptionRouteSummary {\n let hasCloudSubscriber = false\n let hasForceLocalSubscriber = false\n for (const subscriber of subscribers) {\n const routes = routesFor(subscriber)\n if (routes.cloud) hasCloudSubscriber = true\n if (routes.forceLocal) hasForceLocalSubscriber = true\n }\n return {hasCloudSubscriber, hasForceLocalSubscriber}\n}\n\nexport function transcriptionDeliveryRoute(\n source: \"cloud\" | \"local\",\n routes: TranscriptionSubscriberRoutes,\n cloudConnected: boolean,\n): TranscriptionDeliveryRoute | null {\n if (source === \"cloud\") return routes.cloud ? \"default\" : null\n if (cloudConnected) return routes.forceLocal ? \"forceLocal\" : null\n if (routes.cloud && routes.forceLocal) return \"all\"\n if (routes.forceLocal) return \"forceLocal\"\n return routes.cloud ? \"default\" : null\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Convert display-oriented text into plain words before TTS synthesis. */
|
|
2
|
+
export declare function sanitizeTtsText(text: string): string;
|
|
3
|
+
/** Prepare an already-trimmed sentence list while preserving the exact-text opt-out. */
|
|
4
|
+
export declare function prepareTtsSentences(sentences: string[], enableSanitization?: boolean): string[];
|
|
5
|
+
//# sourceMappingURL=TtsTextSanitizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TtsTextSanitizer.d.ts","sourceRoot":"","sources":["../../src/services/TtsTextSanitizer.ts"],"names":[],"mappings":"AAQA,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmCpD;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,kBAAkB,UAAO,GAAG,MAAM,EAAE,CAkB5F"}
|