Skip to main content

aspectly-bridge (Python / WebKitGTK)

PyPI

Type-safe, bidirectional bridge between native Python code and JavaScript running in a WebKitGTK web view (Linux desktop). Speaks the Aspectly protocol, so the same @aspectly/core web content runs unchanged across every host.

WebKitGTK uses the same JS mechanism as WKWebView (window.webkit.messageHandlers.aspectly), so the embedded web content auto-detects this host through the existing @aspectly/transports WebKit transport — no Flutter/Android-style extra transport needed.

Install

pip install aspectly-bridge

# For the WebKitGTK browser bridge (Linux):
#   system packages: gobject-introspection, gir1.2-webkit2-4.1 (or 4.0)
pip install "aspectly-bridge[webkitgtk]"

The core (BridgeHost) is pure Python with no dependencies. Only the WebKitGTKBrowserBridge needs PyGObject + WebKit2GTK (Linux).

Usage

from aspectly_bridge import BridgeHost
from aspectly_bridge.webkitgtk import WebKitGTKBrowserBridge

bridge = BridgeHost(WebKitGTKBrowserBridge(web_view))

# Register handlers JS can call (before initialize).
bridge.register_handler("ping", lambda params: "pong")
bridge.register_handler("add", lambda params: params["a"] + params["b"])

# Initialize (returns a Future; resolves when the handshake completes).
bridge.initialize().result()

# Call a JS method (returns a Future).
result = bridge.send("greet", {"name": "Python"}).result()
print(result["message"])

send and initialize return concurrent.futures.Future. In a GTK app, the result is delivered on the GLib main thread, so use future.add_done_callback or GLib.idle_add rather than blocking .result() on the UI thread.

API

BridgeHost(browser_bridge, logger=None, timeout_ms=100000)

register_handler(method, handler)     # handler(params) -> result
unregister_handler(method)
initialize(handlers=None) -> Future
send(method, params=None, timeout_ms=None) -> Future
process_message(message_json)

is_initialized        # bool
supported_methods     # list[str]  (JS-side methods)
registered_methods    # list[str]  (Python-side handlers)
on_initialized        # callable or None
dispose()

send / handlers surface BridgeException with error_type one of BridgeErrorType.{UNSUPPORTED_METHOD, METHOD_EXECUTION_TIMEOUT, REJECTED, BRIDGE_NOT_AVAILABLE}.

Testing

cd python
python -m pytest          # the pure-Python core (no GTK required)

See examples/webkitgtk for a runnable GTK app.

Other platforms

This is the Python / WebKitGTK host (PyPI aspectly-bridge, 2.1.0). The same Aspectly protocol ships for Web (@aspectly/web), React Native (@aspectly/react-native), React Native Web/Expo (@aspectly/react-native-web), .NET CefSharp/WebView2 (Aspectly.Bridge.CefSharp / Aspectly.Bridge.WebView2), iOS/macOS/visionOS (AspectlyBridge), Android (io.github.jeanisahakyan:aspectly-bridge), and Flutter (aspectly_bridge) — all at version 2.1.0. See the repository README for the full platform matrix.

License

MIT

Metadata

Release files for aspectly-bridge 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aspectly-bridge 2.2.0
File Size Uploaded Provenance Actions
aspectly_bridge-2.2.0.tar.gz 10.9 kB With provenance Details for aspectly_bridge-2.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aspectly-bridge 2.2.0
File Interpreter ABI Platform Actions
aspectly_bridge-2.2.0-py3-none-any.whl Python 3 none any Details for aspectly_bridge-2.2.0-py3-none-any.whl

Total release size: 21.0 kB

Release files / aspectly_bridge-2.2.0.tar.gz

Download URL aspectly_bridge-2.2.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1809f4272120e00b0a1c9c86e5f8f1a65691abde9e266478d062252580a686f7
BLAKE2b-256 checksum
How to use checksums
5c83476a51c545362b332f9b13e9f9f524e661b5ef77e2d92dbe97101dfd6195
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / aspectly_bridge-2.2.0-py3-none-any.whl

Download URL aspectly_bridge-2.2.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32a9ec98aeed0be81ef13565e50d085bf9afbeadde82dfaf4bc84b476db1be9c
BLAKE2b-256 checksum
How to use checksums
ce3a79ab1d6d24c4f55d7b4f9f4413feb4a6b85a4573ba85573f94baa05ebe4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Security for aspectly-bridge 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aspectly_bridge-2.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page