package brr
-
brr
-
-
brr_ocaml_poke
-
brr_ocaml_poke_ui
-
brr_poke
-
brr_poked
Library
Module
Module type
Parameter
Class
Class type
brr 0.0.6
Brr v0.0.6
Brr is a toolkit for programming browsers in OCaml with the js_of_ocaml
compiler. It provides:
- Interfaces to a selection of browser APIs.
- An OCaml console developer tool for live interaction with programs running in web pages.
- A JavaScript FFI for idiomatic OCaml programming.
Manuals
These manuals are available:
- The Web page howto explains how to compile and integrate your OCaml program in a web page.
- The OCaml console manual has intructions to setup the developer tool WebExtension to peek into your programs at runtime.
- The FFI manual explains how OCaml and JavaScript values are represented by
js_of_ocaml
and Brr. Recommended reading. - The FFI cookbook has off-the-shelf design answers for common JavaScript binding scenarios.
Also the test directory of Brr's repository has a few examples that use the APIs.
Library brr
This library has the JavaScript FFI and the interfaces to the supported browser APIs.
Jstr
JavaScript stringsJv
JavaScript values.Fut
Future values.Brr
Browser APIs.Brr_canvas
Canvas APIs.Brr_io
Clipboard, Form, Fetch, Geolocation, Media and Storage APIs.Brr_webaudio
Web Audio API.Brr_webcrypto
Web Crypto API.Brr_webgpu
WebGPU API.Brr_webmidi
Web MIDI API.Brr_webworkers
Web and Service Worker APIs.
Libraries brr.poke[d]
and brr.ocaml_poke[_ui]
The brr.poke
library provides a function to define a poke object for your program so that the OCaml console can interact with it. Use brr.poked
to poke your program by side-effect without modifying its source. In both cases you need compile your JavaScript appropriately.
The brr.ocaml_poke
library provides support to find and access the ocaml_poke
object provided by your program. The brr.ocaml_poke_ui
library provides an HTML interface to the poke object as an interactive toplevel (REPL). These APIs are used by the OCaml console.
Brr_ocaml_poke
ocaml_poke
object for OCaml console.Brr_ocaml_poke_ui
Interactive toplevel HTML interface for poke objects.
Supported browser APIs
The following JavaScript and browser functionality is supported:
- General support for JavaScript values is in
Jv
. - JavaScript
String
s are inJstr
. - Left-pad support is in
Jstr.pad_start
. - JavaScript
Promise
s are inFut
to safely type them.Brr.Abort
has support for aborting them. - JavaScript
ArrayBuffer
s andTypedArray
s are inBrr.Tarray
. - Data encoding are in
Brr.Base64
,Brr.Json
. - Global objects and functions are in
Brr.G
. - A remixed HTML DOM API is provided by
Brr.Ev
,Brr.At
andBrr.El
. - Some browser functionality is in
Brr.Console
,Brr.Window
,Brr.Navigator
. - The Blob API is in
Brr.Blob
- The Broadcast and Channel Messsaging API is in
Brr_io.Message
. - The Canvas 2D API is in
Brr_canvas.C2d
. - The Cache API is in
Brr_io.Fetch.Cache
. - The Clipboard API is in
Brr_io.Clipboard
. - The File API is in
Brr.File
. - The Fetch API is in
Brr_io.Fetch
. - The Form element and Form Data API is in
Brr_io.Form
. - The Geolocation API is in
Brr_io.Geolocation
. - The History API is in
Brr.Window.History
. - The Media capture, media streams and media element APIs are in
Brr_io.Media
. - The Notification API is in
Brr_io.Notification
. - The Performance API is in
Brr.Performance
. - The Service Worker API is in
Brr_webworkers.Service_worker
. - The URL API is in
Brr.Uri
. - The Web Audio API is in
Brr_webaudio
. - The Web Crypto API is in
Brr_webcrypto
. - The WebGL2 API is in
Brr_canvas.Gl
. - The WebGPU API is in
Brr_webgpu.Gpu
. - The Web MIDI API is in
Brr_webmidi
. - The Web Sockets API is in
Brr_io.Websocket
. - The Web Storage API is in
Brr_io.Storage
. - The Web Workers API is in
Brr_webworkers.Worker
.
Finally note that:
- Brr is incomplete. Exhaustiveness is a non-goal.
- Brr tracks long-term, universal and forward-looking browser changes.
- Brr does not provide one-to-one bindings to JavaScript APIs. Some of them may be remixed, tweaked and functionality may be deliberately left out.
- If you would like to add something, first get in touch on the issue tracker.