From 63f247a5ac32b68e92aec229aac7fde7bd3d3d92 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Thu, 25 Jan 2024 00:37:25 +0100 Subject: [PATCH] added public_libraries --- src/main/public_libraries/index.js | 7 ++++ src/main/public_libraries/mcl/index.js | 34 +++++++++++++++++++ .../public_libraries/renderer_ipc/index.js | 7 ++++ 3 files changed, 48 insertions(+) create mode 100644 src/main/public_libraries/index.js create mode 100644 src/main/public_libraries/mcl/index.js create mode 100644 src/main/public_libraries/renderer_ipc/index.js diff --git a/src/main/public_libraries/index.js b/src/main/public_libraries/index.js new file mode 100644 index 0000000..4adcc04 --- /dev/null +++ b/src/main/public_libraries/index.js @@ -0,0 +1,7 @@ +import MCL from "./mcl" +import RendererIPC from "./renderer_ipc" + +export default { + mcl: MCL, + ipc: RendererIPC, +} \ No newline at end of file diff --git a/src/main/public_libraries/mcl/index.js b/src/main/public_libraries/mcl/index.js new file mode 100644 index 0000000..67b8c69 --- /dev/null +++ b/src/main/public_libraries/mcl/index.js @@ -0,0 +1,34 @@ +import Client from "../../lib/mcl/launcher" +import Authenticator from "../../lib/mcl/authenticator" + +export default class MCL { + /** + * Asynchronously authenticate the user using the provided username and password. + * + * @param {string} username - the username of the user + * @param {string} password - the password of the user + * @return {Promise} the authentication information + */ + static async auth(username, password) { + return await Authenticator.getAuth(username, password) + } + + /** + * Launches a new client with the given options. + * + * @param {Object} opts - The options to be passed for launching the client. + * @return {Promise} A promise that resolves with the launched client. + */ + static async launch(opts, callbacks) { + const launcher = new Client() + + launcher.on("debug", (e) => console.log(e)) + launcher.on("data", (e) => console.log(e)) + launcher.on("close", (e) => console.log(e)) + launcher.on("error", (e) => console.log(e)) + + await launcher.launch(opts, callbacks) + + return launcher + } +} \ No newline at end of file diff --git a/src/main/public_libraries/renderer_ipc/index.js b/src/main/public_libraries/renderer_ipc/index.js new file mode 100644 index 0000000..0050a9d --- /dev/null +++ b/src/main/public_libraries/renderer_ipc/index.js @@ -0,0 +1,7 @@ +import sendToRender from "../../utils/sendToRender" + +export default class RendererIPC { + static async send(...args) { + return await sendToRender(...args) + } +} \ No newline at end of file