Skip to content
This repository was archived by the owner on Apr 26, 2025. It is now read-only.

Commit bdc091c

Browse files
committed
renderer: createTextNode, setInitialProperties
1 parent 5a58aab commit bdc091c

File tree

11 files changed

+299
-115
lines changed

11 files changed

+299
-115
lines changed

.editorconfig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ trim_trailing_whitespace = true
77
indent_style = space
88
indent_size = 2
99

10-
; make
11-
[Makefile]
12-
indent_style = tab
13-
1410
; markdown
1511
[*.md]
1612
trim_trailing_whitespace = false
13+
indent_size = 2
14+
indent_style = tab

README.md

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
77
![React-TV Logo](resources/images/reactv-cover-dark.png)
88

9-
```js
9+
```jsx
1010
import React from 'react'
1111
import ReactTV, { Platform } from 'react-tv'
1212

1313
class Clock extends React.Component {
14-
state = { date: new Date() }
15-
16-
render() {
17-
if (Platform.webos) {
18-
return (
19-
<div>
20-
<h1>Hello, {Platform}</h1>
21-
<h2>It is {this.state.date.toLocaleTimeString()}</h2>
22-
</div>
23-
)
24-
}
25-
26-
return <div>This App is available only at LG WebOS</div>
27-
}
14+
state = { date: new Date() }
15+
16+
render() {
17+
if (Platform.webos) {
18+
return (
19+
<div>
20+
<h1>Hello, {Platform}</h1>
21+
<h2>It is {this.state.date.toLocaleTimeString()}</h2>
22+
</div>
23+
)
24+
}
25+
26+
return <div>This App is available only at LG WebOS</div>
27+
}
2828
}
2929

3030
ReactTV.render(Clock, document.getElementById('root'))
@@ -33,19 +33,19 @@ ReactTV.render(Clock, document.getElementById('root'))
3333
## Summary
3434

3535
- [About React-TV](#about-react-tv)
36-
- [Understanding the Problem](#understanding-the-problem)
36+
- [Understanding the Problem](#understanding-the-problem)
3737
- [Getting Started](#getting-started)
38-
- [Installing](#installing)
39-
- [Examples](#examples)
40-
- [Using CLI](#using-cli)
41-
- [Using Module](#using-module)
38+
- [Installing](#installing)
39+
- [Examples](#examples)
40+
- [Using CLI](#using-cli)
41+
- [Using Module](#using-module)
4242
- [Supported Televisions](#supported-televisions)
43-
- [LG WebOS](#lg-webos)
43+
- [LG WebOS](#lg-webos)
4444
- [References for Study](#references)
45-
- [WebOS](#webos)
46-
- [Videos](#videos)
47-
- [Essentials to beginner](#essentials-to-beginner)
48-
- [React Basics and Renderer Architecture](#react-basics-and-renderer-architecture)
45+
- [WebOS](#webos)
46+
- [Videos](#videos)
47+
- [Essentials to beginner](#essentials-to-beginner)
48+
- [React Basics and Renderer Architecture](#react-basics-and-renderer-architecture)
4949
- [TODOLIST for 1.0.0](#todolist)
5050

5151
## About React-TV
@@ -211,28 +211,32 @@ See ReactTV's [Changelog](https://github.com/raphamorim/react-tv/blob/master/CHA
211211

212212
Currently ReactTV is licensed by [MIT License](https://github.com/raphamorim/react-tv/blob/master/LICENSE.md)
213213

214+
## Credits
215+
216+
Thanks [react-dom](https://github.com/facebook/react/tree/master/packages/react-dom) for be example and a inspiration code :)
217+
214218
## TODOLIST
215219

216220
- [ ] {cli} init project
217-
- [x] mkdir app-path
218-
- [x] generate react app tv based on app-name and app-path
219-
- [ ] create a npm script on app: `react-tv run-webos-dev`
221+
- [x] mkdir app-path
222+
- [x] generate react app tv based on app-name and app-path
223+
- [ ] create a npm script on app: `react-tv run-webos-dev`
220224
- [ ] {cli} run-webos-dev
221-
- [ ] mount bundle (crow-scripts) or Webpack
222-
- [ ] check if exists webpack config existent on folder
223-
- [ ] copy bundle for respective folders
224-
- [x] run server (express?)
225+
- [ ] mount bundle (crow-scripts) or Webpack
226+
- [ ] check if exists webpack config existent on folder
227+
- [ ] copy bundle for respective folders
228+
- [x] run server (express?)
225229
- [ ] {cli} run-webos
226-
- [ ] CROW bundling or Webpack
227-
- [ ] Check executable bin path for Windows, OSX and Linux
228-
- [x] pack and install script
229-
- [x] check if virtualbox is up
230-
- [x] launch
231-
- [x] `--disable-emulator`
230+
- [ ] CROW bundling or Webpack
231+
- [ ] Check executable bin path for Windows, OSX and Linux
232+
- [x] pack and install script
233+
- [x] check if virtualbox is up
234+
- [x] launch
235+
- [x] `--disable-emulator`
232236
- [ ] {renderer}
233-
- [ ] WebOS
234-
- [x] platform
235-
- [ ] volume
236-
- [ ] Tizen
237-
- [ ] platform
238-
- [ ] volume
237+
- [ ] WebOS
238+
- [x] platform
239+
- [ ] volume
240+
- [ ] Tizen
241+
- [ ] platform
242+
- [ ] volume

examples/clock-vanilla/example.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
RESULT FROM: https://babeljs.io/repl/#?babili=false&browsers=&build=&builtIns=false&code_lz=MYewdgzgLgBACgGwIZQGYgE4FsYF4YBKApksFACoBqAdIiutgFCPDIQQwDCCIwA1jCIAPKETAATDsVJRqnEFgAO4MbADejGDGgoieGGpjjdALhhgiAdxgARXQAoAlDAC-zLRjHiiGJwc1aMACWqDD2dGiYWNSWRABGIBDOGoGBnlAArhhgYQGpWgA84kEAbgB8efmFABYAjGUAEkQIPAA0BhEMWC4FAPR1FVWpBdUATGUAkrBBHGpQ1TPUOqLUxitQIAAyvEgIRORBWEQAylAYQWAA5k49_eOVw73F5Q8wjpVulelZOUWlZeQFhwAIKKRTBDhIEpIILIOJ7GDgBAATxgKBgmwA4jAAOrxADyxz6z0GrkYn1AkBAe2oPGunSi72kZCo1E8Eh89m4vD47XEvAyRzAskuRCgAFE9kKoAAhZETcT2ADkGBAICgSscjiAA&debug=false&circleciRepo=&evaluate=false&lineWrap=true&presets=es2015%2Creact%2Cstage-2&targets=&version=6.26.0
3+
4+
const Platform = ReactTV.Platform
5+
6+
class Clock extends React.Component {
7+
state = { date: new Date() }
8+
9+
render() {
10+
if (Platform.webos) {
11+
return (
12+
<div>
13+
<h1>Hello, {Platform}</h1>
14+
<h2>It is {this.state.date.toLocaleTimeString()}</h2>
15+
</div>
16+
)
17+
}
18+
19+
return <div>This App is available only at LG WebOS</div>
20+
}
21+
}
22+
23+
console.log(Platform)
24+
ReactTV.render(Clock, document.getElementById('root'))
25+
*/
26+
27+
'use strict';
28+
29+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
30+
31+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
32+
33+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
34+
35+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
36+
37+
var Platform = ReactTV.Platform;
38+
39+
var Clock = function (_React$Component) {
40+
_inherits(Clock, _React$Component);
41+
42+
function Clock() {
43+
var _ref;
44+
45+
var _temp, _this, _ret;
46+
47+
_classCallCheck(this, Clock);
48+
49+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
50+
args[_key] = arguments[_key];
51+
}
52+
53+
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Clock.__proto__ || Object.getPrototypeOf(Clock)).call.apply(_ref, [this].concat(args))), _this), _this.state = { date: new Date() }, _temp), _possibleConstructorReturn(_this, _ret);
54+
}
55+
56+
_createClass(Clock, [{
57+
key: 'render',
58+
value: function render() {
59+
if (Platform.webos) {
60+
return React.createElement(
61+
'div',
62+
null,
63+
React.createElement(
64+
'h1',
65+
null,
66+
'Hello, ',
67+
Platform
68+
),
69+
React.createElement(
70+
'h2',
71+
null,
72+
'It is ',
73+
this.state.date.toLocaleTimeString()
74+
)
75+
);
76+
}
77+
78+
return React.createElement(
79+
'div',
80+
null,
81+
'This App is available only at LG WebOS'
82+
);
83+
}
84+
}]);
85+
86+
return Clock;
87+
}(React.Component);
88+
89+
console.log(Platform);
90+
ReactTV.render(Clock, document.getElementById('root'));

examples/clock-vanilla/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>React TV</title>
6+
</head>
7+
<body>
8+
<div id="root"></div>
9+
10+
<script src="../../node_modules/react/dist/react.min.js"></script>
11+
<script src="../../build/react-tv.js"></script>
12+
<script src="./example.js"></script>
13+
<script>
14+
</script>
15+
</body>
16+
</html>

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "React development for TV (WebOS, Tizen, Orsay)",
55
"main": "src/ReactTVEntry.js",
66
"bin": {
7-
"react-tv": "./cli/index.js"
7+
"react-tv": "./cli"
88
},
99
"scripts": {
1010
"build": "node scripts/rollup/build.js",
@@ -19,9 +19,9 @@
1919
"fbjs": "^0.8.4",
2020
"fs-extra": "^4.0.1",
2121
"glob": "^7.1.2",
22+
"node-replace": "^0.3.1",
2223
"react": "16.0.0-alpha.3",
23-
"react-dom": "16.0.0-alpha.3",
24-
"node-replace": "^0.3.1"
24+
"react-dom": "16.0.0-alpha.3"
2525
},
2626
"devDependencies": {
2727
"babel-plugin-external-helpers": "^6.22.0",

src/ReactTVEntry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
var reactTVRenderer = require('./renderer/ReactTVFiberEntry');
11-
var modules = require('./modules');
11+
var modules = require('./modules/ReactTVModulesEntry');
1212

1313
module.exports = {
1414
render: reactTVRenderer.render,

src/renderer/ReactTVFiberComponent.js

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010

1111
'use strict';
1212

13+
const {
14+
Namespaces: {html: HTML_NAMESPACE},
15+
getIntrinsicNamespace,
16+
} = require('./shared/DOMNamespaces');
17+
18+
const {
19+
DOCUMENT_NODE,
20+
DOCUMENT_FRAGMENT_NODE,
21+
} = require('./shared/HTMLNodeType');
22+
1323
function getOwnerDocumentFromRootContainer(
1424
rootContainerElement: Element | Document,
1525
): Document {
@@ -27,11 +37,11 @@ const ReactTVFiberComponent = {
2737
): Element {
2838
// We create tags in the namespace of their parent container, except HTML
2939
// tags get no namespace.
30-
var ownerDocument: Document = getOwnerDocumentFromRootContainer(
40+
const ownerDocument: Document = getOwnerDocumentFromRootContainer(
3141
rootContainerElement,
3242
);
33-
var domElement: Element;
34-
var namespaceURI = parentNamespace;
43+
let domElement: Element;
44+
let namespaceURI = parentNamespace;
3545
if (namespaceURI === HTML_NAMESPACE) {
3646
namespaceURI = getIntrinsicNamespace(type);
3747
}
@@ -57,8 +67,35 @@ const ReactTVFiberComponent = {
5767
domElement = ownerDocument.createElementNS(namespaceURI, type);
5868
}
5969

70+
console.log(domElement)
6071
return domElement;
61-
}
72+
},
73+
74+
// createTextNode(text: string, rootContainerElement: Element | Document): Text {
75+
// return getOwnerDocumentFromRootContainer(
76+
// rootContainerElement,
77+
// ).createTextNode(text);
78+
// },
79+
80+
// setInitialProperties(
81+
// domElement: Element,
82+
// tag: string,
83+
// rawProps: Object,
84+
// rootContainerElement: Element | Document,
85+
// ): void {
86+
// var isCustomComponentTag = isCustomComponent(tag, rawProps);
87+
// if (__DEV__) {
88+
// validatePropertiesInDevelopment(tag, rawProps);
89+
// if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
90+
// warning(
91+
// false,
92+
// '%s is using shady DOM. Using shady DOM with React can ' +
93+
// 'cause things to break subtly.',
94+
// getCurrentFiberOwnerName() || 'A component',
95+
// );
96+
// didWarnShadyDOM = true;
97+
// }
98+
// },
6299
}
63100

64101
module.exports = ReactTVFiberComponent;

0 commit comments

Comments
 (0)