Thanks to visit codestin.com
Credit goes to github.com

Skip to content

roman01la/cljs-static-hermes

Repository files navigation

This project demonstrates use of ClojureScript and UIx, together with React and a custom reconciler to drive a native GLFW window with Skia rendering library and Yoga layout via AOT compiled JavaScript with Static Hermes.

Differences from tmikov/imgui-react-runtime:

  • Bundles UIx app written in ClojureScript
  • Exposes WebSocket interface to JS env via libwebsockets, needed for REPL connection in dev
  • Supports hot-reloading cljs code in dev, via custom REPL client runtime
  • Supports state preserving hot-reloading via react-refresh
  • Runs requestAnimationFrame at device's refresh rate (60/120/144hz etc)
  • Skia example includes Skia graphics rendered in GLFW window, with Yoga as flex box layout engine and DOM-like event propagation system

Development

native dependencies + interpreted javascript for interactive development

  1. Install NPM dependencies npm i
  2. Run cljs dev build clojure -M -m shadow.cljs.devtools.cli watch skia-app
  3. cd imgui-react-runtime
  4. Configure hermes dev build cmake -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug -G Ninja
  5. Build cmake --build cmake-build-debug --target skia
  6. Run the binary ./cmake-build-debug/examples/skia/skia
  7. Make changes in cljs files to trigger hot-reload or/and connect to REPL server (run (shadow/repl :skia-app) from Clojure REPL to hook into JavaScript env)

Release build

native dependencies + native AOT compiled javascript for maximum performance

  1. Build cljs code clojure -M -m shadow.cljs.devtools.cli release skia-app
  2. cd imgui-react-runtime
  3. Configure hermes release build cmake -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -G Ninja
  4. Build cmake --build cmake-build-release --target skia
  5. Run the binary ./cmake-build-release/examples/skia/skia

Output binary: 15MB

  • 3MB Hermes VM
  • 1.8MB React library
  • 10.2MB app/renderer/GLFW/Skia/Yoga

About

ClojureScript + React + Skia + Yoga + Static Hermes

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •