@mentra/engine 0.1.0-dev.1 → 3.1.0-beta.100
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 +43 -29
- 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/ota-transport.d.ts +2 -0
- package/build/bluetooth-sdk/ota-transport.d.ts.map +1 -0
- package/build/bluetooth-sdk/ota-transport.js +2 -0
- package/build/bluetooth-sdk/ota-transport.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 +18 -15
- package/build/engine.d.ts.map +1 -1
- package/build/engine.js +2 -2
- package/build/engine.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/glasses.d.ts +3 -13
- package/build/facades/glasses.d.ts.map +1 -1
- package/build/facades/glasses.js +3 -3
- package/build/facades/glasses.js.map +1 -1
- package/build/facades/ota.d.ts +16 -22
- package/build/facades/ota.d.ts.map +1 -1
- package/build/facades/ota.js +13 -9
- 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 +83 -9
- package/build/facades/pairing.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 +7 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -5
- package/build/index.js.map +1 -1
- package/build/react/MentraLiveOtaFlow.d.ts +8 -2
- package/build/react/MentraLiveOtaFlow.d.ts.map +1 -1
- package/build/react/MentraLiveOtaFlow.js +256 -354
- package/build/react/MentraLiveOtaFlow.js.map +1 -1
- package/build/react/index.d.ts +1 -0
- package/build/react/index.d.ts.map +1 -1
- package/build/react/index.js +1 -0
- package/build/react/index.js.map +1 -1
- package/build/react/useMentraLiveOta.d.ts +84 -0
- package/build/react/useMentraLiveOta.d.ts.map +1 -0
- package/build/react/useMentraLiveOta.js +627 -0
- package/build/react/useMentraLiveOta.js.map +1 -0
- package/build/services/AppRegistry.d.ts +8 -0
- package/build/services/AppRegistry.d.ts.map +1 -1
- package/build/services/AppRegistry.js +15 -0
- package/build/services/AppRegistry.js.map +1 -1
- package/build/services/BlobStore.d.ts +2 -0
- package/build/services/BlobStore.d.ts.map +1 -1
- package/build/services/BlobStore.js +63 -10
- package/build/services/BlobStore.js.map +1 -1
- package/build/services/DisplayProcessor.d.ts +3 -3
- package/build/services/DisplayProcessor.js +3 -3
- package/build/services/DisplayProcessor.js.map +1 -1
- package/build/services/GlassesStatusProjection.d.ts +15 -2
- package/build/services/GlassesStatusProjection.d.ts.map +1 -1
- package/build/services/GlassesStatusProjection.js +3 -3
- package/build/services/GlassesStatusProjection.js.map +1 -1
- package/build/services/HotspotOtaTransport.d.ts.map +1 -1
- package/build/services/HotspotOtaTransport.js +8 -7
- package/build/services/HotspotOtaTransport.js.map +1 -1
- package/build/services/LocalDisplayManager.d.ts +2 -3
- package/build/services/LocalDisplayManager.d.ts.map +1 -1
- package/build/services/LocalDisplayManager.js +2 -3
- package/build/services/LocalDisplayManager.js.map +1 -1
- package/build/services/OtaAutoChain.d.ts +9 -2
- package/build/services/OtaAutoChain.d.ts.map +1 -1
- package/build/services/OtaAutoChain.js +10 -2
- package/build/services/OtaAutoChain.js.map +1 -1
- package/build/services/OtaInstallCoordinator.d.ts +26 -3
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
- package/build/services/OtaInstallCoordinator.js +38 -13
- package/build/services/OtaInstallCoordinator.js.map +1 -1
- package/build/services/OtaService.d.ts.map +1 -1
- package/build/services/OtaService.js +1 -1
- package/build/services/OtaService.js.map +1 -1
- package/build/services/OtaUpdateCheckService.d.ts +4 -1
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
- package/build/services/OtaUpdateCheckService.js +33 -21
- package/build/services/OtaUpdateCheckService.js.map +1 -1
- package/build/services/PhonePhotoCoordinator.js +1 -1
- package/build/services/PhonePhotoCoordinator.js.map +1 -1
- package/build/services/StreamLifecycleController.d.ts +3 -3
- package/build/services/StreamLifecycleController.js +3 -3
- package/build/services/StreamLifecycleController.js.map +1 -1
- package/build/services/asg/localNetworkTransport.d.ts.map +1 -1
- package/build/services/asg/localNetworkTransport.js +13 -12
- package/build/services/asg/localNetworkTransport.js.map +1 -1
- package/build/services/glassesClockSync.d.ts.map +1 -1
- package/build/services/glassesClockSync.js +5 -1
- package/build/services/glassesClockSync.js.map +1 -1
- package/build/services/otaDisplayState.d.ts +1 -1
- package/build/services/otaDisplayState.d.ts.map +1 -1
- package/build/services/otaDisplayState.js.map +1 -1
- package/build/services/otaInstallPolicy.d.ts +5 -1
- package/build/services/otaInstallPolicy.d.ts.map +1 -1
- package/build/services/otaInstallPolicy.js +4 -0
- 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 +2 -1
- package/build/services/otaManifestUrl.d.ts.map +1 -1
- package/build/services/otaManifestUrl.js +24 -32
- package/build/services/otaManifestUrl.js.map +1 -1
- package/build/services/otaReleaseVersion.d.ts +10 -0
- package/build/services/otaReleaseVersion.d.ts.map +1 -0
- package/build/services/otaReleaseVersion.js +14 -0
- package/build/services/otaReleaseVersion.js.map +1 -0
- package/build/stores/appVisibility.d.ts +3 -0
- package/build/stores/appVisibility.d.ts.map +1 -0
- package/build/stores/appVisibility.js +3 -0
- package/build/stores/appVisibility.js.map +1 -0
- package/build/stores/apps.d.ts.map +1 -1
- package/build/stores/apps.js +7 -1
- package/build/stores/apps.js.map +1 -1
- package/build/stores/core.d.ts +3 -3
- package/build/stores/core.d.ts.map +1 -1
- package/build/stores/core.js.map +1 -1
- package/build/stores/glasses.d.ts +10 -4
- package/build/stores/glasses.d.ts.map +1 -1
- package/build/stores/glasses.js.map +1 -1
- package/build/stores/settings.js +3 -3
- package/build/stores/settings.js.map +1 -1
- package/build/types/applet.d.ts +1 -1
- package/build/types/applet.js +1 -1
- package/build/types/applet.js.map +1 -1
- package/build/types/capabilities/even-realities-g1.d.ts.map +1 -1
- package/build/types/capabilities/even-realities-g1.js +2 -0
- package/build/types/capabilities/even-realities-g1.js.map +1 -1
- package/build/types/capabilities/even-realities-g2.d.ts.map +1 -1
- package/build/types/capabilities/even-realities-g2.js +2 -0
- package/build/types/capabilities/even-realities-g2.js.map +1 -1
- package/build/types/capabilities/mentra-display.d.ts.map +1 -1
- package/build/types/capabilities/mentra-display.js +2 -0
- package/build/types/capabilities/mentra-display.js.map +1 -1
- package/build/types/capabilities/mentra-live.d.ts.map +1 -1
- package/build/types/capabilities/mentra-live.js +2 -0
- package/build/types/capabilities/mentra-live.js.map +1 -1
- package/build/types/capabilities/nimo.d.ts +9 -0
- package/build/types/capabilities/nimo.d.ts.map +1 -0
- package/build/types/capabilities/nimo.js +57 -0
- package/build/types/capabilities/nimo.js.map +1 -0
- package/build/types/capabilities/none.d.ts.map +1 -1
- package/build/types/capabilities/none.js +2 -0
- package/build/types/capabilities/none.js.map +1 -1
- package/build/types/capabilities/simulated-glasses.d.ts.map +1 -1
- package/build/types/capabilities/simulated-glasses.js +2 -0
- package/build/types/capabilities/simulated-glasses.js.map +1 -1
- package/build/types/capabilities/vuzix-z100.d.ts.map +1 -1
- package/build/types/capabilities/vuzix-z100.js +2 -0
- package/build/types/capabilities/vuzix-z100.js.map +1 -1
- package/build/types/enums.d.ts +3 -26
- 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 +6 -15
- package/build/types/hardware.d.ts.map +1 -1
- package/build/types/hardware.js +4 -4
- package/build/types/hardware.js.map +1 -1
- package/build/types/index.d.ts +3 -7
- package/build/types/index.d.ts.map +1 -1
- package/build/types/index.js +3 -7
- package/build/types/index.js.map +1 -1
- package/build/utils/display/composer/ColumnComposer.d.ts +1 -1
- package/build/utils/display/composer/ColumnComposer.js +1 -1
- package/build/utils/display/composer/ColumnComposer.js.map +1 -1
- package/package.json +47 -22
- package/src/bluetooth-sdk/debug.ts +1 -0
- package/src/bluetooth-sdk/index.ts +2 -0
- package/src/bluetooth-sdk/ota-transport.ts +1 -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 +2 -2
- package/src/facades/display.ts +1 -1
- package/src/facades/glasses.ts +4 -4
- package/src/facades/ota.ts +23 -10
- package/src/facades/pairing.ts +92 -16
- package/src/facades/speech.ts +21 -7
- package/src/generated/releaseMetadata.ts +20 -0
- package/src/index.ts +16 -11
- package/src/react/MentraLiveOtaFlow.tsx +378 -480
- package/src/react/index.ts +14 -0
- package/src/react/useMentraLiveOta.ts +793 -0
- package/src/services/AppRegistry.ts +16 -0
- package/src/services/BlobStore.ts +57 -10
- package/src/services/DisplayProcessor.ts +3 -3
- package/src/services/GlassesStatusProjection.ts +7 -6
- package/src/services/HotspotOtaTransport.ts +8 -7
- package/src/services/LocalDisplayManager.ts +2 -3
- package/src/services/OtaAutoChain.ts +26 -2
- package/src/services/OtaInstallCoordinator.ts +40 -13
- package/src/services/OtaService.ts +1 -2
- package/src/services/OtaUpdateCheckService.ts +45 -27
- package/src/services/PhonePhotoCoordinator.ts +1 -1
- package/src/services/StreamLifecycleController.ts +3 -3
- package/src/services/asg/localNetworkTransport.ts +20 -19
- package/src/services/glassesClockSync.ts +5 -1
- package/src/services/otaDisplayState.ts +1 -1
- package/src/services/otaInstallPolicy.ts +5 -1
- package/src/services/otaLegacyMapping.ts +1 -1
- package/src/services/otaManifestPolicy.ts +42 -0
- package/src/services/otaManifestUrl.ts +27 -36
- package/src/services/otaReleaseVersion.ts +22 -0
- package/src/stores/appVisibility.ts +3 -0
- package/src/stores/apps.ts +7 -1
- package/src/stores/core.ts +4 -4
- package/src/stores/glasses.ts +13 -6
- package/src/stores/settings.ts +3 -3
- package/src/types/applet.ts +1 -1
- package/src/types/capabilities/even-realities-g1.ts +3 -0
- package/src/types/capabilities/even-realities-g2.ts +3 -0
- package/src/types/capabilities/mentra-display.ts +3 -0
- package/src/types/capabilities/mentra-live.ts +3 -0
- package/src/types/capabilities/nimo.ts +59 -0
- package/src/types/capabilities/none.ts +3 -0
- package/src/types/capabilities/simulated-glasses.ts +3 -0
- package/src/types/capabilities/vuzix-z100.ts +3 -0
- package/src/types/enums.ts +2 -27
- package/src/types/hardware.ts +7 -15
- package/src/types/index.ts +3 -6
- package/src/utils/display/composer/ColumnComposer.ts +1 -1
- 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 -67
- package/build/internal.d.ts.map +0 -1
- package/build/internal.js +0 -90
- package/build/internal.js.map +0 -1
- package/src/devtools.ts +0 -13
- package/src/internal.ts +0 -160
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamLifecycleController.js","sourceRoot":"","sources":["../../src/services/StreamLifecycleController.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgCH;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;IAkBjB;IAjBX,cAAc,CAAiC;IAC/C,WAAW,GAAgC,IAAI,GAAG,EAAE,CAAA;IACpD,UAAU,GAAG,CAAC,CAAA;IACd,cAAc,CAAQ;IACtB,MAAM,GAAG,KAAK,CAAA;IACd,QAAQ,GAAG,KAAK,CAAA;IAEP,MAAM,CAAiB;IACvB,QAAQ,CAAQ;IAChB,mBAAmB,CAAQ;IAC3B,YAAY,CAAQ;IACpB,aAAa,CAAQ;IACrB,mBAAmB,CAAgB;IACnC,GAAG,CAAc;IAElC,YACE,OAA+B,EACd,SAAmC;QAAnC,cAAS,GAAT,SAAS,CAA0B;QAEpD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAC,SAAS,EAAE,iBAAiB,EAAC,CAAC,CAAA;QAClE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAA;QACtD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;QACxC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;QAC1C,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C,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC9B,IAAI,CAAC,UAAU,IAAI,CAAC,CAAA;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAA;QAEjC,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,EAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAC,EACpE,wBAAwB,CACzB,CAAA;QAED,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QAEjE,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,KAAK,CACf;gBACE,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;aAClC,EACD,iDAAiD,CAClD,CAAA;YAED,KAAK,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAA;QACjC,CAAC;IACH,CAAC;IAEO,gBAAgB;QACtB,KAAK,MAAM,EAAC,OAAO,EAAC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;YAClD,YAAY,CAAC,OAAO,CAAC,CAAA;QACvB,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC;IAEO,WAAW;QACjB,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAChD,CAAC;CACF","sourcesContent":["/**\n * Drives RTMP stream liveliness checks via a keep-alive heartbeat:\n * `setActive(true)` starts the timer; each tick sends a keep-alive with a\n * fresh ackId; `maxMissedAcks` consecutive timeouts fire `onTimeout`.\n *\n * Mirror of `cloud/packages/cloud/src/services/streaming/StreamLifecycleController.ts`\n * — kept byte-equivalent except for the `LifecycleLogger` interface (pino\n * isn't a phone dep). Behavior changes must land in both files.\n */\n\nexport interface LifecycleLogger {\n child(bindings: Record<string, unknown>): LifecycleLogger\n debug(...args: unknown[]): void\n warn(...args: unknown[]): void\n error(...args: unknown[]): void\n}\n\ninterface StreamLifecycleCallbacks {\n sendKeepAlive: (ackId: string) => Promise<void> | void\n onTimeout: () => Promise<void> | void\n onKeepAliveSent?: (ackId: string) => void\n onKeepAliveAcked?: (ackId: string, ageMs: number) => void\n onKeepAliveMissed?: (ackId: string, ageMs: number, missedCount: number) => void\n}\n\nexport interface StreamLifecycleOptions {\n logger: LifecycleLogger\n streamId: string\n keepAliveIntervalMs: number\n ackTimeoutMs: number\n maxMissedAcks: number\n shouldSendKeepAlive?: () => boolean\n now?: () => number\n}\n\ninterface PendingAckInfo {\n sentAt: number\n timeout: ReturnType<typeof setTimeout>\n}\n\n/**\n * Drives RTMP stream liveliness checks. Activate to start the heartbeat;\n * each tick sends a keep-alive with a fresh ackId and arms a timeout. When\n * `maxMissedAcks` consecutive timeouts fire, `onTimeout` is invoked and the\n * caller is expected to tear the stream down.\n */\nexport class StreamLifecycleController {\n private keepAliveTimer?: ReturnType<typeof setInterval>\n private pendingAcks: Map<string, PendingAckInfo> = new Map()\n private missedAcks = 0\n private lastActivityMs: number\n private active = false\n private disposed = false\n\n private readonly logger: LifecycleLogger\n private readonly streamId: string\n private readonly keepAliveIntervalMs: number\n private readonly ackTimeoutMs: number\n private readonly maxMissedAcks: number\n private readonly shouldSendKeepAlive?: () => boolean\n private readonly now: () => number\n\n constructor(\n options: StreamLifecycleOptions,\n private readonly callbacks: StreamLifecycleCallbacks,\n ) {\n this.logger = options.logger.child({component: \"StreamLifecycle\"})\n this.streamId = options.streamId\n this.keepAliveIntervalMs = options.keepAliveIntervalMs\n this.ackTimeoutMs = options.ackTimeoutMs\n this.maxMissedAcks = options.maxMissedAcks\n this.shouldSendKeepAlive = options.shouldSendKeepAlive\n this.now = options.now ?? (() => Date.now())\n this.lastActivityMs = this.now()\n }\n\n setActive(active: boolean): void {\n if (this.disposed || this.active === active) return\n\n this.logger.debug({streamId: this.streamId, active}, \"Updating lifecycle active state\")\n\n this.active = active\n if (active) {\n this.startTimer()\n } else {\n this.stopTimer()\n this.clearPendingAcks()\n this.missedAcks = 0\n }\n }\n\n recordActivity(): void {\n this.lastActivityMs = this.now()\n this.missedAcks = 0\n }\n\n handleAck(ackId: string): void {\n if (this.disposed) return\n\n const ackInfo = this.pendingAcks.get(ackId)\n if (!ackInfo) {\n this.logger.warn({streamId: this.streamId, ackId}, \"Received unknown keep-alive ACK\")\n return\n }\n\n clearTimeout(ackInfo.timeout)\n this.pendingAcks.delete(ackId)\n this.recordActivity()\n\n this.callbacks.onKeepAliveAcked?.(ackId, this.now() - ackInfo.sentAt)\n }\n\n dispose(): void {\n if (this.disposed) return\n\n this.disposed = true\n this.stopTimer()\n this.clearPendingAcks()\n this.logger.debug({streamId: this.streamId}, \"Lifecycle disposed\")\n }\n\n getLastActivityMs(): number {\n return this.lastActivityMs\n }\n\n private startTimer(): void {\n if (this.keepAliveTimer) return\n this.keepAliveTimer = setInterval(() => {\n void this.tick()\n }, this.keepAliveIntervalMs)\n this.logger.debug({streamId: this.streamId}, \"Keep-alive timer started\")\n }\n\n private stopTimer(): void {\n if (this.keepAliveTimer) {\n clearInterval(this.keepAliveTimer)\n this.keepAliveTimer = undefined\n this.logger.debug({streamId: this.streamId}, \"Keep-alive timer stopped\")\n }\n }\n\n private async tick(): Promise<void> {\n if (this.disposed || !this.active) return\n\n if (this.shouldSendKeepAlive && !this.shouldSendKeepAlive()) {\n this.logger.warn(\n {streamId: this.streamId},\n \"Skipping keep-alive send because transport is unavailable\",\n )\n return\n }\n\n const ackId = this.createAckId()\n const sentAt = this.now()\n\n const timeout = setTimeout(() => {\n this.onAckTimeout(ackId, sentAt)\n }, this.ackTimeoutMs)\n\n this.pendingAcks.set(ackId, {sentAt, timeout})\n this.callbacks.onKeepAliveSent?.(ackId)\n\n try {\n await this.callbacks.sendKeepAlive(ackId)\n } catch (error) {\n this.logger.error({streamId: this.streamId, ackId, error}, \"Error sending keep-alive\")\n }\n }\n\n private onAckTimeout(ackId: string, sentAt: number): void {\n if (this.disposed) return\n\n // Race guard: handleAck may have processed the ACK between the timeout\n // being scheduled and this callback running. In that case the ackId is\n // no longer pending — counting it as missed would falsely escalate.\n if (!this.pendingAcks.has(ackId)) return\n\n this.pendingAcks.delete(ackId)\n this.missedAcks += 1\n const ageMs = this.now() - sentAt\n\n this.logger.warn(\n {streamId: this.streamId, ackId, missedAcks: this.missedAcks, ageMs},\n \"Keep-alive ACK timeout\",\n )\n\n this.callbacks.onKeepAliveMissed?.(ackId, ageMs, this.missedAcks)\n\n if (this.missedAcks >= this.maxMissedAcks) {\n this.logger.error(\n {\n streamId: this.streamId,\n missedAcks: this.missedAcks,\n maxMissedAcks: this.maxMissedAcks,\n },\n \"Maximum missed ACKs reached; triggering timeout\",\n )\n\n void this.callbacks.onTimeout()\n }\n }\n\n private clearPendingAcks(): void {\n for (const {timeout} of this.pendingAcks.values()) {\n clearTimeout(timeout)\n }\n this.pendingAcks.clear()\n }\n\n private createAckId(): string {\n return `a${this.now().toString(36).slice(-5)}`\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StreamLifecycleController.js","sourceRoot":"","sources":["../../src/services/StreamLifecycleController.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgCH;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;IAkBjB;IAjBX,cAAc,CAAiC;IAC/C,WAAW,GAAgC,IAAI,GAAG,EAAE,CAAA;IACpD,UAAU,GAAG,CAAC,CAAA;IACd,cAAc,CAAQ;IACtB,MAAM,GAAG,KAAK,CAAA;IACd,QAAQ,GAAG,KAAK,CAAA;IAEP,MAAM,CAAiB;IACvB,QAAQ,C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,SAAS,EAAE,CAAA;QACjC,CAAC;IACH,CAAC;IAEO,gBAAgB;QACtB,KAAK,MAAM,EAAC,OAAO,EAAC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;YAClD,YAAY,CAAC,OAAO,CAAC,CAAA;QACvB,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC;IAEO,WAAW;QACjB,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAChD,CAAC;CACF","sourcesContent":["/**\n * Drives RTMP stream liveliness checks via a keep-alive heartbeat:\n * `setActive(true)` starts the timer; each tick sends a keep-alive with a\n * fresh ackId; `maxMissedAcks` consecutive timeouts fire `onTimeout`.\n *\n * Phone-owned successor to the retired cloud stream lifecycle controller.\n * It uses the local `LifecycleLogger` interface because pino is not a phone\n * dependency.\n */\n\nexport interface LifecycleLogger {\n child(bindings: Record<string, unknown>): LifecycleLogger\n debug(...args: unknown[]): void\n warn(...args: unknown[]): void\n error(...args: unknown[]): void\n}\n\ninterface StreamLifecycleCallbacks {\n sendKeepAlive: (ackId: string) => Promise<void> | void\n onTimeout: () => Promise<void> | void\n onKeepAliveSent?: (ackId: string) => void\n onKeepAliveAcked?: (ackId: string, ageMs: number) => void\n onKeepAliveMissed?: (ackId: string, ageMs: number, missedCount: number) => void\n}\n\nexport interface StreamLifecycleOptions {\n logger: LifecycleLogger\n streamId: string\n keepAliveIntervalMs: number\n ackTimeoutMs: number\n maxMissedAcks: number\n shouldSendKeepAlive?: () => boolean\n now?: () => number\n}\n\ninterface PendingAckInfo {\n sentAt: number\n timeout: ReturnType<typeof setTimeout>\n}\n\n/**\n * Drives RTMP stream liveliness checks. Activate to start the heartbeat;\n * each tick sends a keep-alive with a fresh ackId and arms a timeout. When\n * `maxMissedAcks` consecutive timeouts fire, `onTimeout` is invoked and the\n * caller is expected to tear the stream down.\n */\nexport class StreamLifecycleController {\n private keepAliveTimer?: ReturnType<typeof setInterval>\n private pendingAcks: Map<string, PendingAckInfo> = new Map()\n private missedAcks = 0\n private lastActivityMs: number\n private active = false\n private disposed = false\n\n private readonly logger: LifecycleLogger\n private readonly streamId: string\n private readonly keepAliveIntervalMs: number\n private readonly ackTimeoutMs: number\n private readonly maxMissedAcks: number\n private readonly shouldSendKeepAlive?: () => boolean\n private readonly now: () => number\n\n constructor(\n options: StreamLifecycleOptions,\n private readonly callbacks: StreamLifecycleCallbacks,\n ) {\n this.logger = options.logger.child({component: \"StreamLifecycle\"})\n this.streamId = options.streamId\n this.keepAliveIntervalMs = options.keepAliveIntervalMs\n this.ackTimeoutMs = options.ackTimeoutMs\n this.maxMissedAcks = options.maxMissedAcks\n this.shouldSendKeepAlive = options.shouldSendKeepAlive\n this.now = options.now ?? (() => Date.now())\n this.lastActivityMs = this.now()\n }\n\n setActive(active: boolean): void {\n if (this.disposed || this.active === active) return\n\n this.logger.debug({streamId: this.streamId, active}, \"Updating lifecycle active state\")\n\n this.active = active\n if (active) {\n this.startTimer()\n } else {\n this.stopTimer()\n this.clearPendingAcks()\n this.missedAcks = 0\n }\n }\n\n recordActivity(): void {\n this.lastActivityMs = this.now()\n this.missedAcks = 0\n }\n\n handleAck(ackId: string): void {\n if (this.disposed) return\n\n const ackInfo = this.pendingAcks.get(ackId)\n if (!ackInfo) {\n this.logger.warn({streamId: this.streamId, ackId}, \"Received unknown keep-alive ACK\")\n return\n }\n\n clearTimeout(ackInfo.timeout)\n this.pendingAcks.delete(ackId)\n this.recordActivity()\n\n this.callbacks.onKeepAliveAcked?.(ackId, this.now() - ackInfo.sentAt)\n }\n\n dispose(): void {\n if (this.disposed) return\n\n this.disposed = true\n this.stopTimer()\n this.clearPendingAcks()\n this.logger.debug({streamId: this.streamId}, \"Lifecycle disposed\")\n }\n\n getLastActivityMs(): number {\n return this.lastActivityMs\n }\n\n private startTimer(): void {\n if (this.keepAliveTimer) return\n this.keepAliveTimer = setInterval(() => {\n void this.tick()\n }, this.keepAliveIntervalMs)\n this.logger.debug({streamId: this.streamId}, \"Keep-alive timer started\")\n }\n\n private stopTimer(): void {\n if (this.keepAliveTimer) {\n clearInterval(this.keepAliveTimer)\n this.keepAliveTimer = undefined\n this.logger.debug({streamId: this.streamId}, \"Keep-alive timer stopped\")\n }\n }\n\n private async tick(): Promise<void> {\n if (this.disposed || !this.active) return\n\n if (this.shouldSendKeepAlive && !this.shouldSendKeepAlive()) {\n this.logger.warn(\n {streamId: this.streamId},\n \"Skipping keep-alive send because transport is unavailable\",\n )\n return\n }\n\n const ackId = this.createAckId()\n const sentAt = this.now()\n\n const timeout = setTimeout(() => {\n this.onAckTimeout(ackId, sentAt)\n }, this.ackTimeoutMs)\n\n this.pendingAcks.set(ackId, {sentAt, timeout})\n this.callbacks.onKeepAliveSent?.(ackId)\n\n try {\n await this.callbacks.sendKeepAlive(ackId)\n } catch (error) {\n this.logger.error({streamId: this.streamId, ackId, error}, \"Error sending keep-alive\")\n }\n }\n\n private onAckTimeout(ackId: string, sentAt: number): void {\n if (this.disposed) return\n\n // Race guard: handleAck may have processed the ACK between the timeout\n // being scheduled and this callback running. In that case the ackId is\n // no longer pending — counting it as missed would falsely escalate.\n if (!this.pendingAcks.has(ackId)) return\n\n this.pendingAcks.delete(ackId)\n this.missedAcks += 1\n const ageMs = this.now() - sentAt\n\n this.logger.warn(\n {streamId: this.streamId, ackId, missedAcks: this.missedAcks, ageMs},\n \"Keep-alive ACK timeout\",\n )\n\n this.callbacks.onKeepAliveMissed?.(ackId, ageMs, this.missedAcks)\n\n if (this.missedAcks >= this.maxMissedAcks) {\n this.logger.error(\n {\n streamId: this.streamId,\n missedAcks: this.missedAcks,\n maxMissedAcks: this.maxMissedAcks,\n },\n \"Maximum missed ACKs reached; triggering timeout\",\n )\n\n void this.callbacks.onTimeout()\n }\n }\n\n private clearPendingAcks(): void {\n for (const {timeout} of this.pendingAcks.values()) {\n clearTimeout(timeout)\n }\n this.pendingAcks.clear()\n }\n\n private createAckId(): string {\n return `a${this.now().toString(36).slice(-5)}`\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localNetworkTransport.d.ts","sourceRoot":"","sources":["../../../src/services/asg/localNetworkTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AAMnD,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAA;AAO1D,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,OAAO,CAEzF;AAuBD,eAAO,MAAM,qBAAqB;oCACF,OAAO;oCACP,OAAO;kBAEjB,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;kBAYtD,OAAO,CAAC,IAAI,CAAC;eAQhB,MAAM,GAAG,GAAG,GAAG,OAAO,SAAS,WAAW,uBAAuB,OAAO,CAAC,QAAQ,CAAC;0BA8B7E,eAAe,GAAG,cAAc;
|
|
1
|
+
{"version":3,"file":"localNetworkTransport.d.ts","sourceRoot":"","sources":["../../../src/services/asg/localNetworkTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AAMnD,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAA;AAO1D,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,OAAO,CAEzF;AAuBD,eAAO,MAAM,qBAAqB;oCACF,OAAO;oCACP,OAAO;kBAEjB,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;kBAYtD,OAAO,CAAC,IAAI,CAAC;eAQhB,MAAM,GAAG,GAAG,GAAG,OAAO,SAAS,WAAW,uBAAuB,OAAO,CAAC,QAAQ,CAAC;0BA8B7E,eAAe,GAAG,cAAc;wBA8DlC,MAAM,GAAG,IAAI;CASlC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as RNFS from "@dr.pogodin/react-native-fs";
|
|
2
|
-
import {
|
|
2
|
+
import { otaLocalNetwork } from "@mentra/bluetooth-sdk/ota-transport";
|
|
3
3
|
import { Buffer } from "buffer";
|
|
4
4
|
import { Platform } from "react-native";
|
|
5
5
|
import WifiManager from "react-native-wifi-reborn";
|
|
@@ -11,7 +11,7 @@ export function shouldUseScopedLocalNetwork(os, moduleAvailable) {
|
|
|
11
11
|
return os === "android" && moduleAvailable;
|
|
12
12
|
}
|
|
13
13
|
function supportsScopedConnection() {
|
|
14
|
-
return shouldUseScopedLocalNetwork(Platform.OS,
|
|
14
|
+
return shouldUseScopedLocalNetwork(Platform.OS, otaLocalNetwork.isAvailable());
|
|
15
15
|
}
|
|
16
16
|
function normalizeHeaders(headers) {
|
|
17
17
|
if (!headers)
|
|
@@ -40,22 +40,22 @@ export const localNetworkTransport = {
|
|
|
40
40
|
await WifiManager.connectToProtectedSSID(ssid, password, false, false);
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
|
-
const result = await
|
|
43
|
+
const result = await otaLocalNetwork.connect(ssid, password);
|
|
44
44
|
scopedConnectionActive = true;
|
|
45
45
|
return result.localAddress;
|
|
46
46
|
},
|
|
47
47
|
async disconnect() {
|
|
48
48
|
if (supportsScopedConnection()) {
|
|
49
|
-
await
|
|
49
|
+
await otaLocalNetwork.disconnect().catch(() => { });
|
|
50
50
|
}
|
|
51
51
|
scopedConnectionActive = false;
|
|
52
52
|
nativeJobs.clear();
|
|
53
53
|
},
|
|
54
54
|
async fetch(url, init, timeoutMs = 30_000) {
|
|
55
|
-
if (!scopedConnectionActive || !
|
|
55
|
+
if (!scopedConnectionActive || !otaLocalNetwork.isAvailable() || typeof url !== "string") {
|
|
56
56
|
return globalThis.fetch(url, init);
|
|
57
57
|
}
|
|
58
|
-
const nativeModule =
|
|
58
|
+
const nativeModule = otaLocalNetwork;
|
|
59
59
|
const id = requestId("request");
|
|
60
60
|
const signal = init?.signal;
|
|
61
61
|
const cancel = () => void nativeModule.cancel(id);
|
|
@@ -75,13 +75,13 @@ export const localNetworkTransport = {
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
downloadFile(options) {
|
|
78
|
-
if (!scopedConnectionActive || !
|
|
78
|
+
if (!scopedConnectionActive || !otaLocalNetwork.isAvailable())
|
|
79
79
|
return RNFS.downloadFile(options);
|
|
80
80
|
const jobId = nextJobId++;
|
|
81
81
|
const id = requestId("download");
|
|
82
82
|
let began = false;
|
|
83
83
|
nativeJobs.set(jobId, id);
|
|
84
|
-
const subscription =
|
|
84
|
+
const subscription = otaLocalNetwork.onDownloadProgress((event) => {
|
|
85
85
|
if (event.requestId !== id)
|
|
86
86
|
return;
|
|
87
87
|
if (!began) {
|
|
@@ -99,7 +99,8 @@ export const localNetworkTransport = {
|
|
|
99
99
|
bytesWritten: event.bytesWritten,
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
|
-
const promise =
|
|
102
|
+
const promise = otaLocalNetwork
|
|
103
|
+
.download(id, options.fromUrl, options.toFile, options.headers || {}, options.connectionTimeout || 30_000, options.readTimeout || 30_000)
|
|
103
104
|
.then((result) => {
|
|
104
105
|
if (!began) {
|
|
105
106
|
options.begin?.({
|
|
@@ -129,15 +130,15 @@ export const localNetworkTransport = {
|
|
|
129
130
|
},
|
|
130
131
|
stopDownload(jobId) {
|
|
131
132
|
const nativeId = nativeJobs.get(jobId);
|
|
132
|
-
if (nativeId &&
|
|
133
|
+
if (nativeId && otaLocalNetwork.isAvailable()) {
|
|
133
134
|
cancelledNativeJobs.add(jobId);
|
|
134
|
-
void
|
|
135
|
+
void otaLocalNetwork.cancel(nativeId);
|
|
135
136
|
return;
|
|
136
137
|
}
|
|
137
138
|
RNFS.stopDownload(jobId);
|
|
138
139
|
},
|
|
139
140
|
};
|
|
140
|
-
|
|
141
|
+
otaLocalNetwork.onNetworkLost(() => {
|
|
141
142
|
scopedConnectionActive = false;
|
|
142
143
|
nativeJobs.clear();
|
|
143
144
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localNetworkTransport.js","sourceRoot":"","sources":["../../../src/services/asg/localNetworkTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AACnD,OAAO,EAAC,kBAAkB,EAAoC,MAAM,gCAAgC,CAAA;AACpG,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AACrC,OAAO,WAAW,MAAM,0BAA0B,CAAA;AAKlD,IAAI,sBAAsB,GAAG,KAAK,CAAA;AAClC,IAAI,SAAS,GAAG,SAAS,CAAA;AACzB,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAA;AAC5C,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAU,CAAA;AAE7C,MAAM,UAAU,2BAA2B,CAAC,EAAU,EAAE,eAAwB;IAC9E,OAAO,EAAE,KAAK,SAAS,IAAI,eAAe,CAAA;AAC5C,CAAC;AAED,SAAS,wBAAwB;IAC/B,OAAO,2BAA2B,CAAC,QAAQ,CAAC,EAAE,EAAE,kBAAkB,IAAI,IAAI,CAAC,CAAA;AAC7E,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAqB;IAC7C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAA;IACvB,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;QAC/B,MAAM,MAAM,GAA2B,EAAE,CAAA;QACzC,OAAO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AA;IAC1B,CAAC;CACF,CAAA;AAED,kBAAkB,EAAE,WAAW,CAAC,aAAa,EAAE,GAAG,EAAE;IAClD,sBAAsB,GAAG,KAAK,CAAA;IAC9B,UAAU,CAAC,KAAK,EAAE,CAAA;AACpB,CAAC,CAAC,CAAA","sourcesContent":["import * as RNFS from \"@dr.pogodin/react-native-fs\"\nimport {MentraLocalNetwork, type LocalNetworkDownloadProgress} from \"@mentra/bluetooth-sdk/internal\"\nimport {Buffer} from \"buffer\"\nimport {Platform} from \"react-native\"\nimport WifiManager from \"react-native-wifi-reborn\"\n\ntype DownloadOptions = Parameters<typeof RNFS.downloadFile>[0]\ntype DownloadHandle = ReturnType<typeof RNFS.downloadFile>\n\nlet scopedConnectionActive = false\nlet nextJobId = 1_000_000\nconst nativeJobs = new Map<number, string>()\nconst cancelledNativeJobs = new Set<number>()\n\nexport function shouldUseScopedLocalNetwork(os: string, moduleAvailable: boolean): boolean {\n return os === \"android\" && moduleAvailable\n}\n\nfunction supportsScopedConnection(): boolean {\n return shouldUseScopedLocalNetwork(Platform.OS, MentraLocalNetwork != null)\n}\n\nfunction normalizeHeaders(headers?: HeadersInit): Record<string, string> {\n if (!headers) return {}\n if (headers instanceof Headers) {\n const result: Record<string, string> = {}\n headers.forEach((value, key) => {\n result[key] = value\n })\n return result\n }\n if (Array.isArray(headers)) return Object.fromEntries(headers)\n return {...headers}\n}\n\nfunction requestId(prefix: string): string {\n return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2)}`\n}\n\nexport const localNetworkTransport = {\n supportsScopedConnection: (): boolean => supportsScopedConnection(),\n isScopedConnectionActive: (): boolean => scopedConnectionActive,\n\n async connect(ssid: string, password: string): Promise<string | undefined> {\n scopedConnectionActive = false\n nativeJobs.clear()\n if (!supportsScopedConnection()) {\n await WifiManager.connectToProtectedSSID(ssid, password, false, false)\n return undefined\n }\n const result = await MentraLocalNetwork!.connect(ssid, password)\n scopedConnectionActive = true\n return result.localAddress\n },\n\n async disconnect(): Promise<void> {\n if (supportsScopedConnection()) {\n await MentraLocalNetwork!.disconnect().catch(() => {})\n }\n scopedConnectionActive = false\n nativeJobs.clear()\n },\n\n async fetch(url: string | URL | Request, init?: RequestInit, timeoutMs = 30_000): Promise<Response> {\n if (!scopedConnectionActive || !MentraLocalNetwork || typeof url !== \"string\") {\n return globalThis.fetch(url, init)\n }\n\n const nativeModule = MentraLocalNetwork\n const id = requestId(\"request\")\n const signal = init?.signal\n const cancel = () => void nativeModule.cancel(id)\n if (signal?.aborted) throw new Error(\"Request aborted\")\n signal?.addEventListener(\"abort\", cancel, {once: true})\n try {\n const result = await nativeModule.request(\n id,\n url,\n init?.method || \"GET\",\n normalizeHeaders(init?.headers),\n typeof init?.body === \"string\" ? init.body : null,\n timeoutMs,\n )\n const bytes = Buffer.from(result.bodyBase64, \"base64\")\n return new Response(bytes as unknown as BodyInit, {\n status: result.status,\n headers: result.headers,\n })\n } finally {\n signal?.removeEventListener(\"abort\", cancel)\n }\n },\n\n downloadFile(options: DownloadOptions): DownloadHandle {\n if (!scopedConnectionActive || !MentraLocalNetwork) return RNFS.downloadFile(options)\n\n const jobId = nextJobId++\n const id = requestId(\"download\")\n let began = false\n nativeJobs.set(jobId, id)\n const subscription = MentraLocalNetwork.addListener(\"downloadProgress\", (event: LocalNetworkDownloadProgress) => {\n if (event.requestId !== id) return\n if (!began) {\n began = true\n options.begin?.({\n jobId,\n statusCode: event.statusCode || 200,\n contentLength: event.contentLength,\n headers: event.headers || {},\n })\n }\n options.progress?.({\n jobId,\n contentLength: event.contentLength,\n bytesWritten: event.bytesWritten,\n })\n })\n\n const promise = MentraLocalNetwork.download(\n id,\n options.fromUrl,\n options.toFile,\n options.headers || {},\n options.connectionTimeout || 30_000,\n options.readTimeout || 30_000,\n )\n .then((result) => {\n if (!began) {\n options.begin?.({\n jobId,\n statusCode: result.statusCode,\n contentLength: result.bytesWritten,\n headers: result.headers,\n })\n }\n return {\n jobId,\n statusCode: result.statusCode,\n bytesWritten: result.bytesWritten,\n }\n })\n .catch((error) => {\n if (cancelledNativeJobs.has(jobId)) throw new Error(\"Sync cancelled\")\n throw error\n })\n .finally(() => {\n nativeJobs.delete(jobId)\n cancelledNativeJobs.delete(jobId)\n subscription.remove()\n })\n\n return {jobId, promise} as DownloadHandle\n },\n\n stopDownload(jobId: number): void {\n const nativeId = nativeJobs.get(jobId)\n if (nativeId && MentraLocalNetwork) {\n cancelledNativeJobs.add(jobId)\n void MentraLocalNetwork.cancel(nativeId)\n return\n }\n RNFS.stopDownload(jobId)\n },\n}\n\nMentraLocalNetwork?.addListener(\"networkLost\", () => {\n scopedConnectionActive = false\n nativeJobs.clear()\n})\n"]}
|
|
1
|
+
{"version":3,"file":"localNetworkTransport.js","sourceRoot":"","sources":["../../../src/services/asg/localNetworkTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AACnD,OAAO,EAAC,eAAe,EAAuC,MAAM,qCAAqC,CAAA;AACzG,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AACrC,OAAO,WAAW,MAAM,0BAA0B,CAAA;AAKlD,IAAI,sBAAsB,GAAG,KAAK,CAAA;AAClC,IAAI,SAAS,GAAG,SAAS,CAAA;AACzB,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAA;AAC5C,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAU,CAAA;AAE7C,MAAM,UAAU,2BAA2B,CAAC,EAAU,EAAE,eAAwB;IAC9E,OAAO,EAAE,KAAK,SAAS,IAAI,eAAe,CAAA;AAC5C,CAAC;AAED,SAAS,wBAAwB;IAC/B,OAAO,2BAA2B,CAAC,QAAQ,CAAC,EAAE,EAAE,eAAe,CAAC,WAAW,EAAE,CAAC,CAAA;AAChF,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAqB;IAC7C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,C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B,KAAK,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YACrC,OAAM;QACR,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;CACF,CAAA;AAED,eAAe,CAAC,aAAa,CAAC,GAAG,EAAE;IACjC,sBAAsB,GAAG,KAAK,CAAA;IAC9B,UAAU,CAAC,KAAK,EAAE,CAAA;AACpB,CAAC,CAAC,CAAA","sourcesContent":["import * as RNFS from \"@dr.pogodin/react-native-fs\"\nimport {otaLocalNetwork, type OtaLocalNetworkDownloadProgress} from \"@mentra/bluetooth-sdk/ota-transport\"\nimport {Buffer} from \"buffer\"\nimport {Platform} from \"react-native\"\nimport WifiManager from \"react-native-wifi-reborn\"\n\ntype DownloadOptions = Parameters<typeof RNFS.downloadFile>[0]\ntype DownloadHandle = ReturnType<typeof RNFS.downloadFile>\n\nlet scopedConnectionActive = false\nlet nextJobId = 1_000_000\nconst nativeJobs = new Map<number, string>()\nconst cancelledNativeJobs = new Set<number>()\n\nexport function shouldUseScopedLocalNetwork(os: string, moduleAvailable: boolean): boolean {\n return os === \"android\" && moduleAvailable\n}\n\nfunction supportsScopedConnection(): boolean {\n return shouldUseScopedLocalNetwork(Platform.OS, otaLocalNetwork.isAvailable())\n}\n\nfunction normalizeHeaders(headers?: HeadersInit): Record<string, string> {\n if (!headers) return {}\n if (headers instanceof Headers) {\n const result: Record<string, string> = {}\n headers.forEach((value, key) => {\n result[key] = value\n })\n return result\n }\n if (Array.isArray(headers)) return Object.fromEntries(headers)\n return {...headers}\n}\n\nfunction requestId(prefix: string): string {\n return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2)}`\n}\n\nexport const localNetworkTransport = {\n supportsScopedConnection: (): boolean => supportsScopedConnection(),\n isScopedConnectionActive: (): boolean => scopedConnectionActive,\n\n async connect(ssid: string, password: string): Promise<string | undefined> {\n scopedConnectionActive = false\n nativeJobs.clear()\n if (!supportsScopedConnection()) {\n await WifiManager.connectToProtectedSSID(ssid, password, false, false)\n return undefined\n }\n const result = await otaLocalNetwork.connect(ssid, password)\n scopedConnectionActive = true\n return result.localAddress\n },\n\n async disconnect(): Promise<void> {\n if (supportsScopedConnection()) {\n await otaLocalNetwork.disconnect().catch(() => {})\n }\n scopedConnectionActive = false\n nativeJobs.clear()\n },\n\n async fetch(url: string | URL | Request, init?: RequestInit, timeoutMs = 30_000): Promise<Response> {\n if (!scopedConnectionActive || !otaLocalNetwork.isAvailable() || typeof url !== \"string\") {\n return globalThis.fetch(url, init)\n }\n\n const nativeModule = otaLocalNetwork\n const id = requestId(\"request\")\n const signal = init?.signal\n const cancel = () => void nativeModule.cancel(id)\n if (signal?.aborted) throw new Error(\"Request aborted\")\n signal?.addEventListener(\"abort\", cancel, {once: true})\n try {\n const result = await nativeModule.request(\n id,\n url,\n init?.method || \"GET\",\n normalizeHeaders(init?.headers),\n typeof init?.body === \"string\" ? init.body : null,\n timeoutMs,\n )\n const bytes = Buffer.from(result.bodyBase64, \"base64\")\n return new Response(bytes as unknown as BodyInit, {\n status: result.status,\n headers: result.headers,\n })\n } finally {\n signal?.removeEventListener(\"abort\", cancel)\n }\n },\n\n downloadFile(options: DownloadOptions): DownloadHandle {\n if (!scopedConnectionActive || !otaLocalNetwork.isAvailable()) return RNFS.downloadFile(options)\n\n const jobId = nextJobId++\n const id = requestId(\"download\")\n let began = false\n nativeJobs.set(jobId, id)\n const subscription = otaLocalNetwork.onDownloadProgress((event: OtaLocalNetworkDownloadProgress) => {\n if (event.requestId !== id) return\n if (!began) {\n began = true\n options.begin?.({\n jobId,\n statusCode: event.statusCode || 200,\n contentLength: event.contentLength,\n headers: event.headers || {},\n })\n }\n options.progress?.({\n jobId,\n contentLength: event.contentLength,\n bytesWritten: event.bytesWritten,\n })\n })\n\n const promise = otaLocalNetwork\n .download(\n id,\n options.fromUrl,\n options.toFile,\n options.headers || {},\n options.connectionTimeout || 30_000,\n options.readTimeout || 30_000,\n )\n .then((result) => {\n if (!began) {\n options.begin?.({\n jobId,\n statusCode: result.statusCode,\n contentLength: result.bytesWritten,\n headers: result.headers,\n })\n }\n return {\n jobId,\n statusCode: result.statusCode,\n bytesWritten: result.bytesWritten,\n }\n })\n .catch((error) => {\n if (cancelledNativeJobs.has(jobId)) throw new Error(\"Sync cancelled\")\n throw error\n })\n .finally(() => {\n nativeJobs.delete(jobId)\n cancelledNativeJobs.delete(jobId)\n subscription.remove()\n })\n\n return {jobId, promise} as DownloadHandle\n },\n\n stopDownload(jobId: number): void {\n const nativeId = nativeJobs.get(jobId)\n if (nativeId && otaLocalNetwork.isAvailable()) {\n cancelledNativeJobs.add(jobId)\n void otaLocalNetwork.cancel(nativeId)\n return\n }\n RNFS.stopDownload(jobId)\n },\n}\n\notaLocalNetwork.onNetworkLost(() => {\n scopedConnectionActive = false\n nativeJobs.clear()\n})\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glassesClockSync.d.ts","sourceRoot":"","sources":["../../src/services/glassesClockSync.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,eAAO,MAAM,eAAe,MAAM,CAAA;AASlC,0BAA0B;AAC1B,wBAAgB,gCAAgC,IAAI,IAAI,CAGvD;AAMD;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,EAAE,YAAY,SAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAS3G;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"glassesClockSync.d.ts","sourceRoot":"","sources":["../../src/services/glassesClockSync.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,eAAO,MAAM,eAAe,MAAM,CAAA;AASlC,0BAA0B;AAC1B,wBAAgB,gCAAgC,IAAI,IAAI,CAGvD;AAMD;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,EAAE,YAAY,SAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAS3G;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC,CAmDlB;AAED;;GAEG;AACH,wBAAsB,mCAAmC,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAW5G"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Push phone time to glasses only when clock skew is detected (gallery sync, OTA, etc.).
|
|
3
3
|
*/
|
|
4
|
-
import BluetoothSdk from "@mentra/bluetooth-sdk
|
|
4
|
+
import BluetoothSdk from "@mentra/bluetooth-sdk";
|
|
5
5
|
import { BgTimer } from "../utils/timers";
|
|
6
6
|
import { useGlassesStore } from "../stores/glasses";
|
|
7
7
|
import { resolveOtaManifestUrl } from "./otaManifestUrl";
|
|
@@ -71,6 +71,10 @@ export async function handleOtaClockSkewFromGlasses(errorCode, glassesTimeMs) {
|
|
|
71
71
|
lastOtaClockFixAt = Date.now();
|
|
72
72
|
const { buildNumber, otaVersionUrl } = useGlassesStore.getState();
|
|
73
73
|
const manifestUrl = resolveOtaManifestUrl(otaVersionUrl, buildNumber);
|
|
74
|
+
if (!manifestUrl) {
|
|
75
|
+
console.warn("[GlassesClockSync] OTA restart skipped because this build has no manifest pin");
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
74
78
|
console.log("[GlassesClockSync] ⏰ Restarting OTA with ota_start after clock fix");
|
|
75
79
|
await BluetoothSdk.startOtaUpdate(manifestUrl);
|
|
76
80
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glassesClockSync.js","sourceRoot":"","sources":["../../src/services/glassesClockSync.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,YAAY,MAAM,
|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AAC;gBACX,OAAO,KAAK,CAAA;YACd,CAAC;YAED,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YAC9B,MAAM,EAAC,WAAW,EAAE,aAAa,EAAC,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;YAC/D,MAAM,WAAW,GAAG,qBAAqB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;YACrE,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAA;gBAC7F,OAAO,KAAK,CAAA;YACd,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAA;YACjF,MAAM,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;YAC9C,OAAO,IAAI,CAAA;QACb,CAAC;gBAAS,CAAC;YACT,mBAAmB,GAAG,IAAI,CAAA;QAC5B,CAAC;IACH,CAAC,CAAC,EAAE,CAAA;IAEJ,OAAO,mBAAmB,CAAA;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,YAAgC;IACxF,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAA;IAC5D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["/**\n * Push phone time to glasses only when clock skew is detected (gallery sync, OTA, etc.).\n */\n\nimport BluetoothSdk from \"@mentra/bluetooth-sdk\"\nimport {BgTimer} from \"../utils/timers\"\nimport {useGlassesStore} from \"../stores/glasses\"\n\nimport {resolveOtaManifestUrl} from \"./otaManifestUrl\"\nimport {detectClockSkew} from \"./gallerySyncClock\"\n\nexport const CLOCK_SETTLE_MS = 500\n\nconst OTA_CLOCK_FIX_COOLDOWN_MS = 30_000\nlet lastOtaClockFixAt = 0\n// Coalesce concurrent OTA clock-fix attempts. Glasses can emit two clock_skew events\n// back-to-back during BLE handshake; without this guard both would await the BLE fix\n// + retry pair before either updated `lastOtaClockFixAt`.\nlet inflightOtaClockFix: Promise<boolean> | null = null\n\n/** @internal test-only */\nexport function resetOtaClockFixCooldownForTests(): void {\n lastOtaClockFixAt = 0\n inflightOtaClockFix = null\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => BgTimer.setTimeout(resolve, ms))\n}\n\n/**\n * Set glasses system clock from phone when skew is detected.\n */\nexport async function fixGlassesClockIfSkewed(glassesServerTime: number, lastSyncTime = 0): Promise<boolean> {\n const {skewed, reason} = detectClockSkew(Date.now(), glassesServerTime, lastSyncTime)\n if (!skewed) {\n return false\n }\n console.log(`[GlassesClockSync] ⏰ Clock skew detected (${reason}) — setting glasses time from phone`)\n await BluetoothSdk.setSystemTime(Date.now())\n await delay(CLOCK_SETTLE_MS)\n return true\n}\n\n/**\n * After glasses report OTA failure due to clock skew, fix time and restart\n * through the normal phone-driven ota_start path.\n */\nexport async function handleOtaClockSkewFromGlasses(\n errorCode: string | undefined,\n glassesTimeMs?: number,\n): Promise<boolean> {\n if (Date.now() - lastOtaClockFixAt < OTA_CLOCK_FIX_COOLDOWN_MS) {\n return false\n }\n\n const hasGlassesTime = typeof glassesTimeMs === \"number\" && Number.isFinite(glassesTimeMs) && glassesTimeMs > 0\n\n if (errorCode === \"ssl_error\") {\n if (!hasGlassesTime) {\n return false\n }\n const {skewed} = detectClockSkew(Date.now(), glassesTimeMs, 0)\n if (!skewed) {\n return false\n }\n console.log(\"[GlassesClockSync] ⏰ OTA ssl_error with wall-clock drift — treating as clock skew\")\n } else if (errorCode !== \"clock_skew\") {\n return false\n }\n\n // Coalesce concurrent attempts: if a fix is already in flight, await its result instead\n // of racing it through the cooldown guard.\n if (inflightOtaClockFix) {\n return inflightOtaClockFix\n }\n\n const glassesTime = hasGlassesTime ? glassesTimeMs : Date.now() - 86_400_000\n\n inflightOtaClockFix = (async () => {\n try {\n const fixed = await fixGlassesClockIfSkewed(glassesTime, 0)\n if (!fixed) {\n return false\n }\n\n lastOtaClockFixAt = Date.now()\n const {buildNumber, otaVersionUrl} = useGlassesStore.getState()\n const manifestUrl = resolveOtaManifestUrl(otaVersionUrl, buildNumber)\n if (!manifestUrl) {\n console.warn(\"[GlassesClockSync] OTA restart skipped because this build has no manifest pin\")\n return false\n }\n console.log(\"[GlassesClockSync] ⏰ Restarting OTA with ota_start after clock fix\")\n await BluetoothSdk.startOtaUpdate(manifestUrl)\n return true\n } finally {\n inflightOtaClockFix = null\n }\n })()\n\n return inflightOtaClockFix\n}\n\n/**\n * Proactive fix when version_info includes glasses system_time_ms before OTA manifest checks.\n */\nexport async function maybeFixGlassesClockFromVersionInfo(systemTimeMs: number | undefined): Promise<boolean> {\n if (typeof systemTimeMs !== \"number\" || systemTimeMs <= 0) {\n return false\n }\n\n const fixed = await fixGlassesClockIfSkewed(systemTimeMs, 0)\n if (!fixed) {\n return false\n }\n\n return true\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OtaProgress, OtaStatus } from "@mentra/bluetooth-sdk
|
|
1
|
+
import type { OtaProgress, OtaStatus } from "@mentra/bluetooth-sdk";
|
|
2
2
|
export type DisplayState = "starting" | "updating" | "complete" | "failed" | "disconnected" | "restarting";
|
|
3
3
|
/**
|
|
4
4
|
* Pure derivation of the OTA progress UI state from the glasses data in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaDisplayState.d.ts","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"otaDisplayState.d.ts","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAAA,OA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AAI,SAAS,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACxE,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,WAAW,EAAE,aAAa,KAAK,KAAK,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS,IAAI,WAAW,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACjH,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import type {OtaProgress, OtaStatus} from \"@mentra/bluetooth-sdk/internal\"\n\nimport {isLegacyShapedOtaStatus} from \"./otaInstallPolicy\"\n\nexport type DisplayState = \"starting\" | \"updating\" | \"complete\" | \"failed\" | \"disconnected\" | \"restarting\"\n\n/**\n * Pure derivation of the OTA progress UI state from the glasses data in the\n * Zustand store plus a couple of genuinely-local inputs. See\n * OtaInstallCoordinator.ts for the state machine that consumes this (the host\n * progress screen renders its snapshot).\n *\n * Legacy shape (WP 8C): old (< 37) ASG builds send `ota_progress`, which the SDK\n * maps to ota_status with sessionId \"\" and FINISHED→\"complete\" at ANY phase. For\n * those statuses a download-phase \"complete\" only means the download finished\n * (the install is still ahead), and an apk install \"complete\" may be held by the\n * coordinator's settle window — both stay \"updating\" instead of terminal.\n *\n * Priority-ordered rules (first match wins):\n * 1. errorMsg !== \"\" -> \"failed\"\n * 2. BES reboot recovery complete -> \"complete\"\n * 3. BES reboot recovery awaiting reconnect -> \"restarting\"\n * 4. BES terminal (any connection state) -> \"restarting\"\n * (legacy-shaped BES \"complete\" counts only in install phase)\n * 6. apkCompletedViaBuildIncrease (legacy build-number port) -> \"complete\"\n * 7. otaStatus.status === \"failed\" -> \"failed\"\n * 8. otaStatus.status === \"complete\" (non-BES) -> \"complete\"\n * (unless legacy-shaped download-complete or held apk settle -> in flight)\n * 9. !connected + legacy in-flight complete (held apk) -> \"updating\"\n * 10. !connected + APK step_complete with totalSteps > 1 -> \"starting\" (expected reboot)\n * 11. !connected + BES in flight -> \"restarting\" (defensive)\n * 12. !connected -> \"disconnected\"\n * 13. connected + in_progress | step_complete | legacy in-flight complete -> \"updating\"\n * 14. fallback -> \"starting\"\n */\nexport function deriveDisplayState(args: {\n otaStatus: OtaStatus | null\n otaProgress: OtaProgress | null\n connected: boolean\n errorMsg: string\n /**\n * Retained for host API compatibility. A session-wide reconnect edge is not\n * sufficient for BES completion because it may belong to an earlier APK step.\n */\n sawReconnectEdge: boolean\n /** Coordinator is holding a legacy apk install \"complete\" for the settle window (WP 8C). */\n legacyApkSettleHold?: boolean\n /** Legacy APK completion detected by build-number increase (WP 8C). */\n apkCompletedViaBuildIncrease?: boolean\n /** Phone-observed BES disconnect/reconnect recovery, independent of stale OTA progress. */\n besRestartRecovery?: \"awaiting\" | \"complete\" | null\n /** Downgrade detour: the reconnected glasses reported exactly the pinned target version. */\n versionChangeConverged?: boolean\n /** True for the whole downgrade (version-change) session. */\n versionChangeSession?: boolean\n}): DisplayState {\n const {\n otaStatus,\n otaProgress,\n connected,\n errorMsg,\n legacyApkSettleHold,\n apkCompletedViaBuildIncrease,\n besRestartRecovery,\n versionChangeConverged,\n versionChangeSession,\n } = args\n\n if (errorMsg) return \"failed\"\n\n // Downgrade detour completion: exact-version convergence after reconnect is the\n // only completion signal (the wipe destroys ASG's ota_session, and the target is\n // a LOWER build so no build-number increase fires). Outranks the stale install\n // status still sitting in the store from before the handoff.\n if (versionChangeConverged) return \"complete\"\n\n // A BES reboot destroys or strands the glasses-side OTA session on older\n // clients. Once the phone observed that reboot, stale pre-reboot progress must\n // not move the UI from restarting back to updating.\n if (besRestartRecovery === \"complete\") return \"complete\"\n if (besRestartRecovery === \"awaiting\") return \"restarting\"\n\n // In a version-change session, convergence (above) is the ONLY completion for the ASG\n // downgrade. A bare non-firmware \"complete\" before convergence — the glasses refusing\n // the downgrade (floor/gate) with no install, or a stale pre-handoff status — must never\n // present as success. Firmware-step completions (mtk/bes) DO pass through: a combined\n // downgrade+firmware manifest applies firmware first on its own pass, which must finish\n // so the phone re-checks and re-offers the now-firmware-free downgrade.\n const isFirmwareComplete = otaStatus?.stepType === \"mtk\" || otaStatus?.stepType === \"bes\"\n if (versionChangeSession && otaStatus?.status === \"complete\" && !isFirmwareComplete) {\n return connected ? \"updating\" : \"disconnected\"\n }\n\n const besTerminal = isBesTerminal(otaStatus, otaProgress)\n if (besTerminal) return \"restarting\"\n\n // Legacy build-number APK completion: the coordinator clears errorMsg when it fires,\n // and the flag outranks whatever stale legacy status is still in the store (the old\n // screen's last-write-wins completion from starting/failed/installing).\n if (apkCompletedViaBuildIncrease) return \"complete\"\n\n if (otaStatus?.status === \"failed\") return \"failed\"\n\n // Legacy-shaped \"complete\" that is still in flight: a download-phase FINISHED (the\n // install is still ahead), or an apk install FINISHED held by the settle window.\n const legacyInFlightComplete =\n isLegacyShapedOtaStatus(otaStatus) &&\n otaStatus?.status === \"complete\" &&\n (otaStatus.phase === \"download\" ||\n (!!legacyApkSettleHold && otaStatus.stepType === \"apk\" && otaStatus.phase === \"install\"))\n\n if (otaStatus?.status === \"complete\" && !legacyInFlightComplete) return \"complete\"\n\n if (!connected) {\n // The held apk install complete means the glasses are restarting into the new\n // build — the legacy screen kept showing \"installing\" through that restart.\n if (legacyInFlightComplete && otaStatus?.phase === \"install\") return \"updating\"\n\n // By here, the failed/complete rules already returned for terminal statuses.\n // For APK multi-step, \"step_complete\" means the current step ended and the\n // glasses are rebooting to start the next one.\n const apkRebootExpected =\n otaStatus?.stepType === \"apk\" && (otaStatus?.totalSteps ?? 0) > 1 && otaStatus.status === \"step_complete\"\n if (apkRebootExpected) return \"starting\"\n\n // Legacy-shaped BES download events do not mean a reboot is coming (the flash\n // has not started); the legacy screen treated that drop as a plain disconnect.\n const besStatusInFlight =\n otaStatus?.stepType === \"bes\" && !(isLegacyShapedOtaStatus(otaStatus) && otaStatus.phase === \"download\")\n const besInFlight = besStatusInFlight || (otaProgress?.currentUpdate === \"bes\" && otaProgress?.stage === \"install\")\n if (besInFlight) return \"restarting\"\n\n return \"disconnected\"\n }\n\n if (otaStatus?.status === \"in_progress\" || otaStatus?.status === \"step_complete\" || legacyInFlightComplete) {\n return \"updating\"\n }\n\n return \"starting\"\n}\n\nfunction isBesTerminal(otaStatus: OtaStatus | null, otaProgress: OtaProgress | null): boolean {\n if (otaStatus?.stepType === \"bes\" && (otaStatus.status === \"step_complete\" || otaStatus.status === \"complete\")) {\n // Legacy-shaped statuses map download FINISHED to \"complete\" too; only an\n // install-phase terminal means the BES flash actually ran (WP 8C).\n if (isLegacyShapedOtaStatus(otaStatus) && otaStatus.phase !== \"install\") {\n return false\n }\n return true\n }\n if (otaProgress?.currentUpdate === \"bes\" && otaProgress.stage === \"install\" && otaProgress.status === \"FINISHED\") {\n return true\n }\n return false\n}\n"]}
|
|
1
|
+
{"version":3,"file":"otaDisplayState.js","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAoBlC;IACC,MAAM,EACJ,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,EACR,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,GACrB,GAAG,IAAI,CAAA;IAER,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAE7B,gFAAgF;IAChF,iFAAiF;IACjF,+EAA+E;IAC/E,6DAA6D;IAC7D,IAAI,sBAAsB;QAAE,OAAO,UAAU,CAAA;IAE7C,yEAAyE;IACzE,+EAA+E;IAC/E,oDAAoD;IACpD,IAAI,kBAAkB,KAAK,UAAU;QAAE,OAAO,UAAU,CAAA;IACxD,IAAI,kBAAkB,KAAK,UAAU;QAAE,OAAO,YAAY,CAAA;IAE1D,sFAAsF;IACtF,sFAAsF;IACtF,yFAAyF;IACzF,sF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AACd,CAAC","sourcesContent":["import type {OtaProgress, OtaStatus} from \"@mentra/bluetooth-sdk\"\n\nimport {isLegacyShapedOtaStatus} from \"./otaInstallPolicy\"\n\nexport type DisplayState = \"starting\" | \"updating\" | \"complete\" | \"failed\" | \"disconnected\" | \"restarting\"\n\n/**\n * Pure derivation of the OTA progress UI state from the glasses data in the\n * Zustand store plus a couple of genuinely-local inputs. See\n * OtaInstallCoordinator.ts for the state machine that consumes this (the host\n * progress screen renders its snapshot).\n *\n * Legacy shape (WP 8C): old (< 37) ASG builds send `ota_progress`, which the SDK\n * maps to ota_status with sessionId \"\" and FINISHED→\"complete\" at ANY phase. For\n * those statuses a download-phase \"complete\" only means the download finished\n * (the install is still ahead), and an apk install \"complete\" may be held by the\n * coordinator's settle window — both stay \"updating\" instead of terminal.\n *\n * Priority-ordered rules (first match wins):\n * 1. errorMsg !== \"\" -> \"failed\"\n * 2. BES reboot recovery complete -> \"complete\"\n * 3. BES reboot recovery awaiting reconnect -> \"restarting\"\n * 4. BES terminal (any connection state) -> \"restarting\"\n * (legacy-shaped BES \"complete\" counts only in install phase)\n * 6. apkCompletedViaBuildIncrease (legacy build-number port) -> \"complete\"\n * 7. otaStatus.status === \"failed\" -> \"failed\"\n * 8. otaStatus.status === \"complete\" (non-BES) -> \"complete\"\n * (unless legacy-shaped download-complete or held apk settle -> in flight)\n * 9. !connected + legacy in-flight complete (held apk) -> \"updating\"\n * 10. !connected + APK step_complete with totalSteps > 1 -> \"starting\" (expected reboot)\n * 11. !connected + BES in flight -> \"restarting\" (defensive)\n * 12. !connected -> \"disconnected\"\n * 13. connected + in_progress | step_complete | legacy in-flight complete -> \"updating\"\n * 14. fallback -> \"starting\"\n */\nexport function deriveDisplayState(args: {\n otaStatus: OtaStatus | null\n otaProgress: OtaProgress | null\n connected: boolean\n errorMsg: string\n /**\n * Retained for host API compatibility. A session-wide reconnect edge is not\n * sufficient for BES completion because it may belong to an earlier APK step.\n */\n sawReconnectEdge: boolean\n /** Coordinator is holding a legacy apk install \"complete\" for the settle window (WP 8C). */\n legacyApkSettleHold?: boolean\n /** Legacy APK completion detected by build-number increase (WP 8C). */\n apkCompletedViaBuildIncrease?: boolean\n /** Phone-observed BES disconnect/reconnect recovery, independent of stale OTA progress. */\n besRestartRecovery?: \"awaiting\" | \"complete\" | null\n /** Downgrade detour: the reconnected glasses reported exactly the pinned target version. */\n versionChangeConverged?: boolean\n /** True for the whole downgrade (version-change) session. */\n versionChangeSession?: boolean\n}): DisplayState {\n const {\n otaStatus,\n otaProgress,\n connected,\n errorMsg,\n legacyApkSettleHold,\n apkCompletedViaBuildIncrease,\n besRestartRecovery,\n versionChangeConverged,\n versionChangeSession,\n } = args\n\n if (errorMsg) return \"failed\"\n\n // Downgrade detour completion: exact-version convergence after reconnect is the\n // only completion signal (the wipe destroys ASG's ota_session, and the target is\n // a LOWER build so no build-number increase fires). Outranks the stale install\n // status still sitting in the store from before the handoff.\n if (versionChangeConverged) return \"complete\"\n\n // A BES reboot destroys or strands the glasses-side OTA session on older\n // clients. Once the phone observed that reboot, stale pre-reboot progress must\n // not move the UI from restarting back to updating.\n if (besRestartRecovery === \"complete\") return \"complete\"\n if (besRestartRecovery === \"awaiting\") return \"restarting\"\n\n // In a version-change session, convergence (above) is the ONLY completion for the ASG\n // downgrade. A bare non-firmware \"complete\" before convergence — the glasses refusing\n // the downgrade (floor/gate) with no install, or a stale pre-handoff status — must never\n // present as success. Firmware-step completions (mtk/bes) DO pass through: a combined\n // downgrade+firmware manifest applies firmware first on its own pass, which must finish\n // so the phone re-checks and re-offers the now-firmware-free downgrade.\n const isFirmwareComplete = otaStatus?.stepType === \"mtk\" || otaStatus?.stepType === \"bes\"\n if (versionChangeSession && otaStatus?.status === \"complete\" && !isFirmwareComplete) {\n return connected ? \"updating\" : \"disconnected\"\n }\n\n const besTerminal = isBesTerminal(otaStatus, otaProgress)\n if (besTerminal) return \"restarting\"\n\n // Legacy build-number APK completion: the coordinator clears errorMsg when it fires,\n // and the flag outranks whatever stale legacy status is still in the store (the old\n // screen's last-write-wins completion from starting/failed/installing).\n if (apkCompletedViaBuildIncrease) return \"complete\"\n\n if (otaStatus?.status === \"failed\") return \"failed\"\n\n // Legacy-shaped \"complete\" that is still in flight: a download-phase FINISHED (the\n // install is still ahead), or an apk install FINISHED held by the settle window.\n const legacyInFlightComplete =\n isLegacyShapedOtaStatus(otaStatus) &&\n otaStatus?.status === \"complete\" &&\n (otaStatus.phase === \"download\" ||\n (!!legacyApkSettleHold && otaStatus.stepType === \"apk\" && otaStatus.phase === \"install\"))\n\n if (otaStatus?.status === \"complete\" && !legacyInFlightComplete) return \"complete\"\n\n if (!connected) {\n // The held apk install complete means the glasses are restarting into the new\n // build — the legacy screen kept showing \"installing\" through that restart.\n if (legacyInFlightComplete && otaStatus?.phase === \"install\") return \"updating\"\n\n // By here, the failed/complete rules already returned for terminal statuses.\n // For APK multi-step, \"step_complete\" means the current step ended and the\n // glasses are rebooting to start the next one.\n const apkRebootExpected =\n otaStatus?.stepType === \"apk\" && (otaStatus?.totalSteps ?? 0) > 1 && otaStatus.status === \"step_complete\"\n if (apkRebootExpected) return \"starting\"\n\n // Legacy-shaped BES download events do not mean a reboot is coming (the flash\n // has not started); the legacy screen treated that drop as a plain disconnect.\n const besStatusInFlight =\n otaStatus?.stepType === \"bes\" && !(isLegacyShapedOtaStatus(otaStatus) && otaStatus.phase === \"download\")\n const besInFlight = besStatusInFlight || (otaProgress?.currentUpdate === \"bes\" && otaProgress?.stage === \"install\")\n if (besInFlight) return \"restarting\"\n\n return \"disconnected\"\n }\n\n if (otaStatus?.status === \"in_progress\" || otaStatus?.status === \"step_complete\" || legacyInFlightComplete) {\n return \"updating\"\n }\n\n return \"starting\"\n}\n\nfunction isBesTerminal(otaStatus: OtaStatus | null, otaProgress: OtaProgress | null): boolean {\n if (otaStatus?.stepType === \"bes\" && (otaStatus.status === \"step_complete\" || otaStatus.status === \"complete\")) {\n // Legacy-shaped statuses map download FINISHED to \"complete\" too; only an\n // install-phase terminal means the BES flash actually ran (WP 8C).\n if (isLegacyShapedOtaStatus(otaStatus) && otaStatus.phase !== \"install\") {\n return false\n }\n return true\n }\n if (otaProgress?.currentUpdate === \"bes\" && otaProgress.stage === \"install\" && otaProgress.status === \"FINISHED\") {\n return true\n }\n return false\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Shared OTA progress watchdog timings (see progress-legacy.tsx / progress.tsx). */
|
|
2
|
-
import type { OtaProgress, OtaStatus } from "@mentra/bluetooth-sdk
|
|
2
|
+
import type { OtaProgress, OtaStatus } from "@mentra/bluetooth-sdk";
|
|
3
3
|
/**
|
|
4
4
|
* First glasses `build_number` (ASG `versionCode`) that uses `progress.tsx` with unified
|
|
5
5
|
* `ota_status` session UI. Strictly lower builds use `/ota/progress-legacy` (routed from
|
|
@@ -30,6 +30,8 @@ export declare const PING_INTERVAL_MS = 10000;
|
|
|
30
30
|
export declare const QUERY_REPLY_TIMEOUT_MS = 6000;
|
|
31
31
|
/** 15s lockout on the Continue button after a BES restart, to prevent an accidental tap. */
|
|
32
32
|
export declare const BES_CONTINUE_LOCKOUT_MS = 15000;
|
|
33
|
+
/** Fail closed if a BES reboot never reconnects; normal restarts complete in a fraction of this window. */
|
|
34
|
+
export declare const BES_RESTART_TIMEOUT_MS = 120000;
|
|
33
35
|
/** The uniform pad progress-legacy.tsx added to every duration for old builds. */
|
|
34
36
|
export declare const LEGACY_EXTRA_TIMEOUT_MS = 20000;
|
|
35
37
|
export declare const LEGACY_RETRY_INTERVAL_MS: number;
|
|
@@ -39,6 +41,7 @@ export declare const LEGACY_MTK_INSTALL_TIMEOUT_MS: number;
|
|
|
39
41
|
export declare const LEGACY_GLOBAL_OTA_TIMEOUT_MS: number;
|
|
40
42
|
export declare const LEGACY_PING_INTERVAL_MS: number;
|
|
41
43
|
export declare const LEGACY_BES_CONTINUE_LOCKOUT_MS: number;
|
|
44
|
+
export declare const LEGACY_BES_RESTART_TIMEOUT_MS: number;
|
|
42
45
|
/**
|
|
43
46
|
* After a legacy apk `install FINISHED` observed in-flight, the legacy screen held the
|
|
44
47
|
* completed state for 12s (+20s pad) so the ASG process restart settles (and fresh
|
|
@@ -82,6 +85,7 @@ export declare function selectOtaProtocolProfile(otaStatus: OtaStatus | null, ot
|
|
|
82
85
|
export declare const OtaProgressMessages: {
|
|
83
86
|
readonly stalledOrStuck: "Update may have failed. Ensure glasses have internet access and try again.";
|
|
84
87
|
readonly globalTimeout: "Update took too long. Please try again.";
|
|
88
|
+
readonly restartTimeout: "Glasses did not finish restarting. Restart them before trying the update again.";
|
|
85
89
|
readonly sendOtaStartFailed: "Failed to communicate with glasses.";
|
|
86
90
|
readonly hotspotArtifactDownloadFailed: "Could not download the update to your phone. Check phone internet and try again.";
|
|
87
91
|
readonly hotspotArtifactVerifyFailed: "The update package could not be verified. Please try again later.";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaInstallPolicy.d.ts","sourceRoot":"","sources":["../../src/services/otaInstallPolicy.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"otaInstallPolicy.d.ts","sourceRoot":"","sources":["../../src/services/otaInstallPolicy.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAA;AAE1C,eAAO,MAAM,WAAW,IAAI,CAAA;AAC5B,sFAAsF;AACtF,eAAO,MAAM,iBAAiB,OAAO,CAAA;AACrC,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,SAAU,CAAA;AAC1C,kDAAkD;AAClD,eAAO,MAAM,yBAAyB,QAAS,CAAA;AAC/C,2DAA2D;AAC3D,eAAO,MAAM,sBAAsB,SAAU,CAAA;AAC7C,mCAAmC;AACnC,eAAO,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,GAAG,SAAS,GACrC,OAAO,CAKT;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,SAAS,GAAG,IAAI,EAC3B,WAAW,EAAE,WAAW,GAAG,IAAI,EAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,kBAAkB,GAAG,IAAI,CAQ3B;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;CAWtB,CAAA"}
|
|
@@ -28,6 +28,8 @@ export const PING_INTERVAL_MS = 10_000;
|
|
|
28
28
|
export const QUERY_REPLY_TIMEOUT_MS = 6000;
|
|
29
29
|
/** 15s lockout on the Continue button after a BES restart, to prevent an accidental tap. */
|
|
30
30
|
export const BES_CONTINUE_LOCKOUT_MS = 15_000;
|
|
31
|
+
/** Fail closed if a BES reboot never reconnects; normal restarts complete in a fraction of this window. */
|
|
32
|
+
export const BES_RESTART_TIMEOUT_MS = 120_000;
|
|
31
33
|
// --- Legacy old-build (< MINIMUM_OTA_STATUS_BUILD) OTA policy (WP 8C) ---
|
|
32
34
|
//
|
|
33
35
|
// Ported verbatim from mobile/src/app/ota/progress-legacy.tsx, which padded EVERY
|
|
@@ -45,6 +47,7 @@ export const LEGACY_MTK_INSTALL_TIMEOUT_MS = MTK_INSTALL_TIMEOUT_MS + LEGACY_EXT
|
|
|
45
47
|
export const LEGACY_GLOBAL_OTA_TIMEOUT_MS = GLOBAL_OTA_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS;
|
|
46
48
|
export const LEGACY_PING_INTERVAL_MS = PING_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS;
|
|
47
49
|
export const LEGACY_BES_CONTINUE_LOCKOUT_MS = BES_CONTINUE_LOCKOUT_MS + LEGACY_EXTRA_TIMEOUT_MS;
|
|
50
|
+
export const LEGACY_BES_RESTART_TIMEOUT_MS = BES_RESTART_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS;
|
|
48
51
|
/**
|
|
49
52
|
* After a legacy apk `install FINISHED` observed in-flight, the legacy screen held the
|
|
50
53
|
* completed state for 12s (+20s pad) so the ASG process restart settles (and fresh
|
|
@@ -106,6 +109,7 @@ export function selectOtaProtocolProfile(otaStatus, otaProgress, buildNumber) {
|
|
|
106
109
|
export const OtaProgressMessages = {
|
|
107
110
|
stalledOrStuck: "Update may have failed. Ensure glasses have internet access and try again.",
|
|
108
111
|
globalTimeout: "Update took too long. Please try again.",
|
|
112
|
+
restartTimeout: "Glasses did not finish restarting. Restart them before trying the update again.",
|
|
109
113
|
sendOtaStartFailed: "Failed to communicate with glasses.",
|
|
110
114
|
hotspotArtifactDownloadFailed: "Could not download the update to your phone. Check phone internet and try again.",
|
|
111
115
|
hotspotArtifactVerifyFailed: "The update package could not be verified. Please try again later.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaInstallPolicy.js","sourceRoot":"","sources":["../../src/services/otaInstallPolicy.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAA;AAC5B,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACrC,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAA;AAC1C,kDAAkD;AAClD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAC/C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAA;AAC7C,mCAAmC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AACnD,+BAA+B;AAC/B,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAA;AACtC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAA;AAC1C,4FAA4F;AAC5F,MAAM,CAA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BAAkB,EAAE,wDAAwD;IAC5E,iBAAiB,EAAE,uEAAuE;IAC1F,mBAAmB,EAAE,uEAAuE;CACpF,CAAA","sourcesContent":["/** Shared OTA progress watchdog timings (see progress-legacy.tsx / progress.tsx). */\nimport type {OtaProgress, OtaStatus} from \"@mentra/bluetooth-sdk/internal\"\n\n/**\n * First glasses `build_number` (ASG `versionCode`) that uses `progress.tsx` with unified\n * `ota_status` session UI. Strictly lower builds use `/ota/progress-legacy` (routed from\n * `check-for-updates.tsx` before navigation), and get the LEGACY_* padded policy below\n * in the unified OtaInstallCoordinator (WP 8C). Change only here.\n */\nexport const MINIMUM_OTA_STATUS_BUILD = 37\n\nexport const MAX_RETRIES = 3\n/** Wait between ended native ota_start requests; never overlaps a pending request. */\nexport const RETRY_INTERVAL_MS = 5000\n/** APK/BES and general install when progress events are expected */\nexport const PROGRESS_TIMEOUT_MS = 120_000\n/** Fail if still at 0% in starting/downloading */\nexport const DOWNLOAD_STUCK_TIMEOUT_MS = 70_000\n/** MTK system install often goes quiet for long periods */\nexport const MTK_INSTALL_TIMEOUT_MS = 300_000\n/** Whole multi-step session cap */\nexport const GLOBAL_OTA_TIMEOUT_MS = 20 * 60 * 1000\n/** BLE keepalive during OTA */\nexport const PING_INTERVAL_MS = 10_000\n/**\n * If we sent ota_query_status (e.g. on reconnect) and the glasses haven't\n * replied with an ota_status by then, fall back to ota_start. This recovers\n * from the case where the glasses process restarted between mount and\n * reconnect — the session is gone, ota_query_status returns nothing, and\n * the user would otherwise sit on the spinner forever.\n */\nexport const QUERY_REPLY_TIMEOUT_MS = 6000\n/** 15s lockout on the Continue button after a BES restart, to prevent an accidental tap. */\nexport const BES_CONTINUE_LOCKOUT_MS = 15_000\n\n// --- Legacy old-build (< MINIMUM_OTA_STATUS_BUILD) OTA policy (WP 8C) ---\n//\n// Ported verbatim from mobile/src/app/ota/progress-legacy.tsx, which padded EVERY\n// watchdog/timer by +20s for old ASG builds (\"Legacy OTA: +20s on every watchdog /\n// timer duration\"). Old builds respond slower on every path, so where the legacy\n// screen used a longer duration the coordinator applies the longer value whenever\n// the session is legacy-shaped (see isLegacyShapedOtaStatus / the coordinator's\n// session-shape check). Builds >= 37 keep the unpadded values above.\n\n/** The uniform pad progress-legacy.tsx added to every duration for old builds. */\nexport const LEGACY_EXTRA_TIMEOUT_MS = 20_000\nexport const LEGACY_RETRY_INTERVAL_MS = RETRY_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_PROGRESS_TIMEOUT_MS = PROGRESS_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_DOWNLOAD_STUCK_TIMEOUT_MS = DOWNLOAD_STUCK_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_INSTALL_TIMEOUT_MS = MTK_INSTALL_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_GLOBAL_OTA_TIMEOUT_MS = GLOBAL_OTA_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_PING_INTERVAL_MS = PING_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_BES_CONTINUE_LOCKOUT_MS = BES_CONTINUE_LOCKOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\n/**\n * After a legacy apk `install FINISHED` observed in-flight, the legacy screen held the\n * completed state for 12s (+20s pad) so the ASG process restart settles (and fresh\n * version_info lands) before the user can continue.\n */\nexport const LEGACY_APK_COMPLETION_SETTLE_MS = 12_000 + LEGACY_EXTRA_TIMEOUT_MS\n/**\n * Legacy MTK install stall simulation (display-only): the MTK system install typically\n * stalls around 49-50%. After LEGACY_MTK_STALL_DETECT_MS without a new event in the\n * [45, 55) zone, the legacy screen simulated +1% every LEGACY_MTK_SIM_TICK_MS starting\n * at max(stall+1, 51) and capped at 60%, purely to keep the user informed.\n */\nexport const LEGACY_MTK_STALL_DETECT_MS = 20_000 + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_SIM_TICK_MS = 15_000 + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_STALL_ZONE_MIN_PERCENT = 45\nexport const LEGACY_MTK_STALL_ZONE_MAX_PERCENT = 55\nexport const LEGACY_MTK_SIM_FLOOR_PERCENT = 51\nexport const LEGACY_MTK_SIM_CAP_PERCENT = 60\n\nexport type OtaProtocolProfile = \"legacy\" | \"unified\"\n\n/**\n * Legacy-shaped ota_status: old (< 37) ASG builds send `ota_progress`, which the SDK\n * (Android MentraLive.kt / iOS MentraLive.swift) maps to a unified ota_status with\n * sessionId \"\" and totalSteps 1, and FINISHED→\"complete\" regardless of phase. A real\n * (>= 37) session always carries a sessionId; an \"idle\" reply also has sessionId \"\" but\n * proves the glasses speak the unified protocol, so it is NOT legacy-shaped.\n */\nexport function isLegacyShapedOtaStatus(otaStatus: OtaStatus | null): boolean {\n return !!otaStatus && otaStatus.sessionId === \"\" && otaStatus.status !== \"idle\"\n}\n\n/**\n * Is the current install session legacy-shaped? Event shape wins when events exist\n * (per the WP 8C rule: key off legacy-shaped inputs, not a build flag, where possible);\n * before any event arrives only the glasses build number can tell.\n */\nexport function isLegacyShapedOtaSession(\n otaStatus: OtaStatus | null,\n otaProgress: OtaProgress | null,\n buildNumber: string | null | undefined,\n): boolean {\n if (otaStatus) return isLegacyShapedOtaStatus(otaStatus)\n if (otaProgress) return true\n const build = Number.parseInt(buildNumber ?? \"\", 10)\n return Number.isFinite(build) && build > 0 && build < MINIMUM_OTA_STATUS_BUILD\n}\n\n/**\n * Select the compatibility profile once at install-screen attach. The old split\n * routes made this decision from the pre-update build and kept it for the whole\n * mounted flow, even when an APK step restarted into a newer ASG build. Returning\n * null leaves the coordinator undecided until the first meaningful OTA event.\n */\nexport function selectOtaProtocolProfile(\n otaStatus: OtaStatus | null,\n otaProgress: OtaProgress | null,\n buildNumber: string | null | undefined,\n): OtaProtocolProfile | null {\n const build = Number.parseInt(buildNumber ?? \"\", 10)\n if (Number.isFinite(build) && build > 0) {\n return build < MINIMUM_OTA_STATUS_BUILD ? \"legacy\" : \"unified\"\n }\n if (otaStatus) return isLegacyShapedOtaStatus(otaStatus) ? \"legacy\" : \"unified\"\n if (otaProgress) return \"legacy\"\n return null\n}\n\nexport const OtaProgressMessages = {\n stalledOrStuck: \"Update may have failed. Ensure glasses have internet access and try again.\",\n globalTimeout: \"Update took too long. Please try again.\",\n sendOtaStartFailed: \"Failed to communicate with glasses.\",\n hotspotArtifactDownloadFailed: \"Could not download the update to your phone. Check phone internet and try again.\",\n hotspotArtifactVerifyFailed: \"The update package could not be verified. Please try again later.\",\n hotspotWifiPermissionDenied: \"Allow nearby devices access so the phone can connect to the glasses hotspot.\",\n hotspotStartFailed: \"Could not start the glasses hotspot. Please try again.\",\n hotspotJoinFailed: \"Could not connect the phone to the glasses hotspot. Please try again.\",\n hotspotServerFailed: \"Could not make the update available to the glasses. Please try again.\",\n} as const\n"]}
|
|
1
|
+
{"version":3,"file":"otaInstallPolicy.js","sourceRoot":"","sources":["../../src/services/otaInstallPolicy.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAA;AAC5B,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACrC,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAA;AAC1C,kDAAkD;AAClD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAC/C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAA;AAC7C,mCAAmC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AACnD,+BAA+B;AAC/B,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAA;AACtC;;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A;AACb,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,cAAc,EAAE,4EAA4E;IAC5F,aAAa,EAAE,yCAAyC;IACxD,cAAc,EAAE,iFAAiF;IACjG,kBAAkB,EAAE,qCAAqC;IACzD,6BAA6B,EAAE,kFAAkF;IACjH,2BAA2B,EAAE,mEAAmE;IAChG,2BAA2B,EAAE,8EAA8E;IAC3G,kBAAkB,EAAE,wDAAwD;IAC5E,iBAAiB,EAAE,uEAAuE;IAC1F,mBAAmB,EAAE,uEAAuE;CACpF,CAAA","sourcesContent":["/** Shared OTA progress watchdog timings (see progress-legacy.tsx / progress.tsx). */\nimport type {OtaProgress, OtaStatus} from \"@mentra/bluetooth-sdk\"\n\n/**\n * First glasses `build_number` (ASG `versionCode`) that uses `progress.tsx` with unified\n * `ota_status` session UI. Strictly lower builds use `/ota/progress-legacy` (routed from\n * `check-for-updates.tsx` before navigation), and get the LEGACY_* padded policy below\n * in the unified OtaInstallCoordinator (WP 8C). Change only here.\n */\nexport const MINIMUM_OTA_STATUS_BUILD = 37\n\nexport const MAX_RETRIES = 3\n/** Wait between ended native ota_start requests; never overlaps a pending request. */\nexport const RETRY_INTERVAL_MS = 5000\n/** APK/BES and general install when progress events are expected */\nexport const PROGRESS_TIMEOUT_MS = 120_000\n/** Fail if still at 0% in starting/downloading */\nexport const DOWNLOAD_STUCK_TIMEOUT_MS = 70_000\n/** MTK system install often goes quiet for long periods */\nexport const MTK_INSTALL_TIMEOUT_MS = 300_000\n/** Whole multi-step session cap */\nexport const GLOBAL_OTA_TIMEOUT_MS = 20 * 60 * 1000\n/** BLE keepalive during OTA */\nexport const PING_INTERVAL_MS = 10_000\n/**\n * If we sent ota_query_status (e.g. on reconnect) and the glasses haven't\n * replied with an ota_status by then, fall back to ota_start. This recovers\n * from the case where the glasses process restarted between mount and\n * reconnect — the session is gone, ota_query_status returns nothing, and\n * the user would otherwise sit on the spinner forever.\n */\nexport const QUERY_REPLY_TIMEOUT_MS = 6000\n/** 15s lockout on the Continue button after a BES restart, to prevent an accidental tap. */\nexport const BES_CONTINUE_LOCKOUT_MS = 15_000\n/** Fail closed if a BES reboot never reconnects; normal restarts complete in a fraction of this window. */\nexport const BES_RESTART_TIMEOUT_MS = 120_000\n\n// --- Legacy old-build (< MINIMUM_OTA_STATUS_BUILD) OTA policy (WP 8C) ---\n//\n// Ported verbatim from mobile/src/app/ota/progress-legacy.tsx, which padded EVERY\n// watchdog/timer by +20s for old ASG builds (\"Legacy OTA: +20s on every watchdog /\n// timer duration\"). Old builds respond slower on every path, so where the legacy\n// screen used a longer duration the coordinator applies the longer value whenever\n// the session is legacy-shaped (see isLegacyShapedOtaStatus / the coordinator's\n// session-shape check). Builds >= 37 keep the unpadded values above.\n\n/** The uniform pad progress-legacy.tsx added to every duration for old builds. */\nexport const LEGACY_EXTRA_TIMEOUT_MS = 20_000\nexport const LEGACY_RETRY_INTERVAL_MS = RETRY_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_PROGRESS_TIMEOUT_MS = PROGRESS_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_DOWNLOAD_STUCK_TIMEOUT_MS = DOWNLOAD_STUCK_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_INSTALL_TIMEOUT_MS = MTK_INSTALL_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_GLOBAL_OTA_TIMEOUT_MS = GLOBAL_OTA_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_PING_INTERVAL_MS = PING_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_BES_CONTINUE_LOCKOUT_MS = BES_CONTINUE_LOCKOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_BES_RESTART_TIMEOUT_MS = BES_RESTART_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\n/**\n * After a legacy apk `install FINISHED` observed in-flight, the legacy screen held the\n * completed state for 12s (+20s pad) so the ASG process restart settles (and fresh\n * version_info lands) before the user can continue.\n */\nexport const LEGACY_APK_COMPLETION_SETTLE_MS = 12_000 + LEGACY_EXTRA_TIMEOUT_MS\n/**\n * Legacy MTK install stall simulation (display-only): the MTK system install typically\n * stalls around 49-50%. After LEGACY_MTK_STALL_DETECT_MS without a new event in the\n * [45, 55) zone, the legacy screen simulated +1% every LEGACY_MTK_SIM_TICK_MS starting\n * at max(stall+1, 51) and capped at 60%, purely to keep the user informed.\n */\nexport const LEGACY_MTK_STALL_DETECT_MS = 20_000 + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_SIM_TICK_MS = 15_000 + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_STALL_ZONE_MIN_PERCENT = 45\nexport const LEGACY_MTK_STALL_ZONE_MAX_PERCENT = 55\nexport const LEGACY_MTK_SIM_FLOOR_PERCENT = 51\nexport const LEGACY_MTK_SIM_CAP_PERCENT = 60\n\nexport type OtaProtocolProfile = \"legacy\" | \"unified\"\n\n/**\n * Legacy-shaped ota_status: old (< 37) ASG builds send `ota_progress`, which the SDK\n * (Android MentraLive.kt / iOS MentraLive.swift) maps to a unified ota_status with\n * sessionId \"\" and totalSteps 1, and FINISHED→\"complete\" regardless of phase. A real\n * (>= 37) session always carries a sessionId; an \"idle\" reply also has sessionId \"\" but\n * proves the glasses speak the unified protocol, so it is NOT legacy-shaped.\n */\nexport function isLegacyShapedOtaStatus(otaStatus: OtaStatus | null): boolean {\n return !!otaStatus && otaStatus.sessionId === \"\" && otaStatus.status !== \"idle\"\n}\n\n/**\n * Is the current install session legacy-shaped? Event shape wins when events exist\n * (per the WP 8C rule: key off legacy-shaped inputs, not a build flag, where possible);\n * before any event arrives only the glasses build number can tell.\n */\nexport function isLegacyShapedOtaSession(\n otaStatus: OtaStatus | null,\n otaProgress: OtaProgress | null,\n buildNumber: string | null | undefined,\n): boolean {\n if (otaStatus) return isLegacyShapedOtaStatus(otaStatus)\n if (otaProgress) return true\n const build = Number.parseInt(buildNumber ?? \"\", 10)\n return Number.isFinite(build) && build > 0 && build < MINIMUM_OTA_STATUS_BUILD\n}\n\n/**\n * Select the compatibility profile once at install-screen attach. The old split\n * routes made this decision from the pre-update build and kept it for the whole\n * mounted flow, even when an APK step restarted into a newer ASG build. Returning\n * null leaves the coordinator undecided until the first meaningful OTA event.\n */\nexport function selectOtaProtocolProfile(\n otaStatus: OtaStatus | null,\n otaProgress: OtaProgress | null,\n buildNumber: string | null | undefined,\n): OtaProtocolProfile | null {\n const build = Number.parseInt(buildNumber ?? \"\", 10)\n if (Number.isFinite(build) && build > 0) {\n return build < MINIMUM_OTA_STATUS_BUILD ? \"legacy\" : \"unified\"\n }\n if (otaStatus) return isLegacyShapedOtaStatus(otaStatus) ? \"legacy\" : \"unified\"\n if (otaProgress) return \"legacy\"\n return null\n}\n\nexport const OtaProgressMessages = {\n stalledOrStuck: \"Update may have failed. Ensure glasses have internet access and try again.\",\n globalTimeout: \"Update took too long. Please try again.\",\n restartTimeout: \"Glasses did not finish restarting. Restart them before trying the update again.\",\n sendOtaStartFailed: \"Failed to communicate with glasses.\",\n hotspotArtifactDownloadFailed: \"Could not download the update to your phone. Check phone internet and try again.\",\n hotspotArtifactVerifyFailed: \"The update package could not be verified. Please try again later.\",\n hotspotWifiPermissionDenied: \"Allow nearby devices access so the phone can connect to the glasses hotspot.\",\n hotspotStartFailed: \"Could not start the glasses hotspot. Please try again.\",\n hotspotJoinFailed: \"Could not connect the phone to the glasses hotspot. Please try again.\",\n hotspotServerFailed: \"Could not make the update available to the glasses. Please try again.\",\n} as const\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OtaProgress, OtaStatus } from "@mentra/bluetooth-sdk
|
|
1
|
+
import type { OtaProgress, OtaStatus } from "@mentra/bluetooth-sdk";
|
|
2
2
|
/** Normalized ota_status fields (snake_case) after bridging Core/expo (snake or camel). */
|
|
3
3
|
export type NormalizedOtaStatusEvent = {
|
|
4
4
|
session_id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaLegacyMapping.d.ts","sourceRoot":"","sources":["../../src/services/otaLegacyMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAqB,SAAS,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"otaLegacyMapping.d.ts","sourceRoot":"","sources":["../../src/services/otaLegacyMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAqB,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAEpF,2FAA2F;AAC3F,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,wBAAwB,CAehG;AAED,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAY9E;AAED,6GAA6G;AAC7G,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,wBAAwB,GACxD,WAAW,CAiBb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaLegacyMapping.js","sourceRoot":"","sources":["../../src/services/otaLegacyMapping.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAA8B;IACp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;QACd,WAAW,EAAE,CAAC,CAAC,YAAY;QAC3B,cAAc,EAAE,CAAC,CAAC,eAAe;QACjC,MAAM,EAAE,CAAC,CAAC,MAA6B;QACvC,KAAK,EAAE,CAAC,CAAC,aAAa;KACvB,CAAA;AACH,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,mCAAmC,CACjD,KAAyD;IAEzD,MAAM,CAAC,GAAG,uBAAuB,CAAC,KAAgC,CAAC,CAAA;IACnE,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAW,CAAA;IAChE,IAAI,EAAE,GAAsB,UAAU,CAAA;IACtC,mHAAmH;IACnH,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,MAAM,KAAK,eAAe;QAAE,EAAE,GAAG,UAAU,CAAA;SACvE,IAAI,CAAC,CAAC,MAAM,KAAK,QAAQ;QAAE,EAAE,GAAG,QAAQ,CAAA;SACxC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM;QAAE,EAAE,GAAG,SAAS,CAAA;IAC5C,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;QACrD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;QACzB,eAAe,EAAE,CAAC;QAClB,UAAU,EAAE,CAAC;QACb,aAAa,EAAE,CAAC,CAAC,SAAS,IAAI,KAAK;QACnC,YAAY,EAAE,CAAC,CAAC,aAAa;KAC9B,CAAA;AACH,CAAC","sourcesContent":["import type {OtaProgress, OtaProgressStatus, OtaStatus} from \"@mentra/bluetooth-sdk
|
|
1
|
+
{"version":3,"file":"otaLegacyMapping.js","sourceRoot":"","sources":["../../src/services/otaLegacyMapping.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAA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C,KAAK;QACd,WAAW,EAAE,CAAC,CAAC,YAAY;QAC3B,cAAc,EAAE,CAAC,CAAC,eAAe;QACjC,MAAM,EAAE,CAAC,CAAC,MAA6B;QACvC,KAAK,EAAE,CAAC,CAAC,aAAa;KACvB,CAAA;AACH,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,mCAAmC,CACjD,KAAyD;IAEzD,MAAM,CAAC,GAAG,uBAAuB,CAAC,KAAgC,CAAC,CAAA;IACnE,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAW,CAAA;IAChE,IAAI,EAAE,GAAsB,UAAU,CAAA;IACtC,mHAAmH;IACnH,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,MAAM,KAAK,eAAe;QAAE,EAAE,GAAG,UAAU,CAAA;SACvE,IAAI,CAAC,CAAC,MAAM,KAAK,QAAQ;QAAE,EAAE,GAAG,QAAQ,CAAA;SACxC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM;QAAE,EAAE,GAAG,SAAS,CAAA;IAC5C,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;QACrD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;QACzB,eAAe,EAAE,CAAC;QAClB,UAAU,EAAE,CAAC;QACb,aAAa,EAAE,CAAC,CAAC,SAAS,IAAI,KAAK;QACnC,YAAY,EAAE,CAAC,CAAC,aAAa;KAC9B,CAAA;AACH,CAAC","sourcesContent":["import type {OtaProgress, OtaProgressStatus, OtaStatus} from \"@mentra/bluetooth-sdk\"\n\n/** Normalized ota_status fields (snake_case) after bridging Core/expo (snake or camel). */\nexport type NormalizedOtaStatusEvent = {\n session_id: string\n total_steps: number\n current_step: number\n step_type: string\n phase: \"download\" | \"install\"\n step_percent: number\n overall_percent: number\n status: string\n error_message?: string\n}\n\n/**\n * Core may deliver ota_status with snake_case (Android) or camelCase (some bridge paths).\n * Use this for Mantle and legacy otaProgress mapping.\n */\nexport function normalizeOtaStatusEvent(event: Record<string, unknown>): NormalizedOtaStatusEvent {\n const e = event as Record<string, any>\n const phase: \"download\" | \"install\" = e?.phase === \"install\" ? \"install\" : \"download\"\n const err = e?.error_message ?? e?.errorMessage\n return {\n session_id: String(e?.session_id ?? e?.sessionId ?? \"\"),\n total_steps: Number(e?.total_steps ?? e?.totalSteps ?? 0),\n current_step: Number(e?.current_step ?? e?.currentStep ?? 0),\n step_type: String(e?.step_type ?? e?.stepType ?? \"apk\"),\n phase,\n step_percent: Number(e?.step_percent ?? e?.stepPercent ?? 0),\n overall_percent: Number(e?.overall_percent ?? e?.overallPercent ?? 0),\n status: String(e?.status ?? \"idle\"),\n error_message: err == null || err === \"\" ? undefined : String(err),\n }\n}\n\nexport function otaStatusFromNormalized(n: NormalizedOtaStatusEvent): OtaStatus {\n return {\n sessionId: n.session_id,\n totalSteps: n.total_steps,\n currentStep: n.current_step,\n stepType: n.step_type as OtaStatus[\"stepType\"],\n phase: n.phase,\n stepPercent: n.step_percent,\n overallPercent: n.overall_percent,\n status: n.status as OtaStatus[\"status\"],\n error: n.error_message,\n }\n}\n\n/** Maps unified ota_status from Core into the legacy otaProgress store shape (progress-legacy, settings). */\nexport function legacyOtaProgressFromOtaStatusEvent(\n event: Record<string, unknown> | NormalizedOtaStatusEvent,\n): OtaProgress {\n const n = normalizeOtaStatusEvent(event as Record<string, unknown>)\n const raw = (n.overall_percent ?? n.step_percent ?? 0) as number\n let st: OtaProgressStatus = \"PROGRESS\"\n // Native K900 BES OTA (sr_adota) sends step_complete, not complete, on success — map for progress-legacy FINISHED.\n if (n.status === \"complete\" || n.status === \"step_complete\") st = \"FINISHED\"\n else if (n.status === \"failed\") st = \"FAILED\"\n else if (n.status === \"idle\") st = \"STARTED\"\n return {\n stage: n.phase === \"install\" ? \"install\" : \"download\",\n status: st,\n progress: Math.round(raw),\n bytesDownloaded: 0,\n totalBytes: 0,\n currentUpdate: n.step_type || \"apk\",\n errorMessage: n.error_message,\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function isLegacyAsgOtaStartBuild(glassesBuildNumber?: string | null): boolean;
|
|
2
|
+
export declare function selectModernOtaManifestPin({ developerOverride, hostReleasePin, engineReleasePin, }: {
|
|
3
|
+
developerOverride?: string | null;
|
|
4
|
+
hostReleasePin?: string | null;
|
|
5
|
+
engineReleasePin?: string | null;
|
|
6
|
+
}): string | null;
|
|
7
|
+
export declare function resolveOtaManifestPolicy({ glassesUrl, glassesBuildNumber, developerOverride, hostReleasePin, engineReleasePin, }: {
|
|
8
|
+
glassesUrl?: string | null;
|
|
9
|
+
glassesBuildNumber?: string | null;
|
|
10
|
+
developerOverride?: string | null;
|
|
11
|
+
hostReleasePin?: string | null;
|
|
12
|
+
engineReleasePin?: string | null;
|
|
13
|
+
}): string | null;
|
|
14
|
+
//# sourceMappingURL=otaManifestPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otaManifestPolicy.d.ts","sourceRoot":"","sources":["../../src/services/otaManifestPolicy.ts"],"names":[],"mappings":"AAOA,wBAAgB,wBAAwB,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGpF;AAED,wBAAgB,0BAA0B,CAAC,EACzC,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,EAAE;IACD,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC,GAAG,MAAM,GAAG,IAAI,CAEhB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC,GAAG,MAAM,GAAG,IAAI,CAKhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const OTA_VERSION_URL_LEGACY_PROD = "https://ota.mentraglass.com/prod_live_version.json";
|
|
2
|
+
function trimmed(value) {
|
|
3
|
+
const result = value?.trim();
|
|
4
|
+
return result || null;
|
|
5
|
+
}
|
|
6
|
+
export function isLegacyAsgOtaStartBuild(glassesBuildNumber) {
|
|
7
|
+
const buildNumber = Number.parseInt(glassesBuildNumber ?? "", 10);
|
|
8
|
+
return Number.isFinite(buildNumber) && buildNumber < 39;
|
|
9
|
+
}
|
|
10
|
+
export function selectModernOtaManifestPin({ developerOverride, hostReleasePin, engineReleasePin, }) {
|
|
11
|
+
return trimmed(developerOverride) || trimmed(hostReleasePin) || trimmed(engineReleasePin);
|
|
12
|
+
}
|
|
13
|
+
export function resolveOtaManifestPolicy({ glassesUrl, glassesBuildNumber, developerOverride, hostReleasePin, engineReleasePin, }) {
|
|
14
|
+
if (isLegacyAsgOtaStartBuild(glassesBuildNumber)) {
|
|
15
|
+
return trimmed(glassesUrl) || OTA_VERSION_URL_LEGACY_PROD;
|
|
16
|
+
}
|
|
17
|
+
return selectModernOtaManifestPin({ developerOverride, hostReleasePin, engineReleasePin });
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=otaManifestPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otaManifestPolicy.js","sourceRoot":"","sources":["../../src/services/otaManifestPolicy.ts"],"names":[],"mappings":"AAAA,MAAM,2BAA2B,GAAG,oDAAoD,CAAA;AAExF,SAAS,OAAO,CAAC,KAAqB;IACpC,MAAM,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;IAC5B,OAAO,MAAM,IAAI,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,kBAAkC;IACzE,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IACjE,OAAO,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,EAAE,CAAA;AACzD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,EACzC,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GAKjB;IACC,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAC3F,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EACvC,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GAOjB;IACC,IAAI,wBAAwB,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACjD,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,2BAA2B,CAAA;IAC3D,CAAC;IACD,OAAO,0BAA0B,CAAC,EAAC,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAC,CAAC,CAAA;AAC1F,CAAC","sourcesContent":["const OTA_VERSION_URL_LEGACY_PROD = \"https://ota.mentraglass.com/prod_live_version.json\"\n\nfunction trimmed(value?: string | null): string | null {\n const result = value?.trim()\n return result || null\n}\n\nexport function isLegacyAsgOtaStartBuild(glassesBuildNumber?: string | null): boolean {\n const buildNumber = Number.parseInt(glassesBuildNumber ?? \"\", 10)\n return Number.isFinite(buildNumber) && buildNumber < 39\n}\n\nexport function selectModernOtaManifestPin({\n developerOverride,\n hostReleasePin,\n engineReleasePin,\n}: {\n developerOverride?: string | null\n hostReleasePin?: string | null\n engineReleasePin?: string | null\n}): string | null {\n return trimmed(developerOverride) || trimmed(hostReleasePin) || trimmed(engineReleasePin)\n}\n\nexport function resolveOtaManifestPolicy({\n glassesUrl,\n glassesBuildNumber,\n developerOverride,\n hostReleasePin,\n engineReleasePin,\n}: {\n glassesUrl?: string | null\n glassesBuildNumber?: string | null\n developerOverride?: string | null\n hostReleasePin?: string | null\n engineReleasePin?: string | null\n}): string | null {\n if (isLegacyAsgOtaStartBuild(glassesBuildNumber)) {\n return trimmed(glassesUrl) || OTA_VERSION_URL_LEGACY_PROD\n }\n return selectModernOtaManifestPin({developerOverride, hostReleasePin, engineReleasePin})\n}\n"]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function hasConfiguredModernOtaManifestPin(): boolean;
|
|
2
|
+
export declare function resolveOtaManifestUrl(glassesUrl?: string | null, glassesBuildNumber?: string | null): string | null;
|
|
2
3
|
//# sourceMappingURL=otaManifestUrl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaManifestUrl.d.ts","sourceRoot":"","sources":["../../src/services/otaManifestUrl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"otaManifestUrl.d.ts","sourceRoot":"","sources":["../../src/services/otaManifestUrl.ts"],"names":[],"mappings":"AAyBA,wBAAgB,iCAAiC,IAAI,OAAO,CAQ3D;AAED,wBAAgB,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAQnH"}
|