123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267# 1 "src/lib/eliom_runtime.shared.ml"(* Ocsigen
* http://www.ocsigen.org
* Copyright (C) CNRS Univ Paris Diderot
*
* 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.
*)(**/**)openJs_of_ocamlmoduleClient_value_server_repr=structtypeu={mutableloc:Eliom_lib_base.posoption;instance_id:int;unwrapper:Eliom_wrap.unwrapper}type'at=uletcreate?loc~instance_id~unwrapper={instance_id;loc;unwrapper}letinstance_idcv=cv.instance_idletloccv=cv.locletclear_loccv=cv.loc<-Noneletto_polyv=vendtypeescaped_value=Ocsigen_lib_base.polymoduleRawXML=structtypeseparator=Space|Commaletseparator_to_string=functionSpace->" "|Comma->", "typecookie_info=bool*stringlist[@@derivingjson]typecaml_event_handler=|CE_registered_closureofstring*Ocsigen_lib_base.poly(* 'a Js.t -> unit) client_value *)|CE_client_closureof(Dom_html.eventJs.t->unit)(* Client side-only *)|CE_client_closure_mouseof(Dom_html.mouseEventJs.t->unit)(* Client side-only *)|CE_client_closure_keyboardof(Dom_html.keyboardEventJs.t->unit)(* Client side-only *)|CE_client_closure_touchof(Dom_html.touchEventJs.t->unit)(* Client side-only *)|CE_call_serviceof([`A|`Form_get|`Form_post]*cookie_infooption*stringoption*Ocsigen_lib_base.poly)(* (event -> bool) client_value *)optionEliom_lazy.requesttypeinternal_event_handler=Rawofstring|Camlofcaml_event_handlertypeuri=stringEliom_lazy.requestletstring_of_uri=Eliom_lazy.forceleturi_of_string=Eliom_lazy.from_valleturi_of_fun=Eliom_lazy.from_funletinternal_event_handler_of_serviceinfo=Caml(CE_call_serviceinfo)letce_registered_closure_class="caml_c"(*"caml_closure"*)letce_registered_attr_class="caml_attr"letce_call_service_class="caml_link"letprocess_node_class="caml_p"(*"caml_process_node"*)letrequest_node_class="caml_r"(*"caml_request_node"*)letce_call_service_attrib="data-eliom-cookies-info"letce_template_attrib="data-eliom-template"letnode_id_attrib="data-eliom-id"(*"data-eliom-node-id"*)letclosure_attr_prefix=""(*"caml_closure_id"*)letclosure_name_prefix="data-eliom-c-"(*!!! This prefix has to be different from any other prefix *)letclient_attr_prefix="eliom_attrib"letclient_name_prefix="data-eliom-"typeaname=stringtypeacontent=|AFloatoffloat|AIntofint|AStrofstring|AStrLofseparator*stringlisttyperacontent=|RAofacontent|RAReactofacontentoptionReact.signal|RACamlEventHandlerofcaml_event_handler|RALazyStrofstringEliom_lazy.request|RALazyStrLofseparator*stringEliom_lazy.requestlist|RAClientofstring*attriboption*Ocsigen_lib_base.poly(*attrib client_value *)andattrib=aname*racontentletaname=function|name,RACamlEventHandler(CE_registered_closure(_crypto,_))->closure_name_prefix^name|_,RAClient(_,Some(name,_),_)|name,RAClient(_,None,_)->client_name_prefix^name|name,_->nameletacontent=function|_,RAReacts->(matchReact.S.valueswithNone->AStr""|Somex->x)|_,RAa->a|_,RACamlEventHandler(CE_registered_closure(crypto,_))->AStr(closure_attr_prefix^crypto)|_,RACamlEventHandler_->AStr""|_,RALazyStrstr->AStr(Eliom_lazy.forcestr)|_,RALazyStrL(sep,str)->AStrL(sep,List.mapEliom_lazy.forcestr)|_,RAClient(crypto,_,_)->AStr(client_attr_prefix^crypto)letracontent(_,a)=aletreact_float_attribnames=name,RAReact(React.S.map(funf->Some(AFloatf))s)letreact_int_attribnames=name,RAReact(React.S.map(funf->Some(AIntf))s)letreact_string_attribnames=name,RAReact(React.S.map(funf->Some(AStrf))s)letreact_space_sep_attribnames=name,RAReact(React.S.map(funf->Some(AStrL(Space,f)))s)letreact_comma_sep_attribnames=name,RAReact(React.S.map(funf->Some(AStrL(Comma,f)))s)letreact_poly_attribnamevs=(name,RAReact(React.S.map(functionfalse->None|true->Some(AStrv))s))letfloat_attribnamevalue=name,RA(AFloatvalue)letint_attribnamevalue=name,RA(AIntvalue)letstring_attribnamevalue=name,RA(AStrvalue)letspace_sep_attribnamevalues=name,RA(AStrL(Space,values))letcomma_sep_attribnamevalues=name,RA(AStrL(Comma,values))letinternal_event_handler_attribnamevalue=matchvaluewith|Rawvalue->name,RA(AStrvalue)|Camlv->name,RACamlEventHandlervleturi_attribnamevalue=name,RALazyStrvalueleturis_attribnamevalue=name,RALazyStrL(Space,value)typeename=stringtypenode_id=NoId|ProcessIdofstring|RequestIdofstringmoduleClosureMap=Map.Make(structtypet=stringletcompare=compareend)typeevent_handler_table=Ocsigen_lib_base.poly(* (biggest_event Js.t -> unit) client_value *)ClosureMap.ttypeclient_attrib_table=Ocsigen_lib_base.poly(* attrib client_value *)ClosureMap.tletfilter_class_valueacc=function|AStrv->v::acc|AStrL(_space,v)->v@acc|_->failwith"attribute class is not a string"letfilter_class(freepos,acc_class,acc_attr)=function|"class",RAvalue->freepos,filter_class_valueacc_classvalue,acc_attr|(_,RACamlEventHandler(CE_registered_closure_))asattr->freepos,ce_registered_closure_class::acc_class,attr::acc_attr|_,RACamlEventHandler(CE_call_servicelink_info)->(matchEliom_lazy.forcelink_infowith|None->freepos,acc_class,acc_attr|Some(_kind,cookie_info,tmpl,_)->letacc_class=ce_call_service_class::acc_classinletacc_attr=matchcookie_infowith|None->acc_attr|Somev->(ce_call_service_attrib,RA(AStr([%json_of:cookie_info]v)))::acc_attrinletacc_attr=matchtmplwith|None->acc_attr|Sometmpl->(ce_template_attrib,RA(AStrtmpl))::acc_attrinfreepos,acc_class,acc_attr)|"",RAClient(crypt,Some("class",RAv),cv)->letacc_class=filter_class_valueacc_classvinletacc_class=ce_registered_attr_class::acc_classandacc_attr=("class",RAClient(crypt,None,cv))::acc_attrinfreepos,acc_class,acc_attr|"",RAClient(crypt,init,cv)->letfreepos,acc_attr=matchinitwith|Some((an,_)asa)->freepos,(an,RAClient(crypt,None,cv))::a::acc_attr|None->letname=Printf.sprintf"anonym%d"freeposinletfreepos=succfreeposinfreepos,(name,RAClient(crypt,None,cv))::acc_attrinfreepos,ce_registered_attr_class::acc_class,acc_attr|_,RAClient_->assertfalse|attr->freepos,acc_class,attr::acc_attrletfilter_class_attribsnode_idattribs=letnid_classes,nid_attribs=matchnode_idwith|NoId->[],[]|ProcessIdi->[process_node_class],[node_id_attrib,RA(AStri)]|RequestIdi->[request_node_class],[node_id_attrib,RA(AStri)]inlet_,classes,attribs=List.fold_leftfilter_class(0,nid_classes,nid_attribs)attribsinmatchclasseswith|[]->attribs|_->("class",RA(AStrL(Space,classes)))::attribsendlettyxml_unwrap_id_int=1letclient_value_unwrap_id_int=7typeclient_value_datum={closure_id:string;args:Ocsigen_lib_base.poly;value:Ocsigen_lib_base.polyClient_value_server_repr.t}typeinjection_datum={injection_dbg:(Eliom_lib_base.pos*stringoption)option;injection_id:int;injection_value:Ocsigen_lib_base.poly}typecompilation_unit_global_data={server_sections_data:client_value_datumarrayarray;client_sections_data:injection_datumarrayarray}typeglobal_data=compilation_unit_global_dataEliom_lib.String_map.ttyperequest_data=client_value_datumarrayletglobal_data_unwrap_id_int=8type'aeliom_caml_service_data={ecs_request_data:request_data;ecs_data:'a}(* the data sent on channels *)type'aeliom_comet_data_type='aEliom_wrap.wrapped_value