Skip to content

Commit

Permalink
Rename javascript globals
Browse files Browse the repository at this point in the history
  • Loading branch information
Vendicated committed Jul 12, 2023
1 parent f98760b commit 0715cbe
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 32 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Bug reports, feature requests & contributions are highly appreciated!!

### Windows

Download and run Vencord-Desktop-Setup-VERSION.exe from [releases](https://github.com/Vencord/Vesktop/releases/latest)
Download and run Vesktop-Setup-VERSION.exe from [releases](https://github.com/Vencord/Vesktop/releases/latest)

### Mac

Download and run Vencord-Desktop-VERSION.dmg from [releases](https://github.com/Vencord/Vesktop/releases/latest)
Download and run Vesktop-VERSION.dmg from [releases](https://github.com/Vencord/Vesktop/releases/latest)

### Linux

Expand All @@ -27,15 +27,15 @@ Install [vencord-desktop-git](https://aur.archlinux.org/packages/vencord-desktop

#### Ubuntu/Debian based

Download Vencord-Desktop-VERSION.deb from [releases](https://github.com/Vencord/Vesktop/releases/latest)
Download Vesktop-VERSION.deb from [releases](https://github.com/Vencord/Vesktop/releases/latest)

#### Fedora/RHEL based

Download Vencord-Desktop-VERSION.rpm from [releases](https://github.com/Vencord/Vesktop/releases/latest)
Download Vesktop-VERSION.rpm from [releases](https://github.com/Vencord/Vesktop/releases/latest)

#### Other

Either download Vencord-Desktop-VERSION.AppImage and just run it directly or grab Vencord-Desktop-VERSION.tar.gz, extract it somewhere and run `vencorddesktop`.
Either download Vesktop-VERSION.AppImage and just run it directly or grab Vesktop-VERSION.tar.gz, extract it somewhere and run `vencorddesktop`.

A flatpak is planned, if you want packages for other repos, feel free to create them and they can be linked as unofficial here

Expand Down
8 changes: 6 additions & 2 deletions scripts/build/build.mts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ await Promise.all([
}),
createContext({
...CommonOpts,
globalName: "VencordDesktop",
globalName: "Vesktop",
entryPoints: ["src/renderer/index.ts"],
outfile: "dist/js/renderer.js",
format: "iife",
Expand All @@ -65,7 +65,11 @@ await Promise.all([
tsconfig: "./scripts/build/tsconfig.esbuild.json",
external: ["@vencord/types/*"],
plugins: [vencordDep],
footer: { js: "//# sourceURL=VCDRenderer" }
// TODO: remove legacy name once main Vencord codebase has migrated and some time has passed.
// this 0 is very important. we run this script via webFrame.executeJavaScript and the last
// expression will be the return value. Without the 0, the return value would be Vesktop which
// leads to "An object could not be cloned"
footer: { js: ";window.VencordDesktop=Vesktop;0 \n//# sourceURL=VCDRenderer" }
})
]);

Expand Down
4 changes: 2 additions & 2 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

declare global {
export var VencordDesktopNative: typeof import("preload/VencordDesktopNative").VencordDesktopNative;
export var VencordDesktop: typeof import("renderer/index");
export var VesktopNative: typeof import("preload/VesktopNative").VesktopNative;
export var Vesktop: typeof import("renderer/index");
export var VCDP: any;

export var IS_DEV: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/main/arrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function initArRPC() {
mainWin.webContents
// Safety: Result of JSON.stringify should always be safe to equal
// Also, just to be super super safe, invite is regex validated above
.executeJavaScript(`VencordDesktop.openInviteModal(${JSON.stringify(invite)})`)
.executeJavaScript(`Vesktop.openInviteModal(${JSON.stringify(invite)})`)
.then(callback);
});
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const VENCORD_SETTINGS_FILE = join(VENCORD_SETTINGS_DIR, "settings.json")
export const VENCORD_FILES_DIR =
(require("./settings") as typeof import("./settings")).Settings.store.vencordDir || join(DATA_DIR, "vencordDist");

export const USER_AGENT = `VencordDesktop/${app.getVersion()} (https://github.com/Vencord/Desktop)`;
export const USER_AGENT = `Vesktop/${app.getVersion()} (https://github.com/Vencord/Vesktop)`;

// dimensions shamelessly stolen from Discord Desktop :3
export const MIN_WIDTH = 940;
Expand Down
2 changes: 1 addition & 1 deletion src/main/screenShare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function registerScreenShareHandler() {
}));

const choice = await request.frame
.executeJavaScript(`VencordDesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify(data)})`)
.executeJavaScript(`Vesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify(data)})`)
.then(e => e as StreamPick)
.catch(() => null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ipcRenderer.on(IpcEvents.SPELLCHECK_RESULT, (_, w: string, s: string[]) => {
spellCheckCallbacks.forEach(cb => cb(w, s));
});

export const VencordDesktopNative = {
export const VesktopNative = {
app: {
relaunch: () => invoke<void>(IpcEvents.RELAUNCH),
getVersion: () => sendSync<void>(IpcEvents.GET_VERSION),
Expand Down
8 changes: 5 additions & 3 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import { contextBridge, ipcRenderer, webFrame } from "electron";
import { readFileSync, watch } from "fs";

import { IpcEvents } from "../shared/IpcEvents";
import { VencordDesktopNative } from "./VencordDesktopNative";
import { VesktopNative } from "./VesktopNative";

contextBridge.exposeInMainWorld("VencordDesktopNative", VencordDesktopNative);
contextBridge.exposeInMainWorld("VesktopNative", VesktopNative);
// TODO: remove once main Vencord codebase has migrated and some time has passed
// contextBridge.exposeInMainWorld("VencordDesktopNative", VesktopNative);

require(ipcRenderer.sendSync(IpcEvents.GET_VENCORD_PRELOAD_FILE));

Expand Down Expand Up @@ -41,4 +43,4 @@ if (IS_DEV) {
}
// #endregion

VencordDesktopNative.spellcheck.setLanguages(window.navigator.languages);
VesktopNative.spellcheck.setLanguages(window.navigator.languages);
2 changes: 1 addition & 1 deletion src/renderer/appBadge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function setBadge() {
let totalCount = mentionCount + pendingRequests;
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;

VencordDesktopNative.app.setBadgeCount(totalCount);
VesktopNative.app.setBadgeCount(totalCount);
}

let toFind = 3;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/ScreenSharePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function StreamSettings({
settings: StreamSettings;
setSettings: Dispatch<SetStateAction<StreamSettings>>;
}) {
const [thumb] = useAwaiter(() => VencordDesktopNative.capturer.getLargeThumbnail(source.id), {
const [thumb] = useAwaiter(() => VesktopNative.capturer.getLargeThumbnail(source.id), {
fallbackValue: source.url,
deps: [source.id]
});
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { useSettings } from "renderer/settings";

export default function SettingsUi() {
const Settings = useSettings();
const supportsWindowsTransparency = VencordDesktopNative.app.supportsWindowsTransparency();
const supportsWindowsTransparency = VesktopNative.app.supportsWindowsTransparency();

const { autostart } = VencordDesktopNative;
const { autostart } = VesktopNative;
const [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled());

const switches: [keyof typeof Settings, string, string, boolean?, (() => boolean)?][] = [
Expand Down Expand Up @@ -79,7 +79,7 @@ export default function SettingsUi() {
onChange={v => {
Settings.appBadge = v;
if (v) setBadge();
else VencordDesktopNative.app.setBadgeCount(0);
else VesktopNative.app.setBadgeCount(0);
}}
note="Show mention badge on the app icon"
>
Expand Down Expand Up @@ -143,7 +143,7 @@ export default function SettingsUi() {
href="about:blank"
onClick={e => {
e.preventDefault();
VencordDesktopNative.fileManager.showItemInFolder(Settings.vencordDir!);
VesktopNative.fileManager.showItemInFolder(Settings.vencordDir!);
}}
>
{Settings.vencordDir}
Expand All @@ -156,7 +156,7 @@ export default function SettingsUi() {
<Button
size={Button.Sizes.SMALL}
onClick={async () => {
const choice = await VencordDesktopNative.fileManager.selectVencordDir();
const choice = await VesktopNative.fileManager.selectVencordDir();
switch (choice) {
case "cancelled":
case "invalid":
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/fixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Object.defineProperty(Notification.prototype, "onclick", {
set(onClick) {
originalSetOnClick.call(this, function (this: unknown) {
onClick.apply(this, arguments);
VencordDesktopNative.win.focus();
VesktopNative.win.focus();
});
},
configurable: true
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function openInviteModal(code: string) {
const { invite } = await InviteActions.resolveInvite(code, "Desktop Modal");
if (!invite) return false;

VencordDesktopNative.win.focus();
VesktopNative.win.focus();

FluxDispatcher.dispatch({
type: "INVITE_MODAL_OPEN",
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/patches/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function addPatch<P extends PatchData>(p: P) {
if (typeof r.replace === "string") r.replace = r.replace.replaceAll("$self", "VCDP");
}

patch.plugin = "VencordDesktop";
patch.plugin = "Vesktop";
Vencord.Plugins.patches.push(patch);
}

Expand Down
8 changes: 4 additions & 4 deletions src/renderer/patches/spellCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ addPatch({
}

const cb = (w: string, c: string[]) => {
VencordDesktopNative.spellcheck.offSpellcheckResult(cb);
VesktopNative.spellcheck.offSpellcheckResult(cb);
word = w;
corrections = c;
openMenu();
};
VencordDesktopNative.spellcheck.onSpellcheckResult(cb);
VesktopNative.spellcheck.onSpellcheckResult(cb);
}
});

Expand All @@ -57,14 +57,14 @@ addContextMenuPatch("textarea-context", children => () => {
<Menu.MenuItem
id={"vcd-spellcheck-suggestion-" + c}
label={c}
action={() => VencordDesktopNative.spellcheck.replaceMisspelling(c)}
action={() => VesktopNative.spellcheck.replaceMisspelling(c)}
/>
))}
<Menu.MenuSeparator />
<Menu.MenuItem
id="vcd-spellcheck-learn"
label={`Add ${word} to dictionary`}
action={() => VencordDesktopNative.spellcheck.addToDictionary(word)}
action={() => VesktopNative.spellcheck.addToDictionary(word)}
/>
</>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import { useEffect, useReducer } from "@vencord/types/webpack/common";
import { SettingsStore } from "shared/utils/SettingsStore";

export const Settings = new SettingsStore(VencordDesktopNative.settings.get());
Settings.addGlobalChangeListener((o, p) => VencordDesktopNative.settings.set(o, p));
export const Settings = new SettingsStore(VesktopNative.settings.get());
Settings.addGlobalChangeListener((o, p) => VesktopNative.settings.set(o, p));

export function useSettings() {
const [, update] = useReducer(x => x + 1, 0);
Expand Down

0 comments on commit 0715cbe

Please sign in to comment.