@mentra/engine 3.2.0-dev.137 → 3.2.0-dev.154
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/build/engine.d.ts.map +1 -1
- package/build/engine.js +15 -9
- package/build/engine.js.map +1 -1
- package/build/facades/ota.d.ts +1 -0
- package/build/facades/ota.d.ts.map +1 -1
- package/build/facades/ota.js +1 -0
- package/build/facades/ota.js.map +1 -1
- package/build/facades/reports.d.ts.map +1 -1
- package/build/facades/reports.js +3 -0
- package/build/facades/reports.js.map +1 -1
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/react/MentraLiveOtaFlow.d.ts.map +1 -1
- package/build/react/MentraLiveOtaFlow.js +12 -0
- package/build/react/MentraLiveOtaFlow.js.map +1 -1
- package/build/react/useMentraLiveOta.d.ts +3 -1
- package/build/react/useMentraLiveOta.d.ts.map +1 -1
- package/build/react/useMentraLiveOta.js +19 -1
- package/build/react/useMentraLiveOta.js.map +1 -1
- package/build/runtime/bootstrap.d.ts +46 -3
- package/build/runtime/bootstrap.d.ts.map +1 -1
- package/build/runtime/bootstrap.js +60 -1
- package/build/runtime/bootstrap.js.map +1 -1
- package/build/runtime/config.d.ts +4 -0
- package/build/runtime/config.d.ts.map +1 -1
- package/build/runtime/config.js.map +1 -1
- package/build/runtime/streamConfig.d.ts.map +1 -1
- package/build/runtime/streamConfig.js +6 -0
- package/build/runtime/streamConfig.js.map +1 -1
- package/build/services/AppRegistry.d.ts +15 -1
- package/build/services/AppRegistry.d.ts.map +1 -1
- package/build/services/AppRegistry.js +48 -12
- package/build/services/AppRegistry.js.map +1 -1
- package/build/services/CloudClientService.d.ts +3 -1
- package/build/services/CloudClientService.d.ts.map +1 -1
- package/build/services/CloudClientService.js +75 -18
- package/build/services/CloudClientService.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +54 -12
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/MiniappLauncher.d.ts.map +1 -1
- package/build/services/MiniappLauncher.js +9 -1
- package/build/services/MiniappLauncher.js.map +1 -1
- package/build/services/NavigationHandlers.d.ts.map +1 -1
- package/build/services/NavigationHandlers.js +8 -0
- package/build/services/NavigationHandlers.js.map +1 -1
- package/build/services/OtaUpdateCheckService.d.ts +10 -1
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
- package/build/services/OtaUpdateCheckService.js +24 -5
- package/build/services/OtaUpdateCheckService.js.map +1 -1
- package/build/services/miniappInstallIdentity.d.ts +10 -0
- package/build/services/miniappInstallIdentity.d.ts.map +1 -0
- package/build/services/miniappInstallIdentity.js +10 -0
- package/build/services/miniappInstallIdentity.js.map +1 -0
- package/build/services/otaManifestPolicy.d.ts +3 -0
- package/build/services/otaManifestPolicy.d.ts.map +1 -1
- package/build/services/otaManifestPolicy.js +8 -0
- package/build/services/otaManifestPolicy.js.map +1 -1
- package/build/services/otaManifestUrl.d.ts.map +1 -1
- package/build/services/otaManifestUrl.js +10 -2
- package/build/services/otaManifestUrl.js.map +1 -1
- package/build/stores/glasses.d.ts.map +1 -1
- package/build/stores/glasses.js +6 -0
- package/build/stores/glasses.js.map +1 -1
- package/build/stores/settings.d.ts.map +1 -1
- package/build/stores/settings.js +20 -3
- package/build/stores/settings.js.map +1 -1
- package/package.json +7 -7
- package/src/engine.ts +22 -12
- package/src/facades/ota.ts +1 -0
- package/src/facades/reports.ts +4 -6
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/index.ts +2 -0
- package/src/react/MentraLiveOtaFlow.tsx +21 -0
- package/src/react/useMentraLiveOta.ts +23 -2
- package/src/runtime/bootstrap.ts +117 -4
- package/src/runtime/config.ts +4 -0
- package/src/runtime/streamConfig.ts +4 -0
- package/src/services/AppRegistry.ts +94 -25
- package/src/services/CloudClientService.ts +70 -24
- package/src/services/LocalMiniappRuntime.ts +85 -26
- package/src/services/MiniappLauncher.ts +15 -1
- package/src/services/NavigationHandlers.ts +8 -0
- package/src/services/OtaUpdateCheckService.ts +32 -6
- package/src/services/miniappInstallIdentity.ts +18 -0
- package/src/services/otaManifestPolicy.ts +11 -0
- package/src/services/otaManifestUrl.ts +10 -2
- package/src/stores/glasses.ts +6 -0
- package/src/stores/settings.ts +20 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiniappLauncher.d.ts","sourceRoot":"","sources":["../../src/services/MiniappLauncher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"MiniappLauncher.d.ts","sourceRoot":"","sources":["../../src/services/MiniappLauncher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,OAA4B,EAAC,KAAK,wBAAwB,EAAC,MAAM,uBAAuB,CAAA;AACxF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAEpD,UAAU,YAAY;IACpB,oEAAoE;IACpE,MAAM,EAAE,cAAc,CAAA;CACvB;AAED,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,mBAAmB,EAAE,MAAM,EAAE,CAAA;IAC7B,iBAAiB,CAAC,EAAE,wBAAwB,CAAA;IAC5C,yEAAyE;IACzE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAED,u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isInstalledMiniappAllowed, isLocalMiniappPackageAllowed } from "../runtime/bootstrap";
|
|
26
27
|
import { resolveDevBundleSource } from "../utils/devMiniappSnapshot";
|
|
27
28
|
import { storage } from "../utils/storage/storage";
|
|
28
29
|
import appRegistry, { getLocalAppRunningState, saveLocalAppRunningState } from "./AppRegistry";
|
|
@@ -89,7 +90,7 @@ class MiniappLauncher {
|
|
|
89
90
|
if (!entry?.background)
|
|
90
91
|
return null;
|
|
91
92
|
// Use the host that actually answered — may differ from the stored IP
|
|
92
|
-
// after a laptop Wi-Fi change (mDNS / Metro failover inside
|
|
93
|
+
// after a laptop Wi-Fi change (mDNS / Metro failover inside resolveDevBundleSource).
|
|
93
94
|
const base = resolvedUrl.replace(/\/$/, "");
|
|
94
95
|
// entry.* are bundle-root paths (dist/ stripped); the dev server serves
|
|
95
96
|
// files relative to cwd, so prepend dist/.
|
|
@@ -183,6 +184,9 @@ class MiniappLauncher {
|
|
|
183
184
|
* {@link LocalMiniappRuntime.waitForConnect}.
|
|
184
185
|
*/
|
|
185
186
|
async ensureRunning(packageName, hints) {
|
|
187
|
+
if (!isLocalMiniappPackageAllowed(packageName)) {
|
|
188
|
+
throw new Error(`MiniappLauncher: ${packageName} is disabled by deployment policy`);
|
|
189
|
+
}
|
|
186
190
|
const router = this.requireRouter();
|
|
187
191
|
// Already spawned: best-effort resolve for the UI entry, never throw —
|
|
188
192
|
// a headless caller that doesn't need UI gets {null, null} fast even if
|
|
@@ -211,6 +215,10 @@ class MiniappLauncher {
|
|
|
211
215
|
if (!resolved) {
|
|
212
216
|
throw new Error(`MiniappLauncher: cannot resolve bundle for ${packageName}`);
|
|
213
217
|
}
|
|
218
|
+
const version = resolved.installedManifest?.version;
|
|
219
|
+
if (!isInstalledMiniappAllowed(packageName, version, version ? appRegistry.getReleaseIdentity(packageName, version) : null)) {
|
|
220
|
+
throw new Error(`MiniappLauncher: ${packageName} bundle is not authorized by deployment policy`);
|
|
221
|
+
}
|
|
214
222
|
// Re-check after the async resolve: a different path may have spawned it
|
|
215
223
|
// while we were fetching/reading the bundle.
|
|
216
224
|
if (!router.registeredPackages().includes(packageName)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiniappLauncher.js","sourceRoot":"","sources":["../../src/services/MiniappLauncher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAErC,OAAO,EAAC,sBAAsB,EAAC,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAA;AAChD,OAAO,WAAW,EAAE,EAAC,uBAAuB,EAAE,wBAAwB,EAAC,MAAM,eAAe,CAAA;AAC5F,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,mBAAoD,MAAM,uBAAuB,CAAA;AAiCxF,MAAM,eAAe;IACX,IAAI,GAAwB,IAAI,CAAA;IAExC;;;;;;OAMG;IACc,QAAQ,GAAG,IAAI,GAAG,EAAiC,CAAA;IAEpE,uEAAuE;IACvE,SAAS,CAAC,IAAkB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAA;QACvF,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAA;IACzB,CAAC;IAED,yEAAyE;IACzE,SAAS,CAAC,WAAmB;QAC3B,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,kBAAkB,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,KAAK,CAAA;IAC9E,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB,EAAE,KAAmB;QAC1D,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,IAAI,IAAI,CAAC,Y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EpE,YAAY,CAAC,WAAmB;QACtC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAS,GAAG,WAAW,UAAU,CAAC,CAAA;QACxD,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IACxC,CAAC;IAED,4EAA4E;IACpE,cAAc,CAAC,WAA+B,EAAE,WAAmB;QACzE,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;YACnC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,CAAA;QAClC,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAS,GAAG,WAAW,WAAW,CAAC,CAAA;QAC9D,IAAI,MAAM,CAAC,KAAK,EAAE;YAAE,OAAO,MAAM,CAAC,KAAK,CAAA;QACvC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA","sourcesContent":["/**\n * MiniappLauncher — headless launch/teardown of a local miniapp's background\n * JS context.\n *\n * This is the one piece of \"run a miniapp\" that used to live inside the\n * `LocalMiniappView` React component (resolve the bundle → read the manifest →\n * `spawnAndRegister`), triggered only when the Compositor mounted that\n * component on foreground. Pulling it into the runtime means:\n *\n * - `start()` can actually spawn an app even when nothing foregrounds it\n * (e.g. a system app launching another miniapp via `session.miniapps`).\n * - the action broker can wake a stopped target headlessly — no UI at all.\n * - the dev hot-reload respawn path and the WebView mount path share one\n * resolve+spawn recipe instead of three copies.\n *\n * The launcher is **headless**: no React, no RN components. The engine-owned\n * MiniappEngine hands it the {@link MentraJSRouter} instance once during\n * engine construction. OEMs embedding the runtime drive miniapp lifecycle\n * through the engine facade and stores, not a separate launcher configure API.\n *\n * Boundary: the launcher owns the **background** context. WebView *rendering*\n * (the UI layer) stays with the host — the launcher just hands back the\n * resolved UI entry so the host can mount its `<WebView>`.\n */\n\nimport {File} from \"expo-file-system\"\n\nimport {resolveDevBundleSource} from \"../utils/devMiniappSnapshot\"\nimport {storage} from \"../utils/storage/storage\"\nimport appRegistry, {getLocalAppRunningState, saveLocalAppRunningState} from \"./AppRegistry\"\nimport devServerBridge from \"./DevServerBridge\"\nimport localMiniappRuntime, {type InstalledMiniappManifest} from \"./LocalMiniappRuntime\"\nimport type {MentraJSRouter} from \"./MentraJSRouter\"\n\ninterface LauncherDeps {\n /** The host-constructed router (needs the native Crust binding). */\n router: MentraJSRouter\n}\n\n/** Hints the host may pass from a view's props to avoid re-deriving them. */\nexport interface LaunchHints {\n devUrl?: string\n version?: string\n devPort?: string\n}\n\n/** Everything the launcher resolved for a package — bg source + UI entry. */\nexport interface ResolvedBundle {\n bgSource: string\n uiUri: string | null\n uiBaseDir: string | null\n declaredPermissions: string[]\n installedManifest?: InstalledMiniappManifest\n /** Set for dev miniapps (HTTP off the dev server); null for released. */\n devUrl: string | null\n devPort: number | null\n}\n\n/** What the host needs back to render the UI layer. */\nexport interface LaunchResult {\n uiUri: string | null\n uiBaseDir: string | null\n}\n\nclass MiniappLauncher {\n private deps: LauncherDeps | null = null\n\n /**\n * In-flight launches keyed by packageName. Both apps.ts start() and the\n * WebView mount call ensureRunning() before the first spawnAndRegister\n * resolves — without this, neither sees the package in registeredPackages()\n * yet and both spawn the same context (a clobber/double-spawn). Concurrent\n * callers share the same promise.\n */\n private readonly inFlight = new Map<string, Promise<LaunchResult>>()\n\n /** Wire the router in. Called once from MiniappEngine construction. */\n configure(deps: LauncherDeps): void {\n this.deps = deps\n }\n\n private requireRouter(): MentraJSRouter {\n if (!this.deps) {\n throw new Error(\"MiniappLauncher not configured — ensureMiniappEngine() has not run\")\n }\n return this.deps.router\n }\n\n /** True iff the package's background JS context is currently spawned. */\n isRunning(packageName: string): boolean {\n return this.deps?.router.registeredPackages().includes(packageName) ?? false\n }\n\n /**\n * Resolve the background JS source + UI entry + declared permissions for a\n * package. Handles both dev (HTTP off the running dev server) and released\n * (file:// from the installed snapshot). Reads disk/network/storage; does\n * NOT spawn. Returns null when the bundle can't be resolved (dev server\n * unreachable with no on-disk snapshot, missing entry, no installed version).\n */\n async resolveBundle(packageName: string, hints?: LaunchHints): Promise<ResolvedBundle | null> {\n const devUrl = hints?.devUrl ?? this.storedDevUrl(packageName)\n\n // --- Dev: live HTTP, then the last on-disk snapshot if the laptop is gone. ---\n if (devUrl) {\n const source = await resolveDevBundleSource(packageName, devUrl)\n if (source.kind === \"live\") {\n const live = await this.resolveLiveHttp(packageName, source.resolvedUrl, source.manifest, hints)\n if (live) return live\n // Live probe succeeded but the entry fetch failed — still try disk.\n }\n const snapshotVersion =\n source.kind === \"snapshot\" ? source.version : appRegistry.getLatestDevSnapshotVersion(packageName)\n if (snapshotVersion) {\n const snapshot = await this.resolveInstalledBundle(packageName, snapshotVersion)\n if (snapshot) return snapshot\n }\n return null\n }\n\n // --- Released: resolve from the installed file:// snapshot. ---\n const version = hints?.version ?? (await appRegistry.getActiveVersion(packageName))\n if (!version) return null\n return this.resolveInstalledBundle(packageName, version)\n }\n\n private async resolveLiveHttp(\n packageName: string,\n resolvedUrl: string,\n manifest: {entry?: unknown; permissions?: unknown; [key: string]: unknown},\n hints?: LaunchHints,\n ): Promise<ResolvedBundle | null> {\n const entry = manifest.entry as {background?: string; ui?: string} | undefined\n if (!entry?.background) return null\n\n // Use the host that actually answered — may differ from the stored IP\n // after a laptop Wi-Fi change (mDNS / Metro failover inside decideDevLaunchRoute).\n const base = resolvedUrl.replace(/\\/$/, \"\")\n // entry.* are bundle-root paths (dist/ stripped); the dev server serves\n // files relative to cwd, so prepend dist/.\n const bgUrl = `${base}/dist/${entry.background.replace(/^\\.?\\/+/, \"\")}`\n const uiUri = entry.ui ? `${base}/dist/${entry.ui.replace(/^\\.?\\/+/, \"\")}` : null\n\n const perms = manifest.permissions as Array<{type?: string} | string> | undefined\n const declaredPermissions = (perms ?? [])\n .map((p) => (typeof p === \"string\" ? p : p?.type))\n .filter((t): t is string => typeof t === \"string\")\n const installedManifest: InstalledMiniappManifest = {\n packageName: typeof manifest.packageName === \"string\" ? manifest.packageName : packageName,\n name: typeof manifest.name === \"string\" ? manifest.name : undefined,\n version: typeof manifest.version === \"string\" ? manifest.version : undefined,\n sdkVersion: typeof manifest.sdkVersion === \"string\" ? manifest.sdkVersion : undefined,\n minHostVersion: typeof manifest.minHostVersion === \"string\" ? manifest.minHostVersion : undefined,\n type: typeof manifest.type === \"string\" ? manifest.type : undefined,\n entry: manifest.entry as InstalledMiniappManifest[\"entry\"],\n permissions: manifest.permissions as InstalledMiniappManifest[\"permissions\"],\n hardwareRequirements: manifest.hardwareRequirements as InstalledMiniappManifest[\"hardwareRequirements\"],\n actions: manifest.actions as InstalledMiniappManifest[\"actions\"],\n }\n\n let bgSource: string\n try {\n const res = await fetch(bgUrl)\n if (!res.ok) return null\n bgSource = await res.text()\n } catch {\n return null\n }\n\n return {\n bgSource,\n uiUri,\n uiBaseDir: uiUri ? uiUri.replace(/\\/[^/]+$/, \"/\") : null,\n declaredPermissions,\n installedManifest,\n devUrl: resolvedUrl,\n devPort: this.resolveDevPort(hints?.devPort, packageName),\n }\n }\n\n private async resolveInstalledBundle(packageName: string, version: string): Promise<ResolvedBundle | null> {\n const entryPaths = appRegistry.getMiniappEntryPaths(packageName, version)\n if (!entryPaths?.background) return null\n\n const manifest = appRegistry.getMiniappManifest(packageName, version) as {\n packageName?: string\n name?: string\n version?: string\n sdkVersion?: string\n minHostVersion?: string\n type?: string\n entry?: {background?: string; ui?: string}\n permissions?: Array<{type: string; required?: boolean; description?: string}>\n hardwareRequirements?: Array<{type: string; level: string; description?: string}>\n actions?: Array<{id?: unknown; description?: unknown; parameters?: unknown; outputSchema?: unknown}>\n } | null\n const declaredPermissions = (manifest?.permissions ?? [])\n .map((p) => p.type)\n .filter((t): t is string => typeof t === \"string\")\n const installedManifest: InstalledMiniappManifest | undefined = manifest\n ? {\n packageName: manifest.packageName ?? packageName,\n name: manifest.name,\n version: manifest.version ?? version,\n sdkVersion: manifest.sdkVersion,\n minHostVersion: manifest.minHostVersion,\n type: manifest.type,\n entry: manifest.entry,\n permissions: manifest.permissions,\n hardwareRequirements: manifest.hardwareRequirements,\n actions: manifest.actions,\n }\n : undefined\n\n let bgSource: string\n try {\n bgSource = new File(entryPaths.background).textSync()\n } catch {\n return null\n }\n\n return {\n bgSource,\n uiUri: entryPaths.ui ?? null,\n uiBaseDir: entryPaths.ui ? entryPaths.ui.replace(/\\/[^/]+$/, \"/\") : null,\n declaredPermissions,\n installedManifest,\n // Snapshot fallback is file:// — do not wire the sidecar; the laptop is gone.\n devUrl: null,\n devPort: null,\n }\n }\n\n /**\n * Ensure a miniapp's background JS context is spawned. Idempotent — if the\n * context is already alive this is a no-op spawn-wise (it still resolves the\n * UI entry so a re-mounting host gets its `<WebView>` source back).\n *\n * Resolves once the context is SPAWNED. It does NOT block on the context's\n * CONNECT handshake — the host's WebView mount shouldn't wait on background\n * JS. Callers that need the context to be connected and ready to receive\n * messages (the action broker) follow up with\n * {@link LocalMiniappRuntime.waitForConnect}.\n */\n async ensureRunning(packageName: string, hints?: LaunchHints): Promise<LaunchResult> {\n const router = this.requireRouter()\n\n // Already spawned: best-effort resolve for the UI entry, never throw —\n // a headless caller that doesn't need UI gets {null, null} fast even if\n // the dev server has since dropped.\n if (router.registeredPackages().includes(packageName)) {\n const existing = await this.resolveBundle(packageName, hints).catch(() => null)\n return {uiUri: existing?.uiUri ?? null, uiBaseDir: existing?.uiBaseDir ?? null}\n }\n\n // Coalesce concurrent launches of the same package onto one promise.\n const pending = this.inFlight.get(packageName)\n if (pending) return pending\n\n const launch = this.spawn(packageName, hints)\n this.inFlight.set(packageName, launch)\n try {\n return await launch\n } finally {\n this.inFlight.delete(packageName)\n }\n }\n\n /** Resolve the bundle and spawn the context. Serialized via {@link inFlight}. */\n private async spawn(packageName: string, hints?: LaunchHints): Promise<LaunchResult> {\n const router = this.requireRouter()\n const resolved = await this.resolveBundle(packageName, hints)\n if (!resolved) {\n throw new Error(`MiniappLauncher: cannot resolve bundle for ${packageName}`)\n }\n\n // Re-check after the async resolve: a different path may have spawned it\n // while we were fetching/reading the bundle.\n if (!router.registeredPackages().includes(packageName)) {\n const ok = await router.spawnAndRegister(packageName, resolved.bgSource, {\n permissions: resolved.declaredPermissions,\n installedManifest: resolved.installedManifest,\n })\n if (!ok) {\n throw new Error(`MiniappLauncher: spawn failed for ${packageName}`)\n }\n\n // Dev: wire the hot-reload + log-forwarding sidecar. No-op in prod\n // (devServerBridge silently drops when no sidecar is up).\n if (resolved.devUrl && resolved.devPort != null) {\n devServerBridge.connect(packageName, resolved.devUrl, resolved.devPort)\n } else if (resolved.devUrl) {\n // Dev miniapp with no resolvable port — it still launches, but hot\n // reload + log forwarding won't connect. Surface it instead of failing\n // silently (the old inline path hard-failed with \"no dev port\").\n console.warn(`MiniappLauncher: ${packageName} has no dev port — hot reload + log forwarding disabled`)\n }\n }\n\n return {uiUri: resolved.uiUri, uiBaseDir: resolved.uiBaseDir}\n }\n\n /**\n * Re-spawn local miniapps that were running when the app was last killed.\n *\n * Cloud apps run on a remote server: the cloud persists which ones are\n * running and resurrects them when the phone reconnects, so a host-app\n * restart brings them back on its own. Local (phone-hosted) miniapps run in\n * the phone's own JS engine — a host-process kill tears down their JSContext\n * and there is no server to resurrect them, so without this they silently\n * stay stopped on the next launch even though the user left them running.\n *\n * Each local miniapp persists its running flag to disk on start/stop\n * (`saveLocalAppRunningState`, via the applet's `onStart`/`onStop`). We read\n * those flags back and re-spawn the background context headlessly (no\n * foreground, no navigation) — the spawn registers the package so the home\n * tray/switcher project it as running, exactly as a normal start would. The\n * WebView, if any, re-attaches lazily when the user opens the app.\n *\n * Idempotent and best-effort: skips already-spawned contexts, and clears the\n * persisted flag for any app whose bundle can no longer be resolved\n * (uninstalled, or dev server gone) so a dead entry doesn't retry every boot.\n * Not compatibility-gated: a previously-running background app shouldn't be\n * dropped just because glasses are momentarily disconnected at boot — it\n * resumes when they reconnect, same as mid-session.\n */\n async autostartLocalMiniapps(): Promise<void> {\n const apps = await appRegistry.getInstalledMiniapps()\n for (const app of apps) {\n // Only phone-hosted miniapps have a JSContext to re-spawn. Offline\n // built-ins (`local:false, offline:true`) restore their native running\n // state elsewhere and have no bundle to launch.\n if (!app.local) continue\n if (!getLocalAppRunningState(app.packageName)) continue\n if (this.isRunning(app.packageName)) continue\n try {\n await this.ensureRunning(app.packageName)\n } catch (e) {\n console.warn(`MiniappLauncher: autostart failed for ${app.packageName} — clearing stale running flag`, e)\n saveLocalAppRunningState(app.packageName, false)\n }\n }\n }\n\n /**\n * Ensure the context is running AND has completed its CONNECT handshake.\n * Used by the action broker, which must not deliver to a context that hasn't\n * come up yet. Throws on spawn failure or connect timeout.\n */\n async ensureConnected(packageName: string, connectTimeoutMs = 10_000, hints?: LaunchHints): Promise<void> {\n await this.ensureRunning(packageName, hints)\n await localMiniappRuntime.waitForConnect(packageName, connectTimeoutMs)\n }\n\n /** Tear down a miniapp's background JS context. */\n async stop(packageName: string): Promise<void> {\n // If a launch is in flight, let it finish first. Otherwise unregister()\n // no-ops on the not-yet-registered package and the pending spawn then\n // re-registers the context — leaving it running despite the stop.\n const pending = this.inFlight.get(packageName)\n if (pending) {\n try {\n await pending\n } catch {\n // Launch failed — nothing got registered, so nothing to tear down.\n }\n }\n await this.deps?.router.unregister(packageName)\n }\n\n // --- internals -----------------------------------------------------------\n\n private storedDevUrl(packageName: string): string | undefined {\n const r = storage.load<string>(`${packageName}_dev_url`)\n return r.is_ok() ? r.value : undefined\n }\n\n /** resolveDevPort — moved verbatim from the old LocalMiniappView helper. */\n private resolveDevPort(searchParam: string | undefined, packageName: string): number | null {\n if (searchParam) {\n const n = parseInt(searchParam, 10)\n if (Number.isFinite(n)) return n\n }\n const stored = storage.load<number>(`${packageName}_dev_port`)\n if (stored.is_ok()) return stored.value\n return null\n }\n}\n\nexport const miniappLaunc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AC;IAED,mDAAmD;IACnD,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC5B,wEAAwE;QACxE,sEAAsE;QACtE,kEAAkE;QAClE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QAC9C,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC;gBACH,MAAM,OAAO,CAAA;YACf,CAAC;YAAC,MAAM,CAAC;gBACP,mEAAmE;YACrE,CAAC;QACH,CAAC;QACD,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;IACjD,CAAC;IAED,4EAA4E;IAEpE,YAAY,CAAC,WAAmB;QACtC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAS,GAAG,WAAW,UAAU,CAAC,CAAA;QACxD,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IACxC,CAAC;IAED,4EAA4E;IACpE,cAAc,CAAC,WAA+B,EAAE,WAAmB;QACzE,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;YACnC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,CAAA;QAClC,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAS,GAAG,WAAW,WAAW,CAAC,CAAA;QAC9D,IAAI,MAAM,CAAC,KAAK,EAAE;YAAE,OAAO,MAAM,CAAC,KAAK,CAAA;QACvC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA","sourcesContent":["/**\n * MiniappLauncher — headless launch/teardown of a local miniapp's background\n * JS context.\n *\n * This is the one piece of \"run a miniapp\" that used to live inside the\n * `LocalMiniappView` React component (resolve the bundle → read the manifest →\n * `spawnAndRegister`), triggered only when the Compositor mounted that\n * component on foreground. Pulling it into the runtime means:\n *\n * - `start()` can actually spawn an app even when nothing foregrounds it\n * (e.g. a system app launching another miniapp via `session.miniapps`).\n * - the action broker can wake a stopped target headlessly — no UI at all.\n * - the dev hot-reload respawn path and the WebView mount path share one\n * resolve+spawn recipe instead of three copies.\n *\n * The launcher is **headless**: no React, no RN components. The engine-owned\n * MiniappEngine hands it the {@link MentraJSRouter} instance once during\n * engine construction. OEMs embedding the runtime drive miniapp lifecycle\n * through the engine facade and stores, not a separate launcher configure API.\n *\n * Boundary: the launcher owns the **background** context. WebView *rendering*\n * (the UI layer) stays with the host — the launcher just hands back the\n * resolved UI entry so the host can mount its `<WebView>`.\n */\n\nimport {File} from \"expo-file-system\"\n\nimport {isInstalledMiniappAllowed, isLocalMiniappPackageAllowed} from \"../runtime/bootstrap\"\nimport {resolveDevBundleSource} from \"../utils/devMiniappSnapshot\"\nimport {storage} from \"../utils/storage/storage\"\nimport appRegistry, {getLocalAppRunningState, saveLocalAppRunningState} from \"./AppRegistry\"\nimport devServerBridge from \"./DevServerBridge\"\nimport localMiniappRuntime, {type InstalledMiniappManifest} from \"./LocalMiniappRuntime\"\nimport type {MentraJSRouter} from \"./MentraJSRouter\"\n\ninterface LauncherDeps {\n /** The host-constructed router (needs the native Crust binding). */\n router: MentraJSRouter\n}\n\n/** Hints the host may pass from a view's props to avoid re-deriving them. */\nexport interface LaunchHints {\n devUrl?: string\n version?: string\n devPort?: string\n}\n\n/** Everything the launcher resolved for a package — bg source + UI entry. */\nexport interface ResolvedBundle {\n bgSource: string\n uiUri: string | null\n uiBaseDir: string | null\n declaredPermissions: string[]\n installedManifest?: InstalledMiniappManifest\n /** Set for dev miniapps (HTTP off the dev server); null for released. */\n devUrl: string | null\n devPort: number | null\n}\n\n/** What the host needs back to render the UI layer. */\nexport interface LaunchResult {\n uiUri: string | null\n uiBaseDir: string | null\n}\n\nclass MiniappLauncher {\n private deps: LauncherDeps | null = null\n\n /**\n * In-flight launches keyed by packageName. Both apps.ts start() and the\n * WebView mount call ensureRunning() before the first spawnAndRegister\n * resolves — without this, neither sees the package in registeredPackages()\n * yet and both spawn the same context (a clobber/double-spawn). Concurrent\n * callers share the same promise.\n */\n private readonly inFlight = new Map<string, Promise<LaunchResult>>()\n\n /** Wire the router in. Called once from MiniappEngine construction. */\n configure(deps: LauncherDeps): void {\n this.deps = deps\n }\n\n private requireRouter(): MentraJSRouter {\n if (!this.deps) {\n throw new Error(\"MiniappLauncher not configured — ensureMiniappEngine() has not run\")\n }\n return this.deps.router\n }\n\n /** True iff the package's background JS context is currently spawned. */\n isRunning(packageName: string): boolean {\n return this.deps?.router.registeredPackages().includes(packageName) ?? false\n }\n\n /**\n * Resolve the background JS source + UI entry + declared permissions for a\n * package. Handles both dev (HTTP off the running dev server) and released\n * (file:// from the installed snapshot). Reads disk/network/storage; does\n * NOT spawn. Returns null when the bundle can't be resolved (dev server\n * unreachable with no on-disk snapshot, missing entry, no installed version).\n */\n async resolveBundle(packageName: string, hints?: LaunchHints): Promise<ResolvedBundle | null> {\n const devUrl = hints?.devUrl ?? this.storedDevUrl(packageName)\n\n // --- Dev: live HTTP, then the last on-disk snapshot if the laptop is gone. ---\n if (devUrl) {\n const source = await resolveDevBundleSource(packageName, devUrl)\n if (source.kind === \"live\") {\n const live = await this.resolveLiveHttp(packageName, source.resolvedUrl, source.manifest, hints)\n if (live) return live\n // Live probe succeeded but the entry fetch failed — still try disk.\n }\n const snapshotVersion =\n source.kind === \"snapshot\" ? source.version : appRegistry.getLatestDevSnapshotVersion(packageName)\n if (snapshotVersion) {\n const snapshot = await this.resolveInstalledBundle(packageName, snapshotVersion)\n if (snapshot) return snapshot\n }\n return null\n }\n\n // --- Released: resolve from the installed file:// snapshot. ---\n const version = hints?.version ?? (await appRegistry.getActiveVersion(packageName))\n if (!version) return null\n return this.resolveInstalledBundle(packageName, version)\n }\n\n private async resolveLiveHttp(\n packageName: string,\n resolvedUrl: string,\n manifest: {entry?: unknown; permissions?: unknown; [key: string]: unknown},\n hints?: LaunchHints,\n ): Promise<ResolvedBundle | null> {\n const entry = manifest.entry as {background?: string; ui?: string} | undefined\n if (!entry?.background) return null\n\n // Use the host that actually answered — may differ from the stored IP\n // after a laptop Wi-Fi change (mDNS / Metro failover inside resolveDevBundleSource).\n const base = resolvedUrl.replace(/\\/$/, \"\")\n // entry.* are bundle-root paths (dist/ stripped); the dev server serves\n // files relative to cwd, so prepend dist/.\n const bgUrl = `${base}/dist/${entry.background.replace(/^\\.?\\/+/, \"\")}`\n const uiUri = entry.ui ? `${base}/dist/${entry.ui.replace(/^\\.?\\/+/, \"\")}` : null\n\n const perms = manifest.permissions as Array<{type?: string} | string> | undefined\n const declaredPermissions = (perms ?? [])\n .map((p) => (typeof p === \"string\" ? p : p?.type))\n .filter((t): t is string => typeof t === \"string\")\n const installedManifest: InstalledMiniappManifest = {\n packageName: typeof manifest.packageName === \"string\" ? manifest.packageName : packageName,\n name: typeof manifest.name === \"string\" ? manifest.name : undefined,\n version: typeof manifest.version === \"string\" ? manifest.version : undefined,\n sdkVersion: typeof manifest.sdkVersion === \"string\" ? manifest.sdkVersion : undefined,\n minHostVersion: typeof manifest.minHostVersion === \"string\" ? manifest.minHostVersion : undefined,\n type: typeof manifest.type === \"string\" ? manifest.type : undefined,\n entry: manifest.entry as InstalledMiniappManifest[\"entry\"],\n permissions: manifest.permissions as InstalledMiniappManifest[\"permissions\"],\n hardwareRequirements: manifest.hardwareRequirements as InstalledMiniappManifest[\"hardwareRequirements\"],\n actions: manifest.actions as InstalledMiniappManifest[\"actions\"],\n }\n\n let bgSource: string\n try {\n const res = await fetch(bgUrl)\n if (!res.ok) return null\n bgSource = await res.text()\n } catch {\n return null\n }\n\n return {\n bgSource,\n uiUri,\n uiBaseDir: uiUri ? uiUri.replace(/\\/[^/]+$/, \"/\") : null,\n declaredPermissions,\n installedManifest,\n devUrl: resolvedUrl,\n devPort: this.resolveDevPort(hints?.devPort, packageName),\n }\n }\n\n private async resolveInstalledBundle(packageName: string, version: string): Promise<ResolvedBundle | null> {\n const entryPaths = appRegistry.getMiniappEntryPaths(packageName, version)\n if (!entryPaths?.background) return null\n\n const manifest = appRegistry.getMiniappManifest(packageName, version) as {\n packageName?: string\n name?: string\n version?: string\n sdkVersion?: string\n minHostVersion?: string\n type?: string\n entry?: {background?: string; ui?: string}\n permissions?: Array<{type: string; required?: boolean; description?: string}>\n hardwareRequirements?: Array<{type: string; level: string; description?: string}>\n actions?: Array<{id?: unknown; description?: unknown; parameters?: unknown; outputSchema?: unknown}>\n } | null\n const declaredPermissions = (manifest?.permissions ?? [])\n .map((p) => p.type)\n .filter((t): t is string => typeof t === \"string\")\n const installedManifest: InstalledMiniappManifest | undefined = manifest\n ? {\n packageName: manifest.packageName ?? packageName,\n name: manifest.name,\n version: manifest.version ?? version,\n sdkVersion: manifest.sdkVersion,\n minHostVersion: manifest.minHostVersion,\n type: manifest.type,\n entry: manifest.entry,\n permissions: manifest.permissions,\n hardwareRequirements: manifest.hardwareRequirements,\n actions: manifest.actions,\n }\n : undefined\n\n let bgSource: string\n try {\n bgSource = new File(entryPaths.background).textSync()\n } catch {\n return null\n }\n\n return {\n bgSource,\n uiUri: entryPaths.ui ?? null,\n uiBaseDir: entryPaths.ui ? entryPaths.ui.replace(/\\/[^/]+$/, \"/\") : null,\n declaredPermissions,\n installedManifest,\n // Snapshot fallback is file:// — do not wire the sidecar; the laptop is gone.\n devUrl: null,\n devPort: null,\n }\n }\n\n /**\n * Ensure a miniapp's background JS context is spawned. Idempotent — if the\n * context is already alive this is a no-op spawn-wise (it still resolves the\n * UI entry so a re-mounting host gets its `<WebView>` source back).\n *\n * Resolves once the context is SPAWNED. It does NOT block on the context's\n * CONNECT handshake — the host's WebView mount shouldn't wait on background\n * JS. Callers that need the context to be connected and ready to receive\n * messages (the action broker) follow up with\n * {@link LocalMiniappRuntime.waitForConnect}.\n */\n async ensureRunning(packageName: string, hints?: LaunchHints): Promise<LaunchResult> {\n if (!isLocalMiniappPackageAllowed(packageName)) {\n throw new Error(`MiniappLauncher: ${packageName} is disabled by deployment policy`)\n }\n const router = this.requireRouter()\n\n // Already spawned: best-effort resolve for the UI entry, never throw —\n // a headless caller that doesn't need UI gets {null, null} fast even if\n // the dev server has since dropped.\n if (router.registeredPackages().includes(packageName)) {\n const existing = await this.resolveBundle(packageName, hints).catch(() => null)\n return {uiUri: existing?.uiUri ?? null, uiBaseDir: existing?.uiBaseDir ?? null}\n }\n\n // Coalesce concurrent launches of the same package onto one promise.\n const pending = this.inFlight.get(packageName)\n if (pending) return pending\n\n const launch = this.spawn(packageName, hints)\n this.inFlight.set(packageName, launch)\n try {\n return await launch\n } finally {\n this.inFlight.delete(packageName)\n }\n }\n\n /** Resolve the bundle and spawn the context. Serialized via {@link inFlight}. */\n private async spawn(packageName: string, hints?: LaunchHints): Promise<LaunchResult> {\n const router = this.requireRouter()\n const resolved = await this.resolveBundle(packageName, hints)\n if (!resolved) {\n throw new Error(`MiniappLauncher: cannot resolve bundle for ${packageName}`)\n }\n const version = resolved.installedManifest?.version\n if (\n !isInstalledMiniappAllowed(\n packageName,\n version,\n version ? appRegistry.getReleaseIdentity(packageName, version) : null,\n )\n ) {\n throw new Error(`MiniappLauncher: ${packageName} bundle is not authorized by deployment policy`)\n }\n\n // Re-check after the async resolve: a different path may have spawned it\n // while we were fetching/reading the bundle.\n if (!router.registeredPackages().includes(packageName)) {\n const ok = await router.spawnAndRegister(packageName, resolved.bgSource, {\n permissions: resolved.declaredPermissions,\n installedManifest: resolved.installedManifest,\n })\n if (!ok) {\n throw new Error(`MiniappLauncher: spawn failed for ${packageName}`)\n }\n\n // Dev: wire the hot-reload + log-forwarding sidecar. No-op in prod\n // (devServerBridge silently drops when no sidecar is up).\n if (resolved.devUrl && resolved.devPort != null) {\n devServerBridge.connect(packageName, resolved.devUrl, resolved.devPort)\n } else if (resolved.devUrl) {\n // Dev miniapp with no resolvable port — it still launches, but hot\n // reload + log forwarding won't connect. Surface it instead of failing\n // silently (the old inline path hard-failed with \"no dev port\").\n console.warn(`MiniappLauncher: ${packageName} has no dev port — hot reload + log forwarding disabled`)\n }\n }\n\n return {uiUri: resolved.uiUri, uiBaseDir: resolved.uiBaseDir}\n }\n\n /**\n * Re-spawn local miniapps that were running when the app was last killed.\n *\n * Cloud apps run on a remote server: the cloud persists which ones are\n * running and resurrects them when the phone reconnects, so a host-app\n * restart brings them back on its own. Local (phone-hosted) miniapps run in\n * the phone's own JS engine — a host-process kill tears down their JSContext\n * and there is no server to resurrect them, so without this they silently\n * stay stopped on the next launch even though the user left them running.\n *\n * Each local miniapp persists its running flag to disk on start/stop\n * (`saveLocalAppRunningState`, via the applet's `onStart`/`onStop`). We read\n * those flags back and re-spawn the background context headlessly (no\n * foreground, no navigation) — the spawn registers the package so the home\n * tray/switcher project it as running, exactly as a normal start would. The\n * WebView, if any, re-attaches lazily when the user opens the app.\n *\n * Idempotent and best-effort: skips already-spawned contexts, and clears the\n * persisted flag for any app whose bundle can no longer be resolved\n * (uninstalled, or dev server gone) so a dead entry doesn't retry every boot.\n * Not compatibility-gated: a previously-running background app shouldn't be\n * dropped just because glasses are momentarily disconnected at boot — it\n * resumes when they reconnect, same as mid-session.\n */\n async autostartLocalMiniapps(): Promise<void> {\n const apps = await appRegistry.getInstalledMiniapps()\n for (const app of apps) {\n // Only phone-hosted miniapps have a JSContext to re-spawn. Offline\n // built-ins (`local:false, offline:true`) restore their native running\n // state elsewhere and have no bundle to launch.\n if (!app.local) continue\n if (!getLocalAppRunningState(app.packageName)) continue\n if (this.isRunning(app.packageName)) continue\n try {\n await this.ensureRunning(app.packageName)\n } catch (e) {\n console.warn(`MiniappLauncher: autostart failed for ${app.packageName} — clearing stale running flag`, e)\n saveLocalAppRunningState(app.packageName, false)\n }\n }\n }\n\n /**\n * Ensure the context is running AND has completed its CONNECT handshake.\n * Used by the action broker, which must not deliver to a context that hasn't\n * come up yet. Throws on spawn failure or connect timeout.\n */\n async ensureConnected(packageName: string, connectTimeoutMs = 10_000, hints?: LaunchHints): Promise<void> {\n await this.ensureRunning(packageName, hints)\n await localMiniappRuntime.waitForConnect(packageName, connectTimeoutMs)\n }\n\n /** Tear down a miniapp's background JS context. */\n async stop(packageName: string): Promise<void> {\n // If a launch is in flight, let it finish first. Otherwise unregister()\n // no-ops on the not-yet-registered package and the pending spawn then\n // re-registers the context — leaving it running despite the stop.\n const pending = this.inFlight.get(packageName)\n if (pending) {\n try {\n await pending\n } catch {\n // Launch failed — nothing got registered, so nothing to tear down.\n }\n }\n await this.deps?.router.unregister(packageName)\n }\n\n // --- internals -----------------------------------------------------------\n\n private storedDevUrl(packageName: string): string | undefined {\n const r = storage.load<string>(`${packageName}_dev_url`)\n return r.is_ok() ? r.value : undefined\n }\n\n /** resolveDevPort — moved verbatim from the old LocalMiniappView helper. */\n private resolveDevPort(searchParam: string | undefined, packageName: string): number | null {\n if (searchParam) {\n const n = parseInt(searchParam, 10)\n if (Number.isFinite(n)) return n\n }\n const stored = storage.load<number>(`${packageName}_dev_port`)\n if (stored.is_ok()) return stored.value\n return null\n }\n}\n\nexport const miniappLauncher = new MiniappLauncher()\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationHandlers.d.ts","sourceRoot":"","sources":["../../src/services/NavigationHandlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,EAAC,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"NavigationHandlers.d.ts","sourceRoot":"","sources":["../../src/services/NavigationHandlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,EAAC,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAA;AAKxF;;;GAGG;AACH,KAAK,aAAa,GAAG,CACnB,W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"./CloudClientService";
|
|
25
25
|
import navigationService from "./NavigationService";
|
|
26
26
|
import { MiniappErrorCode, MiniappResponseType, MiniappStreamType } from "@mentra/miniapp";
|
|
27
|
+
import { isFeatureEnabled } from "../runtime/bootstrap";
|
|
27
28
|
const LOG_TAG = "LocalMiniappRuntime";
|
|
28
29
|
export class NavigationHandlers {
|
|
29
30
|
sendToMiniapp;
|
|
@@ -54,6 +55,13 @@ export class NavigationHandlers {
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
async handleStart(packageName, payload, requestId) {
|
|
58
|
+
if (!isFeatureEnabled("navigation")) {
|
|
59
|
+
this.sendResult(packageName, requestId, false, undefined, {
|
|
60
|
+
code: MiniappErrorCode.NOT_IMPLEMENTED,
|
|
61
|
+
message: "Navigation is disabled by this deployment",
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
57
65
|
console.log(`${LOG_TAG}: handleNavigationStart from ${packageName}`, JSON.stringify(payload));
|
|
58
66
|
// v2 wire shape sends `stops`; v1 shape sends bare lat/lng. Accept both.
|
|
59
67
|
const rawStops = payload.stops;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationHandlers.js","sourceRoot":"","sources":["../../src/services/NavigationHandlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAA;AACvD,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAC,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAA;AAExF,MAAM,OAAO,GAAG,qBAAqB,CAAA;AAuBrC,MAAM,OAAO,kBAAkB;IAOV;IACA;IAPnB,uEAAuE;IAC/D,YAAY,GAAG,IAAI,GAAG,EAAsB,CAAA;IACpD,kFAAkF;IAC1E,aAAa,GAAG,IAAI,GAAG,EAAU,CAAA;IAEzC,YACmB,aAA4B,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,SAAS,EAAE;gBACxD,IAAI,EAAE,gBAAgB,CAAC,QAAQ;gBAC/B,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B;aAC9E,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,yFAAyF;IACjF,SAAS,CAAC,GAAY;QAC5B,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAA;QACrD,MAAM,GAAG,GAAG,GAA8B,CAAA;QAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,SAAS,CAAA;QACpE,OAAO,EAAC,GAAG,EAAE,GAAG,EAAC,CAAA;IACnB,CAAC;CACF","sourcesContent":["/**\n * NavigationHandlers — turn-by-turn navigation request handlers for\n * LocalMiniappRuntime. Extracted from LocalMiniappRuntime so the\n * navigation surface (Google Maps Navigation SDK adapter, multi-stop\n * routes, deviation simulator, dev toggles, road-snapped GPS streaming)\n * lives in one file the reviewer can read in isolation.\n *\n * Wire-up: LocalMiniappRuntime owns one instance, constructed with\n * callbacks for sending results / events back to the miniapp. The\n * dispatcher's switch statement delegates each `NAVIGATION_*` case to a\n * handler here. Cross-cutting hooks (cleanup on disconnect, location-\n * stream gating during a trip) are exposed via {@link onDisconnect} and\n * {@link isTripActive}.\n *\n * State owned here:\n * - navListeners: per-package unsubscribers for the nav-update +\n * road-snapped-location + route streams. Detached on disconnect,\n * reattached on the next NAVIGATION_START from the same package.\n * - activeNavApps: packages with a live nav session. Used by the\n * dispatcher to gate raw background-GPS forwards (we don't want the\n * unsnapped fix interleaving with the simulator's snapped output\n * during a trip).\n */\n\nimport {type NavLocation, type NavRoute, type NavUpdate} from \"../runtime/config\"\nimport {cloudClientService} from \"./CloudClientService\"\nimport navigationService from \"./NavigationService\"\nimport {MiniappErrorCode, MiniappResponseType, MiniappStreamType} from \"@mentra/miniapp\"\n\nconst LOG_TAG = \"LocalMiniappRuntime\"\n\n/**\n * Shape of the per-miniapp envelope sender — matches\n * LocalMiniappRuntime.sendToMiniapp's signature.\n */\ntype SendToMiniapp = (\n packageName: string,\n envelope: {type: MiniappResponseType; streamType?: MiniappStreamType; data?: unknown},\n) => void\n\n/**\n * Shape of the request-result sender — matches\n * LocalMiniappRuntime.sendResult's signature.\n */\ntype SendResult = (\n packageName: string,\n requestId: string | undefined,\n ok: boolean,\n result?: unknown,\n error?: {code: MiniappErrorCode; message: string},\n) => void\n\nexport class NavigationHandlers {\n /** packageName → unsubscribe fn for that app's nav event forwarder. */\n private navListeners = new Map<string, () => void>()\n /** Set of packageNames that have called navigation.start() and not yet stop(). */\n private activeNavApps = new Set<string>()\n\n constructor(\n private readonly sendToMiniapp: SendToMiniapp,\n private readonly sendResult: SendResult,\n ) {}\n\n /** True iff a trip is currently active for the package (used to gate raw-GPS forwards). */\n isTripActive(packageName: string): boolean {\n return this.activeNavApps.has(packageName)\n }\n\n /**\n * Detach the per-app nav event forwarder. Called when the mini-app\n * disconnects. The native nav session is left running so the user can\n * reopen the app and reattach without losing their trip; `activeNavApps`\n * is kept intact for the same reason.\n */\n onDisconnect(packageName: string): void {\n const unsub = this.navListeners.get(packageName)\n if (unsub) {\n unsub()\n this.navListeners.delete(packageName)\n }\n }\n\n async handleStart(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n console.log(`${LOG_TAG}: handleNavigationStart from ${packageName}`, JSON.stringify(payload))\n\n // v2 wire shape sends `stops`; v1 shape sends bare lat/lng. Accept both.\n const rawStops = payload.stops as Array<{lat?: unknown; lng?: unknown}> | undefined\n const stops: Array<{lat: number; lng: number}> = []\n if (Array.isArray(rawStops)) {\n for (const s of rawStops) {\n const sLat = Number(s?.lat)\n const sLng = Number(s?.lng)\n if (Number.isFinite(sLat) && Number.isFinite(sLng)) stops.push({lat: sLat, lng: sLng})\n }\n }\n if (stops.length === 0) {\n const lat = Number(payload.lat)\n const lng = Number(payload.lng)\n if (Number.isFinite(lat) && Number.isFinite(lng)) stops.push({lat, lng})\n }\n if (stops.length === 0) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: \"stops or lat/lng required\",\n })\n return\n }\n const lat = stops[0].lat\n const lng = stops[0].lng\n const simulate = payload.simulate === true\n const speedNum = Number(payload.speedMultiplier)\n const speedMultiplier = Number.isFinite(speedNum) && speedNum > 0 ? speedNum : 5\n const mode = typeof payload.mode === \"string\" ? payload.mode : \"driving\"\n const avoidRaw = payload.avoid as Record<string, unknown> | undefined\n const avoid = avoidRaw\n ? {\n highways: avoidRaw.highways === true,\n tolls: avoidRaw.tolls === true,\n ferries: avoidRaw.ferries === true,\n }\n : undefined\n const missedRaw = Number(payload.missedTurnRerouteMeters)\n const missedTurnRerouteMeters = Number.isFinite(missedRaw) && missedRaw > 0 ? missedRaw : undefined\n\n const navigation = navigationService\n if (!navigation) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: \"navigation adapter not configured on host\",\n })\n return\n }\n\n // Reattach the per-app event forwarder (it may have been detached when the\n // mini-app closed its UI without stopping the trip).\n if (!this.navListeners.has(packageName)) {\n const unsubNav = navigation.addListener((update: NavUpdate) => {\n this.sendToMiniapp(packageName, {\n type: MiniappResponseType.EVENT,\n streamType: MiniappStreamType.NAVIGATION_UPDATE,\n data: update,\n })\n // Trip ended naturally — keep the forwarder alive (miniapp may\n // restart nav) but remove from active set so stop() accounting\n // stays accurate.\n if (update.kind === \"arrived\" || update.kind === \"error\") {\n this.activeNavApps.delete(packageName)\n }\n })\n // Forward the nav-SDK's road-snapped GPS fixes as a location_update\n // stream, so the miniapp's existing session.events.onLocation(...) just\n // works while a trip is active.\n const unsubLoc = navigation.addLocationListener((loc: NavLocation) => {\n this.sendToMiniapp(packageName, {\n type: MiniappResponseType.EVENT,\n streamType: MiniappStreamType.LOCATION_UPDATE,\n data: {\n lat: loc.lat,\n lng: loc.lng,\n accuracy: loc.accuracy ?? undefined,\n timestamp: loc.timestamp,\n },\n })\n })\n const unsubRoute = navigation.addRouteListener((route: NavRoute) => {\n this.sendToMiniapp(packageName, {\n type: MiniappResponseType.EVENT,\n streamType: MiniappStreamType.NAVIGATION_ROUTE,\n data: route,\n })\n })\n this.navListeners.set(packageName, () => {\n unsubNav()\n unsubLoc()\n unsubRoute()\n })\n }\n\n // If a trip is already active for this app (user closed the UI and came\n // back), reuse the running session — replay current snapshot and return\n // ok without restarting the native navigator.\n if (this.activeNavApps.has(packageName) && navigation.getState() !== \"idle\") {\n console.log(`${LOG_TAG}: resuming existing nav session for ${packageName}`)\n const snapshot = navigation.getSnapshot()\n this.sendResult(packageName, requestId, true, {ok: true, resumed: true, snapshot})\n return\n }\n\n try {\n const result = await navigation.start(\n {lat, lng},\n {simulate, speedMultiplier, stops, mode, avoid, missedTurnRerouteMeters},\n )\n if (result.ok) {\n this.activeNavApps.add(packageName)\n }\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation start error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation start error\",\n })\n }\n }\n\n async handleStop(packageName: string, requestId?: string): Promise<void> {\n try {\n const unsub = this.navListeners.get(packageName)\n if (unsub) {\n unsub()\n this.navListeners.delete(packageName)\n }\n this.activeNavApps.delete(packageName)\n // Only stop the native trip when no other miniapp is still navigating.\n if (this.activeNavApps.size === 0) {\n const navigation = navigationService\n const result = navigation ? await navigation.stop() : {ok: true}\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } else {\n this.sendResult(packageName, requestId, true, {ok: true}, undefined)\n }\n } catch (err) {\n console.error(`${LOG_TAG}: navigation stop error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation stop error\",\n })\n }\n }\n\n async handleDeviate(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n try {\n const offsetNum = Number(payload.offsetMeters)\n const offsetMeters = Number.isFinite(offsetNum) && offsetNum > 0 ? offsetNum : 20\n const navigation = navigationService\n const result = navigation\n ? await navigation.simulateDeviation(offsetMeters)\n : {ok: false, error: \"navigation adapter not configured\"}\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation deviate error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation deviate error\",\n })\n }\n }\n\n async handleSetWrongSidewalk(\n packageName: string,\n payload: Record<string, unknown>,\n requestId?: string,\n ): Promise<void> {\n try {\n const enabled = payload.enabled === true\n const navigation = navigationService\n const result = navigation\n ? await navigation.setWrongSidewalkOffset(enabled)\n : {ok: false, error: \"navigation adapter not configured\"}\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation setWrongSidewalkOffset error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation setWrongSidewalkOffset error\",\n })\n }\n }\n\n async handleSetSkipCrossings(\n packageName: string,\n payload: Record<string, unknown>,\n requestId?: string,\n ): Promise<void> {\n try {\n const enabled = payload.enabled === true\n const navigation = navigationService\n const result = navigation\n ? await navigation.setSkipCrossings(enabled)\n : {ok: false, error: \"navigation adapter not configured\"}\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation setSkipCrossings error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation setSkipCrossings error\",\n })\n }\n }\n\n handleGetState(packageName: string, requestId?: string): void {\n const snapshot = navigationService.getSnapshot() ?? null\n this.sendResult(packageName, requestId, true, {state: snapshot})\n }\n\n async handleRequestPermission(packageName: string, requestId?: string): Promise<void> {\n try {\n const navigation = navigationService\n const result = navigation\n ? await navigation.requestPermission()\n : {ok: false, accepted: false, error: \"navigation adapter not configured\"}\n this.sendResult(packageName, requestId, true, result)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation requestPermission error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation requestPermission error\",\n })\n }\n }\n\n async handleComputeRoute(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n try {\n // Computed in the v2 cloud (provider-abstracted maps service). The SDK\n // payload shape ({origin, stops, mode, avoid, alternatives}) is the v2\n // DirectionsRequest field-for-field, so it passes straight through. The\n // direct-Mapbox path in NavigationService is deprecated.\n const {routes} = await cloudClientService.maps.directions(payload as never)\n this.sendResult(packageName, requestId, true, {ok: true, routes})\n } catch (err) {\n console.error(`${LOG_TAG}: navigation computeRoute error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation computeRoute error\",\n })\n }\n }\n\n /**\n * Reverse-geocode a coordinate into a short road name + full formatted\n * address. Backs the SDK pivot engine's road-name fallback (`road`) and the\n * navigation miniapp's dropped-pin / POI-tap labels (`address`). Always\n * resolves with `{ok, road?, address?}` — a missing road/address is\n * `{ok: true, road: null, address: null}`, not an error.\n */\n async handleReverseGeocode(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n try {\n const lat = Number(payload.lat)\n const lng = Number(payload.lng)\n if (!Number.isFinite(lat) || !Number.isFinite(lng)) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: \"lat/lng required\",\n })\n return\n }\n // Resolved in the v2 cloud (provider-abstracted maps service). The\n // direct-Mapbox geocoding path in NavigationService is deprecated.\n const {road, address} = await cloudClientService.maps.reverseGeocode({lat, lng})\n this.sendResult(packageName, requestId, true, {ok: true, road, address})\n } catch (err) {\n console.error(`${LOG_TAG}: navigation reverseGeocode error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation reverseGeocode error\",\n })\n }\n }\n\n /**\n * Type-ahead place search. Proxies to the v2 cloud maps service (Mapbox\n * Search Box today). Resolves `{ok: true, suggestions}` — an empty query or no\n * matches is `{ok: true, suggestions: []}`, not an error.\n */\n async handlePlaceAutocomplete(\n packageName: string,\n payload: Record<string, unknown>,\n requestId?: string,\n ): Promise<void> {\n try {\n const query = typeof payload.query === \"string\" ? payload.query : \"\"\n const sessionToken = typeof payload.sessionToken === \"string\" ? payload.sessionToken : \"\"\n const near = this.parseNear(payload.near)\n\n const {suggestions} = await cloudClientService.maps.placeAutocomplete({query, near, sessionToken})\n this.sendResult(packageName, requestId, true, {ok: true, suggestions})\n } catch (err) {\n console.error(`${LOG_TAG}: navigation placeAutocomplete error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation placeAutocomplete error\",\n })\n }\n }\n\n /**\n * Resolve a suggestion (`placeId` + `sessionToken`) to a full place with\n * coordinates, via the v2 cloud maps service. Resolves `{ok: true, place}`.\n */\n async handlePlaceDetails(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n try {\n const placeId = typeof payload.placeId === \"string\" ? payload.placeId : \"\"\n const sessionToken = typeof payload.sessionToken === \"string\" ? payload.sessionToken : \"\"\n if (!placeId) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: \"placeId required\",\n })\n return\n }\n\n const place = await cloudClientService.maps.placeDetails({placeId, sessionToken})\n this.sendResult(packageName, requestId, true, {ok: true, place})\n } catch (err) {\n console.error(`${LOG_TAG}: navigation placeDetails error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation placeDetails error\",\n })\n }\n }\n\n /** Coerce an inbound `near` payload to a {lat,lng}, or undefined when absent/invalid. */\n private parseNear(raw: unknown): {lat: number; lng: number} | undefined {\n if (!raw || typeof raw !== \"object\") return undefined\n const obj = raw as Record<string, unknown>\n const lat = Number(obj.lat)\n const lng = Number(obj.lng)\n if (!Number.isFinite(lat) || !Number.isFinite(lng)) return undefined\n return {lat, lng}\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NavigationHandlers.js","sourceRoot":"","sources":["../../src/services/NavigationHandlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAA;AACvD,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAC,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAA;AAErD,MAAM,OAAO,GAAG,qBAAqB,CAAA;AAuBrC,MAAM,OAAO,kBAAkB;IAOV;IACA;IAPnB,uEAAuE;IAC/D,YAAY,GAAG,IAAI,GAAG,EAAsB,CAAA;IACpD,kFAAkF;IAC1E,aAAa,GAAG,IAAI,GAAG,EAAU,CAAA;IAEzC,YACmB,aAA4B,EAC5B,UAAsB;QADtB,kBAAa,GAAb,aAAa,CAAe;QAC5B,eAAU,GAAV,UAAU,CAAY;IACtC,CAAC;IAEJ,2FAA2F;IAC3F,YAAY,CAAC,WAAmB;QAC9B,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAC5C,C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AAW,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;gBACxD,IAAI,EAAE,gBAAgB,CAAC,QAAQ;gBAC/B,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B;aAC9E,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,yFAAyF;IACjF,SAAS,CAAC,GAAY;QAC5B,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAA;QACrD,MAAM,GAAG,GAAG,GAA8B,CAAA;QAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,SAAS,CAAA;QACpE,OAAO,EAAC,GAAG,EAAE,GAAG,EAAC,CAAA;IACnB,CAAC;CACF","sourcesContent":["/**\n * NavigationHandlers — turn-by-turn navigation request handlers for\n * LocalMiniappRuntime. Extracted from LocalMiniappRuntime so the\n * navigation surface (Google Maps Navigation SDK adapter, multi-stop\n * routes, deviation simulator, dev toggles, road-snapped GPS streaming)\n * lives in one file the reviewer can read in isolation.\n *\n * Wire-up: LocalMiniappRuntime owns one instance, constructed with\n * callbacks for sending results / events back to the miniapp. The\n * dispatcher's switch statement delegates each `NAVIGATION_*` case to a\n * handler here. Cross-cutting hooks (cleanup on disconnect, location-\n * stream gating during a trip) are exposed via {@link onDisconnect} and\n * {@link isTripActive}.\n *\n * State owned here:\n * - navListeners: per-package unsubscribers for the nav-update +\n * road-snapped-location + route streams. Detached on disconnect,\n * reattached on the next NAVIGATION_START from the same package.\n * - activeNavApps: packages with a live nav session. Used by the\n * dispatcher to gate raw background-GPS forwards (we don't want the\n * unsnapped fix interleaving with the simulator's snapped output\n * during a trip).\n */\n\nimport {type NavLocation, type NavRoute, type NavUpdate} from \"../runtime/config\"\nimport {cloudClientService} from \"./CloudClientService\"\nimport navigationService from \"./NavigationService\"\nimport {MiniappErrorCode, MiniappResponseType, MiniappStreamType} from \"@mentra/miniapp\"\nimport {isFeatureEnabled} from \"../runtime/bootstrap\"\n\nconst LOG_TAG = \"LocalMiniappRuntime\"\n\n/**\n * Shape of the per-miniapp envelope sender — matches\n * LocalMiniappRuntime.sendToMiniapp's signature.\n */\ntype SendToMiniapp = (\n packageName: string,\n envelope: {type: MiniappResponseType; streamType?: MiniappStreamType; data?: unknown},\n) => void\n\n/**\n * Shape of the request-result sender — matches\n * LocalMiniappRuntime.sendResult's signature.\n */\ntype SendResult = (\n packageName: string,\n requestId: string | undefined,\n ok: boolean,\n result?: unknown,\n error?: {code: MiniappErrorCode; message: string},\n) => void\n\nexport class NavigationHandlers {\n /** packageName → unsubscribe fn for that app's nav event forwarder. */\n private navListeners = new Map<string, () => void>()\n /** Set of packageNames that have called navigation.start() and not yet stop(). */\n private activeNavApps = new Set<string>()\n\n constructor(\n private readonly sendToMiniapp: SendToMiniapp,\n private readonly sendResult: SendResult,\n ) {}\n\n /** True iff a trip is currently active for the package (used to gate raw-GPS forwards). */\n isTripActive(packageName: string): boolean {\n return this.activeNavApps.has(packageName)\n }\n\n /**\n * Detach the per-app nav event forwarder. Called when the mini-app\n * disconnects. The native nav session is left running so the user can\n * reopen the app and reattach without losing their trip; `activeNavApps`\n * is kept intact for the same reason.\n */\n onDisconnect(packageName: string): void {\n const unsub = this.navListeners.get(packageName)\n if (unsub) {\n unsub()\n this.navListeners.delete(packageName)\n }\n }\n\n async handleStart(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n if (!isFeatureEnabled(\"navigation\")) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.NOT_IMPLEMENTED,\n message: \"Navigation is disabled by this deployment\",\n })\n return\n }\n console.log(`${LOG_TAG}: handleNavigationStart from ${packageName}`, JSON.stringify(payload))\n\n // v2 wire shape sends `stops`; v1 shape sends bare lat/lng. Accept both.\n const rawStops = payload.stops as Array<{lat?: unknown; lng?: unknown}> | undefined\n const stops: Array<{lat: number; lng: number}> = []\n if (Array.isArray(rawStops)) {\n for (const s of rawStops) {\n const sLat = Number(s?.lat)\n const sLng = Number(s?.lng)\n if (Number.isFinite(sLat) && Number.isFinite(sLng)) stops.push({lat: sLat, lng: sLng})\n }\n }\n if (stops.length === 0) {\n const lat = Number(payload.lat)\n const lng = Number(payload.lng)\n if (Number.isFinite(lat) && Number.isFinite(lng)) stops.push({lat, lng})\n }\n if (stops.length === 0) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: \"stops or lat/lng required\",\n })\n return\n }\n const lat = stops[0].lat\n const lng = stops[0].lng\n const simulate = payload.simulate === true\n const speedNum = Number(payload.speedMultiplier)\n const speedMultiplier = Number.isFinite(speedNum) && speedNum > 0 ? speedNum : 5\n const mode = typeof payload.mode === \"string\" ? payload.mode : \"driving\"\n const avoidRaw = payload.avoid as Record<string, unknown> | undefined\n const avoid = avoidRaw\n ? {\n highways: avoidRaw.highways === true,\n tolls: avoidRaw.tolls === true,\n ferries: avoidRaw.ferries === true,\n }\n : undefined\n const missedRaw = Number(payload.missedTurnRerouteMeters)\n const missedTurnRerouteMeters = Number.isFinite(missedRaw) && missedRaw > 0 ? missedRaw : undefined\n\n const navigation = navigationService\n if (!navigation) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: \"navigation adapter not configured on host\",\n })\n return\n }\n\n // Reattach the per-app event forwarder (it may have been detached when the\n // mini-app closed its UI without stopping the trip).\n if (!this.navListeners.has(packageName)) {\n const unsubNav = navigation.addListener((update: NavUpdate) => {\n this.sendToMiniapp(packageName, {\n type: MiniappResponseType.EVENT,\n streamType: MiniappStreamType.NAVIGATION_UPDATE,\n data: update,\n })\n // Trip ended naturally — keep the forwarder alive (miniapp may\n // restart nav) but remove from active set so stop() accounting\n // stays accurate.\n if (update.kind === \"arrived\" || update.kind === \"error\") {\n this.activeNavApps.delete(packageName)\n }\n })\n // Forward the nav-SDK's road-snapped GPS fixes as a location_update\n // stream, so the miniapp's existing session.events.onLocation(...) just\n // works while a trip is active.\n const unsubLoc = navigation.addLocationListener((loc: NavLocation) => {\n this.sendToMiniapp(packageName, {\n type: MiniappResponseType.EVENT,\n streamType: MiniappStreamType.LOCATION_UPDATE,\n data: {\n lat: loc.lat,\n lng: loc.lng,\n accuracy: loc.accuracy ?? undefined,\n timestamp: loc.timestamp,\n },\n })\n })\n const unsubRoute = navigation.addRouteListener((route: NavRoute) => {\n this.sendToMiniapp(packageName, {\n type: MiniappResponseType.EVENT,\n streamType: MiniappStreamType.NAVIGATION_ROUTE,\n data: route,\n })\n })\n this.navListeners.set(packageName, () => {\n unsubNav()\n unsubLoc()\n unsubRoute()\n })\n }\n\n // If a trip is already active for this app (user closed the UI and came\n // back), reuse the running session — replay current snapshot and return\n // ok without restarting the native navigator.\n if (this.activeNavApps.has(packageName) && navigation.getState() !== \"idle\") {\n console.log(`${LOG_TAG}: resuming existing nav session for ${packageName}`)\n const snapshot = navigation.getSnapshot()\n this.sendResult(packageName, requestId, true, {ok: true, resumed: true, snapshot})\n return\n }\n\n try {\n const result = await navigation.start(\n {lat, lng},\n {simulate, speedMultiplier, stops, mode, avoid, missedTurnRerouteMeters},\n )\n if (result.ok) {\n this.activeNavApps.add(packageName)\n }\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation start error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation start error\",\n })\n }\n }\n\n async handleStop(packageName: string, requestId?: string): Promise<void> {\n try {\n const unsub = this.navListeners.get(packageName)\n if (unsub) {\n unsub()\n this.navListeners.delete(packageName)\n }\n this.activeNavApps.delete(packageName)\n // Only stop the native trip when no other miniapp is still navigating.\n if (this.activeNavApps.size === 0) {\n const navigation = navigationService\n const result = navigation ? await navigation.stop() : {ok: true}\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } else {\n this.sendResult(packageName, requestId, true, {ok: true}, undefined)\n }\n } catch (err) {\n console.error(`${LOG_TAG}: navigation stop error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation stop error\",\n })\n }\n }\n\n async handleDeviate(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n try {\n const offsetNum = Number(payload.offsetMeters)\n const offsetMeters = Number.isFinite(offsetNum) && offsetNum > 0 ? offsetNum : 20\n const navigation = navigationService\n const result = navigation\n ? await navigation.simulateDeviation(offsetMeters)\n : {ok: false, error: \"navigation adapter not configured\"}\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation deviate error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation deviate error\",\n })\n }\n }\n\n async handleSetWrongSidewalk(\n packageName: string,\n payload: Record<string, unknown>,\n requestId?: string,\n ): Promise<void> {\n try {\n const enabled = payload.enabled === true\n const navigation = navigationService\n const result = navigation\n ? await navigation.setWrongSidewalkOffset(enabled)\n : {ok: false, error: \"navigation adapter not configured\"}\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation setWrongSidewalkOffset error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation setWrongSidewalkOffset error\",\n })\n }\n }\n\n async handleSetSkipCrossings(\n packageName: string,\n payload: Record<string, unknown>,\n requestId?: string,\n ): Promise<void> {\n try {\n const enabled = payload.enabled === true\n const navigation = navigationService\n const result = navigation\n ? await navigation.setSkipCrossings(enabled)\n : {ok: false, error: \"navigation adapter not configured\"}\n this.sendResult(packageName, requestId, result.ok, result, undefined)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation setSkipCrossings error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation setSkipCrossings error\",\n })\n }\n }\n\n handleGetState(packageName: string, requestId?: string): void {\n const snapshot = navigationService.getSnapshot() ?? null\n this.sendResult(packageName, requestId, true, {state: snapshot})\n }\n\n async handleRequestPermission(packageName: string, requestId?: string): Promise<void> {\n try {\n const navigation = navigationService\n const result = navigation\n ? await navigation.requestPermission()\n : {ok: false, accepted: false, error: \"navigation adapter not configured\"}\n this.sendResult(packageName, requestId, true, result)\n } catch (err) {\n console.error(`${LOG_TAG}: navigation requestPermission error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation requestPermission error\",\n })\n }\n }\n\n async handleComputeRoute(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n try {\n // Computed in the v2 cloud (provider-abstracted maps service). The SDK\n // payload shape ({origin, stops, mode, avoid, alternatives}) is the v2\n // DirectionsRequest field-for-field, so it passes straight through. The\n // direct-Mapbox path in NavigationService is deprecated.\n const {routes} = await cloudClientService.maps.directions(payload as never)\n this.sendResult(packageName, requestId, true, {ok: true, routes})\n } catch (err) {\n console.error(`${LOG_TAG}: navigation computeRoute error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation computeRoute error\",\n })\n }\n }\n\n /**\n * Reverse-geocode a coordinate into a short road name + full formatted\n * address. Backs the SDK pivot engine's road-name fallback (`road`) and the\n * navigation miniapp's dropped-pin / POI-tap labels (`address`). Always\n * resolves with `{ok, road?, address?}` — a missing road/address is\n * `{ok: true, road: null, address: null}`, not an error.\n */\n async handleReverseGeocode(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n try {\n const lat = Number(payload.lat)\n const lng = Number(payload.lng)\n if (!Number.isFinite(lat) || !Number.isFinite(lng)) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: \"lat/lng required\",\n })\n return\n }\n // Resolved in the v2 cloud (provider-abstracted maps service). The\n // direct-Mapbox geocoding path in NavigationService is deprecated.\n const {road, address} = await cloudClientService.maps.reverseGeocode({lat, lng})\n this.sendResult(packageName, requestId, true, {ok: true, road, address})\n } catch (err) {\n console.error(`${LOG_TAG}: navigation reverseGeocode error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation reverseGeocode error\",\n })\n }\n }\n\n /**\n * Type-ahead place search. Proxies to the v2 cloud maps service (Mapbox\n * Search Box today). Resolves `{ok: true, suggestions}` — an empty query or no\n * matches is `{ok: true, suggestions: []}`, not an error.\n */\n async handlePlaceAutocomplete(\n packageName: string,\n payload: Record<string, unknown>,\n requestId?: string,\n ): Promise<void> {\n try {\n const query = typeof payload.query === \"string\" ? payload.query : \"\"\n const sessionToken = typeof payload.sessionToken === \"string\" ? payload.sessionToken : \"\"\n const near = this.parseNear(payload.near)\n\n const {suggestions} = await cloudClientService.maps.placeAutocomplete({query, near, sessionToken})\n this.sendResult(packageName, requestId, true, {ok: true, suggestions})\n } catch (err) {\n console.error(`${LOG_TAG}: navigation placeAutocomplete error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation placeAutocomplete error\",\n })\n }\n }\n\n /**\n * Resolve a suggestion (`placeId` + `sessionToken`) to a full place with\n * coordinates, via the v2 cloud maps service. Resolves `{ok: true, place}`.\n */\n async handlePlaceDetails(packageName: string, payload: Record<string, unknown>, requestId?: string): Promise<void> {\n try {\n const placeId = typeof payload.placeId === \"string\" ? payload.placeId : \"\"\n const sessionToken = typeof payload.sessionToken === \"string\" ? payload.sessionToken : \"\"\n if (!placeId) {\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: \"placeId required\",\n })\n return\n }\n\n const place = await cloudClientService.maps.placeDetails({placeId, sessionToken})\n this.sendResult(packageName, requestId, true, {ok: true, place})\n } catch (err) {\n console.error(`${LOG_TAG}: navigation placeDetails error:`, err)\n this.sendResult(packageName, requestId, false, undefined, {\n code: MiniappErrorCode.INTERNAL,\n message: err instanceof Error ? err.message : \"navigation placeDetails error\",\n })\n }\n }\n\n /** Coerce an inbound `near` payload to a {lat,lng}, or undefined when absent/invalid. */\n private parseNear(raw: unknown): {lat: number; lng: number} | undefined {\n if (!raw || typeof raw !== \"object\") return undefined\n const obj = raw as Record<string, unknown>\n const lat = Number(obj.lat)\n const lng = Number(obj.lng)\n if (!Number.isFinite(lat) || !Number.isFinite(lng)) return undefined\n return {lat, lng}\n }\n}\n"]}
|
|
@@ -66,13 +66,22 @@ export interface OtaCheckResult {
|
|
|
66
66
|
*/
|
|
67
67
|
checkFailureReason?: "network" | "pin_unavailable";
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Package the stock glasses client installs as, and the key every apps-shaped manifest pins the
|
|
71
|
+
* ASG APK under. Android forces a distinct package (`.thirdparty` suffix) on any build not signed
|
|
72
|
+
* with Mentra's release key, so a client reporting anything else is a sideloaded build that
|
|
73
|
+
* coexists with the stock system app.
|
|
74
|
+
*/
|
|
75
|
+
export declare const STOCK_ASG_PACKAGE = "com.mentra.asg_client";
|
|
76
|
+
export type OtaCheckSkippedReason = "disconnected" | "missing_build" | "dev_build" | "unofficial_client";
|
|
70
77
|
export interface OtaCheckCurrentGlassesResult extends OtaCheckResult {
|
|
71
78
|
updateInfo: OtaUpdateInfo | null;
|
|
72
79
|
isRequired: boolean;
|
|
73
80
|
skippedReason?: OtaCheckSkippedReason;
|
|
74
81
|
manifestUrl?: string;
|
|
75
82
|
buildNumber?: string;
|
|
83
|
+
/** Glasses client package, when it reported one. Set on an `unofficial_client` skip. */
|
|
84
|
+
packageName?: string;
|
|
76
85
|
mtkFirmwareVersion?: string;
|
|
77
86
|
besFirmwareVersion?: string;
|
|
78
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaUpdateCheckService.d.ts","sourceRoot":"","sources":["../../src/services/OtaUpdateCheckService.ts"],"names":[],"mappings":"AAAA,OAAqB,EAAC,KAAK,aAAa,EAAC,MAAM,uBAAuB,CAAA;AAOtE;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAA;AAE7C,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE;QACL,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,CAAA;KACnC,CAAA;IACD,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAA;IACxB,YAAY,CAAC,EAAE,WAAW,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAA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W,GAAG,IAAI,CAqBxF;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,QAAQ,EAAE,GAAG,SAAS,EAC/B,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,QAAQ,GAAG,IAAI,CAgBjB;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,SAAS,EAAE,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAUhH;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiB1E;AAED,wBAAsB,iBAAiB,CACrC,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,CAAC,EAAE,MAAM,EAC1B,iBAAiB,CAAC,EAAE,MAAM,EAC1B,gBAAgB,GAAE,MAAqC,GACtD,OAAO,CAAC,cAAc,CAAC,CA4GzB;AAED,wBAAsB,4BAA4B,CAChD,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,4BAA4B,CAAC,CA6KvC"}
|
|
@@ -13,7 +13,14 @@ import { resolveOtaReleaseVersion } from "./otaReleaseVersion";
|
|
|
13
13
|
* in lockstep with the ASG/recovery constant at release time.
|
|
14
14
|
*/
|
|
15
15
|
export const DOWNGRADE_FLOOR_VERSION_CODE = 0;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Package the stock glasses client installs as, and the key every apps-shaped manifest pins the
|
|
18
|
+
* ASG APK under. Android forces a distinct package (`.thirdparty` suffix) on any build not signed
|
|
19
|
+
* with Mentra's release key, so a client reporting anything else is a sideloaded build that
|
|
20
|
+
* coexists with the stock system app.
|
|
21
|
+
*/
|
|
22
|
+
export const STOCK_ASG_PACKAGE = "com.mentra.asg_client";
|
|
23
|
+
function emptyCheckResult(skippedReason, extra) {
|
|
17
24
|
return {
|
|
18
25
|
hasCheckCompleted: false,
|
|
19
26
|
updateAvailable: false,
|
|
@@ -27,6 +34,7 @@ function emptyCheckResult(skippedReason) {
|
|
|
27
34
|
updateInfo: null,
|
|
28
35
|
isRequired: true,
|
|
29
36
|
skippedReason,
|
|
37
|
+
...extra,
|
|
30
38
|
};
|
|
31
39
|
}
|
|
32
40
|
function glassesConnectedNow() {
|
|
@@ -80,7 +88,7 @@ export function getApkUpdateDirection(currentBuildNumber, versionJson, floorVers
|
|
|
80
88
|
}
|
|
81
89
|
let serverVersion;
|
|
82
90
|
let exactPin = false;
|
|
83
|
-
const appEntry = versionJson.apps?.[
|
|
91
|
+
const appEntry = versionJson.apps?.[STOCK_ASG_PACKAGE];
|
|
84
92
|
if (appEntry) {
|
|
85
93
|
serverVersion = appEntry.versionCode;
|
|
86
94
|
exactPin = true;
|
|
@@ -106,8 +114,8 @@ export function getLatestVersionInfo(versionJson) {
|
|
|
106
114
|
if (!versionJson) {
|
|
107
115
|
return null;
|
|
108
116
|
}
|
|
109
|
-
if (versionJson.apps?.[
|
|
110
|
-
return versionJson.apps[
|
|
117
|
+
if (versionJson.apps?.[STOCK_ASG_PACKAGE]) {
|
|
118
|
+
return versionJson.apps[STOCK_ASG_PACKAGE];
|
|
111
119
|
}
|
|
112
120
|
if (versionJson.versionCode) {
|
|
113
121
|
return {
|
|
@@ -187,7 +195,7 @@ export async function checkForOtaUpdate(otaVersionUrl, currentBuildNumber, curre
|
|
|
187
195
|
// than silently completing as "up to date" — an unverifiable state must never
|
|
188
196
|
// present as a verified one.
|
|
189
197
|
const currentVersionNumber = parseInt(currentBuildNumber, 10);
|
|
190
|
-
const pinnedEntry = versionJson?.apps?.[
|
|
198
|
+
const pinnedEntry = versionJson?.apps?.[STOCK_ASG_PACKAGE];
|
|
191
199
|
const pinnedVersion = pinnedEntry?.versionCode ?? versionJson?.versionCode;
|
|
192
200
|
if (versionJson &&
|
|
193
201
|
Number.isFinite(currentVersionNumber) &&
|
|
@@ -288,6 +296,17 @@ export async function checkCurrentGlassesForUpdate(options = {}) {
|
|
|
288
296
|
// "up to date" result from a comparison that never really ran.
|
|
289
297
|
return emptyCheckResult("missing_build");
|
|
290
298
|
}
|
|
299
|
+
// A sideloaded ASG client installs under its own package (Android forces the `.thirdparty`
|
|
300
|
+
// suffix on any build not signed with Mentra's release key) and coexists with the stock system
|
|
301
|
+
// app. Its build number is therefore not comparable to the manifest's pin, and installing the
|
|
302
|
+
// manifest APK would replace the stock package while the sideloaded client keeps holding the
|
|
303
|
+
// link and reporting its own unchanged version — an update prompt that can never be satisfied.
|
|
304
|
+
// Absent means the glasses predate the field: assume stock, preserving existing behavior.
|
|
305
|
+
const packageName = useGlassesStore.getState().packageName;
|
|
306
|
+
if (packageName && packageName !== STOCK_ASG_PACKAGE) {
|
|
307
|
+
console.log(`OTA: check skipped - glasses run an unofficial client (${packageName})`);
|
|
308
|
+
return emptyCheckResult("unofficial_client", { buildNumber, packageName });
|
|
309
|
+
}
|
|
291
310
|
if (!glassesConnectedNow()) {
|
|
292
311
|
return emptyCheckResult("disconnected");
|
|
293
312
|
}
|