12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879(* Js_of_ocaml library
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2015 OCamlPro: Grégoire Henry, Çağdaş Bozman.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)openJsopenDom_htmlopen!Importclasstype['a,'b]worker=object('self)inheriteventTargetmethodonerror:('selft,errorEventt)event_listenerwriteonly_propmethodonmessage:('selft,'bmessageEventt)event_listenerwriteonly_propmethodpostMessage:'a->unitmethmethodterminate:unitmethendanderrorEvent=objectinheriteventmethodmessage:js_stringtreadonly_propmethodfilename:js_stringtreadonly_propmethodlineno:inttreadonly_propmethodcolno:inttreadonly_propmethoderror:Unsafe.any->unitmethendand['a]messageEvent=objectinheriteventmethoddata:'areadonly_propendletworker=Unsafe.global##._Workerletcreatescript=new%jsworker(stringscript)letimport_scriptsscripts:unit=ifUnsafe.global##.importScripts==undefinedtheninvalid_arg"Worker.import_scripts is undefined";Unsafe.fun_callUnsafe.global##.importScripts(Array.map(funs->Unsafe.inject(strings))(Array.of_listscripts))letset_onmessagehandler=ifUnsafe.global##.onmessage==undefinedtheninvalid_arg"Worker.onmessage is undefined";letjs_handler(ev:'amessageEventJs.t)=handlerev##.datainUnsafe.global##.onmessage:=wrap_callbackjs_handlerletpost_messagemsg=ifUnsafe.global##.postMessage==undefinedtheninvalid_arg"Worker.onmessage is undefined";Unsafe.global##postMessagemsg