Skip to content

Commit

Permalink
Update reason dependency (#181)
Browse files Browse the repository at this point in the history
* chore: update reason to 3.11.0 or higher

* chore: improve .ocamlformat

* chore: format files
  • Loading branch information
pedrobslisboa authored Nov 13, 2024
1 parent 158646c commit 61e1f6a
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
profile = default
profile=default
12 changes: 10 additions & 2 deletions demo/universal/native/lib/Align.re
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
type verticalAlign = [ | `top | `center | `bottom];
type horizontalAlign = [ | `left | `center | `right];
type verticalAlign = [
| `top
| `center
| `bottom
];
type horizontalAlign = [
| `left
| `center
| `right
];

[@react.component]
let make = (~h: horizontalAlign=`center, ~v: verticalAlign=`center, ~children) => {
Expand Down
5 changes: 4 additions & 1 deletion demo/universal/native/lib/App.re
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ module Title = {
label: "Issues",
link: "https://github.com/ml-in-barcelona/server-reason-react/issues",
},
{label: "About", link: "https://twitter.com/davesnx"},
{
label: "About",
link: "https://twitter.com/davesnx",
},
|];

<div
Expand Down
14 changes: 6 additions & 8 deletions demo/universal/native/lib/MelRaw.re
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
let%browser_only mockInitWebsocket = () => [%mel.raw
{|
let%browser_only mockInitWebsocket = () =>
{%mel.raw |
function mockInitWebsocket() {
console.log("Load JS");
}
|}
];
|};

let%browser_only initWebsocket = () => [%mel.raw
{|
let%browser_only initWebsocket = () =>
{%mel.raw |
function initWebsocket() {
var socketUrl = "ws://" + location.host + "/_livereload";
var s = new WebSocket(socketUrl);
Expand Down Expand Up @@ -40,7 +39,6 @@ let%browser_only initWebsocket = () => [%mel.raw
console.debug("Live reload: WebSocket error:", event);
};
}
|}
];
|};

let x = 22;
15 changes: 13 additions & 2 deletions demo/universal/native/lib/Theme.re
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
type align = [ | `start | `center | `end_];
type justify = [ | `around | `between | `evenly | `start | `center | `end_];
type align = [
| `start
| `center
| `end_
];
type justify = [
| `around
| `between
| `evenly
| `start
| `center
| `end_
];

module Media = {
let onDesktop = rules => {
Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(depends
; General system dependencies
(ocaml (>= 5.0.0))
(reason (= 3.10.0))
(reason (>= 3.11.0))
(melange (>= 3.0.0))

; Library dependencies
Expand All @@ -45,7 +45,7 @@
; Dev dependencies
(ocamlformat
(and
(= 0.26.1)
(= 0.26.2)
:with-test)) ; We use ocamlformat on the tests
(ocaml-lsp-server :with-dev-setup)

Expand Down
6 changes: 2 additions & 4 deletions packages/promise/js/promise.re
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ let onUnhandledException =
Js.Console.error(exn);
});

[%%mel.raw
{|
{%%mel.raw |
function PromiseBox(p) {
this.nested = p;
};
Expand Down Expand Up @@ -72,8 +71,7 @@ function catch_(promise, callback) {

return promise.catch(safeCallback);
};
|}
];
|};

module Js_ = {
type t('a, 'e) = rejectable('a, 'e);
Expand Down
26 changes: 22 additions & 4 deletions packages/promise/native/promise.re
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ module MutableList: MutableList = {
mutable last: node('a),
};

type list('a) = ref([ | `Empty | `NonEmpty(listEnds('a))]);
type list('a) =
ref(
[
| `Empty
| `NonEmpty(listEnds('a))
],
);

let create = () => ref(`Empty);

Expand All @@ -48,12 +54,24 @@ module MutableList: MutableList = {
let append = (list, value) =>
switch (list^) {
| `Empty =>
let node = {previous: None, next: None, content: value};
list := `NonEmpty({first: node, last: node});
let node = {
previous: None,
next: None,
content: value,
};
list :=
`NonEmpty({
first: node,
last: node,
});
node;

| `NonEmpty(ends) =>
let node = {previous: Some(ends.last), next: None, content: value};
let node = {
previous: Some(ends.last),
next: None,
content: value,
};
ends.last.next = Some(node);
ends.last = node;
node;
Expand Down
5 changes: 3 additions & 2 deletions packages/server-reason-react-ppx/cram/external.t/run.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$ ../ppx.sh --output re input.re
module MyPropIsOptionOptionBoolWithSig = {
[%ocaml.error
"externals aren't supported on server-reason-react. externals are used to bind to React components defined in JavaScript, in the server, that doesn't make sense. If you need to render this on the server, implement a placeholder or an empty element"];
[%%ocaml.error
"externals aren't supported on server-reason-react. externals are used to bind to React components defined in JavaScript, in the server, that doesn't make sense. If you need to render this on the server, implement a placeholder or an empty element"
];
};
8 changes: 7 additions & 1 deletion packages/webapi/tests/Dom/Webapi__Dom__Element__test.re
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ let _ = scrollIntoView(el);
/*let _ = scrollIntoViewNoAlignToTop(el);*/
let _ = scrollIntoViewNoAlignToTop(el);
let _ =
scrollIntoViewWithOptions({"block": "end", "behavior": "smooth"}, el);
scrollIntoViewWithOptions(
{
"block": "end",
"behavior": "smooth",
},
el,
);
let _ = setAttribute("href", "http://...", el);
let _ = setAttributeNS("http://...", "foo", "bar", el);
let _ = setPointerCapture(PointerEvent.pointerId(event), el);
24 changes: 17 additions & 7 deletions packages/webapi/tests/Dom/Webapi__Dom__EventTarget__test.re
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@ addEventListener("click", handleClick, target);
addEventListenerWithOptions(
"click",
handleClick,
{"passive": true, "once": true, "capture": false},
{
"passive": true,
"once": true,
"capture": false,
},
target,
);
addEventListenerUseCapture("click", handleClick, target);
removeEventListener("click", handleClick, target);
removeEventListenerWithOptions(
"click",
handleClick,
{"passive": true, "capture": false},
{
"passive": true,
"capture": false,
},
target,
);
removeEventListenerUseCapture("click", handleClick, target);
let _ = dispatchEvent(event, target);

/* https://github.com/reasonml-community/bs-webapi-incubator/issues/103 */
let customEvent =
CustomEvent.makeWithOptions("custom-event", {
"detail": {
"test": "test",
},
});
CustomEvent.makeWithOptions(
"custom-event",
{
"detail": {
"test": "test",
},
},
);
dispatchEvent(customEvent, target);
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ let elm = document |> Document.createElement("strong");

Element.addSelectionChangeEventListenerWithOptions(
handleSelection,
{"passive": true, "once": true, "capture": false},
{
"passive": true,
"once": true,
"capture": false,
},
elm,
);
Element.addSelectionChangeEventListenerUseCapture(handleSelection, elm);
Element.removeSelectionChangeEventListener(handleSelection, elm);
Element.removeSelectionChangeEventListenerWithOptions(
handleSelection,
{"passive": true, "capture": false},
{
"passive": true,
"capture": false,
},
elm,
);
Element.removeSelectionChangeEventListenerUseCapture(handleSelection, elm);
Expand All @@ -26,7 +33,11 @@ let htmlElm =

HtmlElement.addSelectionChangeEventListenerWithOptions(
handleSelection,
{"passive": true, "once": true, "capture": false},
{
"passive": true,
"once": true,
"capture": false,
},
htmlElm,
);
HtmlElement.addSelectionChangeEventListenerUseCapture(
Expand All @@ -36,7 +47,10 @@ HtmlElement.addSelectionChangeEventListenerUseCapture(
HtmlElement.removeSelectionChangeEventListener(handleSelection, htmlElm);
HtmlElement.removeSelectionChangeEventListenerWithOptions(
handleSelection,
{"passive": true, "capture": false},
{
"passive": true,
"capture": false,
},
htmlElm,
);
HtmlElement.removeSelectionChangeEventListenerUseCapture(
Expand All @@ -49,7 +63,11 @@ let htmlDoc =

HtmlDocument.addSelectionChangeEventListenerWithOptions(
handleSelection,
{"passive": true, "once": true, "capture": false},
{
"passive": true,
"once": true,
"capture": false,
},
htmlDoc,
);
HtmlDocument.addSelectionChangeEventListenerUseCapture(
Expand All @@ -59,7 +77,10 @@ HtmlDocument.addSelectionChangeEventListenerUseCapture(
HtmlDocument.removeSelectionChangeEventListener(handleSelection, htmlDoc);
HtmlDocument.removeSelectionChangeEventListenerWithOptions(
handleSelection,
{"passive": true, "capture": false},
{
"passive": true,
"capture": false,
},
htmlDoc,
);
HtmlDocument.removeSelectionChangeEventListenerUseCapture(
Expand All @@ -69,14 +90,21 @@ HtmlDocument.removeSelectionChangeEventListenerUseCapture(

Window.addSelectionChangeEventListenerWithOptions(
handleSelection,
{"passive": true, "once": true, "capture": false},
{
"passive": true,
"once": true,
"capture": false,
},
window,
);
Window.addSelectionChangeEventListenerUseCapture(handleSelection, window);
Window.removeSelectionChangeEventListener(handleSelection, window);
Window.removeSelectionChangeEventListenerWithOptions(
handleSelection,
{"passive": true, "capture": false},
{
"passive": true,
"capture": false,
},
window,
);
Window.removeSelectionChangeEventListenerUseCapture(handleSelection, window);
4 changes: 2 additions & 2 deletions server-reason-react.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bug-reports: "https://github.com/ml-in-barcelona/server-reason-react/issues"
depends: [
"dune" {>= "3.9"}
"ocaml" {>= "5.0.0"}
"reason" {= "3.10.0"}
"reason" {>= "3.11.0"}
"melange" {>= "3.0.0"}
"uucp" {>= "16.0.0"}
"ppxlib" {> "0.23.0"}
Expand All @@ -20,7 +20,7 @@ depends: [
"uri" {>= "4.2.0"}
"integers"
"odoc" {with-doc}
"ocamlformat" {= "0.26.1" & with-test}
"ocamlformat" {= "0.26.2" & with-test}
"ocaml-lsp-server" {with-dev-setup}
"dream" {with-dev-setup}
"melange-webapi" {with-dev-setup}
Expand Down

0 comments on commit 61e1f6a

Please sign in to comment.