feature/tiny serverless (#11)

* feat(readme) add new stats, licenses, technical description

Signed-off-by: Daniel Thompson-Yvetot <denjell@quasar.dev>

* feat(main.js) make serverless work correctly for bundle

Signed-off-by: Daniel Thompson-Yvetot <denjell@quasar.dev>

* feat(main.js) validate dev&build for server&less

Signed-off-by: Daniel Thompson-Yvetot <denjell@quasar.dev>
This commit is contained in:
nothingismagick 2019-07-25 01:06:55 +02:00 committed by Lucas Fernandes Nogueira
parent 32b2e951be
commit fcd0c7fc35
2 changed files with 43 additions and 23 deletions

View File

@ -62,7 +62,16 @@ more. - [https://www.rust-lang.org/](https://www.rust-lang.org/)
This combination of power, safety and usability are why we chose Rust to be This combination of power, safety and usability are why we chose Rust to be
the default binding for Proton. It is our intention to provide the most safe the default binding for Proton. It is our intention to provide the most safe
and performant native app experience (for devs and app consumers), out of and performant native app experience (for devs and app consumers), out of
the box. the box.
To this end, we have spent a great deal of time creating an especially secure
localhost-free backend for the security conscious application-artisans. This
means that your app does not use a localhost server, as is generally the case with
cordova apps. This also has the positive side effect, that less code is needed
and the final binaries are smaller.
> Less code doesn't always mean something is safer, but it does mean that
> there is less surface area for attackers to barnacle themselves. - Denjell
### Current Status ### Current Status
We are in the process of vetting this new mode. It is not yet available to We are in the process of vetting this new mode. It is not yet available to
@ -75,22 +84,23 @@ you through the process. Here is a bit of a status report.
- [ ] Frameless Mode - [ ] Frameless Mode
- [x] Build on MacOS - [x] Build on MacOS
- [x] Build on Linux - [x] Build on Linux
- [ ] Build on Windows - [x] Build on Windows
- [x] STDOUT Passthrough with Command Invocation - [x] STDOUT Passthrough with Command Invocation
- [x] Self Updater - [x] Self Updater
- [x] Inter Process Communication (IPC) - [x] Inter Process Communication (IPC)
- [x] Documentation - [x] Documentation
- [x] Filesystem R/W (scoped to permissions) - [x] Filesystem R/W (scoped to permissions)
- [ ] Secure Cryptographic Enclave - [ ] Secure Cryptographic Enclave
- [ ] Message Bus - [x] Message Bus
- [x] Copy Buffer - [x] Copy Buffer
- [ ] API Spec (in progress) - [ ] API Spec (in progress)
- [x] localhost-free mode (:fire:)
### Comparison between Proton 1 and Electron 5 ### Comparison between Proton 1 and Electron 5
| | Proton | Electron | | | Proton | Electron |
|--|--------|----------| |--|--------|----------|
| Binary Size MacOS | 3.6 MB | 148.7 MB | | Binary Size MacOS | 2.6 MB | 147.7 MB |
| Memory Consumption MacOS | 13 MB | 34.1 MB | | Memory Consumption MacOS | 13 MB | 34.1 MB |
| Benchmark FPS | TODO | TODO | | Benchmark FPS | TODO | TODO |
| Interface Service Provider | Varies | Chromium | | Interface Service Provider | Varies | Chromium |
@ -107,6 +117,13 @@ you through the process. Here is a bit of a status report.
| Inter Process Communication (IPC) | Yes | Yes | | Inter Process Communication (IPC) | Yes | Yes |
| Cross Platform | Yes | Yes | | Cross Platform | Yes | Yes |
| Custom App Icon | Yes | Yes | | Custom App Icon | Yes | Yes |
| Windows Binary | Yes | Yes |
| MacOS Binary | Yes | Yes |
| Linux Binary | Yes | Yes |
| iOS Binary | Soon | No |
| Android Binary | Soon | No |
| Localhost Server | Yes | Yes |
| No localhost option | Yes | No |
#### Notes #### Notes
1) Electron has no native auto updater on Linux 1) Electron has no native auto updater on Linux
@ -127,9 +144,7 @@ honoured to carry the torch further. Of special note:
- [zserge](https://github.com/zserge) for the original webview approach and - [zserge](https://github.com/zserge) for the original webview approach and
go bindings go bindings
- [Boscop](https://github.com/Boscop) for the Rust Bindings - [Boscop](https://github.com/Boscop) for the Rust Bindings
- [Burtonago](https://github.com/burtonageo) for the Cargo Bundle prototype
## But there is already a project called Proton...
But aren't there other projects with the same name that do something similar? If you search Github, you will find 1,500 repositories with proton in their name. There are also many, many Quasar projects out there - and that is indeed a bit of a risk when you use a word from science to name your project. But Quasar Proton is the official name of this project now, we think its fitting and good for us, especially because no one can trademark the word proton and tell us to stop using it. This protects the project's longevity at the minor cost of needing disambiguation. C'est la vie.
## Documentation ## Documentation
Head over to the Quasar Framework official website: Head over to the Quasar Framework official website:
@ -160,8 +175,9 @@ Thank you to all the people who already <a href="https://github.com/quasarframew
quasarframework/proton is following [Semantic Versioning 2.0](https://semver.org/). quasarframework/proton is following [Semantic Versioning 2.0](https://semver.org/).
## Licenses ## Licenses
Code: (c) 2019 - Daniel Thompson-Yvetot, Razvan Stoenescu, Lucas Nogueira, Boscop, Serge Zaitsev. Code: (c) 2015- 2019 - Daniel Thompson-Yvetot, Razvan Stoenescu, Lucas Nogueira, Boscop, Serge Zaitsev, George Burton and contributors.
MIT
MIT or MIT/Apache where applicable.
Logo: CC-BY-NC-ND Logo: CC-BY-NC-ND
- Original Proton Logo Design by [Daniel Thompson-Yvetot](https://github.com/nothingismagick) - Original Proton Logo Design by [Daniel Thompson-Yvetot](https://github.com/nothingismagick)

View File

@ -17,6 +17,7 @@ extern crate tiny_http;
use clap::{App, Arg}; use clap::{App, Arg};
#[cfg(not(feature = "dev"))] #[cfg(not(feature = "dev"))]
#[cfg(not(feature = "serverless"))]
use std::thread; use std::thread;
mod cmd; mod cmd;
@ -30,7 +31,7 @@ fn main() {
let content; let content;
let _server_url: String; let _server_url: String;
#[cfg(not(feature = "dev"))] #[cfg(feature = "updater")]
{ {
thread::spawn(|| { thread::spawn(|| {
proton::command::spawn_relative_command( proton::command::spawn_relative_command(
@ -68,7 +69,18 @@ fn main() {
debug = cfg!(debug_assertions); debug = cfg!(debug_assertions);
#[cfg(feature = "serverless")] #[cfg(feature = "serverless")]
{ {
content = proton_ui::Content::Html(include_str!("../target/compiled-web/index.html")); fn inline_style(s: &str) -> String {
format!(r#"<style type="text/css">{}</style>"#, s)
}
fn inline_script(s: &str) -> String {
format!(r#"<script type="text/javascript">{}</script>"#, s)
}
let html = format!(r#"<!DOCTYPE html><html><head><meta http-equiv="Content-Security-Policy" content="default-src data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'">{styles}</head><body><div id="q-app"></div>{scripts}</body></html>"#,
styles = inline_style(include_str!("../target/compiled-web/css/app.css")),
scripts = inline_script(include_str!("../target/compiled-web/js/app.js")),
);
content = proton_ui::Content::Html(html);
} }
#[cfg(not(feature = "serverless"))] #[cfg(not(feature = "serverless"))]
{ {
@ -82,15 +94,14 @@ fn main() {
} }
let webview = proton_ui::builder() let webview = proton_ui::builder()
.title("MyAppTitle") .title("MyApp - Serverless")
.content(content)
.size(800, 600) // TODO:Resolution is fixed right now, change this later to be dynamic .size(800, 600) // TODO:Resolution is fixed right now, change this later to be dynamic
.resizable(true) .resizable(true)
.debug(debug) .debug(debug)
.user_data(()) .user_data(())
.invoke_handler(|_webview, arg| { .invoke_handler(|webview, arg| {
// leave this as is to use the proton API from your JS code // leave this as is to use the proton API from your JS code
if !proton::api::handler(_webview, arg) { if !proton::api::handler(webview, arg) {
use cmd::Cmd::*; use cmd::Cmd::*;
match serde_json::from_str(arg) { match serde_json::from_str(arg) {
Err(_) => {} Err(_) => {}
@ -108,19 +119,12 @@ fn main() {
Ok(()) Ok(())
}) })
.content(content)
.build() .build()
.unwrap(); .unwrap();
#[cfg(not(feature = "dev"))] #[cfg(not(feature = "dev"))]
{ {
#[cfg(feature = "serverless")]
{
let handle = webview.handle();
handle.dispatch(move |_webview| {
_webview.inject_css(include_str!("../target/compiled-web/css/app.css")).unwrap();
_webview.eval(include_str!("../target/compiled-web/js/app.js"))
}).unwrap();
}
#[cfg(not(feature = "serverless"))] #[cfg(not(feature = "serverless"))]
{ {