Skip to content

Conversation

@dengr1065
Copy link
Collaborator

@dengr1065 dengr1065 commented Apr 7, 2025

Draft. Mods are broken, but the foundations for ASAR modding are laid. Interesting parts:

  • await import("mod://mod-id/path/to/file.js") works and resolves to a module. The code is shown in Sources panel of devtools
  • Static relative imports import { func } from "./other_file.js" work
  • Dynamic relative imports not tested yet
  • await fetch("mod://mod-id/mod.json").then(r => r.text()) works. Proper resources were not tested (audio/video is more interesting as it requires streaming)

The entire main process mod loader framework is quite overcomplicated, but it should be easy to expand even further, such as adding auto-reload support for development purposes. Right now mods are reloaded on each get-mods IPC call which is not the ideal solution, eventually this should be split into a different IPC method.

The renderer part is missing and will report errors if any mod is loaded.

@dengr1065 dengr1065 added the enhancement New feature or request label Apr 7, 2025
Consider mods broken in this commit. Many areas are unfinished and use
weird or missing types.
Was removed completely along with the preloader script.
The linkApp method is removed as it was unused. A getter is used to
ensure best development experience. It can be further improved by adding
a guard for cases where GLOBAL_APP is not set yet.
Only load the mod with highest priority for now. Proper behavior would
be to keep metadata for all duplicates and load the first that isn't
disabled. This allows easy mod source switching (for example, user mods
and development mods)
Remove the debug option and code that used it. It is redundant due to
existence of --load-mod in the Electron wrapper.
Doesn't make much sense with how experimental CE is right now. A
different logic for checking whether a mod is compatible will be used
later.
@dengr1065 dengr1065 force-pushed the dengr1065/asar-modding-main branch from d96b638 to 321f517 Compare April 10, 2025 21:04
Also fix a few issues in Electron code. This is not as polished yet, UI
from old mod support was reused for now and is likely broken. Mods can
be loaded, but there isn't much QoL around the support for now.
The new mod locator system now respects the --safe-mode command line
switch, ignoring the user and distro mod directories.
For now it only includes a helper function to resolve file URLs and a
method that adds a CSS stylesheet to the document.
Not a complete rework. This is just a temporary improvement.
Not a proper fix, but this thing needs a huge refactor anyway. Goodbye,
a bug that existed ever since the first version of mod support!
@dengr1065 dengr1065 marked this pull request as ready for review April 13, 2025 01:20
@dengr1065
Copy link
Collaborator Author

Still needs a lot of work, but I'll consider it mergeable now. Real mods already exist :)

@dengr1065 dengr1065 merged commit 2b8709d into master Apr 13, 2025
1 check passed
@dengr1065 dengr1065 deleted the dengr1065/asar-modding-main branch June 16, 2025 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants