diff --git a/bun.lockb b/bun.lockb index d1b0319..a2869d8 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/gulpfile.ts b/gulpfile.ts index 6316d8a..0bf9d07 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -1,6 +1,5 @@ import gulp from "gulp"; import ts from "gulp-typescript"; -// @ts-ignore import clean from "gulp-clean"; import fs from "fs"; @@ -30,7 +29,7 @@ gulp.task("assets", () => { }); gulp.task("binary", () => { - return gulp.src("bin/**/*", { encoding: false }).pipe(gulp.dest("dist/electron/bin")); + return gulp.src(`bin/${process.platform}-${process.arch}/**/*`, { encoding: false }).pipe(gulp.dest("dist/electron/bin")); }); gulp.task("locales", () => { diff --git a/src/electron/backend/init.ts b/src/electron/backend/init.ts index 956a622..8f00b8a 100644 --- a/src/electron/backend/init.ts +++ b/src/electron/backend/init.ts @@ -2,17 +2,17 @@ import * as path from "path"; import { Database } from "better-sqlite3"; import DB from "better-sqlite3"; import { __dirname } from "../dirname.js"; -import { getDatabaseDir } from "../utils/index.js"; +import { getBinDir, getDatabaseDir } from "../utils/index.js"; import { migrate } from "./migrate/index.js"; function getLibSimpleExtensionPath() { switch (process.platform) { case "win32": - return path.join(__dirname, "bin", process.platform, "libsimple", "simple.dll"); + return path.join(getBinDir(), "libsimple", "simple.dll"); case "darwin": - return path.join(__dirname, "bin", process.platform, "libsimple", "libsimple.dylib"); + return path.join(getBinDir(), "libsimple", "libsimple.dylib"); case "linux": - return path.join(__dirname, "bin", process.platform, "libsimple", "libsimple.so"); + return path.join(getBinDir(), "libsimple", "libsimple.so"); default: throw new Error("Unsupported platform"); } diff --git a/src/electron/utils/fs/index.ts b/src/electron/utils/fs/index.ts index 01a5d0f..b32502e 100644 --- a/src/electron/utils/fs/index.ts +++ b/src/electron/utils/fs/index.ts @@ -1,6 +1,7 @@ import path from "path"; import fs from "fs"; import { getUserDataDir } from "../platform/index.js"; +import { __dirname } from "../../dirname.js"; export function createDataDir() { const dataDir = getUserDataDir(); @@ -68,6 +69,10 @@ export function getLogDir() { return logDir; } +export function getBinDir() { + return path.join(__dirname, "bin"); +} + export async function waitForFileExists(filePath: string, timeout: number = 10000): Promise { return new Promise((resolve, reject) => { fs.access(filePath, fs.constants.F_OK, (err) => { diff --git a/src/electron/utils/platform/index.ts b/src/electron/utils/platform/index.ts index cdf7a9b..a77b690 100644 --- a/src/electron/utils/platform/index.ts +++ b/src/electron/utils/platform/index.ts @@ -1,8 +1,7 @@ import { join } from "path"; import os from "os"; import { app } from "electron"; -import { __dirname } from "../../dirname.js"; -import { logger } from "../index.js"; +import { getBinDir, logger } from "../index.js"; export function getUserDataDir() { switch (process.platform) { @@ -41,13 +40,13 @@ export function getFFmpegPath() { let path = ""; switch (process.platform) { case "win32": - path = join(__dirname, "bin", process.platform, "ffmpeg.exe"); + path = join(getBinDir(), "ffmpeg.exe"); break; case "darwin": - path = join(__dirname, "bin", process.platform, "ffmpeg"); + path = join(getBinDir(), "ffmpeg"); break; case "linux": - path = join(__dirname, "bin", process.platform, "ffmpeg"); + path = join(getBinDir(), "ffmpeg"); break; default: throw new Error("Unsupported platform"); @@ -55,3 +54,7 @@ export function getFFmpegPath() { logger.info("FFmpeg path: %s", path); return path; } + +export function getOCRitPath() { + const path = join(getBinDir(), "ocrit"); +}