1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::{EventTarget, Port};
use js_sys::Object;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
pub type Runtime;
#[wasm_bindgen(catch, method, js_name = sendMessage)]
pub async fn send_message(
this: &Runtime,
extension_id: Option<&str>,
message: &JsValue,
options: Option<&Object>,
) -> Result<JsValue, JsValue>;
#[wasm_bindgen(catch, method, js_name = sendNativeMessage)]
pub async fn send_native_message(
this: &Runtime,
application: &str,
message: &Object,
) -> Result<JsValue, JsValue>;
#[wasm_bindgen(method)]
pub fn connect(this: &Runtime, extension_id: Option<&str>, connect_info: &Object) -> Port;
#[wasm_bindgen(method, getter, js_name = onMessage)]
pub fn on_message(this: &Runtime) -> EventTarget;
#[wasm_bindgen(method, getter, js_name = onConnect)]
pub fn on_connect(this: &Runtime) -> EventTarget;
#[wasm_bindgen(method, getter, js_name = onInstalled)]
pub fn on_installed(this: &Runtime) -> EventTarget;
#[wasm_bindgen(method, js_name = setUninstallURL)]
pub fn set_uninstall_url(this: &Runtime, url: &str);
#[wasm_bindgen(method, js_name = openOptionsPage)]
pub fn open_options_page(this: &Runtime);
#[wasm_bindgen(method, getter, js_name = lastError)]
pub fn last_error(this: &Runtime) -> Option<js_sys::Error>;
}