Update arRPC and add MS Store assets

This commit is contained in:
smartfridge 2023-02-25 19:08:21 +01:00
parent 23c70301be
commit 74598f2ed8
19 changed files with 85 additions and 208 deletions

View file

@ -39,11 +39,19 @@
## Packaging status
[![Packaging status](https://repology.org/badge/vertical-allrepos/armcord.svg)](https://repology.org/project/armcord/versions)
### Windows
<a href="ms-windows-store://pdp/?ProductId=9PFHLJFD7KJT&mode=mini">
<img src="https://get.microsoft.com/images/en-us%20dark.svg" alt="Download ArmCord" />
</a>
If you're using older version of Windows, you need to use [pre-built installers](https://www.armcord.xyz/download).
### Debian, Ubuntu, Raspbian repository
ArmCord is available on our official repositories for `apt` package manager. By using this method you'll receive automatic updates and get all the dependencies. Run the following commands to install ArmCord from them:
```sh
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F1710089DA28B361
echo "deb [arch=$(dpkg --print-architecture)] https://eu.armcord.xyz/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/armcord.list
curl -fsSL https://eu.armcord.xyz/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/armcord.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/armcord.gpg] https://eu.armcord.xyz/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/armcord.list
sudo apt update
sudo apt install armcord
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
assets/Square44x44Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
assets/StoreLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
assets/Wide310x150Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -1,9 +0,0 @@
# arRPC Examples
## [Bridge Mod](bridge_mod.js)
Simple mod for using the arRPC Bridge WebSocket server for setting RPC status (to be used with just Web).
## [Electron](electron)
Example usage for within an Electron client.

View file

@ -1,78 +0,0 @@
(() => {
let Dispatcher,
lookupAsset,
lookupApp,
apps = {};
const ws = new WebSocket("ws://127.0.0.1:1337"); // connect to arRPC bridge websocket
ws.onmessage = async (x) => {
msg = JSON.parse(x.data);
console.log(msg);
if (!Dispatcher) {
const wpRequire = window.webpackChunkdiscord_app.push([[Symbol()], {}, (x) => x]);
const cache = wpRequire.c;
window.webpackChunkdiscord_app.pop();
for (const id in cache) {
let mod = cache[id].exports;
mod = mod && (mod.Z ?? mod.ZP);
if (mod && mod.register && mod.wait) {
Dispatcher = mod;
break;
}
}
const factories = wpRequire.m;
for (const id in factories) {
if (factories[id].toString().includes("getAssetImage: size must === [number, number] for Twitch")) {
const mod = wpRequire(id);
const _lookupAsset = Object.values(mod).find(
(e) => typeof e === "function" && e.toString().includes("apply(")
);
lookupAsset = async (appId, name) => (await _lookupAsset(appId, [name, undefined]))[0];
break;
}
}
for (const id in factories) {
if (factories[id].toString().includes(`e.application={`)) {
const mod = wpRequire(id);
const _lookupApp = Object.values(mod).find(
(e) => typeof e === "function" && e.toString().includes(`e.application={`)
);
lookupApp = async (appId) => {
let socket = {};
await _lookupApp(socket, appId);
return socket.application;
};
break;
}
}
}
if (msg.activity?.assets?.large_image)
msg.activity.assets.large_image = await lookupAsset(
msg.activity.application_id,
msg.activity.assets.large_image
);
if (msg.activity?.assets?.small_image)
msg.activity.assets.small_image = await lookupAsset(
msg.activity.application_id,
msg.activity.assets.small_image
);
const appId = msg.activity.application_id;
if (!apps[appId]) apps[appId] = await lookupApp(appId);
const app = apps[appId];
if (!msg.activity.name) msg.activity.name = app.name;
Dispatcher.dispatch({type: "LOCAL_ACTIVITY_UPDATE", ...msg}); // set RPC status
};
})();

View file

@ -1,9 +0,0 @@
// myWindow = your discord.com BrowserWindow
import Server from "./path/to/arrpc/server.js";
const arrpc = await new Server();
arrpc.on("activity", (data) => myWindow.webContents.send("rpc", data));
arrpc.on("invite", (code) => {
// your invite code handling here
});

View file

@ -1,73 +0,0 @@
import {ipcRenderer} from "electron";
let Dispatcher,
lookupAsset,
lookupApp,
apps = {};
ipcRenderer.on("rpc", async (event, data) => {
if (!Dispatcher) {
const wpRequire = window.webpackChunkdiscord_app.push([[Symbol()], {}, (x) => x]);
const cache = wpRequire.c;
window.webpackChunkdiscord_app.pop();
for (const id in cache) {
let mod = cache[id].exports;
mod = mod && (mod.Z ?? mod.ZP);
if (mod && mod.register && mod.wait) {
Dispatcher = mod;
break;
}
}
const factories = wpRequire.m;
for (const id in factories) {
if (factories[id].toString().includes("getAssetImage: size must === [number, number] for Twitch")) {
const mod = wpRequire(id);
const _lookupAsset = Object.values(mod).find(
(e) => typeof e === "function" && e.toString().includes("apply(")
);
lookupAsset = async (appId, name) => (await _lookupAsset(appId, [name, undefined]))[0];
break;
}
}
for (const id in factories) {
if (factories[id].toString().includes(`e.application={`)) {
const mod = wpRequire(id);
const _lookupApp = Object.values(mod).find(
(e) => typeof e === "function" && e.toString().includes(`e.application={`)
);
lookupApp = async (appId) => {
let socket = {};
await _lookupApp(socket, appId);
return socket.application;
};
break;
}
}
}
if (data.activity?.assets?.large_image)
data.activity.assets.large_image = await lookupAsset(
data.activity.application_id,
data.activity.assets.large_image
);
if (data.activity?.assets?.small_image)
data.activity.assets.small_image = await lookupAsset(
data.activity.application_id,
data.activity.assets.small_image
);
const appId = data.activity.application_id;
if (!apps[appId]) apps[appId] = await lookupApp(appId);
const app = apps[appId];
if (!data.activity.name) data.activity.name = app.name;
Dispatcher.dispatch({type: "LOCAL_ACTIVITY_UPDATE", ...data}); // set RPC status
});

View file

@ -1,8 +1,7 @@
const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`;
const log = (...args) => console.log(`[${rgb(88, 101, 242, "arRPC")}]`, ...args);
log("arRPC v3.0.0 [ArmCord]");
log("arRPC v3.1.0 ArmCord");
const {RPCServer} = require("./server.js");
const {mainWindow} = require("../../../ts-out/window.js");

View file

@ -11,7 +11,7 @@ const timestamps = {},
pids = {};
class ProcessServer {
constructor(handlers) {
if (!Native) return log("unsupported platform:", process.platform);
if (!Native) return; // log('unsupported platform:', process.platform);
this.handlers = handlers;
@ -24,9 +24,12 @@ class ProcessServer {
}
async scan() {
const startTime = performance.now();
const processes = await Native.getProcesses();
const ids = [];
// log(`got processed in ${(performance.now() - startTime).toFixed(2)}ms`);
for (const [pid, _path] of processes) {
const path = _path.toLowerCase().replaceAll("\\", "/");
const toCompare = [path.split("/").pop(), path.split("/").slice(-2).join("/")];
@ -90,6 +93,9 @@ class ProcessServer {
);
}
}
// log(`finished scan in ${(performance.now() - startTime).toFixed(2)}ms`);
// process.stdout.write(`\r${' '.repeat(100)}\r[${rgb(88, 101, 242, 'arRPC')} > ${rgb(237, 66, 69, 'process')}] scanned (took ${(performance.now() - startTime).toFixed(2)}ms)`);
}
}
module.exports = {ProcessServer};
module.exports = ProcessServer;

View file

@ -1,2 +1,3 @@
const win32 = require("./win32.js");
module.exports = {win32};
const win32 = require("./win32");
const linux = require("./linux");
module.exports = {win32, linux};

View file

@ -0,0 +1,31 @@
const {exec} = require("child_process");
const {readlink} = require("fs/promises");
const getProcesses = () =>
new Promise((res) =>
exec(`ps a -o "%p;%c;%a"`, async (e, out) => {
res(
(
await Promise.all(
out
.toString()
.split("\n")
.slice(1, -1)
.map(async (x) => {
const split = x.trim().split(";");
// if (split.length === 1) return;
const pid = parseInt(split[0].trim());
const cmd = split[1].trim();
const argv = split.slice(2).join(";").trim();
const path = await readlink(`/proc/${pid}/exe`).catch((e) => {}); // read path from /proc/{pid}/exe symlink
return [pid, path];
})
)
).filter((x) => x && x[1])
);
})
);
module.exports = getProcesses;

View file

@ -1,7 +1,6 @@
const {exec} = require("child_process");
module.exports = {
getProcesses: () =>
const getProcesses = () =>
new Promise((res) =>
exec(`wmic process get ProcessID,ExecutablePath /format:csv`, (e, out) => {
res(
@ -17,5 +16,5 @@ module.exports = {
.filter((x) => x[1])
);
})
)
};
);
module.exports = getProcesses;

View file

@ -1,8 +1,10 @@
const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`;
const log = (...args) => console.log(`[${rgb(88, 101, 242, "arRPC")} > ${rgb(87, 242, 135, "bridge")}]`, ...args);
const {EventEmitter} = require("events");
const {IPCServer} = require("./transports/ipc.js");
const {WSServer} = require("./transports/websocket.js");
const {ProcessServer} = require("./process/index.js");
const IPCServer = require("./transports/ipc.js");
const WSServer = require("./transports/websocket.js");
const ProcessServer = require("./process/index.js");
let socketId = 0;
class RPCServer extends EventEmitter {
@ -143,4 +145,4 @@ class RPCServer extends EventEmitter {
}
}
}
module.exports = {RPCServer};
module.exports = RPCServer;

View file

@ -268,4 +268,4 @@ class IPCServer {
this.handlers.message(socket, msg);
}
}
module.exports = {IPCServer};
module.exports = IPCServer;

View file

@ -25,7 +25,7 @@ class WSServer {
await new Promise((res) => {
http = createServer();
http.on("error", (e) => {
// log("http error", e);
// log('http error', e);
if (e.code === "EADDRINUSE") {
log(port, "in use!");
@ -35,7 +35,7 @@ class WSServer {
wss = new WebSocketServer({server: http});
wss.on("error", (e) => {
// log("wss error", e);
// log('wss error', e);
});
wss.on("connection", this.onConnection);
@ -92,8 +92,8 @@ class WSServer {
return;
}
/* if (clientId === "") {
log("client id required");
/* if (clientId === '') {
log('client id required');
socket.close();
return;
@ -127,4 +127,4 @@ class WSServer {
this.handlers.message(socket, JSON.parse(msg));
}
}
module.exports = {WSServer};
module.exports = WSServer;

View file

@ -4,7 +4,6 @@
<meta charset="UTF-8" />
<style>
@import url("../content/css/settings.css");
@import url("../content/css/settingsEng.css");
</style>
</head>

View file

@ -31,6 +31,7 @@ contextMenu({
showSaveImageAs: true,
showCopyImageAddress: true,
showSearchWithGoogle: false,
showSearchWithDuckDuckGo: false,
prepend: (defaultActions, parameters, browserWindow) => [
{
label: "Search with Google",
@ -58,7 +59,7 @@ async function doAfterDefiningTheWindow() {
}
if (transparency && process.platform === "win32") {
import("@pyke/vibe").then(async (vibe) => {
vibe.applyEffect(mainWindow, "unified-acrylic");
vibe.applyEffect(mainWindow, "acrylic");
vibe.forceTheme(mainWindow, "dark");
if ((await getConfig("startMinimized")) == false) {
mainWindow.show();