package js_of_ocaml
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=a991ce25175a5a13240c8bf64354b8f35e0a8d7223b90bef01ba32bc6f929cf4
sha512=ce476986cb2c78990f29b1d7a01bb173a0d30ad0e0a80ba7bde9aa8365952ed01eda4935d92a323b982b0c1c897b20ef01eabe75fe80e4da858f73f6a2d25232
doc/js_of_ocaml.devtools/Js_of_ocaml_devtools/index.html
Module Js_of_ocaml_devtoolsSource
Browser developer tools integration (library js_of_ocaml.devtools).
Chrome DevTools (and other Chromium-based consoles) let a page install custom formatters in globalThis.devtoolsFormatters to control how objects are displayed in the console and in the debugger.
When the compiler is built with Introcaml, OCaml values carry a descriptor of their type at runtime and can be printed in OCaml syntax through Introspect. register_formatters installs a formatter that uses it, so that a value logged with console.log or inspected in the debugger shows as, e.g., Circle ({x = 0; name = "o"}, 1) instead of Array(3), and expands to its fields (with their names for records and constructors) rather than to the array of its raw representation.
Custom formatters must be enabled in the DevTools settings (Settings > Preferences > Console > Enable custom formatters).
Install the formatter in globalThis.devtoolsFormatters, creating the array if needed. Calling it more than once installs it once.
This is a no-op when the compiler has no introspection support or when the program does not run under Js_of_ocaml (native code, Wasm_of_ocaml). When the program was compiled with --disable introspection, the formatter is installed but no value carries a descriptor, so nothing is reformatted.