feat: add optional pgn_to_tex_js entry point

This commit is contained in:
2026-10-23 16:38:24 +02:00
committed by owenrees
parent 135491e915
commit 786bad8956
6 changed files with 89 additions and 10 deletions
+3 -4
View File
@@ -1,8 +1,7 @@
(executable
(name main)
(name pgn_to_tex_js)
(modes js)
(optional)
(libraries pgn_to_tex js_of_ocaml yojson)
(preprocess
(pps js_of_ocaml-ppx))
(enabled_if
(= %{env:CI=false} "false")))
(pps js_of_ocaml-ppx)))
+6 -2
View File
@@ -15,5 +15,9 @@ let convert_js pgn_js diagram_json_js display_clock =
let result = Pgn_to_tex.to_tex ~diagram_data ~clock:display_clock pgn in
Js.string result
(* Exporting the module to the global JavaScript scope *)
let () = Js.export "to_tex" (Js.wrap_callback convert_js)
(* Exporting the module to the global JavaScript scope, including when the
artifact is loaded as a CommonJS module in Node. *)
let () =
let callback = Js.wrap_callback convert_js in
Js.export "to_tex" callback;
Js.Unsafe.set Js.Unsafe.global "to_tex" callback