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::crdt::CrdtExtension;
28pub use first_party::crdt_runtime::{CrdtRuntime, CrdtRuntimeError, InMemoryCrdtRuntime};
29pub use first_party::data::DataExtension;
30pub use first_party::media::MediaExtension;
31pub use first_party::mesh::MeshExtension;
32pub use first_party::mesh_runtime::{
33    current_time_ms,
34    generate_session_nonce,
35    private_object_result,
36    InMemoryMeshConfig,
37    InMemoryMeshRuntime,
38    MeshPrivateControlWireMessage,
39    MeshPrivateReceiptWireMessage,
40    MeshPrivateWireQuery,
41    MeshRuntime,
42    MeshWireQuery,
43    MeshWireReply,
44    // Wire types and channel constants
45    StoredMeshObject,
46    StoredPrivateMeshObject,
47    MESH_PRIVATE_CONTROL_CHANNEL,
48    MESH_PRIVATE_QUERY_CHANNEL,
49    MESH_PRIVATE_RECEIPT_CHANNEL,
50    MESH_QUERY_CHANNEL,
51    MESH_REPLY_CHANNEL,
52};
53#[cfg(feature = "native-realtime")]
54pub use first_party::native_realtime_support::{
55    init_realtime_transport, set_realtime_runtime_config, RealtimeRuntimeConfig, RealtimeStatement,
56    RealtimeTransport,
57};
58pub use host_ext_files::FilesExtension;
59pub use registry::ExtensionRegistry;
60pub use trait_def::{HostExtension, HostPushEvent};