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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ node_modules
# ReScript artifacts
# *.bs.js # we do want this files to ensure zero-cost
.bsb.lock
**/lib/bs
**/lib/ocaml
lib/
**/.merlin
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
24
2,573 changes: 1,001 additions & 1,572 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"description": "ReScript bindings for React Native.",
"version": "0.83.0",
"peerDependencies": {
"@rescript/react": ">=0.14.2",
"@rescript/react": ">=0.15.0",
"react-native": ">=0.83.0",
"rescript": ">=11.0.0"
"rescript": ">=12.0.0"
},
"overrides": {
"react": "^19.2.0"
Expand All @@ -28,24 +28,24 @@
"scripts": {
"prepare": "husky install",
"format:most": "prettier --write \"**/*.{md,json,js,css}\"",
"format:res": "rescript format -all",
"format": "npm run format:most && npm run format:res",
"re:start": "rescript build -w",
"re:build": "rescript",
"re:clean-build": "rescript clean && rescript",
"format": "npm run format:most && npm run re:format",
"re:start": "rescript watch",
"re:build": "rescript build",
"re:clean": "rescript clean",
"re:format": "rescript format",
"start": "npm run re:start",
"build": "npm run re:build",
"test": "npm run re:clean-build",
"test": "npm run re:clean && npm run re:build",
"release": "npmpub"
},
"devDependencies": {
"@rescript/react": "^0.14.2",
"@rescript/react": "^0.15.0",
"husky": "^8.0.0",
"lint-staged": "^13.0.0",
"npm-run-all": "^4.0.0",
"npmpub": "^5.0.0",
"prettier": "^2.0.0",
"rescript": "^11.1.0"
"rescript": "~12.0.2"
},
"prettier": {
"trailingComma": "all"
Expand Down
8 changes: 4 additions & 4 deletions rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
"version": 4
},
"package-specs": {
"module": "commonjs",
"module": "esmodule",
"in-source": true
},
"suffix": ".bs.js",
"suffix": ".res.js",
"sources": [
{
"dir": "src",
"subdirs": true
}
],
"bsc-flags": [
"compiler-flags": [
"-bs-no-version-header"
],
"warnings": {
"error": true
},
"bs-dependencies": [
"dependencies": [
"@rescript/react"
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
136 changes: 0 additions & 136 deletions src/apis/Animated.bs.js

This file was deleted.

14 changes: 5 additions & 9 deletions src/apis/Animated.res
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,23 @@ external stagger: (float, array<Animation.t>) => Animation.t = "stagger"

type loopConfig = {iterations?: int, resetBeforeIteration?: bool}

// multiple externals
@module("react-native") @scope("Animated")
external loop: Animation.t => Animation.t = "loop"

// multiple externals
@module("react-native") @scope("Animated")
external loopWithConfig: (Animation.t, loopConfig) => Animation.t = "loop"
external loop: (Animation.t, ~config: loopConfig=?) => Animation.t = "loop"

type eventOptions<'a, 'platformConfig> = {
type eventConfig<'a, 'platformConfig> = {
listener?: 'a,
useNativeDriver: bool,
platformConfig?: 'platformConfig,
}

// multiple externals
@module("react-native") @scope("Animated")
external event1: (array<'mapping>, eventOptions<'a, 'platformConfig>) => 'a = "event"
external event1: (array<'mapping>, ~config: eventConfig<'a, 'platformConfig>=?) => 'a = "event"

// multiple externals
@module("react-native") @scope("Animated")
external event2: (('mapping1, 'mapping2), eventOptions<'a, 'platformConfig>) => 'a = "event"
external event2: (('mapping1, 'mapping2), ~config: eventConfig<'a, 'platformConfig>=?) => 'a =
"event"

@module("react-native") @scope("Animated")
external createAnimatedComponent: React.component<'props> => React.component<'props> =
Expand Down
138 changes: 138 additions & 0 deletions src/apis/Animated.res.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@


import * as ReactNative from "react-native";
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";

let Animation = {};

function ValueAnimations(Val) {
let Decay = {};
let Spring = {};
let Timing = {};
return {
Decay: Decay,
Spring: Spring,
Timing: Timing
};
}

let Interpolation = {};

function interpolate(prim0, prim1) {
return prim0.interpolate(prim1);
}

let ValueOperations = {
interpolate: interpolate
};

function ValueMethods(Val) {
let Decay = {};
let Spring = {};
let Timing = {};
return {
Decay: Decay,
Spring: Spring,
Timing: Timing
};
}

let Decay = {};

let Spring = {};

let Timing = {};

let Value = {
Decay: Decay,
Spring: Spring,
Timing: Timing,
interpolate: interpolate
};

let Decay$1 = {};

let Spring$1 = {};

let Timing$1 = {};

let ValueXY = {
Decay: Decay$1,
Spring: Spring$1,
Timing: Timing$1
};

let Decay$2 = {};

let Spring$2 = {};

let Timing$2 = {};

let Color = {
Decay: Decay$2,
Spring: Spring$2,
Timing: Timing$2
};

function timing(prim0, prim1) {
return ReactNative.Animated.timing(prim0, prim1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems wrong
but not sure if it was a compiler bug

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's wrong? It look the same in the .bs.js

function timing(prim0, prim1) {
  return ReactNative.Animated.timing(prim0, prim1);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not zero cost, but it could be, if you duplicate the binding definition instead of using let.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see! But it's not really a regression, we've been living with it for years now, so for me it's a non-blocker for this PR.

It's definitely something we could improve as part of a more global Animated refactoring, though!

For now, IMO, the goal should be to move forward with a 0.84 release using Rescript 12.0. We're already a bit late on the release, so we can use a later one for other Rescript updates (12.1, 12.2, 12.3?) or a breaking-change refactor.

}

function spring(prim0, prim1) {
return ReactNative.Animated.spring(prim0, prim1);
}

function decay(prim0, prim1) {
return ReactNative.Animated.decay(prim0, prim1);
}

function start(prim0, prim1) {
prim0.start(prim1 !== undefined ? Primitive_option.valFromOption(prim1) : undefined);
}

function stop(prim) {
prim.stop();
}

function reset(prim) {
prim.reset();
}

let StyleProp = {};

let FlatList = {};

let Image = {};

let ScrollView = {};

let SectionList = {};

let Text = {};

let View = {};

export {
Animation,
ValueAnimations,
Interpolation,
ValueOperations,
ValueMethods,
Value,
ValueXY,
Color,
timing,
spring,
decay,
start,
stop,
reset,
StyleProp,
FlatList,
Image,
ScrollView,
SectionList,
Text,
View,
}
/* react-native Not a pure module */
File renamed without changes.
Loading
Loading