Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/2.11.0 #71

Merged
merged 32 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f1bf5f2
Pull in changes from main app
jliddev Sep 10, 2023
51835b3
Update patch-notes.service.ts
jliddev Sep 10, 2023
32b87bc
Update package.json
jliddev Sep 10, 2023
4a8e006
Fix lint
jliddev Sep 10, 2023
768c901
Roll back electron builder
jliddev Sep 11, 2023
0c6bd0d
Attempt to fix #62
jliddev Sep 12, 2023
1fb1aa0
Update main.ts
jliddev Sep 12, 2023
61fd44c
Update de.json
Nils89 Oct 19, 2023
eded6a0
Update OW
jliddev Nov 21, 2023
7d05720
App runs but styles are jacked
jliddev Nov 21, 2023
a481651
Fix some CSS issues
jliddev Nov 27, 2023
8f4fc6a
Update to latest logger
jliddev Nov 27, 2023
4f8308b
Update angular
jliddev Nov 27, 2023
853d618
Update electron-all-build.yml
jliddev Nov 27, 2023
ae84203
update node-gyp
jliddev Nov 27, 2023
04d0c8b
Tighten up some css
jliddev Nov 28, 2023
0b8e571
Add GPU cache buster attempt
jliddev Nov 28, 2023
4acf597
Update package.json
jliddev Nov 28, 2023
c4fc5c3
Update webview.component.ts
jliddev Nov 28, 2023
8d05cff
Attempt to improve handling of scanned addons that may be sub-addons
jliddev Nov 28, 2023
d3fbfde
Update .gitignore
jliddev Nov 28, 2023
1a46d4b
Update package.json
jliddev Nov 28, 2023
33555a3
Fix several CSS issues
jliddev Nov 30, 2023
c57b1e7
Fix snackbar layout
jliddev Nov 30, 2023
d0f84f6
Update package.json
jliddev Nov 30, 2023
4a951b5
Adjust the progress button
jliddev Nov 30, 2023
9a40497
Update progress-bar.component.ts
jliddev Nov 30, 2023
fc70c45
Update OW
jliddev Jan 31, 2024
61757ea
Update package.json
jliddev Feb 3, 2024
d123806
Merge pull request #64 from Nils89/patch-1
jliddev Feb 3, 2024
faac082
Update patch-notes.service.ts
jliddev Feb 3, 2024
44b7f18
Merge branch 'feature/2.11.0' of https://github.com/WowUp/WowUp.CF in…
jliddev Feb 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/electron-all-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest,"macos-11"]
node-version: [16.x]
node-version: [20.x]

steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions wowup-electron/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/app-builds
/release
/build
/app/utils/*.js
main.js
ipc-events.js
app-updater.js
Expand Down
2 changes: 1 addition & 1 deletion wowup-electron/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular-electron:build"
"buildTarget": "angular-electron:build"
}
},
"test": {
Expand Down
2 changes: 1 addition & 1 deletion wowup-electron/app/app-updater.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app, BrowserWindow, ipcMain } from "electron";
import * as log from "electron-log";
import * as log from "electron-log/main";
import { autoUpdater } from "electron-updater";
import { IPC_APP_CHECK_UPDATE, IPC_APP_INSTALL_UPDATE, IPC_APP_UPDATE_STATE } from "../src/common/constants";
import { AppUpdateDownloadProgress, AppUpdateEvent, AppUpdateState } from "../src/common/wowup/models";
Expand Down
2 changes: 1 addition & 1 deletion wowup-electron/app/curse-folder-scanner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from "path";
import * as _ from "lodash";
import * as log from "electron-log";
import * as log from "electron-log/main";
import { exists, readDirRecursive } from "./file.utils";
import * as fsp from "fs/promises";
import { firstValueFrom, from, mergeMap, toArray } from "rxjs";
Expand Down
2 changes: 1 addition & 1 deletion wowup-electron/app/file.utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exec } from "child_process";
import * as log from "electron-log";
import * as log from "electron-log/main";
import * as fsp from "fs/promises";
import { max, sumBy } from "lodash";
import * as path from "path";
Expand Down
7 changes: 4 additions & 3 deletions wowup-electron/app/ipc-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
shell,
systemPreferences,
} from "electron";
import * as log from "electron-log";
import * as log from "electron-log/main";
import * as globrex from "globrex";
import * as _ from "lodash";
import { nanoid } from "nanoid";
Expand Down Expand Up @@ -151,6 +151,7 @@ async function getSymlinkDirs(basePath: string, files: fs.Dirent[]): Promise<Sym
return _.filter(symlinkDirs, (symDir) => symDir.isDir);
}

/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
function handle(
channel: RendererChannels,
listener: (event: IpcMainInvokeEvent, ...args: any[]) => Promise<void> | any
Expand Down Expand Up @@ -499,9 +500,9 @@ export function initializeIpcHandlers(window: BrowserWindow): void {
handle("decode-product-db", async (evt, filePath: string) => {
const productDbData = await fsp.readFile(filePath);
const productDb = ProductDb.decode(productDbData);
setImmediate(() => {
setTimeout(() => {
console.log("productDb", JSON.stringify(productDb));
});
},1);

return productDb;
});
Expand Down
63 changes: 33 additions & 30 deletions wowup-electron/app/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dialog } from "electron";
import { app, BrowserWindow, BrowserWindowConstructorOptions, powerMonitor } from "electron";
import * as log from "electron-log";
import * as log from "electron-log/main";
import { find } from "lodash";
import * as minimist from "minimist";
import { arch as osArch, release as osRelease, type as osType } from "os";
Expand Down Expand Up @@ -44,12 +44,14 @@ import { initializeDefaultPreferences } from "./preferences";
import { PUSH_NOTIFICATION_EVENT, pushEvents } from "./push";
import { getPreferenceStore, initializeStoreIpcHandlers } from "./stores";
import * as windowState from "./window-state";
import { validateGpuCache } from "./utils/gpu-cache-buster";

// LOGGING SETUP
// Override the default log path so they aren't a pain to find on Mac
const LOG_PATH = join(app.getPath("userData"), "logs");
app.setAppLogsPath(LOG_PATH);
log.transports.file.resolvePath = (variables: log.PathVariables) => {
log.initialize();
log.transports.file.resolvePathFn = (variables) => {
return join(LOG_PATH, variables.fileName ?? "log-file.txt");
};
log.info("Main starting");
Expand All @@ -73,6 +75,8 @@ if (platform.isWin) {
require("win-ca");
}

validateGpuCache(app)

// VARIABLES
const startedAt = Date.now();
const argv = minimist(process.argv.slice(1), {
Expand Down Expand Up @@ -152,16 +156,35 @@ function getProtocol(arg: string) {
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
// Added 400 ms to fix the black background issue while using transparent window. More details at https://github.com/electron/electron/issues/15947
if (app.isReady()) {
log.info(`App already ready: ${Date.now() - startedAt}ms`);
} else {
app.once("ready", () => {
app
.whenReady()
.then(() => {
powerMonitor.on("resume", () => {
log.info("powerMonitor resume");
win?.webContents?.send(IPC_POWER_MONITOR_RESUME);
});

powerMonitor.on("suspend", () => {
log.info("powerMonitor suspend");
win?.webContents?.send(IPC_POWER_MONITOR_SUSPEND);
});

powerMonitor.on("lock-screen", () => {
log.info("powerMonitor lock-screen");
win?.webContents?.send(IPC_POWER_MONITOR_LOCK);
});

powerMonitor.on("unlock-screen", () => {
log.info("powerMonitor unlock-screen");
win?.webContents?.send(IPC_POWER_MONITOR_UNLOCK);
});

log.info(`App ready: ${Date.now() - startedAt}ms`);
// setTimeout(() => {
createWindow();
// }, 400);
})
.catch((e) => {
log.error("whenready failed", e);
});
}

app.on("before-quit", () => {
windowState.saveWindowConfig(win);
Expand Down Expand Up @@ -207,26 +230,6 @@ if (platform.isMac) {
});
}

powerMonitor.on("resume", () => {
log.info("powerMonitor resume");
win?.webContents?.send(IPC_POWER_MONITOR_RESUME);
});

powerMonitor.on("suspend", () => {
log.info("powerMonitor suspend");
win?.webContents?.send(IPC_POWER_MONITOR_SUSPEND);
});

powerMonitor.on("lock-screen", () => {
log.info("powerMonitor lock-screen");
win?.webContents?.send(IPC_POWER_MONITOR_LOCK);
});

powerMonitor.on("unlock-screen", () => {
log.info("powerMonitor unlock-screen");
win?.webContents?.send(IPC_POWER_MONITOR_UNLOCK);
});

let lastCrash = 0;

const crashMap = new Map<string, number>();
Expand All @@ -247,7 +250,7 @@ function onChildProcessCrashed(details: Electron.Details) {
if (ct >= 3) {
dialog.showErrorBox(
"Child Process Failure",
`Child process ${details.serviceName} has crashed too many times, app will now exit`
`Child process ${details.serviceName} has crashed too many times, app will now exit`,
);
app.quit();
}
Expand Down
2 changes: 1 addition & 1 deletion wowup-electron/app/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "../src/common/constants";
import { WowUpReleaseChannelType } from "../src/common/wowup/wowup-release-channel-type";
import { getPreferenceStore } from "./stores";
import * as log from "electron-log";
import * as log from "electron-log/main";

export function initializeDefaultPreferences() {
const isBetaBuild = app.getVersion().toLowerCase().indexOf("beta") != -1;
Expand Down
7 changes: 1 addition & 6 deletions wowup-electron/app/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/// <reference path="../src/common/wowup.d.ts" />

import { ipcRenderer, IpcRendererEvent, shell, OpenExternalOptions } from "electron";
import * as log from "electron-log";
import { join } from "path";
import * as log from "electron-log/renderer";
import * as platform from "./platform";

if (!process.isMainFrame) {
Expand Down Expand Up @@ -38,10 +37,6 @@ const LOG_PATH = getArg("log-path");
const USER_DATA_PATH = getArg("user-data-path");
const BASE_BG_COLOR = getArg("base-bg-color");

log.transports.file.resolvePath = (variables: log.PathVariables) => {
return join(LOG_PATH, variables.fileName);
};

function onRendererEvent(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void) {
ipcRenderer.on(channel, listener);
}
Expand Down
2 changes: 1 addition & 1 deletion wowup-electron/app/push.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as log from "electron-log";
import * as log from "electron-log/main";
import { EventEmitter } from "events";

export const PUSH_NOTIFICATION_EVENT = "push-notification";
Expand Down
81 changes: 81 additions & 0 deletions wowup-electron/app/utils/gpu-cache-buster.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import * as fs from "fs";
import { join } from "path";
import * as log from "electron-log/main";

/**
* There appears to be some issue with Ubuntu and the GPUCache system of electron
* https://github.com/WowUp/WowUp.CF/issues/63
*
* User from an app with similar issue discovered deleting the folder and letting the app rebuild it appears to fix it.
* https://github.com/ferdium/ferdium-app/issues/1265
*
* Added in a version file to the GPU cache folder that should get checked and delete the folder before the initial
* cache is generated hopefully fixing this issue
*/

const GPU_CACHE_FOLDER = "GPUCache";
const GPU_VERSION_FILE = ".wuversion";

interface VersionFileData {
version: string;
}

export function validateGpuCache(app: Electron.App) {
try {
const cacheDir = join(app.getPath("userData"), GPU_CACHE_FOLDER);
const cacheExists = fileExists(cacheDir);
if (cacheExists) {
const files = fs.readdirSync(cacheDir);
const verFile = files.find((f) => f === GPU_VERSION_FILE);
if (verFile === undefined) {
removeDir(cacheDir);
} else {
const verFile = readVersionFile(cacheDir);
if (verFile.version !== app.getVersion()) {
removeDir(cacheDir);
} else {
return;
}
}
}

fs.mkdirSync(cacheDir);
createVersionFile(app.getVersion(), cacheDir);
} catch (e) {
log.error("failed to validate GPU Cache", e);
}
// app.relaunch();
}

function removeDir(path: string) {
fs.rmSync(path, { force: true, recursive: true });
}

function fileExists(path: string) {
try {
fs.accessSync(path);
return true;
} catch (e) {
log.warn(`File does not exist: ${path}`);
log.warn(e.message);
return false;
}
}

function readVersionFile(cacheDir: string): VersionFileData {
const filePath = join(cacheDir, GPU_VERSION_FILE);
const fileData = fs.readFileSync(filePath, { encoding: "utf-8" });
const versionData: VersionFileData = JSON.parse(fileData);
return versionData;
}

function createVersionFile(version: string, cacheDir: string) {
const versionData: VersionFileData = {
version,
};

const filePath = join(cacheDir, GPU_VERSION_FILE);
const verFileData = JSON.stringify(versionData);

fs.writeFileSync(filePath, verFileData, { encoding: "utf-8" });
}
2 changes: 1 addition & 1 deletion wowup-electron/app/window-state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app, BrowserWindow, BrowserWindowConstructorOptions, Display, Rectangle, screen } from "electron";
import * as log from "electron-log";
import * as log from "electron-log/main";

import { IPC_WINDOW_RESUME, MIN_VISIBLE_ON_SCREEN, WINDOW_MIN_HEIGHT, WINDOW_MIN_WIDTH } from "../src/common/constants";
import * as platform from "./platform";
Expand Down
Loading
Loading