package owebview
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page
OCaml bindings for the webview library
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.1.0.tar.gz
md5=96958382fcfef04cc489a87b392abd65
sha512=0494c253643890138099fb14023476d4fef95299449c118301461efa0d2e316bf37a326a76bcf8d29512cdb621c144d06deb76ac5e22adeab76f9fae8a443d24
doc/index.html
Owebview
A thin OCaml binding to webview: open a native window backed by the operating system's web engine, load HTML/CSS/JS, and bridge JavaScript with OCaml — no Electron, no bundler.
Quickstart
A whole application is about ten lines:
let () =
let w = Webview.create () in
Webview.set_title w "My first owebview app";
Webview.set_size w ~width:480 ~height:320 Webview.Hint_none;
Webview.set_html w "<h1>Hello from OCaml</h1>";
Webview.run w;
Webview.destroy wCall OCaml from the page and answer the JavaScript promise:
Webview.bind w "add" (fun id req ->
let result =
match Scanf.sscanf_opt req "[%d,%d]" (fun a b -> a + b) with
| Some n -> string_of_int n
| None -> "null"
in
Webview.return w id ~error:false ~result)API
The whole binding is the Webview module. A tour of it:
- Lifecycle:
Webview.create,Webview.run,Webview.terminate,Webview.destroy - Content:
Webview.navigate,Webview.set_html,Webview.eval - JavaScript bridge:
Webview.bind,Webview.unbind,Webview.return - Threading:
Webview.dispatch - Native handles & icon:
Webview.get_native_handle,Webview.set_app_icon - Locating on-disk assets:
Webview.Utils.web_dir
Native dependencies
webview uses the system web engine, so its native libraries are needed:
- macOS: WebKit / Cocoa, provided by the system.
- Linux:
gtk+-3.0andwebkit2gtk-4.1(-devpackages). - Windows: the WebView2 runtime (ships with Windows 10/11).
The platform-specific compile and link flags are detected automatically at build time, so there is nothing to tweak by hand.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page