Skip to main content

host_extensions/
lib.rs

1//! host-extensions — extension framework for the Polkadot app host bridge.
2//!
3//! Extensions live under `window.host.ext.<namespace>` in the SPA WebView.
4//! First-party extensions reuse the core `hostBridge` channel and
5//! `__hostCall` / `__hostResolve` / `__hostPush` plumbing — they only
6//! contribute a JS injection script that populates `window.host.ext.*`.
7//!
8//! ## Implementing an extension
9//!
10//! 1. Implement [`HostExtension`] — provide a namespace, a channel name, a JS
11//!    injection script, and a message handler.
12//! 2. Register the extension with an [`ExtensionRegistry`].
13//! 3. Call [`ExtensionRegistry::combined_inject_script`] and inject the result
14//!    after `HOST_API_BRIDGE_SCRIPT`.
15//!
16//! See the [extensions guide](../docs/extensions.md) for the full lifecycle,
17//! the JS contract, and the graduation path from `ext.*` to core.
18
19pub mod events;
20pub mod executor_contract;
21pub mod first_party;
22pub mod manifest;
23pub mod protocol;
24pub mod registry;
25pub mod trait_def;
26
27pub use first_party::data::DataExtension;
28pub use first_party::files::FilesExtension;
29pub use first_party::media::MediaExtension;
30pub use first_party::mesh::MeshExtension;
31pub use first_party::mesh_runtime::{
32    current_time_ms,
33    generate_session_nonce,
34    private_object_result,
35    InMemoryMeshRuntime,
36    MeshPrivateControlWireMessage,
37    MeshPrivateReceiptWireMessage,
38    MeshPrivateWireQuery,
39    MeshRuntime,
40    MeshWireQuery,
41    MeshWireReply,
42    // Wire types and channel constants
43    StoredMeshObject,
44    StoredPrivateMeshObject,
45    MESH_PRIVATE_CONTROL_CHANNEL,
46    MESH_PRIVATE_QUERY_CHANNEL,
47    MESH_PRIVATE_RECEIPT_CHANNEL,
48    MESH_QUERY_CHANNEL,
49    MESH_REPLY_CHANNEL,
50};
51#[cfg(feature = "native-realtime")]
52pub use first_party::native_realtime_support::{
53    init_realtime_transport, RealtimeStatement, RealtimeTransport,
54};
55pub use registry::ExtensionRegistry;
56pub use trait_def::{HostExtension, HostPushEvent};