1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-23 23:21:05 +01:00

Add mas build

This commit is contained in:
Nayam Amarshe 2023-11-02 20:33:21 +05:30
parent cfa9db4398
commit 85c8621d4e
14 changed files with 231 additions and 35 deletions

View File

@ -1,7 +1,9 @@
type FeatureFlags = { type FeatureFlags = {
APP_STORE_BUILD: boolean; APP_STORE_BUILD: boolean;
SHOW_UPSCAYL_CLOUD_INFO: boolean;
}; };
export const featureFlags: FeatureFlags = { export const featureFlags: FeatureFlags = {
APP_STORE_BUILD: false, APP_STORE_BUILD: true,
SHOW_UPSCAYL_CLOUD_INFO: false,
}; };

View File

@ -8,16 +8,28 @@ import slash from "../utils/slash";
import COMMAND from "../constants/commands"; import COMMAND from "../constants/commands";
import getModels from "../utils/get-models"; import getModels from "../utils/get-models";
import { getMainWindow } from "../main-window"; import { getMainWindow } from "../main-window";
import { settings } from "../utils/settings";
const customModelsSelect = async (event, message) => { const customModelsSelect = async (event, message) => {
const mainWindow = getMainWindow(); const mainWindow = getMainWindow();
if (!mainWindow) return; if (!mainWindow) return;
const { canceled, filePaths: folderPaths } = await dialog.showOpenDialog({ const {
canceled,
filePaths: folderPaths,
bookmarks,
} = await dialog.showOpenDialog({
properties: ["openDirectory"], properties: ["openDirectory"],
title: "Select Custom Models Folder", title: "Select Custom Models Folder",
defaultPath: customModelsFolderPath, defaultPath: customModelsFolderPath,
securityScopedBookmarks: true,
}); });
if (bookmarks && bookmarks.length > 0) {
logit("📁 Bookmarks: ", bookmarks);
settings.set("custom-models-bookmarks", bookmarks[0]);
}
if (canceled) { if (canceled) {
logit("🚫 Select Custom Models Folder Operation Cancelled"); logit("🚫 Select Custom Models Folder Operation Cancelled");
return null; return null;

View File

@ -2,16 +2,23 @@ import { MessageBoxOptions, dialog } from "electron";
import { getMainWindow } from "../main-window"; import { getMainWindow } from "../main-window";
import { imagePath, setImagePath } from "../utils/config-variables"; import { imagePath, setImagePath } from "../utils/config-variables";
import logit from "../utils/logit"; import logit from "../utils/logit";
import { settings } from "../utils/settings";
const selectFile = async () => { const selectFile = async () => {
const mainWindow = getMainWindow(); const mainWindow = getMainWindow();
const { canceled, filePaths } = await dialog.showOpenDialog({ const { canceled, filePaths, bookmarks } = await dialog.showOpenDialog({
properties: ["openFile", "multiSelections"], properties: ["openFile", "multiSelections"],
title: "Select Image", title: "Select Image",
defaultPath: imagePath, defaultPath: imagePath,
securityScopedBookmarks: true,
}); });
if (bookmarks && bookmarks.length > 0) {
logit("📁 Bookmarks: ", bookmarks);
settings.set("file-bookmarks", bookmarks[0]);
}
if (canceled) { if (canceled) {
logit("🚫 File Operation Cancelled"); logit("🚫 File Operation Cancelled");
return null; return null;

View File

@ -1,13 +1,24 @@
import { dialog } from "electron"; import { dialog } from "electron";
import { folderPath, setFolderPath } from "../utils/config-variables"; import { folderPath, setFolderPath } from "../utils/config-variables";
import logit from "../utils/logit"; import logit from "../utils/logit";
import { settings } from "../utils/settings";
const selectFolder = async (event, message) => { const selectFolder = async (event, message) => {
const { canceled, filePaths: folderPaths } = await dialog.showOpenDialog({ const {
canceled,
filePaths: folderPaths,
bookmarks,
} = await dialog.showOpenDialog({
properties: ["openDirectory"], properties: ["openDirectory"],
defaultPath: folderPath, defaultPath: folderPath,
securityScopedBookmarks: true,
}); });
if (bookmarks && bookmarks.length > 0) {
logit("📁 Bookmarks: ", bookmarks);
settings.set("folder-bookmarks", bookmarks[0]);
}
if (canceled) { if (canceled) {
logit("🚫 Select Folder Operation Cancelled"); logit("🚫 Select Folder Operation Cancelled");
return null; return null;

View File

@ -19,12 +19,27 @@ import doubleUpscayl from "./commands/double-upscayl";
import autoUpdate from "./commands/auto-update"; import autoUpdate from "./commands/auto-update";
import sharp from "sharp"; import sharp from "sharp";
import { featureFlags } from "../common/feature-flags"; import { featureFlags } from "../common/feature-flags";
import { settings } from "./utils/settings";
// INITIALIZATION // INITIALIZATION
log.initialize({ preload: true }); log.initialize({ preload: true });
sharp.cache(false); sharp.cache(false);
logit("🚃 App Path: ", app.getAppPath()); logit("🚃 App Path: ", app.getAppPath());
// SECURITY SCOPED BOOKMARKS
const fileBookmarks = settings.get("file-bookmarks", true);
const folderBookmarks = settings.get("folder-bookmarks", true);
const customModelsBookmarks = settings.get("custom-models-bookmarks", true);
if (fileBookmarks) {
app.startAccessingSecurityScopedResource(fileBookmarks);
}
if (folderBookmarks) {
app.startAccessingSecurityScopedResource(folderBookmarks as string);
}
if (customModelsBookmarks) {
app.startAccessingSecurityScopedResource(customModelsBookmarks as string);
}
app.on("ready", async () => { app.on("ready", async () => {
await prepareNext("./renderer"); await prepareNext("./renderer");

View File

@ -0,0 +1,36 @@
import { getMainWindow } from "../main-window";
/**
* @description LocalStorage wrapper for the main window
* @example
* import { settings } from "./utils/settings";
*
* // Get a value
* const value = settings.get("key", true);
*
* // Set a value
* settings.set("key", value);
*/
export const settings = {
get: (key: string, parse: boolean = false) => {
const mainWindow = getMainWindow();
if (!mainWindow) return;
let result = null;
mainWindow.webContents
.executeJavaScript(`localStorage.getItem("${key}");`, true)
.then((localStorageValue: any) => {
if (localStorageValue) {
result = parse ? JSON.parse(localStorageValue) : localStorageValue;
}
});
return result;
},
set: (key: string, value: any) => {
const mainWindow = getMainWindow();
if (!mainWindow) return;
mainWindow.webContents.executeJavaScript(
`localStorage.setItem("${key}", ${JSON.stringify(value)});`,
true
);
},
};

29
mas-dev.json Normal file
View File

@ -0,0 +1,29 @@
{
"appId": "org.upscayl.Upscayl",
"extraFiles": [
{
"from": "resources/${os}/bin",
"to": "resources/bin",
"filter": ["**/*"]
},
{
"from": "resources/models",
"to": "resources/models",
"filter": ["**/*"]
}
],
"mac": {
"type": "development",
"identity": null,
"mergeASARs": false,
"x64ArchFiles": "*"
},
"masDev": {
"type": "development",
"artifactName": "${name}_${version}_macos.${ext}",
"category": "public.app-category.photography",
"hardenedRuntime": false,
"entitlements": "resources/entitlements.mas.plist",
"entitlementsInherit": "resources/entitlements.mas.plist"
}
}

50
mas.json Normal file
View File

@ -0,0 +1,50 @@
{
"productName": "Upscayl",
"appId": "org.upscayl.Upscayl",
"afterSign": "./notarize.js",
"asar": true,
"asarUnpack": ["**/node_modules/sharp/**/*"],
"extraFiles": [
{
"from": "resources/${os}/bin",
"to": "resources/bin",
"filter": ["**/*"]
},
{
"from": "resources/models",
"to": "resources/models",
"filter": ["**/*"]
}
],
"buildVersion": "3.11.23",
"mas": {
"type": "distribution",
"hardenedRuntime": false,
"electronLanguages": ["en"],
"category": "public.app-category.photography",
"entitlements": "resources/entitlements.mas.plist",
"entitlementsInherit": "resources/entitlements.mas.plist",
"provisioningProfile": "prod.provisionprofile",
"mergeASARs": false,
"gatekeeperAssess": false,
"icon": "build/icon.icns",
"x64ArchFiles": "*",
"target": [
{
"target": "mas",
"arch": ["universal"]
}
]
},
"mac": {
"type": "distribution",
"mergeASARs": false,
"x64ArchFiles": "*",
"provisioningProfile": "prod.provisionprofile",
"category": "public.app-category.photography",
"hardenedRuntime": true,
"gatekeeperAssess": false,
"entitlements": "resources/entitlements.mac.plist",
"entitlementsInherit": "resources/entitlements.mac.plist"
}
}

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "upscayl", "name": "upscayl",
"version": "2.8.5", "version": "2.9.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "upscayl", "name": "upscayl",
"version": "2.8.5", "version": "2.9.3",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"dependencies": { "dependencies": {
"dotenv": "^16.3.1", "dotenv": "^16.3.1",

View File

@ -1,8 +1,13 @@
{ {
"name": "upscayl", "name": "upscayl",
"private": true, "private": true,
"version": "2.9.1", "version": "2.9.3",
"productName": "Upscayl", "productName": "Upscayl",
"author": {
"name": "Nayam Amarshe",
"email": "nayam.emikx@aleeas.com",
"url": "https://github.com/NayamAmarshe"
},
"homepage": "https://github.com/TGS963/upscayl", "homepage": "https://github.com/TGS963/upscayl",
"contributors": [ "contributors": [
{ {
@ -49,7 +54,8 @@
"dist:pkg": "tsc && npm run build && cross-env DEBUG=* electron-builder build -m pkg", "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": "tsc && npm run build && electron-builder --mac --universal",
"dist:mac-arm64": "tsc && npm run build && electron-builder --mac --arm64", "dist:mac-arm64": "tsc && npm run build && electron-builder --mac --arm64",
"dist:mac-mas": "tsc && npm run build && electron-builder --mac mas --universal", "dist:mas": "tsc && npm run build && electron-builder --mac mas --universal",
"dist:mas-dev": "tsc && npm run build && electron-builder --mac mas-dev --universal -c mas-dev.json",
"dist:win": "tsc && npm run build && electron-builder --win", "dist:win": "tsc && npm run build && electron-builder --win",
"dist:linux": "tsc && npm run build && electron-builder --linux", "dist:linux": "tsc && npm run build && electron-builder --linux",
"publish-app": "tsc && npm run build && electron-builder -wlm --publish always", "publish-app": "tsc && npm run build && electron-builder -wlm --publish always",
@ -66,6 +72,7 @@
"artifactName": "${name}-${version}-${os}.${ext}", "artifactName": "${name}-${version}-${os}.${ext}",
"afterSign": "./notarize.js", "afterSign": "./notarize.js",
"asar": true, "asar": true,
"buildVersion": "23.11.3",
"asarUnpack": [ "asarUnpack": [
"**/node_modules/sharp/**/*" "**/node_modules/sharp/**/*"
], ],
@ -99,7 +106,9 @@
], ],
"mas": { "mas": {
"hardenedRuntime": false, "hardenedRuntime": false,
"type": "distribution", "electronLanguages": [
"en"
],
"category": "public.app-category.photography", "category": "public.app-category.photography",
"entitlements": "resources/entitlements.mas.plist", "entitlements": "resources/entitlements.mas.plist",
"entitlementsInherit": "resources/entitlements.mas.inherit.plist", "entitlementsInherit": "resources/entitlements.mas.inherit.plist",
@ -123,6 +132,7 @@
"gatekeeperAssess": false, "gatekeeperAssess": false,
"entitlements": "resources/entitlements.mac.plist", "entitlements": "resources/entitlements.mac.plist",
"entitlementsInherit": "resources/entitlements.mac.plist", "entitlementsInherit": "resources/entitlements.mac.plist",
"provisioningProfile": "embedded.provisionprofile",
"mergeASARs": false, "mergeASARs": false,
"target": [ "target": [
{ {

View File

@ -245,19 +245,23 @@ function SettingsTab({
{/* RESET SETTINGS */} {/* RESET SETTINGS */}
<ResetSettings /> <ResetSettings />
<button {featureFlags.SHOW_UPSCAYL_CLOUD_INFO && (
className="mb-5 rounded-btn p-1 mx-5 bg-success shadow-lg shadow-success/40 text-slate-50 animate-pulse text-sm" <>
onClick={() => { <button
setShow(true); className="mb-5 rounded-btn p-1 mx-5 bg-success shadow-lg shadow-success/40 text-slate-50 animate-pulse text-sm"
}}> onClick={() => {
Introducing Upscayl Cloud setShow(true);
</button> }}>
Introducing Upscayl Cloud
</button>
<UpscaylCloudModal <UpscaylCloudModal
show={show} show={show}
setShow={setShow} setShow={setShow}
setDontShowCloudModal={setDontShowCloudModal} setDontShowCloudModal={setDontShowCloudModal}
/> />
</>
)}
</div> </div>
); );
} }

View File

@ -9,6 +9,7 @@ import {
noImageProcessingAtom, noImageProcessingAtom,
scaleAtom, scaleAtom,
} from "../../../atoms/userSettingsAtom"; } from "../../../atoms/userSettingsAtom";
import { featureFlags } from "@common/feature-flags";
interface IProps { interface IProps {
progress: string; progress: string;
@ -236,10 +237,21 @@ function LeftPaneImageSteps({
className="animate-step-in" className="animate-step-in"
data-tooltip-content={outputPath} data-tooltip-content={outputPath}
data-tooltip-id="tooltip"> data-tooltip-id="tooltip">
<p className="step-heading">Step 3</p> <div className="step-heading flex items-center gap-2">
<p className="mb-2 text-sm"> <span>Step 3</span>
Defaults to {!batchMode ? "Image's" : "Folder's"} path {!outputPath && (
</p> <div className="text-xs">
<span className="bg-error font-medium uppercase text-error-content rounded-btn px-2">
Not selected
</span>
</div>
)}
</div>
{!batchMode && !featureFlags.APP_STORE_BUILD && (
<p className="mb-2 text-sm">
Defaults to {!batchMode ? "Image's" : "Folder's"} path
</p>
)}
<button className="btn-primary btn" onClick={outputHandler}> <button className="btn-primary btn" onClick={outputHandler}>
Set Output Folder Set Output Folder
</button> </button>
@ -263,7 +275,7 @@ function LeftPaneImageSteps({
<button <button
className="btn-accent btn" className="btn-accent btn"
onClick={upscaylHandler} onClick={upscaylHandler}
disabled={progress.length > 0}> disabled={progress.length > 0 || !outputPath}>
{progress.length > 0 ? "Upscayling⏳" : "Upscayl"} {progress.length > 0 ? "Upscayling⏳" : "Upscayl"}
</button> </button>
</div> </div>

View File

@ -292,7 +292,9 @@ const Home = () => {
SetImagePath(path); SetImagePath(path);
var dirname = path.match(/(.*)[\/\\]/)[1] || ""; var dirname = path.match(/(.*)[\/\\]/)[1] || "";
logit("📁 Selected Image Directory: ", dirname); logit("📁 Selected Image Directory: ", dirname);
setOutputPath(dirname); if (!featureFlags.APP_STORE_BUILD) {
setOutputPath(dirname);
}
} }
}; };
@ -495,17 +497,19 @@ const Home = () => {
return ( return (
<div className="flex h-screen w-screen flex-row overflow-hidden bg-base-300"> <div className="flex h-screen w-screen flex-row overflow-hidden bg-base-300">
<div className={`flex h-screen w-128 flex-col bg-base-100`}> <div className={`flex h-screen w-128 flex-col bg-base-100`}>
<UpscaylCloudModal {featureFlags.SHOW_UPSCAYL_CLOUD_INFO && (
show={showCloudModal} <UpscaylCloudModal
setShow={setShowCloudModal} show={showCloudModal}
setDontShowCloudModal={setDontShowCloudModal} setShow={setShowCloudModal}
/> setDontShowCloudModal={setDontShowCloudModal}
/>
)}
{window.electron.platform === "mac" && ( {window.electron.platform === "mac" && (
<div className="pt-8 mac-titlebar"></div> <div className="pt-8 mac-titlebar"></div>
)} )}
{/* HEADER */} {/* HEADER */}
<Header version={version} /> <Header version={version} />
{!dontShowCloudModal && !featureFlags.APP_STORE_BUILD && ( {!dontShowCloudModal && featureFlags.SHOW_UPSCAYL_CLOUD_INFO && (
<button <button
className="mb-5 rounded-btn p-1 mx-5 bg-success shadow-lg shadow-success/40 text-slate-50 animate-pulse text-sm" className="mb-5 rounded-btn p-1 mx-5 bg-success shadow-lg shadow-success/40 text-slate-50 animate-pulse text-sm"
onClick={() => { onClick={() => {

View File

@ -6,8 +6,6 @@
<true/> <true/>
<key>com.apple.security.cs.allow-jit</key> <key>com.apple.security.cs.allow-jit</key>
<true/> <true/>
<key>com.apple.security.files.bookmarks.app-scope</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key> <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/> <true/>
<key>com.apple.security.cs.disable-library-validation</key> <key>com.apple.security.cs.disable-library-validation</key>
@ -18,6 +16,12 @@
<true/> <true/>
<key>com.apple.security.files.user-selected.read-write</key> <key>com.apple.security.files.user-selected.read-write</key>
<true/> <true/>
<key>com.apple.security.inherit</key>
<true/>
<key>com.apple.security.files.bookmarks.document-scope</key>
<true/>
<key>com.apple.security.files.bookmarks.app-scope</key>
<true/>
<key>com.apple.security.application-groups</key> <key>com.apple.security.application-groups</key>
<array> <array>
<string>W2T4W74X87.org.upscayl.Upscayl</string> <string>W2T4W74X87.org.upscayl.Upscayl</string>