XlibloaderInterface for loading OCaml library files and Merlin artifacts into the browser's virtual filesystem. This module is the central point for managing the files required for both the OCaml toplevel and the Merlin code analysis engine.
It supports a hybrid loading strategy:
Performs the initial file setup for the kernel environment.
This function orchestrates the loading of all files necessary for the OCaml standard library to function correctly within the toplevel and Merlin. It first writes any statically-linked files (like `stdlib.cmi`) to the virtual filesystem, then asynchronously fetches all other standard library artifacts (`.cmt`, `.cmti`, and other `.cmi` files) from the server.
This function must be called and awaited successfully *before* the OCaml toplevel or Merlin engine are initialized to prevent `Env.Error` exceptions.
val load_on_demand :
base_url:string ->
name:string ->
(Protocol.output, Protocol.output) Stdlib.result Lwt.tDynamically loads a pre-compiled third-party OCaml library on-demand.
This function is triggered by the toplevel when it encounters a `#require "lib_name"` directive. It looks up the library in a pre-generated manifest (`external_libs.ml`), then fetches the corresponding JavaScript bundle and all its Merlin artifacts (`.cmi`, `.cmt`, `.cmti`).
The JavaScript bundle is executed to make the library's modules available, and the artifacts are written to the virtual filesystem to enable code completion and documentation for the new library.