Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

refactor(desktop): take the cursor types from core

Luis Ortiz507c0f0580ac
diff --git a/apps/desktop/src/main/capture/recorder.ts b/apps/desktop/src/main/capture/recorder.ts
index 924389f..d268d58 100644
--- a/apps/desktop/src/main/capture/recorder.ts
+++ b/apps/desktop/src/main/capture/recorder.ts
@@ -1,6 +1,7 @@
import { randomUUID } from 'node:crypto';
import type { CaptureImage } from '@mimik/core/capture/sink';
import type { ElementMeta } from '@mimik/core/guides/types';
+import type { CursorMark } from '@mimik/core/screenshot/types';
import { screen } from 'electron';
import { cursorPoint } from './displays';
import {
@@ -61,11 +62,6 @@ export interface Point {
y: number;
}
-export interface CursorMark extends Point {
- style: CaptureSettings['cursorStyle'];
- scale: number;
-}
-
export interface CaptureRequest {
action: string;
elementMeta: ElementMeta;
@@ -187,7 +183,7 @@ export function targetRect(element: ScreenElement | null, framed: Rect, point: P
return inner;
}
-export function centreOf(element: ScreenElement | null): Point | null {
+function centreOf(element: ScreenElement | null): Point | null {
const rect = element?.rect;
if (!rect) return null;
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
diff --git a/apps/desktop/src/main/capture/settings.ts b/apps/desktop/src/main/capture/settings.ts
index 9110454..ae38c78 100644
--- a/apps/desktop/src/main/capture/settings.ts
+++ b/apps/desktop/src/main/capture/settings.ts
@@ -1,11 +1,13 @@
import { readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
+import type { CursorStyle } from '@mimik/core/screenshot/types';
import { app } from 'electron';
-export type CursorStyle = 'arrow' | 'hand' | 'dot';
+export type { CursorStyle };
export type CaptureMode = 'window' | 'screen' | 'region';
-export const CURSOR_STYLES: CursorStyle[] = ['arrow', 'hand', 'dot'];
+const EVERY_CURSOR_STYLE: Record<CursorStyle, true> = { arrow: true, hand: true, dot: true };
+export const CURSOR_STYLES = Object.keys(EVERY_CURSOR_STYLE) as CursorStyle[];
export const CAPTURE_MODES: CaptureMode[] = ['window', 'screen', 'region'];
export const MAX_SCREENSHOT_DELAY_MS = 2000;
export const MIN_TYPING_DEBOUNCE_MS = 200;
diff --git a/apps/desktop/src/renderer/SettingsPanel.tsx b/apps/desktop/src/renderer/SettingsPanel.tsx
index 97d7172..da13560 100644
--- a/apps/desktop/src/renderer/SettingsPanel.tsx
+++ b/apps/desktop/src/renderer/SettingsPanel.tsx
@@ -1,5 +1,6 @@
import { validateApiKey } from '@mimik/core/capture/ai/validate';
import { i18n } from '@mimik/core/env';
+import { CURSOR_STYLES } from '@mimik/core/screenshot/types';
import AiSettings from '@mimik/ui/shared/AiSettings';
import { useKeyCheck } from '@mimik/ui/shared/key-status';
import { useEffect, useState } from 'react';
@@ -14,7 +15,6 @@ const SECTIONS: { id: Section; labelKey: string }[] = [
{ id: 'shortcuts', labelKey: 'desktop_shortcutsSection' },
];
-const STYLES: CaptureSettings['cursorStyle'][] = ['arrow', 'hand', 'dot'];
const MODES: { id: CaptureSettings['captureMode']; labelKey: string }[] = [
{ id: 'window', labelKey: 'desktop_modeWindow' },
{ id: 'screen', labelKey: 'desktop_modeScreen' },
@@ -127,7 +127,7 @@ export default function SettingsPanel({ onClose }: { onClose(): void }) {
disabled={!settings.showCursor}
onChange={(e) => save({ cursorStyle: e.target.value as CaptureSettings['cursorStyle'] })}
>
- {STYLES.map((style) => (
+ {CURSOR_STYLES.map((style) => (
<option key={style} value={style}>
{style}
</option>
diff --git a/packages/core/src/screenshot/types.ts b/packages/core/src/screenshot/types.ts
index ad556a4..31446b0 100644
--- a/packages/core/src/screenshot/types.ts
+++ b/packages/core/src/screenshot/types.ts
@@ -140,6 +140,8 @@ export type Annotation =
export type CursorStyle = 'arrow' | 'hand' | 'dot';
+export const CURSOR_STYLES: CursorStyle[] = ['arrow', 'hand', 'dot'];
+
export interface CursorMark {
x: number;
y: number;