123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105(* Js_of_ocaml compiler
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2017 Hugo Heuzard
*
* 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.
*)letsourceMappingURL="//# sourceMappingURL="letsourceMappingURL_base64="//# sourceMappingURL=data:application/json;base64,"letdrop_prefix~prefixs=letplen=String.lengthprefixinifplen>String.lengthsthenNoneelsetryfori=0toString.lengthprefix-1doifs.[i]<>prefix.[i]thenraiseExitdone;Some(String.subsplen(String.lengths-plen))withExit->Nonelet_=drop_prefix~prefix:"qwe:""qwe"letkind~resolve_sourcemap_urlfileline=lets=matchdrop_prefix~prefix:sourceMappingURL_base64linewith|Somebase64->`Json_base64base64|None->(matchdrop_prefix~prefix:sourceMappingURLlinewith|Someurl->`Urlurl|None->`Other)inmatchswith|`Other->`Other|`Json_base64base64->`Source_map(Source_map_io.of_string(Base64.decode_exnbase64))|`Url_whennotresolve_sourcemap_url->`Drop|`Urlurl->letbase=Filename.dirnamefileinletic=open_in(Filename.concatbaseurl)inletl=in_channel_lengthicinletcontent=really_input_stringiclinclose_inic;`Source_map(Source_map_io.of_stringcontent)letlink~output~files~resolve_sourcemap_url~source_map=letsm=ref[]inletline_offset=ref0inletnew_line()=output_stringoutput"\n";incrline_offsetinletsource_offset=ref0inList.iter(funfile->letic=open_infilein(tryoutput_stringoutput(Printf.sprintf"//# 1 %S"file);new_line();letstart_line=!line_offsetinwhiletruedoletline=input_lineicinmatchkind~resolve_sourcemap_urlfileline,source_mapwith|`Other,_->output_stringoutputline;new_line()|`Drop,_->()|`Source_map_,None->()|`Source_mapx,Some_->source_offset:=List.lengthx.Source_map.sources;sm:=(start_line,file,x)::!smdonewithEnd_of_file->());close_inic;new_line())files;matchsource_mapwith|None->()|Some(file,init_sm)->(matchSource_map.merge((0,"",init_sm)::List.rev!sm)with|None->()|Somesm->(matchfilewith|None->letdata=Source_map_io.to_stringsminlets=sourceMappingURL_base64^Base64.encode_exndatainoutput_stringoutputs|Somefile->Source_map_io.to_filesmfile;lets=sourceMappingURL^Filename.basenamefileinoutput_stringoutputs))