You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
This commit adds the ReZygisk WebUI to ReZygisk. Signed-off-by: Emulond Argent <108662981+Emulond@users.noreply.github.com> Signed-off-by: WinCS <94188592+Meltartica@users.noreply.github.com> Signed-off-by: Pedro.js <pedroolimpioguerra@gmail.com> Signed-off-by: unexpected unresolved <minh15052008@gmail.com> Signed-off-by: SheepChef <50871867+SheepChef@users.noreply.github.com> Signed-off-by: AJleKcAHgP68 <78802768+AJleKcAHgP68@users.noreply.github.com> Signed-off-by: Blazzycrafter <39300111+Blazzycrafter@users.noreply.github.com> Signed-off-by: Igor <sorocean.igor@gmail.com> Signed-off-by: unexpected unresolved <xeondev@xeondex.onmicrosoft.com> Signed-off-by: Kirill Kuznetsov <kdevlab@yandex.ru> Signed-off-by: Lucky Kiddos <95188840+GuitarHeroStyles@users.noreply.github.com> Signed-off-by: Kitty <73357005+Kittyskj@users.noreply.github.com> Signed-off-by: GhostFRR <ghost.game.fr@gmail.com> Signed-off-by: Alice w/🌧️ <rainyxeon@gmail.com> Signed-off-by: ZGX089ッ <159061718+ZG089@users.noreply.github.com> Signed-off-by: thasave14 <93542339+thasave14@users.noreply.github.com> Co-authored-by: ThePedroo <pedroolimpioguerra@gmail.com> Co-authored-by: ExtremeXT <75576145+ExtremeXT@users.noreply.github.com> Co-authored-by: Emulond Argent <108662981+Emulond@users.noreply.github.com> Co-authored-by: RainyXeon <xeondev@xeondex.onmicrosoft.com> Co-authored-by: Fyphen <fyphensub@gmail.com> Co-authored-by: WinCS <94188592+Meltartica@users.noreply.github.com> Co-authored-by: CaptainThrowback <captainthrowback@hotmail.com> Co-authored-by: Kirill Kuznetsov <kdevlab@yandex.ru> Co-authored-by: SheepChef <50871867+SheepChef@users.noreply.github.com> Co-authored-by: AJleKcAHgP68 <78802768+AJleKcAHgP68@users.noreply.github.com> Co-authored-by: Blazzycrafter <39300111+Blazzycrafter@users.noreply.github.com> Co-authored-by: Igor <sorocean.igor@gmail.com> Co-authored-by: Berlian Panca <53902591+bpanca05@users.noreply.github.com> Co-authored-by: Willow Hayley Lovelace <65596971+dyingwillow@users.noreply.github.com> Co-authored-by: witch <witch@dyingwillow.dev> Co-authored-by: Lucky Kiddos <95188840+GuitarHeroStyles@users.noreply.github.com> Co-authored-by: Kitty <73357005+Kittyskj@users.noreply.github.com> Co-authored-by: GhostFRR <ghost.game.fr@gmail.com> Co-authored-by: ZGX089ッ <159061718+ZG089@users.noreply.github.com> Co-authored-by: thasave14 <93542339+thasave14@users.noreply.github.com> Co-authored-by: Flopster101 <nahuelgomez329@gmail.com> Co-authored-by: Lxchoooo <155797099+Lxchoooo@users.noreply.github.com>
117 lines
2.7 KiB
JavaScript
117 lines
2.7 KiB
JavaScript
/* https://github.com/tiann/KernelSU/tree/main/js / https://www.npmjs.com/package/kernelsu */
|
|
|
|
let callbackCounter = 0;
|
|
function getUniqueCallbackName(prefix) {
|
|
return `${prefix}_callback_${Date.now()}_${callbackCounter++}`;
|
|
}
|
|
|
|
export function exec(command, options) {
|
|
if (typeof options === "undefined") {
|
|
options = {};
|
|
}
|
|
|
|
return new Promise((resolve, reject) => {
|
|
// Generate a unique callback function name
|
|
const callbackFuncName = getUniqueCallbackName("exec");
|
|
|
|
// Define the success callback function
|
|
window[callbackFuncName] = (errno, stdout, stderr) => {
|
|
resolve({ errno, stdout, stderr });
|
|
cleanup(callbackFuncName);
|
|
};
|
|
|
|
function cleanup(successName) {
|
|
delete window[successName];
|
|
}
|
|
|
|
try {
|
|
ksu.exec(command, JSON.stringify(options), callbackFuncName);
|
|
} catch (error) {
|
|
reject(error);
|
|
cleanup(callbackFuncName);
|
|
}
|
|
});
|
|
}
|
|
|
|
function Stdio() {
|
|
this.listeners = {};
|
|
}
|
|
|
|
Stdio.prototype.on = function (event, listener) {
|
|
if (!this.listeners[event]) {
|
|
this.listeners[event] = [];
|
|
}
|
|
this.listeners[event].push(listener);
|
|
};
|
|
|
|
Stdio.prototype.emit = function (event, ...args) {
|
|
if (this.listeners[event]) {
|
|
this.listeners[event].forEach((listener) => listener(...args));
|
|
}
|
|
};
|
|
|
|
function ChildProcess() {
|
|
this.listeners = {};
|
|
this.stdin = new Stdio();
|
|
this.stdout = new Stdio();
|
|
this.stderr = new Stdio();
|
|
}
|
|
|
|
ChildProcess.prototype.on = function (event, listener) {
|
|
if (!this.listeners[event]) {
|
|
this.listeners[event] = [];
|
|
}
|
|
this.listeners[event].push(listener);
|
|
};
|
|
|
|
ChildProcess.prototype.emit = function (event, ...args) {
|
|
if (this.listeners[event]) {
|
|
this.listeners[event].forEach((listener) => listener(...args));
|
|
}
|
|
};
|
|
|
|
export function spawn(command, args, options) {
|
|
if (typeof args === "undefined") {
|
|
args = [];
|
|
} else if (!(args instanceof Array)) {
|
|
// allow for (command, options) signature
|
|
options = args;
|
|
}
|
|
|
|
if (typeof options === "undefined") {
|
|
options = {};
|
|
}
|
|
|
|
const child = new ChildProcess();
|
|
const childCallbackName = getUniqueCallbackName("spawn");
|
|
window[childCallbackName] = child;
|
|
|
|
function cleanup(name) {
|
|
delete window[name];
|
|
}
|
|
|
|
child.on("exit", code => {
|
|
cleanup(childCallbackName);
|
|
});
|
|
|
|
try {
|
|
ksu.spawn(
|
|
command,
|
|
JSON.stringify(args),
|
|
JSON.stringify(options),
|
|
childCallbackName
|
|
);
|
|
} catch (error) {
|
|
child.emit("error", error);
|
|
cleanup(childCallbackName);
|
|
}
|
|
return child;
|
|
}
|
|
|
|
export function fullScreen(isFullScreen) {
|
|
ksu.fullScreen(isFullScreen);
|
|
}
|
|
|
|
export function toast(message) {
|
|
ksu.toast(message);
|
|
} |