-
-
Notifications
You must be signed in to change notification settings - Fork 38
WIP fastn <package_name> command to launch a native window #2165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There are two ways to invoke fastn now, copied from help text:
```bash
Usage: fastn [OPTIONS] <package_name>
fastn [OPTIONS] <COMMAND>
```
Running with `package_name` required arg will launch a native window. On
platforms where cli is not the entrypoing (phones, macos.app) the UI
will launch with a default value for `package_name`.
Break the fastn crate into a lib and a main binary. Most of the functions in main.rs have been moved into lib.rs. The tauir.rs deals with tauri specific stuff and contains the entrypoint for mobile build of fastn. The assets and configs are generated using `cargo tauri init`
The initial tauri setup is working.
Remove some crates and traits from fastn-core
The cli entrypoint conditionally launches if `package_slug` flag is
passed
The app entrypoint always launches UI with a default slug
("design-system" for now).
The app entrypoint is not tested yet. The UI launches from cli just
fine.
The default slug will be replaced with "lets-os" when it's ready.
fastn/src/lib.rs
Outdated
| #[tracing::instrument] | ||
| pub async fn fastn_ui(slug: &str) -> fastn_core::Result<()> { | ||
| let pkg_dir = { | ||
| let mut data_dir = dirs::data_dir().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need some note on this. Where are these packages getting cloned? Can I run more than once instance of a package, eg checkout them twice, as each checkout will have its sqlite file for example. And if our file upload feature uploads files in the same folder, the two instances will have different files also going forward. Our editor may also modify these files etc.
Actually for every package we should have a template package that should be checked out, as that is what most people want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need some note on this. Where are these packages getting cloned?
at https://docs.rs/dirs/latest/dirs/fn.data_dir.html. I could not find a crate that provides android and ios paths. tauri does have a fs plugin that might help. This is what I am going to look into next. Package this for all platform and see what works and what needs tweaking.
Can I run more than once instance of a package, eg checkout them twice, as each checkout will have its sqlite file for example.
No. Every invocation of fastn design-system will launch the same design-system that is downloaded on disk. We can add support for running multiple packages in future by adding aliases. Like fastn design-system my-design-sytem and future invocations will do fastn my-design-system, this will store some metadata of what was the source package for this alias and we can update the aliased package using that.
Should be:
( |
|
I am focusing on running the current version as a GUI only app for mac and android. This part has a lot of unknowns (does fastn-core even compile for android/arm?) so it's better to do this first. |
The code has been changed quite a lot to let the tauri window open first and then spawn an actix server in the background. This is required for android where we want to launch the app first and then spawn a server in background.
This allows us to run the server inside a `tokio::spawn`. The code still compiles with this change and it also let's us compile the android part that was not compiling before.
|
The android app is stil not working. It launches and shows the loading screen and the http server runs in the background. But, the server crashes with a stack overfllow when a request is received. |
The generated code is supposed to be checked in to git. There's a gitignore file inside that ignored build artifacts. See: tauri-apps/tauri#8323
|
I guess it's the same issue or related to fastn not working in dev builds with stack overflow error. We really have to solve this someday. Not sure how to debug tho. |
Yes! After writing this comment I noticed that the tauri cli is building the crate in debug mode when I did |
|
Can we find out if |
It probably does, I have been able to run the http server with |
I might have to bring the tauri plugin back but it does not seem necessary at this point.
The debug build does not work because fastn-core crashes with stack overflow. Things work fine in release builds. The catch is, tauri is forcing to sign the release apk before it can run it in the emulator. I have create a dev signing script for this. This will have to change and we have to create a signing key when releasing it through github releases.
The cache_it function depends on a cache dir which it can't fetch on android. The path to the cache dir has to come from tauri, this requires changing params of some functions so I'm simply avoiding it for now. FWIW we don't ever read from this cache (the code is commented out) so caching it is just extra work with no benefits. I could be wrong tho and we might be reading from this cache in some other place but it does not seem like it from my quick inspection.
https://youtu.be/BT9QuvR48vc It's working :) |
We're moving HTTP stuff to pista_lib. The pista_lib in future will provide more capabilities like p2p networking and sqlite store with automerge(CRDTs) so it makes sense to have the driver like code (http server and tauri app code) in there.
fastn serve <package-name>in a background threadfastndoes not launch UI