Skip to content

Commit

Permalink
Package upgrades across the board
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Jan 27, 2025
1 parent d5ceef5 commit 44ddad9
Show file tree
Hide file tree
Showing 13 changed files with 11,467 additions and 54,453 deletions.
65,728 changes: 11,382 additions & 54,346 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@typescript-eslint/parser": "^4.33.0",
"babel-eslint": "^10.0.3",
"cross-env": "^7.0.3",
"electron": "^12.1.0",
"electron": "^33.3.1",
"electron-builder": "^25.1.8",
"eslint": "^7.18.0",
"eslint-plugin-node": "^11.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/app/global.js

This file was deleted.

37 changes: 19 additions & 18 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@nuclear/ui": "^0.6.42",
"@testing-library/jest-dom": "^5.16.4",
"@types/react-window": "^1.8.5",
"@types/webpack": "5.28.5",
"ajv": "^6.12.5",
"bluebird": "3.5.3",
"butterchurn-presets": "^2.4.7",
Expand Down Expand Up @@ -78,18 +79,18 @@
"redux-promise": "^0.6.0",
"redux-thunk": "^2.4.1",
"regenerator-runtime": "^0.13.2",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^2.0.4",
"semantic-ui-css": "2.5.0",
"semantic-ui-react": "2.1.5",
"typesafe-actions": "^4.4.2"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.10.4",
"@babel/core": "7.26.7",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-decorators": "7.25.9",
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
"@babel/preset-env": "7.26.7",
"@babel/preset-react": "7.26.3",
"@babel/preset-typescript": "7.26.0",
"@testing-library/dom": "^8.17.1",
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^11.2.7",
Expand All @@ -99,12 +100,12 @@
"@types/react-router-dom": "^5.1.7",
"@types/redux-actions": "^2.6.1",
"ava": "^2.4.0",
"babel-loader": "^8.1.0",
"babel-loader": "9.2.1",
"cross-env": "^7.0.3",
"css-loader": "^5.2.7",
"css-loader": "7.1.2",
"eslint": "^7.18.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.0",
"html-webpack-plugin": "5.6.3",
"i18next-json-sync": "^2.3.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.5.1",
Expand All @@ -113,18 +114,18 @@
"react-beautiful-dnd-test-utils": "^4.1.0",
"react-hot-loader": "^4.13.1",
"redux-mock-store": "^1.5.4",
"sass": "^1.69.5",
"sass-loader": "^10.4.1",
"style-loader": "^2.0.0",
"sass": "1.83.4",
"sass-loader": "16.0.4",
"style-loader": "4.0.0",
"svg-inline-loader": "^0.8.2",
"ts-jest": "^27.1.3",
"ts-loader": "^8.0.3",
"ts-node": "^10.7.0",
"typescript": "^4.2.4",
"url-loader": "^4.1.1",
"utf-8-validate": "^5.0.2",
"webpack": "^5.89.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.15.1"
"webpack": "5.97.1",
"webpack-cli": "6.0.1",
"webpack-dev-server": "5.2.0"
}
}
6 changes: 3 additions & 3 deletions packages/app/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ module.exports = (env) => {
path: BUILD_DIR,
filename: '[name].[contenthash].js',
sourceMapFilename: '[name].[contenthash].map',
chunkFilename: '[id].[contenthash].js'
chunkFilename: '[id].[contenthash].js',
globalObject: 'this'
};
const optimization: webpack.Configuration['optimization'] = {
moduleIds: 'named' as const,
Expand Down Expand Up @@ -119,7 +120,6 @@ module.exports = (env) => {
)
),
new webpack.ProvidePlugin({
global: require.resolve('./global.js'),
EventEmitter: ['events', 'EventEmitter']
}),
new webpack.ContextReplacementPlugin(
Expand Down Expand Up @@ -246,7 +246,7 @@ module.exports = (env) => {
]
},
plugins,
target: 'web'
target: 'electron-renderer'
};

if (IS_DEV) {
Expand Down
11 changes: 6 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
"coverage": "jest --silent --coverage"
},
"dependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.9.4",
"@babel/core": "7.26.7",
"@babel/preset-env": "7.26.7",
"@babel/preset-react": "7.26.3",
"@distube/ytdl-core": "4.15.9",
"@nuclear/scanner": "^0.6.42",
"@electron/remote": "^2.1.2",
"@nuclear/main": "^0.6.42",
"@nuclear/scanner": "^0.6.42",
"@supabase/supabase-js": "^1.35.4",
"ajv": "^6.12.5",
"bandcamp-scraper": "1.4.1",
Expand Down Expand Up @@ -62,4 +63,4 @@
"ts-node": "^10.7.0",
"typescript": "^4.2.4"
}
}
}
73 changes: 32 additions & 41 deletions packages/core/src/logger/nuclear-logger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-console */
import { app, BrowserWindow, ipcMain, IpcMainEvent, IpcRendererEvent, session, Session, WebContents } from 'electron';
import { app, BrowserWindow, ipcMain, IpcMainEvent, ipcRenderer, IpcRendererEvent } from 'electron';
import { performance } from 'node:perf_hooks';
import { resolve } from 'node:path';
import process from 'node:process';

const isMain = process.type === 'browser';
Expand All @@ -14,15 +13,15 @@ const errorChannel = '__ELECTRON_NUCLEAR_LOGGER_ERROR__';
const updateChannel = '__ELECTRON_NUCLEAR_LOGGER_UPDATE__';
const defaultsNameSpace = '__ELECTRON_NUCLEAR_LOGGER_DEFAULTS__';

const preloadScript = resolve(__dirname, 'preload.js');

const logLevels = {
info: 0,
warn: 1,
error: 2
};

type LogLevel = keyof typeof logLevels;
type LogArgs = unknown[];
type ConsoleMethod = (...args: LogArgs) => void;

interface NuclearLoggerOptions {
name?: string;
Expand All @@ -36,12 +35,10 @@ interface NuclearLoggerDefaults {
logLevel: LogLevel;
}

let remoteMain: typeof import('@electron/remote/main') | null = null;
if (isMain) {
(global as any)[defaultsNameSpace] = {
ignore: null,
shouldHookConsole: false,
logLevel: isDevelopment ? logLevels.info : logLevels.warn
};
// Only import in main process
remoteMain = require('@electron/remote/main');
}

let isConsoleHooked = false;
Expand Down Expand Up @@ -87,13 +84,13 @@ class NuclearLogger {
return `%c${this.#name.padStart(longestNameLength)}%c ›`;
}

log(...args: any[]): void {
log(...args: LogArgs): void {
if (logLevels[this.options.logLevel] > logLevels.info) {
return;
}

if (isRenderer) {
(window as any).electronApi.send(logChannel, args);
ipcRenderer.send(logChannel, args);
} else if (this.#name) {
args.unshift(this.#getPrefix(), `color: ${this.#prefixColor}`, 'color: inherit');
}
Expand All @@ -105,13 +102,13 @@ class NuclearLogger {
this.console.log(...args);
}

warn(...args: any[]): void {
warn(...args: LogArgs): void {
if (logLevels[this.options.logLevel] > logLevels.warn) {
return;
}

if (isRenderer) {
(window as any).electronApi.send(warnChannel, args);
ipcRenderer.send(warnChannel, args);
} else if (this.#name) {
args.unshift(this.#getPrefix(), `color: ${this.#prefixColor}`, 'color: yellow');
}
Expand All @@ -123,13 +120,13 @@ class NuclearLogger {
this.console.warn(...args);
}

error(...args: any[]): void {
error(...args: LogArgs): void {
if (logLevels[this.options.logLevel] > logLevels.error) {
return;
}

if (isRenderer) {
(window as any).electronApi.send(errorChannel, args);
ipcRenderer.send(errorChannel, args);
} else if (this.#name) {
args.unshift(this.#getPrefix(), `color: ${this.#prefixColor}`, 'color: red');
}
Expand All @@ -156,7 +153,7 @@ class NuclearLogger {
this.#timers.delete(label);

if (isRenderer) {
(window as any).electronApi.send(logChannel, args);
ipcRenderer.send(logChannel, args);
} else if (this.#name) {
args.unshift(this.#getPrefix(), `color: ${this.#prefixColor}`, 'color: inherit');
}
Expand Down Expand Up @@ -207,10 +204,13 @@ class NuclearLogger {
}

getDefaults(): NuclearLoggerDefaults {
const defaults = isMain
? (global as any)[defaultsNameSpace]
: (window as any).electronApi.getGlobal(defaultsNameSpace);
return { ...defaults };
if (isMain) {
return { ...global[defaultsNameSpace] };
}

// eslint-disable-next-line @typescript-eslint/no-var-requires
const remote = require('@electron/remote');
return { ...remote.getGlobal(defaultsNameSpace) };
}

hookConsole(options: { main?: boolean; renderer?: boolean } = { main: isMain, renderer: isRenderer }): () => void {
Expand All @@ -229,8 +229,8 @@ class NuclearLogger {
isConsoleHooked = true;

for (const key of hookableMethods) {
(_console as any)[key] = console[key as keyof Console];
(console as any)[key] = (this[key as keyof NuclearLogger] as Function).bind(this);
_console[key] = console[key as keyof Console];
console[key] = (this[key as keyof NuclearLogger] as Function).bind(this);
}
}

Expand All @@ -247,8 +247,8 @@ class NuclearLogger {
if (hookThisConsole) {
isConsoleHooked = false;
for (const key of hookableMethods) {
(console as any)[key] = (_console as any)[key];
(_console as any)[key] = null;
console[key] = _console[key] as ConsoleMethod;
_console[key] = undefined;
}
}

Expand All @@ -261,7 +261,7 @@ class NuclearLogger {

private hookRenderers(flag: boolean): void {
if (isMain) {
(global as any)[defaultsNameSpace].shouldHookConsole = flag;
global[defaultsNameSpace].shouldHookConsole = flag;
for (const win of BrowserWindow.getAllWindows()) {
win.webContents.send(updateChannel, flag);
}
Expand All @@ -277,41 +277,32 @@ if (isMain) {
const rendererLogger = new NuclearLogger({ name: 'renderer' });

if (ipcMain.listenerCount(logChannel) === 0) {
ipcMain.on(logChannel, (_event: IpcMainEvent, data: any[]) => {
ipcMain.on(logChannel, (_event: IpcMainEvent, data: LogArgs) => {
rendererLogger.log(...data);
});
}

if (ipcMain.listenerCount(warnChannel) === 0) {
ipcMain.on(warnChannel, (_event: IpcMainEvent, data: any[]) => {
ipcMain.on(warnChannel, (_event: IpcMainEvent, data: LogArgs) => {
rendererLogger.warn(...data);
});
}

if (ipcMain.listenerCount(errorChannel) === 0) {
ipcMain.on(errorChannel, (_event: IpcMainEvent, data: any[]) => {
ipcMain.on(errorChannel, (_event: IpcMainEvent, data: LogArgs) => {
rendererLogger.error(...data);
});
}

(async () => {
await (app as any).whenReady();

const mySession: Session = session.defaultSession;
const currentPreloads = mySession.getPreloads();
if (!currentPreloads.includes(preloadScript)) {
mySession.setPreloads([...currentPreloads, preloadScript]);
}
})();

} else if (isRenderer) {
(window as any).electronApi.onReceive(updateChannel, (_event: IpcRendererEvent, flag: boolean) => {
ipcRenderer.on(updateChannel, (_event: IpcRendererEvent, flag: boolean) => {
if (flag) {
logger.hookConsole();
} else {
isConsoleHooked = false;
for (const key of hookableMethods) {
(console as any)[key] = (_console as any)[key];
(_console as any)[key] = null;
console[key] = _console[key] as ConsoleMethod;
_console[key] = undefined;
}
}
});
Expand Down
9 changes: 5 additions & 4 deletions packages/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"homepage": "https://github.com/nukeop/nuclear#readme",
"dependencies": {
"@electron/remote": "^2.1.2",
"@nuclear/core": "^0.6.42",
"@nuclear/scanner": "^0.6.42",
"autobind-decorator": "^2.4.0",
Expand Down Expand Up @@ -74,7 +75,7 @@
"@types/split2": "^2.1.6",
"@types/tiny-async-pool": "^1.0.0",
"@types/uuid": "^3.4.6",
"@types/webpack": "^4.41.0",
"@types/webpack": "5.28.5",
"copy-webpack-plugin": "^12.0.2",
"cross-env": "^7.0.3",
"electron-builder": "25.1.8",
Expand All @@ -88,13 +89,13 @@
"type-fest": "^0.8.1",
"typescript": "^4.2.4",
"utf-8-validate": "^5.0.2",
"webpack": "^5.68.0",
"webpack-cli": "^4.9.2"
"webpack": "5.97.1",
"webpack-cli": "6.0.1"
},
"optionalDependencies": {
"7zip-bin-mac": "^1.0.1",
"jsbi": "^2.0.5",
"mpris-service": "2.1.0",
"x11": "^2.3.0"
}
}
}
16 changes: 0 additions & 16 deletions packages/main/preload.js
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { contextBridge, ipcRenderer } = require('electron');

const electronApi = {
send: (channel, data) => {
ipcRenderer.send(channel, data);
},
onReceive: (channel, callback) => {
ipcRenderer.on(channel, callback);
},
getGlobal: (key) => {
return window.electronApi.getGlobal(key);
}
};

contextBridge.exposeInMainWorld('electronApi', electronApi);
2 changes: 2 additions & 0 deletions packages/main/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ app.commandLine.appendSwitch('no-sandbox');

let container: Container;

// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@electron/remote/main').initialize();
if (!app.requestSingleInstanceLock()) {
app.quit();
} else {
Expand Down
Loading

0 comments on commit 44ddad9

Please sign in to comment.