···7070 include Brr_webworkers.Worker
71717272 let post t action =
7373- let bytes = Marshal.to_bytes action [] in
7373+ let bytes = Marshal.to_string action []
7474+ |> Js_of_ocaml.Js.bytestring in
7475 post t bytes
7576end
7677···8081 let worker = make_worker @@ Webworker.create @@ Jstr.of_string url in
8182 let on_message m =
8283 let m = Brr.Ev.as_type m in
8383- let data_marshaled : bytes = Brr_io.Message.Ev.data m in
8484- let data : Protocol.answer = Marshal.from_bytes data_marshaled 0 in
8484+ let data_marshaled = Brr_io.Message.Ev.data m |> Js_of_ocaml.Js.to_bytestring in
8585+ let data : Protocol.answer = Marshal.from_string data_marshaled 0 in
8586 on_message worker data
8687 in
8788 let _listen =
+13-9
src/worker/worker.ml
···11open Merlin_utils
22open Std
33+open Js_of_ocaml
34open Merlin_kernel
45module Location = Ocaml_parsing.Location
5667let stdlib_path = "/static/cmis"
7889let sync_get url =
99- let open Js_of_ocaml in
1010 let x = XmlHttpRequest.create () in
1111 x##.responseType := Js.string "arraybuffer";
1212 x##_open (Js.string "GET") (Js.string url) Js._false;
···1616 Js.Opt.case
1717 (File.CoerceTo.arrayBuffer x##.response)
1818 (fun () ->
1919- Js_of_ocaml.Console.console##log (Js.string "Failed to receive file");
1919+ Console.console##log (Js.string "Failed to receive file");
2020 None)
2121 (fun b -> Some (Typed_array.String.of_arrayBuffer b))
2222 | _ -> None
···4646 match fetch (filename_of_module name) with
4747 | Some content ->
4848 let name = Filename.(concat stdlib_path filename) in
4949- Js_of_ocaml.Sys_js.create_file ~name ~content
4949+ Sys_js.create_file ~name ~content
5050 | None -> ()) dcs.dcs_toplevel_modules;
51515252 let new_load ~allow_hidden ~unit_name =
···6262 then begin
6363 match fetch filename with
6464 | Some x ->
6565- Js_of_ocaml.Sys_js.create_file ~name:fs_name ~content:x;
6565+ Sys_js.create_file ~name:fs_name ~content:x;
6666 (* At this point we need to tell merlin that the dir contents
6767 have changed *)
6868 reset_dirs ()
···7878 List.iter static_cmis ~f:(fun { Protocol.sc_name; sc_content } ->
7979 let filename = Printf.sprintf "%s.cmi" (String.uncapitalize_ascii sc_name) in
8080 let name = Filename.(concat stdlib_path filename) in
8181- Js_of_ocaml.Sys_js.create_file ~name ~content:sc_content);
8181+ Sys_js.create_file ~name ~content:sc_content);
8282 Option.iter ~f:add_dynamic_cmis dynamic_cmis;
8383 Protocol.Added_cmis
8484···252252 add_cmis cmis
253253254254let run () =
255255- Js_of_ocaml.Worker.set_onmessage @@ fun marshaled_message ->
256256- let action : Protocol.action = Marshal.from_bytes marshaled_message 0 in
255255+ Console.console##log (Js.string "Worker running");
256256+ Worker.set_onmessage @@ fun marshaled_message ->
257257+ Console.console##log (Js.string "Received message");
258258+ let action : Protocol.action =
259259+ let str = Js.to_bytestring marshaled_message in
260260+ Marshal.from_string str 0 in
257261 let res = on_message action in
258258- let res = Marshal.to_bytes res [] in
259259- Js_of_ocaml.Worker.post_message res
262262+ let res = Marshal.to_string res [] |> Js.bytestring in
263263+ Worker.post_message res