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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use crate::EventTarget;
use js_sys::{Array, Object};
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
    #[derive(Debug)]
    pub type Window;

    #[wasm_bindgen(method, getter, js_name = alwaysOnTop)]
    pub fn always_on_top(this: &Window) -> bool;

    #[wasm_bindgen(method, getter)]
    pub fn focused(this: &Window) -> bool;

    #[wasm_bindgen(method, getter)]
    pub fn incognito(this: &Window) -> bool;

    #[wasm_bindgen(method, getter)]
    // TODO is i32 correct ?
    pub fn left(this: &Window) -> Option<i32>;

    #[wasm_bindgen(method, getter)]
    // TODO is i32 correct ?
    pub fn top(this: &Window) -> Option<i32>;

    #[wasm_bindgen(method, getter)]
    // TODO is u32 correct ?
    pub fn width(this: &Window) -> Option<u32>;

    #[wasm_bindgen(method, getter)]
    // TODO is u32 correct ?
    pub fn height(this: &Window) -> Option<u32>;

    #[wasm_bindgen(method, getter)]
    // TODO is i32 correct ?
    pub fn id(this: &Window) -> Option<i32>;

    #[wasm_bindgen(method, getter, js_name = sessionId)]
    pub fn session_id(this: &Window) -> Option<String>;

    #[wasm_bindgen(method, getter)]
    pub fn title(this: &Window) -> Option<String>;

    #[wasm_bindgen(method, getter)]
    pub fn state(this: &Window) -> Option<String>;

    #[wasm_bindgen(method, getter)]
    pub fn tabs(this: &Window) -> Option<Array>;

    #[wasm_bindgen(method, getter, js_name = type)]
    pub fn type_(this: &Window) -> Option<String>;
}

#[wasm_bindgen]
extern "C" {
    pub type Windows;

    #[wasm_bindgen(method, getter, js_name = WINDOW_ID_NONE)]
    pub fn window_id_none(this: &Windows) -> i32;

    #[wasm_bindgen(method, getter, js_name = WINDOW_ID_CURRENT)]
    pub fn window_id_current(this: &Windows) -> i32;

    #[wasm_bindgen(catch, method)]
    pub async fn get(this: &Windows, window_id: i32, info: &Object) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(catch, method, js_name = getCurrent)]
    pub async fn get_current(this: &Windows, info: &Object) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(catch, method, js_name = getLastFocused)]
    pub async fn get_last_focused(this: &Windows, info: &Object) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(catch, method, js_name = getAll)]
    pub async fn get_all(this: &Windows, info: &Object) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(catch, method)]
    pub async fn create(this: &Windows, info: &Object) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(catch, method)]
    pub async fn update(this: &Windows, window_id: i32, info: &Object) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(catch, method)]
    pub async fn remove(this: &Windows, window_id: i32) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, getter, js_name = onCreated)]
    pub fn on_created(this: &Windows) -> EventTarget;

    #[wasm_bindgen(method, getter, js_name = onRemoved)]
    pub fn on_removed(this: &Windows) -> EventTarget;

    #[wasm_bindgen(method, getter, js_name = onFocusChanged)]
    pub fn on_focus_changed(this: &Windows) -> EventTarget;
}