π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
fix(desktop): answer capture requests from the app window
Luis Ortize98c8f54ba87
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.tsindex fac7ed5..6df9022 100644--- a/apps/desktop/src/main/index.ts+++ b/apps/desktop/src/main/index.ts@@ -108,14 +108,21 @@ function createTray(): void {refreshTrayMenu();}-function broadcastOverlay(command: OverlayCommand): void {- mainWindow?.webContents.send('mimik:capture:command', command, overlay?.state, overlay?.region, guideId);+function broadcastOverlay(command: OverlayCommand, id: string | null): void {+ mainWindow?.webContents.send('mimik:capture:command', command, overlay?.state, overlay?.region, id);}async function onOverlayCommand(command: OverlayCommand): Promise<void> {+ let finished: string | null = null;if (command === 'start' && !guideId) {stepCount = 0;- guideId = await ask<string>(mainWindow?.webContents ?? null, 'mimik:capture:startGuide');+ try {+ guideId = await ask<string>(mainWindow?.webContents ?? null, 'mimik:capture:startGuide');+ } catch (error) {+ overlay?.hide();+ dialog.showErrorBox('Mimik cannot record', error instanceof Error ? error.message : String(error));+ return;+ }const started = await recorder?.start();if (started && !started.ok) {guideId = null;@@ -130,9 +137,14 @@ async function onOverlayCommand(command: OverlayCommand): Promise<void> {} else if (command === 'stop' || command === 'cancel') {recorder?.stop();await recorder?.drain();+ if (command === 'stop' && stepCount > 0) finished = guideId;+ if (finished) {+ await ask(mainWindow?.webContents ?? null, 'mimik:capture:finishGuide', finished).catch(() => undefined);+ }guideId = null;}- broadcastOverlay(command);+ broadcastOverlay(command, finished ?? guideId);+ if (finished) showWindow();}let isQuitting = false;diff --git a/apps/desktop/src/renderer/capture-host.ts b/apps/desktop/src/renderer/capture-host.tsnew file mode 100644index 0000000..71cf113--- /dev/null+++ b/apps/desktop/src/renderer/capture-host.ts@@ -0,0 +1,22 @@+import type { CaptureStepData } from '@mimik/core/capture/sink';+import { i18n } from '@mimik/core/env';+import { getStepsForGuide, permanentlyDeleteGuide, updateGuideTitle } from '@mimik/core/guides/service';+import { DesktopCaptureSink } from './capture-sink';++const sink = new DesktopCaptureSink();++window.mimik.onRequest('mimik:capture:startGuide', () => sink.startGuide());+window.mimik.onRequest('mimik:capture:step', (payload) => sink.captureStep(payload as CaptureStepData));++window.mimik.onRequest('mimik:capture:finishGuide', async (payload) => {+ const guideId = payload as string;+ const steps = await getStepsForGuide(guideId);+ const app = steps.find((step) => step.app?.name)?.app?.name;+ await updateGuideTitle(guideId, app ? i18n.t('desktop.guideInApp', [app]) : i18n.t('desktop.newGuide'));+ return true;+});++window.mimik.onRequest('mimik:check:cleanup', async (payload) => {+ for (const id of payload as string[]) await permanentlyDeleteGuide(id);+ return true;+});diff --git a/apps/desktop/src/renderer/main.tsx b/apps/desktop/src/renderer/main.tsxindex cace833..bfefe79 100644--- a/apps/desktop/src/renderer/main.tsx+++ b/apps/desktop/src/renderer/main.tsx@@ -1,5 +1,6 @@import './core-env';import './ui-env';+import './capture-host';import { createRoot } from 'react-dom/client';import App from './App';import './styles.css';