Skip to content

Commit b381017

Browse files
authored
Prepare bs-react-native-jsx3-compat (#415)
Just a copy of bs-react-native atm. More to come
1 parent c0e9511 commit b381017

217 files changed

Lines changed: 23011 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# bs-react-native-jsx3-compat
2+
3+
Compatibility legacy bindings for jsx3 usage
4+
5+
This bindings make sense if you upgrade your codebase to jsx3 but don't want to
6+
directly migrate to reason-react-native at the same time (which is totally
7+
understandable).
8+
9+
To help you migrate, we advise you to look at this method
10+
11+
https://bloodyowl.github.io/blog/2019-04-19-an-alternative-migration-path-for-reason-react/
12+
13+
---
14+
15+
# PREFER CONTRIBUTING TO reason-react-native
16+
17+
Current stable `bs-react-native` (and jsx3-compat ) has entered a kind of frozen
18+
mode. We are focusing on the rewrite, which is in `reason-react-native` & we
19+
would prefer to get contribution in there. If that's necessary for you to get
20+
something in `bs-react-native`, we would accept it as soon as we also have it
21+
(already or added) in `reason-react-native`.
22+
23+
If you are not sure, just
24+
[come on discord & talk with us](https://discord.gg/q8GQD34)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "bs-react-native-jsx3-compat",
3+
"namespace": "bs-react-native",
4+
"refmt": 3,
5+
"reason": {
6+
"react-jsx": 2
7+
},
8+
"package-specs": {
9+
"module": "es6",
10+
"in-source": true
11+
},
12+
"suffix": ".bs.js",
13+
"sources": [
14+
{
15+
"dir": "src",
16+
"subdirs": true
17+
}
18+
],
19+
"bsc-flags": ["-bs-no-version-header", "-warn-error @a", "-w -41-42-102"],
20+
"bs-dependencies": ["reason-react"]
21+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "bs-react-native-jsx3-compat",
3+
"version": "0.11.0",
4+
"repository": "https://github.com/reasonml-community/bs-react-native.git",
5+
"license": "MIT",
6+
"keywords": [
7+
"reason",
8+
"reasonml",
9+
"bucklescript",
10+
"react-native"
11+
],
12+
"scripts": {
13+
"re:clean": "bsb -clean-world",
14+
"re:start": "bsb -make-world -w",
15+
"re:build": "bsb -make-world",
16+
"re:clean-build": "yarn re:clean && yarn re:build",
17+
"clean": "yarn re:clean",
18+
"test": "yarn re:clean-build"
19+
},
20+
"devDependencies": {
21+
"bs-platform": "^5.0.1",
22+
"reason-react": "^0.7.0",
23+
"upgrade-reason-react": "https://github.com/chenglou/upgrade-reason-react.git#0.6.0-to-0.7.0"
24+
},
25+
"peerDependencies": {
26+
"react-native": "^0.53.3",
27+
"reason-react": "^0.7.0"
28+
}
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
https://facebook.github.io/react-native/docs/interactionmanager
3+
*/
4+
5+
type interactionHandle;
6+
7+
[@bs.module "react-native"] [@bs.scope "InteractionManager"]
8+
/* @todo this returns a cancellable "promise", we need to type return correctly */
9+
external runAfterInteractions: (unit => unit) => Js.t({.}) =
10+
"runAfterInteractions";
11+
12+
[@bs.module "react-native"] [@bs.scope "InteractionManager"]
13+
external createInteractionHandle: unit => interactionHandle =
14+
"createInteractionHandle";
15+
16+
[@bs.module "react-native"] [@bs.scope "InteractionManager"]
17+
external clearInteractionHandle: interactionHandle => unit =
18+
"clearInteractionHandle";
19+
20+
[@bs.module "react-native"] [@bs.scope "InteractionManager"]
21+
external setDeadline: float => unit = "setDeadline";
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
3+
import * as Block from "bs-platform/lib/es6/block.js";
4+
import * as Curry from "bs-platform/lib/es6/curry.js";
5+
import * as Printf from "bs-platform/lib/es6/printf.js";
6+
7+
function pct(f) {
8+
return Curry._1(Printf.sprintf(/* Format */[
9+
/* Float */Block.__(8, [
10+
/* Float_f */0,
11+
/* No_padding */0,
12+
/* Lit_precision */[2],
13+
/* Char_literal */Block.__(12, [
14+
/* "%" */37,
15+
/* End_of_format */0
16+
])
17+
]),
18+
"%.2f%%"
19+
]), f);
20+
}
21+
22+
function deg(f) {
23+
return Curry._1(Printf.sprintf(/* Format */[
24+
/* Float */Block.__(8, [
25+
/* Float_f */0,
26+
/* No_padding */0,
27+
/* Lit_precision */[2],
28+
/* Char_literal */Block.__(12, [
29+
/* "%" */37,
30+
/* End_of_format */0
31+
])
32+
]),
33+
"%.2f%%"
34+
]), f) + "deg";
35+
}
36+
37+
var Encoder = /* module */[
38+
/* pct */pct,
39+
/* deg */deg
40+
];
41+
42+
export {
43+
Encoder ,
44+
45+
}
46+
/* No side effect */
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* encoders to json for react-native */
2+
module Encoder = {
3+
external string: string => Js.Json.t = "%identity";
4+
5+
external float: float => Js.Json.t = "%identity";
6+
7+
external int: int => Js.Json.t = "%identity";
8+
9+
external boolean: bool => Js.Json.t = "%identity";
10+
11+
external object_: Js_dict.t(Js.Json.t) => Js.Json.t = "%identity";
12+
13+
external array: array(Js.Json.t) => Js.Json.t = "%identity";
14+
15+
external animatedValue: AnimatedRe.value('a) => Js.Json.t = "%identity";
16+
17+
let pct = f => string(Printf.sprintf("%.2f%%", f));
18+
19+
let deg = f => string(Printf.sprintf("%.2f%%", f) ++ "deg");
20+
};
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
2+
3+
4+
function layout(t) {
5+
var l = t.nativeEvent.layout;
6+
return /* record */[
7+
/* x */l.x,
8+
/* y */l.y,
9+
/* width */l.width,
10+
/* height */l.height
11+
];
12+
}
13+
14+
var NativeLayoutEvent = /* module */[/* layout */layout];
15+
16+
function contentOffset(t) {
17+
var co = t.nativeEvent.contentOffset;
18+
return /* record */[
19+
/* x */co.x,
20+
/* y */co.y
21+
];
22+
}
23+
24+
function contentSize(t) {
25+
var cs = t.nativeEvent.contentSize;
26+
return /* record */[
27+
/* width */cs.width,
28+
/* height */cs.height
29+
];
30+
}
31+
32+
function layoutMeasurement(t) {
33+
var lm = t.nativeEvent.layoutMeasurement;
34+
return /* record */[
35+
/* width */lm.width,
36+
/* height */lm.height
37+
];
38+
}
39+
40+
function contentInset(t) {
41+
var ci = t.nativeEvent.contentInset;
42+
return /* record */[
43+
/* bottom */ci.bottom,
44+
/* top */ci.top,
45+
/* left */ci.left,
46+
/* right */ci.right
47+
];
48+
}
49+
50+
function NativeEvent_000(prim) {
51+
return prim.changedTouches;
52+
}
53+
54+
function NativeEvent_001(prim) {
55+
return prim.identifier;
56+
}
57+
58+
function NativeEvent_002(prim) {
59+
return prim.locationX;
60+
}
61+
62+
function NativeEvent_003(prim) {
63+
return prim.locationY;
64+
}
65+
66+
function NativeEvent_004(prim) {
67+
return prim.pageX;
68+
}
69+
70+
function NativeEvent_005(prim) {
71+
return prim.pageY;
72+
}
73+
74+
function NativeEvent_006(prim) {
75+
return prim.target;
76+
}
77+
78+
function NativeEvent_007(prim) {
79+
return prim.touches;
80+
}
81+
82+
function NativeEvent_008(prim) {
83+
return prim.timestamp;
84+
}
85+
86+
function NativeEvent_009(prim) {
87+
return prim.data;
88+
}
89+
90+
var NativeEvent = [
91+
NativeEvent_000,
92+
NativeEvent_001,
93+
NativeEvent_002,
94+
NativeEvent_003,
95+
NativeEvent_004,
96+
NativeEvent_005,
97+
NativeEvent_006,
98+
NativeEvent_007,
99+
NativeEvent_008,
100+
NativeEvent_009
101+
];
102+
103+
var NativePressEvent = 0;
104+
105+
var NativeScrollEvent = [
106+
contentOffset,
107+
contentSize,
108+
contentInset,
109+
layoutMeasurement
110+
];
111+
112+
function nativeEvent(prim) {
113+
return prim.nativeEvent;
114+
}
115+
116+
function nativeLayoutEvent(prim) {
117+
return prim.nativeEvent;
118+
}
119+
120+
function nativeScrollEvent(prim) {
121+
return prim.nativeEvent;
122+
}
123+
124+
export {
125+
NativeEvent ,
126+
NativePressEvent ,
127+
NativeScrollEvent ,
128+
NativeLayoutEvent ,
129+
nativeEvent ,
130+
nativeLayoutEvent ,
131+
nativeScrollEvent ,
132+
133+
}
134+
/* No side effect */
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
type t;
2+
3+
module NativeEvent = {
4+
type t;
5+
[@bs.get] external changedTouches: t => array(Js.t({..})) = "";
6+
[@bs.get] external identifier: t => int = "";
7+
[@bs.get] external locationX: t => float = "";
8+
[@bs.get] external locationY: t => float = "";
9+
[@bs.get] external pageX: t => float = "";
10+
[@bs.get] external pageY: t => float = "";
11+
[@bs.get] external target: t => Js.t({..}) = "";
12+
[@bs.get] external touches: t => array(Js.t({..})) = "";
13+
[@bs.get] external timestamp: t => int = "";
14+
[@bs.get] external data: t => string = "";
15+
};
16+
17+
/*
18+
fixme rename NativeEvent to NativePressEvent when necessary
19+
see https://github.com/facebook/react-native/blob/master/Libraries/Types/CoreEventTypes.js
20+
*/
21+
module NativePressEvent = NativeEvent;
22+
23+
module NativeLayoutEvent = {
24+
type t;
25+
type layout = {
26+
x: float,
27+
y: float,
28+
width: float,
29+
height: float,
30+
};
31+
[@bs.get] external _layout: t => Js.t('a) = "nativeEvent";
32+
let layout = (t: t) => {
33+
let l = _layout(t)##layout;
34+
{x: l##x, y: l##y, width: l##width, height: l##height};
35+
};
36+
};
37+
38+
module NativeScrollEvent = {
39+
type t;
40+
type point = {
41+
x: float,
42+
y: float,
43+
};
44+
type size = {
45+
width: float,
46+
height: float,
47+
};
48+
type contentInset = {
49+
bottom: float,
50+
top: float,
51+
left: float,
52+
right: float,
53+
};
54+
[@bs.get] external _nativeEvent: t => Js.t('a) = "nativeEvent";
55+
let contentOffset = (t: t) => {
56+
let co = _nativeEvent(t)##contentOffset;
57+
{x: co##x, y: co##y};
58+
};
59+
let contentSize = (t: t) => {
60+
let cs = _nativeEvent(t)##contentSize;
61+
{width: cs##width, height: cs##height};
62+
};
63+
let layoutMeasurement = (t: t) => {
64+
let lm = _nativeEvent(t)##layoutMeasurement;
65+
{width: lm##width, height: lm##height};
66+
};
67+
let contentInset = (t: t) => {
68+
let ci = _nativeEvent(t)##contentInset;
69+
{bottom: ci##bottom, top: ci##top, left: ci##left, right: ci##right};
70+
};
71+
};
72+
73+
[@bs.get] external nativeEvent: t => NativeEvent.t = "";
74+
75+
[@bs.get] external nativeLayoutEvent: t => NativeLayoutEvent.t = "nativeEvent";
76+
77+
[@bs.get] external nativeScrollEvent: t => NativeScrollEvent.t = "nativeEvent";

0 commit comments

Comments
 (0)