Rename javascript globals
This commit is contained in:
parent
f98760b350
commit
0715cbe17e
16 changed files with 38 additions and 32 deletions
10
README.md
10
README.md
|
@ -13,11 +13,11 @@ Bug reports, feature requests & contributions are highly appreciated!!
|
||||||
|
|
||||||
### Windows
|
### 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
|
### 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
|
### Linux
|
||||||
|
|
||||||
|
@ -27,15 +27,15 @@ Install [vencord-desktop-git](https://aur.archlinux.org/packages/vencord-desktop
|
||||||
|
|
||||||
#### Ubuntu/Debian based
|
#### 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
|
#### 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
|
#### 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
|
A flatpak is planned, if you want packages for other repos, feel free to create them and they can be linked as unofficial here
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ await Promise.all([
|
||||||
}),
|
}),
|
||||||
createContext({
|
createContext({
|
||||||
...CommonOpts,
|
...CommonOpts,
|
||||||
globalName: "VencordDesktop",
|
globalName: "Vesktop",
|
||||||
entryPoints: ["src/renderer/index.ts"],
|
entryPoints: ["src/renderer/index.ts"],
|
||||||
outfile: "dist/js/renderer.js",
|
outfile: "dist/js/renderer.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
|
@ -65,7 +65,11 @@ await Promise.all([
|
||||||
tsconfig: "./scripts/build/tsconfig.esbuild.json",
|
tsconfig: "./scripts/build/tsconfig.esbuild.json",
|
||||||
external: ["@vencord/types/*"],
|
external: ["@vencord/types/*"],
|
||||||
plugins: [vencordDep],
|
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" }
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
4
src/globals.d.ts
vendored
4
src/globals.d.ts
vendored
|
@ -5,8 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
export var VencordDesktopNative: typeof import("preload/VencordDesktopNative").VencordDesktopNative;
|
export var VesktopNative: typeof import("preload/VesktopNative").VesktopNative;
|
||||||
export var VencordDesktop: typeof import("renderer/index");
|
export var Vesktop: typeof import("renderer/index");
|
||||||
export var VCDP: any;
|
export var VCDP: any;
|
||||||
|
|
||||||
export var IS_DEV: boolean;
|
export var IS_DEV: boolean;
|
||||||
|
|
|
@ -29,7 +29,7 @@ export async function initArRPC() {
|
||||||
mainWin.webContents
|
mainWin.webContents
|
||||||
// Safety: Result of JSON.stringify should always be safe to equal
|
// Safety: Result of JSON.stringify should always be safe to equal
|
||||||
// Also, just to be super super safe, invite is regex validated above
|
// 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);
|
.then(callback);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const VENCORD_SETTINGS_FILE = join(VENCORD_SETTINGS_DIR, "settings.json")
|
||||||
export const VENCORD_FILES_DIR =
|
export const VENCORD_FILES_DIR =
|
||||||
(require("./settings") as typeof import("./settings")).Settings.store.vencordDir || join(DATA_DIR, "vencordDist");
|
(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
|
// dimensions shamelessly stolen from Discord Desktop :3
|
||||||
export const MIN_WIDTH = 940;
|
export const MIN_WIDTH = 940;
|
||||||
|
|
|
@ -36,7 +36,7 @@ export function registerScreenShareHandler() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const choice = await request.frame
|
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)
|
.then(e => e as StreamPick)
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ ipcRenderer.on(IpcEvents.SPELLCHECK_RESULT, (_, w: string, s: string[]) => {
|
||||||
spellCheckCallbacks.forEach(cb => cb(w, s));
|
spellCheckCallbacks.forEach(cb => cb(w, s));
|
||||||
});
|
});
|
||||||
|
|
||||||
export const VencordDesktopNative = {
|
export const VesktopNative = {
|
||||||
app: {
|
app: {
|
||||||
relaunch: () => invoke<void>(IpcEvents.RELAUNCH),
|
relaunch: () => invoke<void>(IpcEvents.RELAUNCH),
|
||||||
getVersion: () => sendSync<void>(IpcEvents.GET_VERSION),
|
getVersion: () => sendSync<void>(IpcEvents.GET_VERSION),
|
|
@ -8,9 +8,11 @@ import { contextBridge, ipcRenderer, webFrame } from "electron";
|
||||||
import { readFileSync, watch } from "fs";
|
import { readFileSync, watch } from "fs";
|
||||||
|
|
||||||
import { IpcEvents } from "../shared/IpcEvents";
|
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));
|
require(ipcRenderer.sendSync(IpcEvents.GET_VENCORD_PRELOAD_FILE));
|
||||||
|
|
||||||
|
@ -41,4 +43,4 @@ if (IS_DEV) {
|
||||||
}
|
}
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
VencordDesktopNative.spellcheck.setLanguages(window.navigator.languages);
|
VesktopNative.spellcheck.setLanguages(window.navigator.languages);
|
||||||
|
|
|
@ -23,7 +23,7 @@ export function setBadge() {
|
||||||
let totalCount = mentionCount + pendingRequests;
|
let totalCount = mentionCount + pendingRequests;
|
||||||
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;
|
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;
|
||||||
|
|
||||||
VencordDesktopNative.app.setBadgeCount(totalCount);
|
VesktopNative.app.setBadgeCount(totalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
let toFind = 3;
|
let toFind = 3;
|
||||||
|
|
|
@ -118,7 +118,7 @@ function StreamSettings({
|
||||||
settings: StreamSettings;
|
settings: StreamSettings;
|
||||||
setSettings: Dispatch<SetStateAction<StreamSettings>>;
|
setSettings: Dispatch<SetStateAction<StreamSettings>>;
|
||||||
}) {
|
}) {
|
||||||
const [thumb] = useAwaiter(() => VencordDesktopNative.capturer.getLargeThumbnail(source.id), {
|
const [thumb] = useAwaiter(() => VesktopNative.capturer.getLargeThumbnail(source.id), {
|
||||||
fallbackValue: source.url,
|
fallbackValue: source.url,
|
||||||
deps: [source.id]
|
deps: [source.id]
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,9 +13,9 @@ import { useSettings } from "renderer/settings";
|
||||||
|
|
||||||
export default function SettingsUi() {
|
export default function SettingsUi() {
|
||||||
const Settings = useSettings();
|
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 [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled());
|
||||||
|
|
||||||
const switches: [keyof typeof Settings, string, string, boolean?, (() => boolean)?][] = [
|
const switches: [keyof typeof Settings, string, string, boolean?, (() => boolean)?][] = [
|
||||||
|
@ -79,7 +79,7 @@ export default function SettingsUi() {
|
||||||
onChange={v => {
|
onChange={v => {
|
||||||
Settings.appBadge = v;
|
Settings.appBadge = v;
|
||||||
if (v) setBadge();
|
if (v) setBadge();
|
||||||
else VencordDesktopNative.app.setBadgeCount(0);
|
else VesktopNative.app.setBadgeCount(0);
|
||||||
}}
|
}}
|
||||||
note="Show mention badge on the app icon"
|
note="Show mention badge on the app icon"
|
||||||
>
|
>
|
||||||
|
@ -143,7 +143,7 @@ export default function SettingsUi() {
|
||||||
href="about:blank"
|
href="about:blank"
|
||||||
onClick={e => {
|
onClick={e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
VencordDesktopNative.fileManager.showItemInFolder(Settings.vencordDir!);
|
VesktopNative.fileManager.showItemInFolder(Settings.vencordDir!);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Settings.vencordDir}
|
{Settings.vencordDir}
|
||||||
|
@ -156,7 +156,7 @@ export default function SettingsUi() {
|
||||||
<Button
|
<Button
|
||||||
size={Button.Sizes.SMALL}
|
size={Button.Sizes.SMALL}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const choice = await VencordDesktopNative.fileManager.selectVencordDir();
|
const choice = await VesktopNative.fileManager.selectVencordDir();
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case "cancelled":
|
case "cancelled":
|
||||||
case "invalid":
|
case "invalid":
|
||||||
|
|
|
@ -16,7 +16,7 @@ Object.defineProperty(Notification.prototype, "onclick", {
|
||||||
set(onClick) {
|
set(onClick) {
|
||||||
originalSetOnClick.call(this, function (this: unknown) {
|
originalSetOnClick.call(this, function (this: unknown) {
|
||||||
onClick.apply(this, arguments);
|
onClick.apply(this, arguments);
|
||||||
VencordDesktopNative.win.focus();
|
VesktopNative.win.focus();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
configurable: true
|
configurable: true
|
||||||
|
|
|
@ -23,7 +23,7 @@ export async function openInviteModal(code: string) {
|
||||||
const { invite } = await InviteActions.resolveInvite(code, "Desktop Modal");
|
const { invite } = await InviteActions.resolveInvite(code, "Desktop Modal");
|
||||||
if (!invite) return false;
|
if (!invite) return false;
|
||||||
|
|
||||||
VencordDesktopNative.win.focus();
|
VesktopNative.win.focus();
|
||||||
|
|
||||||
FluxDispatcher.dispatch({
|
FluxDispatcher.dispatch({
|
||||||
type: "INVITE_MODAL_OPEN",
|
type: "INVITE_MODAL_OPEN",
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function addPatch<P extends PatchData>(p: P) {
|
||||||
if (typeof r.replace === "string") r.replace = r.replace.replaceAll("$self", "VCDP");
|
if (typeof r.replace === "string") r.replace = r.replace.replaceAll("$self", "VCDP");
|
||||||
}
|
}
|
||||||
|
|
||||||
patch.plugin = "VencordDesktop";
|
patch.plugin = "Vesktop";
|
||||||
Vencord.Plugins.patches.push(patch);
|
Vencord.Plugins.patches.push(patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,12 @@ addPatch({
|
||||||
}
|
}
|
||||||
|
|
||||||
const cb = (w: string, c: string[]) => {
|
const cb = (w: string, c: string[]) => {
|
||||||
VencordDesktopNative.spellcheck.offSpellcheckResult(cb);
|
VesktopNative.spellcheck.offSpellcheckResult(cb);
|
||||||
word = w;
|
word = w;
|
||||||
corrections = c;
|
corrections = c;
|
||||||
openMenu();
|
openMenu();
|
||||||
};
|
};
|
||||||
VencordDesktopNative.spellcheck.onSpellcheckResult(cb);
|
VesktopNative.spellcheck.onSpellcheckResult(cb);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,14 +57,14 @@ addContextMenuPatch("textarea-context", children => () => {
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id={"vcd-spellcheck-suggestion-" + c}
|
id={"vcd-spellcheck-suggestion-" + c}
|
||||||
label={c}
|
label={c}
|
||||||
action={() => VencordDesktopNative.spellcheck.replaceMisspelling(c)}
|
action={() => VesktopNative.spellcheck.replaceMisspelling(c)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<Menu.MenuSeparator />
|
<Menu.MenuSeparator />
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="vcd-spellcheck-learn"
|
id="vcd-spellcheck-learn"
|
||||||
label={`Add ${word} to dictionary`}
|
label={`Add ${word} to dictionary`}
|
||||||
action={() => VencordDesktopNative.spellcheck.addToDictionary(word)}
|
action={() => VesktopNative.spellcheck.addToDictionary(word)}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
import { useEffect, useReducer } from "@vencord/types/webpack/common";
|
import { useEffect, useReducer } from "@vencord/types/webpack/common";
|
||||||
import { SettingsStore } from "shared/utils/SettingsStore";
|
import { SettingsStore } from "shared/utils/SettingsStore";
|
||||||
|
|
||||||
export const Settings = new SettingsStore(VencordDesktopNative.settings.get());
|
export const Settings = new SettingsStore(VesktopNative.settings.get());
|
||||||
Settings.addGlobalChangeListener((o, p) => VencordDesktopNative.settings.set(o, p));
|
Settings.addGlobalChangeListener((o, p) => VesktopNative.settings.set(o, p));
|
||||||
|
|
||||||
export function useSettings() {
|
export function useSettings() {
|
||||||
const [, update] = useReducer(x => x + 1, 0);
|
const [, update] = useReducer(x => x + 1, 0);
|
||||||
|
|
Reference in a new issue