wip
This commit is contained in:
@@ -255,7 +255,18 @@ export function configureDIContainer(): void {
|
||||
}
|
||||
|
||||
// Overlay Sync Service - create singleton instance directly
|
||||
const lifecycleEmitter = browserAutomation as unknown as IAutomationLifecycleEmitter;
|
||||
const lifecycleEmitter: IAutomationLifecycleEmitter = {
|
||||
onLifecycle: (cb) => {
|
||||
if ('onLifecycle' in browserAutomation && typeof (browserAutomation as { onLifecycle?: unknown }).onLifecycle === 'function') {
|
||||
(browserAutomation as IAutomationLifecycleEmitter).onLifecycle(cb);
|
||||
}
|
||||
},
|
||||
offLifecycle: (cb) => {
|
||||
if ('offLifecycle' in browserAutomation && typeof (browserAutomation as { offLifecycle?: unknown }).offLifecycle === 'function') {
|
||||
(browserAutomation as IAutomationLifecycleEmitter).offLifecycle(cb);
|
||||
}
|
||||
},
|
||||
};
|
||||
const publisher = {
|
||||
publish: async (event: unknown) => {
|
||||
try {
|
||||
|
||||
@@ -374,9 +374,10 @@ export function setupIpcHandlers(mainWindow: BrowserWindow): void {
|
||||
// Subscribe to automation adapter lifecycle events and relay to renderer
|
||||
try {
|
||||
if (!lifecycleSubscribed) {
|
||||
const lifecycleEmitter = container.getBrowserAutomation() as unknown as IAutomationLifecycleEmitter;
|
||||
if (typeof lifecycleEmitter.onLifecycle === 'function') {
|
||||
lifecycleEmitter.onLifecycle((ev) => {
|
||||
const browserAutomation = container.getBrowserAutomation();
|
||||
const candidate = browserAutomation as Partial<IAutomationLifecycleEmitter>;
|
||||
if (typeof candidate.onLifecycle === 'function' && typeof candidate.offLifecycle === 'function') {
|
||||
candidate.onLifecycle((ev) => {
|
||||
try {
|
||||
if (mainWindow && mainWindow.webContents) {
|
||||
mainWindow.webContents.send('automation-event', ev);
|
||||
@@ -388,6 +389,8 @@ export function setupIpcHandlers(mainWindow: BrowserWindow): void {
|
||||
});
|
||||
lifecycleSubscribed = true;
|
||||
logger.debug('Subscribed to adapter lifecycle events for renderer relay');
|
||||
} else {
|
||||
logger.debug?.('Browser automation does not expose lifecycle events; skipping subscription');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -31,12 +31,16 @@ export interface CheckoutConfirmationRequest {
|
||||
timeoutMs: number;
|
||||
}
|
||||
|
||||
export interface StartAutomationResponse {
|
||||
success: boolean;
|
||||
sessionId?: string;
|
||||
error?: string;
|
||||
authRequired?: boolean;
|
||||
authState?: AuthenticationState;
|
||||
}
|
||||
|
||||
export interface ElectronAPI {
|
||||
startAutomation: (config: HostedSessionConfig) => Promise<{
|
||||
success: boolean;
|
||||
sessionId?: string;
|
||||
error?: string;
|
||||
}>;
|
||||
startAutomation: (config: HostedSessionConfig) => Promise<StartAutomationResponse>;
|
||||
stopAutomation: (sessionId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
getSessionStatus: (sessionId: string) => Promise<any>;
|
||||
pauseAutomation: (sessionId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
@@ -60,7 +64,8 @@ export interface ElectronAPI {
|
||||
}
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
startAutomation: (config: HostedSessionConfig) => ipcRenderer.invoke('start-automation', config),
|
||||
startAutomation: (config: HostedSessionConfig) =>
|
||||
ipcRenderer.invoke('start-automation', config) as Promise<StartAutomationResponse>,
|
||||
stopAutomation: (sessionId: string) => ipcRenderer.invoke('stop-automation', sessionId),
|
||||
getSessionStatus: (sessionId: string) => ipcRenderer.invoke('get-session-status', sessionId),
|
||||
pauseAutomation: (sessionId: string) => ipcRenderer.invoke('pause-automation', sessionId),
|
||||
|
||||
Reference in New Issue
Block a user