123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126openFmlib_jstype'mt=|None|Windowofstring*'mHandler.Virtual.t|Interval_timerofint*(Time.t->'m)|Animationof(Time.t->'m)|Messageof'mBase.Decode.t|Url_requestof(Url.t->'m)|Batchof'mtlistletnone:'mt=Noneletbatch(lst:'mtlist):'mt=Batchlstleton_window(event_type:string)(decode:'mBase.Decode.t):'mt=Window(event_type,Event_flag.(no_stop,no_prevent,decode))letevery(ms:int)(callback:Time.t->'m):'mt=Interval_timer(ms,callback)leton_animation(callback:Time.t->'m):'mt=Animationcallbackleton_message(decode:'mBase.Decode.t):'mt=Messagedecodeleton_url_request(f:Url.t->'m):'mt=Url_requestfletmap(f:'a->'b)(sub:'at):'bt=letrecmap=function|None->None|Batchlst->Batch(List.mapmaplst)|Window(event_type,decode)->Window(event_type,Handler.Virtual.mapfdecode)|Interval_timer(millis,g)->Interval_timer(millis,funtime->f(gtime))|Animationg->Animation(funtime->f(gtime))|Messagedecode->MessageBase.Decode.(mapfdecode)|Url_requestg->Url_request(funurl->f(gurl))inmapsubletdecode_key_event(f:string->'m):'mBase.Decode.t=Base.Decode.(mapf(field"key"string))letdecode_mouse_event(f:int->int->'m):'mBase.Decode.t=Base.Decode.(let*x=field"clientX"intinlet*y=field"clientY"intinreturn(fxy))leton_keydown(f:string->'m):'mt=on_window"keydown"(decode_key_eventf)leton_keyup(f:string->'m):'mt=on_window"keyup"(decode_key_eventf)leton_mouse_down(f:int->int->'m):'mt=on_window"mousedown"(decode_mouse_eventf)leton_mouse_move(f:int->int->'m):'mt=on_window"mousemove"(decode_mouse_eventf)leton_mouse_up(f:int->int->'m):'mt=on_window"mouseup"(decode_mouse_eventf)leton_resize(f:int->int->'m):'mt=letdecode=Base.Decode.(let*_=return()infield"currentTarget"(let*width=field"innerWidth"intinlet*height=field"innerHeight"intinreturn(fwidthheight)))inon_window"resize"decodeleton_visibility_change(f:string->'m):'mt=letdecode=Base.Decode.(field"target"((* The target of the visibility change event is "document" and
"document" has the "visibilityState" property. *)let*state=field"visibilityState"stringinreturn(fstate)))inon_window"visibilitychange"decode