Skip to content

Adaptations for ReScript 10 / use records with optional fields #769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 12, 2022
Merged
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
1,469 changes: 531 additions & 938 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"peerDependencies": {
"@rescript/react": ">=0.10.0",
"react-native": ">=0.69.0",
"rescript": ">=9.1.4"
"rescript": ">=10.0.0"
},
"overrides": {
"react": "17.0.2"
Expand Down
24 changes: 20 additions & 4 deletions src/apis/ActionSheetIOS.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
type options
@obj
type options = {
options: array<string>,
cancelButtonIndex?: int,
destructiveButtonIndex?: array<int>,
disabledButtonIndices?: int,
title?: string,
message?: string,
tintColor?: Color.t,
cancelButtonTintColor?: Color.t,
}

@obj @deprecated("Directly create record instead")
external options: (
~options: array<string>,
~cancelButtonIndex: int=?,
Expand All @@ -15,8 +25,14 @@ external options: (
@module("react-native") @scope("ActionSheetIOS")
external showActionSheetWithOptions: (options, int => unit) => unit = "showActionSheetWithOptions"

type shareOptions
@obj
type shareOptions = {
url?: string,
message?: string,
subject?: string,
excludedActivityTypes?: array<string>,
}

@obj @deprecated("Directly create record instead")
external shareOptions: (
~url: string=?,
~message: string=?,
Expand Down
17 changes: 12 additions & 5 deletions src/apis/Alert.res
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
type options
type options = {
cancelable?: bool,
onDismiss?: unit => unit,
}

@obj
@obj @deprecated("Directly create record instead")
external options: (~cancelable: bool=?, ~onDismiss: unit => unit=?, unit) => options = ""

type button

type style = [#default | #cancel | #destructive]

@obj
type button = {
text?: string,
onPress?: unit => unit,
style?: style,
}

@obj @deprecated("Directly create record instead")
external button: (~text: string=?, ~onPress: unit => unit=?, ~style: style=?, unit) => button = ""

@scope("Alert") @module("react-native")
Expand Down
1 change: 0 additions & 1 deletion src/apis/Animated.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ var make$1 = ReactNative.Animated.createAnimatedComponent(ReactNative.Image);

var $$Image = {
Source: Image$ReactNative.Source,
DefaultSource: Image$ReactNative.DefaultSource,
ImageLoadEvent: Image$ReactNative.ImageLoadEvent,
$$ErrorEvent: Image$ReactNative.$$ErrorEvent,
$$ProgressEvent: Image$ReactNative.$$ProgressEvent,
Expand Down
64 changes: 53 additions & 11 deletions src/apis/Animated.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ type value<'a>

module ValueAnimations = (Val: Value) => {
module Decay = {
type config

@obj
type config = {
velocity: Val.rawValue,
useNativeDriver: bool,
deceleration?: float,
isInteraction?: bool,
onComplete?: Animation.endCallback,
iterations?: int,
}

@obj @deprecated("Directly create record instead")
external config: (
~velocity: Val.rawValue,
~deceleration: float=?,
Expand All @@ -45,9 +52,27 @@ module ValueAnimations = (Val: Value) => {
external fromRawValue: Val.rawValue => toValue = "%identity"
external fromAnimatedValue: Val.t => toValue = "%identity"

type config

@obj
type config = {
toValue: toValue,
useNativeDriver: bool,
restDisplacementThreshold?: float,
overshootClamping?: bool,
restSpeedThreshold?: float,
velocity?: Val.rawValue,
bounciness?: float,
speed?: float,
tension?: float,
friction?: float,
stiffness?: float,
mass?: float,
damping?: float,
delay?: float,
isInteraction?: bool,
onComplete?: Animation.endCallback,
iterations?: int,
}

@obj @deprecated("Directly create record instead")
external config: (
~toValue: toValue,
~restDisplacementThreshold: float=?,
Expand Down Expand Up @@ -79,9 +104,18 @@ module ValueAnimations = (Val: Value) => {
external fromRawValue: Val.rawValue => toValue = "%identity"
external fromAnimatedValue: Val.t => toValue = "%identity"

type config

@obj
type config = {
toValue: toValue,
useNativeDriver: bool,
easing?: Easing.t,
duration?: float,
delay?: float,
isInteraction?: bool,
onComplete?: Animation.endCallback,
iterations?: int,
}

@obj @deprecated("Directly create record instead")
external config: (
~toValue: toValue,
~easing: Easing.t=?,
Expand All @@ -107,8 +141,16 @@ module Interpolation = {

type extrapolate = [#extend | #clamp | #identity]

type config
@obj
type config = {
inputRange: array<float>,
outputRange: outputRange,
easing?: Easing.t,
extrapolate?: extrapolate,
extrapolateLeft?: extrapolate,
extrapolateRight?: extrapolate,
}

@obj @deprecated("Directly create record instead")
external config: (
~inputRange: array<float>,
~outputRange: outputRange,
Expand Down
6 changes: 3 additions & 3 deletions src/apis/DynamicColorIOS.res
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
type t = {
dark: Color.t,
light: Color.t,
highContrastLight: option<Color.t>,
highContrastDark: option<Color.t>,
highContrastLight?: Color.t,
highContrastDark?: Color.t,
}

@obj
@obj @deprecated("Directly create record instead")
external dynamicColor: (
~dark: Color.t,
~light: Color.t,
Expand Down
13 changes: 9 additions & 4 deletions src/apis/ImagePickerIOS.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ external canUseCamera: (bool => unit) => unit = "canUseCamera"
@module("react-native") @scope("ImagePickerIOS")
external canRecordVideos: (bool => unit) => unit = "canRecordVideos"

type cameraDialogConfig
@obj
type cameraDialogConfig = {videoMode?: bool}

@obj @deprecated("Directly create record instead")
external cameraDialogConfig: (~videoMode: bool=?, unit) => cameraDialogConfig = ""

type selectDialogConfig
@obj
type selectDialogConfig = {
showImages?: bool,
showVideos?: bool,
}

@obj @deprecated("Directly create record instead")
external selectDialogConfig: (
~showImages: bool=?,
~showVideos: bool=?,
Expand Down
22 changes: 18 additions & 4 deletions src/apis/LayoutAnimation.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ type animationType = [

type property = [#opacity | #scaleX | #scaleY | #scaleXY]

type animationConfig
@obj
type animationConfig = {
duration?: float,
delay?: float,
springDamping?: float,
initialVelocity?: float,
\"type"?: animationType,
property?: property,
}

@obj @deprecated("Directly create record instead")
external animationConfig: (
~duration: float=?,
~delay: float=?,
Expand All @@ -21,8 +29,14 @@ external animationConfig: (
unit,
) => animationConfig = ""

type layoutAnimationConfig
@obj
type layoutAnimationConfig = {
duration: float,
create?: animationConfig,
update?: animationConfig,
delete?: animationConfig,
}

@obj @deprecated("Directly create record instead")
external layoutAnimationConfig: (
~duration: float,
~create: animationConfig=?,
Expand Down
8 changes: 7 additions & 1 deletion src/apis/Linking.bs.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
'use strict';


var ExtraValue = {};

exports.ExtraValue = ExtraValue;
/* No side effect */
17 changes: 15 additions & 2 deletions src/apis/Linking.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
type extra
@obj external extra: (~key: string, ~value: 'a) => extra = ""
module ExtraValue = {
type t

external fromString: string => t = "%identity"
external fromInt: int => t = "%identity"
external fromFloat: float => t = "%identity"
external fromBool: bool => t = "%identity"
}

type extraValue = ExtraValue.t

type extra = {key: string, value: extraValue}

@obj @deprecated("Directly create record instead")
external extra: (~key: string, ~value: extraValue) => extra = ""

@scope("Linking") @module("react-native")
external openURL: string => Js.Promise.t<unit> = "openURL"
Expand Down
19 changes: 17 additions & 2 deletions src/apis/PanResponder.res
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ type gestureState = {
}

type t
type config
type panHandlers
type callback<'a> = Event.pressEvent => 'a

@obj
type config = {
onMoveShouldSetPanResponder?: (Event.pressEvent, gestureState) => bool,
onMoveShouldSetPanResponderCapture?: (Event.pressEvent, gestureState) => bool,
onStartShouldSetPanResponder?: (Event.pressEvent, gestureState) => bool,
onStartShouldSetPanResponderCapture?: (Event.pressEvent, gestureState) => bool,
onPanResponderReject?: (Event.pressEvent, gestureState) => unit,
onPanResponderGrant?: (Event.pressEvent, gestureState) => unit,
onPanResponderStart?: (Event.pressEvent, gestureState) => unit,
onPanResponderEnd?: (Event.pressEvent, gestureState) => unit,
onPanResponderRelease?: (Event.pressEvent, gestureState) => unit,
onPanResponderMove?: (Event.pressEvent, gestureState) => unit,
onPanResponderTerminate?: (Event.pressEvent, gestureState) => unit,
onPanResponderTerminationRequest?: (Event.pressEvent, gestureState) => bool,
onShouldBlockNativeResponder?: (Event.pressEvent, gestureState) => bool,
}

@obj @deprecated("Directly create record instead")
external config: (
~onMoveShouldSetPanResponder: (Event.pressEvent, gestureState) => bool=?,
~onMoveShouldSetPanResponderCapture: (Event.pressEvent, gestureState) => bool=?,
Expand Down
11 changes: 9 additions & 2 deletions src/apis/PermissionsAndroid.res
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@ module Result = {
external neverAskAgain: t = "NEVER_ASK_AGAIN"
}

type rationale
@obj
type rationale = {
title: string,
message: string,
buttonPositive: string,
buttonNegative?: string,
buttonNeutral?: string,
}

@obj @deprecated("Directly create record instead")
external rationale: (
~title: string,
~message: string,
Expand Down
11 changes: 9 additions & 2 deletions src/apis/PermissionsAndroid.resi
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@ module Result: {
external neverAskAgain: t = "NEVER_ASK_AGAIN"
}

type rationale
@obj
type rationale = {
title: string,
message: string,
buttonPositive: string,
buttonNegative?: string,
buttonNeutral?: string,
}

@obj @deprecated("Directly create record instead")
external rationale: (
~title: string,
~message: string,
Expand Down
Loading