diff --git a/electron/index.ts b/electron/index.ts index c69b164..1ed9a20 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -24,21 +24,24 @@ log.initialize({ preload: true }); sharp.cache(false); logit("🚃 App Path: ", app.getAppPath()); -app.whenReady().then(async () => { +app.on("ready", async () => { await prepareNext("./renderer"); - createMainWindow(); - log.info("🚀 UPSCAYL EXEC PATH: ", execPath("realesrgan")); - log.info("🚀 MODELS PATH: ", modelsPath); - - protocol.handle("file:", (request) => { - const pathname = decodeURI(request.url); - return net.fetch(pathname); + app.whenReady().then(() => { + protocol.registerFileProtocol("file", (request, callback) => { + const pathname = decodeURI(request.url.replace("file:///", "")); + callback(pathname); + }); }); + createMainWindow(); + if (!electronIsDev) { autoUpdater.checkForUpdates(); } + + log.info("🚀 UPSCAYL EXEC PATH: ", execPath("realesrgan")); + log.info("🚀 MODELS PATH: ", modelsPath); }); // Quit the app once all windows are closed diff --git a/electron/main-window.ts b/electron/main-window.ts index 16e7b62..1b07f27 100644 --- a/electron/main-window.ts +++ b/electron/main-window.ts @@ -13,8 +13,9 @@ import { setSaveOutputFolder, } from "./utils/config-variables"; import electronIsDev from "electron-is-dev"; +import { format } from "url"; -let mainWindow: BrowserWindow | null; +let mainWindow: BrowserWindow | undefined; const createMainWindow = () => { mainWindow = new BrowserWindow({ @@ -36,10 +37,12 @@ const createMainWindow = () => { const url = electronIsDev ? "http://localhost:8000" - : (new URL("file:///").pathname = join( - __dirname, - "../renderer/out/index.html" - )).toString(); + : format({ + pathname: join(__dirname, "../renderer/out/index.html"), + protocol: "file:", + slashes: true, + }); + mainWindow.loadURL(url); mainWindow.webContents.setWindowOpenHandler(({ url }) => { diff --git a/package.json b/package.json index 549bf37..84761da 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,8 @@ "publish-linux-app": "tsc && npm run build && electron-builder -l --publish always", "publish-win-app": "tsc && npm run build && electron-builder -w --publish always", "publish-mac-universal-app": "tsc && npm run build && electron-builder --mac --universal --publish always", - "publish-mac-app": "tsc && npm run build && electron-builder --mac --x64 --publish always" + "publish-mac-app": "tsc && npm run build && electron-builder --mac --x64 --publish always", + "publish-mac-arm-app": "tsc && npm run build && electron-builder --mac --arm64 --publish always" }, "build": { "productName": "Upscayl", @@ -99,6 +100,7 @@ "entitlementsInherit": "resources/entitlements.mac.plist", "notarize": false, "gatekeeperAssess": false, + "mergeASARs": false, "target": [ { "target": "dmg",