Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.re linguist-language=Reason
*.rei linguist-language=Reason
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"scripts": {
"format:most": "prettier --write \"**/*.{md,json,js,css}\"",
"format:re": "find ./packages -iname '*.re' | xargs bsrefmt --in-place && find ./packages -iname '*.rei' | xargs bsrefmt -i true --in-place && find ./test -iname '*.re' | xargs bsrefmt --in-place && find ./template -iname '*.re' | xargs bsrefmt --in-place",
"format:re": "find ./packages -iname '*.re' | xargs bsrefmt --in-place && find ./packages -iname '*.rei' | xargs bsrefmt -i true --in-place && find ./packages/test -iname '*.re' | xargs bsrefmt --in-place && find ./packages/template -iname '*.re' | xargs bsrefmt --in-place",
"format": "yarn format:most && yarn format:re",
"watch": "run-p watch:reason-expo watch:test",
"watch:reason-expo": "cd packages/reason-expo && yarn watch",
Expand Down
16 changes: 8 additions & 8 deletions packages/reason-expo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "reason-expo",
"description": "ReasonML bindings for Expo",
"version": "37.0.0",
"version": "38.0.0",
"scripts": {
"build": "bsb -make-world",
"watch": "bsb -make-world -w",
Expand All @@ -24,18 +24,18 @@
},
"devDependencies": {
"babel-preset-expo": "^8.1.0",
"bs-platform": "^7.3.2",
"expo": "^37.0.0",
"reason-react": "^0.8.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz"
"bs-platform": "^8.2.0",
"expo": "^38.0.0",
"reason-react": "^0.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz"
},
"bugs": "https://github.com/fiberjw/reason-expo/issues",
"peerDependencies": {
"expo": "^37.0.0",
"expo": "^38.0.0",
"react": "^16.9.0",
"react-dom": "^16.8.1",
"reason-react": "^0.8.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"reason-react-native": "^0.61.1"
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"reason-react-native": "^0.62.3"
}
}
76 changes: 31 additions & 45 deletions packages/reason-expo/src/AR.re
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module HitTestResultTypes = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "HitTestResultTypes")]
external featurePoint: t = "FeaturePoint";
Expand All @@ -21,7 +21,7 @@ module HitTestResultTypes = {
};

module TrackingConfiguration = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "TrackingConfiguration")]
external world: t = "World";
Expand All @@ -34,7 +34,7 @@ module TrackingConfiguration = {
};

module DepthDataQuality = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "DepthDataQuality")]
external low: t = "Low";
Expand All @@ -44,7 +44,7 @@ module DepthDataQuality = {
};

module DepthDataAccuracy = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "DepthDataAccuracy")]
external absolute: t = "Absolute";
Expand All @@ -54,7 +54,7 @@ module DepthDataAccuracy = {
};

module BlendShape = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "BlendShape")]
external browDownL: t = "BrowDownL";
Expand Down Expand Up @@ -211,7 +211,7 @@ module BlendShape = {
};

module FaceAnchorProp = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "FaceAnchorProp")]
external geometry: t = "Geometry";
Expand All @@ -221,7 +221,7 @@ module FaceAnchorProp = {
};

module PlaneDetection = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "PlaneDetection")]
external none: t = "None";
Expand All @@ -234,7 +234,7 @@ module PlaneDetection = {
};

module WorldAlignment = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "WorldAlignment")]
external gravity: t = "Gravity";
Expand Down Expand Up @@ -269,7 +269,7 @@ module EventType = {
};

module AnchorType = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "AnchorType")]
external face: t = "Face";
Expand All @@ -285,7 +285,7 @@ module AnchorType = {
};

module AnchorEventType = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "AnchorEventType")]
external add: t = "Add";
Expand All @@ -298,7 +298,7 @@ module AnchorEventType = {
};

module FrameAttribute = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "FrameAttribute")]
external anchors: t = "Anchors";
Expand All @@ -314,7 +314,7 @@ module FrameAttribute = {
};

module TrackingState = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "TrackingState")]
external notAvailable: t = "NotAvailable";
Expand All @@ -327,7 +327,7 @@ module TrackingState = {
};

module TrackingStateReason = {
type t = string;
type t;

[@bs.module "expo"] [@bs.scope ("AR", "TrackingStateReason")]
external none: t = "None";
Expand Down Expand Up @@ -424,13 +424,9 @@ and arFaceTrackingConfiguration = {
};

type arFrameRequest = {
// [@bs.optional]
anchors: option(arFrameAnchorRequest),
// [@bs.optional]
rawFeaturePoints: option(bool),
// [@bs.optional]
lightEstimation: option(bool),
// [@bs.optional]
capturedDepthData: option(bool),
};

Expand Down Expand Up @@ -513,30 +509,23 @@ external onFrameDidUpdate: (unit => unit) => unit = "onFrameDidUpdate";
external onDidFailWithError: ({. error: string} => unit) => unit =
"onDidFailWithError";

type onAnchorsDidUpdateResult = {
anchors: array(anchor),
eventType: AnchorEventType.t,
};

[@bs.module "expo"] [@bs.scope "AR"]
external onAnchorsDidUpdate:
(
{
.
anchors: array(anchor),
eventType: AnchorEventType.t,
} =>
unit
) =>
unit =
external onAnchorsDidUpdate: (onAnchorsDidUpdateResult => unit) => unit =
"onAnchorsDidUpdate";

type onCameraDidChangeTrackingStateResult = {
trackingState: TrackingState.t,
trackingStateReason: TrackingStateReason.t,
};

[@bs.module "expo"] [@bs.scope "AR"]
external onCameraDidChangeTrackingState:
(
{
.
trackingState: TrackingState.t,
trackingStateReason: TrackingStateReason.t,
} =>
unit
) =>
unit =
(onCameraDidChangeTrackingStateResult => unit) => unit =
"onCameraDidChangeTrackingState";

[@bs.module "expo"] [@bs.scope "AR"]
Expand All @@ -547,17 +536,14 @@ external onSessionWasInterrupted: (unit => unit) => unit =
external onSessionInterruptionEnded: (unit => unit) => unit =
"onSessionInterruptionEnded";

type performHitTestPoint = {
x: float,
y: float,
};

[@bs.module "expo"] [@bs.scope "AR"]
external performHitTest:
(
{
.
x: float,
y: float,
},
HitTestResultTypes.t
) =>
hitTestResults =
(performHitTestPoint, HitTestResultTypes.t) => hitTestResults =
"performHitTest";

[@bs.module "expo"] [@bs.scope "AR"]
Expand Down
8 changes: 2 additions & 6 deletions packages/reason-expo/src/Accelerometer.re
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[@bs.deriving abstract]
type eventSubscription;
type eventSubscription = {remove: unit => unit};

[@bs.send] external remove: (eventSubscription, unit) => unit = "remove";

[@bs.deriving abstract]
type location = {
x: int,
y: int,
Expand All @@ -17,4 +13,4 @@ external addListener: (location => unit) => eventSubscription = "addListener";
external removeAllListeners: unit => unit = "removeAllListeners";

[@bs.module "expo-sensors"] [@bs.scope "Accelerometer"]
external setUpdateInterval: int => unit = "setUpdateInterval";
external setUpdateInterval: int => unit = "setUpdateInterval";
44 changes: 44 additions & 0 deletions packages/reason-expo/src/ActionSheet.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module Provider = {
[@bs.module "@expo/react-native-action-sheet"] [@react.component]
external make: (~children: React.element) => React.element =
"ActionSheetProvider";
};

type actionSheetOptions = {
title: option(string),
message: option(string),
options: array(string),
destructiveButtonIndex: int,
cancelButtonIndex: option(int),
};

type handleAction = int => unit;

type useActionSheet = {
showActionSheetWithOptions: (actionSheetOptions, handleAction) => unit,
};

[@bs.module "@expo/react-native-action-sheet"]
external useActionSheet: unit => useActionSheet = "useActionSheet";

let useActionSheetRe = () => {
let {showActionSheetWithOptions} = useActionSheet();

let showActionSheetWithOptionsRe =
(
~title: option(string)=?,
~message: option(string)=?,
~onSelect: handleAction,
~options: array(string),
~destructiveButtonIndex: int,
~cancelButtonIndex: option(int)=?,
(),
) => {
showActionSheetWithOptions(
{title, message, options, destructiveButtonIndex, cancelButtonIndex},
onSelect,
);
};

showActionSheetWithOptionsRe;
};
83 changes: 23 additions & 60 deletions packages/reason-expo/src/AdMob.re
Original file line number Diff line number Diff line change
@@ -1,64 +1,27 @@
type bannerSize =
| Banner
| LargeBanner
| MediumRectangle
| FullBanner
| Leaderboard
| SmartBannerPortrait
| SmartBannerLandscape;

module AdMobBanner = {
type props = {
// [@bs.optional]
bannerSize: option(string),
// [@bs.optional]
onAdViewDidReceiveAd: option(unit => unit),
// [@bs.optional]
onDidFailToReceiveAdWithError: option(string => unit),
// [@bs.optional]
onAdViewWillPresentScreen: option(unit => unit),
// [@bs.optional]
onAdViewWillDismissScreen: option(unit => unit),
// [@bs.optional]
onAdViewDidDismissScreen: option(unit => unit),
// [@bs.optional]
onAdViewWillLeaveApplication: option(unit => unit),
// [@bs.optional]
children: option(React.element),
};

let props =
(
~bannerSize=Banner,
~onAdViewDidReceiveAd=() => (),
~onDidFailToReceiveAdWithError=_e => (),
~onAdViewWillPresentScreen=() => (),
~onAdViewWillDismissScreen=() => (),
~onAdViewDidDismissScreen=() => (),
~onAdViewWillLeaveApplication=() => (),
~children,
) => {
bannerSize:
switch (bannerSize) {
| Banner => Some("banner")
| LargeBanner => Some("largeBanner")
| MediumRectangle => Some("mediumRectangle")
| FullBanner => Some("fullBanner")
| Leaderboard => Some("leaderboard")
| SmartBannerPortrait => Some("smartBannerPortrait")
| SmartBannerLandscape => Some("smartBannerLandscape")
},
onAdViewDidReceiveAd: Some(onAdViewDidReceiveAd),
onDidFailToReceiveAdWithError: Some(onDidFailToReceiveAdWithError),
onAdViewWillPresentScreen: Some(onAdViewWillPresentScreen),
onAdViewWillDismissScreen: Some(onAdViewWillDismissScreen),
onAdViewDidDismissScreen: Some(onAdViewDidDismissScreen),
onAdViewWillLeaveApplication: Some(onAdViewWillLeaveApplication),
children: Some(children),
};

[@bs.module "expo-ads-admob"] [@react.component]
external make: props => React.element = "AdMobBanner";
external make:
(
~bannerSize: [
| `banner
| `largeBanner
| `mediumRectangle
| `fullBanner
| `leaderboard
| `smartBannerPortrait
| `smartBannerLandscape
]
=?,
~onAdViewDidReceiveAd: unit => unit=?,
~onDidFailToReceiveAdWithError: string => unit=?,
~onAdViewWillPresentScreen: unit => unit=?,
~onAdViewWillDismissScreen: unit => unit=?,
~onAdViewDidDismissScreen: unit => unit=?,
~onAdViewWillLeaveApplication: unit => unit=?,
~children: React.element=?
) =>
React.element =
"AdMobBanner";
};

module AdMobInterstitial = {
Expand All @@ -83,4 +46,4 @@ module AdMobRewarded = {
external requestAdAsync: unit => Js.Promise.t(unit) = "requestAdAsync";
[@bs.module "expo-ads-admob"] [@bs.scope "AdMobRewarded"]
external showAdAsync: unit => Js.Promise.t(unit) = "showAdAsync";
};
};
Loading