So, this PR has a lot, because I got kinda carried away with things. I didn't do a lot of Electron before so I was reading stuff and kinda trying things out to learn.
The focus of this PR is on robustness. It needs more work to achieve that. This is not ready to be merged. I need to test it a bit myself after I rebased this thing on your recent changes. Then I'll give it to a few smaller streamers for real-world testing.
Tell me if you disagree with any of the changes. I know I didn't discuss anything beforehand and I unilaterally made some pretty big decisions so I don't mind having to remove some stuff you don't like.
The changes in broad strokes are:
This PR uses parcel and electron-forge for the build and packaging. I used electron-forge because I only had the JS code and not the build setup when I started working on this. It can handle native modules like SQLite quite nicely. I added Parcel because it is pretty simple to use compared to most bundlers, and you kinda need a bundler to be able to disable node emulation (since you don't get require() in renderer scripts).
Using a SQLite database for storing guesses. This replaces most in-memory state. The database ensures consistency. We can calculate scores with the database instead of adding manually, for example. Because the database is stored in a file, we can now also restore games (eg. the streamer can close the app mid-round and continue the same round+game at a later time).
This should fix issues with people double-guessing on the same round, among others.
Context isolation is enabled and node emulation is disabled in renderer scripts. This is actually very important for security. geoguessr.com is a remote website, not a local application like is usually the case with electron apps. This means that a security hole in geoguessr.com could allow remote code execution through the chatguessr app, including access to the streamer's files. It's much more severe than it would be if you play geoguessr through the browser.
Flags and other assets are served using protocol handlers instead of file:// paths or a builtin web server. This lets us expose things to the web view in a very granular way.
Streaks are handled locally using country-iso, an npm package that has highly-detailed country outlines. Getting the country is now much faster because you don't have to wait for the network. It's significantly more accurate than codegrid was. It also counts the islands near the Chinese coast that are currently under Taiwanese sovereignty as Taiwan instead of China, which fixes one of the most common ways streaks are incorrectly broken.
Streamers can add custom flags. I made this for eviecaps and it's a bit fiddly, so I think we shouldn't document this for now and have it as kind of a secret feature.
Flag lookup now uses match-sorter, an npm package that searches a list based on user input. It's a bit more robust than the custom search implementation was.
I also changed the flag definitions so that !flag korea gives you the south korean flag instead of the north korean one … this is just because that is usually what people expect when they do !flag korea. DPRK doesn't have street view after all (nor many chatguessr players).
What this PR definitely needs:
[ ] Scores stored in electron-store are currently basically discarded. They should be imported in the SQLite database so users don't lose streak records and things like that.
[x] Cleaning up some things that messed up during the rebase. This PR has the build scripts from electron-builder AND electron-forge but only one should be used.
I have a few other things in local branches as well that could be added later.
a React-based scoreboard implementation. My hope was that it is easier to understand / maybe even faster than the jQuery+DataTables implementation. ATM it is not faster, so it needs work.
polyline rendering using https://deck.gl instead of Google Maps's builtin Polyline. This improves performance a lot for high numbers of guesses. deck.gl can easily support thousands of guesses.
So, this PR has a lot, because I got kinda carried away with things. I didn't do a lot of Electron before so I was reading stuff and kinda trying things out to learn.
The focus of this PR is on robustness. It needs more work to achieve that. This is not ready to be merged. I need to test it a bit myself after I rebased this thing on your recent changes. Then I'll give it to a few smaller streamers for real-world testing.
Tell me if you disagree with any of the changes. I know I didn't discuss anything beforehand and I unilaterally made some pretty big decisions so I don't mind having to remove some stuff you don't like.
The changes in broad strokes are:
parcel
andelectron-forge
for the build and packaging. I used electron-forge because I only had the JS code and not the build setup when I started working on this. It can handle native modules like SQLite quite nicely. I added Parcel because it is pretty simple to use compared to most bundlers, and you kinda need a bundler to be able to disable node emulation (since you don't getrequire()
in renderer scripts).file://
paths or a builtin web server. This lets us expose things to the web view in a very granular way.country-iso
, an npm package that has highly-detailed country outlines. Getting the country is now much faster because you don't have to wait for the network. It's significantly more accurate than codegrid was. It also counts the islands near the Chinese coast that are currently under Taiwanese sovereignty as Taiwan instead of China, which fixes one of the most common ways streaks are incorrectly broken.match-sorter
, an npm package that searches a list based on user input. It's a bit more robust than the custom search implementation was.!flag korea
gives you the south korean flag instead of the north korean one … this is just because that is usually what people expect when they do!flag korea
. DPRK doesn't have street view after all (nor many chatguessr players).What this PR definitely needs:
electron-store
are currently basically discarded. They should be imported in the SQLite database so users don't lose streak records and things like that.I have a few other things in local branches as well that could be added later.