Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

Merge branch 'main' into main

Sida569f7037a92
diff --cc dist-electron/main.js
index 74485ec0,fe1bfeb2..d7413f4d
--- a/dist-electron/main.js
+++ b/dist-electron/main.js
@@@ -1,66 -1,45 +1,50 @@@
-import { ipcMain as i, screen as b, BrowserWindow as R, desktopCapturer as V, shell as O, app as d, dialog as S, nativeImage as W, Tray as k, Menu as L } from "electron";
-import { fileURLToPath as E } from "node:url";
-import o from "node:path";
-import P from "node:fs/promises";
-const _ = o.dirname(E(import.meta.url)), U = o.join(_, ".."), m = process.env.VITE_DEV_SERVER_URL, T = o.join(U, "dist");
-let f = null;
-i.on("hud-overlay-hide", () => {
- f && !f.isDestroyed() && f.minimize();
+import { ipcMain, screen, BrowserWindow, desktopCapturer, shell, app, dialog, nativeImage, Tray, Menu } from "electron";
+import { fileURLToPath } from "node:url";
+import path from "node:path";
+import fs from "node:fs/promises";
+const __dirname$2 = path.dirname(fileURLToPath(import.meta.url));
+const APP_ROOT = path.join(__dirname$2, "..");
+const VITE_DEV_SERVER_URL$1 = process.env["VITE_DEV_SERVER_URL"];
+const RENDERER_DIST$1 = path.join(APP_ROOT, "dist");
+let hudOverlayWindow = null;
+ipcMain.on("hud-overlay-hide", () => {
+ if (hudOverlayWindow && !hudOverlayWindow.isDestroyed()) {
+ hudOverlayWindow.minimize();
+ }
});
- function createHudOverlayWindow() {
- const primaryDisplay = screen.getPrimaryDisplay();
- const { workArea } = primaryDisplay;
- const windowWidth = 500;
- const windowHeight = 100;
- const x = Math.floor(workArea.x + (workArea.width - windowWidth) / 2);
- const y = Math.floor(workArea.y + workArea.height - windowHeight - 5);
- const win = new BrowserWindow({
- width: windowWidth,
- height: windowHeight,
+ function C() {
+ const r = b.getPrimaryDisplay(), { workArea: n } = r, c = 500, w = 100, y = Math.floor(n.x + (n.width - c) / 2), h = Math.floor(n.y + n.height - w - 5), e = new R({
+ width: c,
+ height: w,
minWidth: 500,
maxWidth: 500,
minHeight: 100,
maxHeight: 100,
- x,
- y,
- frame: false,
- transparent: true,
- resizable: false,
- alwaysOnTop: true,
- skipTaskbar: true,
- hasShadow: false,
+ x: y,
+ y: h,
+ frame: !1,
+ transparent: !0,
+ resizable: !1,
+ alwaysOnTop: !0,
+ skipTaskbar: !0,
+ hasShadow: !1,
webPreferences: {
- preload: o.join(_, "preload.mjs"),
- nodeIntegration: !1,
- contextIsolation: !0,
- backgroundThrottling: !1
+ preload: path.join(__dirname$2, "preload.mjs"),
+ nodeIntegration: false,
+ contextIsolation: true,
+ backgroundThrottling: false
}
});
- win.webContents.on("did-finish-load", () => {
- win == null ? void 0 : win.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString());
- });
- hudOverlayWindow = win;
- win.on("closed", () => {
- if (hudOverlayWindow === win) {
- hudOverlayWindow = null;
- }
- });
- if (VITE_DEV_SERVER_URL$1) {
- win.loadURL(VITE_DEV_SERVER_URL$1 + "?windowType=hud-overlay");
- } else {
- win.loadFile(path.join(RENDERER_DIST$1, "index.html"), {
- query: { windowType: "hud-overlay" }
- });
- }
- return win;
+ return e.webContents.on("did-finish-load", () => {
+ e == null || e.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString());
+ }), f = e, e.on("closed", () => {
+ f === e && (f = null);
+ }), m ? e.loadURL(m + "?windowType=hud-overlay") : e.loadFile(o.join(T, "index.html"), {
+ query: { windowType: "hud-overlay" }
+ }), e;
}
- function createEditorWindow() {
- const win = new BrowserWindow({
+ function M() {
+ const r = new R({
width: 1200,
height: 800,
minWidth: 800,
@@@ -74,158 -53,108 +58,108 @@@
title: "OpenScreen",
backgroundColor: "#000000",
webPreferences: {
- preload: o.join(_, "preload.mjs"),
- nodeIntegration: !1,
- contextIsolation: !0,
- webSecurity: !1,
- backgroundThrottling: !1
+ preload: path.join(__dirname$2, "preload.mjs"),
+ nodeIntegration: false,
+ contextIsolation: true,
+ webSecurity: false,
+ backgroundThrottling: false
}
});
- win.maximize();
- win.webContents.on("did-finish-load", () => {
- win == null ? void 0 : win.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString());
- });
- if (VITE_DEV_SERVER_URL$1) {
- win.loadURL(VITE_DEV_SERVER_URL$1 + "?windowType=editor");
- } else {
- win.loadFile(path.join(RENDERER_DIST$1, "index.html"), {
- query: { windowType: "editor" }
- });
- }
- return win;
+ return r.maximize(), r.webContents.on("did-finish-load", () => {
+ r == null || r.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString());
+ }), m ? r.loadURL(m + "?windowType=editor") : r.loadFile(o.join(T, "index.html"), {
+ query: { windowType: "editor" }
+ }), r;
}
- function createSourceSelectorWindow() {
- const { width, height } = screen.getPrimaryDisplay().workAreaSize;
- const win = new BrowserWindow({
+ function A() {
+ const { width: r, height: n } = b.getPrimaryDisplay().workAreaSize, c = new R({
width: 620,
height: 420,
minHeight: 350,
maxHeight: 500,
- x: Math.round((width - 620) / 2),
- y: Math.round((height - 420) / 2),
- frame: false,
- resizable: false,
- alwaysOnTop: true,
- transparent: true,
+ x: Math.round((r - 620) / 2),
+ y: Math.round((n - 420) / 2),
+ frame: !1,
+ resizable: !1,
+ alwaysOnTop: !0,
+ transparent: !0,
backgroundColor: "#00000000",
webPreferences: {
- preload: o.join(_, "preload.mjs"),
- nodeIntegration: !1,
- contextIsolation: !0
+ preload: path.join(__dirname$2, "preload.mjs"),
+ nodeIntegration: false,
+ contextIsolation: true
}
});
- if (VITE_DEV_SERVER_URL$1) {
- win.loadURL(VITE_DEV_SERVER_URL$1 + "?windowType=source-selector");
- } else {
- win.loadFile(path.join(RENDERER_DIST$1, "index.html"), {
- query: { windowType: "source-selector" }
- });
- }
- return win;
+ return m ? c.loadURL(m + "?windowType=source-selector") : c.loadFile(o.join(T, "index.html"), {
+ query: { windowType: "source-selector" }
+ }), c;
}
- let selectedSource = null;
- function registerIpcHandlers(createEditorWindow2, createSourceSelectorWindow2, getMainWindow, getSourceSelectorWindow, onRecordingStateChange) {
- ipcMain.handle("get-sources", async (_, opts) => {
- const sources = await desktopCapturer.getSources(opts);
- return sources.map((source) => ({
- id: source.id,
- name: source.name,
- display_id: source.display_id,
- thumbnail: source.thumbnail ? source.thumbnail.toDataURL() : null,
- appIcon: source.appIcon ? source.appIcon.toDataURL() : null
- }));
- });
- ipcMain.handle("select-source", (_, source) => {
- selectedSource = source;
- const sourceSelectorWin = getSourceSelectorWindow();
- if (sourceSelectorWin) {
- sourceSelectorWin.close();
- }
- return selectedSource;
- });
- ipcMain.handle("get-selected-source", () => {
- return selectedSource;
- });
- ipcMain.handle("open-source-selector", () => {
- const sourceSelectorWin = getSourceSelectorWindow();
- if (sourceSelectorWin) {
- sourceSelectorWin.focus();
+ let v = null;
+ function H(r, n, c, w, y) {
+ i.handle("get-sources", async (e, s) => (await V.getSources(s)).map((t) => ({
+ id: t.id,
+ name: t.name,
+ display_id: t.display_id,
+ thumbnail: t.thumbnail ? t.thumbnail.toDataURL() : null,
+ appIcon: t.appIcon ? t.appIcon.toDataURL() : null
+ }))), i.handle("select-source", (e, s) => {
+ v = s;
+ const a = w();
+ return a && a.close(), v;
+ }), i.handle("get-selected-source", () => v), i.handle("open-source-selector", () => {
+ const e = w();
+ if (e) {
+ e.focus();
return;
}
- createSourceSelectorWindow2();
- });
- ipcMain.handle("switch-to-editor", () => {
- const mainWin = getMainWindow();
- if (mainWin) {
- mainWin.close();
- }
- createEditorWindow2();
- });
- ipcMain.handle("store-recorded-video", async (_, videoData, fileName) => {
+ n();
+ }), i.handle("switch-to-editor", () => {
+ const e = c();
+ e && e.close(), r();
+ }), i.handle("store-recorded-video", async (e, s, a) => {
try {
- const videoPath = path.join(RECORDINGS_DIR, fileName);
- await fs.writeFile(videoPath, Buffer.from(videoData));
- currentVideoPath = videoPath;
- return {
- success: true,
- path: videoPath,
+ const t = o.join(p, a);
+ return await P.writeFile(t, Buffer.from(s)), h = t, {
+ success: !0,
+ path: t,
message: "Video stored successfully"
};
- } catch (error) {
- console.error("Failed to store video:", error);
- return {
- success: false,
+ } catch (t) {
+ return console.error("Failed to store video:", t), {
+ success: !1,
message: "Failed to store video",
- error: String(error)
+ error: String(t)
};
}
- });
- ipcMain.handle("get-recorded-video-path", async () => {
+ }), i.handle("get-recorded-video-path", async () => {
try {
- const files = await fs.readdir(RECORDINGS_DIR);
- const videoFiles = files.filter((file) => file.endsWith(".webm"));
- if (videoFiles.length === 0) {
- return { success: false, message: "No recorded video found" };
- }
- const latestVideo = videoFiles.sort().reverse()[0];
- const videoPath = path.join(RECORDINGS_DIR, latestVideo);
- return { success: true, path: videoPath };
- } catch (error) {
- console.error("Failed to get video path:", error);
- return { success: false, message: "Failed to get video path", error: String(error) };
+ const s = (await P.readdir(p)).filter((j) => j.endsWith(".webm"));
+ if (s.length === 0)
+ return { success: !1, message: "No recorded video found" };
+ const a = s.sort().reverse()[0];
+ return { success: !0, path: o.join(p, a) };
+ } catch (e) {
+ return console.error("Failed to get video path:", e), { success: !1, message: "Failed to get video path", error: String(e) };
}
- });
- ipcMain.handle("set-recording-state", (_, recording) => {
- const source = selectedSource || { name: "Screen" };
- if (onRecordingStateChange) {
- onRecordingStateChange(recording, source.name);
- }
- });
- ipcMain.handle("open-external-url", async (_, url) => {
+ }), i.handle("set-recording-state", (e, s) => {
+ y && y(s, (v || { name: "Screen" }).name);
+ }), i.handle("open-external-url", async (e, s) => {
try {
- await shell.openExternal(url);
- return { success: true };
- } catch (error) {
- console.error("Failed to open URL:", error);
- return { success: false, error: String(error) };
+ return await O.openExternal(s), { success: !0 };
+ } catch (a) {
+ return console.error("Failed to open URL:", a), { success: !1, error: String(a) };
}
- });
- ipcMain.handle("get-asset-base-path", () => {
+ }), i.handle("get-asset-base-path", () => {
try {
- if (app.isPackaged) {
- return path.join(process.resourcesPath, "assets");
- }
- return path.join(app.getAppPath(), "public", "assets");
- } catch (err) {
- console.error("Failed to resolve asset base path:", err);
- return null;
+ return d.isPackaged ? o.join(process.resourcesPath, "assets") : o.join(d.getAppPath(), "public", "assets");
+ } catch (e) {
+ return console.error("Failed to resolve asset base path:", e), null;
}
- });
- ipcMain.handle("save-exported-video", async (_, videoData, fileName) => {
+ }), i.handle("save-exported-video", async (e, s, a) => {
try {
- const result = await dialog.showSaveDialog({
+ const t = await S.showSaveDialog({
title: "Save Exported Video",
- defaultPath: path.join(app.getPath("downloads"), fileName),
+ defaultPath: o.join(d.getPath("downloads"), a),
filters: [
{ name: "MP4 Video", extensions: ["mp4"] }
],
@@@ -280,55 -199,32 +204,51 @@@
};
}
});
- let h = null;
- i.handle("set-current-video-path", (e, s) => (h = s, { success: !0 })), i.handle("get-current-video-path", () => h ? { success: !0, path: h } : { success: !1 }), i.handle("clear-current-video-path", () => (h = null, { success: !0 }));
+ let currentVideoPath = null;
+ ipcMain.handle("set-current-video-path", (_, path2) => {
+ currentVideoPath = path2;
+ return { success: true };
+ });
+ ipcMain.handle("get-current-video-path", () => {
+ return currentVideoPath ? { success: true, path: currentVideoPath } : { success: false };
+ });
+ ipcMain.handle("clear-current-video-path", () => {
+ currentVideoPath = null;
+ return { success: true };
+ });
+ ipcMain.handle("get-platform", () => {
+ return process.platform;
+ });
}
-const z = o.dirname(E(import.meta.url)), p = o.join(d.getPath("userData"), "recordings");
-async function N() {
+const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
+const RECORDINGS_DIR = path.join(app.getPath("userData"), "recordings");
+async function ensureRecordingsDir() {
try {
- await fs.mkdir(RECORDINGS_DIR, { recursive: true });
- console.log("RECORDINGS_DIR:", RECORDINGS_DIR);
- console.log("User Data Path:", app.getPath("userData"));
- } catch (error) {
- console.error("Failed to create recordings directory:", error);
+ await P.mkdir(p, { recursive: !0 }), console.log("RECORDINGS_DIR:", p), console.log("User Data Path:", d.getPath("userData"));
+ } catch (r) {
+ console.error("Failed to create recordings directory:", r);
}
}
-process.env.APP_ROOT = o.join(z, "..");
-const B = process.env.VITE_DEV_SERVER_URL, Y = o.join(process.env.APP_ROOT, "dist-electron"), D = o.join(process.env.APP_ROOT, "dist");
-process.env.VITE_PUBLIC = B ? o.join(process.env.APP_ROOT, "public") : D;
-let l = null, g = null, u = null, x = "";
-function I() {
- l = C();
+process.env.APP_ROOT = path.join(__dirname$1, "..");
+const VITE_DEV_SERVER_URL = process.env["VITE_DEV_SERVER_URL"];
+const MAIN_DIST = path.join(process.env.APP_ROOT, "dist-electron");
+const RENDERER_DIST = path.join(process.env.APP_ROOT, "dist");
+process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL ? path.join(process.env.APP_ROOT, "public") : RENDERER_DIST;
+let mainWindow = null;
+let sourceSelectorWindow = null;
+let tray = null;
+let selectedSourceName = "";
+function createWindow() {
+ mainWindow = createHudOverlayWindow();
}
- function createTray() {
- const iconPath = path.join(process.env.VITE_PUBLIC || RENDERER_DIST, "rec-button.png");
- let icon = nativeImage.createFromPath(iconPath);
- icon = icon.resize({ width: 24, height: 24, quality: "best" });
- tray = new Tray(icon);
- updateTrayMenu();
+ function q() {
+ const r = o.join(process.env.VITE_PUBLIC || D, "rec-button.png");
+ let n = W.createFromPath(r);
+ n = n.resize({ width: 24, height: 24, quality: "best" }), u = new k(n), F();
}
- function updateTrayMenu() {
- if (!tray) return;
- const menuTemplate = [
+ function F() {
+ if (!u) return;
+ const r = [
{
label: "Stop Recording",
click: () => {
diff --cc src/components/video-editor/KeyboardShortcutsHelp.tsx
index bab08296,369146a1..3edbd045
--- a/src/components/video-editor/KeyboardShortcutsHelp.tsx
+++ b/src/components/video-editor/KeyboardShortcutsHelp.tsx
@@@ -51,8 -33,12 +55,12 @@@ export function KeyboardShortcutsHelp(
</div>
<div className="flex items-center justify-between">
<span className="text-slate-400">Zoom Timeline</span>
- <kbd className="px-1 py-0.5 bg-white/5 border border-white/10 rounded text-[#34B27B] font-mono">⌘ + Scroll</kbd>
+ <kbd className="px-1 py-0.5 bg-white/5 border border-white/10 rounded text-[#34B27B] font-mono">{shortcuts.zoom}</kbd>
</div>
+ <div className="flex items-center justify-between">
+ <span className="text-slate-400">Pause/Play</span>
+ <kbd className="px-1 py-0.5 bg-white/5 border border-white/10 rounded text-[#34B27B] font-mono">Space</kbd>
+ </div>
</div>
</div>
</div>