@glassly/engine 0.3.0-beta.489 → 0.3.0-dev.460
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 +0 -3
- package/build/engine.d.ts.map +1 -1
- package/build/facades/miniapps.d.ts +0 -6
- package/build/facades/miniapps.d.ts.map +1 -1
- package/build/facades/miniapps.js +0 -7
- package/build/facades/miniapps.js.map +1 -1
- package/build/generated/releaseMetadata.js +3 -3
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/services/AppRegistry.js +1 -1
- package/build/services/AppRegistry.js.map +1 -1
- package/build/services/BlobStore.js +2 -2
- package/build/services/BlobStore.js.map +1 -1
- package/build/services/LocalDisplayManager.d.ts +2 -1
- package/build/services/LocalDisplayManager.d.ts.map +1 -1
- package/build/services/LocalDisplayManager.js +2 -1
- package/build/services/LocalDisplayManager.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts +9 -22
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +52 -117
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/MiniappLauncher.d.ts +0 -2
- package/build/services/MiniappLauncher.d.ts.map +1 -1
- package/build/services/MiniappLauncher.js +1 -6
- package/build/services/MiniappLauncher.js.map +1 -1
- package/build/services/pages/OverlayPages.d.ts +2 -13
- package/build/services/pages/OverlayPages.d.ts.map +1 -1
- package/build/services/pages/OverlayPages.js +10 -11
- package/build/services/pages/OverlayPages.js.map +1 -1
- package/build/services/pages/PageHost.d.ts +1 -1
- package/build/services/pages/PageHost.d.ts.map +1 -1
- package/build/services/pages/PageHost.js +2 -2
- package/build/services/pages/PageHost.js.map +1 -1
- package/build/services/pages/overlayApps.d.ts +13 -20
- package/build/services/pages/overlayApps.d.ts.map +1 -1
- package/build/services/pages/overlayApps.js +31 -50
- package/build/services/pages/overlayApps.js.map +1 -1
- package/build/services/settingsBridge.d.ts +14 -15
- package/build/services/settingsBridge.d.ts.map +1 -1
- package/build/services/settingsBridge.js +20 -20
- package/build/services/settingsBridge.js.map +1 -1
- package/build/stores/appVisibility.d.ts +0 -5
- package/build/stores/appVisibility.d.ts.map +1 -1
- package/build/stores/appVisibility.js +0 -2
- package/build/stores/appVisibility.js.map +1 -1
- package/build/stores/apps.d.ts +0 -5
- package/build/stores/apps.d.ts.map +1 -1
- package/build/stores/apps.js +10 -40
- package/build/stores/apps.js.map +1 -1
- package/build/stores/settings.d.ts.map +1 -1
- package/build/stores/settings.js +45 -19
- package/build/stores/settings.js.map +1 -1
- package/build/types/applet.d.ts +2 -2
- package/build/types/applet.d.ts.map +1 -1
- package/build/types/applet.js.map +1 -1
- package/build/utils/display/scene/anchor.d.ts +2 -1
- package/build/utils/display/scene/anchor.d.ts.map +1 -1
- package/build/utils/display/scene/anchor.js +2 -1
- package/build/utils/display/scene/anchor.js.map +1 -1
- package/package.json +7 -7
- package/src/facades/miniapps.ts +0 -9
- package/src/generated/releaseMetadata.ts +3 -3
- package/src/index.ts +1 -3
- package/src/services/AppRegistry.ts +1 -1
- package/src/services/BlobStore.ts +2 -2
- package/src/services/LocalDisplayManager.ts +2 -1
- package/src/services/LocalMiniappRuntime.ts +52 -136
- package/src/services/MiniappLauncher.ts +1 -6
- package/src/services/pages/OverlayPages.ts +10 -11
- package/src/services/pages/PageHost.ts +2 -2
- package/src/services/pages/overlayApps.ts +30 -51
- package/src/services/settingsBridge.ts +20 -20
- package/src/stores/appVisibility.ts +0 -4
- package/src/stores/apps.ts +12 -44
- package/src/stores/settings.ts +45 -19
- package/src/types/applet.ts +1 -3
- package/src/utils/display/scene/anchor.ts +2 -1
- package/build/services/miniappPermissions.d.ts +0 -16
- package/build/services/miniappPermissions.d.ts.map +0 -1
- package/build/services/miniappPermissions.js +0 -7
- package/build/services/miniappPermissions.js.map +0 -1
- package/build/services/pages/activeDashboard.d.ts +0 -7
- package/build/services/pages/activeDashboard.d.ts.map +0 -1
- package/build/services/pages/activeDashboard.js +0 -21
- package/build/services/pages/activeDashboard.js.map +0 -1
- package/src/services/miniappPermissions.ts +0 -19
- package/src/services/pages/activeDashboard.ts +0 -24
|
@@ -114,8 +114,6 @@ declare class MiniappLauncher {
|
|
|
114
114
|
*
|
|
115
115
|
* Always On apps (the dashboard) start whether or not they were running
|
|
116
116
|
* when the app was last killed, and get a switcher card like any other app.
|
|
117
|
-
* A dashboard that does not hold the role (ADR-0009) is not started by its
|
|
118
|
-
* Always On flag.
|
|
119
117
|
* Both restore paths skip apps missing required OS permissions without
|
|
120
118
|
* prompting or clearing their saved running/Always On choice.
|
|
121
119
|
*/
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,mBAAmB,EAAC,MAAM,kBAAkB,CAAA;AACzD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAExC,UAAU,YAAY;IACpB,oEAAoE;IACpE,MAAM,EAAE,QAAQ,CAAA;CACjB;AAED,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+DAA+D;IAC/D,YAAY,CAAC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G,OAAO,CAAC,IAAI,CAAC;IAKzG,mDAAmD;IAC7C,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB9C,OAAO,CAAC,YAAY;IAKpB,4EAA4E;IAC5E,OAAO,CAAC,cAAc;CASvB;AAED,eAAO,MAAM,eAAe,iBAAwB,CAAA"}
|
|
@@ -29,7 +29,6 @@ import { storage } from "../utils/storage/storage";
|
|
|
29
29
|
import appRegistry, { getLocalAppRunningState, saveLocalAppRunningState } from "./AppRegistry";
|
|
30
30
|
import devServerBridge from "./DevServerBridge";
|
|
31
31
|
import localMiniappRuntime from "./LocalMiniappRuntime";
|
|
32
|
-
import { activeDashboardAmong } from "./pages/activeDashboard";
|
|
33
32
|
class MiniappLauncher {
|
|
34
33
|
deps = null;
|
|
35
34
|
/**
|
|
@@ -246,22 +245,18 @@ class MiniappLauncher {
|
|
|
246
245
|
*
|
|
247
246
|
* Always On apps (the dashboard) start whether or not they were running
|
|
248
247
|
* when the app was last killed, and get a switcher card like any other app.
|
|
249
|
-
* A dashboard that does not hold the role (ADR-0009) is not started by its
|
|
250
|
-
* Always On flag.
|
|
251
248
|
* Both restore paths skip apps missing required OS permissions without
|
|
252
249
|
* prompting or clearing their saved running/Always On choice.
|
|
253
250
|
*/
|
|
254
251
|
async autostartLocalMiniapps() {
|
|
255
252
|
const apps = await appRegistry.getInstalledMiniapps();
|
|
256
|
-
const activeDashboard = activeDashboardAmong(apps);
|
|
257
253
|
for (const app of apps) {
|
|
258
254
|
// Only phone-hosted miniapps have a JSContext to re-spawn. Offline
|
|
259
255
|
// built-ins (`local:false, offline:true`) restore their native running
|
|
260
256
|
// state elsewhere and have no bundle to launch.
|
|
261
257
|
if (!app.local)
|
|
262
258
|
continue;
|
|
263
|
-
|
|
264
|
-
if (!alwaysOn && !getLocalAppRunningState(app.packageName))
|
|
259
|
+
if (!app.alwaysOn && !getLocalAppRunningState(app.packageName))
|
|
265
260
|
continue;
|
|
266
261
|
if (this.isRunning(app.packageName))
|
|
267
262
|
continue;
|
|
@@ -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,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAA;AAC9D,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;AACxF,OAAO,EAAC,oBAAoB,EAAC,MAAM,yBAAyB,CAAA;AAoC5D,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,MA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,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 JSRouter} 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 {permissions} from \"../facades/permissions\"\nimport {decideDevLaunchRoute} from \"../utils/devMiniappLaunch\"\nimport {storage} from \"../utils/storage/storage\"\nimport appRegistry, {getLocalAppRunningState, saveLocalAppRunningState} from \"./AppRegistry\"\nimport devServerBridge from \"./DevServerBridge\"\nimport localMiniappRuntime, {type InstalledMiniappManifest} from \"./LocalMiniappRuntime\"\nimport {activeDashboardAmong} from \"./pages/activeDashboard\"\nimport type {MiniappLaunchSource} from \"@glassly/miniapp\"\nimport type {JSRouter} from \"./JSRouter\"\n\ninterface LauncherDeps {\n /** The host-constructed router (needs the native Crust binding). */\n router: JSRouter\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 /** Who started the app; reported to the miniapp on connect. */\n launchSource?: MiniappLaunchSource\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(): JSRouter {\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, 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: load directly off the local dev server over HTTP. ---\n if (devUrl) {\n const route = await decideDevLaunchRoute(packageName, devUrl)\n if (route.decision === \"offline\" || !route.manifest) return null\n const manifest = route.manifest\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 = route.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: manifest.name,\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: route.resolvedUrl,\n devPort: this.resolveDevPort(hints?.devPort, packageName),\n }\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 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 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 launchSource: hints?.launchSource,\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 * Miniapps run in the phone's own JS engine, so a host-process kill tears\n * down their JSContext with nothing to resurrect them. Without this they\n * would silently stay stopped on the next launch even though the user left\n * 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 * Always On apps (the dashboard) start whether or not they were running\n * when the app was last killed, and get a switcher card like any other app.\n * A dashboard that does not hold the role (ADR-0009) is not started by its\n * Always On flag.\n * Both restore paths skip apps missing required OS permissions without\n * prompting or clearing their saved running/Always On choice.\n */\n async autostartLocalMiniapps(): Promise<void> {\n const apps = await appRegistry.getInstalledMiniapps()\n const activeDashboard = activeDashboardAmong(apps)\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 const alwaysOn = app.alwaysOn && (app.type !== \"dashboard\" || app.packageName === activeDashboard)\n if (!alwaysOn && !getLocalAppRunningState(app.packageName)) continue\n if (this.isRunning(app.packageName)) continue\n try {\n const missing = await permissions.missingRequired(app.permissions ?? [])\n if (missing.length > 0) {\n console.info(\n `MiniappLauncher: skipping autostart for ${app.packageName} — missing required permissions: ${missing.join(\n \", \",\n )}`,\n )\n continue\n }\n } catch (e) {\n console.warn(`MiniappLauncher: skipping autostart for ${app.packageName} — permission check failed`, e)\n continue\n }\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
|
+
{"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,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAA;AAC9D,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;AAoCxF,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,I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AAC,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 JSRouter} 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 {permissions} from \"../facades/permissions\"\nimport {decideDevLaunchRoute} from \"../utils/devMiniappLaunch\"\nimport {storage} from \"../utils/storage/storage\"\nimport appRegistry, {getLocalAppRunningState, saveLocalAppRunningState} from \"./AppRegistry\"\nimport devServerBridge from \"./DevServerBridge\"\nimport localMiniappRuntime, {type InstalledMiniappManifest} from \"./LocalMiniappRuntime\"\nimport type {MiniappLaunchSource} from \"@glassly/miniapp\"\nimport type {JSRouter} from \"./JSRouter\"\n\ninterface LauncherDeps {\n /** The host-constructed router (needs the native Crust binding). */\n router: JSRouter\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 /** Who started the app; reported to the miniapp on connect. */\n launchSource?: MiniappLaunchSource\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(): JSRouter {\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, 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: load directly off the local dev server over HTTP. ---\n if (devUrl) {\n const route = await decideDevLaunchRoute(packageName, devUrl)\n if (route.decision === \"offline\" || !route.manifest) return null\n const manifest = route.manifest\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 = route.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: manifest.name,\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: route.resolvedUrl,\n devPort: this.resolveDevPort(hints?.devPort, packageName),\n }\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 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 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 launchSource: hints?.launchSource,\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 * Miniapps run in the phone's own JS engine, so a host-process kill tears\n * down their JSContext with nothing to resurrect them. Without this they\n * would silently stay stopped on the next launch even though the user left\n * 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 * Always On apps (the dashboard) start whether or not they were running\n * when the app was last killed, and get a switcher card like any other app.\n * Both restore paths skip apps missing required OS permissions without\n * prompting or clearing their saved running/Always On choice.\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 (!app.alwaysOn && !getLocalAppRunningState(app.packageName)) continue\n if (this.isRunning(app.packageName)) continue\n try {\n const missing = await permissions.missingRequired(app.permissions ?? [])\n if (missing.length > 0) {\n console.info(\n `MiniappLauncher: skipping autostart for ${app.packageName} — missing required permissions: ${missing.join(\n \", \",\n )}`,\n )\n continue\n }\n } catch (e) {\n console.warn(`MiniappLauncher: skipping autostart for ${app.packageName} — permission check failed`, e)\n continue\n }\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,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The overlay app's page (ADR-0006, ADR-0009): one Page per dashboard that
|
|
3
|
-
* has taken the slot, the only Page implementation the page host shows. The
|
|
4
|
-
* engine keeps the slot and the eligibility watch; a page only relays:
|
|
5
|
-
* holding the slot is reported to its app as a view change, and the app's
|
|
6
|
-
* frames reach the slot through `renderOverlay` under its package name. Only
|
|
7
|
-
* the dashboard that holds the role may show; when the role moves, the
|
|
8
|
-
* previous holder hears it was replaced. The runtime supplies the sink that
|
|
9
|
-
* delivers to apps, so this module never imports it.
|
|
10
|
-
*/
|
|
11
|
-
import { type PageHiddenReason } from "./PageHost";
|
|
12
1
|
export type DashboardViewChangeReason = "shown" | "hidden" | "replaced" | "ineligible";
|
|
13
2
|
export interface OverlayPagesSink {
|
|
14
3
|
/** Deliver a display_view event to the app. */
|
|
@@ -24,8 +13,8 @@ declare class OverlayPages {
|
|
|
24
13
|
get showingPackage(): string | null;
|
|
25
14
|
/** Give the app the slot (a no-op when it already shows or pages are not eligible). */
|
|
26
15
|
show(packageName: string): boolean;
|
|
27
|
-
/** Release the slot if the app holds it
|
|
28
|
-
hide(packageName: string
|
|
16
|
+
/** Release the slot if the app holds it. */
|
|
17
|
+
hide(packageName: string): void;
|
|
29
18
|
/** The app stopped: release the slot without telling it, and forget its page. */
|
|
30
19
|
remove(packageName: string): void;
|
|
31
20
|
private pageFor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverlayPages.d.ts","sourceRoot":"","sources":["../../../src/services/pages/OverlayPages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OverlayPages.d.ts","sourceRoot":"","sources":["../../../src/services/pages/OverlayPages.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAA;AAEtF,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAChE;AAED,cAAM,YAAY;IAChB,OAAO,CAAC,IAAI,CAAgC;IAC5C,OAAO,CAAC,KAAK,CAA0B;IACvC,gFAAgF;IAChF,OAAO,CAAC,MAAM,CAAoB;IAElC,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI;IAI5C,kDAAkD;IAClD,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAKlC;IAED,uFAAuF;IACvF,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAOlC,4CAA4C;IAC5C,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAK/B,iFAAiF;IACjF,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAYjC,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,IAAI;CAIb;AAED,QAAA,MAAM,YAAY,cAAqB,CAAA;AACvC,eAAe,YAAY,CAAA;AAC3B,OAAO,EAAC,YAAY,EAAC,CAAA"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The overlay
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* delivers to apps, so this module never imports it.
|
|
2
|
+
* The overlay apps' pages (ADR-0006): one Page per app that has taken the
|
|
3
|
+
* slot, the only Page implementation the page host shows. The engine keeps
|
|
4
|
+
* the slot and the eligibility watch; a page only relays: holding the slot
|
|
5
|
+
* is reported to its app as a view change, and the app's frames reach the
|
|
6
|
+
* slot through `renderOverlay` under its package name. Whichever app asked
|
|
7
|
+
* last holds the slot; the previous one hears it was replaced. The runtime
|
|
8
|
+
* supplies the sink that delivers to apps, so this module never imports it.
|
|
10
9
|
*/
|
|
11
10
|
import pageHost from "./PageHost";
|
|
12
11
|
import { isOverlayApp } from "./overlayApps";
|
|
@@ -37,11 +36,11 @@ class OverlayPages {
|
|
|
37
36
|
pageHost.show(page);
|
|
38
37
|
return pageHost.showing === page;
|
|
39
38
|
}
|
|
40
|
-
/** Release the slot if the app holds it
|
|
41
|
-
hide(packageName
|
|
39
|
+
/** Release the slot if the app holds it. */
|
|
40
|
+
hide(packageName) {
|
|
42
41
|
const page = this.pages.get(packageName);
|
|
43
42
|
if (page)
|
|
44
|
-
pageHost.hide(page
|
|
43
|
+
pageHost.hide(page);
|
|
45
44
|
}
|
|
46
45
|
/** The app stopped: release the slot without telling it, and forget its page. */
|
|
47
46
|
remove(packageName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverlayPages.js","sourceRoot":"","sources":["../../../src/services/pages/OverlayPages.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OverlayPages.js","sourceRoot":"","sources":["../../../src/services/pages/OverlayPages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,QAA4C,MAAM,YAAY,CAAA;AACrE,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAS/C,MAAM,YAAY;IACR,IAAI,GAA4B,IAAI,CAAA;IACpC,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAA;IACvC,gFAAgF;IACxE,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;IAElC,OAAO,CAAC,IAA6B;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,kDAAkD;IAClD,IAAI,cAAc;QAChB,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;QAChC,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAA;QACzB,KAAK,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,IAAI,KAAK,OAAO;gBAAE,OAAO,WAAW,CAAA;QACtF,OAAO,IAAI,CAAA;IACb,CAAC;IAED,uFAAuF;IACvF,IAAI,CAAC,WAAmB;QACtB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE;YAAE,OAAO,KAAK,CAAA;QAChE,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QACtC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACnB,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C,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAEO,IAAI,CAAC,WAAmB,EAAE,KAA8B;QAC9D,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;YAAE,OAAM;QACtE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;IACrC,CAAC;CACF;AAED,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;AACvC,eAAe,YAAY,CAAA;AAC3B,OAAO,EAAC,YAAY,EAAC,CAAA","sourcesContent":["/**\n * The overlay apps' pages (ADR-0006): one Page per app that has taken the\n * slot, the only Page implementation the page host shows. The engine keeps\n * the slot and the eligibility watch; a page only relays: holding the slot\n * is reported to its app as a view change, and the app's frames reach the\n * slot through `renderOverlay` under its package name. Whichever app asked\n * last holds the slot; the previous one hears it was replaced. The runtime\n * supplies the sink that delivers to apps, so this module never imports it.\n */\nimport pageHost, {type Page, type PageHiddenReason} from \"./PageHost\"\nimport {isOverlayApp} from \"./overlayApps\"\nimport {pagesEligible} from \"./pageEligibility\"\n\nexport type DashboardViewChangeReason = \"shown\" | \"hidden\" | \"replaced\" | \"ineligible\"\n\nexport interface OverlayPagesSink {\n /** Deliver a display_view event to the app. */\n send(packageName: string, event: Record<string, unknown>): void\n}\n\nclass OverlayPages {\n private sink: OverlayPagesSink | null = null\n private pages = new Map<string, Page>()\n /** Set while an app's page is torn down with the app; it hears nothing then. */\n private silent = new Set<string>()\n\n setSink(sink: OverlayPagesSink | null): void {\n this.sink = sink\n }\n\n /** The app whose page holds the slot, or null. */\n get showingPackage(): string | null {\n const showing = pageHost.showing\n if (!showing) return null\n for (const [packageName, page] of this.pages) if (page === showing) return packageName\n return null\n }\n\n /** Give the app the slot (a no-op when it already shows or pages are not eligible). */\n show(packageName: string): boolean {\n if (!isOverlayApp(packageName) || !pagesEligible()) return false\n const page = this.pageFor(packageName)\n pageHost.show(page)\n return pageHost.showing === page\n }\n\n /** Release the slot if the app holds it. */\n hide(packageName: string): void {\n const page = this.pages.get(packageName)\n if (page) pageHost.hide(page)\n }\n\n /** The app stopped: release the slot without telling it, and forget its page. */\n remove(packageName: string): void {\n const page = this.pages.get(packageName)\n if (!page) return\n this.silent.add(packageName)\n try {\n pageHost.hide(page)\n } finally {\n this.silent.delete(packageName)\n }\n this.pages.delete(packageName)\n }\n\n private pageFor(packageName: string): Page {\n let page = this.pages.get(packageName)\n if (page) return page\n page = {\n id: packageName,\n onShown: () => this.emit(packageName, {kind: \"change\", view: \"dashboard\", reason: \"shown\"}),\n onHidden: (reason: PageHiddenReason) => this.emit(packageName, {kind: \"change\", view: \"main\", reason}),\n }\n this.pages.set(packageName, page)\n return page\n }\n\n private emit(packageName: string, event: Record<string, unknown>): void {\n if (this.silent.has(packageName) || !isOverlayApp(packageName)) return\n this.sink?.send(packageName, event)\n }\n}\n\nconst overlayPages = new OverlayPages()\nexport default overlayPages\nexport {OverlayPages}\n"]}
|
|
@@ -20,7 +20,7 @@ declare class PageHost {
|
|
|
20
20
|
/** Give `page` the slot; no-op when it already shows or pages are not eligible. */
|
|
21
21
|
show(page: Page): void;
|
|
22
22
|
/** Release the slot if `page` holds it. */
|
|
23
|
-
hide(page: Page
|
|
23
|
+
hide(page: Page): void;
|
|
24
24
|
onChange(listener: (page: Page | null) => void): () => void;
|
|
25
25
|
private release;
|
|
26
26
|
private emit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageHost.d.ts","sourceRoot":"","sources":["../../../src/services/pages/PageHost.ts"],"names":[],"mappings":"AAeA,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAA;AAEnE,MAAM,WAAW,IAAI;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,qDAAqD;I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C,IAAI,EAAE,IAAI,GAAG,IAAI;IAYtB,2CAA2C;IAC3C,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAOtB,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;IAO3D,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,OAAO;CAUhB;AAED,QAAA,MAAM,QAAQ,UAAiB,CAAA;AAC/B,eAAe,QAAQ,CAAA;AACvB,OAAO,EAAC,QAAQ,EAAC,CAAA"}
|
|
@@ -53,11 +53,11 @@ class PageHost {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
/** Release the slot if `page` holds it. */
|
|
56
|
-
hide(page
|
|
56
|
+
hide(page) {
|
|
57
57
|
this.enqueue(() => {
|
|
58
58
|
if (this.showingPage !== page)
|
|
59
59
|
return;
|
|
60
|
-
this.release(
|
|
60
|
+
this.release("hidden");
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
onChange(listener) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageHost.js","sourceRoot":"","sources":["../../../src/services/pages/PageHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AAChE,OAAO,mBAAmB,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAa/C,MAAM,QAAQ;IACJ,WAAW,GAAgB,IAAI,CAAA;IAC/B,GAAG,GAAsB,EAAE,CAAA;IAC3B,QAAQ,GAAG,KAAK,CAAA;IAChB,SAAS,GAAG,IAAI,GAAG,EAA+B,CAAA;IAClD,MAAM,GAAsB,EAAE,CAAA;IAC9B,OAAO,GAAG,KAAK,CAAA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AAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QACjC,CAAC,CAAA;IACH,CAAC;IAEO,OAAO,CAAC,MAAwB;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAA;QAC7B,IAAI,CAAC,IAAI;YAAE,OAAM;QACjB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;QACvB,mBAAmB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACrB,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;IAEO,IAAI;QACV,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC/E,CAAC;IAEO,OAAO,CAAC,EAAc;QAC5B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACjB,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAM;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM;gBAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAiB,EAAE,CAAA;QAC5D,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;QACvB,CAAC;IACH,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAA;AAC/B,eAAe,QAAQ,CAAA;AACvB,OAAO,EAAC,QAAQ,EAAC,CAAA","sourcesContent":["/**\n * The page host owns the overlay slot: the single native view above the main\n * content. At most one page shows at a time; showing a page replaces whatever\n * was showing, hiding releases the slot and the main content replays. Which\n * app gets the wearer's gestures is the gesture claims' business, not the\n * host's. Show and hide run through one queue so a page\n * that hides itself from inside its own transition is hidden afterwards, never\n * re-entered. Eligibility (Glassly CFW, dashboard enabled) is checked before a\n * show and watched while a page is up.\n */\nimport {useGlassesStore} from \"../../stores/glasses\"\nimport {SETTINGS, useSettingsStore} from \"../../stores/settings\"\nimport localDisplayManager from \"../LocalDisplayManager\"\nimport {pagesEligible} from \"./pageEligibility\"\n\nexport type PageHiddenReason = \"hidden\" | \"replaced\" | \"ineligible\"\n\nexport interface Page {\n /** Scene app id; the overlay owner while the page shows. */\n readonly id: string\n /** The page holds the slot: draw the first frame. */\n onShown(): void\n /** The slot was released, taken by another page, or lost with eligibility. */\n onHidden(reason: PageHiddenReason): void\n}\n\nclass PageHost {\n private showingPage: Page | null = null\n private ops: Array<() => void> = []\n private draining = false\n private listeners = new Set<(page: Page | null) => void>()\n private unsubs: Array<() => void> = []\n private started = false\n\n start(): void {\n if (this.started) return\n this.started = true\n const check = () => {\n if (this.showingPage && !pagesEligible()) this.release(\"ineligible\")\n }\n this.unsubs.push(\n useGlassesStore.subscribe(\n (state) => `${state.connection.state}:${state.deviceModel}:${state.firmwareVersion}`,\n check,\n ),\n useSettingsStore.subscribe((state) => state.getSetting(SETTINGS.custom_dashboard_enabled.key), check),\n )\n }\n\n stop(): void {\n for (const unsub of this.unsubs) unsub()\n this.unsubs = []\n this.release(\"hidden\")\n this.started = false\n }\n\n get showing(): Page | null {\n return this.showingPage\n }\n\n /** Give `page` the slot; no-op when it already shows or pages are not eligible. */\n show(page: Page): void {\n this.enqueue(() => {\n if (this.showingPage === page || !pagesEligible()) return\n const previous = this.showingPage\n this.showingPage = page\n localDisplayManager.setOverlayOwner(page.id)\n previous?.onHidden(\"replaced\")\n page.onShown()\n this.emit()\n })\n }\n\n /** Release the slot if `page` holds it. */\n hide(page: Page): void {\n this.enqueue(() => {\n if (this.showingPage !== page) return\n this.release(\"hidden\")\n })\n }\n\n onChange(listener: (page: Page | null) => void): () => void {\n this.listeners.add(listener)\n return () => {\n this.listeners.delete(listener)\n }\n }\n\n private release(reason: PageHiddenReason): void {\n const page = this.showingPage\n if (!page) return\n this.showingPage = null\n localDisplayManager.setOverlayOwner(null)\n page.onHidden(reason)\n this.emit()\n }\n\n private emit(): void {\n for (const listener of Array.from(this.listeners)) listener(this.showingPage)\n }\n\n private enqueue(op: () => void): void {\n this.ops.push(op)\n if (this.draining) return\n this.draining = true\n try {\n while (this.ops.length) (this.ops.shift() as () => void)()\n } finally {\n this.draining = false\n }\n }\n}\n\nconst pageHost = new PageHost()\nexport default pageHost\nexport {PageHost}\n"]}
|
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The overlay
|
|
3
|
-
* (
|
|
4
|
-
* `session.display.showView("dashboard")` and
|
|
5
|
-
* `display.views` capability while the glasses are eligible. The runtime
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* both read it without a cycle.
|
|
2
|
+
* The overlay apps: the connected miniapps whose manifest type is
|
|
3
|
+
* "system_dashboard" (the dashboard). They alone may take the overlay slot
|
|
4
|
+
* through `session.display.showView("dashboard")` and have "dashboard" in
|
|
5
|
+
* their `display.views` capability while the glasses are eligible. The runtime adds an app when it connects and
|
|
6
|
+
* removes it when it stops; the engine never knows what any of them draws.
|
|
7
|
+
* Kept free of imports so the runtime and the notification policy can both
|
|
8
|
+
* read it without a cycle.
|
|
10
9
|
*/
|
|
11
10
|
export type DisplayView = "main" | "dashboard";
|
|
12
|
-
/** `packageName` holds the dashboard role and is connected. */
|
|
13
11
|
export declare function isOverlayApp(packageName: string): boolean;
|
|
14
|
-
/** `packageName` is a connected dashboard miniapp, whether or not it holds the role. */
|
|
15
|
-
export declare function isDashboardApp(packageName: string): boolean;
|
|
16
12
|
export declare function overlayApps(): readonly string[];
|
|
17
|
-
|
|
18
|
-
export declare function
|
|
19
|
-
|
|
20
|
-
export declare function
|
|
21
|
-
|
|
22
|
-
/** Record whether a dashboard subscribes to phone notifications (the overlay app is the viewer while it does). */
|
|
23
|
-
export declare function setOverlayViewer(packageName: string, subscribed: boolean): void;
|
|
24
|
-
/** The overlay app presents phone notifications. */
|
|
13
|
+
export declare function addOverlayApp(packageName: string): void;
|
|
14
|
+
export declare function removeOverlayApp(packageName: string): void;
|
|
15
|
+
/** Record whether an overlay app subscribes to phone notifications (it is a viewer while it does). */
|
|
16
|
+
export declare function setOverlayViewer(packageName: string, listening: boolean): void;
|
|
17
|
+
/** An overlay app that presents phone notifications is running. */
|
|
25
18
|
export declare function overlayViewerRunning(): boolean;
|
|
26
19
|
export declare function onOverlayAppsChange(listener: () => void): () => void;
|
|
27
|
-
/** The views `packageName` may draw: main for everyone, the dashboard for
|
|
20
|
+
/** The views `packageName` may draw: main for everyone, the dashboard for overlay apps on eligible glasses. */
|
|
28
21
|
export declare function displayViewsFor(packageName: string, eligible: boolean): DisplayView[];
|
|
29
22
|
/** Tests only. */
|
|
30
23
|
export declare function _resetOverlayAppsForTest(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlayApps.d.ts","sourceRoot":"","sources":["../../../src/services/pages/overlayApps.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"overlayApps.d.ts","sourceRoot":"","sources":["../../../src/services/pages/overlayApps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,CAAA;AAO9C,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,WAAW,IAAI,SAAS,MAAM,EAAE,CAE/C;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAIvD;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAI1D;AAED,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAK9E;AAED,mEAAmE;AACnE,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKpE;AAED,+GAA+G;AAC/G,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,WAAW,EAAE,CAErF;AAMD,kBAAkB;AAClB,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C"}
|
|
@@ -1,65 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The overlay
|
|
3
|
-
* (
|
|
4
|
-
* `session.display.showView("dashboard")` and
|
|
5
|
-
* `display.views` capability while the glasses are eligible. The runtime
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* both read it without a cycle.
|
|
2
|
+
* The overlay apps: the connected miniapps whose manifest type is
|
|
3
|
+
* "system_dashboard" (the dashboard). They alone may take the overlay slot
|
|
4
|
+
* through `session.display.showView("dashboard")` and have "dashboard" in
|
|
5
|
+
* their `display.views` capability while the glasses are eligible. The runtime adds an app when it connects and
|
|
6
|
+
* removes it when it stops; the engine never knows what any of them draws.
|
|
7
|
+
* Kept free of imports so the runtime and the notification policy can both
|
|
8
|
+
* read it without a cycle.
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const listening = new Set();
|
|
15
|
-
let active = null;
|
|
10
|
+
const apps = new Set();
|
|
11
|
+
/** Overlay apps listening to the phone's notifications: something on the glasses presents them. */
|
|
12
|
+
const viewers = new Set();
|
|
16
13
|
const listeners = new Set();
|
|
17
|
-
/** `packageName` holds the dashboard role and is connected. */
|
|
18
14
|
export function isOverlayApp(packageName) {
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
/** `packageName` is a connected dashboard miniapp, whether or not it holds the role. */
|
|
22
|
-
export function isDashboardApp(packageName) {
|
|
23
|
-
return connected.has(packageName);
|
|
15
|
+
return apps.has(packageName);
|
|
24
16
|
}
|
|
25
17
|
export function overlayApps() {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
/** The package that holds the dashboard role, connected or not. */
|
|
29
|
-
export function activeDashboard() {
|
|
30
|
-
return active;
|
|
31
|
-
}
|
|
32
|
-
export function setActiveDashboard(packageName) {
|
|
33
|
-
if (active === packageName)
|
|
34
|
-
return;
|
|
35
|
-
active = packageName;
|
|
36
|
-
emit();
|
|
18
|
+
return [...apps];
|
|
37
19
|
}
|
|
38
|
-
export function
|
|
39
|
-
if (
|
|
20
|
+
export function addOverlayApp(packageName) {
|
|
21
|
+
if (apps.has(packageName))
|
|
40
22
|
return;
|
|
41
|
-
|
|
23
|
+
apps.add(packageName);
|
|
42
24
|
emit();
|
|
43
25
|
}
|
|
44
|
-
export function
|
|
45
|
-
|
|
46
|
-
if (!
|
|
26
|
+
export function removeOverlayApp(packageName) {
|
|
27
|
+
viewers.delete(packageName);
|
|
28
|
+
if (!apps.delete(packageName))
|
|
47
29
|
return;
|
|
48
30
|
emit();
|
|
49
31
|
}
|
|
50
|
-
/** Record whether
|
|
51
|
-
export function setOverlayViewer(packageName,
|
|
52
|
-
const was =
|
|
53
|
-
if (
|
|
54
|
-
|
|
32
|
+
/** Record whether an overlay app subscribes to phone notifications (it is a viewer while it does). */
|
|
33
|
+
export function setOverlayViewer(packageName, listening) {
|
|
34
|
+
const was = viewers.has(packageName);
|
|
35
|
+
if (listening && apps.has(packageName))
|
|
36
|
+
viewers.add(packageName);
|
|
55
37
|
else
|
|
56
|
-
|
|
57
|
-
if (was !==
|
|
38
|
+
viewers.delete(packageName);
|
|
39
|
+
if (was !== viewers.has(packageName))
|
|
58
40
|
emit();
|
|
59
41
|
}
|
|
60
|
-
/**
|
|
42
|
+
/** An overlay app that presents phone notifications is running. */
|
|
61
43
|
export function overlayViewerRunning() {
|
|
62
|
-
return
|
|
44
|
+
return viewers.size > 0;
|
|
63
45
|
}
|
|
64
46
|
export function onOverlayAppsChange(listener) {
|
|
65
47
|
listeners.add(listener);
|
|
@@ -67,9 +49,9 @@ export function onOverlayAppsChange(listener) {
|
|
|
67
49
|
listeners.delete(listener);
|
|
68
50
|
};
|
|
69
51
|
}
|
|
70
|
-
/** The views `packageName` may draw: main for everyone, the dashboard for
|
|
52
|
+
/** The views `packageName` may draw: main for everyone, the dashboard for overlay apps on eligible glasses. */
|
|
71
53
|
export function displayViewsFor(packageName, eligible) {
|
|
72
|
-
return
|
|
54
|
+
return apps.has(packageName) && eligible ? ["main", "dashboard"] : ["main"];
|
|
73
55
|
}
|
|
74
56
|
function emit() {
|
|
75
57
|
for (const listener of Array.from(listeners))
|
|
@@ -77,8 +59,7 @@ function emit() {
|
|
|
77
59
|
}
|
|
78
60
|
/** Tests only. */
|
|
79
61
|
export function _resetOverlayAppsForTest() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
active = null;
|
|
62
|
+
apps.clear();
|
|
63
|
+
viewers.clear();
|
|
83
64
|
}
|
|
84
65
|
//# sourceMappingURL=overlayApps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlayApps.js","sourceRoot":"","sources":["../../../src/services/pages/overlayApps.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"overlayApps.js","sourceRoot":"","sources":["../../../src/services/pages/overlayApps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;AAC9B,mGAAmG;AACnG,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;AACjC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AAEvC,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAC9B,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,WAAmB;IAC/C,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;QAAE,OAAM;IACjC,I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IAAI,CAAC,SAAS,CAAC;QAAE,QAAQ,EAAE,CAAA;AAC1D,CAAC;AAED,kBAAkB;AAClB,MAAM,UAAU,wBAAwB;IACtC,IAAI,CAAC,KAAK,EAAE,CAAA;IACZ,OAAO,CAAC,KAAK,EAAE,CAAA;AACjB,CAAC","sourcesContent":["/**\n * The overlay apps: the connected miniapps whose manifest type is\n * \"system_dashboard\" (the dashboard). They alone may take the overlay slot\n * through `session.display.showView(\"dashboard\")` and have \"dashboard\" in\n * their `display.views` capability while the glasses are eligible. The runtime adds an app when it connects and\n * removes it when it stops; the engine never knows what any of them draws.\n * Kept free of imports so the runtime and the notification policy can both\n * read it without a cycle.\n */\n\nexport type DisplayView = \"main\" | \"dashboard\"\n\nconst apps = new Set<string>()\n/** Overlay apps listening to the phone's notifications: something on the glasses presents them. */\nconst viewers = new Set<string>()\nconst listeners = new Set<() => void>()\n\nexport function isOverlayApp(packageName: string): boolean {\n return apps.has(packageName)\n}\n\nexport function overlayApps(): readonly string[] {\n return [...apps]\n}\n\nexport function addOverlayApp(packageName: string): void {\n if (apps.has(packageName)) return\n apps.add(packageName)\n emit()\n}\n\nexport function removeOverlayApp(packageName: string): void {\n viewers.delete(packageName)\n if (!apps.delete(packageName)) return\n emit()\n}\n\n/** Record whether an overlay app subscribes to phone notifications (it is a viewer while it does). */\nexport function setOverlayViewer(packageName: string, listening: boolean): void {\n const was = viewers.has(packageName)\n if (listening && apps.has(packageName)) viewers.add(packageName)\n else viewers.delete(packageName)\n if (was !== viewers.has(packageName)) emit()\n}\n\n/** An overlay app that presents phone notifications is running. */\nexport function overlayViewerRunning(): boolean {\n return viewers.size > 0\n}\n\nexport function onOverlayAppsChange(listener: () => void): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n\n/** The views `packageName` may draw: main for everyone, the dashboard for overlay apps on eligible glasses. */\nexport function displayViewsFor(packageName: string, eligible: boolean): DisplayView[] {\n return apps.has(packageName) && eligible ? [\"main\", \"dashboard\"] : [\"main\"]\n}\n\nfunction emit(): void {\n for (const listener of Array.from(listeners)) listener()\n}\n\n/** Tests only. */\nexport function _resetOverlayAppsForTest(): void {\n apps.clear()\n viewers.clear()\n}\n"]}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The settings bridge's vocabulary (session.settings): which engine settings
|
|
3
|
-
* a miniapp
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* a system miniapp may read or write, the derived read-only keys the engine
|
|
4
|
+
* computes rather than stores, and the request validation. Pure, so the
|
|
5
|
+
* runtime's handlers stay thin and this can be tested without the native
|
|
6
|
+
* import surface the runtime pulls in.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* glasses-menu keys the phone's settings screens used to,
|
|
10
|
-
* so persistence, server sync and the Bluetooth sync of
|
|
11
|
-
* if a phone screen wrote them.
|
|
12
|
-
* that in its storage.
|
|
8
|
+
* The dashboard miniapp is the consumer: it edits the same dashboard,
|
|
9
|
+
* notification and glasses-menu keys the phone's settings screens used to,
|
|
10
|
+
* through the store, so persistence, server sync and the Bluetooth sync of
|
|
11
|
+
* `menu_apps` behave as if a phone screen wrote them.
|
|
13
12
|
*/
|
|
14
13
|
export type SettingsBridgeAccess = "read" | "write";
|
|
15
|
-
/** Stored settings the bridge serves, by key, with what a
|
|
14
|
+
/** Stored settings the bridge serves, by key, with what a system app may do to each. */
|
|
16
15
|
export declare const SETTINGS_BRIDGE_KEYS: Readonly<Record<string, SettingsBridgeAccess>>;
|
|
17
16
|
/**
|
|
18
17
|
* Read-only keys the engine computes: whether the wearer can see the phone,
|
|
19
|
-
* whether the foreground miniapp is drawing on the glasses, the ring's
|
|
20
|
-
* battery
|
|
21
|
-
*
|
|
18
|
+
* whether the foreground miniapp is drawing on the glasses, and the ring's
|
|
19
|
+
* battery. They change on their own clocks; the runtime pushes them like
|
|
20
|
+
* stored keys.
|
|
22
21
|
*/
|
|
23
|
-
export declare const DERIVED_SETTINGS_KEYS: readonly ["phone_active", "foreground_app_on_screen", "ring_battery"
|
|
22
|
+
export declare const DERIVED_SETTINGS_KEYS: readonly ["phone_active", "foreground_app_on_screen", "ring_battery"];
|
|
24
23
|
export type DerivedSettingsKey = (typeof DERIVED_SETTINGS_KEYS)[number];
|
|
25
24
|
export declare function isDerivedSettingsKey(key: string): key is DerivedSettingsKey;
|
|
26
|
-
/** What a
|
|
25
|
+
/** What a system app may do with `key`, or null when the bridge does not serve it. */
|
|
27
26
|
export declare function settingsBridgeAccess(key: string): SettingsBridgeAccess | null;
|
|
28
27
|
/** Every key the bridge serves, stored then derived. */
|
|
29
28
|
export declare function allSettingsBridgeKeys(): string[];
|