r/SwitchHacks • u/off-by-some • 23h ago
[development update] bounxy: bringing modern HTML, CSS and JavaScript to homebrew
Hi all 👋 I just wanted to share some progress photos of a development tool I've been working on in my free time called bounxy ("bouncy").
The general idea of the project is to allow people to develop native switch homebrew using HTML, CSS, JavaScript, and much of the tooling we're already accustomed to in web development, while still having access to the underlying native APIs of the console.
Some milestones I've completed thus far:
- Compiling a standalone, embeddable WebKit engine ("BunnyKit") from webkitgtk-2.50.6 with custom adaptations for the switch
- FFI for running native code from JavaScript, allowing direct access to hardware, system services, and native C/C++ libraries from web applications
- Live reloading and remote shell access (for my own sanity)
- Successful builds with docker, tested in both macOS and manjaro
Some milestones I'm working on include:
WebKit Compatibility, Rendering, and Performance
While I've managed to get a relatively modern version of WebKit running on the Switch, there's still quite a bit of work to do here. I'm particularly interested in getting a better understanding of the memory consumption, garbage collection, and general performance of WebKit on the Switch, especially as applications get a bit more complicated. While my small scale apps seem to render just fine, I'm unsure on how well some of this will scale to considerably larger applications, or even how much of WebKit's functionality is currently working as intended.
I've also been working on isolating the WebKit port into its own project ("BunnyKit"), as I don't particularly like the idea of the engine itself being coupled to bounxy for quite a few reasons. I'd quite like for people to be able to use it independently, complete with a docker image for building it, should they have some other use for it.
Application Packaging and Distribution
I'd ideally like for the process of building and distributing an application to be as uneventful as possible. You should be able to write an application with whatever web tooling you're comfortable with, run a command, and have a standalone NRO.
Someone downloading an application made with bounxy shouldn't necessarily have to know that it was made with bounxy in the first place.
Extensibility
Something I'd eventually like to iron out is a nice way for people to write and distribute their own native bindings and packages for bounxy.
While I'd certainly like to have a reasonably comprehensive standard library, I don't particularly want people to be reliant on me having implemented a binding for something before they're able to use it. Though, much like the standard library, some of this may come after release.
Vertical integration into a single bounxy command with enjoyable DX
I have most tools hooked up into a single CLI, however, they've all grown from general scripts i have laying around. This is what bounxy looks like now, however.
$ bounxy --help
Usage: bounxy COMMAND [OPTIONS]
Build HTML, CSS, and JavaScript apps for Nintendo Switch with live reload on real hardware.
Commands
create [NAME] Create a new app
dev Start the development server
deploy Install the last successful build of this app
devices Show the connected Switch or SD card
uninstall Remove bounxy development NRO
update Build and publish the runtime
cp | mv | ls | rm | mkdir | cat Manage files on the SD card over USB or Wi-Fi
shell [--native] [-c CODE | --stdin]
Open a JavaScript shell on the Switch, or run one command
screenshot [FILE] Save a screenshot from the Switch
clean Remove build outputThere are a few other things I'm still hoping to implement, such as integration with a local javascript debugger, a way to follow logs, along with some architecture work... just cleaning up each of these commands into their own isolated subpackages with tests, really.
There's not a concrete goal of done in this sense, other than I'm certainly... quite picky and opinionated about what a good DX looks like, all the way down to accessibility around terminal coloring. I often go through quite a few revisions until i settle into something that "feels right".
Automated Testing
Because always having a switch on-hand can be a bit of a pain, I've begun to try and iron out automated testing of software for the switch in general. Currently I have BunnyKit's automated testing suite passing against a personal fork of switch2pc (mostly extended to accommodate WebKit's garbage collector), though I'd certainly like to figure out a nicer harness and visual regression framework (for my own sanity).
But, being able to test changes to the actual switch binaries without reaching for my switch every time has been quite nice. I'd really like for some of this tooling to be useful to other homebrew developers, too, independent of bounxy.
Of course, there's still a good amount of testing to do on an actual switch, especially around rendering and performance.
A Standard Library
Now that i'm (mostly) happy with the FFI layer, I'd really like a default standard javascript library for interacting with the console. I'm still somewhat undecided on what the scope of this should be, and how much of the underlying native APIs I'd like to abstract away, if at all.
However, this one may be pushed off until after release.
I know this is a little long for a post, so the TLDR is that I'm working on a way to develop native switch homebrew with web technologies, and it's still very much a work in progress.
I'm a bit hesitant to release something like this until I consider it relatively seamless and actually useful to people other than myself, so I've decided to keep it private for the time being.
All the same, I figured some people here might find it interesting. I'd also be quite interested in hearing what other homebrew developers would like to have available to them in something like this, should such a desire exist
Thanks for stopping by 👋