All Projects → mbasso → Asm Dom

mbasso / Asm Dom

Licence: other
A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications)

Programming Languages

C++
36643 projects - #6 most used programming language
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects
HTML
75241 projects

Projects that are alternatives of or similar to Asm Dom

Asm Dom Boilerplate
A simple boilerplate to start using asm-dom without configuration.
Stars: ✭ 49 (-98.12%)
Mutual labels:  webassembly, wasm, asmjs, virtual-dom, vdom
Squark
Rust frontend framework, for web browser and more.
Stars: ✭ 162 (-93.78%)
Mutual labels:  wasm, asmjs, virtual-dom, dom
Preact
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
Stars: ✭ 30,527 (+1072.31%)
Mutual labels:  virtual-dom, vdom, dom
Awesome Wasm Langs
😎 A curated list of languages that compile directly to or have their VMs in WebAssembly
Stars: ✭ 2,966 (+13.9%)
Mutual labels:  webassembly, wasm, asmjs
Val
VirtualDOM abstraction layer - give yourself better integration and full control over the DOM with any virtual DOM library that uses a Hyperscript-like API such as React and Preact.
Stars: ✭ 181 (-93.05%)
Mutual labels:  virtual-dom, vdom, dom
Dcmjs
dcmjs is a javascript cross-compile of dcmtk (dcmtk.org).
Stars: ✭ 92 (-96.47%)
Mutual labels:  webassembly, wasm, asmjs
TypeScriptXX
🧷 Stay safe! Type-safe scripting for C++ using TypeScriptToLua and CMake with auto-generated declarations.
Stars: ✭ 33 (-98.73%)
Mutual labels:  webassembly, wasm, asmjs
Emscripten Docker
Docker image with Emscripten to compile ASM.js and WebAssembly
Stars: ✭ 92 (-96.47%)
Mutual labels:  webassembly, wasm, asmjs
Percy
Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
Stars: ✭ 1,856 (-28.73%)
Mutual labels:  webassembly, wasm, virtual-dom
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 (-94.62%)
Mutual labels:  webassembly, wasm, asmjs
Vue
The progressive framework for WebAssembly applications.
Stars: ✭ 211 (-91.9%)
Mutual labels:  webassembly, wasm
Quasar
An experimental rust-to-{wasm,asmjs} frontend framework.
Stars: ✭ 180 (-93.09%)
Mutual labels:  wasm, asmjs
Lam
🚀 a lightweight, universal actor-model vm for writing scalable and reliable applications that run natively and on WebAssembly
Stars: ✭ 176 (-93.24%)
Mutual labels:  webassembly, wasm
Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (-93.2%)
Mutual labels:  webassembly, wasm
Artichoke
💎 Artichoke is a Ruby made with Rust
Stars: ✭ 2,557 (-1.8%)
Mutual labels:  webassembly, wasm
Pont
An online board game in Rust and WebAssembly
Stars: ✭ 218 (-91.63%)
Mutual labels:  webassembly, wasm
Sandspiel
Creative cellular automata browser game
Stars: ✭ 2,476 (-4.92%)
Mutual labels:  webassembly, wasm
Webassembly Examples
From Simple To Complex. A complete collection of webassembly examples.
Stars: ✭ 177 (-93.2%)
Mutual labels:  webassembly, wasm
Raw Wasm
Raw WebAssembly demos
Stars: ✭ 183 (-92.97%)
Mutual labels:  webassembly, wasm
Prototype
(deprecated) The journey continues at ASNEXT: https://github.com/AssemblyScript/assemblyscript
Stars: ✭ 2,114 (-18.82%)
Mutual labels:  webassembly, wasm

:rage4: asm-dom :rage4:

experimental Build Status npm version npm downloads Join the chat at https://gitter.im/mbasso/asm-dom

A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications)

Table of Contents

Motivation

asm-dom is a minimal WebAssembly virtual DOM to build C++ SPA (Single page applications). You can write an entire SPA in C++ and compile it to WebAssembly (or asmjs as fallback) using Emscripten, asm-dom will call DOM APIs for you. This will produce an app that aims to execute at native speed by taking advantage of common hardware capabilities, also, you can use your C/C++ code without any change, you haven't to create a binding layer to use it (as we have to do if we want to use a C++ lib from JS). Basically we are creating an app in C++ that call javascript if needed instead of the opposite. You can write only once in C++ and share as much code as possible with desktop/mobile apps and web site. If you want to learn more about performance, please see this.

How can I structure my application with asm-dom?

asm-dom is a low-level virtual DOM library. It is unopinionated with regards to how you should structure your application.

How did you come up with the concept of asm-dom?

At the beginning asm-dom is born from the idea to test the powerful of WebAssembly in a common use case that is not gaming, VR, AR or Image / video editing. Unfortunately, at the moment, GC/DOM Integration is a future feature 🦄, so, asm-dom isn't totally developed in wasm. All interactions with the DOM are written in Javascript. This is a big disadvantage because of the overhead of the binding between JS and WASM, in the future asm-dom will be even more powerful, anyway results are satisfying.

Inline Example

#include "asm-dom.hpp"

using namespace asmdom;

int main() {
  Config config = Config();
  init(config);

  // asm-dom can be used with a JSX like syntax thanks to gccx
  VNode* vnode = (
    <div
      onclick={[](emscripten::val e) -> bool {
        emscripten::val::global("console").call<void>("log", emscripten::val("clicked"));
        return true;
      }}
    >
      <span style="font-weight: bold">This is bold</span>
      and this is just normal text
      <a href="/foo">I'll take you places!</a>
    </div>
  );

  // Patch into empty DOM element – this modifies the DOM as a side effect
  patch(
    emscripten::val::global("document").call<emscripten::val>(
      "getElementById",
      std::string("root")
    ),
    vnode
  );

  // without gccx
  VNode* newVnode = h("div",
    Data(
      Callbacks {
        {"onclick", [](emscripten::val e) -> bool {
          emscripten::val::global("console").call<void>("log", emscripten::val("another click"));
          return true;
        }}
      }
    ),
    Children {
      h("span",
        Data(
          Attrs {
            {"style", "font-weight: normal; font-style: italic"}
          }
        ),
        std::string("This is now italic type")
      ),
      h(" and this is just normal text", true),
      h("a",
        Data(
          Attrs {
            {"href", "/bar"}
          }
        ),
        std::string("I'll take you places!")
      )
    }
  );

  // Second `patch` invocation
  patch(vnode, newVnode); // asm-dom efficiently updates the old view to the new state

  return 0;
};

Getting started

asm-dom aims to be used from C++, however it can be used also from javascript, here you can find the doc of both:

Ecosystem

Here you can find a list of related projects:

  • gccx - CPX (JSX like syntax) support.
  • asm-dom-boilerplate - A simple boilerplate to start using asm-dom without configuration.

Examples

Examples are available in the examples folder.

Also, here is the list of third-party examples:

and online Demos:

Roadmap

  • Thunks support
  • asm-dom aims to be even more powerful with GC/DOM Integration. Unfortunately this is a future feature 🦄, so, we have to be patient and wait a bit.

Change Log

This project adheres to Semantic Versioning.
Every release, along with the migration instructions, is documented on the Github Releases page.

Authors

Matteo Basso

Copyright and License

Copyright for portions of project asm-dom are held by:

  • Simon Friis Vindum, 2015 as part of project snabbdom
  • project snabbdom-to-html

All other copyright for project asm-dom are held by Matteo Basso.

Copyright (c) 2016, Matteo Basso.

asm-dom source code is licensed under the MIT License.

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].