From 7c48ebfdb05820d73fb7c64ae35b180b579fb667 Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Thu, 21 Aug 2025 14:14:51 +0200 Subject: [PATCH 1/4] Compatibility with js_of_ocaml >= 6 --- dune-project | 4 ++-- js_of_ocaml-eio.opam | 4 ++-- .../examples/boulderdash/boulderdash.ml | 4 ++-- lib_js_of_ocaml_eio/js_events.ml | 2 +- lib_js_of_ocaml_eio/xmlHttpRequest.ml | 15 +++++++-------- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/dune-project b/dune-project index 1a86c4b..48d12cf 100644 --- a/dune-project +++ b/dune-project @@ -26,6 +26,6 @@ (description "An Eio counterpart to package js_of_ocaml-lwt.") (depends (eio_js_backend (= :version)) - (js_of_ocaml-ppx (>= "5.0.1")) - (js_of_ocaml (>= 5.0.1)))) + (js_of_ocaml-ppx (>= "6.0.0")) + (js_of_ocaml (>= 6.0.0)))) (using mdx 0.2) diff --git a/js_of_ocaml-eio.opam b/js_of_ocaml-eio.opam index 219fd96..621c896 100644 --- a/js_of_ocaml-eio.opam +++ b/js_of_ocaml-eio.opam @@ -11,8 +11,8 @@ bug-reports: "https://github.com/ocaml-multicore/eio_js/issues" depends: [ "dune" {>= "3.9"} "eio_js_backend" {= version} - "js_of_ocaml-ppx" {>= "5.0.1"} - "js_of_ocaml" {>= "5.0.1"} + "js_of_ocaml-ppx" {>= "6.0.0"} + "js_of_ocaml" {>= "6.0.0"} "odoc" {with-doc} ] build: [ diff --git a/lib_js_of_ocaml_eio/examples/boulderdash/boulderdash.ml b/lib_js_of_ocaml_eio/examples/boulderdash/boulderdash.ml index 1eadc1c..065b95b 100644 --- a/lib_js_of_ocaml_eio/examples/boulderdash/boulderdash.ml +++ b/lib_js_of_ocaml_eio/examples/boulderdash/boulderdash.ml @@ -421,11 +421,11 @@ let start _ = let t0 = Sys.time () in let rec fade () = let t = Sys.time () in - if t -. t0 >= 1. then table##.style##.opacity := Js.def (js "1") + if t -. t0 >= 1. then table##.style##.opacity := js "1" else ( Eio_js.sleep 0.05; table##.style##.opacity - := Js.def (js (Printf.sprintf "%g" (t -. t0))); + := js (Printf.sprintf "%g" (t -. t0)); fade ()) in fade (); diff --git a/lib_js_of_ocaml_eio/js_events.ml b/lib_js_of_ocaml_eio/js_events.ml index 7f3e112..07db3ad 100644 --- a/lib_js_of_ocaml_eio/js_events.ml +++ b/lib_js_of_ocaml_eio/js_events.ml @@ -605,7 +605,7 @@ let request_animation_frame () = Eio_js_backend.await ~setup:(fun ~resolve ~reject:_ -> Dom_html.window##requestAnimationFrame - (Js.wrap_callback (fun (_ : float) -> resolve ()))) + (Js.wrap_callback (fun _ -> resolve ()))) ~cancel:(fun id -> Dom_html.window##cancelAnimationFrame id) let onload () = make_event Dom_html.Event.load Dom_html.window diff --git a/lib_js_of_ocaml_eio/xmlHttpRequest.ml b/lib_js_of_ocaml_eio/xmlHttpRequest.ml index 79cca21..7f22ebb 100644 --- a/lib_js_of_ocaml_eio/xmlHttpRequest.ml +++ b/lib_js_of_ocaml_eio/xmlHttpRequest.ml @@ -247,14 +247,13 @@ let perform_raw ?(headers = []) ?content_type ?(get_args = []) progress e##.loaded e##.total; Js._true) | None -> ()); - Optdef.iter req##.upload (fun upload -> - match upload_progress with - | Some upload_progress -> - upload##.onprogress := - Dom.handler (fun e -> - upload_progress e##.loaded e##.total; - Js._true) - | None -> ()); + (match upload_progress with + | Some upload_progress -> + req##.upload##.onprogress + := Dom.handler (fun e -> + upload_progress e##.loaded e##.total; + Js._true) + | None -> ()); (match contents with | None -> req##send Js.null | Some (`Form_contents (`Fields l)) -> From 43b157cdc681e3e4bc40c719e3df7d0492f6eb92 Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Thu, 21 Aug 2025 13:39:15 +0200 Subject: [PATCH 2/4] Firebug now called Console --- lib_js_of_ocaml_eio/js_events.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_js_of_ocaml_eio/js_events.ml b/lib_js_of_ocaml_eio/js_events.ml index 07db3ad..87704c6 100644 --- a/lib_js_of_ocaml_eio/js_events.ml +++ b/lib_js_of_ocaml_eio/js_events.ml @@ -50,7 +50,7 @@ let make_event event_kind ?use_capture ?passive target = type cancel = { cancel : unit -> unit } let with_error_log f x = - try f x with e -> Firebug.console##log (Js.string (Printexc.to_string e)) + try f x with e -> Console.console##log (Js.string (Printexc.to_string e)) let seq_loop ~sw evh ?(cancel_handler = false) ?use_capture ?passive target handler = @@ -327,7 +327,7 @@ let mousewheel ?use_capture ?passive target = ?capture:(opt_map Js.bool use_capture) ?passive:(opt_map Js.bool passive) target (fun (ev : #Dom_html.event Js.t) ~dx ~dy -> - Firebug.console##log ev; + Console.console##log ev; cancel (); resolve (ev, (dx, dy)); Js.bool true) From 156bf4422889959e2b152107515db8ac8aae513a Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Thu, 21 Aug 2025 14:15:53 +0200 Subject: [PATCH 3/4] Compatibility with IE has been dropped by js_of_ocaml --- lib_js_of_ocaml_eio/xmlHttpRequest.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_js_of_ocaml_eio/xmlHttpRequest.ml b/lib_js_of_ocaml_eio/xmlHttpRequest.ml index 7f22ebb..8d83aea 100644 --- a/lib_js_of_ocaml_eio/xmlHttpRequest.ml +++ b/lib_js_of_ocaml_eio/xmlHttpRequest.ml @@ -222,9 +222,8 @@ let perform_raw ?(headers = []) ?content_type ?(get_args = []) (* IE doesn't have the same semantics for HEADERS_RECEIVED. so we wait til LOADING to check headers. See: http://msdn.microsoft.com/en-us/library/ms534361(v=vs.85).aspx *) - | HEADERS_RECEIVED when not Dom_html.onIE -> + | HEADERS_RECEIVED -> ignore (do_check_headers ()) - | LOADING when Dom_html.onIE -> ignore (do_check_headers ()) | DONE -> (* If we didn't catch a previous event, we check the header. *) if do_check_headers () then From 377b0bbd91670e89b7e4e14aed5098c53ffd8872 Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Thu, 21 Aug 2025 14:20:48 +0200 Subject: [PATCH 4/4] Use ocamlformat 27 --- .ocamlformat | 2 +- lib_eio_js_backend/eio_js_backend.ml | 7 +++++-- lib_js_of_ocaml_eio/js_events.ml | 2 +- lib_js_of_ocaml_eio/xmlHttpRequest.ml | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index c870de9..e80baea 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1 +1 @@ -version=0.26.1 +version=0.27.0 diff --git a/lib_eio_js_backend/eio_js_backend.ml b/lib_eio_js_backend/eio_js_backend.ml index 32f0b76..358bbcb 100644 --- a/lib_eio_js_backend/eio_js_backend.ml +++ b/lib_eio_js_backend/eio_js_backend.ml @@ -133,8 +133,11 @@ let start main = !uncaught_exception_handler ex bt; Scheduler.next ()); effc = - (fun (type a) (e : a Effect.t) : - ((a, suspend) Effect.Deep.continuation -> suspend) option -> + (fun (type a) + (e : a Effect.t) + : + ((a, suspend) Effect.Deep.continuation -> suspend) option + -> match e with | Eio.Private.Effects.Suspend f -> Some diff --git a/lib_js_of_ocaml_eio/js_events.ml b/lib_js_of_ocaml_eio/js_events.ml index 87704c6..c5cd4b2 100644 --- a/lib_js_of_ocaml_eio/js_events.ml +++ b/lib_js_of_ocaml_eio/js_events.ml @@ -331,7 +331,7 @@ let mousewheel ?use_capture ?passive target = cancel (); resolve (ev, (dx, dy)); Js.bool true) - (* true because we do not want to prevent default -> + (* true because we do not want to prevent default -> the user can use the preventDefault function above. *)); cancel) diff --git a/lib_js_of_ocaml_eio/xmlHttpRequest.ml b/lib_js_of_ocaml_eio/xmlHttpRequest.ml index 8d83aea..57aa074 100644 --- a/lib_js_of_ocaml_eio/xmlHttpRequest.ml +++ b/lib_js_of_ocaml_eio/xmlHttpRequest.ml @@ -222,8 +222,7 @@ let perform_raw ?(headers = []) ?content_type ?(get_args = []) (* IE doesn't have the same semantics for HEADERS_RECEIVED. so we wait til LOADING to check headers. See: http://msdn.microsoft.com/en-us/library/ms534361(v=vs.85).aspx *) - | HEADERS_RECEIVED -> - ignore (do_check_headers ()) + | HEADERS_RECEIVED -> ignore (do_check_headers ()) | DONE -> (* If we didn't catch a previous event, we check the header. *) if do_check_headers () then