diff --git a/.gitignore b/.gitignore index 0d6c31d..74645ea 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,9 @@ /renderer/out/ # production -/dist +/dist/ +/export/electron +/export/common # misc .DS_Store diff --git a/common/feature-flags.ts b/common/feature-flags.ts new file mode 100644 index 0000000..b2466c4 --- /dev/null +++ b/common/feature-flags.ts @@ -0,0 +1,7 @@ +type FeatureFlags = { + APP_STORE_BUILD: boolean; +}; + +export const featureFlags: FeatureFlags = { + APP_STORE_BUILD: true, +}; diff --git a/electron/index.ts b/electron/index.ts index 1502784..0b7dc60 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -1,7 +1,7 @@ import prepareNext from "electron-next"; import { autoUpdater } from "electron-updater"; import log from "electron-log"; -import { app, ipcMain, protocol, net } from "electron"; +import { app, ipcMain, protocol } from "electron"; import COMMAND from "./constants/commands"; import logit from "./utils/logit"; import openFolder from "./commands/open-folder"; @@ -18,7 +18,7 @@ import batchUpscayl from "./commands/batch-upscayl"; import doubleUpscayl from "./commands/double-upscayl"; import autoUpdate from "./commands/auto-update"; import sharp from "sharp"; -import { getPlatform } from "./utils/get-device-specs"; +import { featureFlags } from "../common/feature-flags"; // INITIALIZATION log.initialize({ preload: true }); @@ -51,7 +51,8 @@ app.on("window-all-closed", () => { }); // ! ENABLE THIS FOR MACOS APP STORE BUILD -if (getPlatform() === "mac") { +if (featureFlags.APP_STORE_BUILD) { + logit("🚀 APP STORE BUILD ENABLED"); app.commandLine.appendSwitch("in-process-gpu"); } @@ -73,4 +74,6 @@ ipcMain.on(COMMAND.FOLDER_UPSCAYL, batchUpscayl); ipcMain.on(COMMAND.DOUBLE_UPSCAYL, doubleUpscayl); -// autoUpdater.on("update-downloaded", autoUpdate); +if (!featureFlags.APP_STORE_BUILD) { + autoUpdater.on("update-downloaded", autoUpdate); +} diff --git a/electron/main-window.ts b/electron/main-window.ts index 8336adc..65cd1a1 100644 --- a/electron/main-window.ts +++ b/electron/main-window.ts @@ -2,23 +2,14 @@ import { BrowserWindow, shell } from "electron"; import { getPlatform } from "./utils/get-device-specs"; import { join } from "path"; import COMMAND from "./constants/commands"; -import { - overwrite, - setCustomModelsFolderPath, - setFolderPath, - setImagePath, - setOutputFolderPath, - setOverwrite, - setCompression, - setSaveOutputFolder, - fetchLocalStorage, -} from "./utils/config-variables"; +import { fetchLocalStorage } from "./utils/config-variables"; import electronIsDev from "electron-is-dev"; import { format } from "url"; let mainWindow: BrowserWindow | undefined; const createMainWindow = () => { + console.log("📂 DIRNAME", __dirname); mainWindow = new BrowserWindow({ icon: join(__dirname, "build", "icon.png"), width: 1300, diff --git a/export/build/background.png b/export/build/background.png new file mode 100644 index 0000000..2a17807 Binary files /dev/null and b/export/build/background.png differ diff --git a/export/build/icon.icns b/export/build/icon.icns new file mode 100644 index 0000000..9cd9699 Binary files /dev/null and b/export/build/icon.icns differ diff --git a/main/build/icon.png b/export/build/icon.png similarity index 100% rename from main/build/icon.png rename to export/build/icon.png diff --git a/main/build/icon.icns b/main/build/icon.icns deleted file mode 100644 index e89f9e8..0000000 Binary files a/main/build/icon.icns and /dev/null differ diff --git a/main/utils/listener/customModelsSelect.js b/main/utils/listener/customModelsSelect.js deleted file mode 100644 index ae9290a..0000000 --- a/main/utils/listener/customModelsSelect.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const electron_1 = require("electron"); -const commands_1 = __importDefault(require("../../commands")); -function default_1({ mainWindow, customModelsFolderPath, logit, slash, getModels, }) { - electron_1.ipcMain.handle(commands_1.default.SELECT_CUSTOM_MODEL_FOLDER, (event, message) => __awaiter(this, void 0, void 0, function* () { - const { canceled, filePaths: folderPaths } = yield electron_1.dialog.showOpenDialog({ - properties: ["openDirectory"], - title: "Select Custom Models Folder", - defaultPath: customModelsFolderPath, - }); - if (canceled) { - logit("🚫 Select Custom Models Folder Operation Cancelled"); - return null; - } - else { - customModelsFolderPath = folderPaths[0]; - if (!folderPaths[0].endsWith(slash + "models") && - !folderPaths[0].endsWith(slash + "models" + slash)) { - logit("❌ Invalid Custom Models Folder Detected: Not a 'models' folder"); - const options = { - type: "error", - title: "Invalid Folder", - message: "Please make sure that the folder name is 'models' and nothing else.", - buttons: ["OK"], - }; - electron_1.dialog.showMessageBoxSync(options); - return null; - } - mainWindow.webContents.send(commands_1.default.CUSTOM_MODEL_FILES_LIST, getModels(customModelsFolderPath)); - logit("📁 Custom Folder Path: ", customModelsFolderPath); - return customModelsFolderPath; - } - })); -} -exports.default = default_1; diff --git a/main/utils/listener/doubleUpscayl.js b/main/utils/listener/doubleUpscayl.js deleted file mode 100644 index 3af7ba9..0000000 --- a/main/utils/listener/doubleUpscayl.js +++ /dev/null @@ -1,139 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const electron_1 = require("electron"); -const commands_1 = __importDefault(require("../../commands")); -const path_1 = require("path"); -const upscayl_1 = require("../../upscayl"); -const getArguments_1 = require("../getArguments"); -const jimp_1 = __importDefault(require("jimp")); -function default_1({ mainWindow, slash, logit, childProcesses, stopped, modelsPath, customModelsFolderPath, saveOutputFolder, outputFolderPath, quality, defaultModels, }) { - electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __awaiter(this, void 0, void 0, function* () { - const model = payload.model; - let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)[1] || ""); - let outputDir = payload.outputPath; - if (saveOutputFolder === true && outputFolderPath) { - outputDir = outputFolderPath; - } - const gpuId = payload.gpuId; - const saveImageAs = payload.saveImageAs; - const isDefaultModel = defaultModels.includes(model); - // COPY IMAGE TO TMP FOLDER - const fullfileName = payload.imagePath.split(slash).slice(-1)[0]; - const fileName = (0, path_1.parse)(fullfileName).name; - const outFile = outputDir + - slash + - fileName + - "_upscayl_16x_" + - model + - "." + - saveImageAs; - let scale = "4"; - if (model.includes("x2")) { - scale = "2"; - } - else if (model.includes("x3")) { - scale = "3"; - } - else { - scale = "4"; - } - // UPSCALE - let upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getDoubleUpscaleArguments)(inputDir, fullfileName, outFile, isDefaultModel ? modelsPath : customModelsFolderPath !== null && customModelsFolderPath !== void 0 ? customModelsFolderPath : modelsPath, model, gpuId, saveImageAs, scale), logit); - childProcesses.push(upscayl); - stopped = false; - let failed = false; - let isAlpha = false; - let failed2 = false; - const onData = (data) => { - // CONVERT DATA TO STRING - data = data.toString(); - // SEND UPSCAYL PROGRESS TO RENDERER - mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_PROGRESS, data); - // IF PROGRESS HAS ERROR, UPSCAYL FAILED - if (data.includes("invalid gpu") || data.includes("failed")) { - failed = true; - } - if (data.includes("has alpha channel")) { - isAlpha = true; - } - }; - const onError = (data) => { - data.toString(); - // SEND UPSCAYL PROGRESS TO RENDERER - mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_PROGRESS, data); - // SET FAILED TO TRUE - failed = true; - return; - }; - const onData2 = (data) => { - // CONVERT DATA TO STRING - data = data.toString(); - // SEND UPSCAYL PROGRESS TO RENDERER - mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_PROGRESS, data); - // IF PROGRESS HAS ERROR, UPSCAYL FAILED - if (data.includes("invalid gpu") || data.includes("failed")) { - failed2 = true; - } - }; - const onError2 = (data) => { - data.toString(); - // SEND UPSCAYL PROGRESS TO RENDERER - mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_PROGRESS, data); - // SET FAILED TO TRUE - failed2 = true; - return; - }; - const onClose2 = (code) => __awaiter(this, void 0, void 0, function* () { - if (!failed2 && !stopped) { - logit("💯 Done upscaling"); - logit("♻ Scaling and converting now..."); - const originalImage = yield jimp_1.default.read(inputDir + slash + fullfileName); - try { - const newImage = yield jimp_1.default.read(isAlpha ? outFile + ".png" : outFile); - try { - newImage - .scaleToFit(originalImage.getWidth() * parseInt(payload.scale), originalImage.getHeight() * parseInt(payload.scale)) - .quality(100 - quality) - .write(isAlpha ? outFile + ".png" : outFile); - mainWindow.setProgressBar(-1); - mainWindow.webContents.send(commands_1.default.DOUBLE_UPSCAYL_DONE, isAlpha ? outFile + ".png" : outFile); - } - catch (error) { - logit("❌ Error converting to PNG: ", error); - onError(error); - } - } - catch (error) { - logit("❌ Error reading original image metadata", error); - onError(error); - } - } - }); - upscayl.process.stderr.on("data", onData); - upscayl.process.on("error", onError); - upscayl.process.on("close", (code) => { - // IF NOT FAILED - if (!failed && !stopped) { - // UPSCALE - let upscayl2 = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getDoubleUpscaleSecondPassArguments)(isAlpha, outFile, isDefaultModel ? modelsPath : customModelsFolderPath !== null && customModelsFolderPath !== void 0 ? customModelsFolderPath : modelsPath, model, gpuId, saveImageAs, scale), logit); - childProcesses.push(upscayl2); - upscayl2.process.stderr.on("data", onData2); - upscayl2.process.on("error", onError2); - upscayl2.process.on("close", onClose2); - } - }); - })); -} -exports.default = default_1; diff --git a/main/utils/listener/folderUpscayl.js b/main/utils/listener/folderUpscayl.js deleted file mode 100644 index e421037..0000000 --- a/main/utils/listener/folderUpscayl.js +++ /dev/null @@ -1,72 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const electron_1 = require("electron"); -const commands_1 = __importDefault(require("../../commands")); -const upscayl_1 = require("../../upscayl"); -const getArguments_1 = require("../getArguments"); -const fs_1 = __importDefault(require("fs")); -function default_1({ mainWindow, logit, childProcesses, stopped, modelsPath, customModelsFolderPath, saveOutputFolder, outputFolderPath, defaultModels, }) { - electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __awaiter(this, void 0, void 0, function* () { - // GET THE MODEL - const model = payload.model; - const gpuId = payload.gpuId; - const saveImageAs = payload.saveImageAs; - const scale = payload.scale; - // GET THE IMAGE DIRECTORY - let inputDir = payload.batchFolderPath; - // GET THE OUTPUT DIRECTORY - let outputDir = payload.outputPath; - if (saveOutputFolder === true && outputFolderPath) { - outputDir = outputFolderPath; - } - if (!fs_1.default.existsSync(outputDir)) { - fs_1.default.mkdirSync(outputDir, { recursive: true }); - } - const isDefaultModel = defaultModels.includes(model); - // UPSCALE - const upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getBatchArguments)(inputDir, outputDir, isDefaultModel ? modelsPath : customModelsFolderPath !== null && customModelsFolderPath !== void 0 ? customModelsFolderPath : modelsPath, model, gpuId, saveImageAs, scale), logit); - childProcesses.push(upscayl); - stopped = false; - let failed = false; - const onData = (data) => { - data = data.toString(); - mainWindow.webContents.send(commands_1.default.FOLDER_UPSCAYL_PROGRESS, data.toString()); - if (data.includes("invalid gpu") || data.includes("failed")) { - logit("❌ INVALID GPU OR INVALID FILES IN FOLDER - FAILED"); - failed = true; - upscayl.kill(); - } - }; - const onError = (data) => { - mainWindow.webContents.send(commands_1.default.FOLDER_UPSCAYL_PROGRESS, data.toString()); - failed = true; - upscayl.kill(); - return; - }; - const onClose = () => { - if (!failed && !stopped) { - logit("💯 Done upscaling"); - mainWindow.webContents.send(commands_1.default.FOLDER_UPSCAYL_DONE, outputDir); - } - else { - upscayl.kill(); - } - }; - upscayl.process.stderr.on("data", onData); - upscayl.process.on("error", onError); - upscayl.process.on("close", onClose); - })); -} -exports.default = default_1; diff --git a/main/utils/listener/getModelsList.js b/main/utils/listener/getModelsList.js deleted file mode 100644 index c09a604..0000000 --- a/main/utils/listener/getModelsList.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const electron_1 = require("electron"); -const commands_1 = __importDefault(require("../../commands")); -function default_1({ mainWindow, customModelsFolderPath, logit, getModels, }) { - electron_1.ipcMain.on(commands_1.default.GET_MODELS_LIST, (event, payload) => __awaiter(this, void 0, void 0, function* () { - if (payload) { - customModelsFolderPath = payload; - logit("📁 Custom Models Folder Path: ", customModelsFolderPath); - mainWindow.webContents.send(commands_1.default.CUSTOM_MODEL_FILES_LIST, getModels(payload)); - } - })); -} -exports.default = default_1; diff --git a/main/utils/listener/imageUpscayl.js b/main/utils/listener/imageUpscayl.js deleted file mode 100644 index 8df33e9..0000000 --- a/main/utils/listener/imageUpscayl.js +++ /dev/null @@ -1,118 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const electron_1 = require("electron"); -const commands_1 = __importDefault(require("../../commands")); -const path_1 = require("path"); -const upscayl_1 = require("../../upscayl"); -const jimp_1 = __importDefault(require("jimp")); -const getArguments_1 = require("../getArguments"); -const fs_1 = __importDefault(require("fs")); -function default_1({ mainWindow, slash, logit, childProcesses, stopped, modelsPath, customModelsFolderPath, saveOutputFolder, outputFolderPath, quality, defaultModels, folderPath, }) { - electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(this, void 0, void 0, function* () { - const model = payload.model; - const gpuId = payload.gpuId; - const saveImageAs = payload.saveImageAs; - let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)[1] || ""); - let outputDir = folderPath || payload.outputPath; - if (saveOutputFolder === true && outputFolderPath) { - outputDir = outputFolderPath; - } - const isDefaultModel = defaultModels.includes(model); - const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, ""); - const fileName = (0, path_1.parse)(fullfileName).name; - const fileExt = (0, path_1.parse)(fullfileName).ext; - let scale = "4"; - if (model.includes("x2")) { - scale = "2"; - } - else if (model.includes("x3")) { - scale = "3"; - } - else { - scale = "4"; - } - const outFile = outputDir + - slash + - fileName + - "_upscayl_" + - payload.scale + - "x_" + - model + - "." + - saveImageAs; - // UPSCALE - if (fs_1.default.existsSync(outFile)) { - // If already upscayled, just output that file - logit("✅ Already upscayled at: ", outFile); - mainWindow.webContents.send(commands_1.default.UPSCAYL_DONE, outFile); - } - else { - const upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getSingleImageArguments)(inputDir, fullfileName, outFile, isDefaultModel ? modelsPath : customModelsFolderPath !== null && customModelsFolderPath !== void 0 ? customModelsFolderPath : modelsPath, model, scale, gpuId, saveImageAs), logit); - childProcesses.push(upscayl); - stopped = false; - let isAlpha = false; - let failed = false; - const onData = (data) => { - logit("image upscayl: ", data.toString()); - mainWindow.setProgressBar(parseFloat(data.slice(0, data.length)) / 100); - data = data.toString(); - mainWindow.webContents.send(commands_1.default.UPSCAYL_PROGRESS, data.toString()); - if (data.includes("invalid gpu") || data.includes("failed")) { - logit("❌ INVALID GPU OR FAILED"); - failed = true; - } - if (data.includes("has alpha channel")) { - logit("📢 INCLUDES ALPHA CHANNEL, CHANGING OUTFILE NAME!"); - isAlpha = true; - } - }; - const onError = (data) => { - mainWindow.webContents.send(commands_1.default.UPSCAYL_PROGRESS, data.toString()); - failed = true; - return; - }; - const onClose = () => __awaiter(this, void 0, void 0, function* () { - if (!failed && !stopped) { - logit("💯 Done upscaling"); - logit("♻ Scaling and converting now..."); - const originalImage = yield jimp_1.default.read(inputDir + slash + fullfileName); - try { - const newImage = yield jimp_1.default.read(isAlpha ? outFile + ".png" : outFile); - try { - newImage - .scaleToFit(originalImage.getWidth() * parseInt(payload.scale), originalImage.getHeight() * parseInt(payload.scale)) - .quality(100 - quality) - .write(isAlpha ? outFile + ".png" : outFile); - mainWindow.setProgressBar(-1); - mainWindow.webContents.send(commands_1.default.UPSCAYL_DONE, isAlpha ? outFile + ".png" : outFile); - } - catch (error) { - logit("❌ Error converting to PNG: ", error); - onError(error); - } - } - catch (error) { - logit("❌ Error reading original image metadata", error); - onError(error); - } - } - }); - upscayl.process.stderr.on("data", onData); - upscayl.process.on("error", onError); - upscayl.process.on("close", onClose); - } - })); -} -exports.default = default_1; diff --git a/main/utils/listener/selectFile.js b/main/utils/listener/selectFile.js deleted file mode 100644 index 1fcc9d5..0000000 --- a/main/utils/listener/selectFile.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const electron_1 = require("electron"); -const commands_1 = __importDefault(require("../../commands")); -function default_1({ mainWindow, imagePath, logit }) { - return electron_1.ipcMain.handle(commands_1.default.SELECT_FILE, () => __awaiter(this, void 0, void 0, function* () { - const { canceled, filePaths } = yield electron_1.dialog.showOpenDialog({ - properties: ["openFile", "multiSelections"], - title: "Select Image", - defaultPath: imagePath, - }); - if (canceled) { - logit("🚫 File Operation Cancelled"); - return null; - } - else { - imagePath = filePaths[0]; - let isValid = false; - // READ SELECTED FILES - filePaths.forEach((file) => { - // log.log("Files in Folder: ", file); - if (file.endsWith(".png") || - file.endsWith(".jpg") || - file.endsWith(".jpeg") || - file.endsWith(".webp") || - file.endsWith(".JPG") || - file.endsWith(".PNG") || - file.endsWith(".JPEG") || - file.endsWith(".WEBP")) { - isValid = true; - } - }); - if (!isValid) { - logit("❌ Invalid File Detected"); - const options = { - type: "error", - title: "Invalid File", - message: "The selected file is not a valid image. Make sure you select a '.png', '.jpg', or '.webp' file.", - }; - electron_1.dialog.showMessageBoxSync(mainWindow, options); - return null; - } - logit("📄 Selected File Path: ", filePaths[0]); - // CREATE input AND upscaled FOLDER - return filePaths[0]; - } - })); -} -exports.default = default_1; diff --git a/main/utils/listener/selectFolder.js b/main/utils/listener/selectFolder.js deleted file mode 100644 index 407a130..0000000 --- a/main/utils/listener/selectFolder.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const electron_1 = require("electron"); -const commands_1 = __importDefault(require("../../commands")); -function default_1({ folderPath, logit }) { - electron_1.ipcMain.handle(commands_1.default.SELECT_FOLDER, (event, message) => __awaiter(this, void 0, void 0, function* () { - const { canceled, filePaths: folderPaths } = yield electron_1.dialog.showOpenDialog({ - properties: ["openDirectory"], - defaultPath: folderPath, - }); - if (canceled) { - logit("🚫 Select Folder Operation Cancelled"); - return null; - } - else { - folderPath = folderPaths[0]; - logit("📁 Selected Folder Path: ", folderPath); - return folderPaths[0]; - } - })); -} -exports.default = default_1; diff --git a/next.config.js b/next.config.js index 4ce82dc..cc99621 100644 --- a/next.config.js +++ b/next.config.js @@ -6,6 +6,9 @@ const nextConfig = { images: { unoptimized: true, }, + experimental: { + externalDir: true, + }, }; module.exports = nextConfig; diff --git a/package.json b/package.json index cfa00ef..0d354d0 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "KDE", "Gnome" ], - "main": "main/index.js", + "main": "export/electron/index.js", "scripts": { "clean": "rimraf dist renderer/.next renderer/out", "start": "tsc && electron .", @@ -180,7 +180,7 @@ "target": [ "nsis" ], - "icon": "main/build/icon.png" + "icon": "build/icon.png" }, "nsis": { "allowToChangeInstallationDirectory": true, @@ -189,7 +189,7 @@ "perMachine": true }, "files": [ - "main", + "export", "renderer/out" ] }, diff --git a/renderer/components/settings-tab/index.tsx b/renderer/components/settings-tab/index.tsx index 452477f..5e1ce1c 100644 --- a/renderer/components/settings-tab/index.tsx +++ b/renderer/components/settings-tab/index.tsx @@ -21,7 +21,7 @@ import OverwriteToggle from "./OverwriteToggle"; import { UpscaylCloudModal } from "../UpscaylCloudModal"; import { ResetSettings } from "./ResetSettings"; import ProcessImageToggle from "./ProcessImageToggle"; -import { FLAGS } from "@/utils/flags"; +import { featureFlags } from "@common/feature-flags"; interface IProps { batchMode: boolean; @@ -190,7 +190,7 @@ function SettingsTab({ target="_blank"> Read Wiki Guide - {!FLAGS.APP_STORE_BUILD && } + {!featureFlags.APP_STORE_BUILD && } { // STATES @@ -505,7 +505,7 @@ const Home = () => { )} {/* HEADER */}
- {!dontShowCloudModal && !FLAGS.APP_STORE_BUILD && ( + {!dontShowCloudModal && !featureFlags.APP_STORE_BUILD && (