Merge branch 'main' into main
This commit is contained in:
		
						commit
						032b9b3659
					
				
					 14 changed files with 3309 additions and 2709 deletions
				
			
		
							
								
								
									
										1
									
								
								.npmrc
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								.npmrc
									
									
									
									
									
								
							|  | @ -1 +1,2 @@ | |||
| node-linker=hoisted | ||||
| package-manager-strict=false | ||||
|  | @ -61,7 +61,7 @@ To check which version is appropriate for your system, type `uname -m` in a term | |||
| There are unofficial packages created by the community. They are not officially supported by us; so, before reporting issues, please first confirm the issue also happens on official builds. When in doubt, consult with their packager first. The Flatpak and AppImage should work on any distro that [supports them](https://flatpak.org/setup/), so I recommend you just use those instead! | ||||
| 
 | ||||
| - Arch Linux: [Vesktop on the Arch User Repository (AUR)](https://aur.archlinux.org/packages?K=vesktop) | ||||
| - NixOS: https://nixos.wiki/wiki/Discord#Vesktop | ||||
| - NixOS: https://wiki.nixos.org/wiki/Discord#Vesktop | ||||
| - Windows (via Scoop): https://scoop.sh/#/apps?q=Vesktop | ||||
| 
 | ||||
| ## Building from source | ||||
|  |  | |||
							
								
								
									
										33
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								package.json
									
									
									
									
									
								
							|  | @ -27,15 +27,15 @@ | |||
|         "arrpc": "github:OpenAsar/arrpc#6960a8fd4d65d566da93dbdb8a7ca474aa0a3c9c" | ||||
|     }, | ||||
|     "optionalDependencies": { | ||||
|         "@vencord/venmic": "^3.4.2" | ||||
|         "@vencord/venmic": "^3.5.0" | ||||
|     }, | ||||
|     "devDependencies": { | ||||
|         "@fal-works/esbuild-plugin-global-externals": "^2.1.2", | ||||
|         "@types/node": "^20.11.26", | ||||
|         "@types/react": "^18.2.65", | ||||
|         "@types/react": "^18.2.0", | ||||
|         "@typescript-eslint/eslint-plugin": "^7.2.0", | ||||
|         "@typescript-eslint/parser": "^7.2.0", | ||||
|         "@vencord/types": "^0.1.2", | ||||
|         "@vencord/types": "^1.8.4", | ||||
|         "dotenv": "^16.4.5", | ||||
|         "electron": "^29.1.1", | ||||
|         "electron-builder": "^24.13.3", | ||||
|  | @ -136,20 +136,21 @@ | |||
|             "icon": "build/icon.icns", | ||||
|             "iconSize": 105, | ||||
|             "window": { | ||||
|               "width": 512, | ||||
|               "height": 340 | ||||
|                 "width": 512, | ||||
|                 "height": 340 | ||||
|             }, | ||||
|        | ||||
|             "contents": [{ | ||||
|                 "x": 140, | ||||
|                 "y": 160 | ||||
|             }, | ||||
|             { | ||||
|                 "x": 372, | ||||
|                 "y": 160, | ||||
|                 "type": "link", | ||||
|                 "path": "/Applications" | ||||
|             }] | ||||
|             "contents": [ | ||||
|                 { | ||||
|                     "x": 140, | ||||
|                     "y": 160 | ||||
|                 }, | ||||
|                 { | ||||
|                     "x": 372, | ||||
|                     "y": 160, | ||||
|                     "type": "link", | ||||
|                     "path": "/Applications" | ||||
|                 } | ||||
|             ] | ||||
|         }, | ||||
|         "nsis": { | ||||
|             "include": "build/installer.nsh", | ||||
|  |  | |||
							
								
								
									
										5871
									
								
								pnpm-lock.yaml
									
									
									
									
									
								
							
							
						
						
									
										5871
									
								
								pnpm-lock.yaml
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -40,6 +40,10 @@ function init() { | |||
|         app.commandLine.appendSwitch("disable-smooth-scrolling"); | ||||
|     } | ||||
| 
 | ||||
|     // disable renderer backgrounding to prevent the app from unloading when in the background
 | ||||
|     // https://github.com/electron/electron/issues/2822
 | ||||
|     app.commandLine.appendSwitch("disable-renderer-backgrounding"); | ||||
| 
 | ||||
|     // work around chrome 66 disabling autoplay by default
 | ||||
|     app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required"); | ||||
|     // WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows.
 | ||||
|  |  | |||
|  | @ -93,12 +93,8 @@ handle(IpcEvents.MAXIMIZE, e => { | |||
|     } | ||||
| }); | ||||
| 
 | ||||
| handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => { | ||||
|     const ses = session.defaultSession; | ||||
| 
 | ||||
|     const available = ses.availableSpellCheckerLanguages; | ||||
|     const applicable = languages.filter(l => available.includes(l)).slice(0, 3); | ||||
|     if (applicable.length) ses.setSpellCheckerLanguages(applicable); | ||||
| handleSync(IpcEvents.SPELLCHECK_GET_AVAILABLE_LANGUAGES, e => { | ||||
|     e.returnValue = session.defaultSession.availableSpellCheckerLanguages; | ||||
| }); | ||||
| 
 | ||||
| handle(IpcEvents.SPELLCHECK_REPLACE_MISSPELLING, (e, word: string) => { | ||||
|  |  | |||
|  | @ -12,6 +12,8 @@ import { | |||
|     Menu, | ||||
|     MenuItemConstructorOptions, | ||||
|     nativeTheme, | ||||
|     screen, | ||||
|     session, | ||||
|     Tray | ||||
| } from "electron"; | ||||
| import { rm } from "fs/promises"; | ||||
|  | @ -269,7 +271,9 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions { | |||
|         height: height ?? DEFAULT_HEIGHT | ||||
|     } as BrowserWindowConstructorOptions; | ||||
| 
 | ||||
|     if (x != null && y != null) { | ||||
|     const storedDisplay = screen.getAllDisplays().find(display => display.id === State.store.displayid); | ||||
| 
 | ||||
|     if (x != null && y != null && storedDisplay) { | ||||
|         options.x = x; | ||||
|         options.y = y; | ||||
|     } | ||||
|  | @ -317,6 +321,7 @@ function initWindowBoundsListeners(win: BrowserWindow) { | |||
| 
 | ||||
|     const saveBounds = () => { | ||||
|         State.store.windowBounds = win.getBounds(); | ||||
|         State.store.displayid = screen.getDisplayMatching(State.store.windowBounds).id; | ||||
|     }; | ||||
| 
 | ||||
|     win.on("resize", saveBounds); | ||||
|  | @ -356,12 +361,27 @@ function initSettingsListeners(win: BrowserWindow) { | |||
|     addSettingsListener("enableMenu", enabled => { | ||||
|         win.setAutoHideMenuBar(enabled ?? false); | ||||
|     }); | ||||
| 
 | ||||
|     addSettingsListener("spellCheckLanguages", languages => initSpellCheckLanguages(win, languages)); | ||||
| } | ||||
| 
 | ||||
| async function initSpellCheckLanguages(win: BrowserWindow, languages?: string[]) { | ||||
|     languages ??= await win.webContents.executeJavaScript("[...new Set(navigator.languages)]").catch(() => []); | ||||
|     if (!languages) return; | ||||
| 
 | ||||
|     const ses = session.defaultSession; | ||||
| 
 | ||||
|     const available = ses.availableSpellCheckerLanguages; | ||||
|     const applicable = languages.filter(l => available.includes(l)).slice(0, 5); | ||||
|     if (applicable.length) ses.setSpellCheckerLanguages(applicable); | ||||
| } | ||||
| 
 | ||||
| function initSpellCheck(win: BrowserWindow) { | ||||
|     win.webContents.on("context-menu", (_, data) => { | ||||
|         win.webContents.send(IpcEvents.SPELLCHECK_RESULT, data.misspelledWord, data.dictionarySuggestions); | ||||
|     }); | ||||
| 
 | ||||
|     initSpellCheckLanguages(win, Settings.store.spellCheckLanguages); | ||||
| } | ||||
| 
 | ||||
| function createMainWindow() { | ||||
|  |  | |||
|  | @ -35,11 +35,6 @@ function loadSettings<T extends object = any>(file: string, name: string) { | |||
| } | ||||
| 
 | ||||
| export const Settings = loadSettings<TSettings>(SETTINGS_FILE, "Vesktop settings"); | ||||
| if (Object.hasOwn(Settings.plain, "discordWindowsTitleBar")) { | ||||
|     Settings.plain.customTitleBar = Settings.plain.discordWindowsTitleBar; | ||||
|     delete Settings.plain.discordWindowsTitleBar; | ||||
|     Settings.markAsChanged(); | ||||
| } | ||||
| 
 | ||||
| export const VencordSettings = loadSettings<any>(VENCORD_SETTINGS_FILE, "Vencord settings"); | ||||
| 
 | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ export const VesktopNative = { | |||
|         set: (settings: Settings, path?: string) => invoke<void>(IpcEvents.SET_SETTINGS, settings, path) | ||||
|     }, | ||||
|     spellcheck: { | ||||
|         setLanguages: (languages: readonly string[]) => invoke<void>(IpcEvents.SPELLCHECK_SET_LANGUAGES, languages), | ||||
|         getAvailableLanguages: () => sendSync<string[]>(IpcEvents.SPELLCHECK_GET_AVAILABLE_LANGUAGES), | ||||
|         onSpellcheckResult(cb: SpellCheckerResultCallback) { | ||||
|             spellCheckCallbacks.add(cb); | ||||
|         }, | ||||
|  |  | |||
|  | @ -40,5 +40,3 @@ if (IS_DEV) { | |||
|     }); | ||||
| } | ||||
| // #endregion
 | ||||
| 
 | ||||
| VesktopNative.spellcheck.setLanguages(window.navigator.languages); | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ import "./themedSplash"; | |||
| console.log("read if cute :3"); | ||||
| 
 | ||||
| export * as Components from "./components"; | ||||
| import { findByPropsLazy } from "@vencord/types/webpack"; | ||||
| import { findByPropsLazy, onceReady } from "@vencord/types/webpack"; | ||||
| import { FluxDispatcher } from "@vencord/types/webpack/common"; | ||||
| 
 | ||||
| import SettingsUi from "./components/settings/Settings"; | ||||
|  | @ -52,8 +52,10 @@ const arRPC = Vencord.Plugins.plugins["WebRichPresence (arRPC)"] as any as { | |||
|     handleEvent(e: MessageEvent): void; | ||||
| }; | ||||
| 
 | ||||
| VesktopNative.arrpc.onActivity(data => { | ||||
| VesktopNative.arrpc.onActivity(async data => { | ||||
|     if (!Settings.store.arRPC) return; | ||||
| 
 | ||||
|     await onceReady; | ||||
| 
 | ||||
|     arRPC.handleEvent(new MessageEvent("message", { data })); | ||||
| }); | ||||
|  |  | |||
|  | @ -6,7 +6,8 @@ | |||
| 
 | ||||
| import { addContextMenuPatch } from "@vencord/types/api/ContextMenu"; | ||||
| import { findStoreLazy } from "@vencord/types/webpack"; | ||||
| import { FluxDispatcher, Menu, useStateFromStores } from "@vencord/types/webpack/common"; | ||||
| import { FluxDispatcher, Menu, useMemo, useStateFromStores } from "@vencord/types/webpack/common"; | ||||
| import { useSettings } from "renderer/settings"; | ||||
| 
 | ||||
| import { addPatch } from "./shared"; | ||||
| 
 | ||||
|  | @ -50,7 +51,16 @@ addContextMenuPatch("textarea-context", children => { | |||
|     const spellCheckEnabled = useStateFromStores([SpellCheckStore], () => SpellCheckStore.isEnabled()); | ||||
|     const hasCorrections = Boolean(word && corrections?.length); | ||||
| 
 | ||||
|     children.push( | ||||
|     const availableLanguages = useMemo(VesktopNative.spellcheck.getAvailableLanguages, []); | ||||
| 
 | ||||
|     const settings = useSettings(); | ||||
|     const spellCheckLanguages = (settings.spellCheckLanguages ??= [...new Set(navigator.languages)]); | ||||
| 
 | ||||
|     const pasteSectionIndex = children.findIndex(c => c?.props?.children?.some(c => c?.props?.id === "paste")); | ||||
| 
 | ||||
|     children.splice( | ||||
|         pasteSectionIndex === -1 ? children.length : pasteSectionIndex, | ||||
|         0, | ||||
|         <Menu.MenuGroup> | ||||
|             {hasCorrections && ( | ||||
|                 <> | ||||
|  | @ -69,14 +79,39 @@ addContextMenuPatch("textarea-context", children => { | |||
|                     /> | ||||
|                 </> | ||||
|             )} | ||||
|             <Menu.MenuCheckboxItem | ||||
|                 id="vcd-spellcheck-enabled" | ||||
|                 label="Enable Spellcheck" | ||||
|                 checked={spellCheckEnabled} | ||||
|                 action={() => { | ||||
|                     FluxDispatcher.dispatch({ type: "SPELLCHECK_TOGGLE" }); | ||||
|                 }} | ||||
|             /> | ||||
| 
 | ||||
|             <Menu.MenuItem id="vcd-spellcheck-settings" label="Spellcheck Settings"> | ||||
|                 <Menu.MenuCheckboxItem | ||||
|                     id="vcd-spellcheck-enabled" | ||||
|                     label="Enable Spellcheck" | ||||
|                     checked={spellCheckEnabled} | ||||
|                     action={() => { | ||||
|                         FluxDispatcher.dispatch({ type: "SPELLCHECK_TOGGLE" }); | ||||
|                     }} | ||||
|                 /> | ||||
| 
 | ||||
|                 <Menu.MenuItem id="vcd-spellcheck-languages" label="Languages" disabled={!spellCheckEnabled}> | ||||
|                     {availableLanguages.map(lang => { | ||||
|                         const isEnabled = spellCheckLanguages.includes(lang); | ||||
|                         return ( | ||||
|                             <Menu.MenuCheckboxItem | ||||
|                                 id={"vcd-spellcheck-lang-" + lang} | ||||
|                                 label={lang} | ||||
|                                 checked={isEnabled} | ||||
|                                 disabled={!isEnabled && spellCheckLanguages.length >= 5} | ||||
|                                 action={() => { | ||||
|                                     const newSpellCheckLanguages = spellCheckLanguages.filter(l => l !== lang); | ||||
|                                     if (newSpellCheckLanguages.length === spellCheckLanguages.length) { | ||||
|                                         newSpellCheckLanguages.push(lang); | ||||
|                                     } | ||||
| 
 | ||||
|                                     settings.spellCheckLanguages = newSpellCheckLanguages; | ||||
|                                 }} | ||||
|                             /> | ||||
|                         ); | ||||
|                     })} | ||||
|                 </Menu.MenuItem> | ||||
|             </Menu.MenuItem> | ||||
|         </Menu.MenuGroup> | ||||
|     ); | ||||
| }); | ||||
|  |  | |||
|  | @ -29,7 +29,7 @@ export const enum IpcEvents { | |||
|     UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD", | ||||
|     UPDATE_IGNORE = "VCD_UPDATE_IGNORE", | ||||
| 
 | ||||
|     SPELLCHECK_SET_LANGUAGES = "VCD_SPELLCHECK_SET_LANGUAGES", | ||||
|     SPELLCHECK_GET_AVAILABLE_LANGUAGES = "VCD_SPELLCHECK_GET_AVAILABLE_LANGUAGES", | ||||
|     SPELLCHECK_RESULT = "VCD_SPELLCHECK_RESULT", | ||||
|     SPELLCHECK_REPLACE_MISSPELLING = "VCD_SPELLCHECK_REPLACE_MISSPELLING", | ||||
|     SPELLCHECK_ADD_TO_DICTIONARY = "VCD_SPELLCHECK_ADD_TO_DICTIONARY", | ||||
|  |  | |||
							
								
								
									
										5
									
								
								src/shared/settings.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								src/shared/settings.d.ts
									
									
									
									
										vendored
									
									
								
							|  | @ -21,8 +21,6 @@ export interface Settings { | |||
|     appBadge?: boolean; | ||||
|     disableMinSize?: boolean; | ||||
|     clickTrayToShowHide?: boolean; | ||||
|     /** @deprecated use customTitleBar */ | ||||
|     discordWindowsTitleBar?: boolean; | ||||
|     customTitleBar?: boolean; | ||||
| 
 | ||||
|     checkUpdates?: boolean; | ||||
|  | @ -30,12 +28,15 @@ export interface Settings { | |||
|     splashTheming?: boolean; | ||||
|     splashColor?: string; | ||||
|     splashBackground?: string; | ||||
| 
 | ||||
|     spellCheckLanguages?: string[]; | ||||
| } | ||||
| 
 | ||||
| export interface State { | ||||
|     maximized?: boolean; | ||||
|     minimized?: boolean; | ||||
|     windowBounds?: Rectangle; | ||||
|     displayid: int; | ||||
| 
 | ||||
|     skippedUpdate?: string; | ||||
|     firstLaunch?: boolean; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 vee
						vee