boiawang / rax

:tophat: A hyperscript render engine.

Home Page:https://developers.taobao.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rax

[๐Ÿšง Work In Progress v1.0] The fastest way to build cross-container application.


Community


โšก Fast: blazing fast virtual DOM.

๐ŸŽฏ Tiny: 12.6 KB minified + gzipped.

๐ŸŽจ Universal: works in browsers, Weex, Node.js, Mini-program, WebGL and could works more container that implement driver specification.

Quick Start

Install the Rax CLI tools to init project:

$ npm install rax-cli -g
$ rax init <YourProjectName>

Start local server to launch project:

$ cd YourProjectName
$ npm run start

Project Support

  • WebApp Project
  • MiniApp Project

WebApp Project

.
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .eslintrc.js
โ”œโ”€โ”€ src
โ”‚   โ””โ”€โ”€ index.js
โ””โ”€โ”€ public
    โ””โ”€โ”€ index.html

MiniApp Project

.
โ”œโ”€โ”€ app.acss
โ”œโ”€โ”€ app.js
โ”œโ”€โ”€ app.json
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .eslintrc.js
โ””โ”€โ”€ pages
    โ”œโ”€โ”€ page1
    โ”‚   โ”œโ”€โ”€ page1.acss
    โ”‚   โ”œโ”€โ”€ page1.axml
    โ”‚   โ”œโ”€โ”€ page1.js
    โ”‚   โ””โ”€โ”€ page1.json
    โ””โ”€โ”€ page2
        โ”œโ”€โ”€ page2.acss
        โ”œโ”€โ”€ page2.axml
        โ”œโ”€โ”€ page2.js
        โ””โ”€โ”€ page2.json

DSL Support

  • JSX(XML-like syntax extension to ECMAScript) DSL
  • SFC(Single File Component) DSL
  • MP(Mini Program) DSL

JSX(XML-like syntax extension to ECMAScript) DSL

Each JSX element is just syntactic sugar for calling createElement(component, props, ...children). So, anything you can do with JSX can also be done with just plain JavaScript.

// Hello.jsx
import {createElement, Component} from 'rax';

export default class extends Component {
  state = {
    name: 'world'
  };
  onChange = ()=>{
    this.setState({
      name: 'rax'
    });
  };
  render() {
    return (
      <view style={styles.hello}>
        <text style={styles.title} onClick={this.onChange}>
        Hello {this.state.name}
        </text>
      </view>
    );
  }
}

const styles = {
  hello: {
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center'
  },
  title: {
    fontSize: '40px',
    textAlign: 'center'
  }
};
// app.js
import {render} from 'rax';
import Hello from './Hello';

render(<Hello name="world" />);

SFC(Single File Component) DSL

SFC is a Vue-like DSL that will compile to rax component.

<!-- hello.html -->
<template>
  <view class="hello">
    <text class="title" @click="change">Hello {{name}}</text>
  </view>
</template>

<script>
  export default {
    data: function () {
      return {
        name: 'world'
      }
    },
    methods: {
      change () {
        this.name = 'rax';
      }
    }
  }
</script>

<style>
  .hello {
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .title {
    font-size: 40px;
    text-align: center;
  }
</style>
// app.js
import {render} from 'rax';
import Hello from './hello';

render(<Hello name="world" />);

MP(Mini Program) DSL

MP DSL will compile to rax component.

Component({
  data: {
    name: 'world'
  },
  methods: {
    onChange(e) {
      this.setData({
        name: 'rax' 
      });
    }
  }
});
/* index.acss */
.hello {
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.title {
  font-size: 40px;
  text-align: center;
}
<!-- index.axml -->
<view class="hello">
  <text class="title" onClick="change">Hello {{name}}</text>
</view>

Rax Renderers

Developer Tools

  • React Developer Tools: Allow you inspect and modify the state of your Rax components at runtime in Chrome Developer Tools.

React Developer Tools

Redux DevTools extension

Contributing

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing.

Development Workflow

After cloning rax, run npm install to fetch its dependencies.
Run npm run setup link and bootstrap project before development. Then, you can run several commands:

  • npm run lint checks the code style.
  • npm test runs the complete test suite.
  • npm test -- --watch runs an interactive test watcher.
  • npm test <pattern> runs tests with matching filenames.
  • npm run build creates lib and dist folder with all the packages.
  • npm start start local server with examples folder.

Core Team


@yuanyan

Core


@imsobear

Development


@yacheng

Universals & Components


@boiawang

Loaders & Plugins


@wssgcg1213

DSL Runtimes & Loaders

Users


โฌ† back to top

About

:tophat: A hyperscript render engine.

https://developers.taobao.com/

License:Other


Languages

Language:JavaScript 95.6%Language:HTML 3.9%Language:CSS 0.5%Language:Shell 0.1%