Skip to content

Conversation

@Vendicated
Copy link
Owner

@Vendicated Vendicated commented Nov 24, 2025

Unifies and organises all Vencord styles into one central root node. The main motivation behind this is that previously, styles were all over the place and it was easy to accidentally change the order in which they were inserted, which breaks specificity. That issue happened in an earlier version of this PR. Thus I decided to also reorganise.

image

Also refactors the preload script to support Electron process sandboxing, which heavily restricts what the preload can access.

This will only be used on Vesktop because the Discord desktop app does not support sandboxing. But once they eventually enable it, we will already be prepared :)

This is needed for Vencord/Vesktop#1206


Same PR because they are tangentially related (both refactor Vencord css logic to use IPC instead of doing it fully in the preload)

Vendicated added a commit to Vencord/Vesktop that referenced this pull request Nov 24, 2025
@Vendicated
Copy link
Owner Author

Essentially sandboxing makes it so that the preload script is also sandboxed and has similar access to the renderer (plus a few electron apis). So we have to move all file operations and such to the main process via IPC call. That's what this PR does

@Vendicated Vendicated changed the title Refactor preload to support preload sandboxing Unify styles into single root node & support preload sandboxing Nov 25, 2025
Vendicated

This comment was marked as resolved.

@Vendicated Vendicated marked this pull request as ready for review December 7, 2025 01:19
@Vendicated Vendicated requested review from Nuckyz and Copilot December 7, 2025 01:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors Vencord's CSS management system to unify all styles into a single hierarchical root node and updates the preload script to support Electron process sandboxing for future compatibility.

  • Centralizes all Vencord styles under a vencord-root node with three child nodes for core, managed, and user styles to maintain consistent specificity ordering
  • Migrates CSS loading from the preload script to IPC handlers in the main process to support sandboxed preload contexts
  • Moves classNameFactory utility from @api/Styles to @utils/css with backwards compatibility maintained

Reviewed changes

Copilot reviewed 50 out of 50 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/api/Styles.ts Introduces new hierarchical style root nodes and initStyles() function, exports deprecated classNameFactory for backwards compatibility
src/utils/css.ts Adds classNameFactory and classNameToSelector utilities moved from Styles API
src/preload.ts Refactored to use IPC for CSS loading instead of direct file system access, supporting sandboxed contexts
src/main/ipcMain.ts Adds IPC handlers for renderer CSS retrieval and file watching, consolidates file watcher initialization
src/main/patcher.ts Removes initIpc call as watchers now initialize via IPC request
src/shared/IpcEvents.ts Adds new IPC events for CSS/JS retrieval and removes unused theme upload/delete events
src/VencordNative.ts Adds stub implementations for removed theme methods, adds renderer CSS and Monaco theme getters
src/Vencord.ts Updates to use new initStyles() and coreStyleRootNode
src/api/Themes.ts Updates to append styles to userStyleRootNode instead of document root
src/components/css.ts Removed file, functionality moved to src/api/Styles.ts
browser/* Updates browser extension to pass renderer CSS URL via postMessage instead of direct insertion
scripts/build/buildWeb.mjs Updates userscript to set CSS via global variable instead of direct DOM insertion
src/plugins/* Updates 20+ plugin files to import classNameFactory from @utils/css instead of @api/Styles
src/components/* Updates component files to import classNameFactory from @utils/css

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants