From 3dd8737c6cd5024ba6fb946dbbf370dfeb852097 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 29 Oct 2026 10:34:55 +0100 Subject: Updated the code the latest js_of_ocaml --- viz.js/process/process.ml | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'viz.js/process/process.ml') diff --git a/viz.js/process/process.ml b/viz.js/process/process.ml index ef23b78..8d37788 100755 --- a/viz.js/process/process.ml +++ b/viz.js/process/process.ml @@ -1,29 +1,27 @@ -open Js_of_ocaml +module Js = Js_of_ocaml.Js class type viz = object - (* PNG output *) - method renderImageElement: Js.js_string Js.t -> (Dom_html.imageElement Js.t, unit) Promise.promise Js.meth (* SVG output *) - method renderSVGElement: Js.js_string Js.t -> (Dom_svg.svgElement Js.t, unit) Promise.promise Js.meth + method renderSVGElement : + Js.js_string Js.t + -> (Js_of_ocaml.Dom_svg.svgElement Js.t, unit) Promise.promise Js.meth - method renderString: Js.js_string Js.t -> (Js.js_string Js.t, unit) Promise.promise Js.meth + method renderString : + Js.js_string Js.t -> (Js.js_string Js.t, unit) Promise.promise Js.meth end type t = Js.js_string Js.t * Js.js_string Js.t -let do_action - : viz Js.t -> Js.js_string Js.t -> (unit, unit) Promise.promise - = fun v text -> - - if text##.length != 0 then ( - let gv = Formatter.convert text in - let promise = - (try v##renderString gv - with _ -> Promise.reject () - ) in - Promise.then_map - ~on_fulfilled:(fun svg -> Worker.post_message ((gv, svg):t)) - ~on_rejected:(fun _ -> ()) - promise - ) else - Promise.reject () +let do_action : viz Js.t -> Js.js_string Js.t -> (unit, unit) Promise.promise = + fun v text -> + if text##.length != 0 then + let gv = Formatter.convert text in + let promise = + try v##renderString gv with + | _ -> Promise.reject () + in + Promise.then_map + ~on_fulfilled:(fun svg -> Js_of_ocaml.Worker.post_message ((gv, svg) : t)) + ~on_rejected:(fun _ -> ()) + promise + else Promise.reject () -- cgit v1.2.3