VencordDesktop -> VencordDesktopNative; add VencordDesktop global
This commit is contained in:
parent
7e0532444d
commit
b4a2c41e74
10 changed files with 17 additions and 25 deletions
|
@ -33,6 +33,7 @@ await Promise.all([
|
||||||
}),
|
}),
|
||||||
createContext({
|
createContext({
|
||||||
...CommonOpts,
|
...CommonOpts,
|
||||||
|
globalName: "VencordDesktop",
|
||||||
entryPoints: ["src/renderer/index.ts"],
|
entryPoints: ["src/renderer/index.ts"],
|
||||||
outfile: "dist/js/renderer.js",
|
outfile: "dist/js/renderer.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
|
|
3
src/globals.d.ts
vendored
3
src/globals.d.ts
vendored
|
@ -1,5 +1,6 @@
|
||||||
declare global {
|
declare global {
|
||||||
export var VencordDesktop: typeof import("./preload/VencordDesktop").VencordDesktop;
|
export var VencordDesktopNative: typeof import("preload/VencordDesktopNative").VencordDesktopNative;
|
||||||
|
export var VencordDesktop: typeof import("renderer/index");
|
||||||
// TODO
|
// TODO
|
||||||
export var Vencord: any;
|
export var Vencord: any;
|
||||||
export var vcdLS: typeof localStorage;
|
export var vcdLS: typeof localStorage;
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { ipcRenderer } from "electron";
|
import { app, ipcRenderer } from "electron";
|
||||||
import type { Settings } from "../main/settings";
|
import type { Settings } from "../main/settings";
|
||||||
import { FOCUS, GET_SETTINGS, RELAUNCH, SET_SETTINGS, SHOW_ITEM_IN_FOLDER } from "../shared/IpcEvents";
|
import { FOCUS, GET_SETTINGS, RELAUNCH, SET_SETTINGS, SHOW_ITEM_IN_FOLDER } from "../shared/IpcEvents";
|
||||||
|
|
||||||
export const VencordDesktop = {
|
export const VencordDesktopNative = {
|
||||||
app: {
|
app: {
|
||||||
relaunch: () => ipcRenderer.invoke(RELAUNCH)
|
relaunch: () => ipcRenderer.invoke(RELAUNCH),
|
||||||
|
getVersion: () => app.getVersion()
|
||||||
},
|
},
|
||||||
fileManager: {
|
fileManager: {
|
||||||
showItemInFolder: (path: string) => ipcRenderer.invoke(SHOW_ITEM_IN_FOLDER, path)
|
showItemInFolder: (path: string) => ipcRenderer.invoke(SHOW_ITEM_IN_FOLDER, path)
|
|
@ -1,8 +1,8 @@
|
||||||
import { contextBridge, ipcRenderer, webFrame } from "electron";
|
import { contextBridge, ipcRenderer, webFrame } from "electron";
|
||||||
import { GET_RENDERER_SCRIPT, GET_RENDERER_STYLES, GET_VENCORD_PRELOAD_FILE } from "../shared/IpcEvents";
|
import { GET_RENDERER_SCRIPT, GET_RENDERER_STYLES, GET_VENCORD_PRELOAD_FILE } from "../shared/IpcEvents";
|
||||||
import { VencordDesktop } from "./VencordDesktop";
|
import { VencordDesktopNative } from "./VencordDesktopNative";
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld("VencordDesktop", VencordDesktop);
|
contextBridge.exposeInMainWorld("VencordDesktopNative", VencordDesktopNative);
|
||||||
|
|
||||||
require(ipcRenderer.sendSync(GET_VENCORD_PRELOAD_FILE));
|
require(ipcRenderer.sendSync(GET_VENCORD_PRELOAD_FILE));
|
||||||
|
|
||||||
|
|
1
src/renderer/components/index.ts
Normal file
1
src/renderer/components/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { default as Settings } from "./Settings";
|
|
@ -7,7 +7,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);
|
||||||
VencordDesktop.win.focus();
|
VencordDesktopNative.win.focus();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
configurable: true
|
configurable: true
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import "./fixes";
|
import "./fixes";
|
||||||
import "./ui/patchSettings";
|
|
||||||
|
|
||||||
console.log("read if cute :3");
|
console.log("read if cute :3");
|
||||||
|
|
||||||
|
export * as Components from "./components";
|
||||||
|
export { PlainSettings, Settings } from "./settings";
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import { Common } from "./vencord";
|
||||||
|
|
||||||
const signals = new Set<() => void>();
|
const signals = new Set<() => void>();
|
||||||
|
|
||||||
export const PlainSettings = VencordDesktop.settings.get() as TSettings;
|
export const PlainSettings = VencordDesktopNative.settings.get() as TSettings;
|
||||||
export const Settings = makeChangeListenerProxy(PlainSettings, s => {
|
export const Settings = makeChangeListenerProxy(PlainSettings, s => {
|
||||||
VencordDesktop.settings.set(s);
|
VencordDesktopNative.settings.set(s);
|
||||||
signals.forEach(fn => fn());
|
signals.forEach(fn => fn());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { monkeyPatch } from "../../shared/utils/monkeyPatch";
|
|
||||||
import { Common, plugins } from "../vencord";
|
|
||||||
import Settings from "./Settings";
|
|
||||||
|
|
||||||
monkeyPatch(plugins.Settings, "makeSettingsCategories", function (this: unknown, original, { ID }: { ID: Record<string, unknown>; }) {
|
|
||||||
const cats = original.call(this, { ID });
|
|
||||||
cats.splice(1, 0, {
|
|
||||||
section: "VencordDesktop",
|
|
||||||
label: "Desktop Settings",
|
|
||||||
element: Settings,
|
|
||||||
onClick: () => Common.SettingsRouter.open("VencordDesktop")
|
|
||||||
});
|
|
||||||
|
|
||||||
return cats;
|
|
||||||
});
|
|
Loading…
Reference in a new issue