forked from Blendman974/faceclaw
EvenHub app can search and check for updates
This commit is contained in:
1 parent
60c9167a87
commit
b69fdc220a
8 files changed
+938
-239
No files matched your search
+60
-33
@@ -14,6 +14,7 @@ import { launchPackage, launchUrl, normalizeAppUrl } from "./manager";
|
||||
import { createInProcessWindow, type InProcessWindow } from "../../ui/shell/in-process-window";
|
||||
import { renderEvenRealitiesLogo } from "../../graphics/even-realities-logo";
|
||||
import { makeImageWindowIcon, windowIcon } from "../../ui/shell/chrome-layer";
|
||||
import { type InstalledEvenHubApp } from "./installed-apps";
|
||||
|
||||
const EVENHUB_STORE_WINDOW_ID = "evenhub:store";
|
||||
const EVENHUB_STORE_SURFACE_ID = "window:evenhub:store";
|
||||
@@ -40,45 +41,71 @@ export function isLoadableAppUrl(url: string): boolean {
|
||||
return normalizeAppUrl(url) !== null;
|
||||
}
|
||||
|
||||
/** The open store window, so a second launch focuses it and deep links can reach its layer. */
|
||||
let storeWindow: { window: InProcessWindow; store: EvenHubStoreLayer } | null = null;
|
||||
|
||||
/** Open the store window, or focus the one already open. */
|
||||
async function ensureStoreWindow(ctx: AppContext): Promise<{ window: InProcessWindow; store: EvenHubStoreLayer }> {
|
||||
if (storeWindow && shell.getWindows().some((window) => window.windowId === EVENHUB_STORE_WINDOW_ID)) {
|
||||
shell.focusWindow(EVENHUB_STORE_WINDOW_ID);
|
||||
ctx.requestShellRender();
|
||||
return storeWindow;
|
||||
}
|
||||
let created: InProcessWindow | null = null;
|
||||
const store = new EvenHubStoreLayer({
|
||||
launchApp: (appId) => ctx.launchApp(appId),
|
||||
appendLog: ctx.appendLog,
|
||||
});
|
||||
await ctx.launchInProcessApp(EVENHUB_STORE_WINDOW_ID, EVENHUB_STORE_SURFACE_ID, (options) => {
|
||||
created = createInProcessWindow({
|
||||
appId: "evenhub",
|
||||
windowId: EVENHUB_STORE_WINDOW_ID,
|
||||
title: "EvenHub",
|
||||
iconLetter: "EH",
|
||||
icon: "package",
|
||||
drawIcon: makeImageWindowIcon(renderEvenRealitiesLogo, windowIcon("package", "EH")),
|
||||
closeable: true,
|
||||
menuItems: () => (created?.stack.isAtBase() ? store.buildMenuItems() : []),
|
||||
actions: options.actions,
|
||||
// Dictated text runs a store search (when the store page itself is on top).
|
||||
receiveTextInput: (text) => {
|
||||
if (created?.stack.receiveTextInput(text)) created.requestRender();
|
||||
},
|
||||
baseLayer: store,
|
||||
submitFrame: options.submitFrame,
|
||||
setSurfaceVisible: options.setSurfaceVisible,
|
||||
removeSurface: options.removeSurface,
|
||||
onClosed: () => {
|
||||
store.onWindowClosed(options.actions);
|
||||
if (storeWindow?.store === store) storeWindow = null;
|
||||
options.onClosed();
|
||||
},
|
||||
});
|
||||
return created;
|
||||
});
|
||||
if (!created) throw new Error("EvenHub store window was not created.");
|
||||
storeWindow = { window: created, store };
|
||||
return storeWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the store on an installed app's page. The launcher uses it when the
|
||||
* registry lists a package whose EHPK is gone (a settings import after a
|
||||
* reinstall), so the tap lands on a Reinstall button instead of failing.
|
||||
*/
|
||||
export async function openEvenHubStoreForPackage(ctx: AppContext, installed: InstalledEvenHubApp): Promise<void> {
|
||||
const { window, store } = await ensureStoreWindow(ctx);
|
||||
store.showInstalledPackage(window.stack, installed);
|
||||
window.requestRender();
|
||||
}
|
||||
|
||||
const evenhubApp: AppDefinition = {
|
||||
appId: "evenhub",
|
||||
title: "EvenHub",
|
||||
icon: "package",
|
||||
renderIcon: renderEvenRealitiesLogo,
|
||||
launch: async (ctx) => {
|
||||
const existing = shell.getWindows().find((window) => window.windowId === EVENHUB_STORE_WINDOW_ID);
|
||||
if (existing) {
|
||||
shell.focusWindow(existing.windowId);
|
||||
ctx.requestShellRender();
|
||||
return;
|
||||
}
|
||||
let created: InProcessWindow | null = null;
|
||||
const store = new EvenHubStoreLayer({
|
||||
launchApp: (appId) => ctx.launchApp(appId),
|
||||
appendLog: ctx.appendLog,
|
||||
});
|
||||
await ctx.launchInProcessApp(EVENHUB_STORE_WINDOW_ID, EVENHUB_STORE_SURFACE_ID, (options) => {
|
||||
created = createInProcessWindow({
|
||||
appId: "evenhub",
|
||||
windowId: EVENHUB_STORE_WINDOW_ID,
|
||||
title: "EvenHub",
|
||||
iconLetter: "EH",
|
||||
icon: "package",
|
||||
drawIcon: makeImageWindowIcon(renderEvenRealitiesLogo, windowIcon("package", "EH")),
|
||||
closeable: true,
|
||||
menuItems: () => (created?.stack.isAtBase() ? store.buildMenuItems() : []),
|
||||
actions: options.actions,
|
||||
baseLayer: store,
|
||||
submitFrame: options.submitFrame,
|
||||
setSurfaceVisible: options.setSurfaceVisible,
|
||||
removeSurface: options.removeSurface,
|
||||
onClosed: () => {
|
||||
store.onWindowClosed(options.actions);
|
||||
options.onClosed();
|
||||
},
|
||||
});
|
||||
return created;
|
||||
});
|
||||
await ensureStoreWindow(ctx);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user