Giter VIP home page Giter VIP logo

sol-gate's Introduction

sol-gate: A Freespace mod manager.

WORK IN PROGRESS

Why?

As a minimum viable product, Knossos works well. However, there are several issues with it that have made continued work on it difficult. The complex build process of both old-knossos and new-knossos makes onboarding new developers troublesome, and limitations with fsnebula's mods.json file mean the big usability issues with old-knossos are fundamentally unfixable.

User Goals

Minimise Check-for-updates time

Smaller, conditional API calls instead of downloading a single ~270MB JSON of global state when checking for updates means sol-gate is ready to go ASAP.

Speedy Updates

sol-gate tracks the contents of VP archives, so mod updates (both uploads and downloads) only consist of changed files, massively reducing network usage.

Locally Sourced Files

Many mods re-use models, textures, sounds and effects from each other. If another mod uses the same files, sol-gate will copy those instead of re-downloading them.

FSNebula compatability

Sol-gate is in very early development! The end goal here is a full replacement of the Knossos and FSNebula ecosystem, but sol-gate ships with the ability to query and install mods from FSNebula in the mean time.

Modder Goals

As you meant it

If you include files with the same name in different packages (i.e. advanced graphics packs with higher-rez texture overrides), sol-gate won't complain, no need to trick it by hiding some in VPs and keeping others unbundled.

FSO Builds and Tools

Freespace builds are treated as an entirely separate system to mods instead of being tacked-on as something like a dependency. Experimental builds are supported and need explicit opt-in from the user as a security feature. Modders can also exchange modelling and conversion tools and keep them automatically updated.

Building - Devs only at the moment, sorry!

Make sure you have installed:

Clone repo and run in the root directory:

cargo run

This should automatically:

  • Pull in the npm dependencies,
  • Build the frontend
  • Pull in and build Rust dependencies
  • Build executable and embed frontend
  • Run a debug version that will open in the browser.

Currently there's no button to trigger the API request to get the list of mods on FSNebula. Manually accessing http://localhost:4000/api/fsn/update (link here) once the server is running will initiate getting the list. This command will take a while to return, and the page will load with the message updated once the modlist has been processed.

Development

Backend

Development of backend is as can be expected, edit code and see if it works etc.

Frontend

Thankfully you don't need to know Rust for this! sol-gate's frontend is a SvelteKit app that can be developed and iterated on as any other.

You can use the npm dev server to speed up iteration. In one terminal run:

cargo run

This will launch a sol-gate instance on localhost:4000. We can't edit the frontend of this instance, but we can proxy requests to it's backend. In another terminal, cd into the frontend directory and run:

npm run dev

The npm development web server will boot up and open a page at localhost:XXXX. The page will will automatically reload when frontend files are saved. API requests are proxied to the running sol-gate instance.

Any changes made to frontend code should be picked up by cargo run and/or cargo build. This will automatically recomple the frontend for deployment and embed the updated version in the new executable.

Development FAQ

Why Rust?

Any package/mod manager does a lot of file and network operations. These are both prone to failure. A problem that keeps popping up with Knossos is the assumption of the success of downloads and file operations due to the underlying libraries not correctly identifying failures. Rust's checked errors system forces us to handle or propagate these sorts of failures. Simply put, network and file operations fail a lot, and the control flow of Rust errors makes this easier to reason about and forces you to handle them.

Why all this async/await nonsense?

This sort of program is heavily bound by file and network operations, and should be spending CPU cycles effectively on checksumming, database querying and de/compression rather than blocking on I/O. While Rust's asynchronous ecosystem still has some sharp edges (Pin, Unpin, Send/Sync across .await hell), it's happily being applied in global scale use cases. Using a cooperative multitasking runtime of many tasks across a fixed pool of threads also allows us to handle many short, concurrent operations (such as file downloading) without the overheads of thread creation (especially on our main target platform, Windows).

Why is this a web server that runs a page in the browser?

Cross-Platform GUI work isn't fun, and one of the major pain points for dev work on knossos was setting up Qt on Windows (this is also one of the reasons work on QtFRED is so intermittent). A web browser is a well specified, cross platform target that is strongly supported on all Freespace platforms. While Electron fills this role well, the Rust + Electron ecosystem doesn't seem mature at the moment.

Secondly, as our file/network operations already lend us to using asynchronous runtimes, we might as well embrace this apprach and offload a lot of the work of concurrent GUI operations onto the Node ecosystem and browser runtime - a space where async is the norm.

Finally, the end goal of sol-gate is as a client and server program to replace both knossos and the fsnebula mod server. Architecting sol-gate as a web server from the beginning makes implementing this much easier. Functionality to download files from another sol-gate instance is already partially implemented, using the same mechanism as streaming a file into a new VP archive, or fetching an image to display on the frontend. However, the API calls necessary aren't wired up yet as there's no user authentication in place.

In future, when sol-gate is in a reasonable state, the client might be migrated to something like Tauri instead of Electron so that we can leverage system webviews rather than shipping a massive binary that's mostly chromium.

Why are you using HTML+JS instead of a Rust frontend like Yew?

Freespace is a small modding community with an even smaller pool of developers, there's a few devs who know Rust but they'd rather not do GUI work, and frontend developers don't usually know Rust. The simplicity of the build process means that (hopefully) someone with zero Rust experience is capable of contributing to frontend work.

sol-gate's People

Contributors

dependabot[bot] avatar qazwsxal avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

johnafernandez

sol-gate's Issues

Nail Down API design and layout.

The design and structure of the API should be nailed down before any frontend work can really be done. Basic features such as:

  • Install Mod
  • Update Mod
  • Uninstall Mod
  • Launch Mod

Need to be in before even considering a frontend design

Dependency logic

Need to figure out the logic to be used for dependency resolution.
https://fsprojects.github.io/Paket/resolver.html paket's dependency resolution algorithm
https://www.debian.org/doc/manuals/aptitude/ch02s03s02.en.html apt's algorithm

http://www.cas.mcmaster.ca/~cas724/2007/paper2.pdf lot of theory stuff here.

Cargo's dependency resolution algorithm doesn't seem applicable here, cargo "features" don't map to fsnebula "packages" well.

In apt terms, it's probably best to treat a "mod" as a meta-package made up of several packages, (some optional). Dependencies on FSN/knossos can be thought as "package depends on set of other packages". That way we can flatten the mod/package tree, just need to make sure that a selected group of packages from the same mod have the same semver.

Frontend

Need someone who can actually do webdev to write a frontend (or learn it).
React? Vue? Svelte? Angular?
These are all words from a strange and distant land.

There's a basic React frontend at the moment, but I don't know how to retain state or use react hooks properly, so this will likely be a big undertaking.

  • #6 API design is a blocking issue for this, needs to be sorted frontend work can go ahead.

Download logic

Need to figure out the logic for what to download, where to download etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.