Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file vue_nav.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687openMjs(** navigation ML object *)typepush_obj=|PPathof{path:string;query:(string*string)list}|PNameof{name:string;params:(string*any)list;query:(string*string)list}(** get query params from ML object *)letget_query=function|PPath{query;_}|PName{query;_}->query(** get params from ML object *)letget_params=function|PName{params=(_::_)asparams;_}->Someparams|_->None(** navigation ML argument : string ot object *)typepush_arg=PStrofstring|PObjofpush_obj(** navigation ML object constructor *)letpush_obj?(params=[])?(query=[])s=ifs=""thenPStr"/"elseifString.gets0='/'thenPObj(PPath{path=s;query})elsePObj(PName{name=s;query;params})(** navigation iterator argument for 'next' *)type'anext=|NUnit|NFalse|NRouteofpush_obj|NErroroferrort|NFunctionof('at->unit)(** navigation JS object signature *)classtypepush_args=objectmethodpath:js_stringtoptdefreadonly_propmethodname:js_stringtoptreadonly_propmethodparams:anytableoptdefreadonly_propmethodquery:js_stringttableoptdefreadonly_propend(** JS to ML *)letto_push_obj(p:push_argst)=letquery=matchto_optdef(Table.itemsfto_string)p##.querywith|None->[]|Somel->linmatchto_optdefto_stringp##.path,to_optto_stringp##.name,to_optdefTable.itemsp##.paramswith|Somepath,_,_->PPath{path;query}|None,Somename,None->PName{name;query;params=[]}|None,Somename,Someparams->PName{name;query;params}|_->failwith"cannot read JS push object"(** ML to JS *)letof_push_objp:push_argst=letpath,name,params=matchpwith|PPath{path;_}->def(stringpath),null,undefined|PName{name;params;_}->undefined,some(stringname),ifparams=[]thenundefinedelsedef(Table.makeparams)inletquery=matchpwithPPath{query;_}|PName{query;_}->ifquery=[]thenundefinedelsedef(Table.makefstringquery)inobject%jsvalpath=pathvalname=namevalparams=paramsvalquery=queryend(** wrapper for navigation guards that don't have access to this *)letwrap_hookf=wrap_callback(funto_fromnext->letnext_arg=matchf(to_push_objto_)(to_push_objfrom)with|NUnit->to_any()|NFalse->to_any_false|NRouter->to_any(of_push_objr)|NErrore->to_anye|NFunctionf->to_any@@wrap_callbackfinnextnext_arg)(** wrapper for navigation guards that have access to this *)letwrap_meth_hookf=wrap_meth_callback(funthisto_fromnext->letnext_arg=matchfthis(to_push_objto_)(to_push_objfrom)with|NUnit->to_any()|NFalse->to_any_false|NRouter->to_any(of_push_objr)|NErrore->to_anye|NFunction_->Firebug.console##warn(string"cannot have a callback in this hook");assertfalseinnextnext_arg)