dscalzi / HeliosLauncher

☀ Custom launcher for modded minecraft written in Electron and Node.js
MIT License
838 stars 1.73k forks source link

Full code refacto and project restructuration + Svelte 🎉 #275

Closed Shadowner closed 9 months ago

Shadowner commented 1 year ago

Hello, I really appreciate this open-source project, and I think that TypeScript could be really useful to implement new features and more!

This is totally far from finished (that's why it's in draft). I just wanted to know if anyone had some advice or anything on how I should organize the src repository. :D

There isn't a lot of optimization, just addressing the more obvious parts and refactoring the project :)

Hope you like it !

dscalzi commented 1 year ago

I have tried to do this in the past but ran into a lot of problems. The direction I have been going in is to rewrite and move core code to helios-core. A big problem is I want to use strict mode, but the UI js code is all put into the global scope. So some files reference variables that are "undefined" because they were already injected into the global scope by a file loaded beforehand. A large part of this is going to be covered by the assetguard-2 PR I am working on, but I really don't know what to do about the UI code (short of rewriting it).

Shadowner commented 1 year ago

I Actually have an idea to make the view stric, will come back when I'm on this part of the refacto

dscalzi commented 1 year ago

ok, just be aware that assetguard-2 will definitely be coming into master at some point. I don't have an exact timeframe because I do it in my freetime, but the old code really needs to be replaced. When the launcher was first written the nodejs ecosystem was really quite different (async/await was not even in the runtime, and libs largely used callbacks not promises). When it does eventually land this will need to be rebased off those changes.

Reference: https://github.com/dscalzi/HeliosLauncher/pull/270 https://github.com/dscalzi/helios-core/pull/2 https://github.com/dscalzi/helios-distribution-types/compare/master...feature/1.1.0

Shadowner commented 1 year ago

@dscalzi Ok I understand the complexity of the problem now. At this point it's not just only refactoring, but doing the entire view from scratch.

Have you started doing something ? I could replicate the entire design using Svelt if you want :D

dscalzi commented 1 year ago

@dscalzi Ok I understand the complexity of the problem now. At this point it's not just only refactoring, but doing the entire view from scratch.

Have you started doing something ? I could replicate the entire design using Svelt if you want :D

I actually would like to use svelte, if you could set up a quick POC (proof of concept) of a simple svelte view in electron I would be happy to take a look. Don't do too much yet though, need to make sure that the POC looks good first!

dscalzi commented 1 year ago

Also, I started redoing everything in react ("v2") but it was such a headache. I would end up doing 1 hour of real coding and 8 hours of getting the stupid 3rd party libs to all work together. https://github.com/dscalzi/HeliosLauncher/tree/ts-refactor

That's why my current approach is to break out functionality, rewrite in helios-core, and then consume helios-core in the main launcher.

Shadowner commented 1 year ago

Okay, nice. Has for now I will just replicate the actual design of the launcher because it will be pretty easy (Thank's for you comment in the code / css, it's really helpful) .

Shadowner commented 1 year ago

Okay, @dscalzi , here's a svelte POC using Vite for real-time development with nodemon for Electron changes. Currently, there's no logic on the view side but i'm already working on it.

I'm continuing to adapt the logic side for AssetGuardV1 to make it cleaner until you release AssetGuardV2 :) There is just the news part that i didn't adapt because I feel lazy for now To use It juste make npm start

(Didn't saw your message "don't do too much" 😅😅)

Shadowner commented 1 year ago

Here it is for tonight if you have any question feel free to ask here is my discord to make speaking more fluent (as we're not in the same timezon) : Shado#7227

dscalzi commented 1 year ago

Planning on taking a look at this once assetguard-2 is done. I just got through rewriting the javaguard logic, the next step is to integrate the openjdk download with the new download engine. That is probably going to involve rewriting the control flow logic in landing.js (but it's just one or two functions so it shouldnt be a massive effort. From there I need to test the error handling and add more unit tests into helios-core.

dscalzi commented 1 year ago

assetguard-2 has landed