123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065openPpxlibopenAst_builder.Defaulttypeprop={key:string;typ:core_typeoption;cons:expressionoption;dft:expressionoption;validator:expressionoption;req:bool;convert:bool;}typeacc={name:stringoption;globals:(string*core_typeoption*expression*bool)list;datas:(string*core_typeoption*expression*bool)list;methods:(string*core_typeoption*expression*bool)list;computeds:(string*core_typeoption*expression*bool)list;watchs:(string*core_typeoption*expression*bool)list;directives:stringlist;props:proplist;template:[`stringofstring|`expressionofexpression]option;lifecycle:(string*expression)list;emits:stringlist;compile:bool;debug:bool;types:bool;convert_all:bool;modules:(string*string)listoption;}letempty_acc={name=None;globals=[];datas=[];methods=[];computeds=[];watchs=[];props=[];template=None;lifecycle=[];emits=[];compile=false;debug=false;types=false;convert_all=false;modules=None;directives=[];}letget_str_patp=matchp.ppat_descwith|Ppat_var{txt;_}->txt|Ppat_any->"_"|Ppat_constraint({ppat_desc=Ppat_var{txt;_};_},_)->txt|Ppat_constraint({ppat_desc=Ppat_any;_},_)->"_"|_->Location.raise_errorf~loc:p.ppat_loc"pattern expected to be '_', a variable or a constraint of these patterns"letget_list_expressione=letrecauxacce=matche.pexp_descwith|Pexp_construct({txt=Lident"[]";_},None)->acc|Pexp_construct({txt=Lident"::";_},Some{pexp_desc=Pexp_tuple[e1;e2];_})->aux(e1::acc)e2|_->Location.raise_errorf~loc:e.pexp_loc"wrong expression for a list"inList.rev(aux[]e)letremove_polyc=matchc.ptyp_descwith|Ptyp_poly(_,c)->c|_->cletrecget_exit_typee=matche.pexp_descwith|Pexp_fun(_,_,_,e)->get_exit_typee|Pexp_constraint(_,c)->Some(remove_polyc)|_->Noneletjs_mod,dom_mod=matchSys.getenv_opt"VUE_MODULE"with|Somes->Ppx_deriving_jsoo_lib.Ppx_js.wrapper:=Somes;beginmatchString.rindex_opts'.'with|None->refs,ref(s^"."^"Dom_html")|Somei->refs,ref(String.subs0i^"Dom_html")end|_->ref"Ezjs_min",ref"Ezjs_min.Dom_html"letvue_compiler=matchSys.getenv_opt"VUE_COMPILER",Sys.getenv_opt"OPAM_SWITCH_PREFIX"with|Somes,_->refs|_,Somes->ref(Filename.concats"bin/vue-compiler")|_->ref"src/render.bundle.js"letvue_compile=matchSys.getenv_opt"VUE_COMPILE"with|Some("true"|"1")->reftrue|_->reffalseletvue_debug=matchSys.getenv_opt"VUE_DEBUG"with|Some"true"|Some"1"->reftrue|_->reffalseletjstyp~locsarg=ptyp_constr~loc{txt=Longident.parse(!js_mod^"."^s);loc}argletjsid~locs=evar~loc(!js_mod^"."^s)letjsapp~locsl=eapply~loc(jsid~locs)lletdomtyp~locsarg=ptyp_constr~loc{txt=Longident.parse(!dom_mod^"."^s);loc}argletdomid~locs=evar~loc(!dom_mod^"."^s)letfield_names=lets=matchString.rindex_opts'_'with|None->s|Someiwheni=String.lengths-1->s|Some_->s^"_"inmatchString.gets0with|'A'..'Z'->"_"^s|_|exception_->sletkebabs=String.fold_left(funaccc->matchcwith|'_'->acc^"-"|'A'..'Z'->letacc=ifacc=""then""elseacc^"-"inacc^String.make1(Char.chr@@Char.codec+32)|c->acc^String.make1c)""slethooks=["beforeCreate";"created";"beforeMount";"mounted";"beforeUpdate";"updated";"beforeUnmount";"unmounted"]letinstances=["data";"props";"el";"options";"parent";"root";"slots";"refs";"attrs";"ref"]letconverted_typeaccconvertc=ifconvertthenmatchPpx_deriving_jsoo_lib.Jsoo_type.type_of_core~name:""~params:[]?modules:acc.modulescwith|Ppx_deriving_jsoo_lib.Common.TTc,_->c|Ppx_deriving_jsoo_lib.Common.CTc,_->jstyp~loc:c.ptyp_loc"t"[c]elsecletconverted_expr?(of_=false)accconvertce=matchconvert,cwith|true,Somec->letc=remove_polycinletm=Ppx_deriving_jsoo_lib.Jsoo_conv.expr_of_core~name:""~params:[]?modules:acc.modulescinletconv=ifof_thenm.Ppx_deriving_jsoo_lib.Common.e_ofelsem.Ppx_deriving_jsoo_lib.Common.e_toineapply~loc:e.pexp_locconv[e]|_->eletdata_type_fields~locacc=List.map(fun(k,c,_,convert)->letc=Option.fold~none:(ptyp_any~loc)~some:(converted_typeaccconvert)cinotag~loc{txt=field_namek;loc}@@jstyp~loc"prop"[c])acc.datasletdata_class_type_fields~locacc=List.map(fun(k,c,_,convert)->letc=Option.fold~none:(ptyp_any~loc)~some:(converted_typeaccconvert)cinpctf_method~loc({txt=field_namek;loc},Public,Concrete,jstyp~loc"prop"[c]))acc.datasletglobal_type_fields~locacc=List.map(fun(k,c,_,convert)->letc=Option.fold~none:(ptyp_any~loc)~some:(converted_typeaccconvert)cinotag~loc{txt=field_namek;loc}@@jstyp~loc"readonly_prop"[c])acc.globalsletcomputed_type_fields~locacc=List.map(fun(k,c,_,convert)->letc=Option.fold~none:(ptyp_any~loc)~some:(converted_typeaccconvert)cinotag~loc{txt=field_namek;loc}@@jstyp~loc"readonly_prop"[c])acc.computedsletcomputed_class_type_fields~locacc=List.map(fun(k,c,_,convert)->letc=Option.fold~none:(ptyp_any~loc)~some:(converted_typeaccconvert)cinpctf_method~loc({txt=field_namek;loc},Public,Concrete,jstyp~loc"readonly_prop"[c]))acc.computedsletprop_type_fields~locacc=List.map(funp->letc=Option.fold~none:(ptyp_any~loc)~some:(converted_typeaccp.convert)p.typinotag~loc{txt=field_namep.key;loc}@@jstyp~loc"readonly_prop"[c])acc.propsletprop_class_type_fields~locacc=List.map(funp->letc=Option.fold~none:(ptyp_any~loc)~some:(converted_typeaccp.convert)p.typinpctf_method~loc({txt=field_namep.key;loc},Public,Concrete,jstyp~loc"readonly_prop"[c]))acc.propsletmethod_type_fields~locacc=letrecaux?(first=true)e=matche.pexp_desc,firstwith|Pexp_fun(_,_,_,e),true->aux~first:falsee|Pexp_fun(_,_,{ppat_desc=Ppat_constraint(_,c);_},e),_->ptyp_arrow~locNolabel(remove_polyc)(aux~first:falsee)|Pexp_fun(_,_,_,e),_->ptyp_arrow~locNolabel(ptyp_any~loc)(aux~first:falsee)|Pexp_constraint(_,c),_->jstyp~loc"meth"[remove_polyc]|_->jstyp~loc"meth"[ptyp_any~loc]inList.map(fun(k,_,e,_)->letc=auxeinotag~loc{txt=field_namek;loc}@@c)acc.methodsletmethod_class_type_fields~locacc=letrecaux?(first=true)e=matche.pexp_desc,firstwith|Pexp_fun(_,_,_,e),true->aux~first:falsee|Pexp_fun(_,_,{ppat_desc=Ppat_constraint(_,c);_},e),_->ptyp_arrow~locNolabel(remove_polyc)(aux~first:falsee)|Pexp_fun(_,_,_,e),_->ptyp_arrow~locNolabel(ptyp_any~loc)(aux~first:falsee)|Pexp_constraint(_,c),_->jstyp~loc"meth"[remove_polyc]|_->jstyp~loc"meth"[ptyp_any~loc]inList.map(fun(k,_,e,_)->letc=auxeinpctf_method~loc({txt=field_namek;loc},Public,Concrete,c))acc.methodsletapp_type~locacc=letglobal_type=letfields=global_type_fields~locaccinletct=ptyp_object~locfieldsClosedinjstyp~loc"t"[ct]inifacc.typesthenjstyp~loc"t"[ptyp_object~loc[oinherit~loc(ptyp_constr~loc{txt=Lident"all";loc}[]);oinherit~loc[%type:(_,_,_,_,_,_,_,[%tglobal_type])Vue.app]]Closed]elseletfields=data_type_fields~locacc@prop_type_fields~locacc@computed_type_fields~locacc@method_type_fields~locacc@[oinherit~loc[%type:(_,_,_,_,_,_,_,[%tglobal_type])Vue.app]]inletct=ptyp_object~locfieldsClosedinjstyp~loc"t"[ct]letvue_type~locacc=ifacc.typesthenSome(jstyp~loc"t"[ptyp_constr~loc{txt=Lident"all";loc}[]])elseletfields=data_type_fields~locacc@prop_type_fields~locacc@computed_type_fields~locacc@method_type_fields~locaccinmatchfieldswith|[]->None|_->letct=ptyp_object~locfieldsClosedinSome(jstyp~loc"t"[ct])letall_types~locacc=pstr_class_type~loc@@List.map(fun(name,fields)->letname={txt=name;loc}inclass_infos~loc~virt:Concrete~params:[]~name~expr:(pcty_signature~loc@@class_signature~self:(ptyp_any~loc)~fields))["data",data_class_type_fields~locacc;"props",prop_class_type_fields~locacc;"computed",computed_class_type_fields~locacc;"methods",method_class_type_fields~locacc;"all",[pctf_inherit~loc(pcty_constr~loc{txt=Lident"data";loc}[]);pctf_inherit~loc(pcty_constr~loc{txt=Lident"props";loc}[]);pctf_inherit~loc(pcty_constr~loc{txt=Lident"computed";loc}[]);pctf_inherit~loc(pcty_constr~loc{txt=Lident"methods";loc}[])]]letrender~locs=ifnot(String.containss' ')&¬(Sys.file_exists!vue_compiler)then(Location.raise_errorf~loc"vue-compiler not found at path: %S"!vue_compiler)elseletic=Unix.open_process_in@@Filename.quote_command!vue_compiler[s]inletrecauxacc=trylets=input_lineicinaux(s::acc)with_->close_inic;String.concat"\n"@@List.revaccinletcode=String.trim@@aux[]inmatchUnix.close_process_inicwith|Unix.WEXITED0->jsapp~loc"Unsafe.pure_js_expr"[estring~loccode]|Unix.WEXITEDi|Unix.WSIGNALEDi|Unix.WSTOPPEDi->Location.raise_errorf~loc"render compilation failed with code %d"iletcheck_computede=matche.pexp_descwith|Pexp_fun(_,_,p,_)->Location.raise_errorf~loc:p.ppat_loc"'computed' have only one argument"|_->etypex=Xof(string*xlist)letrectype_namec=matchc.ptyp_descwith|Ptyp_constr({txt;_},l)->letrecauxacc=function|[]->Someacc|h::tl->matchtype_namehwith|None->None|Somex->aux(acc@[x])tlinbeginmatchaux[]lwith|None->None|Somel->Some(X(Longident.nametxt,l))end|_->Noneletcheck_watch~nameacce=matche.pexp_descwith|Pexp_fun(_,_,_,{pexp_desc=Pexp_fun(_,_,_,{pexp_desc=Pexp_fun(_,_,p,_);_});_})->Location.raise_errorf~loc:p.ppat_loc"'watch' have only 3 arguments"|Pexp_fun(_,_,p_new,{pexp_desc=Pexp_fun(_,_,p_old,elast);_})->letloc=e.pexp_locinbeginmatchp_new.ppat_desc,p_old.ppat_descwith|Ppat_constraint(_,c_new),Ppat_constraint(_,c_old)->iftype_namec_new=type_namec_oldtheneelseLocation.raise_errorf~loc:c_old.ptyp_loc"'watch' should have same types for new and old value"|Ppat_constraint(_,c_new),_->pexp_fun~locNolabelNonep_new(pexp_fun~locNolabelNone(ppat_constraint~locp_old{c_newwithptyp_loc=p_old.ppat_loc})elast)|_,Ppat_constraint(_,c_old)->pexp_fun~locNolabelNone(ppat_constraint~locp_new{c_oldwithptyp_loc=p_new.ppat_loc})(pexp_fun~locNolabelNonep_oldelast)|_->letc=matchList.find_opt(fun(k,_)->k=name)@@(List.map(fun(k,c,_,_)->k,c)acc.datas)@(List.map(funp->p.key,p.typ)acc.props)with|Some(_,Somec)->c|_->ptyp_var~loc(name^"_arg")inpexp_fun~locNolabelNone(ppat_constraint~locp_newc)(pexp_fun~locNolabelNone(ppat_constraint~locp_oldc)elast)end|_->Location.raise_errorf~loc:e.pexp_loc"'watch' needs 3 arguments (this, new, old)"letcheck_lifecyclee=matche.pexp_descwith|Pexp_fun(_,_,p,_)->Location.raise_errorf~loc:p.ppat_loc"'lifecycle' have only one argument"|Pexp_constraint(e,{ptyp_desc=Ptyp_constr({txt=Lident"unit";_},[]);_})->e|_->letloc=e.pexp_locinpexp_constraint~loce(ptyp_constr~loc{txt=Lident"unit";loc}[])letcheck_kindacce=function|None->e|Some`computed->check_computede|Some`watchname->check_watch~nameacce|Some`lifecycle->check_lifecycleeletrecwrap_method?this?kind?(pats=[])?(convert=false)?c~keyacce=letloc=e.pexp_locinmatche.pexp_desc,thiswith|Pexp_fun(_,_,p,e),None->letthis=get_str_patpinlete=check_kindaccekindinwrap_method~this~key~convert?cacce|Pexp_fun(_,_,p,e),Somethis->letp2=matchconvert,p.ppat_descwith|true,Ppat_constraint(p,c)->ppat_constraint~loc:p.ppat_locp(converted_typeacctruec)|_->pinpexp_fun~locNolabelNonep2(wrap_method~this~key~pats:(pats@[p])~convert?cacce)|_,Some_->letloc=e.pexp_locinletthis=jsapp~loc"Unsafe.coerce"[evar~loc"_this"]inletargs=List.map(funp->letloc=p.ppat_locinlete,c=matchp.ppat_descwith|Ppat_var{txt;_}->evar~loctxt,None|Ppat_any->evar~loc"_",None|Ppat_constraint({ppat_desc=Ppat_var{txt;_};_},c)->evar~loctxt,Somec|Ppat_constraint({ppat_desc=Ppat_any;_},c)->evar~loc"_",Somec|_->Location.raise_errorf~loc"pattern expected to be '_', a variable or a constraint of these patterns"inconverted_expr~of_:trueaccconvertce)patsinlete=eapply~loc(evar~lockey)(this::args)inconverted_expraccconvertce|_->Location.raise_errorf~loc"unexpected expression for method"letwrap_directivee=matche.pexp_descwith|Pexp_fun(_,_,_,{pexp_desc=Pexp_fun(_,_,_,{pexp_desc=Pexp_fun(_,_,p,_);_});_})->Location.raise_errorf~loc:p.ppat_loc"'directive' have only 2 arguments"|Pexp_fun(_,_,p_el,{pexp_desc=Pexp_fun(_,_,p_binding,elast);_})->letp_el=matchp_el.ppat_descwith|Ppat_constraint_->p_el|_->letloc=p_el.ppat_locinppat_constraint~locp_el(jstyp~loc"t"[domtyp~loc"element"[]])inletp_binding=matchp_binding.ppat_descwith|Ppat_constraint_->p_binding|_->letloc=p_binding.ppat_locinppat_constraint~locp_binding(jstyp~loc"t"[ptyp_constr~loc{txt=Longident.parse"Vue.binding";loc}[ptyp_any~loc]])inpexp_fun~loc:e.pexp_locNolabelNonep_el(pexp_fun~loc:e.pexp_locNolabelNonep_binding(pexp_constraint~loc:elast.pexp_locelast(ptyp_constr~loc:elast.pexp_loc{txt=Lident"unit";loc=elast.pexp_loc}[])))|_->Location.raise_errorf~loc:e.pexp_loc"'directive' needs 2 arguments (el, binding)"letprop_arg_type~locaccp=lettyp=Option.map(converted_typeaccp.convert)p.typinmatchtyp,p.conswith|None,None->jsid~loc"undefined",None,`unknown|_,Somecons->jsapp~loc"def"[cons],typ,`unknown|Somec,_->letc=remove_polycinletaux~optionalc=letconss=jsapp~loc"def"[pexp_constraint~loc(eapply~loc(evar~loc"(##.)")[jsid~loc"Unsafe.global";evar~locs])@@jstyp~loc"constr"[c]]inmatchc.ptyp_descwith|Ptyp_constr({txt;_},l)->beginmatchLongident.nametxtwith|"int"|"Int.t"->cons"_Number",Somec,(ifoptionalthen`optionalelse`not_optional)|"t"|"Js.t"|"Js_of_ocaml.Js.t"|"Ezjs_min.t"->beginmatchlwith|[{ptyp_desc=Ptyp_constr({txt;_},_);_}]->beginmatchLongident.last_exntxtwith|"number"->cons"_Number",Somec,(ifoptionalthen`optionalelse`not_optional)|"js_string"->cons"_String",Somec,(ifoptionalthen`optionalelse`not_optional)|"bool"|"Bool.t"->cons"_Boolean",Somec,(ifoptionalthen`optionalelse`not_optional)|"bigInt"->cons"_BigInt",Somec,(ifoptionalthen`optionalelse`not_optional)|_->cons"_Object",Somec,(ifoptionalthen`optionalelse`not_optional)end|_->cons"_Object",Somec,(ifoptionalthen`optionalelse`not_optional)end|_->jsid~loc"undefined",Somec,`unknownend|Ptyp_arrow_->cons"_Function",Somec,`unknown|_->jsid~loc"undefined",Somec,`unknowninmatchc.ptyp_descwith|Ptyp_constr({txt;_},[c2])->beginmatchLongident.last_exntxtwith|"optdef"->aux~optional:truec2|_->aux~optional:falsecend|_->aux~optional:falsecletprop_arg_requiredp=matchp.req,p.typwith|true,_->true|_,None->false|_,Some{ptyp_desc=Ptyp_constr({txt;_},_);_}->(matchLongident.last_exntxtwith"optdef"->false|_->true)|_->trueletprop_arg~locaccp=lett,c,opt=prop_arg_type~locaccpinletdft=matchp.dft,optwith|None,_->jsid~loc"undefined"|Somee,(`unknown|`not_optional)->jsapp~loc"def"[converted_expraccp.convertp.type]|Somee,`optional->converted_expraccp.convertp.typeinletc=Option.value~default:(ptyp_any~loc)cin[%expr(object%jsvaltype_=[%et]valrequired=[%eifp.reqthenjsapp~loc"def"[jsid~loc"_true"]elsejsid~loc"undefined"]valdefault=[%edft]valvalidator=[%ematchp.validatorwithNone->jsid~loc"undefined"|Somee->jsapp~loc"def"[e]]end:[%tjstyp~loc"t"[[%type:[%tc]Vue.prop_arg]]])]letcreate_arg~loc?optionsacc=letauxfields=letcs=class_structure~self:(pvar~loc"_this")~fieldsinpexp_extension~loc({txt="js";loc},PStr[pstr_eval~loc(pexp_object~loccs)[]])inletdatas=letfields=List.map(fun(key,c,e,convert)->lete=matche.pexp_descwith|Pexp_fun_->wrap_method~convert?c~keyacce|_->converted_expraccconvertceinpcf_val~loc({txt=field_namekey;loc},Mutable,Cfk_concrete(Fresh,e)))acc.datasinpcf_method~loc({txt="data";loc},Public,Cfk_concrete(Fresh,auxfields))inletmethods=matchacc.methodswith|[]->jsid~loc"undefined"|_->letfields=List.map(fun(key,c,e,convert)->pcf_method~loc({txt=field_namekey;loc},Public,Cfk_concrete(Fresh,wrap_method~key~convert?cacce)))acc.methodsinjsapp~loc"def"[auxfields]inletmethods=pcf_val~loc({txt="methods";loc},Immutable,Cfk_concrete(Fresh,methods))inletcomputeds=matchacc.computedswith|[]->jsid~loc"undefined"|_->letfields=List.map(fun(key,c,e,convert)->pcf_method~loc({txt=field_namekey;loc},Public,Cfk_concrete(Fresh,wrap_method~kind:`computed~key~convert?cacce)))acc.computedsinjsapp~loc"def"[auxfields]inletcomputeds=pcf_val~loc({txt="computed";loc},Immutable,Cfk_concrete(Fresh,computeds))inletwatchs=matchacc.watchswith|[]->jsid~loc"undefined"|_->letfields=List.map(fun(key,c,e,convert)->pcf_method~loc({txt=field_namekey;loc},Public,Cfk_concrete(Fresh,wrap_method~kind:(`watchkey)~key~convert?cacce)))acc.watchsinjsapp~loc"def"[auxfields]inletwatchs=pcf_val~loc({txt="watch";loc},Immutable,Cfk_concrete(Fresh,watchs))inletprops=matchacc.propswith|[]->jsid~loc"undefined"|_->letfields=List.map(funp->pcf_val~loc({txt=field_namep.key;loc},Immutable,Cfk_concrete(Fresh,prop_arg~locaccp)))acc.propsinjsapp~loc"def"[auxfields]inletprops=pcf_val~loc({txt="props";loc},Immutable,Cfk_concrete(Fresh,props))inletdirectives=matchacc.directiveswith|[]->jsid~loc"undefined"|_->letfields=List.map(funkey->pcf_method~loc({txt=field_namekey;loc},Public,Cfk_concrete(Fresh,evar~lockey)))acc.directivesinjsapp~loc"def"[auxfields]inletdirectives=pcf_val~loc({txt="directives";loc},Immutable,Cfk_concrete(Fresh,directives))inlettemplate,render=matchacc.template,acc.compilewith|None,_->jsid~loc"undefined",jsid~loc"undefined"|Some(`strings),false->jsapp~loc"def"[eapply~loc(jsid~loc"string")[estring~locs]],jsid~loc"undefined"|Some(`expressione),_->jsapp~loc"def"[e],jsid~loc"undefined"|Some(`strings),true->jsid~loc"undefined",jsapp~loc"def"[render~locs]inlettemplate=pcf_val~loc({txt="template";loc},Immutable,Cfk_concrete(Fresh,template))inletrender=pcf_val~loc({txt="render";loc},Immutable,Cfk_concrete(Fresh,render))inletemits=matchacc.emitswith|[]->jsid~loc"undefined"|_->jsapp~loc"def"[jsapp~loc"array"[pexp_array~loc@@List.map(funs->jsapp~loc"string"[estring~locs])acc.emits]]inletemits=pcf_val~loc({txt="emits";loc},Immutable,Cfk_concrete(Fresh,emits))inletlifecycle=List.map(fun(key,e)->pcf_method~loc({txt=key;loc},Public,Cfk_concrete(Fresh,wrap_method~kind:`lifecycle~keyacce)))acc.lifecycleinletaux_componenteacc=matche.pexp_descwith|Pexp_construct({txt;_},None)->acc@[Longident.last_exntxt,evar~loc(Longident.nametxt^".component")]|Pexp_ident{txt;_}->acc@[Longident.last_exntxt,e]|Pexp_tuple[{pexp_desc=Pexp_constantPconst_string(txt,_,_);_};e]->acc@[txt,e]|_->accinletrecaux_listeacc=matche.pexp_descwith|Pexp_construct({txt=Lident"[]";_},None)->acc|Pexp_construct({txt=Lident"::";_},Some{pexp_desc=Pexp_tuple[e1;e2];_})->aux_componente1(aux_liste2acc)|_->accinletcomponents,debug,name=matchoptionswith|None->jsid~loc"undefined",false,None|Someoptions->letl,debug,name=List.fold_left(fun(cos,dbg,n)({txt;_},e)->matchLongident.nametxt,e.pexp_descwith|"components",_->(aux_liste[]),dbg,n|"debug",_->cos,true,n|"name",Pexp_constantPconst_string(s,_,_)->cos,dbg,Somes|_->cos,dbg,n)([],false,None)optionsinmatchlwith|[]->jsid~loc"undefined",debug,name|_->letfields=List.map(fun(k,e)->lete2=[%expr[%ejsid~loc"Unsafe.meth_call"]([%ejsid~loc"Unsafe.global"]##._Vue)"defineComponent"[|[%ejsid~loc"Unsafe.inject"][%ee]|]]in[%expr(Option.fold~none:[%eestring~loc(field_namek)]~some:[%ejsid~loc"to_string"]([%ejsid~loc"Optdef.to_option"][%ee]##.name)),[%ejsid~loc"Unsafe.inject"][%ee2]])lin[%expr[%ejsid~loc"def"]([%ejsid~loc"Unsafe.obj"][%epexp_array~locfields])],debug,nameinletname=matchacc.name,namewith|_,Somes|Somes,_->jsapp~loc"def"[jsapp~loc"string"[estring~loc(kebabs)]]|_->jsid~loc"undefined"inletname=pcf_val~loc({txt="name";loc},Immutable,Cfk_concrete(Fresh,name))inletcomponents=pcf_val~loc({txt="components";loc},Immutable,Cfk_concrete(Fresh,components))inletfields=[datas;methods;computeds;watchs;props;directives;template;render;emits;name;components]@lifecycleinletcreate_arg=class_structure~self:(pvar~loc"_this")~fieldsinlete=pexp_extension~loc({txt="js";loc},PStr[pstr_eval~loc(pexp_object~loccreate_arg)[]])inifdebugthenFormat.eprintf"%s@."@@Pprintast.string_of_expressione;eletcreate_app~locaccoptions=letaux_componenteeafter=letexpr=matche.pexp_descwith|Pexp_construct({txt;_},None)->[%exprVue.component_app[%eevar~loc(Longident.nametxt^".component")]]|Pexp_tuple[{pexp_desc=Pexp_constantPconst_string(txt,_,_);_};e]->[%exprVue.component~name:[%eestring~loctxt]_app[%ee]]|_->[%exprVue.component_app[%ee]]inpexp_let~locNonrecursive[value_binding~loc~pat:(pvar~loc"_app")~expr]eafterinletrecaux_listeeafter=matche.pexp_descwith|Pexp_construct({txt=Lident"[]";_},None)->eafter|Pexp_construct({txt=Lident"::";_},Some{pexp_desc=Pexp_tuple[e1;e2];_})->aux_componente1(aux_liste2eafter)|_->eafterinletcomponents,mount,id,unhide,export,plugins=List.fold_left(fun(cos,mo,id,uh,ex,pl)({txt;_},e)->matchLongident.nametxt,e.pexp_descwith|"mount",Pexp_constantPconst_string(s,_,_)->cos,true,s,uh,ex,pl|"mount",_->cos,true,id,uh,ex,pl|"components",_->(aux_liste),mo,id,uh,ex,pl|"id",Pexp_constantPconst_string(s,_,_)->cos,mo,s,uh,ex,pl|"unhide",Pexp_constantPconst_string(s,_,_)->cos,mo,s,true,ex,pl|"unhide",_->cos,mo,id,true,ex,pl|"export",Pexp_constantPconst_string(s,_,_)->cos,mo,s,uh,true,pl|"export",_->cos,mo,id,uh,true,pl|"plugins",_->cos,mo,id,uh,ex,get_list_expressione|_->cos,mo,id,uh,ex,pl)(Fun.id,false,"app",false,false,[])optionsinletarg=create_arg~locaccinletrecgloballeafter=matchlwith|(k,_,e,_)::tl->letexp=globaltleafterinlete=[%exprVue.set_global_app[%eestring~lock][%ee]]inpexp_sequence~loceexp|[]->eafterinlettyp=app_type~locaccinletrecuseleafter=matchlwith|[]->eafter|p::tl->lete=usetleafterinletexpr=[%exprVue.use_app[%ejsapp~loc"Unsafe.inject"[p]]]inpexp_let~locNonrecursive[value_binding~loc~pat:(pvar~loc"_app")~expr]einletmounteafter=ifmountthenpexp_let~locNonrecursive[value_binding~loc~pat:(pvar~loc"_app")~expr:[%exprVue.mount~id:[%eestring~locid]_app]]eafterelseeafterinletexporteafter=ifexportthenpexp_sequence~loc(jsapp~loc"export"[estring~locid;evar~loc"_app"])eafterelseeafterinletunhideeafter=ifunhidethen[%expr(match[%edomid~loc"getElementById_opt"][%eestring~locid]with|None->()|Someapp->app##.style##.display:=string"block");(match[%edomid~loc"getElementById_opt"]([%eestring~locid]^"-loading")with|None->()|Someloading->loading##.style##.display:=string"none");[%eeafter]]elseeafterinlete=[%exprlet_app:[%ttyp]=Vue.create_app(Some[%earg])in[%euseplugins@@globalacc.globals@@components@@mount@@unhide@@export[%expr_app]]]inifacc.debugthenFormat.eprintf"%s@."(Pprintast.string_of_expressione);eletinfer_typee=letloc=e.pexp_locinmatche.pexp_descwith|Pexp_constantPconst_string_->Some(ptyp_constr~loc{txt=Lident"string";loc}[])|Pexp_constantPconst_integer(_,Some'l')->Some(ptyp_constr~loc{txt=Lident"int32";loc}[])|Pexp_constantPconst_integer(_,Some'L')->Some(ptyp_constr~loc{txt=Lident"int64";loc}[])|Pexp_constantPconst_integer(_,Some'n')->Some(ptyp_constr~loc{txt=Lident"nativeint";loc}[])|Pexp_constantPconst_float_->Some(ptyp_constr~loc{txt=Lident"float";loc}[])|Pexp_constantPconst_char_->Some(ptyp_constr~loc{txt=Lident"char";loc}[])|Pexp_construct({txt=Lident("true"|"false");_},None)->Some(ptyp_constr~loc{txt=Lident"bool";loc}[])|_->Noneletrecadd_global?(convert=false)acc=function|vb::tl->letkey=get_str_patvb.pvb_patinletconv=convert&¬(List.exists(funa->a.attr_name.txt="noconv"||a.attr_name.txt="noconvert")vb.pvb_attributes)inlettyp=Option.fold~none:(infer_typevb.pvb_expr)~some:Option.some@@get_exit_typevb.pvb_exprinadd_global~convert{accwithglobals=(key,typ,vb.pvb_expr,conv)::acc.globals}tl|[]->{accwithglobals=List.revacc.globals}letrecadd_data?(convert=false)acc=function|vb::tl->letkey=get_str_patvb.pvb_patinletconv=convert&¬(List.exists(funa->a.attr_name.txt="noconv"||a.attr_name.txt="noconvert")vb.pvb_attributes)inlettyp=Option.fold~none:(infer_typevb.pvb_expr)~some:Option.some@@get_exit_typevb.pvb_exprinadd_data~convert{accwithdatas=(key,typ,vb.pvb_expr,conv)::acc.datas}tl|[]->{accwithdatas=List.revacc.datas}letrecadd_method?(convert=false)acc=function|vb::tl->letkey=get_str_patvb.pvb_patinletconv=convert&¬(List.exists(funa->a.attr_name.txt="noconv"||a.attr_name.txt="noconvert")vb.pvb_attributes)inlettyp=get_exit_typevb.pvb_exprinadd_method~convert{accwithmethods=(key,typ,vb.pvb_expr,conv)::acc.methods}tl|[]->{accwithmethods=List.revacc.methods}letrecadd_computed?(convert=false)acc=function|vb::tl->letkey=get_str_patvb.pvb_patinletconv=convert&¬(List.exists(funa->a.attr_name.txt="noconv"||a.attr_name.txt="noconvert")vb.pvb_attributes)inlettyp=get_exit_typevb.pvb_exprinadd_computed~convert{accwithcomputeds=(key,typ,vb.pvb_expr,conv)::acc.computeds}tl|[]->{accwithcomputeds=List.revacc.computeds}letrecadd_watch?(convert=false)acc=function|vb::tl->letkey=get_str_patvb.pvb_patinletconv=convert&¬(List.exists(funa->a.attr_name.txt="noconv"||a.attr_name.txt="noconvert")vb.pvb_attributes)inlettyp=get_exit_typevb.pvb_exprinadd_watch~convert{accwithwatchs=(key,typ,vb.pvb_expr,conv)::acc.watchs}tl|[]->{accwithwatchs=List.revacc.watchs}letrecadd_directive?(convert=false)acc=function|vb::tl->letkey=get_str_patvb.pvb_patinadd_directive~convert{accwithdirectives=key::acc.directives}tl|[]->{accwithdirectives=List.revacc.directives}letrecadd_prop?(convert=false)acc=function|vb::tl->letkey=get_str_patvb.pvb_patinlettyp=Option.fold~none:(infer_typevb.pvb_expr)~some:Option.some@@get_exit_typevb.pvb_exprinletconv=convert&¬(List.exists(funa->a.attr_name.txt="noconv"||a.attr_name.txt="noconvert")vb.pvb_attributes)inletp={key;typ;cons=None;validator=None;dft=None;req=false;convert=conv}inletaux_dfte=matche.pexp_descwith|Pexp_ident{txt;_}->beginmatchLongident.last_exntxtwith|"undefined"->None|_->Someeend|Pexp_construct({txt=Lident"None";_},_)->None|_->Someeinletp=matchvb.pvb_expr.pexp_descwith|Pexp_record(l,_)|Pexp_constraint({pexp_desc=Pexp_record(l,_);_},_)->List.fold_left(funp({txt;_},e)->matchLongident.last_exntxtwith|"cons"|"type"->{pwithcons=Somee}|"req"|"required"->{pwithreq=true}|"dft"|"default"->{pwithdft=Somee}|"validator"->{pwithvalidator=Somee}|_->p)pl|Pexp_construct({txt=Lident"()";_},None)|Pexp_constraint({pexp_desc=Pexp_construct({txt=Lident"()";_},None);_},_)->p|Pexp_constraint(e,_)->{pwithdft=aux_dfte}|_->{pwithdft=aux_dftvb.pvb_expr}inadd_prop~convert{accwithprops=p::acc.props}tl|[]->{accwithprops=List.revacc.props}letadd_lifecycle~nameacce={accwithlifecycle=acc.lifecycle@[name,e]}letadd_emit~nameacc={accwithemits=acc.emits@[name]}lettrim_htmls=letl=String.split_on_char'\n'sinmatchlwith|""::s::_|s::_->leti,_=String.fold_left(fun(i,stop)c->ifstopthen(i,stop)elseifc=' 'then(i+1,false)else(i,true))(0,false)sinletl=List.map(funs->ifString.lengths>ithenString.subsi(String.lengths-i)elses)linString.trim@@String.concat"\n"l|_->sletwrap_thisacce=matche.pexp_desc,vue_type~loc:e.pexp_locaccwith|_,None->e|Pexp_fun(_,_,{ppat_desc=Ppat_constraint(p,_);_},e),Somec|Pexp_fun(_,_,p,e),Somec->pexp_fun~loc:e.pexp_locNolabelNone(ppat_constraint~loc:p.ppat_locpc)e|_->eletinstance_attrs~locacckeye=letfields=matchkeywith|"data"->data_type_fields~locacc|"props"->prop_type_fields~locacc|_->[]inlett,key,e,f=matchfields,key,e.pexp_descwith|_::_,_,_->letct=ptyp_object~locfieldsClosedinSome(jstyp~loc"t"[ct]),key,e,Fun.id|_,"el",_->Some(jstyp~loc"optdef"[jstyp~loc"t"[domtyp~loc"element"[]]]),key,e,Fun.id|_,"ref",Pexp_apply(e,[_,{pexp_desc=Pexp_constantPconst_string(s,_,_);_}])->Some(jstyp~loc"optdef"[jstyp~loc"t"[domtyp~loc"element"[]]]),"refs",e,(fune->jsapp~loc"Unsafe.get"[e;jsapp~loc"string"[estring~locs]])|_->None,key,e,Fun.idinlete=f@@jsapp~loc"Unsafe.get"[e;jsapp~loc"string"[estring~loc("$"^key)]]inmatchtwith|None->e|Somet->pexp_constraint~locetletdo_convertl=List.exists(funpv->List.exists(funa->a.attr_name.txt="conv"||a.attr_name.txt="convert")pv.pvb_attributes)lletconvert_all_and_modules_auxl=letconvert_all=List.exists(fun({txt;_},_)->txt=Lident"convert"||txt=Lident"conv")linletmodules=List.find_map(function|({txt=Lident"modules";_},e)->letl=get_list_expressioneinletl=List.filter_map(fune->matche.pexp_descwith|Pexp_tuple[{pexp_desc=Pexp_construct({txt=m1;_},_);_};{pexp_desc=Pexp_construct({txt=m2;_},_);_}]->Some(Longident.namem1,Longident.namem2)|_->None)linSomel|_->None)linconvert_all,modulesletconvert_all_and_modules=object(_self)inherit[acc]Ast_traverse.foldassupermethod!structure_itemitacc=matchit.pstr_descwith|Pstr_extension(({txt=("app"|"vue.app"|"comp"|"vue.comp"|"component"|"vue.component");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}]),_)->letconvert_all,modules=convert_all_and_modules_auxlin{accwithconvert_all;modules}|_->super#structure_itemitaccmethod!expressioneacc=matche.pexp_descwith|Pexp_extension({txt=("app"|"vue.app"|"component"|"vue.component");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}])->letconvert_all,modules=convert_all_and_modules_auxlin{accwithconvert_all;modules}|_->super#expressioneaccendletast_fold=object(self)inherit[acc]Ast_traverse.foldassupermethod!expressioneacc=matche.pexp_descwith|Pexp_extension({txt=("global"|"glob"|"vue.global"|"vue.glob");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,l,elast);_},_);_}])->letacc=add_global~convert:(acc.convert_all||do_convertl)acclinletacc=List.fold_left(funaccvb->self#value_bindingvbacc)acclinself#expressionelastacc|Pexp_extension({txt=("data"|"vue.data");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,l,elast);_},_);_}])->letacc=add_data~convert:(acc.convert_all||do_convertl)acclinletacc=List.fold_left(funaccvb->self#value_bindingvbacc)acclinself#expressionelastacc|Pexp_extension({txt=("meth"|"method"|"vue.meth"|"vue.method");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,l,elast);_},_);_}])->letacc=add_method~convert:(acc.convert_all||do_convertl)acclinletacc=List.fold_left(funaccvb->self#value_bindingvbacc)acclinself#expressionelastacc|Pexp_extension({txt=("computed"|"comp"|"vue.computed"|"vue.comp");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,l,elast);_},_);_}])->letacc=add_computed~convert:(acc.convert_all||do_convertl)acclinletacc=List.fold_left(funaccvb->self#value_bindingvbacc)acclinself#expressionelastacc|Pexp_extension({txt=("watch"|"vue.watch");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,l,elast);_},_);_}])->letacc=add_watch~convert:(acc.convert_all||do_convertl)acclinletacc=List.fold_left(funaccvb->self#value_bindingvbacc)acclinself#expressionelastacc|Pexp_extension({txt=("dir"|"vue.dir"|"directive"|"vue.directive");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,l,elast);_},_);_}])->letacc=add_directive~convert:(acc.convert_all||do_convertl)acclinletacc=List.fold_left(funaccvb->self#value_bindingvbacc)acclinself#expressionelastacc|Pexp_extension({txt=("prop"|"vue.prop");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,l,elast);_},_);_}])->letacc=add_prop~convert:(acc.convert_all||do_convertl)acclinself#expressionelastacc|Pexp_extension({txt=("template"|"vue.template"|"render"|"vue.render"astxt);_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,[{pvb_expr={pexp_desc=Pexp_constantPconst_string(tpl,_,_);_};_}],elast);_},_);_}])->lettemplate=Some(`stringtpl)inletcompile=txt="render"||txt="vue.render"||!vue_compileinself#expressionelast{accwithcompile;template}|Pexp_extension({txt=("template"|"vue.template");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,[vb],elast);_},_);_}])->letloc=vb.pvb_expr.pexp_locinlettemplate=Some(`expression(pexp_constraint~locvb.pvb_expr(jstyp~loc"t"[jstyp~loc"js_string"[]])))inself#expressionelast{accwithtemplate}|Pexp_extension({txt=("emit"|"vue.emit");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_apply({pexp_desc=Pexp_constantPconst_string(name,_,_);_},_);_},_);_}])->add_emit~nameacc|Pexp_extension({txt=("app"|"vue.app"|"component"|"vue.component");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}])->lettypes=List.exists(fun({txt;_},_)->txt=Lident"types")linletdebug=List.exists(fun({txt;_},_)->txt=Lident"debug")lin{accwithtypes;debug}|_->super#expressioneaccmethod!structure_itemitacc=matchit.pstr_descwith|Pstr_extension(({txt=("global"|"glob"|"vue.global"|"vue.glob");_},PStr[{pstr_desc=Pstr_value(_,l);_}]),_)->letacc=add_global~convert:(acc.convert_all||do_convertl)acclinList.fold_left(funaccvb->self#value_bindingvbacc)accl|Pstr_extension(({txt=("data"|"vue.data");_},PStr[{pstr_desc=Pstr_value(_,l);_}]),_)->letacc=add_data~convert:(acc.convert_all||do_convertl)acclinList.fold_left(funaccvb->self#value_bindingvbacc)accl|Pstr_extension(({txt=("meth"|"method"|"vue.meth"|"vue.method");_},PStr[{pstr_desc=Pstr_value(_,l);_}]),_)->letacc=add_method~convert:(acc.convert_all||do_convertl)acclinList.fold_left(funaccvb->self#value_bindingvbacc)accl|Pstr_extension(({txt=("computed"|"comp"|"vue.computed"|"vue.comp");_},PStr[{pstr_desc=Pstr_value(_,l);_}]),_)->letacc=add_computed~convert:(acc.convert_all||do_convertl)acclinList.fold_left(funaccvb->self#value_bindingvbacc)accl|Pstr_extension(({txt=("watch"|"vue.watch");_},PStr[{pstr_desc=Pstr_value(_,l);_}]),_)->letacc=add_watch~convert:(acc.convert_all||do_convertl)acclinList.fold_left(funaccvb->self#value_bindingvbacc)accl|Pstr_extension(({txt=("dir"|"vue.dir"|"directive"|"vue.directive");_},PStr[{pstr_desc=Pstr_value(_,l);_}]),_)->letacc=add_directive~convert:(acc.convert_all||do_convertl)acclinList.fold_left(funaccvb->self#value_bindingvbacc)accl|Pstr_extension(({txt=("prop"|"vue.prop");_},PStr[{pstr_desc=Pstr_value(_,l);_}]),_)->letacc=add_prop~convert:(acc.convert_all||do_convertl)acclinList.fold_left(funaccvb->self#value_bindingvbacc)accl|Pstr_extension(({txt=("template"|"vue.template"|"render"|"vue.render"astxt);_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constantPconst_string(tpl,_,_);_},_);_}]),_)|Pstr_extension(({txt=("template"|"vue.template"|"render"|"vue.render"astxt);_},PStr[{pstr_desc=Pstr_value(_,[{pvb_expr={pexp_desc=Pexp_constantPconst_string(tpl,_,_);_};_}]);_}]),_)->lettemplate=Some(`string(trim_htmltpl))inletcompile=txt="render"||txt="vue.render"||!vue_compilein{accwithcompile;template}|Pstr_extension(({txt=("template"|"vue.template");_},PStr[{pstr_desc=Pstr_value(_,[vb]);_}]),_)->letloc=vb.pvb_expr.pexp_locin{accwithtemplate=Some(`expression(pexp_constraint~locvb.pvb_expr(jstyp~loc"t"[jstyp~loc"js_string"[]])))}|Pstr_extension(({txt;_},PStr[{pstr_desc=Pstr_value(_,[vb]);_}]),_)whenList.memtxthooks->letacc=add_lifecycle~name:txtaccvb.pvb_exprinself#value_bindingvbacc|Pstr_extension(({txt;_},PStr[{pstr_desc=Pstr_eval(e,_);_}]),_)whenList.memtxthooks->letacc=add_lifecycle~name:txtacceinself#expressioneacc|Pstr_extension(({txt=("app"|"vue.app"|"comp"|"vue.comp"|"component"|"vue.component");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}]),_)->lettypes=List.exists(fun({txt;_},_)->txt=Lident"types")linletdebug=List.exists(fun({txt;_},_)->txt=Lident"debug")lin{accwithtypes;debug}|Pstr_module_->acc|_->super#structure_itemitaccmethod!structuresacc=letacc2=convert_all_and_modules#structuresaccinList.fold_left(funaccit->self#structure_itemitacc)acc2sendletnext_expr~locaccthisf=lettunit~loc=ptyp_constr~loc{txt=Lident"unit";loc}[]inletf=matchf.pexp_descwith|Pexp_fun(_,_,({ppat_desc=Ppat_constraint_;_}asp),e)->pexp_fun~loc:f.pexp_locNolabelNonep(pexp_constraint~loce(tunit~loc:e.pexp_loc))|Pexp_fun(_,_,p,e)->beginmatchvue_type~loc:p.ppat_locaccwith|None->pexp_fun~loc:e.pexp_locNolabelNonep(pexp_constraint~loce(tunit~loc:e.pexp_loc))|Somec->pexp_fun~loc:e.pexp_locNolabelNone(ppat_constraint~loc:p.ppat_locpc)(pexp_constraint~loce(tunit~loc:e.pexp_loc))end|_->letloc=f.pexp_locinbeginmatchvue_type~locaccwith|None->f|Somec->pexp_fun~locNolabelNone(ppat_constraint~loc(pvar~loc"_x")c)(pexp_constraint~loc(eapply~locf[evar~loc"_x"])(tunit~loc))endinletexpr=[%expr[%ejsid~loc"Unsafe.meth_call"][%ethis]"$nextTick"[|[%ejsid~loc"Unsafe.inject"]([%ejsid~loc"wrap_meth_callback"](fun_this()->[%ef]_this))|]]inpexp_constraint~locexpr(ptyp_constr~loc{txt=Lident"unit";loc}[]),accletast_map=object(self)inherit[acc]Ast_traverse.fold_mapassupermethod!expressioneacc=matche.pexp_descwith|Pexp_extension({txt=("global"|"glob"|"vue.global"|"vue.glob"|"data"|"vue.data"|"template"|"vue.template"|"render"|"vue.render"|"prop"|"vue.prop");_},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_let(_,_,elast);_},_);_}])->self#expressionelastacc|Pexp_extension({txt=("meth"|"method"|"vue.meth"|"vue.method"|"computed"|"comp"|"vue.computed"|"vue.comp"|"watch"|"vue.watch");_},PStr[{pstr_desc=Pstr_eval(e,_);_}])->lete=wrap_thisacceinself#expressioneacc|Pexp_extension({txt=("dir"|"vue.dir"|"directive"|"vue.directive");_},PStr[{pstr_desc=Pstr_eval(e,_);_}])->lete=wrap_directiveeinself#expressioneacc|Pexp_extension({txt=("emit"|"vue.emit");loc},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_apply({pexp_desc=Pexp_constantPconst_string(name,_,_);_},l);_},_);_}])->lete=matchlwith|(_,this)::args->letargs=(jsapp~loc"string"[estring~locname])::List.mapsndargsinjsapp~loc"Unsafe.meth_call"[this;(estring~loc"$emit");pexp_array~loc(List.map(fune->jsapp~loc"Unsafe.inject"[e])args)]|_->Location.raise_errorf~loc"missing instance argument for 'emit'"inself#expressioneacc|Pexp_extension({txt;loc},PStr[{pstr_desc=Pstr_eval(e,_);_}])whenList.memtxtinstances->instance_attrs~locacctxte,acc|Pexp_extension({txt=("update"|"vue.update");loc},PStr[{pstr_desc=Pstr_eval(this,_);_}])->letexpr=jsapp~loc"Unsafe.meth_call"[this;(estring~loc"$forceUpdate");pexp_array~loc[]]inpexp_constraint~locexpr(ptyp_constr~loc{txt=Lident"unit";loc}[]),acc|Pexp_extension({txt=("next"|"vue.next");loc},PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_apply(this,[_,f]);_},_);_}])->letf,_=self#expressionfaccinnext_expr~locaccthisf|Pexp_extension({txt=("app"|"vue.app");loc},PStrl)->letoptions=matchlwith|[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}]->l|_->[]increate_app~locaccoptions,acc|Pexp_extension({txt=("component"|"vue.component"|"comp"|"vue.comp");loc},PStrl)->letoptions=matchlwith|[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}]->l|_->[]increate_arg~loc~optionsacc,acc|_->super#expressioneaccmethod!value_bindingvbacc=letloc=vb.pvb_locinmatchvb.pvb_expr.pexp_descwith|Pexp_extension({txt=("app"|"vue.app");_},PStrl)->letoptions=matchlwith|[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}]->l|_->[]inletpvb_expr=create_app~locaccoptionsin{vbwithpvb_expr},acc|Pexp_extension({txt=("component"|"vue.component");_},PStrl)->letoptions=matchlwith|[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}]->l|_->[]inletpvb_expr=create_arg~loc~optionsaccin{vbwithpvb_expr},acc|_->super#value_bindingvbaccmethod!structuresacc_old=letacc=ast_fold#structures{empty_accwithname=acc_old.name}inlets=List.fold_left(funsit->matchit.pstr_descwith|Pstr_extension(({txt=("global"|"glob"|"vue.global"|"vue.glob"|"prop"|"vue.prop"|"template"|"vue.template"|"render"|"vue.render");_},PStr[{pstr_desc=Pstr_value(_,_);_}]),_)->s|Pstr_extension(({txt=("meth"|"method"|"vue.meth"|"vue.method"|"computed"|"comp"|"vue.computed"|"vue.comp"|"watch"|"vue.watch");_},PStr[{pstr_desc=Pstr_value(rec_flag,l);pstr_loc;_}]),_)->letl=List.map(funvb->letpvb_expr=wrap_thisaccvb.pvb_exprinfst@@self#value_binding{vbwithpvb_expr}acc)lins@[pstr_value~loc:pstr_locrec_flagl]|Pstr_extension(({txt=("dir"|"vue.dir"|"directive"|"vue.directive");_},PStr[{pstr_desc=Pstr_value(rec_flag,l);pstr_loc;_}]),_)->letl=List.map(funvb->letpvb_expr=wrap_directivevb.pvb_exprinfst@@self#value_binding{vbwithpvb_expr}acc)lins@[pstr_value~loc:pstr_locrec_flagl]|Pstr_extension(({txt=("data"|"vue.data");_},PStr[{pstr_desc=Pstr_value(rec_flag,l);pstr_loc;_}]),_)->letl=List.filter_map(funvb->matchvb.pvb_expr.pexp_descwith|Pexp_fun_->letpvb_expr=wrap_thisaccvb.pvb_exprinSome(fst@@self#value_binding{vbwithpvb_expr}acc)|_->None)linbeginmatchlwith|[]->s|_->s@[pstr_value~loc:pstr_locrec_flagl]end|Pstr_extension(({txt=("template"|"vue.template"|"render"|"vue.render");_},PStr[{pstr_desc=Pstr_eval(_,_);_}]),_)->s|Pstr_extension(({txt;_},PStr[{pstr_desc=Pstr_value(rec_flag,[vb]);pstr_loc;_}]),_)whenList.memtxthooks->letpvb_expr=wrap_thisaccvb.pvb_exprins@[pstr_value~loc:pstr_locrec_flag[fst@@self#value_binding{vbwithpvb_expr}acc]]|Pstr_extension(({txt;loc},PStr[{pstr_desc=Pstr_eval(e,_);_}]),_)whenList.memtxthooks->lete=wrap_thisacceinletexpr=fst@@self#expressioneaccins@[pstr_value~loc:e.pexp_locNonrecursive[value_binding~loc:e.pexp_loc~pat:(pvar~loctxt)~expr]]|Pstr_module{pmb_name={txt=Somemodu;loc};pmb_expr={pmod_desc=Pmod_structurest;_};_}->letit=pstr_module~loc@@module_binding~loc~name:{txt=Somemodu;loc}~expr:(pmod_structure~loc(fst@@self#structurest{empty_accwithname=Somemodu}))ins@[it]|Pstr_extension(({txt=("app"|"vue.app");loc},PStrl),_)->letoptions=matchlwith|[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}]->l|_->[]inletexpr=create_app~locaccoptionsins@[pstr_value~locNonrecursive[value_binding~loc~pat:(pvar~loc"_app")~expr]]|Pstr_extension(({txt=("comp"|"vue.comp"|"component"|"vue.component");loc},PStrl),_)->letoptions=matchlwith|[{pstr_desc=Pstr_eval({pexp_desc=Pexp_record(l,_);_},_);_}]->l|_->[]inletexpr=create_arg~loc~optionsaccins@[pstr_value~locNonrecursive[value_binding~loc~pat:(pvar~loc"component")~expr]]|_->letit=fst@@super#structure_itemitaccins@[it])[]sinlets=matchs,acc.typeswith|h::_,true->lettypes=all_types~loc:h.pstr_locaccinletrecaux=function|({pstr_desc=(Pstr_type_|Pstr_module_|Pstr_modtype_|Pstr_open_|Pstr_class_type_|Pstr_include_);_}asit)::tl->it::auxtl|l->types::linauxs|_->sins,acc_oldendlet()=Driver.register_transformation"vue"~impl:(funs->lets=fst@@ast_map#structuresempty_accinif!vue_debugthenFormat.eprintf"%s@."(Pprintast.string_of_structures);s)