From 1311280603cdefa656a2c19684013c1ea14092be Mon Sep 17 00:00:00 2001 From: Kylie C Date: Wed, 18 Dec 2024 23:01:56 -0500 Subject: [PATCH 1/3] feat(rpc): implement arrpc's `link` event This implements deep links from web so message links and the like work over just invites work. Depends on OpenAsar/arrpc/pull/128 --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- src/main/arrpc.ts | 3 +++ src/renderer/index.ts | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 83c91af5..faa60f59 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "updateMeta": "tsx scripts/utils/updateMeta.mts" }, "dependencies": { - "arrpc": "github:OpenAsar/arrpc#5aadc307cb9bf4479f0a12364a253b07a77ace22", + "arrpc": "github:OpenAsar/arrpc#b6dd0069399c3f6e048c9794be0e4898a25aa6f7", "electron-updater": "^6.3.9" }, "optionalDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d28002f2..7393ba84 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,8 +14,8 @@ importers: .: dependencies: arrpc: - specifier: github:OpenAsar/arrpc#5aadc307cb9bf4479f0a12364a253b07a77ace22 - version: https://codeload.github.com/OpenAsar/arrpc/tar.gz/5aadc307cb9bf4479f0a12364a253b07a77ace22(patch_hash=biyukfa6dww2wxujy4eyvkhrti) + specifier: github:OpenAsar/arrpc#b6dd0069399c3f6e048c9794be0e4898a25aa6f7 + version: https://codeload.github.com/OpenAsar/arrpc/tar.gz/b6dd0069399c3f6e048c9794be0e4898a25aa6f7(patch_hash=biyukfa6dww2wxujy4eyvkhrti) electron-updater: specifier: ^6.3.9 version: 6.3.9 @@ -799,8 +799,8 @@ packages: resolution: {integrity: sha512-bMxMKAjg13EBSVscxTaYA4mRc5t1UAXa2kXiGTNfZ079HIWXEkKmkgFrh/nJqamaLSrXO5H4WFFkPEaLJWbs3A==} engines: {node: '>= 0.4'} - arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/5aadc307cb9bf4479f0a12364a253b07a77ace22: - resolution: {tarball: https://codeload.github.com/OpenAsar/arrpc/tar.gz/5aadc307cb9bf4479f0a12364a253b07a77ace22} + arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/b6dd0069399c3f6e048c9794be0e4898a25aa6f7: + resolution: {tarball: https://codeload.github.com/OpenAsar/arrpc/tar.gz/b6dd0069399c3f6e048c9794be0e4898a25aa6f7} version: 3.5.0 hasBin: true @@ -3658,7 +3658,7 @@ snapshots: is-array-buffer: 3.0.4 is-shared-array-buffer: 1.0.3 - arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/5aadc307cb9bf4479f0a12364a253b07a77ace22(patch_hash=biyukfa6dww2wxujy4eyvkhrti): + arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/b6dd0069399c3f6e048c9794be0e4898a25aa6f7(patch_hash=biyukfa6dww2wxujy4eyvkhrti): dependencies: ws: 8.18.0 transitivePeerDependencies: diff --git a/src/main/arrpc.ts b/src/main/arrpc.ts index 1899d9cb..5b422b3e 100644 --- a/src/main/arrpc.ts +++ b/src/main/arrpc.ts @@ -30,6 +30,9 @@ export async function initArRPC() { .executeJavaScript(`Vesktop.openInviteModal(${JSON.stringify(invite)})`) .then(callback); }); + server.on("link", (data: any, deep_callback: (valid: boolean) => void) => { + mainWin.webContents.executeJavaScript(`Vesktop.openDeepLink(${JSON.stringify(data)})`).then(deep_callback); + }); } catch (e) { console.error("Failed to start arRPC server", e); } diff --git a/src/renderer/index.ts b/src/renderer/index.ts index e8ad31ca..63b4487b 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -37,6 +37,23 @@ export async function openInviteModal(code: string) { return true; } +export async function openDeepLink(data: any) { + console.log(data); + if (data.type === "CHANNEL") { + // I am unaware of any other types but ensure just in case. + const { guildId, channelId, messageId } = data.params; + if (!guildId) return false; // ensure at least guildId exists + + const path = [guildId, channelId, messageId].filter(Boolean).join("/"); + Vencord.Webpack.Common.NavigationRouter.transitionTo(`/channels/${path}`); + + return true; + } else { + console.warn("Unhandled deep link type: ", data.type); + return false; + } +} + const customSettingsSections = ( Vencord.Plugins.plugins.Settings as any as { customSections: ((ID: Record) => any)[] } ).customSections; From daba371ff905b02af3a04afce07b2ecd51aa0cbd Mon Sep 17 00:00:00 2001 From: Kylie C Date: Wed, 15 Jan 2025 19:19:07 -0500 Subject: [PATCH 2/3] PR is merged. use on branch hash --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index faa60f59..d33d608a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "updateMeta": "tsx scripts/utils/updateMeta.mts" }, "dependencies": { - "arrpc": "github:OpenAsar/arrpc#b6dd0069399c3f6e048c9794be0e4898a25aa6f7", + "arrpc": "github:OpenAsar/arrpc#2234e9c9111f4c42ebcc3aa6a2215bfd979eef77", "electron-updater": "^6.3.9" }, "optionalDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7393ba84..de131214 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,8 +14,8 @@ importers: .: dependencies: arrpc: - specifier: github:OpenAsar/arrpc#b6dd0069399c3f6e048c9794be0e4898a25aa6f7 - version: https://codeload.github.com/OpenAsar/arrpc/tar.gz/b6dd0069399c3f6e048c9794be0e4898a25aa6f7(patch_hash=biyukfa6dww2wxujy4eyvkhrti) + specifier: github:OpenAsar/arrpc#2234e9c9111f4c42ebcc3aa6a2215bfd979eef77 + version: https://codeload.github.com/OpenAsar/arrpc/tar.gz/2234e9c9111f4c42ebcc3aa6a2215bfd979eef77(patch_hash=biyukfa6dww2wxujy4eyvkhrti) electron-updater: specifier: ^6.3.9 version: 6.3.9 @@ -799,8 +799,8 @@ packages: resolution: {integrity: sha512-bMxMKAjg13EBSVscxTaYA4mRc5t1UAXa2kXiGTNfZ079HIWXEkKmkgFrh/nJqamaLSrXO5H4WFFkPEaLJWbs3A==} engines: {node: '>= 0.4'} - arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/b6dd0069399c3f6e048c9794be0e4898a25aa6f7: - resolution: {tarball: https://codeload.github.com/OpenAsar/arrpc/tar.gz/b6dd0069399c3f6e048c9794be0e4898a25aa6f7} + arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/2234e9c9111f4c42ebcc3aa6a2215bfd979eef77: + resolution: {tarball: https://codeload.github.com/OpenAsar/arrpc/tar.gz/2234e9c9111f4c42ebcc3aa6a2215bfd979eef77} version: 3.5.0 hasBin: true @@ -3658,7 +3658,7 @@ snapshots: is-array-buffer: 3.0.4 is-shared-array-buffer: 1.0.3 - arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/b6dd0069399c3f6e048c9794be0e4898a25aa6f7(patch_hash=biyukfa6dww2wxujy4eyvkhrti): + arrpc@https://codeload.github.com/OpenAsar/arrpc/tar.gz/2234e9c9111f4c42ebcc3aa6a2215bfd979eef77(patch_hash=biyukfa6dww2wxujy4eyvkhrti): dependencies: ws: 8.18.0 transitivePeerDependencies: From 6eece90aee71b5b996128cc58552e9162e314de6 Mon Sep 17 00:00:00 2001 From: Cookie <52550063+Covkie@users.noreply.github.com> Date: Fri, 24 Jan 2025 01:15:33 -0500 Subject: [PATCH 3/3] Update arrpc.ts --- src/main/arrpc.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/arrpc.ts b/src/main/arrpc.ts index 5b422b3e..4775326b 100644 --- a/src/main/arrpc.ts +++ b/src/main/arrpc.ts @@ -30,8 +30,8 @@ export async function initArRPC() { .executeJavaScript(`Vesktop.openInviteModal(${JSON.stringify(invite)})`) .then(callback); }); - server.on("link", (data: any, deep_callback: (valid: boolean) => void) => { - mainWin.webContents.executeJavaScript(`Vesktop.openDeepLink(${JSON.stringify(data)})`).then(deep_callback); + server.on("link", (data: any, deepCallback: (valid: boolean) => void) => { + mainWin.webContents.executeJavaScript(`Vesktop.openDeepLink(${JSON.stringify(data)})`).then(deepCallback); }); } catch (e) { console.error("Failed to start arRPC server", e);