web_extensions_sys/
windows.rs

1use crate::EventTarget;
2use js_sys::{Array, Object};
3use wasm_bindgen::prelude::*;
4
5#[wasm_bindgen]
6extern "C" {
7    #[derive(Debug)]
8    pub type Window;
9
10    #[wasm_bindgen(method, getter, js_name = alwaysOnTop)]
11    pub fn always_on_top(this: &Window) -> bool;
12
13    #[wasm_bindgen(method, getter)]
14    pub fn focused(this: &Window) -> bool;
15
16    #[wasm_bindgen(method, getter)]
17    pub fn incognito(this: &Window) -> bool;
18
19    #[wasm_bindgen(method, getter)]
20    // TODO is i32 correct ?
21    pub fn left(this: &Window) -> Option<i32>;
22
23    #[wasm_bindgen(method, getter)]
24    // TODO is i32 correct ?
25    pub fn top(this: &Window) -> Option<i32>;
26
27    #[wasm_bindgen(method, getter)]
28    // TODO is u32 correct ?
29    pub fn width(this: &Window) -> Option<u32>;
30
31    #[wasm_bindgen(method, getter)]
32    // TODO is u32 correct ?
33    pub fn height(this: &Window) -> Option<u32>;
34
35    #[wasm_bindgen(method, getter)]
36    // TODO is i32 correct ?
37    pub fn id(this: &Window) -> Option<i32>;
38
39    #[wasm_bindgen(method, getter, js_name = sessionId)]
40    pub fn session_id(this: &Window) -> Option<String>;
41
42    #[wasm_bindgen(method, getter)]
43    pub fn title(this: &Window) -> Option<String>;
44
45    #[wasm_bindgen(method, getter)]
46    pub fn state(this: &Window) -> Option<String>;
47
48    #[wasm_bindgen(method, getter)]
49    pub fn tabs(this: &Window) -> Option<Array>;
50
51    #[wasm_bindgen(method, getter, js_name = type)]
52    pub fn type_(this: &Window) -> Option<String>;
53}
54
55#[wasm_bindgen]
56extern "C" {
57    pub type Windows;
58
59    #[wasm_bindgen(method, getter, js_name = WINDOW_ID_NONE)]
60    pub fn window_id_none(this: &Windows) -> i32;
61
62    #[wasm_bindgen(method, getter, js_name = WINDOW_ID_CURRENT)]
63    pub fn window_id_current(this: &Windows) -> i32;
64
65    #[wasm_bindgen(catch, method)]
66    pub async fn get(this: &Windows, window_id: i32, info: &Object) -> Result<JsValue, JsValue>;
67
68    #[wasm_bindgen(catch, method, js_name = getCurrent)]
69    pub async fn get_current(this: &Windows, info: &Object) -> Result<JsValue, JsValue>;
70
71    #[wasm_bindgen(catch, method, js_name = getLastFocused)]
72    pub async fn get_last_focused(this: &Windows, info: &Object) -> Result<JsValue, JsValue>;
73
74    #[wasm_bindgen(catch, method, js_name = getAll)]
75    pub async fn get_all(this: &Windows, info: &Object) -> Result<JsValue, JsValue>;
76
77    #[wasm_bindgen(catch, method)]
78    pub async fn create(this: &Windows, info: &Object) -> Result<JsValue, JsValue>;
79
80    #[wasm_bindgen(catch, method)]
81    pub async fn update(this: &Windows, window_id: i32, info: &Object) -> Result<JsValue, JsValue>;
82
83    #[wasm_bindgen(catch, method)]
84    pub async fn remove(this: &Windows, window_id: i32) -> Result<JsValue, JsValue>;
85
86    #[wasm_bindgen(method, getter, js_name = onCreated)]
87    pub fn on_created(this: &Windows) -> EventTarget;
88
89    #[wasm_bindgen(method, getter, js_name = onRemoved)]
90    pub fn on_removed(this: &Windows) -> EventTarget;
91
92    #[wasm_bindgen(method, getter, js_name = onFocusChanged)]
93    pub fn on_focus_changed(this: &Windows) -> EventTarget;
94}