Skip to content

Commit 28ca995

Browse files
author
Gaëtan Renaudeau
committed
Modernize the project. latest Lerna version, etc..
1 parent 2143688 commit 28ca995

File tree

465 files changed

+16225
-26213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

465 files changed

+16225
-26213
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ before_install:
55
- curl -o- -L https://yarnpkg.com/install.sh | bash
66
- export PATH="$HOME/.yarn/bin:$PATH"
77
before_script:
8+
- yarn run build
89
- export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start
910
script: yarn test
1011
os: linux

CONTRIBUTING.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Contributions are always welcome, no matter how large or small.
44

55
## Requirement
66

7-
- **Node 6**+
8-
- [yarn](https://yarnpkg.com)
7+
* **Node 6**+
8+
* [yarn](https://yarnpkg.com)
99

1010
## Setup / Building
1111

@@ -36,12 +36,6 @@ if you need to regenerate the snapshots:
3636
yarn run test-rewrite-snapshots
3737
```
3838

39-
typecheck:
40-
41-
```sh
42-
yarn run flow
43-
```
44-
4539
Finally, Please check that ALL examples of the cookbook are working correctly.
4640

4741
## Cookbook
File renamed without changes.
File renamed without changes.

packages/cookbook-expo/exp.json renamed to examples/cookbook-expo/exp.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
"privacy": "public",
44
"description": "GL React Native Cookbook",
55
"slug": "gl-react",
6-
"sdkVersion": "19.0.0",
6+
"sdkVersion": "25.0.0",
77
"version": "1.0.1",
88
"orientation": "portrait",
99
"primaryColor": "#cccccc",
10-
"icon": "https://cloud.githubusercontent.com/assets/211411/9813786/eacfcc24-5888-11e5-8f9b-5a907a2cbb21.png",
10+
"icon":
11+
"https://cloud.githubusercontent.com/assets/211411/9813786/eacfcc24-5888-11e5-8f9b-5a907a2cbb21.png",
1112
"notification": {
12-
"icon": "https://s3.amazonaws.com/exp-us-standard/placeholder-push-icon-blue-circle.png",
13+
"icon":
14+
"https://s3.amazonaws.com/exp-us-standard/placeholder-push-icon-blue-circle.png",
1315
"color": "#000000"
1416
},
1517
"loading": {
16-
"icon": "https://cloud.githubusercontent.com/assets/211411/9813786/eacfcc24-5888-11e5-8f9b-5a907a2cbb21.png",
18+
"icon":
19+
"https://cloud.githubusercontent.com/assets/211411/9813786/eacfcc24-5888-11e5-8f9b-5a907a2cbb21.png",
1720
"hideExponentText": false
1821
},
1922
"packagerOpts": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Expo from "expo";
2+
import { Surface } from "gl-react-expo";
3+
export const name = "gl-react-expo";
4+
export const EXGLView = Expo.GLView;
5+
export { Surface };
6+
export const endFrame = gl => gl.endFrameEXP();
7+
export const loadThreeJSTexture = (gl, src, texture) => {
8+
let image = new Image();
9+
image.onload = function() {
10+
texture.image = image;
11+
texture.needsUpdate = true;
12+
};
13+
image.src = src;
14+
};

examples/cookbook-expo/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import "expo";
2+
import Expo from "expo";
3+
import App from "./shared";
4+
Expo.registerRootComponent(App);

examples/cookbook-expo/package.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "cookbook-expo",
3+
"version": "3.13.0",
4+
"description": "GL React Native cookbook",
5+
"author": "Gaëtan Renaudeau",
6+
"private": true,
7+
"scripts": {
8+
"prepare":
9+
"cp -R ../cookbook-rn-shared shared && cp gl-react-implementation.js shared && ./shared/examples/gen.sh > ./shared/examples/index.js"
10+
},
11+
"main": "main.js",
12+
"dependencies": {
13+
"expo": "^25.0.0",
14+
"gl-react-expo": "^3.13.0",
15+
"gl-react": "^3.13.0",
16+
"gl-transitions": "^0.44.0",
17+
"ndarray": "~1.0.18",
18+
"prop-types": "^15.6.0",
19+
"raf": "~3.3.0",
20+
"react-gl-transition": "^1.9.0",
21+
"react-motion": "^0.5.0",
22+
"react-native": "github:expo/react-native#sdk-25.0.0",
23+
"react-navigation": "^1.1.2",
24+
"react": "^16.0.0",
25+
"seedrandom": "github:gre/seedrandom#released",
26+
"three": "0.85.0"
27+
}
28+
}

packages/cookbook-rn-shared/src/About.js renamed to examples/cookbook-expo/shared/About.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import {
77
Platform,
88
Linking
99
} from "react-native";
10-
import getGLReactImplementation from "./gl-react-implementation";
11-
const { Surface, name } = getGLReactImplementation();
10+
import { Surface, name } from "./gl-react-implementation";
1211
import { Node, Shaders, GLSL, Uniform, LinearCopy } from "gl-react";
1312
import timeLoop from "./HOC/timeLoop";
1413

@@ -143,9 +142,9 @@ class Ex1 extends Component {
143142
props: { time: number };
144143
render() {
145144
const { time } = this.props;
146-
const persistence = 0.75 - 0.20 * Math.cos(0.0005 * time);
145+
const persistence = 0.75 - 0.2 * Math.cos(0.0005 * time);
147146
const red = 0.6 + 0.4 * Math.cos(0.004 * time);
148-
const scale = 0.70 + 0.40 * Math.cos(0.001 * time);
147+
const scale = 0.7 + 0.4 * Math.cos(0.001 * time);
149148
const angle = 2 * Math.PI * (0.5 + 0.5 * Math.cos(0.001 * time));
150149
return (
151150
<View style={styles.ex1}>
@@ -196,7 +195,7 @@ export default class Home extends React.Component {
196195
}
197196
};
198197
props: {
199-
navigator: *
198+
navigation: *
200199
};
201200
render() {
202201
return (
@@ -209,15 +208,11 @@ export default class Home extends React.Component {
209208
<Ex1Loop />
210209
</View>
211210
<View>
212-
<Text style={styles.linkTitle}>
213-
Cookbook, web version:
214-
</Text>
211+
<Text style={styles.linkTitle}>Cookbook, web version:</Text>
215212
<Link url="https://gl-react-cookbook.surge.sh" />
216213
</View>
217214
<View>
218-
<Text style={styles.linkTitle}>
219-
Github:
220-
</Text>
215+
<Text style={styles.linkTitle}>Github:</Text>
221216
<Link url="https://github.com/gre/gl-react" />
222217
</View>
223218
</View>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { Component } from "react";
2+
import { EXGLView } from "../gl-react-implementation";
3+
4+
type DemoFunction<Props> = (
5+
gl: WebGLRenderingContext,
6+
initialProps: Props
7+
) => {
8+
onPropsChange: (props: Props) => void,
9+
dispose: () => void
10+
};
11+
12+
export default <Props>(demoFunction: DemoFunction<Props>) =>
13+
class Demo extends Component {
14+
props: { style: any };
15+
demoHooks: *;
16+
onContextCreate = (gl: WebGLRenderingContext) => {
17+
this.demoHooks = demoFunction(gl, this.props);
18+
};
19+
componentWillReceiveProps(nextProps: *) {
20+
const { demoHooks } = this;
21+
if (demoHooks) demoHooks.onPropsChange(nextProps);
22+
}
23+
componentWillUnmount() {
24+
const { demoHooks } = this;
25+
if (demoHooks) demoHooks.dispose();
26+
}
27+
render() {
28+
const { style } = this.props;
29+
return <EXGLView style={style} onContextCreate={this.onContextCreate} />;
30+
}
31+
};

packages/cookbook-rn-shared/src/Home.js renamed to examples/cookbook-expo/shared/Home.js

+17-23
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
import React, { Component } from "react";
22
import { StyleSheet, Text, ScrollView, View, Button } from "react-native";
3-
import getGLReactImplementation from "./gl-react-implementation";
4-
const { name } = getGLReactImplementation();
3+
import { name } from "./gl-react-implementation";
54
import Item from "./Item";
65
import * as examples from "./examples";
76
import * as tests from "./tests";
8-
import Router from "./Router";
97

108
const styles = StyleSheet.create({
119
container: {
1210
flex: 1,
1311
backgroundColor: "#f9f9f9",
14-
flexDirection: "column",
12+
flexDirection: "column"
1513
},
1614
list: {
1715
flex: 1,
1816
backgroundColor: "#fff",
19-
marginBottom: 50,
17+
marginBottom: 50
2018
},
2119
subHeader: {
2220
padding: 10,
23-
paddingVertical: 40,
21+
paddingVertical: 40
2422
},
2523
title: {
2624
flex: 1,
2725
flexDirection: "row",
2826
alignItems: "center",
29-
justifyContent: "center",
27+
justifyContent: "center"
3028
},
3129
titleText: {
3230
fontWeight: "bold",
3331
color: "#fff",
34-
fontSize: 18,
32+
fontSize: 18
3533
},
3634
sectionTitle: {
3735
fontWeight: "bold",
3836
color: "#000",
3937
fontSize: 18,
40-
padding: 10,
41-
},
38+
padding: 10
39+
}
4240
});
4341

4442
export default class Home extends Component {
@@ -48,37 +46,33 @@ export default class Home extends Component {
4846
<View style={styles.title}>
4947
<Text style={styles.titleText}>{name}</Text>
5048
</View>
51-
),
52-
},
49+
)
50+
}
5351
};
5452
props: {
55-
navigator: *,
53+
navigation: *
5654
};
5755
render() {
58-
const { navigator } = this.props;
56+
const { navigation } = this.props;
5957
return (
6058
<ScrollView style={styles.container}>
6159
<View style={styles.subHeader}>
6260
<Button
63-
onPress={() => navigator.push(Router.getRoute("about"))}
61+
onPress={() => navigation.navigate("about")}
6462
color="#e24"
6563
title="What is gl-react ?"
6664
/>
6765
</View>
6866
<View style={styles.list}>
69-
<Text style={styles.sectionTitle}>
70-
Examples
71-
</Text>
67+
<Text style={styles.sectionTitle}>Examples</Text>
7268
{Object.keys(examples).map(ex => (
73-
<Item key={ex} id={ex} navigator={navigator} {...examples[ex]} />
69+
<Item key={ex} id={ex} navigation={navigation} {...examples[ex]} />
7470
))}
7571
</View>
7672
<View style={styles.list}>
77-
<Text style={styles.sectionTitle}>
78-
Tests
79-
</Text>
73+
<Text style={styles.sectionTitle}>Tests</Text>
8074
{Object.keys(tests).map(ex => (
81-
<Item key={ex} id={ex} navigator={navigator} {...tests[ex]} />
75+
<Item key={ex} id={ex} navigation={navigation} {...tests[ex]} />
8276
))}
8377
</View>
8478
</ScrollView>

packages/cookbook-rn-shared/src/Item.js renamed to examples/cookbook-expo/shared/Item.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@flow
22
import React from "react";
33
import { Image, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4-
import Router from "./Router";
54

65
const styles = StyleSheet.create({
76
container: {
@@ -10,36 +9,36 @@ const styles = StyleSheet.create({
109
borderTopColor: "rgba(0, 0, 0, .1)",
1110
paddingVertical: 8,
1211
paddingHorizontal: 8,
13-
flexDirection: "row",
12+
flexDirection: "row"
1413
},
1514
thumbnail: {
1615
width: 50,
1716
height: 50,
18-
marginRight: 8,
17+
marginRight: 8
1918
},
2019
title: {
2120
fontSize: 16,
2221
fontWeight: "bold",
2322
color: "#222",
24-
margin: 2,
23+
margin: 2
2524
},
2625
description: {
2726
fontSize: 12,
2827
color: "#888",
29-
margin: 2,
30-
},
28+
margin: 2
29+
}
3130
});
3231

3332
export default class Item extends React.PureComponent {
3433
props: {
35-
navigator: *,
34+
navigation: *,
3635
id: string,
3736
title: string,
3837
description: ?string,
39-
thumbnail: ?string,
38+
thumbnail: ?string
4039
};
4140

42-
onPress = () => this.props.navigator.push(Router.getRoute(this.props.id));
41+
onPress = () => this.props.navigation.navigate(this.props.id);
4342

4443
render() {
4544
const {
@@ -48,13 +47,13 @@ export default class Item extends React.PureComponent {
4847
description,
4948
disabled,
5049
thumbnail,
51-
navigator,
50+
navigation
5251
} = this.props;
5352
return (
5453
<TouchableOpacity style={styles.container} onPress={this.onPress}>
55-
{thumbnail
56-
? <Image style={styles.thumbnail} source={thumbnail} />
57-
: null}
54+
{thumbnail ? (
55+
<Image style={styles.thumbnail} source={thumbnail} />
56+
) : null}
5857
<View>
5958
<Text style={styles.title}>{title}</Text>
6059
<Text style={styles.description}>{description}</Text>

0 commit comments

Comments
 (0)