Source file tabs_browser_lwt.ml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
open Ezjs_min_lwt
open Promise
open Extension_utils
open Browser
open Runtime
open Tabs
class type tabs = object
method _TAB_ID_NONE : js_string t prop
method captureTab : int optdef -> imageDetails t optdef -> js_string t promise t meth
method captureVisibleTab : int optdef -> imageDetails t optdef -> js_string t promise t meth
method connect : int -> 'a t optdef -> port meth
method create : createProperties t -> tab t promise t meth
method detectLanguage : int optdef -> js_string t promise t meth
method discard : int -> unit promise t meth
method discard_arr : int js_array t -> unit promise t meth
method duplicate : int -> tab t promise t meth
method executeScript : int optdef -> details t -> 'a t js_array t promise t meth
method get : int -> tab t promise t meth
method getAllInWindow : int optdef -> tab t js_array t promise t meth
method getCurrent : tab t promise t meth
method getZoom : int optdef -> number t promise t meth
method getZoomSettings : int optdef -> zoomSettings t promise t meth
method hide : int -> js_string t js_array t promise t meth
method hide_arr : int js_array t -> js_string t js_array t promise t meth
method highlight : highlightInfo t -> window t promise t meth
method insertCSS : int optdef -> details t meth
method move : int -> moveProperties -> tab t promise t meth
method move_arr : int js_array t -> moveProperties -> tab t js_array t promise t meth
method moveInSuccession : int js_array t -> int optdef -> moveInSuccessionOptions t optdef -> unit meth
method print : unit meth
method printPreview : unit promise t meth
method query : queryInfo t -> tab t js_array t promise t meth
method reload : int optdef -> reloadProperties t optdef -> unit promise t meth
method remove : int -> unit promise t meth
method remove_arr : int js_array t -> unit promise t meth
method removeCSS : int optdef -> details t -> unit promise t meth
method saveAsPDF : pageSettings t -> js_string t promise t meth
method sendMessage : int -> 'a t -> details t optdef -> 'b t promise t meth
method setZoom : int optdef -> number t -> unit promise t meth
method setZoomSettings : int optdef -> zoomSettings t -> unit promise t meth
method show : int -> unit promise t meth
method show_arr : int js_array t -> unit promise t meth
method toggleReaderMode : int optdef -> unit promise t meth
method update : int optdef -> tab t -> tab t promise t meth
method onActivated : 'a t event t prop
method onAttached : (int, 'a t) event2 t prop
method onCreated : tab t event t prop
method onDetached : (int, 'a t) event2 t prop
method onHighlighted : 'a t event t prop
method onMoved : (int, 'a t) event2 t prop
method onRemoved : (int, 'a t) event2 t prop
method onReplaced : (int, int) event2 t prop
method onUpdated : (int, 'a t, tab t) event3 t prop
method onZoomChanged : 'a t event t prop
end
let tabs : tabs t = Unsafe.global##.browser##.tabs
let tab_id_none () = tabs##._TAB_ID_NONE
let captureTab ?id ?options () =
to_lwt_tr to_string (tabs##captureTab (Optdef.option id) (Optdef.option options))
let captureVisibleTab ?id ?options () =
to_lwt_tr to_string (tabs##captureVisibleTab (Optdef.option id) (Optdef.option options))
let connect ?info id = tabs##connect id (Optdef.option info)
let create ?callback tab = to_lwt_opt callback (tabs##create tab)
let detectLanguage ?id () =
to_lwt_tr to_string (tabs##detectLanguage (Optdef.option id))
let discard ?callback id = to_lwt_opt callback (tabs##discard id)
let discard_list ?callback ids =
to_lwt_opt callback (tabs##discard_arr (of_list ids))
let duplicate ?callback id = to_lwt_opt callback (tabs##duplicate id)
let executeScript ?id ?callback details =
to_lwt_opt callback (tabs##executeScript (Optdef.option id) details)
let get id = to_lwt (tabs##get id)
let getCurrent () = to_lwt tabs##getCurrent
let getZoom ?id () = to_lwt_tr float_of_number (tabs##getZoom (Optdef.option id))
let getZoomSettings ?id () = to_lwt (tabs##getZoomSettings (Optdef.option id))
let hide id = tabs##hide id
let hide_list ids = tabs##hide_arr (of_list ids)
let highlight ?callback info = to_lwt_opt callback (tabs##highlight info)
let insertCSS ?id () = tabs##insertCSS (Optdef.option id)
let move ?callback id props = to_lwt_opt callback (tabs##move id props)
let move_list ?callback ids props =
to_lwt_opt callback (tabs##move_arr (of_list ids) props)
let moveInSuccession ?id ?options ids =
tabs##moveInSuccession (of_list ids) (Optdef.option id) (Optdef.option options)
let print () = tabs##print
let printPreview () = tabs##printPreview
let query info = to_lwt (tabs##query info)
let reload ?id ?props ?callback () =
to_lwt_opt callback (tabs##reload (Optdef.option id) (Optdef.option props))
let remove ?callback id = to_lwt_opt callback (tabs##remove id)
let removeCSS ?id details = tabs##removeCSS (Optdef.option id) details
let saveAsPDF settings = to_lwt_tr to_string (tabs##saveAsPDF settings)
let remove_list ?callback id = to_lwt_opt callback (tabs##remove_arr (of_list id))
let sendMessage ?details ?callback id message =
to_lwt_opt callback (tabs##sendMessage id message (Optdef.option details))
let setZoom ?id ?callback factor =
to_lwt_opt callback (tabs##setZoom (Optdef.option id) (number_of_float factor))
let setZoomSettings ?id props =
to_lwt (tabs##setZoomSettings (Optdef.option id) props)
let show id = tabs##show id
let show_list ids = tabs##show_arr (of_list ids)
let toggleReaderMode ?id () = tabs##toggleReaderMode (Optdef.option id)
let update ?id ?callback props =
to_lwt_opt callback (tabs##update (Optdef.option id) props)
let onActivated f = addListener1 tabs##.onActivated f
let onAttached f = addListener2 tabs##.onAttached f
let onCreated f = addListener1 tabs##.onCreated f
let onDetached f = addListener2 tabs##.onDetached f
let onHighLighted f = addListener1 tabs##.onHighlighted f
let onMoved f = addListener2 tabs##.onMoved f
let onRemoved f = addListener2 tabs##.onRemoved f
let onReplaced f = addListener2 tabs##.onReplaced f
let onUpdated f = addListener3 tabs##.onUpdated f
let onZoomChanged f = addListener1 tabs##.onZoomChanged f