Compare commits

..

No commits in common. "a0a90f24280438e97e64865fcd3f392b11c22d42" and "497c73725cc1683d7d085bbaee94a7e1340a5a9b" have entirely different histories.

14 changed files with 20 additions and 47 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -2,7 +2,8 @@
"appId": "com.alikia2x.openrewind", "appId": "com.alikia2x.openrewind",
"mac": { "mac": {
"category": "public.app-category.productivity", "category": "public.app-category.productivity",
"target": "dmg" "target": "dmg",
"files": ["bin/macos"]
}, },
"productName": "OpenRewind", "productName": "OpenRewind",
"directories": { "directories": {

View File

@ -1,6 +1,6 @@
{ {
"name": "openrewind", "name": "openrewind",
"version": "0.8.0", "version": "0.6.0",
"type": "module", "type": "module",
"description": "Your second brain, superpowered.", "description": "Your second brain, superpowered.",
"main": "dist/electron/index.js", "main": "dist/electron/index.js",
@ -41,7 +41,6 @@
"image-size": "^1.1.1", "image-size": "^1.1.1",
"jotai": "^2.11.0", "jotai": "^2.11.0",
"memory-cache": "^0.2.0", "memory-cache": "^0.2.0",
"pino": "^9.6.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"react-i18next": "^15.1.2", "react-i18next": "^15.1.2",

View File

@ -4,8 +4,8 @@ import fs from "fs";
import path, { join } from "path"; import path, { join } from "path";
import type { EncodingTask, Frame } from "./schema"; import type { EncodingTask, Frame } from "./schema";
import sizeOf from "image-size"; import sizeOf from "image-size";
import { getEncodeCommand } from "../utils/index.js"; import { getEncodeCommand } from "../utils/video/index.js";
import { getRecordingsDir, getEncodingTempDir, getScreenshotsDir } from "../utils/index.js"; import { getRecordingsDir, getEncodingTempDir, getScreenshotsDir } from "../utils/fs/index.js";
import cache from "memory-cache"; import cache from "memory-cache";
import { ENCODING_FRAME_INTERVAL, RECORD_FRAME_RATE as FRAME_RATE } from "./consts.js"; import { ENCODING_FRAME_INTERVAL, RECORD_FRAME_RATE as FRAME_RATE } from "./consts.js";

View File

@ -2,7 +2,7 @@ import * as path from "path";
import { Database } from "better-sqlite3"; import { Database } from "better-sqlite3";
import DB from "better-sqlite3"; import DB from "better-sqlite3";
import { __dirname } from "../dirname.js"; import { __dirname } from "../dirname.js";
import { getDatabaseDir } from "../utils/index.js"; import { getDatabaseDir } from "../utils/fs/index.js";
import { migrate } from "./migrate/index.js"; import { migrate } from "./migrate/index.js";
function getLibSimpleExtensionPath() { function getLibSimpleExtensionPath() {

View File

@ -1,5 +1,5 @@
import screenshot from "screenshot-desktop"; import screenshot from "screenshot-desktop";
import { getScreenshotsDir } from "../utils/index.js"; import { getScreenshotsDir } from "../utils/fs/index.js";
import { join } from "path"; import { join } from "path";
import { Database } from "better-sqlite3"; import { Database } from "better-sqlite3";
import SqlString from "sqlstring"; import SqlString from "sqlstring";

View File

@ -2,7 +2,7 @@ import { app, BrowserWindow, screen } from "electron";
import { join } from "path"; import { join } from "path";
import { __dirname } from "./dirname.js"; import { __dirname } from "./dirname.js";
import windowStateManager from "electron-window-state"; import windowStateManager from "electron-window-state";
import { hideDock, showDock } from "./utils/index.js"; import { hideDock, showDock } from "./utils/platform/index.js";
function loadURL(window: BrowserWindow, path = "", vitePort: string) { function loadURL(window: BrowserWindow, path = "", vitePort: string) {
const dev = !app.isPackaged; const dev = !app.isPackaged;

View File

@ -16,7 +16,7 @@ import { initDatabase } from "./backend/init.js";
import { Database } from "better-sqlite3"; import { Database } from "better-sqlite3";
import { startScreenshotLoop } from "./backend/screenshot.js"; import { startScreenshotLoop } from "./backend/screenshot.js";
import { __dirname } from "./dirname.js"; import { __dirname } from "./dirname.js";
import { hideDock } from "./utils/index.js"; import { hideDock } from "./utils/platform/index.js";
import { import {
checkFramesForEncoding, checkFramesForEncoding,
deleteUnnecessaryScreenshots, deleteUnnecessaryScreenshots,
@ -24,7 +24,7 @@ import {
} from "./backend/encoding.js"; } from "./backend/encoding.js";
import honoApp from "./server/index.js"; import honoApp from "./server/index.js";
import { serve } from "@hono/node-server"; import { serve } from "@hono/node-server";
import { findAvailablePort } from "./utils/index.js"; import { findAvailablePort } from "./utils/network/index.js";
import cache from "memory-cache"; import cache from "memory-cache";
import { generate as generateAPIKey } from "@alikia/random-key"; import { generate as generateAPIKey } from "@alikia/random-key";

View File

@ -10,8 +10,8 @@ import {
getRecordingsDir, getRecordingsDir,
getScreenshotsDir, getScreenshotsDir,
waitForFileExists waitForFileExists
} from "../utils/index.js"; } from "../utils/fs/index.js";
import { immediatelyExtractFrameFromVideo } from "../utils/index.js"; import { immediatelyExtractFrameFromVideo } from "../utils/video/index.js";
import { existsSync } from "fs"; import { existsSync } from "fs";
const app = new Hono(); const app = new Hono();

View File

@ -59,15 +59,6 @@ export function getDecodingTempDir() {
return decodingTempDir; return decodingTempDir;
} }
export function getLogDir() {
const dataDir = createDataDir();
const logDir = path.join(dataDir, "logs");
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir, { recursive: true });
}
return logDir;
}
export async function waitForFileExists(filePath: string, timeout: number = 10000): Promise<void> { export async function waitForFileExists(filePath: string, timeout: number = 10000): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fs.access(filePath, fs.constants.F_OK, (err) => { fs.access(filePath, fs.constants.F_OK, (err) => {

View File

@ -2,4 +2,3 @@ export * from "./fs/index.js";
export * from "./platform/index.js"; export * from "./platform/index.js";
export * from "./video/index.js"; export * from "./video/index.js";
export * from "./network/index.js"; export * from "./network/index.js";
export * from "./logging/index.js";

View File

@ -1,10 +0,0 @@
import pino from "pino";
import { join } from "path";
import { getLogDir } from "../fs/index.js";
const logPath = join(getLogDir(), "log.json");
const dest = pino.destination(logPath);
const logger = pino(dest);
export { logger };

View File

@ -1,15 +1,14 @@
import { join } from "path"; import path from "path";
import os from "os"; import os from "os";
import { app } from "electron"; import { app } from "electron";
import { __dirname } from "../../dirname.js"; import { __dirname } from "../../dirname.js";
import { logger } from "../index.js";
export function getUserDataDir() { export function getUserDataDir() {
switch (process.platform) { switch (process.platform) {
case "win32": case "win32":
return join(process.env.APPDATA!, "OpenRewind", "Record Data"); return path.join(process.env.APPDATA!, "OpenRewind", "Record Data");
case "darwin": case "darwin":
return join( return path.join(
os.homedir(), os.homedir(),
"Library", "Library",
"Application Support", "Application Support",
@ -17,7 +16,7 @@ export function getUserDataDir() {
"Record Data" "Record Data"
); );
case "linux": case "linux":
return join(os.homedir(), ".config", "OpenRewind", "Record Data"); return path.join(os.homedir(), ".config", "OpenRewind", "Record Data");
default: default:
throw new Error("Unsupported platform"); throw new Error("Unsupported platform");
} }
@ -38,20 +37,14 @@ export function showDock() {
} }
export function getFFmpegPath() { export function getFFmpegPath() {
let path = "";
switch (process.platform) { switch (process.platform) {
case "win32": case "win32":
path = join(__dirname, "bin", process.platform, "ffmpeg.exe"); return path.join(__dirname, "bin", process.platform, "ffmpeg.exe");
break;
case "darwin": case "darwin":
path = join(__dirname, "bin", process.platform, "ffmpeg"); return path.join(__dirname, "bin", process.platform, "ffmpeg");
break;
case "linux": case "linux":
path = join(__dirname, "bin", process.platform, "ffmpeg"); return path.join(__dirname, "bin", process.platform, "ffmpeg");
break;
default: default:
throw new Error("Unsupported platform"); throw new Error("Unsupported platform");
} }
logger.info("FFmpeg path: %s", path);
return path;
} }

View File

@ -44,7 +44,7 @@ export function immediatelyExtractFrameFromVideo(
"1", "1",
`${outputPathArg}` `${outputPathArg}`
]; ];
const ffmpeg = spawn(getFFmpegPath(), args); const ffmpeg = spawn("ffmpeg", args);
ffmpeg.stdout.on("data", (data) => { ffmpeg.stdout.on("data", (data) => {
console.log(data.toString()); console.log(data.toString());
}); });