1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-09-23 19:08:25 +02: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 = {
APP_STORE_BUILD: boolean;
SHOW_UPSCAYL_CLOUD_INFO: boolean;
};
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 getModels from "../utils/get-models";
import { getMainWindow } from "../main-window";
import { settings } from "../utils/settings";
const customModelsSelect = async (event, message) => {
const mainWindow = getMainWindow();
if (!mainWindow) return;
const { canceled, filePaths: folderPaths } = await dialog.showOpenDialog({
const {
canceled,
filePaths: folderPaths,
bookmarks,
} = await dialog.showOpenDialog({
properties: ["openDirectory"],
title: "Select Custom Models Folder",
defaultPath: customModelsFolderPath,
securityScopedBookmarks: true,
});
if (bookmarks && bookmarks.length > 0) {
logit("📁 Bookmarks: ", bookmarks);
settings.set("custom-models-bookmarks", bookmarks[0]);
}
if (canceled) {
logit("🚫 Select Custom Models Folder Operation Cancelled");
return null;

View File

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

View File

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

View File

@ -19,12 +19,27 @@ import doubleUpscayl from "./commands/double-upscayl";
import autoUpdate from "./commands/auto-update";
import sharp from "sharp";
import { featureFlags } from "../common/feature-flags";
import { settings } from "./utils/settings";
// INITIALIZATION
log.initialize({ preload: true });
sharp.cache(false);
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 () => {
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",
"version": "2.8.5",
"version": "2.9.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "upscayl",
"version": "2.8.5",
"version": "2.9.3",
"license": "AGPL-3.0",
"dependencies": {
"dotenv": "^16.3.1",

View File

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

View File

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

View File

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

View File

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

View File

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