From d048547ba1ce067cd082e1cfbfbef41f237466d7 Mon Sep 17 00:00:00 2001 From: Nayam Amarshe <25067102+NayamAmarshe@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:07:34 +0530 Subject: [PATCH] Fix model --- electron/index.ts | 10 +++++- electron/main-window.ts | 4 ++- electron/preload.ts | 3 +- mac-dev.json | 32 +++++++++++++++++++ package.json | 4 ++- .../upscayl-tab/select-model-dialog.tsx | 8 ++--- renderer/pages/_app.tsx | 1 + 7 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 mac-dev.json diff --git a/electron/index.ts b/electron/index.ts index 1176e58..13fb2a9 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -20,10 +20,10 @@ import autoUpdate from "./commands/auto-update"; import { FEATURE_FLAGS } from "../common/feature-flags"; import settings from "electron-settings"; import pasteImage from "./commands/paste-image"; +import path from "path"; // INITIALIZATION log.initialize({ preload: true }); -logit("🚃 App Path: ", app.getAppPath()); app.on("ready", async () => { await prepareNext("./renderer"); @@ -33,6 +33,14 @@ app.on("ready", async () => { const pathname = decodeURI(request.url.replace("file:///", "")); callback(pathname); }); + protocol.registerFileProtocol("public", (request, callback) => { + const filePath = decodeURI(request.url.replace("public:///", "")); + const asarPath = path.join(app.getAppPath(), "renderer", "out", filePath); + console.log("🚀 => asarPath:", asarPath); + + callback(asarPath); + }); + logit("🚃 App Path: ", app.getAppPath()); }); createMainWindow(); diff --git a/electron/main-window.ts b/electron/main-window.ts index 56895b5..24e4826 100644 --- a/electron/main-window.ts +++ b/electron/main-window.ts @@ -1,4 +1,4 @@ -import { BrowserWindow, shell } from "electron"; +import { app, BrowserWindow, shell } from "electron"; import { getPlatform } from "./utils/get-device-specs"; import { join } from "path"; import { ELECTRON_COMMANDS } from "../common/electron-commands"; @@ -11,6 +11,8 @@ let mainWindow: BrowserWindow | undefined; const createMainWindow = () => { console.log("📂 DIRNAME", __dirname); + console.log("🚃 App Path: ", app.getAppPath()); + mainWindow = new BrowserWindow({ icon: join(__dirname, "build", "icon.png"), width: 1300, diff --git a/electron/preload.ts b/electron/preload.ts index 466c81f..2d8268f 100644 --- a/electron/preload.ts +++ b/electron/preload.ts @@ -1,10 +1,9 @@ -import { ipcRenderer, contextBridge, app } from "electron"; +import { ipcRenderer, contextBridge } from "electron"; import { getAppVersion, getDeviceSpecs, getPlatform, } from "./utils/get-device-specs"; -import { FEATURE_FLAGS } from "@common/feature-flags"; // 'ipcRenderer' will be available in index.js with the method 'window.electron' contextBridge.exposeInMainWorld("electron", { diff --git a/mac-dev.json b/mac-dev.json new file mode 100644 index 0000000..b7eeac9 --- /dev/null +++ b/mac-dev.json @@ -0,0 +1,32 @@ +{ + "productName": "Upscayl", + "appId": "org.upscayl.Upscayl", + "buildVersion": "25.06.01", + "asar": true, + "asarUnpack": ["**/node_modules/sharp/**/*", "**/node_modules/@img/**/*"], + "extraFiles": [ + { + "from": "resources/${os}/bin", + "to": "resources/bin", + "filter": ["**/*"] + }, + { + "from": "resources/models", + "to": "resources/models", + "filter": ["**/*"] + } + ], + "mac": { + "hardenedRuntime": true, + "gatekeeperAssess": false, + "mergeASARs": false, + "minimumSystemVersion": "12.0.0", + "electronLanguages": ["en"], + "x64ArchFiles": "*", + "type": "distribution", + "icon": "build/icon.icns", + "category": "public.app-category.photography", + "identity": null, + "target": ["dir"] + } +} diff --git a/package.json b/package.json index 8f2b115..8e2080c 100644 --- a/package.json +++ b/package.json @@ -48,11 +48,12 @@ "dist:deb": "tsc && npm run build && cross-env DEBUG=* electron-builder build -l deb", "dist:rpm": "tsc && npm run build && cross-env DEBUG=* electron-builder build -l rpm", "dist:zip": "tsc && npm run build && cross-env DEBUG=* electron-builder build -l zip", - "dist:mac-zip": "tsc && npm run build && cross-env DEBUG=* electron-builder build -l zip", + "dist:mac-zip": "tsc && npm run build && electron-builder build -m --universal", "dist:dmg": "tsc && npm run build && electron-builder build -m dmg", "dist:msi": "tsc && npm run build && cross-env DEBUG=* electron-builder build -w nsis", "dist:pkg": "tsc && npm run build && cross-env DEBUG=* electron-builder build -m pkg", "dist:mac": "tsc && npm run build && electron-builder --mac --universal", + "dist:mac-dev": "tsc && npm run build && electron-builder --mac --arm64 -c mac-dev.json", "dist:mac-arm64": "tsc && npm run build && electron-builder --mac --arm64", "dist:mas": "npm run enable-store && tsc && npm run build && electron-builder --mac mas --universal -c mas.json && npm run disable-store", "dist:mas-dev": "npm run enable-store && tsc && npm run build && electron-builder --mac mas-dev --universal -c mas-dev.json && npm run disable-store", @@ -134,6 +135,7 @@ "entitlements": "resources/entitlements.mac.plist", "entitlementsInherit": "resources/entitlements.mac.plist", "provisioningProfile": "embedded.provisionprofile", + "type": null, "target": [ { "target": "dmg", diff --git a/renderer/components/sidebar/upscayl-tab/select-model-dialog.tsx b/renderer/components/sidebar/upscayl-tab/select-model-dialog.tsx index a6a64fe..f3635c6 100644 --- a/renderer/components/sidebar/upscayl-tab/select-model-dialog.tsx +++ b/renderer/components/sidebar/upscayl-tab/select-model-dialog.tsx @@ -77,12 +77,12 @@ const SelectModelDialog = () => {