All Projects → rail44 → Squark

rail44 / Squark

Licence: wtfpl
Rust frontend framework, for web browser and more.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Squark

Asm Dom
A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications)
Stars: ✭ 2,604 (+1507.41%)
Mutual labels:  wasm, asmjs, virtual-dom, dom
Quasar
An experimental rust-to-{wasm,asmjs} frontend framework.
Stars: ✭ 180 (+11.11%)
Mutual labels:  wasm, asmjs, frontend-framework
Dcmjs
dcmjs is a javascript cross-compile of dcmtk (dcmtk.org).
Stars: ✭ 92 (-43.21%)
Mutual labels:  emscripten, wasm, asmjs
Asm Dom Boilerplate
A simple boilerplate to start using asm-dom without configuration.
Stars: ✭ 49 (-69.75%)
Mutual labels:  wasm, asmjs, virtual-dom
Emscripten Docker
Docker image with Emscripten to compile ASM.js and WebAssembly
Stars: ✭ 92 (-43.21%)
Mutual labels:  emscripten, wasm, asmjs
Yew
Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly.
Stars: ✭ 18,243 (+11161.11%)
Mutual labels:  emscripten, wasm, asmjs
TypeScriptXX
🧷 Stay safe! Type-safe scripting for C++ using TypeScriptToLua and CMake with auto-generated declarations.
Stars: ✭ 33 (-79.63%)
Mutual labels:  wasm, emscripten, asmjs
Modern Wasm Starter
🛸 Run C++ code on web and create blazingly fast websites! A starter template to easily create WebAssembly packages using type-safe C++ bindings with automatic TypeScript declarations.
Stars: ✭ 140 (-13.58%)
Mutual labels:  emscripten, wasm, asmjs
Seed
A Rust framework for creating web apps
Stars: ✭ 3,069 (+1794.44%)
Mutual labels:  wasm, frontend-framework
Cargo Web
A Cargo subcommand for the client-side Web
Stars: ✭ 1,026 (+533.33%)
Mutual labels:  emscripten, asmjs
Xwasm
[Work In Progress] WebAssembly Packager and WASM tooling for modern frontend
Stars: ✭ 45 (-72.22%)
Mutual labels:  emscripten, wasm
Hyperx
🏷 - tagged template string virtual dom builder
Stars: ✭ 991 (+511.73%)
Mutual labels:  virtual-dom, dom
Cppwasm Book
📚 WebAssembly friendly programming with C/C++ -- Emscripten practice
Stars: ✭ 956 (+490.12%)
Mutual labels:  emscripten, wasm
Preact
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
Stars: ✭ 30,527 (+18743.83%)
Mutual labels:  virtual-dom, dom
Opus Stream Decoder
Instantly decode Ogg Opus audio streams in chunks with JavaScript & WebAssembly (Wasm)
Stars: ✭ 80 (-50.62%)
Mutual labels:  emscripten, wasm
Sql.js
A javascript library to run SQLite on the web.
Stars: ✭ 9,594 (+5822.22%)
Mutual labels:  emscripten, wasm
Puddles
Tiny vdom app framework. Pure Redux. No boilerplate.
Stars: ✭ 24 (-85.19%)
Mutual labels:  virtual-dom, frontend-framework
Wasmjit
Small Embeddable WebAssembly Runtime
Stars: ✭ 1,063 (+556.17%)
Mutual labels:  emscripten, wasm
Wasmer
🚀 The leading WebAssembly Runtime supporting WASI and Emscripten
Stars: ✭ 11,047 (+6719.14%)
Mutual labels:  emscripten, wasm
Assortedwidgets
OpenGL GUI library
Stars: ✭ 92 (-43.21%)
Mutual labels:  emscripten, wasm

squark

Rust frontend framework, for web browser and more.

Currently, we depend on nightly channel

Design

  • Separating runtime definition and implemention
    • squark crate has no dependency for specific platform
  • Architecture inspired from Elm and HyperApp
    • Simplicy
    • Elegant
  • Supporting futures-0.1
    • reducer can emit task for async work such as fetch resource

crates

squark

crates.io docs.rs

Core crate.

  • Pure Rust virtual DOM implemention
  • Definition of GUI application
  • Definition of runtime to handle diffirence of virtual DOM

squark-macros

crates.io docs.rs

It provides macro like JSX for helping writing view.
Very thanks to pest parser.

Syntax

view! {
    <button class="some-class" onclick={ |_| Some(Action::Submit) }>
        Button!
    </button>
}

We can generate native Rust expression at compile-time.

squark-web

crates.io docs.rs

Runtime implemention for web browser with usinng wasm-bindgen.

Here is full example of counter app!

#![feature(proc_macro_hygiene)]

extern crate squark;
extern crate squark_macros;
extern crate squark_web;
extern crate wasm_bindgen;
extern crate web_sys;

use squark::{App, Runtime, View, Task};
use squark_macros::view;
use squark_web::WebRuntime;
use wasm_bindgen::prelude::*;
use web_sys::window;

#[derive(Clone, Debug, PartialEq)]
struct State {
    count: isize,
}

impl State {
    pub fn new() -> State {
        State { count: 0 }
    }
}

#[derive(Clone, Debug)]
enum Action {
    ChangeCount(isize),
}

#[derive(Clone, Debug)]
struct CounterApp;
impl App for CounterApp {
    type State = State;
    type Action = Action;

    fn reducer(&self, mut state: State, action: Action) -> (State, Task<Action>) {
        match action {
            Action::ChangeCount(c) => {
                state.count = c;
            }
        };
        (state, Task::empty())
    }

    fn view(&self, state: State) -> View<Action> {
        let count = state.count;
        view! {
            <div>
                { count.to_string() }
                <button onclick={ move |_| Some(Action::ChangeCount(count.clone() + 1)) }>
                    increment
                </button>
                <button onclick={ move |_| Some(Action::ChangeCount(count - 1)) }>
                    decrement
                </button>
            </div>
        }
    }
}

impl Default for CounterApp {
    fn default() -> CounterApp {
        CounterApp
    }
}

#[wasm_bindgen]
pub fn run() {
    WebRuntime::<CounterApp>::new(
        window()
            .unwrap()
            .document()
            .expect("Failed to get document")
            .query_selector("body")
            .unwrap()
            .unwrap(),
        State::new(),
    )
    .run();
}

Project dir is located at examples/counter.

There are some other examples available on examples, most of them use rust-webpack-template.
TodoMVC is working on https://rail44.github.io/squark/.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].