Module Js_top_worker_message.MessageSource
Message protocol for worker communication.
This module defines a simple JSON-based message protocol for communication between the client and the OCaml toplevel worker.
Types
Source
type location = {loc_start : Js_top_worker_message.Message.position;loc_end : Js_top_worker_message.Message.position;
}Source
type completions = {from : int;to_ : int;entries : Js_top_worker_message.Message.compl_entry list;
}Source
type error = {kind : string;loc : Js_top_worker_message.Message.location;main : string;sub : string list;source : string;
}Source
type type_info = {loc : Js_top_worker_message.Message.location;type_str : string;tail : string;
}Client -> Worker messages
Source
type client_msg = | Init of Js_top_worker_message.Message.init_config| Eval of {}| Complete of {}| TypeAt of {}| Errors of {}| CreateEnv of {}| DestroyEnv of {}| WidgetEvent of {}
Worker -> Client messages
Source
type worker_msg = | Ready| InitError of {}| Output of {cell_id : int;stdout : string;stderr : string;caml_ppf : string;mime_vals : Js_top_worker_message.Message.mime_val list;
}| OutputAt of {cell_id : int;loc : int;caml_ppf : string;mime_vals : Js_top_worker_message.Message.mime_val list;
}| Completions of {cell_id : int;completions : Js_top_worker_message.Message.completions;
}| Types of {cell_id : int;types : Js_top_worker_message.Message.type_info list;
}| ErrorList of {cell_id : int;errors : Js_top_worker_message.Message.error list;
}| EvalError of {}| EnvCreated of {}| EnvDestroyed of {}| WidgetUpdate of {widget_id : string;view : Js_top_worker_message.Widget_view.node;
}| WidgetClear of {}| WidgetConfig of {}| WidgetCommand of {}| WidgetRegisterAdapter of {}
JSON helpers
Use plain JSON.stringify/JSON.parse instead of jsoo's Json.output/Json.unsafe_input. The jsoo versions use bytestring revivers that are incompatible across different jsoo versions (e.g., 6.0.1+ox vs 6.2.0). Since all values in our message objects are already proper JS values (created via Js.string, Js.Unsafe.inject, etc.), plain JSON works correctly and is cross-version compatible.