From 61e1f6aa0180a38c30c82ab2f85d7c63ed378d6c Mon Sep 17 00:00:00 2001 From: Pedro Lisboa <35539594+pedrobslisboa@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:53:39 +0100 Subject: [PATCH] Update reason dependency (#181) * chore: update reason to 3.11.0 or higher * chore: improve .ocamlformat * chore: format files --- .ocamlformat | 2 +- demo/universal/native/lib/Align.re | 12 ++++- demo/universal/native/lib/App.re | 5 ++- demo/universal/native/lib/MelRaw.re | 14 +++--- demo/universal/native/lib/Theme.re | 15 ++++++- dune-project | 4 +- packages/promise/js/promise.re | 6 +-- packages/promise/native/promise.re | 26 +++++++++-- .../cram/external.t/run.t | 5 ++- .../tests/Dom/Webapi__Dom__Element__test.re | 8 +++- .../Dom/Webapi__Dom__EventTarget__test.re | 24 +++++++--- .../Webapi__Dom__GlobalEventHandlers__test.re | 44 +++++++++++++++---- server-reason-react.opam | 4 +- 13 files changed, 125 insertions(+), 44 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index 37525ae36..afed6176e 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1 +1 @@ -profile = default +profile=default diff --git a/demo/universal/native/lib/Align.re b/demo/universal/native/lib/Align.re index 4c7da4a99..6397067f1 100644 --- a/demo/universal/native/lib/Align.re +++ b/demo/universal/native/lib/Align.re @@ -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) => { diff --git a/demo/universal/native/lib/App.re b/demo/universal/native/lib/App.re index 79963fbb2..5b9897481 100644 --- a/demo/universal/native/lib/App.re +++ b/demo/universal/native/lib/App.re @@ -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", + }, |];
[%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); @@ -40,7 +39,6 @@ let%browser_only initWebsocket = () => [%mel.raw console.debug("Live reload: WebSocket error:", event); }; } - |} -]; + |}; let x = 22; diff --git a/demo/universal/native/lib/Theme.re b/demo/universal/native/lib/Theme.re index bc772ea80..64b94a5e6 100644 --- a/demo/universal/native/lib/Theme.re +++ b/demo/universal/native/lib/Theme.re @@ -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 => { diff --git a/dune-project b/dune-project index 8aa5d6673..197bad8d4 100644 --- a/dune-project +++ b/dune-project @@ -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 @@ -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) diff --git a/packages/promise/js/promise.re b/packages/promise/js/promise.re index 6d6296004..346bee0e3 100644 --- a/packages/promise/js/promise.re +++ b/packages/promise/js/promise.re @@ -14,8 +14,7 @@ let onUnhandledException = Js.Console.error(exn); }); -[%%mel.raw - {| +{%%mel.raw | function PromiseBox(p) { this.nested = p; }; @@ -72,8 +71,7 @@ function catch_(promise, callback) { return promise.catch(safeCallback); }; -|} -]; +|}; module Js_ = { type t('a, 'e) = rejectable('a, 'e); diff --git a/packages/promise/native/promise.re b/packages/promise/native/promise.re index 7f87fd188..dc6f2dbc5 100644 --- a/packages/promise/native/promise.re +++ b/packages/promise/native/promise.re @@ -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); @@ -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; diff --git a/packages/server-reason-react-ppx/cram/external.t/run.t b/packages/server-reason-react-ppx/cram/external.t/run.t index 859a61303..468e4d215 100644 --- a/packages/server-reason-react-ppx/cram/external.t/run.t +++ b/packages/server-reason-react-ppx/cram/external.t/run.t @@ -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" + ]; }; diff --git a/packages/webapi/tests/Dom/Webapi__Dom__Element__test.re b/packages/webapi/tests/Dom/Webapi__Dom__Element__test.re index 8e0e9bdff..e79481926 100644 --- a/packages/webapi/tests/Dom/Webapi__Dom__Element__test.re +++ b/packages/webapi/tests/Dom/Webapi__Dom__Element__test.re @@ -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); diff --git a/packages/webapi/tests/Dom/Webapi__Dom__EventTarget__test.re b/packages/webapi/tests/Dom/Webapi__Dom__EventTarget__test.re index 6972eab97..45bdd31a5 100644 --- a/packages/webapi/tests/Dom/Webapi__Dom__EventTarget__test.re +++ b/packages/webapi/tests/Dom/Webapi__Dom__EventTarget__test.re @@ -10,7 +10,11 @@ addEventListener("click", handleClick, target); addEventListenerWithOptions( "click", handleClick, - {"passive": true, "once": true, "capture": false}, + { + "passive": true, + "once": true, + "capture": false, + }, target, ); addEventListenerUseCapture("click", handleClick, target); @@ -18,7 +22,10 @@ removeEventListener("click", handleClick, target); removeEventListenerWithOptions( "click", handleClick, - {"passive": true, "capture": false}, + { + "passive": true, + "capture": false, + }, target, ); removeEventListenerUseCapture("click", handleClick, target); @@ -26,9 +33,12 @@ 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); diff --git a/packages/webapi/tests/Dom/Webapi__Dom__GlobalEventHandlers__test.re b/packages/webapi/tests/Dom/Webapi__Dom__GlobalEventHandlers__test.re index 75bdbe806..8bcc73d32 100644 --- a/packages/webapi/tests/Dom/Webapi__Dom__GlobalEventHandlers__test.re +++ b/packages/webapi/tests/Dom/Webapi__Dom__GlobalEventHandlers__test.re @@ -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); @@ -26,7 +33,11 @@ let htmlElm = HtmlElement.addSelectionChangeEventListenerWithOptions( handleSelection, - {"passive": true, "once": true, "capture": false}, + { + "passive": true, + "once": true, + "capture": false, + }, htmlElm, ); HtmlElement.addSelectionChangeEventListenerUseCapture( @@ -36,7 +47,10 @@ HtmlElement.addSelectionChangeEventListenerUseCapture( HtmlElement.removeSelectionChangeEventListener(handleSelection, htmlElm); HtmlElement.removeSelectionChangeEventListenerWithOptions( handleSelection, - {"passive": true, "capture": false}, + { + "passive": true, + "capture": false, + }, htmlElm, ); HtmlElement.removeSelectionChangeEventListenerUseCapture( @@ -49,7 +63,11 @@ let htmlDoc = HtmlDocument.addSelectionChangeEventListenerWithOptions( handleSelection, - {"passive": true, "once": true, "capture": false}, + { + "passive": true, + "once": true, + "capture": false, + }, htmlDoc, ); HtmlDocument.addSelectionChangeEventListenerUseCapture( @@ -59,7 +77,10 @@ HtmlDocument.addSelectionChangeEventListenerUseCapture( HtmlDocument.removeSelectionChangeEventListener(handleSelection, htmlDoc); HtmlDocument.removeSelectionChangeEventListenerWithOptions( handleSelection, - {"passive": true, "capture": false}, + { + "passive": true, + "capture": false, + }, htmlDoc, ); HtmlDocument.removeSelectionChangeEventListenerUseCapture( @@ -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); diff --git a/server-reason-react.opam b/server-reason-react.opam index e16796a9a..26e51b5ec 100644 --- a/server-reason-react.opam +++ b/server-reason-react.opam @@ -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"} @@ -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}