mirror of
https://github.com/HugoAura/Seewo-HugoAura.git
synced 2026-06-22 08:14:26 +08:00
[Feat] Bump version to 0.1.0-beta && 1st rel
This commit is contained in:
@@ -6,22 +6,102 @@ if (!global.__HUGO_AURA__) {
|
||||
};
|
||||
}
|
||||
|
||||
const HooksManager = require("../aura/init/hook/hooksManager");
|
||||
const fs = require("fs");
|
||||
const util = require("util");
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
|
||||
const HooksManager = require("../aura/init/rendererHook/hooksManager");
|
||||
const NetworkHook = require("../aura/init/rendererHook/networkHook");
|
||||
const configManager = require("../aura/init/shared/configManager");
|
||||
const { buildIpcMain } = require("../aura/init/main/ipcHandler");
|
||||
|
||||
const initLogger = () => {
|
||||
const logDir = path.join(os.homedir(), "Documents", "HugoAura", "logs");
|
||||
if (!fs.existsSync(logDir)) {
|
||||
fs.mkdirSync(logDir, { recursive: true });
|
||||
}
|
||||
|
||||
const logFile = path.join(
|
||||
logDir,
|
||||
`main-process-${new Date().toISOString().replace(/:/g, "-")}.log`
|
||||
);
|
||||
const logStream = fs.createWriteStream(logFile, { flags: "a" });
|
||||
|
||||
const originalConsole = {
|
||||
log: console.log,
|
||||
error: console.error,
|
||||
warn: console.warn,
|
||||
info: console.info,
|
||||
debug: console.debug,
|
||||
};
|
||||
|
||||
console.log = function (...args) {
|
||||
const msg = util.format("[LOG] ", ...args) + "\n";
|
||||
logStream.write(msg);
|
||||
originalConsole.log.apply(console, args);
|
||||
};
|
||||
|
||||
console.error = function (...args) {
|
||||
const msg = util.format("[ERROR] ", ...args) + "\n";
|
||||
logStream.write(msg);
|
||||
originalConsole.error.apply(console, args);
|
||||
};
|
||||
|
||||
console.warn = function (...args) {
|
||||
const msg = util.format("[WARN] ", ...args) + "\n";
|
||||
logStream.write(msg);
|
||||
originalConsole.warn.apply(console, args);
|
||||
};
|
||||
|
||||
console.info = function (...args) {
|
||||
const msg = util.format("[INFO] ", ...args) + "\n";
|
||||
logStream.write(msg);
|
||||
originalConsole.info.apply(console, args);
|
||||
};
|
||||
|
||||
console.debug = function (...args) {
|
||||
if (!process.argv.includes("--aura-debug")) return;
|
||||
const msg = util.format("[DEBUG] ", ...args) + "\n";
|
||||
logStream.write(msg);
|
||||
originalConsole.debug.apply(console, args);
|
||||
};
|
||||
|
||||
process.on("uncaughtException", (err) => {
|
||||
console.error("UNCAUGHT EXCEPTION:", err);
|
||||
});
|
||||
|
||||
console.log("Logger initialized. Log file:", logFile);
|
||||
};
|
||||
|
||||
module.exports = function ({ central, windowName, config }) {
|
||||
process.stdout.isTTY = true;
|
||||
process.stderr.isTTY = true;
|
||||
|
||||
const electron = central(0);
|
||||
const electron = central(1);
|
||||
const app = electron.app;
|
||||
if (!global.__HUGO_AURA__.central) global.__HUGO_AURA__.central = central;
|
||||
|
||||
global.reloadApp = () => {
|
||||
app.relaunch({ args: process.argv.slice(1).concat(["--inspect 5858"]) });
|
||||
app.exit(0);
|
||||
};
|
||||
|
||||
initLogger();
|
||||
|
||||
console.log("[HugoAura / Loaded] Aura is loaded!");
|
||||
|
||||
if (!global.__HUGO_AURA__.ipcInit) {
|
||||
buildIpcMain(electron);
|
||||
global.__HUGO_AURA__.ipcInit = true;
|
||||
}
|
||||
|
||||
const hooksManager = new HooksManager();
|
||||
|
||||
configManager.ensureConfigExists();
|
||||
const loadedConfig = configManager.loadConfig();
|
||||
if (!global.__HUGO_AURA__.configInit) global.__HUGO_AURA__.configInit = true;
|
||||
|
||||
const hooks = hooksManager.loadHooks();
|
||||
|
||||
if (loadedConfig.devTools && !config.canOpenDevTool) {
|
||||
@@ -30,6 +110,18 @@ module.exports = function ({ central, windowName, config }) {
|
||||
|
||||
const webContentsCreatedListener = (_event, webContents) => {
|
||||
const hookConfig = hooks.get(windowName);
|
||||
|
||||
const initNetworkHook = () => {
|
||||
const networkHook = new NetworkHook();
|
||||
networkHook.installHook(webContents.session, loadedConfig);
|
||||
|
||||
console.debug(
|
||||
`[HugoAura / Init / Done / NetworkHook] Network Hook for ${windowName} installed.`
|
||||
);
|
||||
};
|
||||
|
||||
initNetworkHook();
|
||||
|
||||
if (hookConfig) {
|
||||
hooksManager.handleWindowHook(webContents, hookConfig, windowName);
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
const __AURA_VERSION__ = "0.1.0-beta";
|
||||
|
||||
(() => {
|
||||
if (!global.__HUGO_AURA__) {
|
||||
global.__HUGO_AURA__ = {
|
||||
configInit: true,
|
||||
configInit: true, // preload 始终比 hook 晚, 默认 config 已初始化
|
||||
version: __AURA_VERSION__,
|
||||
};
|
||||
}
|
||||
|
||||
if (!global.__HUGO_AURA_UI_FUNCTIONS__) {
|
||||
global.__HUGO_AURA_UI_FUNCTIONS__ = {};
|
||||
}
|
||||
|
||||
if (!global.__HUGO_AURA_UI_REACTIVES__) {
|
||||
global.__HUGO_AURA_UI_REACTIVES__ = {};
|
||||
}
|
||||
|
||||
const configManager = require("../aura/init/shared/configManager");
|
||||
const WebpackHook = require("../aura/init/preload/webpackHook");
|
||||
|
||||
@@ -19,10 +31,17 @@
|
||||
},
|
||||
set(target, prop, value) {
|
||||
target[prop] = value;
|
||||
const configUpdateEvent = new CustomEvent("onHugoAuraConfigUpdate", {
|
||||
detail: {
|
||||
path: [...path, prop],
|
||||
value,
|
||||
},
|
||||
});
|
||||
document.dispatchEvent(configUpdateEvent);
|
||||
console.log(
|
||||
`[HugoAura / Config] Config changed at path: ${[...path, prop].join(
|
||||
"."
|
||||
)}`
|
||||
)}, new value: ${value}`
|
||||
);
|
||||
configManager.writeConfig(window.__HUGO_AURA_CONFIG__);
|
||||
return true;
|
||||
|
||||
23
src/core/zeron.js
Normal file
23
src/core/zeron.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// Ex-Early Load Pro Plus Max ++
|
||||
|
||||
console.debug("[HugoAura / Zeron] Early load script loaded.");
|
||||
|
||||
module.exports = function (central) {
|
||||
const originalCentral = { ...central };
|
||||
const genHookedWS = require("../aura/init/zeron/hookWS");
|
||||
|
||||
console.debug(
|
||||
"[HugoAura / Zeron / WebSocket Hook] WebSocket hooked class generated."
|
||||
);
|
||||
|
||||
return new Proxy(central, {
|
||||
apply(target, thisArg, args) {
|
||||
switch (args[0]) {
|
||||
case 18:
|
||||
return genHookedWS(central);
|
||||
default:
|
||||
return Reflect.apply(target, thisArg, args);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user