From 2f24038cb58c1d7852389f8ebbfda978203f9b97 Mon Sep 17 00:00:00 2001 From: Theodor Peifer Date: Thu, 16 Apr 2026 17:33:05 +0200 Subject: [PATCH] fix: use existing getPlatform() so the OS based CPU readback check also works in the browser --- src/lib/exporter/gifExporter.ts | 3 ++- src/lib/exporter/videoExporter.ts | 3 ++- src/utils/platformUtils.ts | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/lib/exporter/gifExporter.ts b/src/lib/exporter/gifExporter.ts index 81c540e..46ac6a0 100644 --- a/src/lib/exporter/gifExporter.ts +++ b/src/lib/exporter/gifExporter.ts @@ -8,6 +8,7 @@ import type { WebcamSizePreset, ZoomRegion, } from "@/components/video-editor/types"; +import { getPlatform } from "@/utils/platformUtils"; import { AsyncVideoFrameQueue } from "./asyncVideoFrameQueue"; import { FrameRenderer } from "./frameRenderer"; import { StreamingVideoDecoder } from "./streamingDecoder"; @@ -117,7 +118,7 @@ export class GifExporter { let webcamFrameQueue: AsyncVideoFrameQueue | null = null; try { - const platform = await window.electronAPI.getPlatform(); + const platform = await getPlatform(); this.cleanup(); this.cancelled = false; diff --git a/src/lib/exporter/videoExporter.ts b/src/lib/exporter/videoExporter.ts index 13c0696..7662d93 100644 --- a/src/lib/exporter/videoExporter.ts +++ b/src/lib/exporter/videoExporter.ts @@ -7,6 +7,7 @@ import type { WebcamSizePreset, ZoomRegion, } from "@/components/video-editor/types"; +import { getPlatform } from "@/utils/platformUtils"; import { AsyncVideoFrameQueue } from "./asyncVideoFrameQueue"; import { AudioProcessor } from "./audioEncoder"; import { FrameRenderer } from "./frameRenderer"; @@ -112,7 +113,7 @@ export class VideoExporter { this.fatalEncoderError = null; try { - const platform = await window.electronAPI.getPlatform(); + const platform = await getPlatform(); const streamingDecoder = new StreamingVideoDecoder(); this.streamingDecoder = streamingDecoder; diff --git a/src/utils/platformUtils.ts b/src/utils/platformUtils.ts index 37d5a6d..2fb57e1 100644 --- a/src/utils/platformUtils.ts +++ b/src/utils/platformUtils.ts @@ -3,7 +3,7 @@ let cachedPlatform: string | null = null; /** * Gets the current platform from Electron */ -const getPlatform = async (): Promise => { +export const getPlatform = async (): Promise => { if (cachedPlatform) return cachedPlatform; try { @@ -14,9 +14,14 @@ const getPlatform = async (): Promise => { console.warn("Failed to get platform from Electron, falling back to navigator:", error); // Fallback for development/testing let fallbackPlatform = "win32"; - if (typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.platform)) { - fallbackPlatform = "darwin"; + if (typeof navigator !== "undefined") { + if (/Mac|iPhone|iPad|iPod/.test(navigator.platform)) { + fallbackPlatform = "darwin"; + } else if (/Linux/.test(navigator.platform)) { + fallbackPlatform = "linux"; + } } + cachedPlatform = fallbackPlatform; return fallbackPlatform; }