forked from rescript-lang/experimental-rescript-webapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventAPI.res
More file actions
229 lines (219 loc) · 7.71 KB
/
EventAPI.res
File metadata and controls
229 lines (219 loc) · 7.71 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
@@warning("-30")
@unboxed
type eventType =
| @as("abort") Abort
| @as("auxclick") Auxclick
| @as("beforeinput") Beforeinput
| @as("beforetoggle") Beforetoggle
| @as("blur") Blur
| @as("cancel") Cancel
| @as("canplay") Canplay
| @as("canplaythrough") Canplaythrough
| @as("change") Change
| @as("click") Click
| @as("close") Close
| @as("contextlost") Contextlost
| @as("contextmenu") Contextmenu
| @as("contextrestored") Contextrestored
| @as("copy") Copy
| @as("cuechange") Cuechange
| @as("cut") Cut
| @as("dblclick") Dblclick
| @as("DOMContentLoaded") DOMContentLoaded
| @as("drag") Drag
| @as("dragend") Dragend
| @as("dragenter") Dragenter
| @as("dragleave") Dragleave
| @as("dragover") Dragover
| @as("dragstart") Dragstart
| @as("drop") Drop
| @as("durationchange") Durationchange
| @as("emptied") Emptied
| @as("ended") Ended
| @as("error") Error
| @as("focus") Focus
| @as("formdata") Formdata
| @as("input") Input
| @as("invalid") Invalid
| @as("keydown") Keydown
| @as("keypress") Keypress
| @as("keyup") Keyup
| @as("load") Load
| @as("loadeddata") Loadeddata
| @as("loadedmetadata") Loadedmetadata
| @as("loadstart") Loadstart
| @as("mousedown") Mousedown
| @as("mouseenter") Mouseenter
| @as("mouseleave") Mouseleave
| @as("mousemove") Mousemove
| @as("mouseout") Mouseout
| @as("mouseover") Mouseover
| @as("mouseup") Mouseup
| @as("notificationclick") NotificationClick
| @as("paste") Paste
| @as("pause") Pause
| @as("play") Play
| @as("playing") Playing
| @as("progress") Progress
| @as("ratechange") Ratechange
| @as("reset") Reset
| @as("resize") Resize
| @as("scroll") Scroll
| @as("scrollend") Scrollend
| @as("securitypolicyviolation") Securitypolicyviolation
| @as("seeked") Seeked
| @as("seeking") Seeking
| @as("select") Select
| @as("slotchange") Slotchange
| @as("stalled") Stalled
| @as("submit") Submit
| @as("suspend") Suspend
| @as("timeupdate") Timeupdate
| @as("toggle") Toggle
| @as("volumechange") Volumechange
| @as("waiting") Waiting
| @as("webkitanimationend") Webkitanimationend
| @as("webkitanimationiteration") Webkitanimationiteration
| @as("webkitanimationstart") Webkitanimationstart
| @as("webkittransitionend") Webkittransitionend
| @as("wheel") Wheel
| @as("animationstart") Animationstart
| @as("animationiteration") Animationiteration
| @as("animationend") Animationend
| @as("animationcancel") Animationcancel
| @as("transitionrun") Transitionrun
| @as("transitionstart") Transitionstart
| @as("transitionend") Transitionend
| @as("transitioncancel") Transitioncancel
| @as("pointerover") Pointerover
| @as("pointerenter") Pointerenter
| @as("pointerdown") Pointerdown
| @as("pointermove") Pointermove
| @as("pointerup") Pointerup
| @as("pointercancel") Pointercancel
| @as("pointerout") Pointerout
| @as("pointerleave") Pointerleave
| @as("push") Push
| @as("gotpointercapture") Gotpointercapture
| @as("lostpointercapture") Lostpointercapture
| @as("selectstart") Selectstart
| @as("selectionchange") Selectionchange
| @as("touchstart") Touchstart
| @as("touchend") Touchend
| @as("touchmove") Touchmove
| @as("touchcancel") Touchcancel
| Custom(string)
type eventListener<'event> = 'event => unit
/**
EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.
[See EventTarget on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget)
*/
@editor.completeFrom(EventTarget)
type eventTarget = {}
/**
An event which takes place in the DOM.
[See Event on MDN](https://developer.mozilla.org/docs/Web/API/Event)
*/
@editor.completeFrom(Event)
type event = {
/**
Returns the type of event, e.g. "click", "hashchange", or "submit".
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/type)
*/
@as("type")
type_: eventType,
/**
Returns the object to which event is dispatched (its target).
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/target)
*/
target: Null.t<eventTarget>,
/**
Returns the object whose event listener's callback is currently being invoked.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
*/
currentTarget: Null.t<eventTarget>,
/**
Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
*/
eventPhase: int,
/**
Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
*/
bubbles: bool,
/**
Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
*/
cancelable: bool,
/**
Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
*/
defaultPrevented: bool,
/**
Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/composed)
*/
composed: bool,
/**
Returns true if event was dispatched by the user agent, and false otherwise.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
*/
isTrusted: bool,
/**
Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
*/
timeStamp: float,
}
/**
A controller object that allows you to abort one or more DOM requests as and when desired.
[See AbortController on MDN](https://developer.mozilla.org/docs/Web/API/AbortController)
*/
@editor.completeFrom(AbortController)
type rec abortController = {
/**
Returns the AbortSignal object associated with this object.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
*/
signal: abortSignal,
}
/**
A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object.
[See AbortSignal on MDN](https://developer.mozilla.org/docs/Web/API/AbortSignal)
*/
@editor.completeFrom(AbortSignal)
and abortSignal = {
...eventTarget,
/**
Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
*/
aborted: bool,
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
*/
reason: JSON.t,
}
type eventListenerOptions = {mutable capture?: bool}
type addEventListenerOptions = {
...eventListenerOptions,
mutable passive?: bool,
mutable once?: bool,
mutable signal?: abortSignal,
}
type eventInit = {
mutable bubbles?: bool,
mutable cancelable?: bool,
mutable composed?: bool,
}
/**
The ExtendableEvent interface extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle.
[See ExtendableEvent on MDN](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
*/
@editor.completeFrom(ExtendableEvent)
type extendableEvent = {
...event,
}