Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
{
"from": "public/wallpapers",
"to": "assets/wallpapers"
},
{
"from": "public/audio",
"to": "assets/audio"
}
],

Expand Down
7 changes: 7 additions & 0 deletions electron/electron-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ interface Window {
fileName: string,
) => Promise<{ success: boolean; path?: string; message?: string; canceled?: boolean }>;
openVideoFilePicker: () => Promise<{ success: boolean; path?: string; canceled?: boolean }>;
openAudioFilePicker: () => Promise<{
success: boolean;
path?: string;
message?: string;
error?: string;
canceled?: boolean;
}>;
setCurrentVideoPath: (path: string) => Promise<{ success: boolean }>;
setCurrentRecordingSession: (
session: import("../src/lib/recordingSession").RecordingSession | null,
Expand Down
81 changes: 81 additions & 0 deletions electron/ipc/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ const PROJECT_FILE_EXTENSION = "openscreen";
const SHORTCUTS_FILE = path.join(app.getPath("userData"), "shortcuts.json");
const RECORDING_SESSION_SUFFIX = ".session.json";
const ALLOWED_IMPORT_VIDEO_EXTENSIONS = new Set([".webm", ".mp4", ".mov", ".avi", ".mkv"]);
const ALLOWED_IMPORT_AUDIO_EXTENSIONS = new Set([
".mp3",
".wav",
".m4a",
".aac",
".ogg",
".flac",
".webm",
]);

/**
* Paths explicitly approved by the user via file picker dialogs or project loads.
Expand Down Expand Up @@ -56,6 +65,10 @@ function hasAllowedImportVideoExtension(filePath: string): boolean {
return ALLOWED_IMPORT_VIDEO_EXTENSIONS.has(path.extname(filePath).toLowerCase());
}

function hasAllowedImportAudioExtension(filePath: string): boolean {
return ALLOWED_IMPORT_AUDIO_EXTENSIONS.has(path.extname(filePath).toLowerCase());
}

async function approveReadableVideoPath(
filePath?: string | null,
trustedDirs?: string[],
Expand Down Expand Up @@ -97,6 +110,33 @@ async function approveReadableVideoPath(
return normalizedPath;
}

async function approveReadableAudioPath(filePath?: string | null): Promise<string | null> {
const normalizedPath = normalizeVideoSourcePath(filePath);
if (!normalizedPath) {
return null;
}

if (isPathAllowed(normalizedPath)) {
return normalizedPath;
}

if (!hasAllowedImportAudioExtension(normalizedPath)) {
return null;
}

try {
const stats = await fs.stat(normalizedPath);
if (!stats.isFile()) {
return null;
}
} catch {
return null;
}

approveFilePath(normalizedPath);
return normalizedPath;
}

function resolveRecordingOutputPath(fileName: string): string {
const trimmed = fileName.trim();
if (!trimmed) {
Expand Down Expand Up @@ -724,6 +764,47 @@ export function registerIpcHandlers(
}
});

ipcMain.handle("open-audio-file-picker", async () => {
try {
const result = await dialog.showOpenDialog({
title: "Select audio",
defaultPath: app.getPath("music"),
filters: [
{
name: "Audio Files",
extensions: ["mp3", "wav", "m4a", "aac", "ogg", "flac", "webm"],
},
{ name: "All Files", extensions: ["*"] },
],
properties: ["openFile"],
});

if (result.canceled || result.filePaths.length === 0) {
return { success: false, canceled: true };
}

const approvedPath = await approveReadableAudioPath(result.filePaths[0]);
if (!approvedPath) {
return {
success: false,
message: "Selected file is not a supported audio file",
};
}

return {
success: true,
path: approvedPath,
};
} catch (error) {
console.error("Failed to open audio file picker:", error);
return {
success: false,
message: "Failed to open audio file picker",
error: String(error),
};
}
});

ipcMain.handle("reveal-in-folder", async (_, filePath: string) => {
try {
// shell.showItemInFolder doesn't return a value, it throws on error
Expand Down
3 changes: 3 additions & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ contextBridge.exposeInMainWorld("electronAPI", {
openVideoFilePicker: () => {
return ipcRenderer.invoke("open-video-file-picker");
},
openAudioFilePicker: () => {
return ipcRenderer.invoke("open-audio-file-picker");
},
Comment thread
imAaryash marked this conversation as resolved.
setCurrentVideoPath: (path: string) => {
return ipcRenderer.invoke("set-current-video-path", path);
},
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"dnd-timeline": "^2.2.0",
"emoji-picker-react": "^4.16.1",
"fix-webm-duration": "^1.0.6",
"fuse.js": "^7.3.0",
"gif.js": "^0.2.0",
"gsap": "^3.13.0",
"lucide-react": "^0.545.0",
Expand Down
Binary file added public/audio/hooks/annotation.mp3
Binary file not shown.
Binary file added public/audio/hooks/blur.wav
Binary file not shown.
Binary file added public/audio/hooks/speed.mp3
Binary file not shown.
Binary file added public/audio/hooks/trim.wav
Binary file not shown.
Binary file added public/audio/hooks/zoom.wav
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion scripts/i18n-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import path from "node:path";

const LOCALES_DIR = path.resolve("src/i18n/locales");
const BASE_LOCALE = "en";
const COMPARE_LOCALES = ["zh-CN", "zh-TW", "es", "tr", "ko-KR"];

function getKeys(obj, prefix = "") {
const keys = [];
Expand Down
Loading
Loading