• This repository has been archived on 26/Mar/2024
  • Stars
    star
    2,014
  • Rank 22,982 (Top 0.5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[ Unmaintained due to raphamorim/react-ape ] React Renderer for low memory applications

React-TV · license npm version circleci status Build status PRs Welcome

react-tv: React Renderer for low memory applications.

react-tv-cli: React Packager for TVs.

Currently under development.

React-TV Logo

import React from 'react'
import ReactTV, { Platform } from 'react-tv'

class Clock extends React.Component {
  state = { date: new Date() }

  componentDidMount() {
    setInterval(() => this.setState({date: new Date()}), 1000)
  }

  render() {
    if (Platform('webos')) {
      return (
        <h1>Time is {this.state.date.toLocaleTimeString()}</h1>
      )
    }

    return <h2>This App is available only at LG webOS</h2>
  }
}

ReactTV.render(<Clock/>, document.getElementById('root'))

Summary

About React-TV

React-TV is an ecosystem for TV based React applications (from the renderer to CLI for pack/build applications).
At the moment we're focusing on webOS and SmartTV.
React-TV's aims to be a better tool for building and developing fast for TVs.

Understanding the Problem

tl;dr: Crafting a high-performance TV user interface using React

Crafting a high-performance TV user interface using React is a real challenge, because of some reasons:

  • Limited graphics acceleration
  • Single core CPUs
  • High Memory Usage for a common TV App

These restrictions make super responsive 60fps experiences especially tricky. The strategy is step in the renderer: Applying reactive concepts to unblock the processing on the renderer layer, plug the TV's keyListener, avoid React.createElement.

In addition: Unify the build for multiple TV platforms.

Articles

Friendly list of tutorials and articles:

react-tv-cli

To install react-tv-cli (CLI Packager):

$ yarn global add react-tv-cli
Support for React-TV-CLI
Target Platform Status Available Version
LG webOS stable 0.3.1
Samsung Tizen ongoing x
Samsung Orsay not started yet x
Sony PS4 not started yet x
Nintendo Switch not started yet x

Developing for webOS

Short Description: webOS, also known as Open webOS or LG webOS, (previously known as HP webOS and Palm webOS, stylized as webOS) is a Linux kernel-based multitasking operating system for smart devices such as Smart TVs and it has been used as a mobile operating system.


First of all, setup your webOS Environment:

Setup webOS Enviroment

Then, init your react-tv project:

$ react-tv-cli init <my-app-name>

From the project directory, install the dependencies to enable building:

$ yarn install

You will need to keep the list of files related to your app on the React-TV entry up to date in package.json. The init command will already add index.html, bundle.js and style.css to the package.

{
  "name": "my-app-name",
  "react-tv": {
    "files": [
      "index.html",
      "bundle.js",
      "style.css"
    ]
  }
}

To build your project:

$ yarn build

Once the project is built, you can run it on a specific device or emulator:

$ react-tv-cli run-webos <device>
  • When you not specify the device, it runs on VirtualBox webOS Simulator

react-tv

To install react-tv (React Renderer):

$ yarn add react-tv

Platform

When building a cross-platform TV app, you'll want to re-use as much code as possible. You'll probably have different scenarios where different code might be necessary.
For instance, you may want to implement separated visual components for LG-webOS and Samsung-Tizen.

React-TV provides the Platform module to easily organize your code and separate it by platform:

import { Platform } from 'react-tv'

console.log(Platform('webos')) // true
console.log(Platform('tizen')) // false
console.log(Platform('orsay')) // false

renderOnAppLoaded

Takes a component and returns a higher-order component version of that component, which renders only after application was launched, allows to not write diffent logics for many devices.

import { renderOnAppLoaded } from 'react-tv'

const Component = () => (<div></div>)
const App = renderOnAppLoaded(Component)

findDOMNode

Similar to react-dom findDOMNode

Navigation

If you want to start with Navigation for TVs. React-TV provides a package for spatial navigation with declarative support based on Netflix navigation system.

React-TV Navigation exports withFocusable and withNavigation which act as helpers for Navigation.

import React from 'react'
import ReactTV from 'react-tv'
import { withFocusable, withNavigation } from 'react-tv-navigation'

const Item = ({focused, setFocus, focusPath}) => {
  focused = (focused) ? 'focused' : 'unfocused'
  return (
    <div onClick={() => { setFocus() }} >
      It's {focused} Item
    </div>
  )
}

const Button = ({setFocus}) => {
  return (
    <div onClick={() => { setFocus('item-1') }}>
      Back To First Item!
    </div>
  )
}

const FocusableItem = withFocusable(Item)
const FocusableButton = withFocusable(Button)

function App({currentFocusPath}) {
  return (
    <div>
      <h1>Current FocusPath: '{currentFocusPath}'</h1>,
      <FocusableItem focusPath='item-1'/>
      <FocusableItem focusPath='item-2'/>
      <FocusableButton
        focusPath='button'
        onEnterPress={() => console.log('Pressed enter on Button!')}/>
    </div>
  )
}

const NavigableApp = withNavigation(App)

ReactTV.render(<NavigableApp/>, document.querySelector('#app'))

See examples/navigation for more details about usage.

Examples

Clock App

Clock App Example

Youtube App

Youtube App Example

References:

webOS

Videos

Windows
OSX

Essentials to beginner

Developing for SmartTV Guidelines

React Basics and Renderer Architecture

Roadmap

Stage 1

Initial proof-of-concept. [DONE]

  • CLI Build Abstraction of LG webOS (run-webos, run-webos-dev)
  • Create a guide or script to Install all LG webOS environment
  • Renderer ReactElements to simple DOM
    • Support HOF and HOC
    • Support State and Lifecycle
    • Keyboard Navigation
  • Check webos Platform
  • Migrate to React-Reconciler

Stage 2 [IN PROGRESS]

Implement essential functionality needed for daily use by early adopters.

  • Support render to Canvas instead DOM using React.CanvasComponent
  • run-webos support TV device as param
  • Optmizate DOMRenderer for TV
  • Start CLI for Tizen
  • Develop helpers for webOS debbug (e.g: Log System).
  • Support Cross Platform
    • Check executable bin path for Windows, OSX and Linux
  • Bind all TV key listeners on React.Element
  • Improve documentation
  • Benchmark it

Stage 3

Add additional features users expect from a Renderer. Then fix bugs and stabilize through continuous daily use. At this point we can start to experiment with innovative ideas and paradigms.

  • Start CLI for Orsay
  • Update Benchmarks
  • Handle common errors
  • Reactive Renderer
  • Testing and stability

See ReactTV's Changelog.

Currently ReactTV is licensed by MIT License

Credits

Thanks react-dom for be example and a inspiration code :)

More Repositories

1

react-ape

🦍• React Renderer to build UI interfaces using canvas/WebGL (TV and Hardware-Accelerated GPU development based)
JavaScript
1,513
star
2

awesome-canvas

A curated list of awesome HTML5 Canvas with examples, related articles and posts.
Markdown
1,399
star
3

lucario

The best flat theme for Vim, Atom, Sublime Text, Jetbrains Editors, Terminal.app, iTerm, Xcode, Windows Terminal and XTerm
Vim Script
797
star
4

origami.js

Powerful and Lightweight Library to create using HTML5 Canvas
JavaScript
765
star
5

waterfall.js

Tired of use creepy hacks or heavy ways to get a Grid based on Pinterest?
JavaScript
540
star
6

wasm-and-rust

WebAssembly and Rust: A Web Love Story
495
star
7

native-css

Convert pure CSS to React Style or javascript literal objects.
JavaScript
340
star
8

write-code-every-day

[No longer maintained] :octocat: A project to honor those developers who believed in the challenge.
HTML
170
star
9

retro

[Work in Progress] Minimalist Vim Based Editor for the 30th Century
JavaScript
105
star
10

go-rainbow

Golang Helper for beautiful CLI Applications
Go
89
star
11

react-motions

Compose React Animations using High-Order Functions or Components
CSS
88
star
12

imgStatus

[855bytes] Detect when images have been loaded without jQuery
JavaScript
65
star
13

xwasm

[Work In Progress] WebAssembly Packager and WASM tooling for modern frontend
JavaScript
55
star
14

clapton

Yet Another Open Source Desktop Media Player
JavaScript
50
star
15

canvas-experiments

Some experiments using Canvas HTML5 technology.
JavaScript
46
star
16

inphinity

A infinity scroll without jQuery or other dependency.
JavaScript
45
star
17

calendario

📆 Check if a day is a workday or holiday
JavaScript
37
star
18

firefox-offline-game

Mozillian fork from Chromium T-Rex Game
JavaScript
35
star
19

ranza

The dependency checker
JavaScript
30
star
20

LR35902

Gameboy Emulator written in Rust and WebAssembly. 8-bit microprocessor: Sharp LR35902.
Rust
28
star
21

memory-inspector

Memory Inspector watches memory usage/behaviour of an Web Application
JavaScript
22
star
22

wat

[fsnotify] A cross-platform File Watcher that runs specific tasks when specific files are added, changed or deleted
Go
21
star
23

cargo-server

serve a static site, single page application or just a static file with Rust
Rust
21
star
24

elekid

Resolver for React's Server Side Render on Module, ReactElement or Electron
JavaScript
19
star
25

kyoto

Kyoto Lang - A programming language designed to build WebAssembly
Rust
19
star
26

nautilus.js

Async CSS/JavaScript loader & dependency manager in ~1kb (600B gziped)
JavaScript
18
star
27

react-song

React renderer to MIDI, Custom Notes, ArrayBuffers and Base64 based on Songs
JavaScript
18
star
28

off-the-hook

[WIP] React Hooks that I use in my personal projects or I've created just for fun.
JavaScript
16
star
29

webpack-2-vs-rollup

Comparison between Webpack 2 and Rollup
JavaScript
14
star
30

treeData.js

A JavaScript plugin to easy create an tree data structure.
CSS
14
star
31

js2c

[WIP] Transform JavaScript into ANSI C
JavaScript
14
star
32

angular-drag-n-drop

Angular Drag and Drop, with no dependency on Jquery or other library.
JavaScript
13
star
33

just-canvas

Dancing using JavaScript - Canvas HTML5 Feature
JavaScript
13
star
34

algorithms

Solutions to algorithmic problems
JavaScript
13
star
35

redux-ssr-shopping-cart

A complete sample of React + Redux + Server Side Render + GraphQL + Express + MongoDB
JavaScript
13
star
36

awesome-conduct

Be Truly Awesome
12
star
37

sound-hunter

Increase speed for search, finding songs in less than 5 minutes
CSS
12
star
38

astrofish

A intergalactic theme based on Spacemacs Color Scheme
Vim Script
11
star
39

reactsandbox

Create a React Component Sandboxes based on compositions
JavaScript
11
star
40

mugiwara

fast minimal CSS-in-JS created to reduce size of CSS injected
JavaScript
11
star
41

tzu

The belt of number conversion for nodejs
JavaScript
10
star
42

500-dias-de-open-source

Meu livro que retrata a experiencia de ter mergulhado de cabeça no mundo open source e escrever código útil diariamente por 500 dias seguidos.
Shell
10
star
43

raphamorim-keynote-theme

My own keynote theme :))
9
star
44

how-to-write-your-react-renderer

Slides: http://raphamorim.io/how-to-write-your-react-renderer
JavaScript
8
star
45

webassembly-image-editor

Image Editor powered by WebAssembly and Rust
JavaScript
8
star
46

kenobi

Render objects for view engines or static html
JavaScript
7
star
47

nbfs

NonBlocking ~Nodejs~ File System
JavaScript
6
star
48

aQuery

jQuery chunk [<=1kb]
JavaScript
6
star
49

rust-dockerclient

Rust client for the Docker remote API
Rust
6
star
50

blonde

Paintfull setup no more
JavaScript
5
star
51

origamijs

Origami.js Site
CSS
5
star
52

capivara

[no longer maintained] Generates & Obtain DOM (Document Object Model)
Python
5
star
53

500-days

http://raphamorim.io/500-days/
JavaScript
4
star
54

shell-script-frontend

[WIP] Replace grunt / gulp tasks using Shell Script
Shell
4
star
55

react-ape-movie-list-demo

Demo with React Ape
JavaScript
4
star
56

axum-service-checklist

Template for Rust API with Axum and Tokio
Rust
3
star
57

react-blessed-task-list

JavaScript
3
star
58

retroeditor.io

[Deprecated] Move to raphamorim/retro
HTML
3
star
59

raphamorim.github.com

A open blog plataform
JavaScript
2
star
60

Bring-Game-Boy-Alive-in-the-Web-with-Rust-and-WebAssembly-RustLab-2023

Rustlab 2023 talk
HTML
2
star
61

shells

My collection of shell scripts
Shell
2
star
62

skyrim-vr

Skyrim scenarios to Panoramic View using MozVR, thanks Skyrim360.
JavaScript
2
star
63

MapJs

The geolocation API and google maps working based only on your HTML.
JavaScript
2
star
64

500-days-of-open-source

My book about the write code every single day experience
2
star
65

tv-react-renderer-benchmark

Benchmark between renderers focused on memory
JavaScript
2
star
66

virtual.js

Use markup to create VR slide presentations that work across desktop, iOS, Android, and the Oculus Rift.
JavaScript
1
star
67

wa

Nothing to see here yet
Rust
1
star
68

arjs

Augmented Reality [拡張現実] JavaScript Library
JavaScript
1
star
69

suikoden-stars

A json data about all stars of destiny and how recruit in each suikoden game.
1
star
70

awesome-webgl

A curated list of awesome HTML5 Canvas with examples, related articles and posts.
1
star
71

chlog

[WIP] Changelog for Humans
JavaScript
1
star
72

js2c-set

Transform JS to C
JavaScript
1
star
73

rust-is-awesome

Personal list to check some resources which I've <3
1
star
74

The-good-developer

My book talks about how to become a better developer
HTML
1
star
75

react-conf-brasil

HTML
1
star
76

sayok

[EXPERIMENT] Terminal Notification for MacOS to notify Succeed Task
JavaScript
1
star
77

react-ape-preview

Service to run previews of React Ape render. Created specifically to react-ape docs
JavaScript
1
star
78

origami.svg

A Origami Plugin to deliver SVG instead Canvas (canvas to SVG)
JavaScript
1
star
79

canvas-icons

in development (Move Along, Nothing to See Here)
JavaScript
1
star
80

weird

Elixir
1
star
81

react-ape-photo-gallery

JavaScript
1
star
82

canvas-filter-tools

filter tools powered by wasm and canvas
JavaScript
1
star
83

offline-reader

Work in progress
JavaScript
1
star
84

rio

Rio is an opinionated package manager built with Rust for NodeJS ecosystem.
Rust
1
star
85

hackathon-1746

Projeto desenvolvido para solucionar o problema com a poda de árvores para a HackAthon 1746 realizado pela prefeitura do Rio de Janeiro
PHP
1
star