Repository navigation
Windows/webkitgtk front-end support: build jsaddle-terminal on Windows, expose the WebView2 HWND - #167
Merged
Conversation
The tunnel runner (Language.Javascript.JSaddle.Terminal) needs raw-mode stdin/termios, so it stays POSIX-only — but the framing (Protocol) and iframe JS (Bootstrap) are pure. Replace the blanket Windows buildable: False with a conditional that drops just the Terminal module and the unix dependency, so IDE-side consumers (leksah's Windows front end) can link the library.
webView2Hwnd (C: wv2GetHwnd) returns the Win32 HWND of the window hosting the WebView2, so embedding applications can do native window integration (menu bar, dialogs) from the run' callback.
The warp fallback (jsaddle-warp, warp, websockets, stm, aeson, text) is only used by the POSIX-only Terminal module; keeping jsaddle-warp in the Windows dependency set made solving impossible for consumers whose plan needs aeson >=2.3 (jsaddle-warp caps aeson <2.3).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds small integration-oriented features to support embedding jsaddle in native front ends: it makes jsaddle-terminal’s pure library modules build on Windows, and exposes the host window HWND from jsaddle-webview2 for Win32-native integration.
Changes:
jsaddle-terminal: expose onlyTerminal.Protocol+Terminal.Bootstrapon Windows while gating the POSIX-only runner module (and its deps) behindif !os(windows).jsaddle-webview2: add a newwebView2HwndHaskell API backed by a C shim functionwv2GetHwndreturning the host window handle.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| jsaddle-webview2/src/Language/Javascript/JSaddle/WebView2.hs | Exports webView2Hwnd :: WebView2 -> IO (Ptr ()) via FFI to surface the hosting window’s HWND. |
| jsaddle-webview2/cbits/WebView2Shim.c | Implements wv2GetHwnd returning app->hwnd for the Haskell binding. |
| jsaddle-terminal/jsaddle-terminal.cabal | Makes the library buildable on Windows by exposing only pure modules and conditionally including the POSIX runner + deps on non-Windows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three small changes needed to embed jsaddle in native front ends (a
GTK4/WebKitGTK 6.0 app on Linux and a WebView2 app on Windows). No behaviour
changes on existing platforms.
jsaddle-terminal: build the library on Windows (pure modules only)
The whole package was
buildable: Falseon Windows because the tunnel runner(
Language.Javascript.JSaddle.Terminal) needs raw-mode stdin/termios, which isPOSIX-only. But the framing (
.Terminal.Protocol) and the iframe bootstrap JS(
.Terminal.Bootstrap) are pure and build everywhere.IDE-side consumers only import those two modules, so the library now exposes
them unconditionally and gates just the runner module — plus its deps — behind
if !os(windows). This lets an embedder link jsaddle-terminal on Windows.The runner's deps (
aeson,jsaddle-warp,stm,text,unix,warp,websockets) move under the same guard. This also dropsjsaddle-warpfromthe Windows build, which matters because
jsaddle-warpcapsaeson < 2.3andwould otherwise constrain the whole plan.
jsaddle-webview2: expose the host window's HWND
Adds
wv2GetHwnd(C) /webView2Hwnd :: WebView2 -> IO (Ptr ())(Haskell) sothe embedding application can reach the Win32
HWNDof the window hosting theWebView2 and do native window integration — install a menu bar, run file
dialogs, etc. Only meaningful once the
run'callback has been entered (theHWND exists by then).
Testing
on POSIX.
webView2Hwndreturns the shim's HWND at runtime.leksah-webkitgtkandleksah-webview2front ends (Linux native + Windows cross), which build via haskell.nix.