Coder Social home page Coder Social logo

thekakkun / pax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paxengine/pax

0.0 1.0 0.0 34.98 MB

User interface engine for native apps & WebAssembly sites

Home Page: https://pax.dev/

License: Apache License 2.0

Shell 0.32% JavaScript 6.17% Python 0.66% C 0.13% Objective-C 0.09% Rust 67.47% TypeScript 7.98% CSS 0.23% Swift 16.83% HTML 0.12%

pax's Introduction

Pax

Pax is a user interface engine for native apps and websites.

This repository includes:

  • The Pax compiler and language implementation
  • Native runtimes
  • Language bindings for supported programming languages, currently only Rust
  • Pax's CLI for compiling and managing projects
  • Example projects

Example

Writing Pax is intended to feel familiar and the language borrows many ideas from prior art.

Following is a simple Pax component called IncrementMe:

//File: increment-me.rs

use pax_lang::*;
use pax_std::{Text};
use pax_std::forms::{Button, ArgsButtonSubmit};
use pax_std::layout::{Stacker};

/// Defines the Pax component `IncrementMe`, with template & settings specified in `increment-me.pax`.
#[derive(Pax)]
#[file("increment-me.pax")] 
pub struct IncrementMe {
  pub num_clicks: Property<i64>
}
impl IncrementMe {
  pub async fn increment(&self, args: ArgsButtonSubmit) {
    let old_num_clicks = self.num_clicks.get();
    self.num_clicks.set(old_num_clicks + 1);
  }
}
//File: increment-me.pax

<Stacker cells=2>
  <Text text={"I have been clicked " + self.num_clicks + " times."}></Text>
  <Button @submit=self.increment>"Increment me!"</Button>
</Stacker>

Any Pax component like the example above may be included inside other Pax components, or may be mounted as the root of a stand-alone app.

See a more thorough, running example.

Features

  • Fast — 240fps animations, compiles to machine code
  • Native — Platform-native text, UI controls, and drawing APIs.
  • Accessible — Supports screen readers for native text & GUI elements, as well as SEO on the Web
  • Lightweight — <100kB footprint baseline for WebAssembly binary. No web tech in desktop & mobile builds.
  • Declarative UI language makes it easy to reason about complex scenes and GUIs, as well as build tooling that reads & writes Pax
  • Expressive — Free-form drawing and animation toolkit, plus GUI form elements and responsive layouts. Blur the lines between work & play, function & art.
  • Extensible — UI component system built around Rust structs enables modular application building and publication of reusable components through cargo and crates.io. Pax's standard library (pax-std) is a canonical example, publishing modular primitives like <Group />, drawing elements like <Rectangle />, form elements like <Text />, and layout elements like <Stacker />.

Docs

Read more in The Pax Docs

Getting Started

Setup, macOS workstation

  • Install rustc 1.70.0 via rustup
  • Install the Pax CLI: cargo install pax-cli
  • Follow instructions to build for WebAssembly or macOS below
  • Create a new project pax-cli new my-first-project

Setup, Linux (Debian / Ubuntu) workstation

  • Install rustc 1.70.0 via rustup
  • Install development dependencies: apt install pkg-config libssl-dev
  • Install the Pax CLI: cargo install pax-cli
  • Follow instructions to build for WebAssembly below
  • Create a new project pax-cli new my-first-project

Setup, Windows workstation

  • Install rustc via installer
  • Install the Pax CLI: cargo install pax-cli
  • Follow instructions to build for WebAssembly below
  • Create a new project pax-cli new my-first-project

To build Pax projects for WebAssembly

  • Install 'wasm-pack' via:

     curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh 

    For Windows, follow instructions to use installer here.

  • Install node v20 LTS, recommended via nvm

    # For macOS / Linux:  first install nvm
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    # After restarting terminal:
    nvm install 20
    nvm use 20 --default

    For Windows, install nvm-windows and install Node v20 LTS.

To build Pax projects as native macOS apps

  • Building macOS apps requires running a Mac with macOS. This is a constraint enforced technically and legally by Apple.
  • Install xcode >=14.3 and Xcode command line utils: xcode-select --install
  • SDK Version macosx13.3, Xcode version >=14.3
  • Current Minimum Deployment 13.0

Support matrix:

Web browsers Native iOS Native Android Native macOS Native Windows Native Linux
Development harness & chassis
2D rendering and UIs
Canvas

CoreGraphics

Cairo

CoreGraphics

Direct2D

Cairo
3D rendering and UIs
Vector graphics APIs
2D layouts
Animation APIs
Native text rendering
DOM

UIKit

android:*

SwiftUI

System.Windows.Forms

GTK
Native form elements
DOM

UIKit

android:*

SwiftUI

System.Windows.Forms

GTK
Native event handling (e.g. Click, Tap)
Rust host language
WASM

LLVM

LLVM

LLVM

LLVM

LLVM
JS/TypeScript host language
Legend:
✅ Supported
⏲ Not yet supported

License

© 2023 PaxCorp Inc. [[email protected]].

This project is licensed under either of:

at your option.

Running Monorepo Development Environment

First, refer to the latest project status

Run pax-example:

# after cloning pax, from `pax/`
cd pax-example
# the `./pax` shell script emulates the `pax` CLI for Pax monorepo development
./pax run --target=macos # or --target=web 

To initialize the submodules, for super-grep powers:

git submodule update --init --recursive

As needed, review the git submodule docs.

pax's People

Contributors

zackbrown avatar warfaj avatar ouz-a avatar c410-f3r avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.